diff --git a/gulliver/system/class.headPublisher.php b/gulliver/system/class.headPublisher.php index b857d5788..a098722e1 100644 --- a/gulliver/system/class.headPublisher.php +++ b/gulliver/system/class.headPublisher.php @@ -1,701 +1,707 @@ -. - * - * For more information, contact Colosa Inc, 2566 Le Jeune Rd., - * Coral Gables, FL, 33134, USA, or email info@colosa.com. - * - */ -/** - * Class headPublisher - * - * @author David S. Callizaya S. - * @package gulliver.system - * @access public - */ -class headPublisher -{ - private static $instance = null; - var $maborakFiles = array (); - var $maborakLoaderFiles = array (); - var $scriptFiles = array (); - var $leimnudLoad = array (); - - /* extJsSkin init coreLoad flag*/ - var $extJsInit = 'false'; - - /* extJsSkin store the current skin for the ExtJs*/ - var $extJsSkin = ''; - - /* extJsScript Array, to store the file to be include */ - var $extJsScript = array (); - - /* extJsLibrary Array, to store extended ExtJs lybraries */ - var $extJsLibrary = array (); - - /* extJsContent Array, to store the file to be include in the skin content */ - var $extJsContent = array (); - - /* extVariable array, to store the variables generated in PHP, and used in JavaScript */ - var $extVariable = array (); - - /* variable array, to store the variables generated in PHP, and used in JavaScript */ - var $vars = array (); - - /* tplVariable array, to store the variables for template power */ - var $tplVariable = array (); - - var $leimnudInitString = ' var leimnud = new maborak(); - leimnud.make({ - zip:true, - inGulliver:true, - modules :"dom,abbr,rpc,drag,drop,app,panel,fx,grid,xmlform,validator,dashboard", - files :"" - });'; - var $headerScript = ' - try{ - leimnud.exec(leimnud.fix.memoryLeak); - if(leimnud.browser.isIphone){ - leimnud.iphone.make(); - } - }catch(e){}'; - var $disableHeaderScripts = false; - var $title = ''; - - /** - * Function headPublisher - * - * @author David S. Callizaya S. - * @access public - * @return string - */ - - public function __construct () - { - $this->addScriptFile( "/js/maborak/core/maborak.js" ); - } - - function &getSingleton () - { - if (self::$instance == null) { - self::$instance = new headPublisher(); - } - return self::$instance; - } - - /** - * Function setTitle - * - * @author David S. Callizaya S. - * @access public - * @param eter string url - * @param eter string LoadType - * @return string - */ - function setTitle ($title) - { - $this->title = $title; - } - - /** - * Function addMaborakFile - * - * @access public - * @param eter string filename - * @param eter string loader; false -> maborak files, true maborak.loader - * @return string - */ - function addMaborakFile ($filename, $loader = false) - { - if ($loader) { - $this->maborakLoaderFiles[] = $filename; - } else { - $this->maborakFiles[] = $filename; - } - } - - /** - * Function addScriptFile - * - * @author David S. Callizaya S. - * @access public - * @param eter string url - * @param eter string LoadType - * @return string - */ - function addScriptFile ($url, $LoadType = 1) - { - if ($LoadType == 1) { - $this->scriptFiles[$url] = $url; - } - if ($LoadType == 2) { - $this->leimnudLoad[$url] = $url; - } - } - - /** - * Function addInstanceModule - * - * @author David S. Callizaya S. - * @access public - * @param eter string instance - * @param eter string module - * @return string - */ - - function addInstanceModule ($instance, $module) - { - $this->headerScript .= "leimnud.Package.Load('" . $module . "',{Instance:" . $instance . ",Type:'module'});\n"; - } - - /** - * Function addClassModule - * - * @author David S. Callizaya S. - * @access public - * @param eter string class - * @param eter string module - * @return string - */ - function addClassModule ($class, $module) - { - $this->headerScript .= "leimnud.Package.Load('" . $module . "',{Class:" . $class . ",Type:'module'});\n"; - } - - /** - * Function addScriptCode - * - * @author David S. Callizaya S. - * @access public - * @param eter string script - * @return string - */ - function addScriptCode ($script) - { - $this->headerScript .= $script; - } - - /** - * Function printHeader - * - * @author David S. Callizaya S. - * @access public - * @return string - */ - function printHeader () - { - $jslabel = 'labels/en.js'; - if (defined( 'SYS_LANG' )) { - $jslabel = 'labels' . PATH_SEP . SYS_LANG . '.js'; - if (! file_exists( PATH_CORE . 'js' . PATH_SEP . $jslabel )) { - $jslabel = 'labels/en.js'; - } - } - if (file_exists( PATH_CORE . 'js' . PATH_SEP . $jslabel )) { - $this->addScriptFile( '/jscore/' . $jslabel, 1 ); - } - if ($this->disableHeaderScripts) { - return ''; - } - - // available js-calendar languages array - $availableJsCalendarLang = array ('ca','cn','cz','de','en','es','fr','it','jp','nl','pl','pt','ro','ru','sv'); - - // get the system language without locale - $sysLang = explode( '-', SYS_LANG ); - $sysLang = $sysLang[0]; - - // verify if the requested lang by the system is supported by js-calendar library, if not set english by default - $sysLang = in_array( $sysLang, $availableJsCalendarLang ) ? $sysLang : 'en'; - - $this->addScriptFile( "/js/widgets/js-calendar/unicode-letter.js" ); - $this->addScriptFile( "/js/widgets/js-calendar/lang/" . $sysLang . ".js" ); - - $head = ''; - $head .= '' . $this->title . "\n"; - foreach ($this->scriptFiles as $file) { - $head .= "\n"; - } - $head .= "\n"; - return $head; - } - - /** - * Function printRawHeader - * Its prupose is to load el HEADs initialization javascript - * into a single SCRIPT tag, it is usefull when it is needed - * to load a page by leimnud floating panel of by another ajax - * method. (See also RAW skin) - * - * @author David S. Callizaya S. - * @access public - * @return string - */ - function printRawHeader () - { - $jslabel = '/jscore/labels/en.js'; - if (defined( 'SYS_LANG' )) { - $jslabel1 = 'labels' . PATH_SEP . SYS_LANG . '.js'; - if (! file_exists( PATH_CORE . 'js' . PATH_SEP . $jslabel1 )) { - $jslabel = '/jscore/labels/en.js'; - } - } - $head = ''; - //$head .= "\n"; - return $head; - } - - /** - * Function clearScripts - * Its prupose is to clear all the scripts of the header. - * - * @author David S. Callizaya S. - * @access public - * @return string - */ - function clearScripts () - { - $this->scriptFiles = array (); - $this->leimnudLoad = array (); - $this->leimnudInitString = ''; - $this->headerScript = ''; - } - - /** - * Function includeExtJs - * with this function we are using the ExtJs library, this library is not compatible with - * previous libraries, for that reason oHeadPublisher will clear previous libraries like maborak - * we need to check if we need the language file - * this function returns the header needed to render a page using ExtJs - * - * @author Fernando Ontiveros - * @access public - * @return string - */ - function includeExtJs () - { - $this->clearScripts(); - $head = ''; - $head .= " \n"; - $head .= " \n"; - $aux = explode( '-', strtolower( SYS_LANG ) ); - if (($aux[0] != 'en') && file_exists( PATH_GULLIVER_HOME . 'js' . PATH_SEP . 'ext' . PATH_SEP . 'locale' . PATH_SEP . 'ext-lang-' . $aux[0] . '.js' )) { - $head .= " \n"; - } - - // enabled for particular use - $head .= $this->getExtJsLibraries(); - - // $head .= " \n"; - $head .= " \n"; - - if (! isset( $this->extJsSkin ) || $this->extJsSkin == '') { - $this->extJsSkin = 'xtheme-gray'; - //$this->extJsSkin = 'gtheme'; - } - //$head .= $this->getExtJsStylesheets(); - $head .= $this->getExtJsScripts(); - $head .= $this->getExtJsVariablesScript(); - $oServerConf = & serverConf::getSingleton(); - if ($oServerConf->isRtl( SYS_LANG )) { - $head .= " \n"; - } - - return $head; - } - - function getExtJsStylesheets ($skinName) - { - $script = " \n"; - $script .= " \n"; - /* - $script .= " \n"; - $script .= " \n"; - - // - - //new interactive css decorator - $script .= " \n"; - $script .= " \n"; - */ - // Load external/plugin css - // NOTE is necesary to move this to decorator server - if (class_exists( 'PMPluginRegistry' )) { - $oPluginRegistry = & PMPluginRegistry::getSingleton(); - $registeredCss = $oPluginRegistry->getRegisteredCss(); - foreach ($registeredCss as $cssFile) { - $script .= " \n"; - } - } - return $script; - } - - function getExtJsScripts () - { - $script = ''; - if (isset( $this->extJsScript ) && is_array( $this->extJsScript )) { - foreach ($this->extJsScript as $key => $file) { - $script .= " \n"; - } - } - return $script; - } - - function getExtJsVariablesScript () - { - $script = ''; - if (count( $this->extVariable ) > 0) { - $script = "\n"; - } - return $script; - } - - function getExtJsLibraries () - { - $script = ''; - if (isset( $this->extJsLibrary ) && is_array( $this->extJsLibrary )) { - foreach ($this->extJsLibrary as $file) { - $script .= " \n"; - } - } - return $script; - } - - /** - * add a ExtJS extended library - * - * @author Erik A. Ortiz - * @access public - * @param (String) http js path library - * @return none - */ - function usingExtJs ($library) - { - if (! is_string( $library )) { - throw new Exception( 'headPublisher::usingExt->ERROR - the parameter should be a js path string' ); - } - array_push( $this->extJsLibrary, $library ); - } - - /** - * Function setExtSkin - * with this function we are using the ExtJs library, this library is not compatible with - * previous libraries, for that reason oHeadPublisher will clear previous libraries like maborak - * we need to check if we need the language file - * - * @author Fernando Ontiveros - * @access public - * @return string - */ - function setExtSkin ($skin) - { - $this->extJsSkin = $skin; - } - - /** - * Function addExtJsScript - * adding a javascript file . - * js - * add a js file in the extension Javascript Array, - * later, when we use the includeExtJs function, all the files in this array will be included in the output - * if the second argument is true, the file will not be minified, this is useful for debug purposes. - * - * Feature added - - * - Hook to find javascript registered from plugins and load them - * - * @author Fernando Ontiveros - * @author Erik Amaru Ortiz - * @access public - * @return string - */ - function addExtJsScript ($filename, $debug = false, $isExternal = false) - { - $sPath = PATH_TPL; - //if the template file doesn't exists, then try with the plugins folders - - - if (! is_file( $sPath . $filename . ".js" )) { - $aux = explode( PATH_SEP, $filename ); - //check if G_PLUGIN_CLASS is defined, because publisher can be called without an environment - if (count( $aux ) == 2 && defined( 'G_PLUGIN_CLASS' )) { - $oPluginRegistry = & PMPluginRegistry::getSingleton(); - if ($oPluginRegistry->isRegisteredFolder( $aux[0] )) { - $sPath = PATH_PLUGINS; - } - } - } - - if (! $isExternal) { - $jsFilename = $sPath . $filename . '.js'; - } else { - $jsFilename = $filename . '.js'; - } - - if (! file_exists( $jsFilename )) { - return; - } - - $mtime = filemtime( $jsFilename ); - G::mk_dir( PATH_C . 'ExtJs' ); - if ($debug) { - $cacheName = str_replace( '/', '_', $filename ); - $cacheFilename = PATH_C . 'ExtJs' . PATH_SEP . $cacheName . '.js'; - file_put_contents( $cacheFilename, file_get_contents( $jsFilename ) ); - } else { - $cacheName = md5( $mtime . $jsFilename ); - $cacheFilename = PATH_C . 'ExtJs' . PATH_SEP . $cacheName . '.js'; - - if (! file_exists( $cacheFilename )) { - require_once (PATH_THIRDPARTY . 'jsmin/jsmin.php'); - $content = JSMin::minify( file_get_contents( $jsFilename ) ); - file_put_contents( $cacheFilename, $content ); - } - } - - $this->extJsScript[] = '/extjs/' . $cacheName; - - //hook for registered javascripts from plugins - if (class_exists( 'PMPluginRegistry' )) { - $oPluginRegistry = & PMPluginRegistry::getSingleton(); - $pluginJavascripts = $oPluginRegistry->getRegisteredJavascriptBy( $filename ); - } else { - $pluginJavascripts = array (); - } - - if (count( $pluginJavascripts ) > 0) { - if ($debug) { - foreach ($pluginJavascripts as $pluginJsFile) { - $jsPluginCacheName = ''; - if (substr( $pluginJsFile, - 3 ) != '.js') { - $pluginJsFile .= '.js'; - } - - if (file_exists( PATH_PLUGINS . $pluginJsFile )) { - $jsPluginCacheName = str_replace( '/', '_', str_replace( '.js', '', $pluginJsFile ) ); - $cacheFilename = PATH_C . 'ExtJs' . PATH_SEP . $jsPluginCacheName . ".js"; - file_put_contents( $cacheFilename, file_get_contents( PATH_PLUGINS . $pluginJsFile ) ); - } - if ($jsPluginCacheName != '') { - $this->extJsScript[] = '/extjs/' . $jsPluginCacheName; - } - } - } else { - foreach ($pluginJavascripts as $pluginJsFile) { - $jsPluginCacheName = ''; - if (substr( $pluginJsFile, - 3 ) !== '.js') { - $pluginJsFile .= '.js'; - } - if (file_exists( PATH_PLUGINS . $pluginJsFile )) { - $mtime = filemtime( PATH_PLUGINS . $pluginJsFile ); - $jsPluginCacheName = md5( $mtime . $pluginJsFile ); - $cacheFilename = PATH_C . 'ExtJs' . PATH_SEP . $jsPluginCacheName . '.js'; - - if (! file_exists( $cacheFilename )) { - require_once (PATH_THIRDPARTY . 'jsmin/jsmin.php'); - $content = JSMin::minify( file_get_contents( PATH_PLUGINS . $pluginJsFile ) ); - file_put_contents( $cacheFilename, $content ); - } - } - if ($jsPluginCacheName != '') { - $this->extJsScript[] = '/extjs/' . $jsPluginCacheName; - } - } - } - } - //end hook for registered javascripts from plugins - } - - /** - * Function AddContent - * adding a html file . - * html. - * the main idea for this function, is to be a replacement to homonymous function in Publisher class. - * with this function you are adding Content to the output, the class HeadPublisher will maintain a list of - * files to render in the body of the output page - * - * @author Fernando Ontiveros - * @access public - * @return string - */ - function AddContent ($templateHtml) - { - $this->extJsContent[] = $templateHtml; - } - - function getContent () - { - return $this->extJsContent; - } - - /** - * Function assign - * assign a STRING value to a JS variable - * use this function to send from PHP variables to be used in JavaScript - * - * @author Fernando Ontiveros - * @access public - * @return string - */ - function Assign ($variable, $value) - { - $this->extVariable[] = array ('name' => $variable,'value' => $value,'type' => 'string'); - } - - function AssignVar ($name, $value) - { - $this->vars[$name] = $value; - } - - function getVars () - { - return $this->vars; - } - - /** - * Function assignNumber - * assign a Number value to a JS variable - * use this function to send from PHP variables to be used in JavaScript - * - * @author Fernando Ontiveros - * @access public - * @return string - */ - function AssignNumber ($variable, $value) - { - $this->extVariable[] = array ('name' => $variable,'value' => $value,'type' => 'number'); - } - - /** - * Function renderExtJs - * this function returns the content rendered using ExtJs - * extJsContent have an array, and we iterate this array to draw the content - * - * @author Fernando Ontiveros - * @access public - * @return string - */ - function renderExtJs () - { - $body = ''; - if (isset( $this->extJsContent ) && is_array( $this->extJsContent )) { - foreach ($this->extJsContent as $key => $file) { - $sPath = PATH_TPL; - //if the template file doesn't exists, then try with the plugins folders - if (! is_file( $sPath . $file . ".html" )) { - $aux = explode( PATH_SEP, $file ); - //check if G_PLUGIN_CLASS is defined, because publisher can be called without an environment - if (count( $aux ) == 2 && defined( 'G_PLUGIN_CLASS' )) { - $oPluginRegistry = & PMPluginRegistry::getSingleton(); - if ($oPluginRegistry->isRegisteredFolder( $aux[0] )) { - $sPath = PATH_PLUGINS; - } - } - } - - $template = new TemplatePower( $sPath . $file . '.html' ); - $template->prepare(); - - foreach ($this->getVars() as $k => $v) { - $template->assign( $k, $v ); - } - - $body .= $template->getOutputContent(); - } - } - return $body; - } - - function stripCodeQuotes ($sJson) - { - $fields = array ("editor","renderer"); - foreach ($fields as $field) { - $pattern = '/"(' . $field . ')":"[a-zA-Z.()]*"/'; - // echo $pattern."
"; - preg_match( $pattern, $sJson, $matches ); - // var_dump ($matches); - // echo "
"; - if (! empty( $matches )) { - $rendererMatch = $matches[0]; - $replaceBy = explode( ":", $matches[0] ); - $replaceBy[1] = str_replace( '"', '', $replaceBy[1] ); - $tmpString = implode( ":", $replaceBy ); - $sJson = str_replace( $rendererMatch, $tmpString, $sJson ); - // var_dump ($sJson); - // echo "
"; - } - } - return $sJson; - } - - /** - * Function disableHeaderScripts - * this function sets disableHeaderScripts to true - * to avoid print scripts into the header - * - * @author Enrique Ponce de Leom - * @access public - * @return string - */ - function disableHeaderScripts () - { - $this->disableHeaderScripts = true; - } -} - +. + * + * For more information, contact Colosa Inc, 2566 Le Jeune Rd., + * Coral Gables, FL, 33134, USA, or email info@colosa.com. + * + */ +/** + * Class headPublisher + * + * @author David S. Callizaya S. + * @package gulliver.system + * @access public + */ +class headPublisher +{ + private static $instance = null; + var $maborakFiles = array (); + var $maborakLoaderFiles = array (); + var $scriptFiles = array (); + var $leimnudLoad = array (); + + /* extJsSkin init coreLoad flag*/ + var $extJsInit = 'false'; + + /* extJsSkin store the current skin for the ExtJs*/ + var $extJsSkin = ''; + + /* extJsScript Array, to store the file to be include */ + var $extJsScript = array (); + + /* extJsLibrary Array, to store extended ExtJs lybraries */ + var $extJsLibrary = array (); + + /* extJsContent Array, to store the file to be include in the skin content */ + var $extJsContent = array (); + + /* extVariable array, to store the variables generated in PHP, and used in JavaScript */ + var $extVariable = array (); + + /* variable array, to store the variables generated in PHP, and used in JavaScript */ + var $vars = array (); + + /* tplVariable array, to store the variables for template power */ + var $tplVariable = array (); + + var $leimnudInitString = ' var leimnud = new maborak(); + leimnud.make({ + zip:true, + inGulliver:true, + modules :"dom,abbr,rpc,drag,drop,app,panel,fx,grid,xmlform,validator,dashboard", + files :"" + });'; + var $headerScript = ' + try{ + leimnud.exec(leimnud.fix.memoryLeak); + if(leimnud.browser.isIphone){ + leimnud.iphone.make(); + } + }catch(e){}'; + var $disableHeaderScripts = false; + var $title = ''; + + /** + * Function headPublisher + * + * @author David S. Callizaya S. + * @access public + * @return string + */ + + public function __construct () + { + $this->addScriptFile( "/js/maborak/core/maborak.js" ); + } + + function &getSingleton () + { + if (self::$instance == null) { + self::$instance = new headPublisher(); + } + return self::$instance; + } + + /** + * Function setTitle + * + * @author David S. Callizaya S. + * @access public + * @param eter string url + * @param eter string LoadType + * @return string + */ + function setTitle ($title) + { + $this->title = $title; + } + + /** + * Function addMaborakFile + * + * @access public + * @param eter string filename + * @param eter string loader; false -> maborak files, true maborak.loader + * @return string + */ + function addMaborakFile ($filename, $loader = false) + { + if ($loader) { + $this->maborakLoaderFiles[] = $filename; + } else { + $this->maborakFiles[] = $filename; + } + } + + /** + * Function addScriptFile + * + * @author David S. Callizaya S. + * @access public + * @param eter string url + * @param eter string LoadType + * @return string + */ + function addScriptFile ($url, $LoadType = 1) + { + if ($LoadType == 1) { + $this->scriptFiles[$url] = $url; + } + if ($LoadType == 2) { + $this->leimnudLoad[$url] = $url; + } + } + + /** + * Function addInstanceModule + * + * @author David S. Callizaya S. + * @access public + * @param eter string instance + * @param eter string module + * @return string + */ + + function addInstanceModule ($instance, $module) + { + $this->headerScript .= "leimnud.Package.Load('" . $module . "',{Instance:" . $instance . ",Type:'module'});\n"; + } + + /** + * Function addClassModule + * + * @author David S. Callizaya S. + * @access public + * @param eter string class + * @param eter string module + * @return string + */ + function addClassModule ($class, $module) + { + $this->headerScript .= "leimnud.Package.Load('" . $module . "',{Class:" . $class . ",Type:'module'});\n"; + } + + /** + * Function addScriptCode + * + * @author David S. Callizaya S. + * @access public + * @param eter string script + * @return string + */ + function addScriptCode ($script) + { + $this->headerScript .= $script; + } + + /** + * Function printHeader + * + * @author David S. Callizaya S. + * @access public + * @return string + */ + function printHeader () + { + $jslabel = 'labels/en.js'; + if (defined( 'SYS_LANG' )) { + $jslabel = 'labels' . PATH_SEP . SYS_LANG . '.js'; + if (! file_exists( PATH_CORE . 'js' . PATH_SEP . $jslabel )) { + $jslabel = 'labels/en.js'; + } + } + if (file_exists( PATH_CORE . 'js' . PATH_SEP . $jslabel )) { + $this->addScriptFile( '/jscore/' . $jslabel, 1 ); + } + if ($this->disableHeaderScripts) { + return ''; + } + + // available js-calendar languages array + $availableJsCalendarLang = array ('ca','cn','cz','de','en','es','fr','it','jp','nl','pl','pt','ro','ru','sv' + ); + + // get the system language without locale + $sysLang = explode( '-', SYS_LANG ); + $sysLang = $sysLang[0]; + + // verify if the requested lang by the system is supported by js-calendar library, if not set english by default + $sysLang = in_array( $sysLang, $availableJsCalendarLang ) ? $sysLang : 'en'; + + $this->addScriptFile( "/js/widgets/js-calendar/unicode-letter.js" ); + $this->addScriptFile( "/js/widgets/js-calendar/lang/" . $sysLang . ".js" ); + + $head = ''; + $head .= '' . $this->title . "\n"; + foreach ($this->scriptFiles as $file) { + $head .= "\n"; + } + $head .= "\n"; + return $head; + } + + /** + * Function printRawHeader + * Its prupose is to load el HEADs initialization javascript + * into a single SCRIPT tag, it is usefull when it is needed + * to load a page by leimnud floating panel of by another ajax + * method. (See also RAW skin) + * + * @author David S. Callizaya S. + * @access public + * @return string + */ + function printRawHeader () + { + $jslabel = '/jscore/labels/en.js'; + if (defined( 'SYS_LANG' )) { + $jslabel1 = 'labels' . PATH_SEP . SYS_LANG . '.js'; + if (! file_exists( PATH_CORE . 'js' . PATH_SEP . $jslabel1 )) { + $jslabel = '/jscore/labels/en.js'; + } + } + $head = ''; + //$head .= "\n"; + return $head; + } + + /** + * Function clearScripts + * Its prupose is to clear all the scripts of the header. + * + * @author David S. Callizaya S. + * @access public + * @return string + */ + function clearScripts () + { + $this->scriptFiles = array (); + $this->leimnudLoad = array (); + $this->leimnudInitString = ''; + $this->headerScript = ''; + } + + /** + * Function includeExtJs + * with this function we are using the ExtJs library, this library is not compatible with + * previous libraries, for that reason oHeadPublisher will clear previous libraries like maborak + * we need to check if we need the language file + * this function returns the header needed to render a page using ExtJs + * + * @author Fernando Ontiveros + * @access public + * @return string + */ + function includeExtJs () + { + $this->clearScripts(); + $head = ''; + $head .= " \n"; + $head .= " \n"; + $aux = explode( '-', strtolower( SYS_LANG ) ); + if (($aux[0] != 'en') && file_exists( PATH_GULLIVER_HOME . 'js' . PATH_SEP . 'ext' . PATH_SEP . 'locale' . PATH_SEP . 'ext-lang-' . $aux[0] . '.js' )) { + $head .= " \n"; + } + + // enabled for particular use + $head .= $this->getExtJsLibraries(); + + // $head .= " \n"; + $head .= " \n"; + + if (! isset( $this->extJsSkin ) || $this->extJsSkin == '') { + $this->extJsSkin = 'xtheme-gray'; + //$this->extJsSkin = 'gtheme'; + } + //$head .= $this->getExtJsStylesheets(); + $head .= $this->getExtJsScripts(); + $head .= $this->getExtJsVariablesScript(); + $oServerConf = & serverConf::getSingleton(); + if ($oServerConf->isRtl( SYS_LANG )) { + $head .= " \n"; + } + + return $head; + } + + function getExtJsStylesheets ($skinName) + { + $script = " \n"; + $script .= " \n"; + /* + $script .= " \n"; + $script .= " \n"; + + // + + //new interactive css decorator + $script .= " \n"; + $script .= " \n"; + */ + // Load external/plugin css + // NOTE is necesary to move this to decorator server + if (class_exists( 'PMPluginRegistry' )) { + $oPluginRegistry = & PMPluginRegistry::getSingleton(); + $registeredCss = $oPluginRegistry->getRegisteredCss(); + foreach ($registeredCss as $cssFile) { + $script .= " \n"; + } + } + return $script; + } + + function getExtJsScripts () + { + $script = ''; + if (isset( $this->extJsScript ) && is_array( $this->extJsScript )) { + foreach ($this->extJsScript as $key => $file) { + $script .= " \n"; + } + } + return $script; + } + + function getExtJsVariablesScript () + { + $script = ''; + if (count( $this->extVariable ) > 0) { + $script = "\n"; + } + return $script; + } + + function getExtJsLibraries () + { + $script = ''; + if (isset( $this->extJsLibrary ) && is_array( $this->extJsLibrary )) { + foreach ($this->extJsLibrary as $file) { + $script .= " \n"; + } + } + return $script; + } + + /** + * add a ExtJS extended library + * + * @author Erik A. Ortiz + * @access public + * @param (String) http js path library + * @return none + */ + function usingExtJs ($library) + { + if (! is_string( $library )) { + throw new Exception( 'headPublisher::usingExt->ERROR - the parameter should be a js path string' ); + } + array_push( $this->extJsLibrary, $library ); + } + + /** + * Function setExtSkin + * with this function we are using the ExtJs library, this library is not compatible with + * previous libraries, for that reason oHeadPublisher will clear previous libraries like maborak + * we need to check if we need the language file + * + * @author Fernando Ontiveros + * @access public + * @return string + */ + function setExtSkin ($skin) + { + $this->extJsSkin = $skin; + } + + /** + * Function addExtJsScript + * adding a javascript file . + * + * js + * add a js file in the extension Javascript Array, + * later, when we use the includeExtJs function, all the files in this array will be included in the output + * if the second argument is true, the file will not be minified, this is useful for debug purposes. + * + * Feature added - + * - Hook to find javascript registered from plugins and load them + * + * @author Fernando Ontiveros + * @author Erik Amaru Ortiz + * @access public + * @return string + */ + function addExtJsScript ($filename, $debug = false, $isExternal = false) + { + $sPath = PATH_TPL; + //if the template file doesn't exists, then try with the plugins folders + + + if (! is_file( $sPath . $filename . ".js" )) { + $aux = explode( PATH_SEP, $filename ); + //check if G_PLUGIN_CLASS is defined, because publisher can be called without an environment + if (count( $aux ) == 2 && defined( 'G_PLUGIN_CLASS' )) { + $oPluginRegistry = & PMPluginRegistry::getSingleton(); + if ($oPluginRegistry->isRegisteredFolder( $aux[0] )) { + $sPath = PATH_PLUGINS; + } + } + } + + if (! $isExternal) { + $jsFilename = $sPath . $filename . '.js'; + } else { + $jsFilename = $filename . '.js'; + } + + if (! file_exists( $jsFilename )) { + return; + } + + $mtime = filemtime( $jsFilename ); + G::mk_dir( PATH_C . 'ExtJs' ); + if ($debug) { + $cacheName = str_replace( '/', '_', $filename ); + $cacheFilename = PATH_C . 'ExtJs' . PATH_SEP . $cacheName . '.js'; + file_put_contents( $cacheFilename, file_get_contents( $jsFilename ) ); + } else { + $cacheName = md5( $mtime . $jsFilename ); + $cacheFilename = PATH_C . 'ExtJs' . PATH_SEP . $cacheName . '.js'; + + if (! file_exists( $cacheFilename )) { + require_once (PATH_THIRDPARTY . 'jsmin/jsmin.php'); + $content = JSMin::minify( file_get_contents( $jsFilename ) ); + file_put_contents( $cacheFilename, $content ); + } + } + + $this->extJsScript[] = '/extjs/' . $cacheName; + + //hook for registered javascripts from plugins + if (class_exists( 'PMPluginRegistry' )) { + $oPluginRegistry = & PMPluginRegistry::getSingleton(); + $pluginJavascripts = $oPluginRegistry->getRegisteredJavascriptBy( $filename ); + } else { + $pluginJavascripts = array (); + } + + if (count( $pluginJavascripts ) > 0) { + if ($debug) { + foreach ($pluginJavascripts as $pluginJsFile) { + $jsPluginCacheName = ''; + if (substr( $pluginJsFile, - 3 ) != '.js') { + $pluginJsFile .= '.js'; + } + + if (file_exists( PATH_PLUGINS . $pluginJsFile )) { + $jsPluginCacheName = str_replace( '/', '_', str_replace( '.js', '', $pluginJsFile ) ); + $cacheFilename = PATH_C . 'ExtJs' . PATH_SEP . $jsPluginCacheName . ".js"; + file_put_contents( $cacheFilename, file_get_contents( PATH_PLUGINS . $pluginJsFile ) ); + } + if ($jsPluginCacheName != '') { + $this->extJsScript[] = '/extjs/' . $jsPluginCacheName; + } + } + } else { + foreach ($pluginJavascripts as $pluginJsFile) { + $jsPluginCacheName = ''; + if (substr( $pluginJsFile, - 3 ) !== '.js') { + $pluginJsFile .= '.js'; + } + if (file_exists( PATH_PLUGINS . $pluginJsFile )) { + $mtime = filemtime( PATH_PLUGINS . $pluginJsFile ); + $jsPluginCacheName = md5( $mtime . $pluginJsFile ); + $cacheFilename = PATH_C . 'ExtJs' . PATH_SEP . $jsPluginCacheName . '.js'; + + if (! file_exists( $cacheFilename )) { + require_once (PATH_THIRDPARTY . 'jsmin/jsmin.php'); + $content = JSMin::minify( file_get_contents( PATH_PLUGINS . $pluginJsFile ) ); + file_put_contents( $cacheFilename, $content ); + } + } + if ($jsPluginCacheName != '') { + $this->extJsScript[] = '/extjs/' . $jsPluginCacheName; + } + } + } + } + //end hook for registered javascripts from plugins + } + + /** + * Function AddContent + * adding a html file . + * + * html. + * the main idea for this function, is to be a replacement to homonymous function in Publisher class. + * with this function you are adding Content to the output, the class HeadPublisher will maintain a list of + * files to render in the body of the output page + * + * @author Fernando Ontiveros + * @access public + * @return string + */ + function AddContent ($templateHtml) + { + $this->extJsContent[] = $templateHtml; + } + + function getContent () + { + return $this->extJsContent; + } + + /** + * Function assign + * assign a STRING value to a JS variable + * use this function to send from PHP variables to be used in JavaScript + * + * @author Fernando Ontiveros + * @access public + * @return string + */ + function Assign ($variable, $value) + { + $this->extVariable[] = array ('name' => $variable,'value' => $value,'type' => 'string' + ); + } + + function AssignVar ($name, $value) + { + $this->vars[$name] = $value; + } + + function getVars () + { + return $this->vars; + } + + /** + * Function assignNumber + * assign a Number value to a JS variable + * use this function to send from PHP variables to be used in JavaScript + * + * @author Fernando Ontiveros + * @access public + * @return string + */ + function AssignNumber ($variable, $value) + { + $this->extVariable[] = array ('name' => $variable,'value' => $value,'type' => 'number' + ); + } + + /** + * Function renderExtJs + * this function returns the content rendered using ExtJs + * extJsContent have an array, and we iterate this array to draw the content + * + * @author Fernando Ontiveros + * @access public + * @return string + */ + function renderExtJs () + { + $body = ''; + if (isset( $this->extJsContent ) && is_array( $this->extJsContent )) { + foreach ($this->extJsContent as $key => $file) { + $sPath = PATH_TPL; + //if the template file doesn't exists, then try with the plugins folders + if (! is_file( $sPath . $file . ".html" )) { + $aux = explode( PATH_SEP, $file ); + //check if G_PLUGIN_CLASS is defined, because publisher can be called without an environment + if (count( $aux ) == 2 && defined( 'G_PLUGIN_CLASS' )) { + $oPluginRegistry = & PMPluginRegistry::getSingleton(); + if ($oPluginRegistry->isRegisteredFolder( $aux[0] )) { + $sPath = PATH_PLUGINS; + } + } + } + + $template = new TemplatePower( $sPath . $file . '.html' ); + $template->prepare(); + + foreach ($this->getVars() as $k => $v) { + $template->assign( $k, $v ); + } + + $body .= $template->getOutputContent(); + } + } + return $body; + } + + function stripCodeQuotes ($sJson) + { + $fields = array ("editor","renderer" + ); + foreach ($fields as $field) { + $pattern = '/"(' . $field . ')":"[a-zA-Z.()]*"/'; + // echo $pattern."
"; + preg_match( $pattern, $sJson, $matches ); + // var_dump ($matches); + // echo "
"; + if (! empty( $matches )) { + $rendererMatch = $matches[0]; + $replaceBy = explode( ":", $matches[0] ); + $replaceBy[1] = str_replace( '"', '', $replaceBy[1] ); + $tmpString = implode( ":", $replaceBy ); + $sJson = str_replace( $rendererMatch, $tmpString, $sJson ); + // var_dump ($sJson); + // echo "
"; + } + } + return $sJson; + } + + /** + * Function disableHeaderScripts + * this function sets disableHeaderScripts to true + * to avoid print scripts into the header + * + * @author Enrique Ponce de Leom + * @access public + * @return string + */ + function disableHeaderScripts () + { + $this->disableHeaderScripts = true; + } +} + diff --git a/workflow/engine/classes/model/AppSolrQueue.php b/workflow/engine/classes/model/AppSolrQueue.php index 834adf91c..b28e5ad86 100644 --- a/workflow/engine/classes/model/AppSolrQueue.php +++ b/workflow/engine/classes/model/AppSolrQueue.php @@ -3,25 +3,25 @@ require_once 'classes/model/om/BaseAppSolrQueue.php'; require_once 'classes/entities/AppSolrQueue.php'; - /** * Skeleton subclass for representing a row from the 'APP_SOLR_QUEUE' table. * * * * You should add additional methods to this class to meet the - * application requirements. This class will only be generated as + * application requirements. This class will only be generated as * long as it does not already exist in the output directory. * - * @package classes.model + * @package classes.model */ class AppSolrQueue extends BaseAppSolrQueue { - public function exists($sAppUid) + + public function exists ($sAppUid) { try { $oRow = AppSolrQueuePeer::retrieveByPK( $sAppUid ); - if (!is_null($oRow)) { + if (! is_null( $oRow )) { return true; } else { return false; @@ -31,46 +31,46 @@ class AppSolrQueue extends BaseAppSolrQueue } } - public function createUpdate($sAppUid, $iUpdated) + public function createUpdate ($sAppUid, $iUpdated) { - $con = Propel::getConnection(AppSolrQueuePeer::DATABASE_NAME); + $con = Propel::getConnection( AppSolrQueuePeer::DATABASE_NAME ); try { - if ($this->exists($sAppUid)) { + if ($this->exists( $sAppUid )) { $con->begin(); //update record //$oRow = AppSolrQueuePeer::retrieveByPK( $sAppUid ); //$aFields = $oRow->toArray(BasePeer::TYPE_FIELDNAME); //$this->fromArray($aFields,BasePeer::TYPE_FIELDNAME); - $this->setNew(false); + $this->setNew( false ); //set field - $this->setAppUid($sAppUid); - $this->setAppUpdated($iUpdated); + $this->setAppUid( $sAppUid ); + $this->setAppUpdated( $iUpdated ); if ($this->validate()) { - $result=$this->save(); + $result = $this->save(); } else { $con->rollback(); - throw(new Exception("Failed Validation in class ".get_class($this).".")); + throw (new Exception( "Failed Validation in class " . get_class( $this ) . "." )); } $con->commit(); return $result; } else { //create record //set values - $this->setAppUid($sAppUid); - $this->setAppUpdated($iUpdated); + $this->setAppUid( $sAppUid ); + $this->setAppUpdated( $iUpdated ); if ($this->validate()) { - $result=$this->save(); + $result = $this->save(); } else { - $e=new Exception("Failed Validation in class ".get_class($this)."."); + $e = new Exception( "Failed Validation in class " . get_class( $this ) . "." ); //$e->aValidationFailures=$this->getValidationFailures(); - throw($e); + throw ($e); } $con->commit(); return $result; } } catch (Exception $e) { $con->rollback(); - throw($e); + throw ($e); } } @@ -78,25 +78,25 @@ class AppSolrQueue extends BaseAppSolrQueue * Returns the list of updated applications * array of Entity_AppSolrQueue */ - public function getListUpdatedApplications() + public function getListUpdatedApplications () { - $updatedApplications = array(); + $updatedApplications = array (); try { $c = new Criteria(); - $c->addSelectColumn(AppSolrQueuePeer::APP_UID); - $c->addSelectColumn(AppSolrQueuePeer::APP_UPDATED); + $c->addSelectColumn( AppSolrQueuePeer::APP_UID ); + $c->addSelectColumn( AppSolrQueuePeer::APP_UPDATED ); //"WHERE - $c->add(AppSolrQueuePeer::APP_UPDATED, 0, Criteria::NOT_EQUAL); + $c->add( AppSolrQueuePeer::APP_UPDATED, 0, Criteria::NOT_EQUAL ); - $rs = AppSolrQueuePeer::doSelectRS($c); - $rs->setFetchmode(ResultSet::FETCHMODE_ASSOC); + $rs = AppSolrQueuePeer::doSelectRS( $c ); + $rs->setFetchmode( ResultSet::FETCHMODE_ASSOC ); //echo $c->toString(); $rs->next(); $row = $rs->getRow(); - while (is_array($row)) { + while (is_array( $row )) { $appSolrQueue = Entity_AppSolrQueue::createEmpty(); $appSolrQueue->appUid = $row['APP_UID']; $appSolrQueue->appUpdated = $row['APP_UPDATED']; @@ -107,7 +107,7 @@ class AppSolrQueue extends BaseAppSolrQueue return $updatedApplications; } catch (Exception $e) { $con->rollback(); - throw($e); + throw ($e); } } } diff --git a/workflow/engine/classes/triggers/class.pmSharepointFunctions.php b/workflow/engine/classes/triggers/class.pmSharepointFunctions.php index f56b6e0b4..3447e9a24 100755 --- a/workflow/engine/classes/triggers/class.pmSharepointFunctions.php +++ b/workflow/engine/classes/triggers/class.pmSharepointFunctions.php @@ -19,15 +19,15 @@ /** * Sharepoint Triggers that allow ProcessMaker to perform common DWS actions * @class pmTrSharepoint + * * @name Sharepoint DWS Triggers v. 0.1 * @icon /images/triggers/sharepoint.gif * @className class.pmTrSharepoint.pmFunctions.php */ /** - * @method * - * Create a DWS in Sharepoint server + * @method Create a DWS in Sharepoint server * * @name createDWS * @label Create a DWS in Sharepoint server @@ -42,18 +42,18 @@ * @return string | $result | Response * */ -function createDWS($sharepointServer, $auth, $name="", $users="", $title="", $documents="", $result="") { - //print "Trigger: createDWS"; - require_once(PATH_CORE. 'classes' . PATH_SEP.'triggers' . PATH_SEP . 'class.pmTrSharepoint.php'); - $pmTrSharepoint = new pmTrSharepointClass($sharepointServer, $auth); - $beforeResult = $pmTrSharepoint->createDWS($name, $users, $title, $documents); - return $beforeResult; +function createDWS ($sharepointServer, $auth, $name = "", $users = "", $title = "", $documents = "", $result = "") +{ + //print "Trigger: createDWS"; + require_once (PATH_CORE . 'classes' . PATH_SEP . 'triggers' . PATH_SEP . 'class.pmTrSharepoint.php'); + $pmTrSharepoint = new pmTrSharepointClass( $sharepointServer, $auth ); + $beforeResult = $pmTrSharepoint->createDWS( $name, $users, $title, $documents ); + return $beforeResult; } /** - * @method * - * Delete a DWS in Sharepoint server + * @method Delete a DWS in Sharepoint server * * @name deleteDWS * @label Delete a DWS in Sharepoint server @@ -65,22 +65,23 @@ function createDWS($sharepointServer, $auth, $name="", $users="", $title="", $do * @return string | $result | Response * */ -function deleteDWS($sharepointServer, $auth, $dwsname) { - require_once(PATH_CORE. 'classes' . PATH_SEP.'triggers' . PATH_SEP . 'class.pmTrSharepoint.php'); - $pmTrSharepoint = new pmTrSharepointClass($sharepointServer, $auth); - $beforeResult = $pmTrSharepoint->deleteDWS($dwsname); - $newResult = $beforeResult->DeleteDwsResult; - if($newResult == '') - return "Successfully deleted the DWS"; - else - return "Error in deleting the DWS"; +function deleteDWS ($sharepointServer, $auth, $dwsname) +{ + require_once (PATH_CORE . 'classes' . PATH_SEP . 'triggers' . PATH_SEP . 'class.pmTrSharepoint.php'); + $pmTrSharepoint = new pmTrSharepointClass( $sharepointServer, $auth ); + $beforeResult = $pmTrSharepoint->deleteDWS( $dwsname ); + $newResult = $beforeResult->DeleteDwsResult; + if ($newResult == '') { + return "Successfully deleted the DWS"; + } else { + return "Error in deleting the DWS"; + } } /** - * @method * - * Create a folder in a DWS + * @method Create a folder in a DWS * * @name createFolderDWS * @label Create a folder in a DWS @@ -93,27 +94,26 @@ function deleteDWS($sharepointServer, $auth, $dwsname) { * @return string | $result | Response * */ -function createFolderDWS($sharepointServer, $auth, $dwsname, $dwsFolderName) { - require_once(PATH_CORE. 'classes' . PATH_SEP.'triggers' . PATH_SEP . 'class.pmTrSharepoint.php'); - $pmTrSharepoint = new pmTrSharepointClass($sharepointServer, $auth); - $result = $pmTrSharepoint->createFolderDWS($dwsname,$dwsFolderName); - var_dump($result); - $newResult = $result->CreateFolderResult; - var_dump($newResult); - if(isset($newResult)) - { - if($newResult == '') - return "Folder is created"; - else - return "Folder could not be created"; - } +function createFolderDWS ($sharepointServer, $auth, $dwsname, $dwsFolderName) +{ + require_once (PATH_CORE . 'classes' . PATH_SEP . 'triggers' . PATH_SEP . 'class.pmTrSharepoint.php'); + $pmTrSharepoint = new pmTrSharepointClass( $sharepointServer, $auth ); + $result = $pmTrSharepoint->createFolderDWS( $dwsname, $dwsFolderName ); + var_dump( $result ); + $newResult = $result->CreateFolderResult; + var_dump( $newResult ); + if (isset( $newResult )) { + if ($newResult == '') { + return "Folder is created"; + } else { + return "Folder could not be created"; + } + } } - /** - * @method * - * Delete a DWS folder + * @method Delete a DWS folder * * @name deleteFolderDWS * @label Delete a DWS folder @@ -127,25 +127,24 @@ function createFolderDWS($sharepointServer, $auth, $dwsname, $dwsFolderName) { * */ -function deleteFolderDWS($sharepointServer, $auth, $dwsname, $folderName) { - require_once(PATH_CORE. 'classes' . PATH_SEP.'triggers' . PATH_SEP . 'class.pmTrSharepoint.php'); - $pmTrSharepoint = new pmTrSharepointClass($sharepointServer, $auth); - $result = $pmTrSharepoint->deleteFolderDWS($dwsname, $folderName); - $newResult = $result->DeleteFolderResult; - if(isset($newResult)) - { - if($newResult == '') - return "Folder is deleted"; - else - return "Folder could not be deleted"; - } +function deleteFolderDWS ($sharepointServer, $auth, $dwsname, $folderName) +{ + require_once (PATH_CORE . 'classes' . PATH_SEP . 'triggers' . PATH_SEP . 'class.pmTrSharepoint.php'); + $pmTrSharepoint = new pmTrSharepointClass( $sharepointServer, $auth ); + $result = $pmTrSharepoint->deleteFolderDWS( $dwsname, $folderName ); + $newResult = $result->DeleteFolderResult; + if (isset( $newResult )) { + if ($newResult == '') { + return "Folder is deleted"; + } else { + return "Folder could not be deleted"; + } + } } - /** - * @method * - * Get DWS data + * @method Get DWS data * * @name getDWSData * @label Get DWS data @@ -159,20 +158,21 @@ function deleteFolderDWS($sharepointServer, $auth, $dwsname, $folderName) { * @return string | $result | Response * */ -function getDWSData($sharepointServer, $auth, $newFileName, $dwsname, $lastUpdate) { - require_once(PATH_CORE. 'classes' . PATH_SEP.'triggers' . PATH_SEP . 'class.pmTrSharepoint.php'); - $pmTrSharepoint = new pmTrSharepointClass($sharepointServer, $auth); - $resultDWSData = $pmTrSharepoint->getDWSData($newFileName, $dwsname, $lastUpdate); -if($resultDWSData) +function getDWSData ($sharepointServer, $auth, $newFileName, $dwsname, $lastUpdate) +{ + require_once (PATH_CORE . 'classes' . PATH_SEP . 'triggers' . PATH_SEP . 'class.pmTrSharepoint.php'); + $pmTrSharepoint = new pmTrSharepointClass( $sharepointServer, $auth ); + $resultDWSData = $pmTrSharepoint->getDWSData( $newFileName, $dwsname, $lastUpdate ); + if ($resultDWSData) { return $resultDWSData; - else + } else { return "There was some error while getting the DWS Data"; + } } /** - * @method * - * Get DWS meta data + * @method Get DWS meta data * * @name getDWSMetaData * @label Get DWS meta data @@ -187,27 +187,23 @@ if($resultDWSData) * @return string | $result | Response * */ -function getDWSMetaData($sharepointServer, $auth, $newFileName, $dwsname, $id) { - require_once(PATH_CORE. 'classes' . PATH_SEP.'triggers' . PATH_SEP . 'class.pmTrSharepoint.php'); - $pmTrSharepoint = new pmTrSharepointClass($sharepointServer, $auth); - $result = $pmTrSharepoint->getDWSMetaData($newFileName, $dwsname, $id); - //$newResult = $result->GetDwsMetaDataResult; - if(isset($result)) - { - return $result; - } - else - { - return "Document workspace Meta-data not found"; - } +function getDWSMetaData ($sharepointServer, $auth, $newFileName, $dwsname, $id) +{ + require_once (PATH_CORE . 'classes' . PATH_SEP . 'triggers' . PATH_SEP . 'class.pmTrSharepoint.php'); + $pmTrSharepoint = new pmTrSharepointClass( $sharepointServer, $auth ); + $result = $pmTrSharepoint->getDWSMetaData( $newFileName, $dwsname, $id ); + //$newResult = $result->GetDwsMetaDataResult; + if (isset( $result )) { + return $result; + } else { + return "Document workspace Meta-data not found"; + } } - /** - * @method * - * Copy/Upload Documents to DWS folder + * @method Copy/Upload Documents to DWS folder * * @name uploadDocumentDWS * @label Copy/Upload Documents to DWS folder @@ -222,18 +218,18 @@ function getDWSMetaData($sharepointServer, $auth, $newFileName, $dwsname, $id) { * @return string | $result | Response * */ -function uploadDocumentDWS($sharepointServer, $auth, $dwsname, $folderName, $sourceUrl, $filename) { - require_once(PATH_CORE. 'classes' . PATH_SEP.'triggers' . PATH_SEP . 'class.pmTrSharepoint.php'); - $pmTrSharepoint = new pmTrSharepointClass($sharepointServer, $auth); - $beforeResult = $pmTrSharepoint->uploadDocumentDWS($dwsname, $folderName, $sourceUrl, $filename); +function uploadDocumentDWS ($sharepointServer, $auth, $dwsname, $folderName, $sourceUrl, $filename) +{ + require_once (PATH_CORE . 'classes' . PATH_SEP . 'triggers' . PATH_SEP . 'class.pmTrSharepoint.php'); + $pmTrSharepoint = new pmTrSharepointClass( $sharepointServer, $auth ); + $beforeResult = $pmTrSharepoint->uploadDocumentDWS( $dwsname, $folderName, $sourceUrl, $filename ); - return $beforeResult; + return $beforeResult; } /** - * @method * - * Download documents from DWS folder + * @method Download documents from DWS folder * * @name downloadDocumentDWS * @label Download DWS Documents @@ -247,21 +243,21 @@ function uploadDocumentDWS($sharepointServer, $auth, $dwsname, $folderName, $sou * @return string | $result | Response * */ -function downloadDocumentDWS($sharepointServer, $auth, $dwsname, $fileName, $fileLocation) { - require_once(PATH_CORE. 'classes' . PATH_SEP.'triggers' . PATH_SEP . 'class.pmTrSharepoint.php'); - $pmTrSharepoint = new pmTrSharepointClass($sharepointServer, $auth); - $result = $pmTrSharepoint->downloadDocumentDWS($dwsname, $fileName, $fileLocation); - if(isset($result)) +function downloadDocumentDWS ($sharepointServer, $auth, $dwsname, $fileName, $fileLocation) +{ + require_once (PATH_CORE . 'classes' . PATH_SEP . 'triggers' . PATH_SEP . 'class.pmTrSharepoint.php'); + $pmTrSharepoint = new pmTrSharepointClass( $sharepointServer, $auth ); + $result = $pmTrSharepoint->downloadDocumentDWS( $dwsname, $fileName, $fileLocation ); + if (isset( $result )) { return "Document downloaded"; - else - return "Document cannot be downloaded"; + } else { + return "Document cannot be downloaded"; + } } - /** - * @method * - * Get DWS Folder items + * @method Get DWS Folder items * * @name getDWSFolderItems * @label Get DWS Folder items @@ -274,20 +270,21 @@ function downloadDocumentDWS($sharepointServer, $auth, $dwsname, $fileName, $fil * @return string | $result | Response * */ -function getDWSFolderItems($sharepointServer, $auth,$dwsname, $strFolderUrl) { - require_once(PATH_CORE. 'classes' . PATH_SEP.'triggers' . PATH_SEP . 'class.pmTrSharepoint.php'); - $pmTrSharepoint = new pmTrSharepointClass($sharepointServer, $auth); - $result = $pmTrSharepoint->getDWSFolderItems($dwsname, $strFolderUrl); - if(isset($result)) +function getDWSFolderItems ($sharepointServer, $auth, $dwsname, $strFolderUrl) +{ + require_once (PATH_CORE . 'classes' . PATH_SEP . 'triggers' . PATH_SEP . 'class.pmTrSharepoint.php'); + $pmTrSharepoint = new pmTrSharepointClass( $sharepointServer, $auth ); + $result = $pmTrSharepoint->getDWSFolderItems( $dwsname, $strFolderUrl ); + if (isset( $result )) { return $result; - else - return "Folder does not exist"; + } else { + return "Folder does not exist"; + } } /** - * @method * - * Get DWS Document Versions + * @method Get DWS Document Versions * * @name getDWSDocumentVersions * @label Get DWS Document Versions @@ -300,33 +297,32 @@ function getDWSFolderItems($sharepointServer, $auth,$dwsname, $strFolderUrl) { * @return string | $result | Response * */ -function getDWSDocumentVersions($sharepointServer, $auth, $newFileName, $dwsname) { - require_once(PATH_CORE. 'classes' . PATH_SEP.'triggers' . PATH_SEP . 'class.pmTrSharepoint.php'); - $pmTrSharepoint = new pmTrSharepointClass($sharepointServer, $auth); - $result = $pmTrSharepoint->getDWSDocumentVersions($newFileName, $dwsname); - if(isset($result->GetVersionsResult)) - { - /* +function getDWSDocumentVersions ($sharepointServer, $auth, $newFileName, $dwsname) +{ + require_once (PATH_CORE . 'classes' . PATH_SEP . 'triggers' . PATH_SEP . 'class.pmTrSharepoint.php'); + $pmTrSharepoint = new pmTrSharepointClass( $sharepointServer, $auth ); + $result = $pmTrSharepoint->getDWSDocumentVersions( $newFileName, $dwsname ); + if (isset( $result->GetVersionsResult )) { + /* * Code to get the Document's Version/s */ - $xml = $result->GetVersionsResult->any;// in Result we get string in Xml format - $xmlNew = simplexml_load_string($xml);// used to parse string to xml - $xmlArray = @G::json_decode(@G::json_encode($xmlNew),1);// used to convert Objects to array - $resultCount = count($xmlArray['result']); - for($i=0;$i<$resultCount;$i++) - { - $version[] =$xmlArray['result'][$i]['@attributes']['version']; - } - $serializeResult = serialize($version);// serializing the Array for Returning. - return $serializeResult; - } - else - return "No version found"; + $xml = $result->GetVersionsResult->any; // in Result we get string in Xml format + $xmlNew = simplexml_load_string( $xml ); // used to parse string to xml + $xmlArray = @G::json_decode( @G::json_encode( $xmlNew ), 1 ); // used to convert Objects to array + $resultCount = count( $xmlArray['result'] ); + for ($i = 0; $i < $resultCount; $i ++) { + $version[] = $xmlArray['result'][$i]['@attributes']['version']; + } + $serializeResult = serialize( $version ); // serializing the Array for Returning. + return $serializeResult; + } else { + return "No version found"; + } } + /** - * @method * - * Delete DWS Document Version + * @method Delete DWS Document Version * * @name deleteDWSDocumentVersion * @label Delete DWS Document Version @@ -340,18 +336,17 @@ function getDWSDocumentVersions($sharepointServer, $auth, $newFileName, $dwsname * @return string | $result | Response * */ -function deleteDWSDocumentVersion($sharepointServer, $auth, $newFileName, $dwsname, $versionNum) { - require_once(PATH_CORE. 'classes' . PATH_SEP.'triggers' . PATH_SEP . 'class.pmTrSharepoint.php'); - $pmTrSharepoint = new pmTrSharepointClass($sharepointServer, $auth); - $result = $pmTrSharepoint->deleteDWSDocVersion($newFileName, $dwsname, $versionNum); - return $result; +function deleteDWSDocumentVersion ($sharepointServer, $auth, $newFileName, $dwsname, $versionNum) +{ + require_once (PATH_CORE . 'classes' . PATH_SEP . 'triggers' . PATH_SEP . 'class.pmTrSharepoint.php'); + $pmTrSharepoint = new pmTrSharepointClass( $sharepointServer, $auth ); + $result = $pmTrSharepoint->deleteDWSDocVersion( $newFileName, $dwsname, $versionNum ); + return $result; } - /** - * @method * - * Delete all DWS Document Versions + * @method Delete all DWS Document Versions * * @name deleteDWSAllDocumentVersion * @label Delete all DWS Document Versions @@ -364,9 +359,11 @@ function deleteDWSDocumentVersion($sharepointServer, $auth, $newFileName, $dwsna * @return string | $result | Response * */ -function deleteDWSAllDocumentVersion($sharepointServer, $auth, $newFileName, $dwsname) { - require_once(PATH_CORE. 'classes' . PATH_SEP.'triggers' . PATH_SEP . 'class.pmTrSharepoint.php'); - $pmTrSharepoint = new pmTrSharepointClass($sharepointServer, $auth); - $result = $pmTrSharepoint->deleteAllDWSDocVersion($newFileName, $dwsname); - return $result; -} \ No newline at end of file +function deleteDWSAllDocumentVersion ($sharepointServer, $auth, $newFileName, $dwsname) +{ + require_once (PATH_CORE . 'classes' . PATH_SEP . 'triggers' . PATH_SEP . 'class.pmTrSharepoint.php'); + $pmTrSharepoint = new pmTrSharepointClass( $sharepointServer, $auth ); + $result = $pmTrSharepoint->deleteAllDWSDocVersion( $newFileName, $dwsname ); + return $result; +} +