public function __construct() { Openbiz::$app = $this; //$this->isInitialized = true; // preInit // registerErrorHandlers // registerCoreComponent $this->request = new Request($this); $this->initSystemDefaultTimezone(); // define default class alias $classAliases = ['BizDataObj' => 'Openbiz\\Data\\BizDataObj', 'BizField' => 'Openbiz\\Data\\BizField', 'EasyForm' => 'Openbiz\\Easy\\EasyForm', 'WebPage' => 'Openbiz\\Easy\\WebPage', 'PickerForm' => 'Openbiz\\Easy\\PickerForm', 'FormReference' => 'Openbiz\\Easy\\FormReference', 'AutoSuggest' => 'Openbiz\\Easy\\Element\\AutoSuggest', 'BarcodeScanner' => 'Openbiz\\Easy\\Element\\BarcodeScanner', 'Button' => 'Openbiz\\Easy\\Element\\Button', 'Checkbox' => 'Openbiz\\Easy\\Element\\Checkbox', 'CheckListbox' => 'Openbiz\\Easy\\Element\\CheckListbox', 'CKEditor' => 'Openbiz\\Easy\\Element\\CKEditor', 'ColorPicker' => 'Openbiz\\Easy\\Element\\ColorPicker', 'ColumnBar' => 'Openbiz\\Easy\\Element\\ColumnBar', 'ColumnBool' => 'Openbiz\\Easy\\Element\\ColumnBool', 'ColumnHidden' => 'Openbiz\\Easy\\Element\\ColumnHidden', 'ColumnImage' => 'Openbiz\\Easy\\Element\\ColumnImage', 'ColumnInputText' => 'Openbiz\\Easy\\Element\\ColumnInputText', 'ColumnList' => 'Openbiz\\Easy\\Element\\ColumnList', 'ColumnListbox' => 'Openbiz\\Easy\\Element\\ColumnListbox', 'ColumnPassword' => 'Openbiz\\Easy\\Element\\ColumnPassword', 'ColumnShare' => 'Openbiz\\Easy\\Element\\ColumnShare', 'ColumnSorting' => 'Openbiz\\Easy\\Element\\ColumnSorting', 'ColumnStyle' => 'Openbiz\\Easy\\Element\\ColumnStyle', 'ColumnText' => 'Openbiz\\Easy\\Element\\ColumnText', 'ColumnValue' => 'Openbiz\\Easy\\Element\\ColumnValue', 'DropDownList' => 'Openbiz\\Easy\\Element\\DropDownList', 'EditCombobox' => 'Openbiz\\Easy\\Element\\EditCombobox', 'Element' => 'Openbiz\\Easy\\Element\\Element', 'EventHandler' => 'Openbiz\\Easy\\Element\\EventHandler', 'File' => 'Openbiz\\Easy\\Element\\File', 'FileInput' => 'Openbiz\\Easy\\Element\\FileInput', 'FileUploader' => 'Openbiz\\Easy\\Element\\FileUploader', 'FormElement' => 'Openbiz\\Easy\\Element\\FormElement', 'Hidden' => 'Openbiz\\Easy\\Element\\Hidden', 'HTMLBlock' => 'Openbiz\\Easy\\Element\\HTMLBlock', 'HTMLButton' => 'Openbiz\\Easy\\Element\\HTMLButton', 'HTMLPreview' => 'Openbiz\\Easy\\Element\\HTMLPreview', 'IDCardReader' => 'Openbiz\\Easy\\Element\\IDCardReader', 'IFrameBox' => 'Openbiz\\Easy\\Element\\IFrameBox', 'ImageSelector' => 'Openbiz\\Easy\\Element\\ImageUploader', 'ImageUploader' => 'Openbiz\\Easy\\Element\\ImageUploader', 'InputDate' => 'Openbiz\\Easy\\Element\\InputDate', 'InputDateRangePicker' => 'Openbiz\\Easy\\Element\\InputDateRangePicker', 'InputDatetime' => 'Openbiz\\Easy\\Element\\InputDatetime', 'InputElement' => 'Openbiz\\Easy\\Element\\InputElement', 'InputPassword' => 'Openbiz\\Easy\\Element\\InputPassword', 'InputPicker' => 'Openbiz\\Easy\\Element\\InputPicker', 'InputText' => 'Openbiz\\Easy\\Element\\InputText', 'LabelBack' => 'Openbiz\\Easy\\Element\\LabelBack', 'LabelBar' => 'Openbiz\\Easy\\Element\\LabelBar', 'LabelBool' => 'Openbiz\\Easy\\Element\\LabelBool', 'LabelImage' => 'Openbiz\\Easy\\Element\\LabelImage', 'LabelList' => 'Openbiz\\Easy\\Element\\LabelList', 'LabelPassword' => 'Openbiz\\Easy\\Element\\LabelPassword', 'LabelText' => 'Openbiz\\Easy\\Element\\LabelText', 'LabelTextarea' => 'Openbiz\\Easy\\Element\\LabelTextarea', 'LabelTextPaging' => 'Openbiz\\Easy\\Element\\LabelTextPaging', 'Listbox' => 'Openbiz\\Easy\\Element\\Listbox', 'OptionElement' => 'Openbiz\\Easy\\Element\\OptionElement', 'PageSelector' => 'Openbiz\\Easy\\Element\\PageSelector', 'PagesizeSelector' => 'Openbiz\\Easy\\Element\\PagesizeSelector', 'Password' => 'Openbiz\\Easy\\Element\\Password', 'Radio' => 'Openbiz\\Easy\\Element\\Radio', 'RawData' => 'Openbiz\\Easy\\Element\\RawData', 'ResetButton' => 'Openbiz\\Easy\\Element\\ResetButton', 'RichText' => 'Openbiz\\Easy\\Element\\RichText', 'RowCheckbox' => 'Openbiz\\Easy\\Element\\RowCheckbox', 'Spacer' => 'Openbiz\\Easy\\Element\\Spacer', 'SubmitButton' => 'Openbiz\\Easy\\Element\\SubmitButton', 'Textarea' => 'Openbiz\\Easy\\Element\\Textarea', 'TreeLabelText' => 'Openbiz\\Easy\\Element\\TreeLabelText', 'TreeListbox' => 'Openbiz\\Easy\\Element\\TreeListbox']; Openbiz::objectFactory()->setClassAliases($classAliases); }
/** * Contructor of class * * @param array $xmlArr * @param string $childClassName * @param object $parentObj * @return void */ public function __construct(&$xmlArr, $childClassName, $parentObj = null) { $this->parentObj = $parentObj; if (!$xmlArr) { return; } if (isset($xmlArr["ATTRIBUTES"])) { $className = isset($xmlArr["ATTRIBUTES"]['CLASS']) ? $xmlArr["ATTRIBUTES"]['CLASS'] : $childClassName; if ((bool) strpos($className, ".")) { $a_package_name = explode(".", $className); $className = array_pop($a_package_name); $clsLoaded = ClassLoader::loadMetadataClass($className, implode(".", $a_package_name)); } //if (!$clsLoaded) trigger_error("Cannot find the load class $className", E_USER_ERROR); $className = Openbiz::objectFactory()->getClassNameFromAlias($className); $obj = new $className($xmlArr, $parentObj); $this->varValue[$obj->objectName] = $obj; } else { foreach ($xmlArr as $child) { $className = isset($child["ATTRIBUTES"]['CLASS']) ? $child["ATTRIBUTES"]['CLASS'] : $childClassName; /** * If a '.' is found within className we need to require such class * and then get the className after the last dot * ex. shared.dataobjs.FieldName, in this case FieldName is the class, shared/dataobjs the path * * The best solution to this is enable object factory to specify its resulting object constructor parameters */ if ($className) { //bug fixed by jixian for resolve load an empty classname if ((bool) strpos($className, ".")) { $a_package_name = explode(".", $className); $className = array_pop($a_package_name); $clsLoaded = ClassLoader::loadMetadataClass($className, implode(".", $a_package_name)); } elseif ($parentObj->package) { $clsLoaded = ClassLoader::loadMetadataClass($className, $parentObj->package); } $className = Openbiz::objectFactory()->getClassNameFromAlias($className); $obj = new $className($child, $parentObj); $this->varValue[$obj->objectName] = $obj; } } } }
/** * Save session variables of all stateful objects into sessionid_obj file * * @return void * */ public function saveSessionObjects() { // loop all objects (bizview, bizform, bizdataobj) collect their session vars $allobjs = Openbiz::objectFactory()->getAllObjects(); foreach ($allobjs as $obj) { if (method_exists($obj, "saveStatefullVars")) { //after calling $obj->saveStatefullVars SessObjArr and StatefulSessObjArr are filled $obj->saveStatefullVars($this); } // if previous view's object is used in current view, don't discard its session data if (isset($obj->objectName) && isset($this->_prevViewObjNames[$obj->objectName])) { unset($this->_prevViewObjNames[$obj->objectName]); Openbiz::$app->getLog()->log(LOG_ERR, "SESSION", "unset " . $obj->objectName); } } // discard useless previous view's session objects //foreach($this->_prevViewObjNames as $objName=>$tmp) // unset($this->_sessObjArr[$objName]); $this->_sessObjArr["ViewHist"] = $this->_viewHistory; $this->setVar(OB_TRANSIENT_DATA_SESSION_INDEX, $this->_sessObjArr); $this->setVar(OB_STATEFUL_DATA_SESSION_INDEX, $this->_statefulSessObjArr); }