/** * Render the chart output * * @param string $objName object name which is the bizform name * @return void */ public function render($objName) { // get the value of the control that issues the call $chartName = BizSystem::clientProxy()->getFormInputs("__this"); // get the current UI bizobj $formObj = BizSystem::getObject($objName); // get the existing bizform object $bizDataObj = $formObj->getDataObj(); // get chart config xml file $chartXmlFile = BizSystem::GetXmlFileWithPath($objName . "_chart"); $xmlArr = BizSystem::getXmlArray($chartXmlFile); ob_clean(); // get the chart section from config xml file foreach ($xmlArr["BIZFORM_CHART"]["CHARTLIST"]["CHART"] as $chart) { if (count($xmlArr["BIZFORM_CHART"]["CHARTLIST"]["CHART"]) == 1) { $chart = $xmlArr["BIZFORM_CHART"]["CHARTLIST"]["CHART"]; } // try to match the chartName, if no chartName given, always draw the first chart defined in xml file if ($chartName && $chart["ATTRIBUTES"]["NAME"] == $chartName || !$chartName) { if ($chart["ATTRIBUTES"]["GRAPHTYPE"] == 'XY') { $this->xyGraphRender($bizDataObj, $chart); break; } if ($chart["ATTRIBUTES"]["GRAPHTYPE"] == 'Pie') { $this->pieGraphRender($bizDataObj, $chart); break; } } } }
private function getMetadataArray($objName) { $xmlFile = BizSystem::GetXmlFileWithPath($objName); if (!$xmlFile) { $dotPos = strrpos($objName, "."); $package = $dotPos > 0 ? substr($objName, 0, $dotPos) : null; $class = $dotPos > 0 ? substr($objName, $dotPos + 1) : $objName; } else { $xmlArr = BizSystem::getXmlArray($xmlFile); } if ($xmlArr) { $keys = array_keys($xmlArr); $root = $keys[0]; // add by mr_a_ton , atrubut name must match with object name $dotPos = strrpos($objName, "."); $shortObjectName = $dotPos > 0 ? substr($objName, $dotPos + 1) : $objName; if ($xmlArr[$root]["ATTRIBUTES"]["NAME"] == "") { $xmlArr[$root]["ATTRIBUTES"]["NAME"] = $shortObjectName; } else { if ($shortObjectName != $xmlArr[$root]["ATTRIBUTES"]["NAME"]) { trigger_error("Metadata file parsing error for object {$objName}. Name attribut [" . $xmlArr[$root]["ATTRIBUTES"]["NAME"] . "] not same with object name. Please double check your metadata xml file again.", E_USER_ERROR); } } //$package = $xmlArr[$root]["ATTRIBUTES"]["PACKAGE"]; $class = $xmlArr[$root]["ATTRIBUTES"]["CLASS"]; // if class has package name as prefix, change the package to the prefix $dotPos = strrpos($class, "."); $classPrefix = $dotPos > 0 ? substr($class, 0, $dotPos) : null; $classPackage = $classPrefix ? $classPrefix : null; if ($classPrefix) { $class = substr($class, $dotPos + 1); } // set object package $dotPos = strrpos($objName, "."); $package = $dotPos > 0 ? substr($objName, 0, $dotPos) : null; if (!$classPackage) { $classPackage = $package; } $xmlArr[$root]["ATTRIBUTES"]["PACKAGE"] = $package; return $xmlArr; } return; }
protected function getXMLFromList($selectFrom) { $pos0 = strpos($selectFrom, "("); $pos1 = strpos($selectFrom, ")"); if ($pos0 > 0 && $pos1 > $pos0) { // select from xml file $xmlFile = substr($selectFrom, 0, $pos0); $tag = substr($selectFrom, $pos0 + 1, $pos1 - $pos0 - 1); $tag = strtoupper($tag); $xmlFile = BizSystem::GetXmlFileWithPath($xmlFile); if (!$xmlFile) { return false; } $xmlArr =& BizSystem::getXmlArray($xmlFile); if ($xmlArr) { $i = 0; if (!key_exists($tag, $xmlArr["SELECTION"])) { return false; } foreach ($xmlArr["SELECTION"][$tag] as $node) { $list[$i]['val'] = $node["ATTRIBUTES"]["VALUE"]; $list[$i]['pic'] = $node["ATTRIBUTES"]["PICTURE"]; if ($node["ATTRIBUTES"]["TEXT"]) { $list[$i]['txt'] = $node["ATTRIBUTES"]["TEXT"]; } else { $list[$i]['txt'] = $list[$i]['val']; } $i++; } $list = $this->translateList($list, $tag); // supprot multi-language } return $list; } return false; }
/** * Run DataObject trigger * * @param string $triggerType type of the trigger */ private function _runDOTrigger($triggerType) { // locate the trigger metadata file BOName_Trigger.xml $triggerServiceName = $this->m_Name . "_Trigger"; $xmlFile = BizSystem::GetXmlFileWithPath($triggerServiceName); if (!$xmlFile) { return; } $triggerService = BizSystem::getObject($triggerServiceName); if ($triggerService == null) { return; } // invoke trigger service ExecuteTrigger($triggerType, $currentRecord) $triggerService->execute($this, $triggerType); }
/** * Get user preference * * @param string $attribute key that representing attribute * @return mixed */ public static function getUserPreference($attribute = null) { if (!BizSystem::GetXmlFileWithPath(PREFERENCE_SERVICE)) { return null; } $preferenceService = BizSystem::getService(PREFERENCE_SERVICE); if (method_exists($preferenceService, 'getPreference')) { return $preferenceService->getPreference($attribute); } else { $preference = BizSystem::sessionContext()->getVar("_USER_PREFERENCE"); return isset($preference[$attribute]) ? $preference[$attribute] : ""; } }
/** * Read Config.xml into a internal array. */ public function __construct() { $xmlFile = BizSystem::GetXmlFileWithPath("Config"); $this->_xmlArr =& BizSystem::getXmlArray($xmlFile); }
/** * Construct an instance of an object * * @param string $objName object name * @param array $xmlArr xml array * @return object the instance of the object */ protected function constructObject($objName, &$xmlArr = null) { if (!$xmlArr) { $xmlFile = BizSystem::GetXmlFileWithPath($objName); if (!$xmlFile) { $dotPos = strrpos($objName, "."); $package = $dotPos > 0 ? substr($objName, 0, $dotPos) : null; $class = $dotPos > 0 ? substr($objName, $dotPos + 1) : $objName; } else { $xmlArr = BizSystem::getXmlArray($xmlFile); } } if ($xmlArr) { $keys = array_keys($xmlArr); $root = $keys[0]; // add by mr_a_ton , atrubut name must match with object name $dotPos = strrpos($objName, "."); $shortObjectName = $dotPos > 0 ? substr($objName, $dotPos + 1) : $objName; if ($xmlArr[$root]["ATTRIBUTES"]["NAME"] == "") { $xmlArr[$root]["ATTRIBUTES"]["NAME"] = $shortObjectName; } else { if ($shortObjectName != $xmlArr[$root]["ATTRIBUTES"]["NAME"]) { trigger_error("Metadata file parsing error for object {$objName}. Name attribut [" . $xmlArr[$root]["ATTRIBUTES"]["NAME"] . "] not same with object name. Please double check your metadata xml file again.", E_USER_ERROR); } } //$package = $xmlArr[$root]["ATTRIBUTES"]["PACKAGE"]; $class = $xmlArr[$root]["ATTRIBUTES"]["CLASS"]; // if class has package name as prefix, change the package to the prefix $dotPos = strrpos($class, "."); $classPrefix = $dotPos > 0 ? substr($class, 0, $dotPos) : null; $classPackage = $classPrefix ? $classPrefix : null; if ($classPrefix) { $class = substr($class, $dotPos + 1); } // set object package $dotPos = strrpos($objName, "."); $package = $dotPos > 0 ? substr($objName, 0, $dotPos) : null; if (strpos($package, '@') === 0) { $package = substr($package, 1); } if (!$classPackage) { $classPackage = $package; } $xmlArr[$root]["ATTRIBUTES"]["PACKAGE"] = $package; } if ($class == "BizObj") { // convert BizObj to BizDataObj, support <1.2 version $class = "BizDataObj"; } if (!class_exists($class, false)) { $classFile = BizClassLoader::getLibFileWithPath($class, $classPackage); if (!$classFile) { if ($package) { trigger_error("Cannot find the class with name as {$package}.{$class}", E_USER_ERROR); } else { trigger_error("Cannot find the class with name as {$class} of {$objName}", E_USER_ERROR); } exit; } include_once $classFile; } if (class_exists($class, false)) { //if ($objName == "collab.calendar.form.EventListForm") { print_r($xmlArr); exit; } $obj_ref = new $class($xmlArr); if ($obj_ref) { return $obj_ref; } } else { if (function_exists("ioncube_read_file")) { $data = ioncube_read_file($classFile); if (!strpos($data, "ionCube Loader")) { trigger_error("Cannot find the class with name as {$class} in {$classFile}", E_USER_ERROR); } else { } } } return null; }
/** * Get from list * * @param array $list * @return <type> */ public function getFromList(&$list) { $selectFrom = $this->getSelectFrom(); // from XML file (Selection) $pos0 = strpos($selectFrom, "("); $pos1 = strpos($selectFrom, ")"); if ($pos0 > 0 && $pos1 > $pos0) { // select from xml file $xmlFile = substr($selectFrom, 0, $pos0); $tag = substr($selectFrom, $pos0 + 1, $pos1 - $pos0 - 1); $tag = strtoupper($tag); $xmlFile = BizSystem::GetXmlFileWithPath($xmlFile); if (!$xmlFile) { return; } $xmlArr =& BizSystem::getXmlArray($xmlFile); if ($xmlArr) { $i = 0; if (!key_exists($tag, $xmlArr["SELECTION"])) { return; } foreach ($xmlArr["SELECTION"][$tag] as $node) { $list[$i]['val'] = $node["ATTRIBUTES"]["VALUE"]; if ($node["ATTRIBUTES"]["TEXT"]) { $list[$i]['txt'] = I18n::getInstance()->translate($node["ATTRIBUTES"]["TEXT"]); } else { $list[$i]['txt'] = I18n::getInstance()->translate($list[$i]['val']); } $i++; } } return; } // from Database $pos0 = strpos($selectFrom, "["); $pos1 = strpos($selectFrom, "]"); if ($pos0 > 0 && $pos1 > $pos0) { // select from bizObj // support BizObjName[BizFieldName] or BizObjName[BizFieldName4Text:BizFieldName4Value] $bizObjName = substr($selectFrom, 0, $pos0); $pos3 = strpos($selectFrom, ":"); if ($pos3 > $pos0 && $pos3 < $pos1) { $fieldName = substr($selectFrom, $pos0 + 1, $pos3 - $pos0 - 1); $fieldName_v = substr($selectFrom, $pos3 + 1, $pos1 - $pos3 - 1); } else { $fieldName = substr($selectFrom, $pos0 + 1, $pos1 - $pos0 - 1); $fieldName_v = $fieldName; } $this->m_SelectFieldName = $fieldName; $commaPos = strpos($selectFrom, ",", $pos1); $commaPos2 = strpos($selectFrom, ",", $commaPos + 1); if ($commaPos > $pos1) { if ($commaPos2) { $searchRule = trim(substr($selectFrom, $commaPos + 1, $commaPos2 - $commaPos - 1)); } else { $searchRule = trim(substr($selectFrom, $commaPos + 1)); } } if ($commaPos2 > $commaPos) { $rootSearchRule = trim(substr($selectFrom, $commaPos2 + 1)); } $bizObj = BizSystem::getObject($bizObjName); if (!$bizObj) { return; } $recList = array(); $oldAssoc = $bizObj->m_Association; $bizObj->m_Association = null; if ($searchRule) { $searchRule = Expression::evaluateExpression($searchRule, $this->getFormObj()); } if ($rootSearchRule) { $rootSearchRule = Expression::evaluateExpression($rootSearchRule, $this->getFormObj()); } else { $rootSearchRule = "[PId]=0 OR [PId]='' OR [PId] is NULL"; } $recListTree = $bizObj->fetchTree($rootSearchRule, 100, $searchRule); $bizObj->m_Association = $oldAssoc; if (!$recListTree) { return; } // bugfix : error if data blank foreach ($recListTree as $recListTreeNode) { $this->tree2array($recListTreeNode, $recList); } foreach ($recList as $rec) { $list[$i]['val'] = $rec[$fieldName_v]; $list[$i]['txt'] = $rec[$fieldName]; $i++; } return; } // in case of a|b|c $recList = explode('|', $selectFrom); foreach ($recList as $rec) { $list[$i]['val'] = $rec; $list[$i]['txt'] = $rec; $i++; } return; }
/** * Get Select from list * @param array $list output array * @return void */ public function getFromList(&$list) { $selFrom = $this->getSelectFrom(); $pos0 = strpos($selFrom, "("); $pos1 = strpos($selFrom, ")"); $sql_rules = strstr($selFrom, ','); if ($pos0 > 0 && $pos1 > $pos0 && $sql_rules == FALSE) { // select from xml file $xmlFile = substr($selFrom, 0, $pos0); $tag = substr($selFrom, $pos0 + 1, $pos1 - $pos0 - 1); $tag = strtoupper($tag); $xmlFile = BizSystem::GetXmlFileWithPath($xmlFile); if (!$xmlFile) { return; } $xmlArr =& BizSystem::getXmlArray($xmlFile); if ($xmlArr) { $i = 0; if (!key_exists($tag, $xmlArr["SELECTION"])) { return; } foreach ($xmlArr["SELECTION"][$tag] as $node) { $list[$i]['val'] = $node["ATTRIBUTES"]["VALUE"]; if ($node["ATTRIBUTES"]["TEXT"]) { $list[$i]['txt'] = I18n::getInstance()->translate($node["ATTRIBUTES"]["TEXT"]); } else { $list[$i]['txt'] = I18n::getInstance()->translate($list[$i]['val']); } $i++; } } return; } $pos0 = strpos($selFrom, "["); $pos1 = strpos($selFrom, "]"); if ($pos0 > 0 && $pos1 > $pos0) { // select from bizObj // support BizObjName[BizFieldName] or BizObjName[BizFieldName4Text:BizFieldName4Value] $bizobjName = substr($selFrom, 0, $pos0); $pos3 = strpos($selFrom, ":"); if ($pos3 > $pos0 && $pos3 < $pos1) { $fldName = substr($selFrom, $pos0 + 1, $pos3 - $pos0 - 1); $fldName_v = substr($selFrom, $pos3 + 1, $pos1 - $pos3 - 1); } else { $fldName = substr($selFrom, $pos0 + 1, $pos1 - $pos0 - 1); $fldName_v = $fldName; } $pos_comma = strpos($selFrom, ",", $pos1); if ($pos_comma > $pos1) { $searchRule = trim(substr($selFrom, $pos_comma + 1)); } global $g_BizSystem; $bizobj = BizSystem::getObject($bizobjName); if (!$bizobj) { return; } $recList = array(); $old_assoc = $bizobj->m_Association; $bizobj->m_Association = null; $recList = $bizobj->directFetch($searchRule); $bizobj->m_Association = $old_assoc; foreach ($recList as $rec) { $list[$i]['val'] = $rec[$fldName_v]; $list[$i]['txt'] = $rec[$fldName]; $i++; } return; } // in case of a|b|c $recList = explode('|', $selFrom); foreach ($recList as $rec) { $list[$i]['val'] = $rec; $list[$i]['txt'] = $rec; $i++; } return; }
/** * Get from list * * @param array $list * @return void */ public function getFromList(&$list, $selectFrom = null) { if (!$selectFrom) { $selectFrom = $this->getSelectFrom(); } if (!$selectFrom) { return $this->getSQLFromList($list); } $pos0 = strpos($selectFrom, "("); $pos1 = strpos($selectFrom, ")"); if ($pos0 > 0 && $pos1 > $pos0) { // select from xml file $xmlFile = substr($selectFrom, 0, $pos0); $tag = substr($selectFrom, $pos0 + 1, $pos1 - $pos0 - 1); $tag = strtoupper($tag); $xmlFile = BizSystem::GetXmlFileWithPath($xmlFile); if (!$xmlFile) { return; } $xmlArr =& BizSystem::getXmlArray($xmlFile); if ($xmlArr) { $i = 0; if (!key_exists($tag, $xmlArr["SELECTION"])) { return; } foreach ($xmlArr["SELECTION"][$tag] as $node) { $list[$i]['val'] = $node["ATTRIBUTES"]["VALUE"]; $list[$i]['pic'] = $node["ATTRIBUTES"]["PICTURE"]; if ($node["ATTRIBUTES"]["TEXT"]) { $list[$i]['txt'] = $node["ATTRIBUTES"]["TEXT"]; } else { $list[$i]['txt'] = $list[$i]['val']; } $i++; } $this->translateList($list, $tag); // supprot multi-language } return; } $pos0 = strpos($selectFrom, "["); $pos1 = strpos($selectFrom, "]"); if ($pos0 > 0 && $pos1 > $pos0) { // select from bizObj // support BizObjName[BizFieldName] or // BizObjName[BizFieldName4Text:BizFieldName4Value] or // BizObjName[BizFieldName4Text:BizFieldName4Value:BizFieldName4Pic] $bizObjName = substr($selectFrom, 0, $pos0); $pos3 = strpos($selectFrom, ":"); if ($pos3 > $pos0 && $pos3 < $pos1) { $fieldName = substr($selectFrom, $pos0 + 1, $pos3 - $pos0 - 1); $fieldName_v = substr($selectFrom, $pos3 + 1, $pos1 - $pos3 - 1); } else { $fieldName = substr($selectFrom, $pos0 + 1, $pos1 - $pos0 - 1); $fieldName_v = $fieldName; } $pos4 = strpos($fieldName_v, ":"); if ($pos4) { $fieldName_v_mixed = $fieldName_v; $fieldName_v = substr($fieldName_v_mixed, 0, $pos4); $fieldName_p = substr($fieldName_v_mixed, $pos4 + 1, strlen($fieldName_v_mixed) - $pos4 - 1); unset($fieldName_v_mixed); } $commaPos = strpos($selectFrom, ",", $pos1); if ($commaPos > $pos1) { $searchRule = trim(substr($selectFrom, $commaPos + 1)); } $bizObj = BizSystem::getObject($bizObjName); if (!$bizObj) { return; } $recList = array(); $oldAssoc = $bizObj->m_Association; $bizObj->m_Association = null; $recList = $bizObj->directFetch($searchRule); $bizObj->m_Association = $oldAssoc; foreach ($recList as $rec) { $list[$i]['val'] = $rec[$fieldName_v]; $list[$i]['txt'] = $rec[$fieldName]; $list[$i]['pic'] = $rec[$fieldName_p]; $i++; } return; } // in case of a|b|c $recList = explode('|', $selectFrom); foreach ($recList as $rec) { $list[$i]['val'] = $rec; $list[$i]['txt'] = $rec; $list[$i]['pic'] = $rec; $i++; } return; }
public function getFromList(&$list) { $selectFrom = $this->getSelectFrom(); $pos0 = strpos($selectFrom, "("); $pos1 = strpos($selectFrom, ")"); if ($pos0 > 0 && $pos1 > $pos0) { // select from xml file $xmlFile = substr($selectFrom, 0, $pos0); $tag = substr($selectFrom, $pos0 + 1, $pos1 - $pos0 - 1); $tag = strtoupper($tag); $xmlFile = BizSystem::GetXmlFileWithPath($xmlFile); if (!$xmlFile) { return; } $xmlArr =& BizSystem::getXmlArray($xmlFile); if ($xmlArr) { $i = 0; if (!key_exists($tag, $xmlArr["SELECTION"])) { return; } foreach ($xmlArr["SELECTION"][$tag] as $node) { $list[$i]['val'] = $node["ATTRIBUTES"]["VALUE"]; if ($node["ATTRIBUTES"]["TEXT"]) { $list[$i]['txt'] = I18n::getInstance()->translate($node["ATTRIBUTES"]["TEXT"]); } else { $list[$i]['txt'] = I18n::getInstance()->translate($list[$i]['val']); } $i++; } } return; } $pos0 = strpos($selectFrom, "["); $pos1 = strpos($selectFrom, "]"); if ($pos0 > 0 && $pos1 > $pos0) { // select from bizObj // support BizObjName[BizFieldName] or BizObjName[BizFieldName4Text:BizFieldName4Value] $bizObjName = substr($selectFrom, 0, $pos0); $pos3 = strpos($selectFrom, ":"); if ($pos3 > $pos0 && $pos3 < $pos1) { $fieldName = substr($selectFrom, $pos0 + 1, $pos3 - $pos0 - 1); $fieldName_v = substr($selectFrom, $pos3 + 1, $pos1 - $pos3 - 1); } else { $fieldName = substr($selectFrom, $pos0 + 1, $pos1 - $pos0 - 1); $fieldName_v = $fieldName; } $this->m_SelectFieldName = $fieldName; $commaPos = strpos($selectFrom, ",", $pos1); if ($commaPos > $pos1) { $searchRule = trim(substr($selectFrom, $commaPos + 1)); } $bizObj = BizSystem::getObject($bizObjName); if (!$bizObj) { return; } $recList = array(); $oldAssoc = $bizObj->m_Association; $bizObj->m_Association = null; $recListTree = array(); $bizObj->fetchNodePath("[PId]='" . $this->getValue() . "'", $recListTree); $level = 0; foreach ($recListTree as $recListTreeNode) { $this->tree2array($recListTreeNode, $recList, $level); $level++; } $bizObj->m_Association = $oldAssoc; foreach ($recList as $rec) { $list[$i]['val'] = $rec[$fieldName_v]; $list[$i]['txt'] = $rec[$fieldName]; $i++; } return; } // in case of a|b|c $recList = explode('|', $selectFrom); foreach ($recList as $rec) { $list[$i]['val'] = $rec; $list[$i]['txt'] = $rec; $i++; } return; }