Example #1
0
 /**
  * Fetch record
  * 
  * @param string $doName data object name
  * @param string $searchRule rule of search
  * @return mixed
  */
 public function fetchRecord($doName, $searchRule)
 {
     $do = Openbizx::getObject($doName);
     if (!$do) {
         throw new Exception("System cannot get object of {$doName}.");
         return;
     }
     $r = $do->directFetch($searchRule, 1);
     if (count($r) > 0) {
         return $r[0];
     }
     return null;
 }
Example #2
0
 protected function getDOFromList(&$list, $selectFrom)
 {
     $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));
         }
         /* @var $bizObj BizDataObj */
         $bizObj = Openbizx::getObject($bizObjName);
         if (!$bizObj) {
             return false;
         }
         $recList = array();
         $oldAssoc = $bizObj->association;
         $bizObj->association = null;
         QueryStringParam::reset();
         $recList = $bizObj->directFetch($searchRule);
         $bizObj->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 true;
     }
     return false;
 }
 /**
  * Get the object instance defined in the object reference
  *
  * @param string $objName the object name list in the ObjectReference part
  * @return BizDataObj object instance
  */
 public function getRefObject($objName)
 {
     // see if there is such object in the ObjReferences
     $objRef = $this->objReferences->get($objName);
     if (!$objRef) {
         return null;
     }
     // apply association on the object
     // $assc = $this->EvaluateExpression($objRef->association);
     // get the object instance
     $obj = Openbizx::getObject($objName);
     $obj->setAssociation($objRef, $this);
     return $obj;
 }
Example #4
0
 protected function getFormObj()
 {
     return Openbizx::getObject($this->formName);
 }
 public function buildDeleteSQLwithCondition($dataObj, $condition = null)
 {
     $sql = "DELETE FROM `" . $dataObj->mainTableName . "`";
     if ($condition) {
         $whereStr = $this->_convertSqlExpressionWithoutPrefix($dataObj, $condition);
         $sql .= " WHERE " . $whereStr;
     }
     // append DataPerm in the WHERE clause
     if ($dataObj->dataPermControl == 'Y') {
         $svcObj = Openbizx::getService(OPENBIZ_DATAPERM_SERVICE);
         $hasOwnerField = $this->_hasOwnerField($dataObj);
         $dataPermSQLRule = $svcObj->buildSqlRule($dataObj, 'delete', $hasOwnerField);
         $sqlSearchRule = $this->_convertSqlExpressionWithoutPrefix($dataObj, $dataPermSQLRule);
         if ($whereStr != '') {
             $sql .= ' AND ' . $sqlSearchRule;
         } else {
             $sql .= $sqlSearchRule;
         }
     }
     return $sql;
 }
Example #6
0
 /**
  * Get record array by converting input indexed-Value array to Field-Value pairs
  *
  * @param array $sqlArr column value pair array
  * @return array record array
  * */
 public final function getRecordArr($sqlArr = null)
 {
     if ($sqlArr) {
         $this->_setSqlRecord($sqlArr);
     }
     $recArr = array();
     foreach ($this->varValue as $key => $field) {
         if ($field->encrypted == 'Y') {
             $svcobj = Openbizx::getService(CRYPT_SERVICE);
             $value = $svcobj->decrypt($field->getValue());
             $recArr[$key] = $value;
         } else {
             $recArr[$key] = $field->getValue();
         }
     }
     return $recArr;
 }
Example #7
0
 public function getValue()
 {
     if ($this->allowAccess()) {
         $formElementObj = Openbizx::getObject($this->formReference);
         if (method_exists($formElementObj, "getValue")) {
             return $formElementObj->getValue();
         }
     }
 }
