/** * @covers G::createUID * @todo Implement testCreateUID(). */ public function testCreateUID() { $uidTest001 = 'cDhpajRHQ2paUQ______'; $responseUID = G::createUID('test', '001'); $this->assertEquals($responseUID, $uidTest001); }
/** * Get the condition for Cases List * * @name getConditionCasesList * @param string $sTypeList * @param string $sUIDUserLogged * @param string $ClearSession * @param string $aAdditionalFilter * @return array */ public function getConditionCasesList($sTypeList = 'all', $sUIDUserLogged = '', $ClearSession = true, $aAdditionalFilter = null) { $c = new Criteria('workflow'); $c->clearSelectColumns(); $c->addSelectColumn(ApplicationPeer::APP_UID); $c->addSelectColumn(ApplicationPeer::APP_NUMBER); $c->addSelectColumn(ApplicationPeer::APP_UPDATE_DATE); $c->addSelectColumn(ApplicationPeer::PRO_UID); $c->addSelectColumn(ApplicationPeer::APP_INIT_USER); $c->addSelectColumn(AppDelegationPeer::DEL_PRIORITY); //$c->addSelectColumn(AppDelegationPeer::DEL_TASK_DUE_DATE); $c->addAsColumn( 'DEL_TASK_DUE_DATE', " IF (" . AppDelegationPeer::DEL_TASK_DUE_DATE . " <= NOW(), CONCAT('<span style=\'color:red\';>', " . AppDelegationPeer::DEL_TASK_DUE_DATE . ", '</span>'), " . AppDelegationPeer::DEL_TASK_DUE_DATE . ") " ); global $RBAC; //seems the PM_SUPERVISOR can delete a completed case if ($sTypeList == "completed" && $RBAC->userCanAccess('PM_SUPERVISOR') == 1) { $c->addAsColumn("DEL_LINK", "CONCAT('" . G::LoadTranslation('ID_DELETE') . "')"); } $c->addSelectColumn(AppDelegationPeer::DEL_INDEX); $c->addSelectColumn(AppDelegationPeer::TAS_UID); $c->addSelectColumn(AppDelegationPeer::DEL_INIT_DATE); $c->addSelectColumn(AppDelegationPeer::DEL_FINISH_DATE); $c->addSelectColumn(UsersPeer::USR_UID); $c->addAsColumn('APP_CURRENT_USER', "CONCAT(USERS.USR_LASTNAME, ' ', USERS.USR_FIRSTNAME)"); $c->addSelectColumn(ApplicationPeer::APP_STATUS); $c->addAsColumn('APP_TITLE', 'APP_TITLE.CON_VALUE'); $c->addAsColumn('APP_PRO_TITLE', 'PRO_TITLE.CON_VALUE'); $c->addAsColumn('APP_TAS_TITLE', 'TAS_TITLE.CON_VALUE'); //$c->addAsColumn('APP_DEL_PREVIOUS_USER', 'APP_LAST_USER.USR_USERNAME'); $c->addAsColumn( 'APP_DEL_PREVIOUS_USER', "CONCAT(APP_LAST_USER.USR_LASTNAME, ' ', APP_LAST_USER.USR_FIRSTNAME)" ); $c->addAlias("APP_TITLE", 'CONTENT'); $c->addAlias("PRO_TITLE", 'CONTENT'); $c->addAlias("TAS_TITLE", 'CONTENT'); $c->addAlias("APP_PREV_DEL", 'APP_DELEGATION'); $c->addAlias("APP_LAST_USER", 'USERS'); $c->addJoin(ApplicationPeer::APP_UID, AppDelegationPeer::APP_UID, Criteria::LEFT_JOIN); $c->addJoin(AppDelegationPeer::TAS_UID, TaskPeer::TAS_UID, Criteria::LEFT_JOIN); $appThreadConds[] = array(ApplicationPeer::APP_UID, AppThreadPeer::APP_UID); $appThreadConds[] = array(AppDelegationPeer::DEL_INDEX, AppThreadPeer::DEL_INDEX); $c->addJoinMC($appThreadConds, Criteria::LEFT_JOIN); $c->addJoin(AppDelegationPeer::USR_UID, UsersPeer::USR_UID, Criteria::LEFT_JOIN); $del = DBAdapter::getStringDelimiter(); $appTitleConds = array(); $appTitleConds[] = array(ApplicationPeer::APP_UID, 'APP_TITLE.CON_ID'); $appTitleConds[] = array('APP_TITLE.CON_CATEGORY', $del . 'APP_TITLE' . $del); $appTitleConds[] = array('APP_TITLE.CON_LANG', $del . SYS_LANG . $del); $c->addJoinMC($appTitleConds, Criteria::LEFT_JOIN); $proTitleConds = array(); $proTitleConds[] = array(ApplicationPeer::PRO_UID, 'PRO_TITLE.CON_ID'); $proTitleConds[] = array('PRO_TITLE.CON_CATEGORY', $del . 'PRO_TITLE' . $del); $proTitleConds[] = array('PRO_TITLE.CON_LANG', $del . SYS_LANG . $del); $c->addJoinMC($proTitleConds, Criteria::LEFT_JOIN); $tasTitleConds = array(); $tasTitleConds[] = array(AppDelegationPeer::TAS_UID, 'TAS_TITLE.CON_ID'); $tasTitleConds[] = array('TAS_TITLE.CON_CATEGORY', $del . 'TAS_TITLE' . $del); $tasTitleConds[] = array('TAS_TITLE.CON_LANG', $del . SYS_LANG . $del); $c->addJoinMC($tasTitleConds, Criteria::LEFT_JOIN); $prevConds = array(); $prevConds[] = array(ApplicationPeer::APP_UID, 'APP_PREV_DEL.APP_UID'); $prevConds[] = array('APP_PREV_DEL.DEL_INDEX', AppDelegationPeer::DEL_PREVIOUS); $c->addJoinMC($prevConds, Criteria::LEFT_JOIN); $usrConds = array(); $usrConds[] = array('APP_PREV_DEL.USR_UID', 'APP_LAST_USER.USR_UID'); $c->addJoinMC($usrConds, Criteria::LEFT_JOIN); $c->add(TaskPeer::TAS_TYPE, 'SUBPROCESS', Criteria::NOT_EQUAL); //gral, to_revise, to_reassign dont have userid in the query if ($sTypeList != 'gral' && $sTypeList != 'to_revise' && $sTypeList != 'to_reassign' && $sTypeList != 'my_started' && $sTypeList != 'sent') { $c->add(UsersPeer::USR_UID, $sUIDUserLogged); } /** * Additional filters * By Erik <*****@*****.**> */ if (isset($aAdditionalFilter) && is_array($aAdditionalFilter)) { foreach ($aAdditionalFilter as $sFilter => $sValue) { switch ($sFilter) { case 'PRO_UID': if ($sValue != "0") { $c->add(ApplicationPeer::PRO_UID, $sValue, Criteria::EQUAL); } break; case 'READ': $c->add(AppDelegationPeer::DEL_INIT_DATE, null, Criteria::ISNOTNULL); break; case 'UNREAD': $c->add(AppDelegationPeer::DEL_INIT_DATE, null, Criteria::ISNULL); break; } } } $filesList = array( //7 standard list 'to_do' => 'cases/cases_ListTodo', 'draft' => 'cases/cases_ListDraft', 'paused' => 'cases/cases_ListOnHold', 'cancelled' => 'cases/cases_ListCancelled', 'completed' => 'cases/cases_ListCompleted', 'sent' => 'cases/cases_ListSent', 'selfservice' => 'cases/cases_ListSelfService', //5 admin list 'all' => 'cases/cases_ListAll', 'to_revise' => 'cases/cases_ListToRevise', 'to_reassign' => 'cases/cases_ListAll_Reassign', 'my_started' => 'cases/cases_ListStarted', 'Alldelete' => 'cases/cases_ListAllDelete' ); switch ($sTypeList) { case 'all': $c->add( $c->getNewCriterion( AppThreadPeer::APP_THREAD_STATUS, 'OPEN')-> addOr($c->getNewCriterion(ApplicationPeer::APP_STATUS, 'COMPLETED')-> addAnd($c->getNewCriterion(AppDelegationPeer::DEL_PREVIOUS, 0) ) ) ); $c->addDescendingOrderByColumn(ApplicationPeer::APP_NUMBER); break; case 'my_started': $oCriteria = new Criteria('workflow'); $oCriteria->addSelectColumn(AppDelayPeer::APP_UID); $oCriteria->add( $oCriteria->getNewCriterion( AppDelayPeer::APP_DISABLE_ACTION_USER, null, Criteria::ISNULL )->addOr( $oCriteria->getNewCriterion(AppDelayPeer::APP_DISABLE_ACTION_USER, 0) ) ); //$oCriteria->add(AppDelayPeer::APP_DISABLE_ACTION_USER, null, Criteria::ISNULL); $oDataset = AppDelayPeer::doSelectRS($oCriteria); $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC); $oDataset->next(); $aProcesses = array(); while ($aRow = $oDataset->getRow()) { $aProcesses[] = $aRow['APP_UID']; $oDataset->next(); } $c->add($c->getNewCriterion(ApplicationPeer::APP_INIT_USER, $sUIDUserLogged)); $c->add( $c->getNewCriterion( AppThreadPeer::APP_THREAD_STATUS, 'OPEN' )->addOr( $c->getNewCriterion( ApplicationPeer::APP_STATUS, 'COMPLETED' )->addAnd( $c->getNewCriterion(AppDelegationPeer::DEL_PREVIOUS, 0) ) ) ); $c->add($c->getNewCriterion(ApplicationPeer::APP_UID, $aProcesses, Criteria::NOT_IN)); $c->addDescendingOrderByColumn(ApplicationPeer::APP_NUMBER); break; case 'to_do': $c->add(ApplicationPeer::APP_STATUS, 'TO_DO'); $c->add(AppDelegationPeer::DEL_FINISH_DATE, null, Criteria::ISNULL); $c->add(AppThreadPeer::APP_THREAD_STATUS, 'OPEN'); $c->add(AppDelegationPeer::DEL_THREAD_STATUS, 'OPEN'); $c->addDescendingOrderByColumn(ApplicationPeer::APP_NUMBER); break; case 'draft': $c->add(ApplicationPeer::APP_STATUS, 'DRAFT'); $c->add(AppDelegationPeer::DEL_FINISH_DATE, null, Criteria::ISNULL); $c->add(AppDelegationPeer::DEL_THREAD_STATUS, 'OPEN'); $c->addDescendingOrderByColumn(ApplicationPeer::APP_NUMBER); break; case 'paused': $appDelayConds[] = array(ApplicationPeer::APP_UID, AppDelayPeer::APP_UID); $appDelayConds[] = array(AppDelegationPeer::DEL_INDEX, AppDelayPeer::APP_DEL_INDEX); $c->addJoinMC($appDelayConds, Criteria::LEFT_JOIN); $c->add(AppDelayPeer::APP_DELAY_UID, null, Criteria::ISNOTNULL); $c->add(AppDelayPeer::APP_TYPE, array("REASSIGN", "ADHOC", "CANCEL"), Criteria::NOT_IN); $c->add( $c->getNewCriterion(AppDelayPeer::APP_DISABLE_ACTION_USER, null, Criteria::ISNULL)-> addOr($c->getNewCriterion(AppDelayPeer::APP_DISABLE_ACTION_USER, 0)) ); $c->addDescendingOrderByColumn(ApplicationPeer::APP_NUMBER); break; case 'cancelled': $c->add( $c->getNewCriterion(AppThreadPeer::APP_THREAD_STATUS, 'CLOSED')-> addAnd($c->getNewCriterion(ApplicationPeer::APP_STATUS, 'CANCELLED')) ); $c->addDescendingOrderByColumn(ApplicationPeer::APP_NUMBER); break; case 'completed': $c->add(ApplicationPeer::APP_STATUS, 'COMPLETED'); $c->add(AppDelegationPeer::DEL_PREVIOUS, '0', Criteria::NOT_EQUAL); //$c->addAsColumn('DEL_FINISH_DATE', 'max('.AppDelegationPeer::DEL_FINISH_DATE.')'); $c->addGroupByColumn(ApplicationPeer::APP_UID); $c->addDescendingOrderByColumn(ApplicationPeer::APP_NUMBER); break; case 'gral': $c->add( $c->getNewCriterion(AppThreadPeer::APP_THREAD_STATUS, 'OPEN')-> addOr($c->getNewCriterion(ApplicationPeer::APP_STATUS, 'COMPLETED')-> addAnd($c->getNewCriterion(AppDelegationPeer::DEL_PREVIOUS, 0))) ); $c->addDescendingOrderByColumn(ApplicationPeer::APP_NUMBER); $params = array(); $sSql = BasePeer::createSelectSql($c, $params); break; case 'to_revise': $oCriteria = new Criteria('workflow'); $oCriteria->add(ProcessUserPeer::USR_UID, $sUIDUserLogged); $oCriteria->add(ProcessUserPeer::PU_TYPE, 'SUPERVISOR'); $oDataset = ProcessUserPeer::doSelectRS($oCriteria); $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC); $oDataset->next(); $aProcesses = array(); while ($aRow = $oDataset->getRow()) { $aProcesses[] = $aRow['PRO_UID']; $oDataset->next(); } $c->add(ApplicationPeer::PRO_UID, $aProcesses, Criteria::IN); $c->add(ApplicationPeer::APP_STATUS, 'TO_DO'); $c->add(AppDelegationPeer::DEL_FINISH_DATE, null, Criteria::ISNULL); $c->add(AppThreadPeer::APP_THREAD_STATUS, 'OPEN'); $c->add(AppDelegationPeer::DEL_THREAD_STATUS, 'OPEN'); $c->addDescendingOrderByColumn(ApplicationPeer::APP_NUMBER); break; case 'selfservice': //get the valid selfservice tasks for this user $oCase = new Cases(); $tasks = $oCase->getSelfServiceTasks($_SESSION['USER_LOGGED']); $aTasks = array(); foreach ($tasks as $key => $val) { if (strlen(trim($val['uid'])) > 10) { $aTasks[] = $val['uid']; } } $c = new Criteria('workflow'); $c->clearSelectColumns(); $c->addSelectColumn(ApplicationPeer::APP_UID); $c->addSelectColumn(ApplicationPeer::APP_NUMBER); $c->addSelectColumn(ApplicationPeer::APP_UPDATE_DATE); $c->addSelectColumn(ApplicationPeer::PRO_UID); $c->addSelectColumn(ApplicationPeer::APP_INIT_USER); $c->addSelectColumn(AppDelegationPeer::DEL_PRIORITY); $c->addAsColumn( 'DEL_TASK_DUE_DATE', " IF (" . AppDelegationPeer::DEL_TASK_DUE_DATE . " <= NOW(), CONCAT('<span style=\'color:red\';>', " . AppDelegationPeer::DEL_TASK_DUE_DATE . ", '</span>'), " . AppDelegationPeer::DEL_TASK_DUE_DATE . ") " ); $c->addSelectColumn(AppDelegationPeer::DEL_INDEX); $c->addSelectColumn(AppDelegationPeer::TAS_UID); $c->addSelectColumn(AppDelegationPeer::DEL_INIT_DATE); $c->addSelectColumn(AppDelegationPeer::DEL_FINISH_DATE); $c->addSelectColumn(UsersPeer::USR_UID); $c->addAsColumn('APP_CURRENT_USER', "CONCAT(USERS.USR_LASTNAME, ' ', USERS.USR_FIRSTNAME)"); $c->addSelectColumn(ApplicationPeer::APP_STATUS); $c->addAsColumn('APP_TITLE', 'APP_TITLE.CON_VALUE'); $c->addAsColumn('APP_PRO_TITLE', 'PRO_TITLE.CON_VALUE'); $c->addAsColumn('APP_TAS_TITLE', 'TAS_TITLE.CON_VALUE'); $c->addAlias("APP_TITLE", 'CONTENT'); $c->addAlias("PRO_TITLE", 'CONTENT'); $c->addAlias("TAS_TITLE", 'CONTENT'); $c->addJoin(ApplicationPeer::APP_UID, AppDelegationPeer::APP_UID, Criteria::LEFT_JOIN); $c->addJoin(AppDelegationPeer::TAS_UID, TaskPeer::TAS_UID, Criteria::LEFT_JOIN); $appThreadConds[] = array(ApplicationPeer::APP_UID, AppThreadPeer::APP_UID); $appThreadConds[] = array(AppDelegationPeer::DEL_INDEX, AppThreadPeer::DEL_INDEX); $c->addJoinMC($appThreadConds, Criteria::LEFT_JOIN); $c->addJoin(AppDelegationPeer::USR_UID, UsersPeer::USR_UID, Criteria::LEFT_JOIN); $del = DBAdapter::getStringDelimiter(); $appTitleConds = array(); $appTitleConds[] = array(ApplicationPeer::APP_UID, 'APP_TITLE.CON_ID'); $appTitleConds[] = array('APP_TITLE.CON_CATEGORY', $del . 'APP_TITLE' . $del); $appTitleConds[] = array('APP_TITLE.CON_LANG', $del . SYS_LANG . $del); $c->addJoinMC($appTitleConds, Criteria::LEFT_JOIN); // $proTitleConds = array(); $proTitleConds[] = array(ApplicationPeer::PRO_UID, 'PRO_TITLE.CON_ID'); $proTitleConds[] = array('PRO_TITLE.CON_CATEGORY', $del . 'PRO_TITLE' . $del); $proTitleConds[] = array('PRO_TITLE.CON_LANG', $del . SYS_LANG . $del); $c->addJoinMC($proTitleConds, Criteria::LEFT_JOIN); // $tasTitleConds = array(); $tasTitleConds[] = array(AppDelegationPeer::TAS_UID, 'TAS_TITLE.CON_ID'); $tasTitleConds[] = array('TAS_TITLE.CON_CATEGORY', $del . 'TAS_TITLE' . $del); $tasTitleConds[] = array('TAS_TITLE.CON_LANG', $del . SYS_LANG . $del); $c->addJoinMC($tasTitleConds, Criteria::LEFT_JOIN); $c->add(AppDelegationPeer::USR_UID, ''); $c->add(AppDelegationPeer::TAS_UID, $aTasks, Criteria::IN); break; case 'to_reassign': $c->add( $c->getNewCriterion(ApplicationPeer::APP_STATUS, 'TO_DO')-> addOr($c->getNewCriterion(ApplicationPeer::APP_STATUS, 'DRAFT')) ); $c->add(AppDelegationPeer::DEL_FINISH_DATE, null, Criteria::ISNULL); $c->add(AppThreadPeer::APP_THREAD_STATUS, 'OPEN'); $c->add(AppDelegationPeer::DEL_THREAD_STATUS, 'OPEN'); $c->addDescendingOrderByColumn(ApplicationPeer::APP_NUMBER); break; case 'sent': $oCriteria = new Criteria('workflow'); $oCriteria->addSelectColumn(AppDelayPeer::APP_UID); $oCriteria->add( $oCriteria->getNewCriterion( AppDelayPeer::APP_DISABLE_ACTION_USER, null, Criteria::ISNULL )->addOr( $oCriteria->getNewCriterion(AppDelayPeer::APP_DISABLE_ACTION_USER, 0) ) ); $oDataset = AppDelayPeer::doSelectRS($oCriteria); $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC); $oDataset->next(); $aProcesses = array(); while ($aRow = $oDataset->getRow()) { $aProcesses[] = $aRow['APP_UID']; $oDataset->next(); } if (isset($aAdditionalFilter) && isset($aAdditionalFilter['MINE'])) { $c->add($c->getNewCriterion(ApplicationPeer::APP_INIT_USER, $sUIDUserLogged)); } else { $c->add( $c->getNewCriterion( ApplicationPeer::APP_INIT_USER, $sUIDUserLogged )->addOr( $c->getNewCriterion( AppDelegationPeer::USR_UID, $sUIDUserLogged ) ) ); } if (isset($aAdditionalFilter) && isset($aAdditionalFilter['APP_STATUS_FILTER'])) { $c->add(ApplicationPeer::APP_STATUS, $sValue, Criteria::EQUAL); } else { $c->add(ApplicationPeer::APP_STATUS, 'DRAFT', Criteria::NOT_EQUAL); } $c->add( $c->getNewCriterion( AppDelegationPeer::DEL_THREAD_STATUS, 'CLOSED' )->addOr( $c->getNewCriterion( ApplicationPeer::APP_STATUS, 'COMPLETED' )->addAnd( $c->getNewCriterion(AppDelegationPeer::DEL_PREVIOUS, 0) ) ) ); $c->add($c->getNewCriterion(ApplicationPeer::APP_UID, $aProcesses, Criteria::NOT_IN)); $c->addDescendingOrderByColumn(ApplicationPeer::APP_NUMBER); break; } //select the xmlList to show if ($sTypeList == 'gral') { if ($RBAC->userCanAccess('PM_DELETECASE') == 1) { $xmlfile = $filesList['Alldelete']; } else { $xmlfile = $filesList['all']; } } else { $xmlfile = $filesList[$sTypeList]; } if ($ClearSession) { //OPCION_1: claening the $_SESSION and updating the List.... only case List foreach ($filesList as $file) { $id = G::createUID('', $file . '.xml'); unset($_SESSION['pagedTable[' . $id . ']']); unset($_SESSION[$id]); } //OPTION_2: cleaning the $_SESSION and whole List and xmls $cur = array_keys($_SESSION); foreach ($cur as $key) { if (substr($key, 0, 11) === "pagedTable[") { unset($_SESSION[$key]); } else { $xml = G::getUIDName($key, ''); if (strpos($xml, '.xml') !== false) { unset($_SESSION[$key]); } } } } return array($c, $xmlfile); }
/** * Function xmlformTemplate * * @author David S. Callizaya S. <*****@*****.**> * @access public * @param string form * @param string templateFile * @return string */ public function parseFile($filename, $language, $forceParse) { $this->language = $language; $filenameInitial = $filename; $filename = $this->home . $filename; //if the xmlform file doesn't exists, then try with the plugins folders if (!is_file($filename)) { $aux = explode(PATH_SEP, $filenameInitial); //check if G_PLUGIN_CLASS is defined, because publisher can be called without an environment if (count($aux) > 2) { //Subfolders $filename = array_pop($aux); $aux0 = implode(PATH_SEP, $aux); $aux = array(); $aux[0] = $aux0; $aux[1] = $filename; } if (count($aux) == 2 && defined('G_PLUGIN_CLASS')) { $oPluginRegistry =& PMPluginRegistry::getSingleton(); if ($response = $oPluginRegistry->isRegisteredFolder($aux[0])) { if ($response !== true) { $sPath = PATH_PLUGINS . $response . PATH_SEP; } else { $sPath = PATH_PLUGINS; } $filename = $sPath . $aux[0] . PATH_SEP . $aux[1]; } } } $this->fileName = $filename; $parsedFile = dirname($filename) . PATH_SEP . basename($filename, 'xml') . $language; $parsedFilePath = defined('PATH_C') ? defined('SYS_SYS') ? PATH_C . 'ws' . PATH_SEP . SYS_SYS . PATH_SEP : PATH_C : PATH_DATA; $parsedFilePath .= 'xmlform/' . substr($parsedFile, strlen($this->home)); // Improvement for the js cache - Start $realPath = substr(realpath($this->fileName), strlen(realpath($this->home)), -4); if (substr($realPath, 0, 1) != PATH_SEP) { $realPath = PATH_SEP . $realPath; } $filesToDelete = substr((defined('PATH_C') ? PATH_C : PATH_DATA) . 'xmlform/', 0, -1) . $realPath . '.*.js'; $auxPath = explode(PATH_SEP, $realPath); $auxPath[count($auxPath) - 1] = $auxPath[count($auxPath) - 1] . '.' . md5(filemtime($this->fileName)); $realPath = implode(PATH_SEP, $auxPath); // Improvement for the js cache - End $this->parsedFile = $parsedFilePath; $this->scriptURL = '/jsform' . $realPath . '.js'; $this->scriptFile = substr((defined('PATH_C') ? PATH_C : PATH_DATA) . 'xmlform/', 0, -1) . substr($this->scriptURL, 7); $this->id = G::createUID('', substr($this->fileName, strlen($this->home))); $this->scriptURL = str_replace('\\', '/', $this->scriptURL); $newVersion = false; if ($forceParse || (!file_exists($this->parsedFile) || filemtime($filename) > filemtime($this->parsedFile) || filemtime(__FILE__) > filemtime($this->parsedFile)) || !file_exists($this->scriptFile) || filemtime($filename) > filemtime($this->scriptFile)) { if (glob($filesToDelete)) { foreach (glob($filesToDelete) as $fileToDelete) { @unlink($fileToDelete); } } $this->tree = new Xml_Document(); $this->tree->parseXmlFile($filename); //$this->tree->unsetParent(); if (!is_object($this->tree->children[0])) { throw new Exception('Failure loading root node.'); } $this->tree =& $this->tree->children[0]->toTree(); //ERROR CODE [1] : Failed to read the xml document if (!isset($this->tree)) { return 1; } $xmlNode =& $this->tree->children; //Set the form's attributes $myAttributes = get_class_vars(get_class($this)); foreach ($myAttributes as $k => $v) { $myAttributes[$k] = strtolower($k); } foreach ($this->tree->attributes as $k => $v) { $key = array_search(strtolower($k), $myAttributes); if ($key !== false && strtolower($k) !== 'fields' && strtolower($k) !== 'values') { $this->{$key} = $v; } } //Reeplace non valid characters in xmlform name with "_" $this->name = preg_replace('/\\W/', '_', $this->name); //Create fields foreach ($xmlNode as $k => $v) { if ($xmlNode[$k]->type !== 'cdata' && isset($xmlNode[$k]->attributes['type'])) { if (class_exists('XmlForm_Field_' . $xmlNode[$k]->attributes['type'])) { $x = '$field = new XmlForm_Field_' . $xmlNode[$k]->attributes['type'] . '( $xmlNode[$k], $language, $this->home, $this);'; eval($x); } else { $field = new XmlForm_Field($xmlNode[$k], $language, $this->home, $this); } $field->language = $this->language; $this->fields[$field->name] = $field; } if (isset($xmlNode[$k]->attributes['required']) || isset($xmlNode[$k]->attributes['validate'])) { // the fields or xml nodes with a required attribute are put in an array that is passed to the view file $isEditMode = isset($xmlNode[$k]->attributes['mode']) && $xmlNode[$k]->attributes['mode'] == 'view' ? false : true; if ($isEditMode && $this->mode != 'view') { $validateValue = ""; if (isset($xmlNode[$k]->attributes['validate'])) { $validateValue = $xmlNode[$k]->attributes['validate']; } $requiredValue = "0"; if (isset($xmlNode[$k]->attributes['required'])) { $requiredValue = $xmlNode[$k]->attributes['required'] == 1 ? '1' : '0'; } $this->requiredFields[] = array('name' => $field->name, 'type' => $xmlNode[$k]->attributes['type'], 'label' => addslashes(trim($field->label)), 'validate' => $validateValue, 'required' => $requiredValue); } } } //$oJSON = new Services_JSON(); $jsonRequired = G::json_encode($this->requiredFields); $this->objectRequiredFields = str_replace('"', "%27", str_replace("'", "%39", $jsonRequired)); //Load the default values //$this->setDefaultValues(); //Save the cache file if (!is_dir(dirname($this->parsedFile))) { G::mk_dir(dirname($this->parsedFile)); } $f = fopen($this->parsedFile, 'w+'); //ERROR CODE [2] : Failed to open cache file if ($f === false) { return 2; } fwrite($f, "<?php\n"); /* fwrite ($f, '$this = unserialize( \'' . addcslashes( serialize ( $this ), '\\\'' ) . '\' );' . "\n" );*/ foreach ($this as $key => $value) { //cho $key .'<br/>'; switch ($key) { case 'home': case 'fileName': case 'parsedFile': case 'scriptFile': case 'scriptURL': break; default: switch (true) { case is_string($this->{$key}): fwrite($f, '$this->' . $key . '=\'' . addcslashes($this->{$key}, '\\\'') . '\'' . ";\n"); break; case is_bool($this->{$key}): fwrite($f, '$this->' . $key . '=' . ($this->{$key} ? 'true;' : 'false') . ";\n"); break; case is_null($this->{$key}): fwrite($f, '$this->' . $key . '=null' . ";\n"); break; case is_float($this->{$key}): case is_int($this->{$key}): fwrite($f, '$this->' . $key . '=' . $this->{$key} . ";\n"); break; default: fwrite($f, '$this->' . $key . ' = unserialize( \'' . addcslashes(serialize($this->{$key}), '\\\'') . '\' );' . "\n"); } } } fwrite($f, "?>"); fclose($f); $newVersion = true; } //if $forceParse //Loads the parsedFile. require $this->parsedFile; $this->fileName = $filename; $this->parsedFile = $parsedFile; //RECREATE LA JS file //Note: Template defined with publisher doesn't affect the .js file //created at this point. if ($newVersion) { $template = PATH_CORE . 'templates/' . $this->type . '.html'; //If the type is not the correct template name, use xmlform.html //if (!file_exists($template)) $template = PATH_CORE . 'templates/xmlform.html'; if ($template !== '' && file_exists($template)) { if (!is_dir(dirname($this->scriptFile))) { G::mk_dir(dirname($this->scriptFile)); } $f = fopen($this->scriptFile, 'w'); $o = new xmlformTemplate($this, $template); $scriptContent = $o->printJSFile($this); unset($o); fwrite($f, $scriptContent); fclose($f); } } return 0; }
/** * Function renderTitle * * @author David S. Callizaya S. <*****@*****.**> * @access public * @return string */ public function renderTitle() { //fix the bug about showing hidden fields in propel table. foreach ($this->fields as $r => $rval) { if ($this->style[$r]['type'] == 'hidden') { $this->style[$r]['showInTable'] = '0'; } } //Render headers $this->colCount = 0; $this->shownFields = '['; foreach ($this->fields as $r => $rval) { if ($this->style[$r]['showInTable'] != '0' && !in_array($this->fields[$r]['Name'], $this->masterdetail)) { //if (($this->style[$r]['showInTable'] != '0' )) $this->tpl->newBlock("headers"); $sortOrder = isset($this->aOrder[$this->fields[$r]['Name']]) && $this->aOrder[$this->fields[$r]['Name']] === 'ASC' ? 'DESC' : 'ASC'; $sortOrder = isset($this->aOrder[$this->fields[$r]['Name']]) && $this->aOrder[$this->fields[$r]['Name']] === 'DESC' ? '' : $sortOrder; if ($this->style[$r]['titleVisibility'] != '0') { $this->style[$r]['href'] = $this->ownerPage . '?order=' . ($sortOrder !== '' ? G::createUID('', $this->fields[$r]['Name']) . '=' . $sortOrder : '') . '&page=' . $this->currentPage; $this->style[$r]['onsort'] = $this->id . '.doSort("' . G::createUID('', $this->fields[$r]['Name']) . '" , "' . $sortOrder . '");return false;'; } else { $this->style[$r]['href'] = '#'; $this->style[$r]['onsort'] = 'return false;'; } if (isset($this->style[$r]['href'])) { $this->tpl->assign("href", $this->style[$r]['href']); } if (isset($this->style[$r]['onsort'])) { $this->tpl->assign("onsort", htmlentities($this->style[$r]['onsort'], ENT_QUOTES, 'UTF-8')); } /* BUG 8080 - erik: don't setup onclick on page table header, doesn't have sense and causing problems if (isset($this->style[$r]['onclick'])) $this->tpl->assign( "onclick" , htmlentities( $this->style[$r]['onclick'] , ENT_QUOTES, 'UTF-8' ) ); */ if (isset($this->style[$r]['colWidth'])) { $this->tpl->assign("width", $this->style[$r]['colWidth']); } if (isset($this->style[$r]['colWidth'])) { $this->tpl->assign("widthPercent", $this->style[$r]['colWidth'] * 100 / $this->totalWidth . "%"); //Hook for special skin with RTL languajes } if (defined('SYS_LANG_DIRECTION') && SYS_LANG_DIRECTION == 'R') { $this->style[$r]['titleAlign'] = 'right'; } if (isset($this->style[$r]['titleAlign'])) { $this->tpl->assign("align", 'text-align:' . $this->style[$r]['titleAlign'] . ';'); } if ($this->style[$r]['titleVisibility'] != '0') { $sortOrder = isset($this->aOrder[$this->fields[$r]['Name']]) && $this->aOrder[$this->fields[$r]['Name']] === 'ASC' ? '<img src="/images/arrow-up.gif">' : ''; $sortOrder = isset($this->aOrder[$this->fields[$r]['Name']]) && $this->aOrder[$this->fields[$r]['Name']] === 'DESC' ? '<img src="/images/arrow-down.gif">' : $sortOrder; $this->tpl->assign("header", $this->fields[$r]['Label'] . $sortOrder); $this->tpl->assign('displaySeparator', $this->colCount == 0 || !isset($this->fields[$r]['Label']) || $this->fields[$r]['Label'] === '' ? 'display:none;' : ''); } else { $this->tpl->assign('displaySeparator', 'display:none;'); } $this->colCount += 2; $this->shownFields .= $this->shownFields !== '[' ? ',' : ''; $this->shownFields .= '"' . $r . '"'; } } $this->shownFields .= ']'; }
/** * Function renderTitle * @author David S. Callizaya S. <*****@*****.**> * @access public * @return string */ function renderTitle() { //Render Title $thereisnotitle = true; foreach ($this->fields as $r => $rval) { if ($this->fields[$r]['Type'] === 'title') { $this->tpl->assign("title", $this->fields[$r]['Label']); $thereisnotitle = false; } } if ($thereisnotitle) { $this->tpl->assign("title", ' '); } //Render headers $this->colCount = 0; $this->shownFields = '['; foreach ($this->fields as $r => $rval) { if ($this->style[$r]['showInTable'] != '0') { $this->tpl->newBlock("headers"); $sortOrder = isset($this->aOrder[$this->fields[$r]['Name']]) && $this->aOrder[$this->fields[$r]['Name']] === 'ASC' ? 'DESC' : 'ASC'; $sortOrder = isset($this->aOrder[$this->fields[$r]['Name']]) && $this->aOrder[$this->fields[$r]['Name']] === 'DESC' ? '' : $sortOrder; $this->style[$r]['href'] = $this->ownerPage . '?order=' . ($sortOrder !== '' ? urlencode(G::createUID('', $this->fields[$r]['Name']) . '=' . $sortOrder) : '') . '&page=' . $this->currentPage; $this->style[$r]['onsort'] = $this->id . '.doSort("' . G::createUID('', $this->fields[$r]['Name']) . '" , "' . $sortOrder . '");return false;'; if (isset($this->style[$r]['href'])) { $this->tpl->assign("href", $this->style[$r]['href']); } if (isset($this->style[$r]['onsort'])) { $this->tpl->assign("onclick", htmlentities($this->style[$r]['onsort'], ENT_QUOTES, 'UTF-8')); } if (isset($this->style[$r]['colWidth'])) { $this->tpl->assign("width", $this->style[$r]['colWidth']); } if (isset($this->style[$r]['colWidth'])) { $this->tpl->assign("widthPercent", $this->style[$r]['colWidth'] * 100 / $this->totalWidth . "%"); } if (isset($this->style[$r]['titleAlign'])) { $this->tpl->assign("align", 'text-align:' . $this->style[$r]['titleAlign'] . ';'); } if ($this->style[$r]['titleVisibility'] != '0') { $sortOrder = isset($this->aOrder[$this->fields[$r]['Name']]) && $this->aOrder[$this->fields[$r]['Name']] === 'ASC' ? 'b2' : ''; $sortOrder = isset($this->aOrder[$this->fields[$r]['Name']]) && $this->aOrder[$this->fields[$r]['Name']] === 'DESC' ? 'b<' : $sortOrder; $this->tpl->assign("header", $this->fields[$r]['Label'] . $sortOrder); $this->tpl->assign('displaySeparator', $this->colCount == 0 || !isset($this->fields[$r]['Label']) || $this->fields[$r]['Label'] === '' ? 'display:none;' : ''); } else { $this->tpl->assign('displaySeparator', 'display:none;'); } $this->colCount += 2; $this->shownFields .= $this->shownFields !== '[' ? ',' : ''; $this->shownFields .= '"' . $r . '"'; } } $this->shownFields .= ']'; }
$t->can_ok($obj, 'LoadTemplate', 'LoadTemplate()'); $t->can_ok($obj, 'LoadClassRBAC', 'LoadClassRBAC()'); $t->can_ok($obj, 'LoadClass', 'LoadClass()'); $t->can_ok($obj, 'LoadThirdParty', 'LoadThirdParty()'); $t->can_ok($obj, 'encryptlink', 'encryptlink()'); $t->is(G::encryptlink("normal url"), "normal url", 'encryptlink() normal url'); $t->todo('more tests with encryplink and remove ENABLE_ENCRYPT dependency'); $t->can_ok($obj, 'parseURI', 'parseURI()'); G::parseURI("http:/192.168.0.9/sysos/en/wf5/login/login/abc?ab=123&bc=zy"); $t->todo('more tests with parseURI'); $t->can_ok($obj, 'streamFile', 'streamFile()'); $t->can_ok($obj, 'sendHeaders', 'sendHeaders()'); $t->todo('more tests with sendHeaders'); $t->can_ok($obj, 'virtualURI', 'virtualURI()'); $t->can_ok($obj, 'createUID', 'createUID()'); $t->is(G::createUID('directory', 'filename'), 'bDh5aTBaUG5vNkxwMnByWjJxT2EzNVk___', 'createUID() normal'); $t->can_ok($obj, 'getUIDName', 'getUIDName()'); $t->is(G::getUIDName('bDh5aTBaUG5vNkxwMnByWjJxT2EzNVk___', '12345678901234567890'), false, 'getUIDName() normal?'); $t->can_ok($obj, 'formatNumber', 'formatNumber()'); $t->is(G::formatNumber('100000'), '100000', 'formatNumber() normal'); $t->todo('is useful the function formatNumber??'); $t->can_ok($obj, 'formatDate', 'formatDate()'); $t->is(G::formatDate('2001-02-29'), '2001-02-29', 'formatDate() '); $t->is(G::formatDate('2001-02-29', 'F d, Y'), 'Februar01 29, 2001', 'formatDate() '); //is not working $t->is(G::formatDate('2001-02-29', 'd.m.Y'), '29.02.2001', 'formatDate() '); $t->todo(" the month literal text is defined here!! "); $t->todo('review all methods in class G'); $i = 1; $t->diag('class G'); $t->is(count($methods), 95, "class database " . count($methods) . " methods.");
/** * Function renderTitle * * @author David S. Callizaya S. <*****@*****.**> * @access public * @return string */ public function renderTitle() { //fix the bug about showing hidden fields in propel table. foreach ($this->fields as $r => $rval) { if ($this->style[$r]['type'] == 'hidden') { $this->style[$r]['showInTable'] = '0'; } } //Render headers $this->colCount = 0; $this->shownFields = '['; foreach ($this->fields as $r => $rval) { if ($this->style[$r]['showInTable'] != '0' && !in_array($this->fields[$r]['Name'], $this->masterdetail)) { //if (($this->style[$r]['showInTable'] != '0' )) $this->tpl->newBlock("headers"); $sortDir = "ASC"; if (isset($this->aOrder[$this->fields[$r]["Name"]])) { $sortDir = $this->aOrder[$this->fields[$r]["Name"]] == "ASC" ? "DESC" : "ASC"; } if ($this->style[$r]['titleVisibility'] != '0') { $this->style[$r]["href"] = "javascript:;"; $this->style[$r]["onsort"] = $this->id . ".doSort(\"" . G::createUID("", $this->fields[$r]["Name"]) . "\", \"" . ($this->sortable == "0" ? "" : $sortDir) . "\"); return false;"; } else { $this->style[$r]["href"] = "javascript:;"; $this->style[$r]['onsort'] = 'return false;'; } if (isset($this->style[$r]['href'])) { $this->tpl->assign("href", $this->style[$r]['href']); } if (isset($this->style[$r]['onsort'])) { $this->tpl->assign("onsort", htmlentities($this->style[$r]['onsort'], ENT_QUOTES, 'UTF-8')); } /* BUG 8080 - erik: don't setup onclick on page table header, doesn't have sense and causing problems if (isset($this->style[$r]['onclick'])) $this->tpl->assign( "onclick" , htmlentities( $this->style[$r]['onclick'] , ENT_QUOTES, 'UTF-8' ) ); */ if (isset($this->style[$r]['colWidth'])) { $this->tpl->assign("width", $this->style[$r]['colWidth']); } if (isset($this->style[$r]['colWidth'])) { $this->tpl->assign("widthPercent", $this->style[$r]['colWidth'] * 100 / $this->totalWidth . "%"); //Hook for special skin with RTL languajes } if (defined('SYS_LANG_DIRECTION') && SYS_LANG_DIRECTION == 'R') { $this->style[$r]['titleAlign'] = 'right'; } if (isset($this->style[$r]['titleAlign'])) { $this->tpl->assign("align", 'text-align:' . $this->style[$r]['titleAlign'] . ';'); } if ($this->style[$r]['titleVisibility'] != '0') { $sortDirImg = ""; if (isset($this->aOrder[$this->fields[$r]["Name"]])) { $sortDirImg = $this->aOrder[$this->fields[$r]["Name"]] == "ASC" ? "<img src=\"/images/arrow-up.gif\" />" : "<img src=\"/images/arrow-down.gif\" />"; } $this->tpl->assign("header", $this->fields[$r]["Label"] . $sortDirImg); $this->tpl->assign("displaySeparator", $this->colCount == 0 || !isset($this->fields[$r]["Label"]) || $this->fields[$r]["Label"] == "" ? "display: none;" : ""); } else { $this->tpl->assign('displaySeparator', 'display:none;'); } $this->colCount += 2; $this->shownFields .= $this->shownFields !== '[' ? ',' : ''; $this->shownFields .= '"' . $r . '"'; } } $this->shownFields .= ']'; }