예제 #1
0
 /**
  * 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 = Openbizx::$app->getClientProxy()->getFormInputs("__this");
     // get the current UI bizobj
     $formObj = Openbizx::getObject($objName);
     // get the existing bizform object
     $bizDataObj = $formObj->getDataObj();
     // get chart config xml file
     $chartXmlFile = ObjectFactoryHelper::getXmlFileWithPath($objName . "_chart");
     $xmlArr = ObjectFactoryHelper::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;
             }
         }
     }
 }
예제 #2
0
 protected function getXMLFromList(&$list, $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 = ObjectFactoryHelper::getXmlFileWithPath($xmlFile);
         if (!$xmlFile) {
             return false;
         }
         $xmlArr =& ObjectFactoryHelper::getXmlArray($xmlFile);
         if ($xmlArr) {
             $i = 0;
             if (!isset($xmlArr["SELECTION"][$tag])) {
                 return false;
             }
             if (!$xmlArr["SELECTION"][$tag][0]) {
                 $array = $xmlArr["SELECTION"][$tag];
                 unset($xmlArr["SELECTION"][$tag]);
                 $xmlArr["SELECTION"][$tag][0] = $array;
             }
             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 true;
     }
     return false;
 }
예제 #3
0
 /**
  * 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 = ObjectFactoryHelper::getXmlFileWithPath($objName);
         if ($xmlFile) {
             $xmlArr = ObjectFactoryHelper::getXmlArray($xmlFile);
         } else {
             //$this->_createObjectFromClass($objName);
             /* 
              * if not have metadata, create object from class directly
              * metadata is on the class it self.                 * 
              */
             $class = str_replace('.', '\\', $objName);
             /*
             $dotPos = strrpos($objName, ".");
             if ($dotPos > 0) { // if has package/namespace
                 $objectPackage =  substr($objName, 0, $dotPos) ;
                 $class = substr($objName, $dotPos + 1);
             } else {
                 $objectPackage = null;
                 $class = $objName;
             }
             * 
             */
         }
     }
     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);
             }
         }
         $class = $xmlArr[$root]["ATTRIBUTES"]["CLASS"];
         //echo __METHOD__.'-'.__LINE__ . ' class : ' . $class . ' <br />';
         // if class has package name as prefix, change the package to the prefix
         $dotPos = strrpos($class, ".");
         if ($dotPos > 0) {
             $classPrefix = substr($class, 0, $dotPos);
             $classPackage = $classPrefix;
             $shortClass = substr($class, $dotPos + 1);
         } else {
             $classPrefix = null;
             $classPackage = null;
             $shortClass = $class;
         }
         //echo 'shortclass : ' . $shortClass .'<br />' ;
         // set object package
         $dotPos = strrpos($objName, ".");
         $objectPackage = $dotPos > 0 ? substr($objName, 0, $dotPos) : null;
         if (strpos($objectPackage, '@') === 0) {
             $objectPackage = substr($objectPackage, 1);
         }
         if (!$classPackage) {
             $classPackage = $objectPackage;
         }
         $xmlArr[$root]["ATTRIBUTES"]["PACKAGE"] = $objectPackage;
     }
     //$package = $xmlArr[$root]["ATTRIBUTES"]["PACKAGE"];
     //$class = $xmlArr[$root]["ATTRIBUTES"]["CLASS"];
     $class = $shortClass;
     // echo $class . '<br />';
     $class = $this->getClassNameFromAlias($class);
     if (strrpos($class, '\\') !== false) {
         $obj_ref = new $class($xmlArr);
         return $obj_ref;
     }
     //echo $class . '<br />';
     //echo $classPackage . '<br />';
     if (!class_exists($class, false)) {
         //echo 'class not exist<br />';
         $classFile = ClassLoader::getLibFileWithPath($class, $classPackage);
         //echo 'classFile: '.$classFile .'<br />';
         if (!$classFile) {
             if ($objectPackage) {
                 trigger_error("Cannot find the class with name as {$objectPackage}.{$class}", E_USER_ERROR);
             } else {
                 trigger_error("Cannot find the class with name as {$class} of {$objName}", E_USER_ERROR);
             }
             exit;
         }
         include_once $classFile;
     }
     //echo 'class_exists($class, false): '. (class_exists($class, false)? 'true':'false') . '<br />';
     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 {
         trigger_error("Cannot find the class with name as {$class} in {$classFile}", E_USER_ERROR);
     }
     return null;
 }
예제 #4
0
 /**
  * Get user preference
  *
  * @param string $attribute key that representing attribute
  * @return mixed
  */
 public function getUserPreference($attribute = null)
 {
     if (!ObjectFactoryHelper::getXmlFileWithPath(OPENBIZ_PREFERENCE_SERVICE)) {
         return null;
     }
     $preferenceService = Openbizx::getService(OPENBIZ_PREFERENCE_SERVICE);
     if (method_exists($preferenceService, 'getPreference')) {
         return $preferenceService->getPreference($attribute);
     } else {
         $preference = $this->getSessionContext()->getVar("_USER_PREFERENCE");
         return isset($preference[$attribute]) ? $preference[$attribute] : "";
     }
 }
예제 #5
0
 private function getMetadataArray($objName)
 {
     $xmlFile = ObjectFactoryHelper::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 = ObjectFactoryHelper::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;
 }
 /**
  * Read application.xml into a internal array.
  */
 public function __construct()
 {
     $xmlFile = ObjectFactoryHelper::getXmlFileWithPath("application");
     $this->_xmlArr =& ObjectFactoryHelper::getXmlArray($xmlFile);
 }
예제 #7
0
 /**
  * Run DataObject trigger
  *
  * @param string $triggerType type of the trigger
  */
 private function _runDOTrigger($triggerType)
 {
     // locate the trigger metadata file BOName_Trigger.xml
     $triggerServiceName = $this->objectName . "_Trigger";
     $xmlFile = ObjectFactoryHelper::getXmlFileWithPath($triggerServiceName);
     if (!$xmlFile) {
         return;
     }
     $triggerService = Openbizx::getObject($triggerServiceName);
     if ($triggerService == null) {
         return;
     }
     // invoke trigger service ExecuteTrigger($triggerType, $currentRecord)
     $triggerService->execute($this, $triggerType);
 }