Example #8
0
 /**
  * Get the number of records according the Select SQL
  *
  * @param object $db database connection
  * @param string $sql SQL string
  * @return int number of records
  */
 private function _getNumberRecords($db, $sql)
 {
     $has_subquery = false;
     if (preg_match("/\\(\\s*?SELECT\\s*?.+\\)/si", $sql)) {
         $has_subquery = true;
     }
     if (preg_match("/^\\s*SELECT\\s+DISTINCT/is", $sql) || preg_match('/\\s+GROUP\\s+BY\\s+/is', $sql)) {
         // ok, has SELECT DISTINCT or GROUP BY so see if we can use a table alias
         $rewritesql = preg_replace('/(\\sORDER\\s+BY\\s.*)/is', '', $sql);
         $rewritesql = "SELECT COUNT(*) FROM ({$rewritesql}) _TABLE_ALIAS_";
     } elseif ($has_subquery == false) {
         // now replace SELECT ... FROM with SELECT COUNT(*) FROM
         $rewritesql = preg_replace('/\\s*?SELECT\\s.*?\\s+FROM\\s/is', 'SELECT COUNT(*) FROM ', $sql);
         // Because count(*) and 'order by' fails with mssql, access and postgresql.
         // Also a good speedup optimization - skips sorting!
         $rewritesql = preg_replace('/(\\sORDER\\s+BY\\s.*)/is', '', $rewritesql);
     } else {
         $rewritesql = $sql;
     }
     try {
         if ($this->cacheLifeTime > 0) {
             $cache_id = md5($this->objectName . $rewritesql . serialize($bindValues));
             //try to process cache service.
             $cacheSvc = Openbizx::getService(CACHE_SERVICE);
             $cacheSvc->init($this->objectName, $this->cacheLifeTime);
             if ($cacheSvc->test($cache_id)) {
                 //Openbizx::$app->getLog()->log(LOG_DEBUG, "DATAOBJ", ". Query Sql = ".$rewritesql);
                 $resultArray = $cacheSvc->load($cache_id);
             } else {
                 Openbizx::$app->getLog()->log(LOG_DEBUG, "DATAOBJ", "Query Sql = " . $rewritesql);
                 $result = $db->query($rewritesql);
                 $resultArray = $result->fetch();
                 $cacheSvc->save($resultArray, $cache_id);
             }
         } else {
             Openbizx::$app->getLog()->log(LOG_DEBUG, "DATAOBJ", "Query Sql = " . $rewritesql);
             $resultSet = $db->query($rewritesql);
             $resultArray = $resultSet->fetch();
         }
     } catch (Exception $e) {
         Openbizx::$app->getLog()->log(LOG_ERR, "DATAOBJ", "Query Error: " . $e->getMessage());
         $this->errorMessage = $this->getMessage("DATA_ERROR_QUERY") . ": Rewrite:" . $rewritesql . ". Raw:" . $sql . ". " . $e->getMessage();
         throw new \Openbizx\Data\Exception($this->errorMessage);
         return 0;
     }
     if ($has_subquery) {
         $record_count = (int) $resultSet->rowCount();
     } else {
         $record_count = (int) $resultArray[0];
     }
     return (string) $record_count;
 }
Example #9
0
 public function targetSwitchForm($targetForm, $formName = null, $id = null, $params = null, $target = null)
 {
     if ($targetForm) {
         $formObj = Openbizx::getObject($targetForm);
         if ($formObj) {
             return $formObj->switchForm($formName, $id, $params, $target);
         }
     }
 }
Example #10
0
 /**
  * Clean chache
  *
  * @global BizSystem $g_BizSystem
  * @return void
  */
 public function cleanCache()
 {
     if ($this->cacheLifeTime > 0) {
         $cacheSvc = Openbizx::getService(CACHE_SERVICE, 1);
         $cacheSvc->init($this->objectName, $this->cacheLifeTime);
         $cacheSvc->cleanAll();
     }
 }
Example #11
0
 /**
  * Check value type
  *
  * @param mixed $value
  * @return mixed|boolean
  */
 public function checkValueType($value = null)
 {
     if (!$value) {
         $value = $this->value;
     }
     $validator = Openbizx::getService(VALIDATE_SERVICE);
     switch ($this->type) {
         case "Number":
             $result = is_numeric($value);
             break;
         case "Text":
             $result = is_string($value);
             break;
         case "Date":
             $result = $validator->date($value);
             break;
             /*
              case "Datetime":    // zend doesn't support date time
              $result = $validator->date($value);
              break;
             
              case "Currency":
              $result = $validator->date($value);
              break;
             */
         /*
          case "Datetime":    // zend doesn't support date time
          $result = $validator->date($value);
          break;
         
          case "Currency":
          $result = $validator->date($value);
          break;
         */
         case "Phone":
             $result = $validator->phone($value);
             break;
         default:
             $result = true;
             break;
     }
     return $result;
 }
