BUG 0000 Adjustment for the standardization of code. CODE_STYLE

This commit is contained in:
Hector Cortez
2013-03-05 09:12:44 -04:00
parent 782300f92c
commit 3fe55aa94f
4 changed files with 400 additions and 384 deletions

View File

@@ -25,6 +25,7 @@
* Coral Gables, FL, 33134, USA, or email info@colosa.com. * Coral Gables, FL, 33134, USA, or email info@colosa.com.
* *
*/ */
/** /**
* Class headPublisher * Class headPublisher
* *
@@ -34,51 +35,50 @@
*/ */
class headPublisher class headPublisher
{ {
public static $instance = null;
var $scriptFiles = array ();
var $leimnudLoad = array ();
/* extJsSkin init coreLoad flag*/ public static $instance = null;
var $extJsInit = 'false'; public $scriptFiles = array();
/* extJsSkin store the current skin for the ExtJs*/ public $leimnudLoad = array();
var $extJsSkin = '';
/* extJsSkin init coreLoad flag */
public $extJsInit = 'false';
/* extJsSkin store the current skin for the ExtJs */
public $extJsSkin = '';
/* extJsScript Array, to store the file to be include */ /* extJsScript Array, to store the file to be include */
var $extJsScript = array (); public $extJsScript = array();
/* extJsLibrary Array, to store extended ExtJs lybraries */ /* extJsLibrary Array, to store extended ExtJs lybraries */
var $extJsLibrary = array (); public $extJsLibrary = array();
/* extJsContent Array, to store the file to be include in the skin content */ /* extJsContent Array, to store the file to be include in the skin content */
var $extJsContent = array (); public $extJsContent = array();
/* extVariable array, to store the variables generated in PHP, and used in JavaScript */ /* extVariable array, to store the variables generated in PHP, and used in JavaScript */
var $extVariable = array (); public $extVariable = array();
/* variable array, to store the variables generated in PHP, and used in JavaScript */ /* variable array, to store the variables generated in PHP, and used in JavaScript */
var $vars = array (); public $vars = array();
/* tplVariable array, to store the variables for template power */ /* tplVariable array, to store the variables for template power */
var $tplVariable = array (); public $tplVariable = array();
public $translationsFile;
var $translationsFile; public $leimnudInitString = ' var leimnud = new maborak();
var $leimnudInitString = ' var leimnud = new maborak();
leimnud.make({ leimnud.make({
zip:true, zip:true,
inGulliver:true, inGulliver:true,
modules :"dom,abbr,rpc,drag,drop,app,panel,fx,grid,xmlform,validator,dashboard", modules :"dom,abbr,rpc,drag,drop,app,panel,fx,grid,xmlform,validator,dashboard",
files :"" files :""
});'; });';
var $headerScript = ' public $headerScript = '
try{ try{
leimnud.exec(leimnud.fix.memoryLeak); leimnud.exec(leimnud.fix.memoryLeak);
if(leimnud.browser.isIphone){ if(leimnud.browser.isIphone){
leimnud.iphone.make(); leimnud.iphone.make();
} }
}catch(e){}'; }catch(e){}';
var $disableHeaderScripts = false; public $disableHeaderScripts = false;
var $title = ''; public $title = '';
/** /**
* Function headPublisher * Function headPublisher
@@ -87,14 +87,13 @@ class headPublisher
* @access public * @access public
* @return string * @return string
*/ */
public function __construct()
public function __construct ()
{ {
$this->addScriptFile( "/js/maborak/core/maborak.js" ); $this->addScriptFile("/js/maborak/core/maborak.js");
$this->translationsFile = "/js/ext/translation." . SYS_LANG . ".js"; $this->translationsFile = "/js/ext/translation." . SYS_LANG . ".js";
} }
function &getSingleton () public function &getSingleton()
{ {
if (self::$instance == null) { if (self::$instance == null) {
self::$instance = new headPublisher(); self::$instance = new headPublisher();
@@ -111,7 +110,7 @@ class headPublisher
* @param eter string LoadType * @param eter string LoadType
* @return string * @return string
*/ */
function setTitle ($title) public function setTitle($title)
{ {
$this->title = $title; $this->title = $title;
} }
@@ -125,7 +124,7 @@ class headPublisher
* @param eter string LoadType * @param eter string LoadType
* @return string * @return string
*/ */
function addScriptFile ($url, $LoadType = 1) public function addScriptFile($url, $LoadType = 1)
{ {
if ($LoadType == 1) { if ($LoadType == 1) {
$this->scriptFiles[$url] = $url; $this->scriptFiles[$url] = $url;
@@ -144,8 +143,7 @@ class headPublisher
* @param eter string module * @param eter string module
* @return string * @return string
*/ */
public function addInstanceModule($instance, $module)
function addInstanceModule ($instance, $module)
{ {
$this->headerScript .= "leimnud.Package.Load('" . $module . "',{Instance:" . $instance . ",Type:'module'});\n"; $this->headerScript .= "leimnud.Package.Load('" . $module . "',{Instance:" . $instance . ",Type:'module'});\n";
} }
@@ -159,7 +157,7 @@ class headPublisher
* @param eter string module * @param eter string module
* @return string * @return string
*/ */
function addClassModule ($class, $module) public function addClassModule($class, $module)
{ {
$this->headerScript .= "leimnud.Package.Load('" . $module . "',{Class:" . $class . ",Type:'module'});\n"; $this->headerScript .= "leimnud.Package.Load('" . $module . "',{Class:" . $class . ",Type:'module'});\n";
} }
@@ -172,7 +170,7 @@ class headPublisher
* @param eter string script * @param eter string script
* @return string * @return string
*/ */
function addScriptCode ($script) public function addScriptCode($script)
{ {
$this->headerScript .= $script; $this->headerScript .= $script;
} }
@@ -184,34 +182,33 @@ class headPublisher
* @access public * @access public
* @return string * @return string
*/ */
function printHeader () public function printHeader()
{ {
$jslabel = 'labels/en.js'; $jslabel = 'labels/en.js';
if (defined( 'SYS_LANG' )) { if (defined('SYS_LANG')) {
$jslabel = 'labels' . PATH_SEP . SYS_LANG . '.js'; $jslabel = 'labels' . PATH_SEP . SYS_LANG . '.js';
if (! file_exists( PATH_CORE . 'js' . PATH_SEP . $jslabel )) { if (!file_exists(PATH_CORE . 'js' . PATH_SEP . $jslabel)) {
$jslabel = 'labels/en.js'; $jslabel = 'labels/en.js';
} }
} }
if (file_exists( PATH_CORE . 'js' . PATH_SEP . $jslabel )) { if (file_exists(PATH_CORE . 'js' . PATH_SEP . $jslabel)) {
$this->addScriptFile( '/jscore/' . $jslabel, 1 ); $this->addScriptFile('/jscore/' . $jslabel, 1);
} }
if ($this->disableHeaderScripts) { if ($this->disableHeaderScripts) {
return ''; return '';
} }
// available js-calendar languages array // available js-calendar languages array
$availableJsCalendarLang = array ('ca','cn','cz','de','en','es','fr','it','jp','nl','pl','pt','ro','ru','sv' $availableJsCalendarLang = array('ca', 'cn', 'cz', 'de', 'en', 'es', 'fr', 'it', 'jp', 'nl', 'pl', 'pt', 'ro', 'ru', 'sv');
);
// get the system language without locale // get the system language without locale
$sysLang = explode( '-', SYS_LANG ); $sysLang = explode('-', SYS_LANG);
$sysLang = $sysLang[0]; $sysLang = $sysLang[0];
// verify if the requested lang by the system is supported by js-calendar library, if not set english by default // 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'; $sysLang = in_array($sysLang, $availableJsCalendarLang) ? $sysLang : 'en';
$this->addScriptFile( "/js/widgets/js-calendar/unicode-letter.js" ); $this->addScriptFile("/js/widgets/js-calendar/unicode-letter.js");
//$this->addScriptFile( "/js/widgets/js-calendar/lang/" . $sysLang . ".js" ); //$this->addScriptFile( "/js/widgets/js-calendar/lang/" . $sysLang . ".js" );
$head = ''; $head = '';
@@ -219,7 +216,7 @@ class headPublisher
foreach ($this->scriptFiles as $file) { foreach ($this->scriptFiles as $file) {
$head .= "<script type='text/javascript' src='" . $file . "'></script>\n"; $head .= "<script type='text/javascript' src='" . $file . "'></script>\n";
} }
if(!in_array( $this->translationsFile, $this->scriptFiles)) { if (!in_array($this->translationsFile, $this->scriptFiles)) {
$head .= "<script type='text/javascript' src='" . $this->translationsFile . "'></script>\n"; $head .= "<script type='text/javascript' src='" . $this->translationsFile . "'></script>\n";
} }
@@ -245,12 +242,12 @@ class headPublisher
* @access public * @access public
* @return string * @return string
*/ */
function printRawHeader () public function printRawHeader()
{ {
$jslabel = '/jscore/labels/en.js'; $jslabel = '/jscore/labels/en.js';
if (defined( 'SYS_LANG' )) { if (defined('SYS_LANG')) {
$jslabel1 = 'labels' . PATH_SEP . SYS_LANG . '.js'; $jslabel1 = 'labels' . PATH_SEP . SYS_LANG . '.js';
if (! file_exists( PATH_CORE . 'js' . PATH_SEP . $jslabel1 )) { if (!file_exists(PATH_CORE . 'js' . PATH_SEP . $jslabel1)) {
$jslabel = '/jscore/labels/en.js'; $jslabel = '/jscore/labels/en.js';
} }
} }
@@ -265,7 +262,7 @@ class headPublisher
$head .= " eval(ajax_function('" . $file . "','',''));\n"; $head .= " eval(ajax_function('" . $file . "','',''));\n";
} }
//Adapts the add events on load to simple javascript sentences. //Adapts the add events on load to simple javascript sentences.
$this->headerScript = preg_replace( '/\s*leimnud.event.add\s*\(\s*window\s*,\s*(?:\'|")load(?:\'|")\s*,\s*function\(\)\{(.+)\}\s*\)\s*;?/', '$1', $this->headerScript ); $this->headerScript = preg_replace('/\s*leimnud.event.add\s*\(\s*window\s*,\s*(?:\'|")load(?:\'|")\s*,\s*function\(\)\{(.+)\}\s*\)\s*;?/', '$1', $this->headerScript);
$head .= $this->headerScript; $head .= $this->headerScript;
//$head .= "</script>\n"; //$head .= "</script>\n";
return $head; return $head;
@@ -279,10 +276,10 @@ class headPublisher
* @access public * @access public
* @return string * @return string
*/ */
function clearScripts () public function clearScripts()
{ {
$this->scriptFiles = array (); $this->scriptFiles = array();
$this->leimnudLoad = array (); $this->leimnudLoad = array();
$this->leimnudInitString = ''; $this->leimnudInitString = '';
$this->headerScript = ''; $this->headerScript = '';
} }
@@ -298,14 +295,14 @@ class headPublisher
* @access public * @access public
* @return string * @return string
*/ */
function includeExtJs () public function includeExtJs()
{ {
$this->clearScripts(); $this->clearScripts();
$head = ''; $head = '';
$head .= " <script type='text/javascript' src='/js/ext/ext-base.js'></script>\n"; $head .= " <script type='text/javascript' src='/js/ext/ext-base.js'></script>\n";
$head .= " <script type='text/javascript' src='/js/ext/ext-all.js'></script>\n"; $head .= " <script type='text/javascript' src='/js/ext/ext-all.js'></script>\n";
$aux = explode( '-', strtolower( SYS_LANG ) ); $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' )) { if (($aux[0] != 'en') && file_exists(PATH_GULLIVER_HOME . 'js' . PATH_SEP . 'ext' . PATH_SEP . 'locale' . PATH_SEP . 'ext-lang-' . $aux[0] . '.js')) {
$head .= " <script type='text/javascript' src='/js/ext/locale/ext-lang-" . $aux[0] . ".js'></script>\n"; $head .= " <script type='text/javascript' src='/js/ext/locale/ext-lang-" . $aux[0] . ".js'></script>\n";
} }
@@ -315,7 +312,7 @@ class headPublisher
// $head .= " <script type='text/javascript' src='/js/ext/draw2d.js'></script>\n"; // $head .= " <script type='text/javascript' src='/js/ext/draw2d.js'></script>\n";
// $head .= " <script type='text/javascript' src='/js/ext/translation." . SYS_LANG . ".js'></script>\n"; // $head .= " <script type='text/javascript' src='/js/ext/translation." . SYS_LANG . ".js'></script>\n";
if (! isset( $this->extJsSkin ) || $this->extJsSkin == '') { if (!isset($this->extJsSkin) || $this->extJsSkin == '') {
$this->extJsSkin = 'xtheme-gray'; $this->extJsSkin = 'xtheme-gray';
//$this->extJsSkin = 'gtheme'; //$this->extJsSkin = 'gtheme';
} }
@@ -323,34 +320,34 @@ class headPublisher
$head .= $this->getExtJsScripts(); $head .= $this->getExtJsScripts();
$head .= $this->getExtJsVariablesScript(); $head .= $this->getExtJsVariablesScript();
$oServerConf = & serverConf::getSingleton(); $oServerConf = & serverConf::getSingleton();
if ($oServerConf->isRtl( SYS_LANG )) { if ($oServerConf->isRtl(SYS_LANG)) {
$head .= " <script type='text/javascript' src='/js/ext/extjs_rtl.js'></script>\n"; $head .= " <script type='text/javascript' src='/js/ext/extjs_rtl.js'></script>\n";
} }
return $head; return $head;
} }
function getExtJsStylesheets ($skinName) public function getExtJsStylesheets($skinName)
{ {
$script = " <link rel='stylesheet' type='text/css' href='/css/$skinName.css' />\n"; $script = " <link rel='stylesheet' type='text/css' href='/css/$skinName.css' />\n";
//$script .= " <script type='text/javascript' src='/js/ext/translation." . SYS_LANG . ".js'></script>\n"; //$script .= " <script type='text/javascript' src='/js/ext/translation." . SYS_LANG . ".js'></script>\n";
/* /*
$script .= " <link rel='stylesheet' type='text/css' href='/skins/ext/ext-all-notheme.css' />\n"; $script .= " <link rel='stylesheet' type='text/css' href='/skins/ext/ext-all-notheme.css' />\n";
$script .= " <link rel='stylesheet' type='text/css' href='/skins/ext/" . $this->extJsSkin.".css' />\n"; $script .= " <link rel='stylesheet' type='text/css' href='/skins/ext/" . $this->extJsSkin.".css' />\n";
// <!-- DEPRECATED, this will be removed in a future - the three next lines // <!-- DEPRECATED, this will be removed in a future - the three next lines
if (file_exists ( PATH_HTML . 'skins' . PATH_SEP . 'ext' . PATH_SEP . 'pmos-' . $this->extJsSkin . '.css' )) { if (file_exists ( PATH_HTML . 'skins' . PATH_SEP . 'ext' . PATH_SEP . 'pmos-' . $this->extJsSkin . '.css' )) {
$script .= " <link rel='stylesheet' type='text/css' href='/skins/ext/pmos-" . $this->extJsSkin . ".css' />\n"; $script .= " <link rel='stylesheet' type='text/css' href='/skins/ext/pmos-" . $this->extJsSkin . ".css' />\n";
} }
//DEPRECATED, this will be removed in a future --> //DEPRECATED, this will be removed in a future -->
//new interactive css decorator //new interactive css decorator
$script .= " <link rel='stylesheet' type='text/css' href='/gulliver/loader?t=extjs-cssExtended&s=".$this->extJsSkin."' />\n"; $script .= " <link rel='stylesheet' type='text/css' href='/gulliver/loader?t=extjs-cssExtended&s=".$this->extJsSkin."' />\n";
$script .= " <link rel='stylesheet' type='text/css' href='/images/icons_silk/sprite.css' />\n"; $script .= " <link rel='stylesheet' type='text/css' href='/images/icons_silk/sprite.css' />\n";
*/ */
// Load external/plugin css // Load external/plugin css
// NOTE is necesary to move this to decorator server // NOTE is necesary to move this to decorator server
if (class_exists( 'PMPluginRegistry' )) { if (class_exists('PMPluginRegistry')) {
$oPluginRegistry = & PMPluginRegistry::getSingleton(); $oPluginRegistry = & PMPluginRegistry::getSingleton();
$registeredCss = $oPluginRegistry->getRegisteredCss(); $registeredCss = $oPluginRegistry->getRegisteredCss();
foreach ($registeredCss as $cssFile) { foreach ($registeredCss as $cssFile) {
@@ -360,10 +357,10 @@ class headPublisher
return $script; return $script;
} }
function getExtJsScripts () public function getExtJsScripts()
{ {
$script = ''; $script = '';
if (isset( $this->extJsScript ) && is_array( $this->extJsScript )) { if (isset($this->extJsScript) && is_array($this->extJsScript)) {
foreach ($this->extJsScript as $key => $file) { foreach ($this->extJsScript as $key => $file) {
$script .= " <script type='text/javascript' src='" . $file . ".js'></script>\n"; $script .= " <script type='text/javascript' src='" . $file . ".js'></script>\n";
} }
@@ -371,40 +368,40 @@ class headPublisher
return $script; return $script;
} }
function getExtJsVariablesScript () public function getExtJsVariablesScript()
{ {
$script = ''; $script = '';
if (count( $this->extVariable ) > 0) { if (count($this->extVariable) > 0) {
$script = "<script language='javascript'>\n"; $script = "<script language='javascript'>\n";
foreach ($this->extVariable as $key => $val) { foreach ($this->extVariable as $key => $val) {
$name = $val['name']; $name = $val['name'];
$value = $val['value']; $value = $val['value'];
$variablesValues = G::json_encode( $value ); $variablesValues = G::json_encode($value);
$variablesValues = $this->stripCodeQuotes( $variablesValues ); $variablesValues = $this->stripCodeQuotes($variablesValues);
// var_dump($variablesValues); // var_dump($variablesValues);
// echo "<br>"; // echo "<br>";
$script .= " var $name = " . $variablesValues . ";\n"; $script .= " var $name = " . $variablesValues . ";\n";
/* /*
if ($val ['type'] == 'number') if ($val ['type'] == 'number')
$script .= " var $name = $value;\n"; $script .= " var $name = $value;\n";
else else
$script .= " var $name = '$value';\n"; $script .= " var $name = '$value';\n";
*/ */
} }
$script .= "</script>\n"; $script .= "</script>\n";
} }
return $script; return $script;
} }
function getExtJsLibraries () public function getExtJsLibraries()
{ {
$script = ''; $script = '';
if (isset( $this->extJsLibrary ) && is_array( $this->extJsLibrary )) { if (isset($this->extJsLibrary) && is_array($this->extJsLibrary)) {
foreach ($this->extJsLibrary as $file) { foreach ($this->extJsLibrary as $file) {
$script .= " <script type='text/javascript' src='/js/ext/" . $file . ".js'></script>\n"; $script .= " <script type='text/javascript' src='/js/ext/" . $file . ".js'></script>\n";
} }
} }
if(!in_array( $this->translationsFile, $this->extJsLibrary)) { if (!in_array($this->translationsFile, $this->extJsLibrary)) {
$script .= " <script type='text/javascript' src='" . $this->translationsFile . "'></script>\n"; $script .= " <script type='text/javascript' src='" . $this->translationsFile . "'></script>\n";
} }
return $script; return $script;
@@ -418,12 +415,12 @@ class headPublisher
* @param (String) http js path library * @param (String) http js path library
* @return none * @return none
*/ */
function usingExtJs ($library) public function usingExtJs($library)
{ {
if (! is_string( $library )) { if (!is_string($library)) {
throw new Exception( 'headPublisher::usingExt->ERROR - the parameter should be a js path string' ); throw new Exception('headPublisher::usingExt->ERROR - the parameter should be a js path string');
} }
array_push( $this->extJsLibrary, $library ); array_push($this->extJsLibrary, $library);
} }
/** /**
@@ -433,7 +430,7 @@ class headPublisher
* @access public * @access public
* @return string * @return string
*/ */
function setExtSkin ($skin) public function setExtSkin($skin)
{ {
$this->extJsSkin = $skin; $this->extJsSkin = $skin;
} }
@@ -455,72 +452,72 @@ class headPublisher
* @access public * @access public
* @return string * @return string
*/ */
function addExtJsScript ($filename, $debug = false, $isExternal = false) public function addExtJsScript($filename, $debug = false, $isExternal = false)
{ {
$sPath = PATH_TPL; $sPath = PATH_TPL;
//if the template file doesn't exists, then try with the plugins folders //if the template file doesn't exists, then try with the plugins folders
if (! is_file( $sPath . $filename . ".js" )) { if (!is_file($sPath . $filename . ".js")) {
$aux = explode( PATH_SEP, $filename ); $aux = explode(PATH_SEP, $filename);
//check if G_PLUGIN_CLASS is defined, because publisher can be called without an environment //check if G_PLUGIN_CLASS is defined, because publisher can be called without an environment
if (count( $aux ) == 2 && defined( 'G_PLUGIN_CLASS' )) { if (count($aux) == 2 && defined('G_PLUGIN_CLASS')) {
$oPluginRegistry = & PMPluginRegistry::getSingleton(); $oPluginRegistry = & PMPluginRegistry::getSingleton();
if ($oPluginRegistry->isRegisteredFolder( $aux[0] )) { if ($oPluginRegistry->isRegisteredFolder($aux[0])) {
$sPath = PATH_PLUGINS; $sPath = PATH_PLUGINS;
} }
} }
} }
if (! $isExternal) { if (!$isExternal) {
$jsFilename = $sPath . $filename . '.js'; $jsFilename = $sPath . $filename . '.js';
} else { } else {
$jsFilename = $filename . '.js'; $jsFilename = $filename . '.js';
} }
if (! file_exists( $jsFilename )) { if (!file_exists($jsFilename)) {
return; return;
} }
$mtime = filemtime( $jsFilename ); $mtime = filemtime($jsFilename);
G::mk_dir( PATH_C . 'ExtJs' ); G::mk_dir(PATH_C . 'ExtJs');
if ($debug) { if ($debug) {
$cacheName = str_replace( '/', '_', $filename ); $cacheName = str_replace('/', '_', $filename);
$cacheFilename = PATH_C . 'ExtJs' . PATH_SEP . $cacheName . '.js'; $cacheFilename = PATH_C . 'ExtJs' . PATH_SEP . $cacheName . '.js';
file_put_contents( $cacheFilename, file_get_contents( $jsFilename ) ); file_put_contents($cacheFilename, file_get_contents($jsFilename));
} else { } else {
$cacheName = md5( $mtime . $jsFilename ); $cacheName = md5($mtime . $jsFilename);
$cacheFilename = PATH_C . 'ExtJs' . PATH_SEP . $cacheName . '.js'; $cacheFilename = PATH_C . 'ExtJs' . PATH_SEP . $cacheName . '.js';
if (! file_exists( $cacheFilename )) { if (!file_exists($cacheFilename)) {
require_once (PATH_THIRDPARTY . 'jsmin/jsmin.php'); require_once (PATH_THIRDPARTY . 'jsmin/jsmin.php');
$content = JSMin::minify( file_get_contents( $jsFilename ) ); $content = JSMin::minify(file_get_contents($jsFilename));
file_put_contents( $cacheFilename, $content ); file_put_contents($cacheFilename, $content);
} }
} }
$this->extJsScript[] = '/extjs/' . $cacheName; $this->extJsScript[] = '/extjs/' . $cacheName;
//hook for registered javascripts from plugins //hook for registered javascripts from plugins
if (class_exists( 'PMPluginRegistry' )) { if (class_exists('PMPluginRegistry')) {
$oPluginRegistry = & PMPluginRegistry::getSingleton(); $oPluginRegistry = & PMPluginRegistry::getSingleton();
$pluginJavascripts = $oPluginRegistry->getRegisteredJavascriptBy( $filename ); $pluginJavascripts = $oPluginRegistry->getRegisteredJavascriptBy($filename);
} else { } else {
$pluginJavascripts = array (); $pluginJavascripts = array();
} }
if (count( $pluginJavascripts ) > 0) { if (count($pluginJavascripts) > 0) {
if ($debug) { if ($debug) {
foreach ($pluginJavascripts as $pluginJsFile) { foreach ($pluginJavascripts as $pluginJsFile) {
$jsPluginCacheName = ''; $jsPluginCacheName = '';
if (substr( $pluginJsFile, - 3 ) != '.js') { if (substr($pluginJsFile, - 3) != '.js') {
$pluginJsFile .= '.js'; $pluginJsFile .= '.js';
} }
if (file_exists( PATH_PLUGINS . $pluginJsFile )) { if (file_exists(PATH_PLUGINS . $pluginJsFile)) {
$jsPluginCacheName = str_replace( '/', '_', str_replace( '.js', '', $pluginJsFile ) ); $jsPluginCacheName = str_replace('/', '_', str_replace('.js', '', $pluginJsFile));
$cacheFilename = PATH_C . 'ExtJs' . PATH_SEP . $jsPluginCacheName . ".js"; $cacheFilename = PATH_C . 'ExtJs' . PATH_SEP . $jsPluginCacheName . ".js";
file_put_contents( $cacheFilename, file_get_contents( PATH_PLUGINS . $pluginJsFile ) ); file_put_contents($cacheFilename, file_get_contents(PATH_PLUGINS . $pluginJsFile));
} }
if ($jsPluginCacheName != '') { if ($jsPluginCacheName != '') {
$this->extJsScript[] = '/extjs/' . $jsPluginCacheName; $this->extJsScript[] = '/extjs/' . $jsPluginCacheName;
@@ -529,18 +526,18 @@ class headPublisher
} else { } else {
foreach ($pluginJavascripts as $pluginJsFile) { foreach ($pluginJavascripts as $pluginJsFile) {
$jsPluginCacheName = ''; $jsPluginCacheName = '';
if (substr( $pluginJsFile, - 3 ) !== '.js') { if (substr($pluginJsFile, - 3) !== '.js') {
$pluginJsFile .= '.js'; $pluginJsFile .= '.js';
} }
if (file_exists( PATH_PLUGINS . $pluginJsFile )) { if (file_exists(PATH_PLUGINS . $pluginJsFile)) {
$mtime = filemtime( PATH_PLUGINS . $pluginJsFile ); $mtime = filemtime(PATH_PLUGINS . $pluginJsFile);
$jsPluginCacheName = md5( $mtime . $pluginJsFile ); $jsPluginCacheName = md5($mtime . $pluginJsFile);
$cacheFilename = PATH_C . 'ExtJs' . PATH_SEP . $jsPluginCacheName . '.js'; $cacheFilename = PATH_C . 'ExtJs' . PATH_SEP . $jsPluginCacheName . '.js';
if (! file_exists( $cacheFilename )) { if (!file_exists($cacheFilename)) {
require_once (PATH_THIRDPARTY . 'jsmin/jsmin.php'); require_once (PATH_THIRDPARTY . 'jsmin/jsmin.php');
$content = JSMin::minify( file_get_contents( PATH_PLUGINS . $pluginJsFile ) ); $content = JSMin::minify(file_get_contents(PATH_PLUGINS . $pluginJsFile));
file_put_contents( $cacheFilename, $content ); file_put_contents($cacheFilename, $content);
} }
} }
if ($jsPluginCacheName != '') { if ($jsPluginCacheName != '') {
@@ -565,12 +562,12 @@ class headPublisher
* @access public * @access public
* @return string * @return string
*/ */
function AddContent ($templateHtml) public function AddContent($templateHtml)
{ {
$this->extJsContent[] = $templateHtml; $this->extJsContent[] = $templateHtml;
} }
function getContent () public function getContent()
{ {
return $this->extJsContent; return $this->extJsContent;
} }
@@ -584,18 +581,18 @@ class headPublisher
* @access public * @access public
* @return string * @return string
*/ */
function Assign ($variable, $value) public function Assign($variable, $value)
{ {
$this->extVariable[] = array ('name' => $variable,'value' => $value,'type' => 'string' $this->extVariable[] = array('name' => $variable, 'value' => $value, 'type' => 'string'
); );
} }
function AssignVar ($name, $value) public function AssignVar($name, $value)
{ {
$this->vars[$name] = $value; $this->vars[$name] = $value;
} }
function getVars () public function getVars()
{ {
return $this->vars; return $this->vars;
} }
@@ -609,10 +606,9 @@ class headPublisher
* @access public * @access public
* @return string * @return string
*/ */
function AssignNumber ($variable, $value) public function AssignNumber($variable, $value)
{ {
$this->extVariable[] = array ('name' => $variable,'value' => $value,'type' => 'number' $this->extVariable[] = array('name' => $variable, 'value' => $value, 'type' => 'number');
);
} }
/** /**
@@ -624,29 +620,29 @@ class headPublisher
* @access public * @access public
* @return string * @return string
*/ */
function renderExtJs () public function renderExtJs()
{ {
$body = ''; $body = '';
if (isset( $this->extJsContent ) && is_array( $this->extJsContent )) { if (isset($this->extJsContent) && is_array($this->extJsContent)) {
foreach ($this->extJsContent as $key => $file) { foreach ($this->extJsContent as $key => $file) {
$sPath = PATH_TPL; $sPath = PATH_TPL;
//if the template file doesn't exists, then try with the plugins folders //if the template file doesn't exists, then try with the plugins folders
if (! is_file( $sPath . $file . ".html" )) { if (!is_file($sPath . $file . ".html")) {
$aux = explode( PATH_SEP, $file ); $aux = explode(PATH_SEP, $file);
//check if G_PLUGIN_CLASS is defined, because publisher can be called without an environment //check if G_PLUGIN_CLASS is defined, because publisher can be called without an environment
if (count( $aux ) == 2 && defined( 'G_PLUGIN_CLASS' )) { if (count($aux) == 2 && defined('G_PLUGIN_CLASS')) {
$oPluginRegistry = & PMPluginRegistry::getSingleton(); $oPluginRegistry = & PMPluginRegistry::getSingleton();
if ($oPluginRegistry->isRegisteredFolder( $aux[0] )) { if ($oPluginRegistry->isRegisteredFolder($aux[0])) {
$sPath = PATH_PLUGINS; $sPath = PATH_PLUGINS;
} }
} }
} }
$template = new TemplatePower( $sPath . $file . '.html' ); $template = new TemplatePower($sPath . $file . '.html');
$template->prepare(); $template->prepare();
foreach ($this->getVars() as $k => $v) { foreach ($this->getVars() as $k => $v) {
$template->assign( $k, $v ); $template->assign($k, $v);
} }
$body .= $template->getOutputContent(); $body .= $template->getOutputContent();
@@ -655,24 +651,24 @@ class headPublisher
return $body; return $body;
} }
function stripCodeQuotes ($sJson) public function stripCodeQuotes($sJson)
{ {
$fields = array ("editor","renderer" $fields = array("editor", "renderer"
); );
foreach ($fields as $field) { foreach ($fields as $field) {
$pattern = '/"(' . $field . ')":"[a-zA-Z.()]*"/'; $pattern = '/"(' . $field . ')":"[a-zA-Z.()]*"/';
// echo $pattern."<br>"; // echo $pattern."<br>";
preg_match( $pattern, $sJson, $matches ); preg_match($pattern, $sJson, $matches);
// var_dump ($matches); // var_dump ($matches);
// echo "<br>"; // echo "<br>";
if (! empty( $matches )) { if (!empty($matches)) {
$rendererMatch = $matches[0]; $rendererMatch = $matches[0];
$replaceBy = explode( ":", $matches[0] ); $replaceBy = explode(":", $matches[0]);
$replaceBy[1] = str_replace( '"', '', $replaceBy[1] ); $replaceBy[1] = str_replace('"', '', $replaceBy[1]);
$tmpString = implode( ":", $replaceBy ); $tmpString = implode(":", $replaceBy);
$sJson = str_replace( $rendererMatch, $tmpString, $sJson ); $sJson = str_replace($rendererMatch, $tmpString, $sJson);
// var_dump ($sJson); // var_dump ($sJson);
// echo "<br>"; // echo "<br>";
} }
} }
return $sJson; return $sJson;
@@ -687,7 +683,7 @@ class headPublisher
* @access public * @access public
* @return string * @return string
*/ */
function disableHeaderScripts () public function disableHeaderScripts()
{ {
$this->disableHeaderScripts = true; $this->disableHeaderScripts = true;
} }

View File

@@ -1,4 +1,5 @@
<?php <?php
/** /**
* class.helper.php * class.helper.php
* @package gulliver.system * @package gulliver.system
@@ -30,70 +31,85 @@
* @package gulliver.system * @package gulliver.system
* @access public * @access public
*/ */
class Helper
{
class Helper{ public $content;
public $content; public $gzipEnabled;
public $gzipEnabled; public $minified;
public $minified; public $gzipModuleEnabled;
public $gzipModuleEnabled; public $contentType;
public $contentType;
function __construct(){ public function __construct()
$this->content = ''; {
$this->gzipEnabled = true; $this->content = '';
$this->minified = true; $this->gzipEnabled = true;
$this->gzipModuleEnabled = false; $this->minified = true;
$this->contentType = 'text/html'; $this->gzipModuleEnabled = false;
} $this->contentType = 'text/html';
}
function addFile($file){ public function addFile($file)
if( is_file($file) ) {
$this->content .= file_get_contents($file); if (is_file($file)) {
} $this->content .= file_get_contents($file);
}
}
function addContent($content){ public function addContent($content)
$this->content = $content; {
} $this->content = $content;
}
function setContentType($ctype){ public function setContentType($ctype)
$this->contentType = $ctype; {
} $this->contentType = $ctype;
}
function init(){ public function init()
header("Content-type: {$this->contentType}"); {
header('Pragma: cache'); header("Content-type: {$this->contentType}");
header('Cache-Control: public'); header('Pragma: cache');
header('Cache-Control: public');
if( $this->gzipEnabled && extension_loaded('zlib') ){ if ($this->gzipEnabled && extension_loaded('zlib')) {
$this->gzipModuleEnabled = true; $this->gzipModuleEnabled = true;
ob_start('ob_gzhandler'); ob_start('ob_gzhandler');
} else } else {
ob_start(); ob_start();
} }
}
function minify() { public function minify()
if ($this->contentType != 'text/css') { {
G::LoadThirdParty('jsmin', 'jsmin'); if ($this->contentType != 'text/css') {
$this->content = JSMin::minify($this->content); G::LoadThirdParty('jsmin', 'jsmin');
} $this->content = JSMin::minify($this->content);
} }
}
function flush(){ public function flush()
if( $this->minified ) {
$this->minify(); if ($this->minified) {
print($this->content); $this->minify();
ob_end_flush(); }
} print($this->content);
ob_end_flush();
}
function serve($type=null){ public function serve($type = null)
if( isset($type) ) {
$this->setContentType($ctype); if (isset($type)) {
$this->init(); $this->setContentType($ctype);
$this->flush(); }
} $this->init();
$this->flush();
}
} }
/* /*
function minify($buffer) { function minify($buffer) {
return G::removeComments($buffer); return G::removeComments($buffer);
} }
*/ */

View File

@@ -23,7 +23,6 @@
* @icon /images/triggers/alfrescoIcon.png * @icon /images/triggers/alfrescoIcon.png
* @className class.pmTrAlfresco.pmFunctions.php * @className class.pmTrAlfresco.pmFunctions.php
*/ */
/** /**
* @method * @method
* *
@@ -41,14 +40,16 @@
* *
*/ */
G::LoadSystem('restClient'); G::LoadSystem('restClient');
// Validation left // Validation left
function cancelCheckout($alfrescoServerUrl, $docUid, $user="", $pwd="") { function cancelCheckout($alfrescoServerUrl, $docUid, $user = "", $pwd = "")
//require_once(PATH_CORE. 'classes' . PATH_SEP.'triggers' . PATH_SEP . 'class.pmTrAlfresco.php'); {
$alfresco_url = "$alfrescoServerUrl/s/cmis/pwc/s/workspace:SpacesStore/i/$docUid"; //require_once(PATH_CORE. 'classes' . PATH_SEP.'triggers' . PATH_SEP . 'class.pmTrAlfresco.php');
$domapi_exec = RestClient::delete($alfresco_url,$user,$pwd,"application/atom+xml;type=entry"); $alfresco_url = "$alfrescoServerUrl/s/cmis/pwc/s/workspace:SpacesStore/i/$docUid";
//$alfrescoMessage = $domapi_exec['header']; $domapi_exec = RestClient::delete($alfresco_url, $user, $pwd, "application/atom+xml;type=entry");
$domapi_res = G::json_decode($domapi_exec->getResponse()); //$alfrescoMessage = $domapi_exec['header'];
return $domapi_res; $domapi_res = G::json_decode($domapi_exec->getResponse());
return $domapi_res;
} }
/** /**
@@ -69,22 +70,23 @@ return $domapi_res;
* *
*/ */
// Validation done // Validation done
function checkIn($alfrescoServerUrl, $docUid, $comments, $user="", $pwd="") { function checkIn($alfrescoServerUrl, $docUid, $comments, $user = "", $pwd = "")
$alfresco_url = "$alfrescoServerUrl/s/cmis/pwc/i/$docUid?checkin=true&checkinComment=$comments"; {
$xmlData = array(); $alfresco_url = "$alfrescoServerUrl/s/cmis/pwc/i/$docUid?checkin=true&checkinComment=$comments";
$xmlData = '<?xml version="1.0" encoding="utf-8"?><entry xmlns="http://www.w3.org/2005/Atom"/>'; $xmlData = array();
$xmlData = '<?xml version="1.0" encoding="utf-8"?><entry xmlns="http://www.w3.org/2005/Atom"/>';
$alfresco_exec = RestClient::put($alfresco_url,$xmlData,$user,$pwd,"application/atom+xml"); $alfresco_exec = RestClient::put($alfresco_url, $xmlData, $user, $pwd, "application/atom+xml");
$alfrescoMessage = $alfresco_exec->getResponseMessage(); $alfrescoMessage = $alfresco_exec->getResponseMessage();
if($alfrescoMessage === 'OK' ) if ($alfrescoMessage === 'OK') {
return "The Document has been Checkedin"; return "The Document has been Checkedin";
elseif ($alfrescoMessage === 'Internal Server Error') } elseif ($alfrescoMessage === 'Internal Server Error') {
return "Please enter a Valid Document Id"; return "Please enter a Valid Document Id";
else } else {
return $alfrescoMessage; return $alfrescoMessage;
}
} }
/** /**
* @method * @method
* *
@@ -102,19 +104,21 @@ return $alfrescoMessage;
* *
*/ */
// Validation done // Validation done
function checkOut($alfrescoServerUrl, $docUid, $user="", $pwd="") { function checkOut($alfrescoServerUrl, $docUid, $user = "", $pwd = "")
$alfresco_url = "$alfrescoServerUrl/s/cmis/checkedout"; {
$xmlData = array(); $alfresco_url = "$alfrescoServerUrl/s/cmis/checkedout";
$xmlData = '<?xml version="1.0" encoding="utf-8"?>'.'<entry xmlns="http://www.w3.org/2005/Atom" xmlns:cmisra="http://docs.oasis-open.org/ns/cmis/restatom/200908/" xmlns:cmis="http://docs.oasis-open.org/ns/cmis/core/200908/">'.'<cmisra:object>'.'<cmis:properties>'.'<cmis:propertyId propertyDefinitionId="cmis:objectId">'.'<cmis:value>workspace://SpacesStore/'.$docUid.'</cmis:value>'.'</cmis:propertyId>'.'</cmis:properties>'.'</cmisra:object>'.'</entry>'; $xmlData = array();
$xmlData = '<?xml version="1.0" encoding="utf-8"?>' . '<entry xmlns="http://www.w3.org/2005/Atom" xmlns:cmisra="http://docs.oasis-open.org/ns/cmis/restatom/200908/" xmlns:cmis="http://docs.oasis-open.org/ns/cmis/core/200908/">' . '<cmisra:object>' . '<cmis:properties>' . '<cmis:propertyId propertyDefinitionId="cmis:objectId">' . '<cmis:value>workspace://SpacesStore/' . $docUid . '</cmis:value>' . '</cmis:propertyId>' . '</cmis:properties>' . '</cmisra:object>' . '</entry>';
$alfresco_exec = RestClient::post($alfresco_url,$xmlData,$user,$pwd,"application/atom+xml;type=entry"); $alfresco_exec = RestClient::post($alfresco_url, $xmlData, $user, $pwd, "application/atom+xml;type=entry");
$alfrescoMessage = $alfresco_exec->getResponseMessage(); $alfrescoMessage = $alfresco_exec->getResponseMessage();
if($alfrescoMessage === 'Created' ) if ($alfrescoMessage === 'Created') {
return "The Document has been Checkedout"; return "The Document has been Checkedout";
elseif ($alfrescoMessage === 'Conflict') } elseif ($alfrescoMessage === 'Conflict') {
return "The Document you are trying to checkout has already been Checkedout"; return "The Document you are trying to checkout has already been Checkedout";
else } else {
return $alfrescoMessage; return $alfrescoMessage;
}
} }
/** /**
@@ -134,22 +138,23 @@ return $alfrescoMessage;
* @return string | $result | Response * @return string | $result | Response
* *
*/ */
function createFolder($alfrescoServerUrl, $parentFolder, $folderName, $user, $pwd) { function createFolder($alfrescoServerUrl, $parentFolder, $folderName, $user, $pwd)
{
$name = explode("/", $folderName); $name = explode("/", $folderName);
$init = substr($parentFolder,0,1); $init = substr($parentFolder, 0, 1);
$parentFolder = ($init == "/")? substr($parentFolder, 1)."/": $parentFolder."/"; $parentFolder = ($init == "/") ? substr($parentFolder, 1) . "/" : $parentFolder . "/";
$alfresco_url = "$alfrescoServerUrl/s/cmis/p/".$parentFolder."children"; $alfresco_url = "$alfrescoServerUrl/s/cmis/p/" . $parentFolder . "children";
$xmlData = array(); $xmlData = array();
$xmlData = '<?xml version="1.0" encoding="utf-8"?>'.'<entry xmlns="http://www.w3.org/2005/Atom" xmlns:cmisra="http://docs.oasis-open.org/ns/cmis/restatom/200908/" xmlns:cmis="http://docs.oasis-open.org/ns/cmis/core/200908/">'.'<title>'.$name[0].'</title>'.'<cmisra:object>'.'<cmis:properties>'.'<cmis:propertyId propertyDefinitionId="cmis:objectTypeId"><cmis:value>cmis:folder</cmis:value></cmis:propertyId>'.'</cmis:properties>'.'</cmisra:object>'.'</entry>'; $xmlData = '<?xml version="1.0" encoding="utf-8"?>' . '<entry xmlns="http://www.w3.org/2005/Atom" xmlns:cmisra="http://docs.oasis-open.org/ns/cmis/restatom/200908/" xmlns:cmis="http://docs.oasis-open.org/ns/cmis/core/200908/">' . '<title>' . $name[0] . '</title>' . '<cmisra:object>' . '<cmis:properties>' . '<cmis:propertyId propertyDefinitionId="cmis:objectTypeId"><cmis:value>cmis:folder</cmis:value></cmis:propertyId>' . '</cmis:properties>' . '</cmisra:object>' . '</entry>';
$alfresco_exec = RestClient::post($alfresco_url,$xmlData,$user,$pwd,"application/atom+xml"); $alfresco_exec = RestClient::post($alfresco_url, $xmlData, $user, $pwd, "application/atom+xml");
$alfrescoMessage = $alfresco_exec->getResponseMessage(); $alfrescoMessage = $alfresco_exec->getResponseMessage();
$folderName = substr(strstr($folderName, "/"),1); $folderName = substr(strstr($folderName, "/"), 1);
$parentFolder = $parentFolder."".$name[0]; $parentFolder = $parentFolder . "" . $name[0];
if ($folderName != null) { if ($folderName != null) {
createFolder($alfrescoServerUrl, $parentFolder, $folderName, $user, $pwd); createFolder($alfrescoServerUrl, $parentFolder, $folderName, $user, $pwd);
} }
if($alfrescoMessage === 'Created') { if ($alfrescoMessage === 'Created') {
return "The Folder has been Created"; return "The Folder has been Created";
} else { } else {
return $alfrescoMessage; return $alfrescoMessage;
@@ -172,9 +177,10 @@ function createFolder($alfrescoServerUrl, $parentFolder, $folderName, $user, $pw
* @return string | $result | Response * @return string | $result | Response
* *
*/ */
function deleteObject($alfrescoServerUrl, $objetcId, $user, $pwd) { function deleteObject($alfrescoServerUrl, $objetcId, $user, $pwd)
$alfresco_url = "$alfrescoServerUrl/s/cmis/s/workspace:SpacesStore/i/$objetcId"; {
$alfresco_exec = RestClient::delete($alfresco_url,$user,$pwd,"application/atom+xml"); $alfresco_url = "$alfrescoServerUrl/s/cmis/s/workspace:SpacesStore/i/$objetcId";
$alfresco_exec = RestClient::delete($alfresco_url, $user, $pwd, "application/atom+xml");
$alfresco_res = G::json_decode($alfresco_exec->getResponse()); $alfresco_res = G::json_decode($alfresco_exec->getResponse());
echo($alfresco_res); echo($alfresco_res);
@@ -198,10 +204,11 @@ function deleteObject($alfrescoServerUrl, $objetcId, $user, $pwd) {
* @return string | $result | Response * @return string | $result | Response
* *
*/ */
function downloadDoc($alfrescoServerUrl, $pathFile , $pathFolder, $user, $pwd) { function downloadDoc($alfrescoServerUrl, $pathFile, $pathFolder, $user, $pwd)
{
if (!(G::verifyPath($pathFolder))) { if (!(G::verifyPath($pathFolder))) {
G::SendTemporalMessage('ID_FILE_PLUGIN_NOT_EXISTS', 'error', 'labels', null, null, array('pluginFile' => $pathFolder)); G::SendTemporalMessage('ID_FILE_PLUGIN_NOT_EXISTS', 'error', 'labels', null, null, array('pluginFile' => $pathFolder));
G::header('Location: '.$_SERVER['HTTP_REFERER']); G::header('Location: ' . $_SERVER['HTTP_REFERER']);
die; die;
} }
@@ -209,19 +216,19 @@ function downloadDoc($alfrescoServerUrl, $pathFile , $pathFolder, $user, $pwd) {
$nameFile = $dataPathFile['basename']; $nameFile = $dataPathFile['basename'];
$alfresco_url = "$alfrescoServerUrl" . PATH_SEP . "s" . PATH_SEP . "cmis" . PATH_SEP . "p" . PATH_SEP . "Sites" . PATH_SEP . "$pathFile"; $alfresco_url = "$alfrescoServerUrl" . PATH_SEP . "s" . PATH_SEP . "cmis" . PATH_SEP . "p" . PATH_SEP . "Sites" . PATH_SEP . "$pathFile";
$alfresco_exec = RestClient::get($alfresco_url,$user,$pwd,'application/atom+xml'); $alfresco_exec = RestClient::get($alfresco_url, $user, $pwd, 'application/atom+xml');
$sXmlArray = $alfresco_exec->getResponse(); $sXmlArray = $alfresco_exec->getResponse();
$sXmlArray = eregi_replace("[\n|\r|\n\r]", '', $sXmlArray); $sXmlArray = eregi_replace("[\n|\r|\n\r]", '', $sXmlArray);
$xmlObject = simplexml_load_string((string)$sXmlArray); $xmlObject = simplexml_load_string((string) $sXmlArray);
if (!isset($xmlObject->content)) { if (!isset($xmlObject->content)) {
G::SendTemporalMessage('ID_FILE_PLUGIN_NOT_EXISTS', 'error', 'labels', null, null, array('pluginFile' => $nameFile . ' in Alfresco')); G::SendTemporalMessage('ID_FILE_PLUGIN_NOT_EXISTS', 'error', 'labels', null, null, array('pluginFile' => $nameFile . ' in Alfresco'));
G::header('Location: '.$_SERVER['HTTP_REFERER']); G::header('Location: ' . $_SERVER['HTTP_REFERER']);
die; die;
} }
$linkContent = (string)$xmlObject->content->attributes()->src; $linkContent = (string) $xmlObject->content->attributes()->src;
$alfresco_exec = RestClient::get($linkContent,$user,$pwd,'application/atom+xml'); $alfresco_exec = RestClient::get($linkContent, $user, $pwd, 'application/atom+xml');
$sXmlArray = $alfresco_exec->getResponse(); $sXmlArray = $alfresco_exec->getResponse();
$content = eregi_replace("[\n|\r|\n\r]", '', $sXmlArray); $content = eregi_replace("[\n|\r|\n\r]", '', $sXmlArray);
@@ -250,16 +257,17 @@ function downloadDoc($alfrescoServerUrl, $pathFile , $pathFolder, $user, $pwd) {
* @return string | $result | Response * @return string | $result | Response
* *
*/ */
function getCheckedoutFiles($alfrescoServerUrl, $user, $pwd) { function getCheckedoutFiles($alfrescoServerUrl, $user, $pwd)
$getChildrenUrl = "$alfrescoServerUrl/s/cmis/checkedout"; {
$getChildrenUrl = "$alfrescoServerUrl/s/cmis/checkedout";
$domapi_exec = RestClient::get($getChildrenUrl,$user,$pwd,'application/atom+xml'); $domapi_exec = RestClient::get($getChildrenUrl, $user, $pwd, 'application/atom+xml');
$sXmlArray = G::json_decode($domapi_exec->getResponse()); $sXmlArray = G::json_decode($domapi_exec->getResponse());
$sXmlArray = trim($sXmlArray); $sXmlArray = trim($sXmlArray);
$xXmlArray = simplexml_load_string($sXmlArray); $xXmlArray = simplexml_load_string($sXmlArray);
$aXmlArray = @G::json_decode(@G::json_encode($xXmlArray),1); $aXmlArray = @G::json_decode(@G::json_encode($xXmlArray), 1);
return $alfresco_res; return $alfresco_res;
} }
/** /**
@@ -278,13 +286,14 @@ function getCheckedoutFiles($alfrescoServerUrl, $user, $pwd) {
* @return string | $result | Response * @return string | $result | Response
* *
*/ */
function getFolderChildren($alfrescoServerUrl, $folderId, $user, $pwd) { function getFolderChildren($alfrescoServerUrl, $folderId, $user, $pwd)
{
$getChildrenUrl = "$alfrescoServerUrl/service/api/node/workspace/SpacesStore/$folderId/children"; $getChildrenUrl = "$alfrescoServerUrl/service/api/node/workspace/SpacesStore/$folderId/children";
$alfresco_exec = RestClient::get($getChildrenUrl,$user,$pwd); $alfresco_exec = RestClient::get($getChildrenUrl, $user, $pwd);
$sXmlArray = $alfresco_exec->getResponse(); $sXmlArray = $alfresco_exec->getResponse();
$sXmlArray = trim($sXmlArray); $sXmlArray = trim($sXmlArray);
$xXmlArray = simplexml_load_string($sXmlArray); $xXmlArray = simplexml_load_string($sXmlArray);
$aXmlArray = @G::json_decode(@G::json_encode($xXmlArray),1); $aXmlArray = @G::json_decode(@G::json_encode($xXmlArray), 1);
return $aXmlArray; return $aXmlArray;
} }
@@ -309,17 +318,17 @@ function getFolderChildren($alfrescoServerUrl, $folderId, $user, $pwd) {
* @return string | $result | Response * @return string | $result | Response
* *
*/ */
function uploadDoc($alfrescoServerUrl, $fileSource, $title, $description, $docType, $user, $pwd, $path = '') { function uploadDoc($alfrescoServerUrl, $fileSource, $title, $description, $docType, $user, $pwd, $path = '')
if (!(file_exists($fileSource))) {
{ if (!(file_exists($fileSource))) {
G::SendTemporalMessage('ID_FILE_PLUGIN_NOT_EXISTS', 'error', 'labels', null, null, array('pluginFile' => $fileSource)); G::SendTemporalMessage('ID_FILE_PLUGIN_NOT_EXISTS', 'error', 'labels', null, null, array('pluginFile' => $fileSource));
G::header('Location: '.$_SERVER['HTTP_REFERER']); G::header('Location: ' . $_SERVER['HTTP_REFERER']);
die; die;
} }
$filep = fopen($fileSource,"r"); $filep = fopen($fileSource, "r");
$fileLength = filesize($fileSource); $fileLength = filesize($fileSource);
$fileContent = fread($filep,$fileLength); $fileContent = fread($filep, $fileLength);
$fileContent = base64_encode($fileContent); $fileContent = base64_encode($fileContent);
if ($path != '') { if ($path != '') {
createFolder($alfrescoServerUrl, 'Sites', $path, $user, $pwd); createFolder($alfrescoServerUrl, 'Sites', $path, $user, $pwd);
@@ -328,13 +337,14 @@ function uploadDoc($alfrescoServerUrl, $fileSource, $title, $description, $docTy
$alfresco_url = "$alfrescoServerUrl/s/cmis/p/Sites/" . $path . "children"; $alfresco_url = "$alfrescoServerUrl/s/cmis/p/Sites/" . $path . "children";
$xmlData = array(); $xmlData = array();
$xmlData = '<?xml version="1.0" encoding="utf-8"?><entry xmlns="http://www.w3.org/2005/Atom" xmlns:cmisra="http://docs.oasis-open.org/ns/cmis/restatom/200908/" xmlns:cmis="http://docs.oasis-open.org/ns/cmis/core/200908/"><title>'.$title.'</title><summary>'.$description.'</summary><content type="application/'.$docType.'">'.$fileContent.'</content><cmisra:object><cmis:properties><cmis:propertyId propertyDefinitionId="cmis:objectTypeId"><cmis:value>cmis:document</cmis:value></cmis:propertyId></cmis:properties></cmisra:object></entry>'; $xmlData = '<?xml version="1.0" encoding="utf-8"?><entry xmlns="http://www.w3.org/2005/Atom" xmlns:cmisra="http://docs.oasis-open.org/ns/cmis/restatom/200908/" xmlns:cmis="http://docs.oasis-open.org/ns/cmis/core/200908/"><title>' . $title . '</title><summary>' . $description . '</summary><content type="application/' . $docType . '">' . $fileContent . '</content><cmisra:object><cmis:properties><cmis:propertyId propertyDefinitionId="cmis:objectTypeId"><cmis:value>cmis:document</cmis:value></cmis:propertyId></cmis:properties></cmisra:object></entry>';
$alfresco_exec = RestClient::post($alfresco_url,$xmlData,$user,$pwd,"application/atom+xml"); $alfresco_exec = RestClient::post($alfresco_url, $xmlData, $user, $pwd, "application/atom+xml");
$sXmlArray = $alfresco_exec->getResponse(); $sXmlArray = $alfresco_exec->getResponse();
$sXmlArray = trim($sXmlArray); $sXmlArray = trim($sXmlArray);
$xXmlArray = simplexml_load_string($sXmlArray); $xXmlArray = simplexml_load_string($sXmlArray);
$aXmlArray = @G::json_decode(@G::json_encode($xXmlArray),1); $aXmlArray = @G::json_decode(@G::json_encode($xXmlArray), 1);
return $aXmlArray; return $aXmlArray;
} }

View File

@@ -1,4 +1,5 @@
<?php <?php
/** /**
* cases_SaveDocument.php * cases_SaveDocument.php
* *
@@ -22,144 +23,137 @@
* Coral Gables, FL, 33134, USA, or email info@colosa.com. * Coral Gables, FL, 33134, USA, or email info@colosa.com.
* *
*/ */
try { try {
$docUid=$_POST['form']['DOC_UID']; $docUid = $_POST['form']['DOC_UID'];
$appDocUid=$_POST['form']['APP_DOC_UID']; $appDocUid = $_POST['form']['APP_DOC_UID'];
$docVersion=$_POST['form']['docVersion']; $docVersion = $_POST['form']['docVersion'];
$actionType=$_POST['form']['actionType']; $actionType = $_POST['form']['actionType'];
$appId=$_GET['appId']; $appId = $_GET['appId'];
$docType=isset($_GET['docType'])?$_GET['docType']:""; $docType = isset($_GET['docType']) ? $_GET['docType'] : "";
//save info //save info
require_once ( "classes/model/AppDocument.php" ); require_once ("classes/model/AppDocument.php");
require_once ('classes/model/AppFolder.php'); require_once ('classes/model/AppFolder.php');
require_once ('classes/model/InputDocument.php'); require_once ('classes/model/InputDocument.php');
$oInputDocument = new InputDocument(); $oInputDocument = new InputDocument();
if($_GET['UID']!=-1){ if ($_GET['UID'] != -1) {
$aID = $oInputDocument->load($_GET['UID']); $aID = $oInputDocument->load($_GET['UID']);
}else{ } else {
$oFolder=new AppFolder(); $oFolder = new AppFolder();
$folderStructure=$oFolder->getFolderStructure(isset($_GET['folderId'])?$_GET['folderId']:"/"); $folderStructure = $oFolder->getFolderStructure(isset($_GET['folderId']) ? $_GET['folderId'] : "/");
$aID=array('INP_DOC_DESTINATION_PATH'=>$folderStructure['PATH']); $aID = array('INP_DOC_DESTINATION_PATH' => $folderStructure['PATH']);
} }
$oAppDocument = new AppDocument(); $oAppDocument = new AppDocument();
//Get the Custom Folder ID (create if necessary) //Get the Custom Folder ID (create if necessary)
$oFolder=new AppFolder(); $oFolder = new AppFolder();
if($_GET['UID']!=-1){ if ($_GET['UID'] != -1) {
//krumo("jhl"); //krumo("jhl");
$folderId=$oFolder->createFromPath($aID['INP_DOC_DESTINATION_PATH'],$appId); $folderId = $oFolder->createFromPath($aID['INP_DOC_DESTINATION_PATH'], $appId);
//Tags //Tags
$fileTags=$oFolder->parseTags($aID['INP_DOC_TAGS'],$appId); $fileTags = $oFolder->parseTags($aID['INP_DOC_TAGS'], $appId);
}else{ } else {
$folderId=isset($_GET['folderId'])?$_GET['folderId']:"/"; $folderId = isset($_GET['folderId']) ? $_GET['folderId'] : "/";
$fileTags="EXTERNAL"; $fileTags = "EXTERNAL";
} }
switch($actionType){ switch ($actionType) {
case "R": //replace case "R": //replace
$aFields = array('APP_DOC_UID' => $appDocUid, $aFields = array('APP_DOC_UID' => $appDocUid,
'APP_UID' => $appId, 'APP_UID' => $appId,
'DOC_VERSION' => $docVersion, 'DOC_VERSION' => $docVersion,
'DEL_INDEX' => 1, 'DEL_INDEX' => 1,
'USR_UID' => $_SESSION['USER_LOGGED'], 'USR_UID' => $_SESSION['USER_LOGGED'],
'DOC_UID' => $docUid, 'DOC_UID' => $docUid,
'APP_DOC_TYPE' => $_POST['form']['APP_DOC_TYPE'], 'APP_DOC_TYPE' => $_POST['form']['APP_DOC_TYPE'],
'APP_DOC_CREATE_DATE' => date('Y-m-d H:i:s'), 'APP_DOC_CREATE_DATE' => date('Y-m-d H:i:s'),
'APP_DOC_COMMENT' => isset($_POST['form']['APP_DOC_COMMENT']) ? $_POST['form']['APP_DOC_COMMENT'] : '', 'APP_DOC_COMMENT' => isset($_POST['form']['APP_DOC_COMMENT']) ? $_POST['form']['APP_DOC_COMMENT'] : '',
'APP_DOC_TITLE' => '', 'APP_DOC_TITLE' => '',
'APP_DOC_FILENAME' => isset($_FILES['form']['name']['APP_DOC_FILENAME']) ? $_FILES['form']['name']['APP_DOC_FILENAME'] : '', 'APP_DOC_FILENAME' => isset($_FILES['form']['name']['APP_DOC_FILENAME']) ? $_FILES['form']['name']['APP_DOC_FILENAME'] : '',
'FOLDER_UID' => $folderId, 'FOLDER_UID' => $folderId,
'APP_DOC_TAGS' => $fileTags); 'APP_DOC_TAGS' => $fileTags);
$oAppDocument->update($aFields); $oAppDocument->update($aFields);
break; break;
case "NV": //New Version case "NV": //New Version
$aFields = array('APP_DOC_UID' => $appDocUid,
$aFields = array('APP_DOC_UID' => $appDocUid, 'APP_UID' => $appId,
'APP_UID' => $appId, 'DEL_INDEX' => 1,
'USR_UID' => $_SESSION['USER_LOGGED'],
'DEL_INDEX' => 1, 'DOC_UID' => $docUid,
'USR_UID' => $_SESSION['USER_LOGGED'], 'APP_DOC_TYPE' => $_POST['form']['APP_DOC_TYPE'],
'DOC_UID' => $docUid, 'APP_DOC_CREATE_DATE' => date('Y-m-d H:i:s'),
'APP_DOC_TYPE' => $_POST['form']['APP_DOC_TYPE'], 'APP_DOC_COMMENT' => isset($_POST['form']['APP_DOC_COMMENT']) ? $_POST['form']['APP_DOC_COMMENT'] : '',
'APP_DOC_CREATE_DATE' => date('Y-m-d H:i:s'), 'APP_DOC_TITLE' => '',
'APP_DOC_COMMENT' => isset($_POST['form']['APP_DOC_COMMENT']) ? $_POST['form']['APP_DOC_COMMENT'] : '', 'APP_DOC_FILENAME' => isset($_FILES['form']['name']['APP_DOC_FILENAME']) ? $_FILES['form']['name']['APP_DOC_FILENAME'] : '',
'APP_DOC_TITLE' => '', 'FOLDER_UID' => $folderId,
'APP_DOC_FILENAME' => isset($_FILES['form']['name']['APP_DOC_FILENAME']) ? $_FILES['form']['name']['APP_DOC_FILENAME'] : '', 'APP_DOC_TAGS' => $fileTags);
'FOLDER_UID' => $folderId,
'APP_DOC_TAGS' => $fileTags);
$oAppDocument->create($aFields); $oAppDocument->create($aFields);
break; break;
default: //New default: //New
$aFields = array('APP_UID' => $appId, $aFields = array('APP_UID' => $appId,
'DEL_INDEX' => isset($_SESSION['INDEX'])?$_SESSION['INDEX']:1, 'DEL_INDEX' => isset($_SESSION['INDEX']) ? $_SESSION['INDEX'] : 1,
'USR_UID' => $_SESSION['USER_LOGGED'], 'USR_UID' => $_SESSION['USER_LOGGED'],
'DOC_UID' => $docUid, 'DOC_UID' => $docUid,
'APP_DOC_TYPE' => $_POST['form']['APP_DOC_TYPE'], 'APP_DOC_TYPE' => $_POST['form']['APP_DOC_TYPE'],
'APP_DOC_CREATE_DATE' => date('Y-m-d H:i:s'), 'APP_DOC_CREATE_DATE' => date('Y-m-d H:i:s'),
'APP_DOC_COMMENT' => isset($_POST['form']['APP_DOC_COMMENT']) ? $_POST['form']['APP_DOC_COMMENT'] : '', 'APP_DOC_COMMENT' => isset($_POST['form']['APP_DOC_COMMENT']) ? $_POST['form']['APP_DOC_COMMENT'] : '',
'APP_DOC_TITLE' => '', 'APP_DOC_TITLE' => '',
'APP_DOC_FILENAME' => isset($_FILES['form']['name']['APP_DOC_FILENAME']) ? $_FILES['form']['name']['APP_DOC_FILENAME'] : '', 'APP_DOC_FILENAME' => isset($_FILES['form']['name']['APP_DOC_FILENAME']) ? $_FILES['form']['name']['APP_DOC_FILENAME'] : '',
'FOLDER_UID' => $folderId, 'FOLDER_UID' => $folderId,
'APP_DOC_TAGS' => $fileTags); 'APP_DOC_TAGS' => $fileTags);
$oAppDocument->create($aFields); $oAppDocument->create($aFields);
break; break;
} }
$sAppDocUid = $oAppDocument->getAppDocUid(); $sAppDocUid = $oAppDocument->getAppDocUid();
$iDocVersion = $oAppDocument->getDocVersion(); $iDocVersion = $oAppDocument->getDocVersion();
$info = pathinfo( $oAppDocument->getAppDocFilename() ); $info = pathinfo($oAppDocument->getAppDocFilename());
$ext = (isset($info['extension']) ? $info['extension'] : ''); $ext = (isset($info['extension']) ? $info['extension'] : '');
//save the file //save the file
if (!empty($_FILES['form'])) { if (!empty($_FILES['form'])) {
if ($_FILES['form']['error']['APP_DOC_FILENAME'] == 0) { if ($_FILES['form']['error']['APP_DOC_FILENAME'] == 0) {
$sPathName = PATH_DOCUMENT . $appId . PATH_SEP; $sPathName = PATH_DOCUMENT . $appId . PATH_SEP;
$sFileName = $sAppDocUid . "_".$iDocVersion. '.' . $ext; $sFileName = $sAppDocUid . "_" . $iDocVersion . '.' . $ext;
G::uploadFile($_FILES['form']['tmp_name']['APP_DOC_FILENAME'], $sPathName, $sFileName ); G::uploadFile($_FILES['form']['tmp_name']['APP_DOC_FILENAME'], $sPathName, $sFileName);
//Plugin Hook PM_UPLOAD_DOCUMENT for upload document //Plugin Hook PM_UPLOAD_DOCUMENT for upload document
$oPluginRegistry =& PMPluginRegistry::getSingleton(); $oPluginRegistry = & PMPluginRegistry::getSingleton();
if ( $oPluginRegistry->existsTrigger ( PM_UPLOAD_DOCUMENT ) && class_exists ('uploadDocumentData' ) ) { if ($oPluginRegistry->existsTrigger(PM_UPLOAD_DOCUMENT) && class_exists('uploadDocumentData')) {
$oData['APP_UID'] = $appId; $oData['APP_UID'] = $appId;
$documentData = new uploadDocumentData ( $documentData = new uploadDocumentData(
$appId, $appId,
$_SESSION['USER_LOGGED'], $_SESSION['USER_LOGGED'],
$sPathName . $sFileName, $sPathName . $sFileName,
$aFields['APP_DOC_FILENAME'], $aFields['APP_DOC_FILENAME'],
$sAppDocUid $sAppDocUid
); );
$oPluginRegistry->executeTriggers ( PM_UPLOAD_DOCUMENT , $documentData ); $oPluginRegistry->executeTriggers(PM_UPLOAD_DOCUMENT, $documentData);
unlink ( $sPathName . $sFileName ); unlink($sPathName . $sFileName);
}
//end plugin
} }
//end plugin
}
} }
G::header('location: appFolderList');
die;
G::header('location: appFolderList'); } catch (Exception $e) {
die;
} catch ( Exception $e ) {
/* Render Error page */ /* Render Error page */
$aMessage['MESSAGE'] = $e->getMessage(); $aMessage['MESSAGE'] = $e->getMessage();
$G_PUBLISH = new Publisher; $G_PUBLISH = new Publisher;
$G_PUBLISH->AddContent('xmlform', 'xmlform', 'login/showMessage', '', $aMessage ); $G_PUBLISH->AddContent('xmlform', 'xmlform', 'login/showMessage', '', $aMessage);
G::RenderPage( 'publish' ); G::RenderPage('publish');
} }