Example #12
0
 /**
  * Get the openbiz view object by object name.
  * It's functional same as getObject() method, just this method can return more eclipse friendly result,
  * it can support IDE's code auto completaion.
  *
  * @param string $objectName object name
  * @return WebPage  if the return object is a WebPage then return, or return null
  * @example ../../example/ViewObject.php
  */
 public static function getWebpageObject($objectName)
 {
     return Openbizx::getObject($objectName, 0);
 }
Example #13
0
 /**
  * Show HTML error message
  * This method call by {@link ShowErrorMessage} if RPC flag false.
  *
  * @param string $errMsg error message
  * @return void
  */
 private function _errorOutput($errMsg)
 {
     //ob_clean();
     //Openbizx::$app->isInitialized = false;
     if (defined('OPENBIZ_INTERNAL_ERROR_VIEW') && Openbizx::$app->isInitialized) {
         //render the view
         $_GET['ob_err_msg'] = $errMsg;
         ob_end_clean();
         Openbizx::getObject(OPENBIZ_INTERNAL_ERROR_VIEW)->render();
         exit;
     } else {
         echo $errMsg;
         echo "<input type='button' NAME='btn_back' VALUE='Go back' onClick='history.go(-1);return true;'>";
     }
 }
Example #14
0
 /**
  * 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 = Openbizx::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]);
             Openbizx::$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);
 }
Example #15
0
 /**
  * Gather all template variables needed. Should play well with Smarty or \Zend templates
  *
  * @param WebPage $webPage
  * @return array associative array holding all needed VIEW based template variables
  */
 public static function buildTemplateAttributes($webPage)
 {
     // Assocative Array to hold all Template Values
     // Fill with default viewobj attributes
     //$tplAttributes = $viewObj->outputAttrs();
     //Not sure what this is doing...
     $newClntObjs = '';
     //Fill other direct view variables
     $tplAttributes["module"] = $webPage->getModuleName($webPage->objectName);
     $tplAttributes["description"] = $webPage->objectDescription;
     $tplAttributes["keywords"] = $webPage->keywords;
     if (isset($webPage->tiles)) {
         foreach ($webPage->tiles as $tname => $tile) {
             // renderForms() : BEGIN
             foreach ($tile as $formRef) {
                 if ($formRef->display == false) {
                     continue;
                 }
                 $tiles[$tname][$formRef->objectName] = Openbizx::getObject($formRef->objectName)->render();
                 $tiletabs[$tname][$formRef->objectName] = $formRef->objectDescription;
             }
             // renderForms() : END
         }
     } else {
         // renderForms() : BEGIN
         foreach ($webPage->formRefs as $formRef) {
             if ($formRef->display == false) {
                 continue;
             }
             $forms[$formRef->objectName] = Openbizx::getObject($formRef->objectName)->render();
             $formtabs[$formRef->objectName] = $formRef->objectDescription;
         }
         // renderForms() : END
     }
     if (count($webPage->widgets)) {
         // renderForms() : BEGIN
         foreach ($webPage->widgets as $formRef) {
             if ($formRef->display == false) {
                 continue;
             }
             $widgets[$formRef->objectName] = Openbizx::getObject($formRef->objectName)->render();
         }
     }
     //Fill Loop related data
     $tplAttributes["forms"] = $forms;
     $tplAttributes["widgets"] = $widgets;
     $tplAttributes["formtabs"] = $formtabs;
     $tplAttributes["tiles"] = $tiles;
     $tplAttributes["tiletabs"] = $tiletabs;
     // add clientProxy scripts
     $includedScripts = Openbizx::$app->getClientProxy()->getAppendedScripts();
     $tplAttributes["style_sheets"] = Openbizx::$app->getClientProxy()->getAppendedStyles();
     if ($webPage->isPopup && $bReRender == false) {
         $moveToCenter = "moveToCenter(self, " . $webPage->width . ", " . $webPage->height . ");";
         $tplAttributes["scripts"] = $includedScripts . "\n<script>\n" . $newClntObjs . $moveToCenter . "</script>\n";
     } else {
         $tplAttributes["scripts"] = $includedScripts . "\n<script>\n" . $newClntObjs . "</script>\n";
     }
     if ($webPage->title) {
         $tplAttributes["title"] = Expression::evaluateExpression($webPage->title, $webPage);
     } else {
         $tplAttributes["title"] = $webPage->objectDescription;
     }
     if (OPENBIZ_DEFAULT_SYSTEM_NAME) {
         $tplAttributes["title"] = $tplAttributes["title"] . ' - ' . OPENBIZ_DEFAULT_SYSTEM_NAME;
     }
     return $tplAttributes;
 }
Example #16
0
 /**
  * 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 = Openbizx::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 = Openbizx::objectFactory()->getClassNameFromAlias($className);
                 $obj = new $className($child, $parentObj);
                 $this->varValue[$obj->objectName] = $obj;
             }
         }
     }
 }
Example #17
0
 public function getProfile()
 {
     return Openbizx::getService(PROFILE_SERVICE);
 }
Example #18
0
 protected function getDOFromList(&$list, $selectFrom)
 {
     // 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->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 = Openbizx::getObject($bizObjName);
         if (!$bizObj) {
             return;
         }
         $recList = array();
         $oldAssoc = $bizObj->association;
         $bizObj->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->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;
     }
 }
Example #19
0
 /**
  * Replace var expression
  * @objname:property, @objname:field[fldname].property, @objname:control[ctrlname].property
  * @:prop = @thisobjname:prop
  *
  * @global BizSystem $g_BizSystem
  * @param string $expression
  * @param object $object
  * @return string
  */
 protected static function replaceVarExpr($expression, $object)
 {
     // replace @objname:property to GetObject()->getProperty(property)
     while (true) {
         // TODO: one clause must be separated by whitespace
         //modified by jixian for support package full name of a object
         //e.g : shared.objects.compaines.objCompany:Field[Id].Value
         $pattern = "/@([[a-zA-Z0-9_\\.]*):([a-zA-Z0-9_\\.\\[\\]]+)/";
         if (!preg_match($pattern, $expression, $matches)) {
             break;
         }
         $macro = $matches[0];
         $objName = $matches[1];
         $propExpr = $matches[2];
         $obj = null;
         if ($objName == "profile") {
             // @profile:attribute is reserved
             $profileAttribute = Openbizx::$app->getUserProfile($propExpr);
             $expression = str_replace($macro, $profileAttribute, $expression);
             continue;
         }
         if ($objName == "home") {
             // @home:url is reserved
             switch ($propExpr) {
                 case "url":
                     $value = "'" . OPENBIZ_APP_INDEX_URL . "'";
                     break;
                 case "base_url":
                     $value = "'" . OPENBIZ_APP_URL . "'";
                     break;
             }
             $expression = str_replace($macro, $value, $expression);
             continue;
         } elseif (in_array($objName, array_keys(Expression::$services))) {
             // reserved keywords
             $body = $expression;
             $objFunc = '@' . $objName . ':' . $propExpr;
             $posStart = strpos($body, $objFunc);
             $beforeString = substr($body, 0, $posStart);
             $paramStart = strpos($body, $objFunc . '(') + strlen($objFunc . '(');
             $paramEnd = strpos($body, ')', $paramStart);
             $paramLen = $paramEnd - $paramStart;
             $function = $propExpr;
             $paramString = substr($body, $paramStart, $paramLen);
             $restString = substr($body, $paramEnd + 1);
             $paramString = Expression::evaluateExpression('{' . $paramString . '}', $object);
             $serviceName = Expression::$services[$objName];
             $serviceObj = Openbizx::getService($serviceName);
             $params = explode(',', $paramString);
             for ($i = 0; $i < count($params); $i++) {
                 $params[$i] = trim($params[$i]);
             }
             $val_result = call_user_func_array(array($serviceObj, $function), $params);
             return $beforeString . $val_result . $restString;
         } elseif ($objName == "" || $objName == "this") {
             $obj = $object;
             $body = $expression;
             $objFunc = '@' . $objName . ':' . $propExpr;
             $posStart = strpos($body, $objFunc);
             $beforeString = substr($body, 0, $posStart);
             if (strpos($body, '(') > 0 && substr($expression, 0, 2) == '@:') {
                 $paramStart = strpos($body, $objFunc . '(') + strlen($objFunc . '(');
                 $paramEnd = strpos($body, ')', $paramStart);
                 $paramLen = $paramEnd - $paramStart;
                 $function = $propExpr;
                 $paramString = substr($body, $paramStart, $paramLen);
                 $restString = substr($body, $paramEnd + 1);
                 $params = explode(',', $paramString);
                 // bug fix
                 for ($i = 0; $i < count($params); $i++) {
                     $params[$i] = trim($params[$i]);
                 }
                 if (!is_array($params)) {
                     $params = array();
                 }
                 if (method_exists($obj, $function)) {
                     $val_result = call_user_func_array(array($obj, $function), $params);
                     return $beforeString . $val_result . $restString;
                 }
             }
         } else {
             $obj = Openbizx::getObject($objName);
         }
         if ($obj == null) {
             throw new \Exception("Wrong expression syntax " . $expression . ", cannot get object " . $objName);
         }
         $pos = strpos($propExpr, ".");
         $paramStart = strpos($expression, $objFunc . '(');
         if ($pos > 0) {
             // in case of @objname:field[fldname].property
             $property1 = substr($propExpr, 0, $pos);
             $property2 = substr($propExpr, $pos + 1);
             $propertyObj = $obj->getProperty($property1);
             if ($propertyObj == null) {
                 $propertyObj = $obj->getDataObj()->getProperty($property1);
                 if ($propertyObj == null) {
                     throw new Exception("Wrong expression syntax " . $expression . ", cannot get property object " . $property1 . " of object " . $objName);
                 } else {
                     $val = $propertyObj->getProperty($property2);
                 }
             }
             $val = $propertyObj->getProperty($property2);
         } else {
             // in case of @objname:property
             $val = $obj->getProperty($propExpr);
         }
         if ($val === null) {
             $val = "";
         }
         if (is_string($val)) {
             $val = "'{$val}'";
         }
         $expression = str_replace($macro, $val, $expression);
     }
     return $expression;
 }
Example #20
0
 /**
  * Process request
  *
  * @return void
  */
 protected function processRequest()
 {
     // if url has form=...
     $paramForm = isset($_REQUEST['form']) ? $_REQUEST['form'] : null;
     // check url arg as fld:name=val
     $getKeys = array_keys($_REQUEST);
     $pageid = $_GET["pageid"];
     $paramFields = null;
     foreach ($getKeys as $key) {
         if (substr($key, 0, 4) == "fld:") {
             $fieldName = substr($key, 4);
             $fieldValue = $_REQUEST[$key];
             $paramFields[$fieldName] = $fieldValue;
         }
     }
     if (!$paramFields && !$pageid) {
         return;
     }
     // get the form object
     if (!$paramForm) {
         // get the first form name if no form is given
         foreach ($this->formRefs as $formRef) {
             $paramForm = $formRef->objectName;
             break;
         }
     }
     if (!$paramForm) {
         return;
     }
     $paramForm = $this->prefixPackage($paramForm);
     $formObj = Openbizx::getObject($paramForm);
     $formObj->setRequestParams($paramFields);
     if ($pageid) {
         $formObj->setCurrentPage($pageid);
     }
 }
Example #21
0
 public function getInvokeAction()
 {
     if ($this->formedFunction) {
         return $this->formedFunction;
     }
     $name = $this->_elemName;
     $ehName = $this->objectName;
     $formobj = Openbizx::getObject($this->_formName);
     if (!$this->formedFunction) {
         // add direct URL support
         if ($this->url) {
             $_func = "loadPage('" . $this->url . "');";
         } else {
             if (strpos($this->function, "js:") === 0) {
                 $_func = substr($this->function, 3) . ";";
             } else {
                 $temp = $this->functionType == null ? "" : ",'" . $this->functionType . "'";
                 //$_func = "SetOnElement('$name:$ehName'); Openbizx.CallFunction('" . $this->function . "'$temp);";
                 list($funcName, $funcParams) = $this->parseFunction($this->function);
                 $funcParams = Expression::evaluateExpression($funcParams, $formobj);
                 $action = "{$name}:{$ehName}";
                 // TODO: encrypt paramString to add more security
                 $_func = "Openbizx.invoke('{$this->_formName}','{$action}','{$funcParams}'{$temp});";
             }
         }
         //$_func = Expression::evaluateExpression($_func, $formobj);
         $this->formedFunction = $_func;
     }
     return $this->formedFunction;
 }