Esempio n. 1
0
 /**
  * Render element, according to the mode
  *
  * @return string HTML text
  */
 public function render()
 {
     $val = $this->getText() ? $this->getText() : $this->getValue();
     $style = $this->getStyle();
     $text = $this->getText();
     $id = $this->objectName;
     $func = $this->getFunction();
     if ($val === '1' || $val === 'true' || strtoupper($val) == 'Y' || $val > 0 || $val == $this->trueValue) {
         $image_url = $this->trueImg;
     } else {
         $image_url = $this->falseImg;
     }
     if (preg_match("/\\{.*\\}/si", $image_url)) {
         $formobj = $this->getFormObj();
         $image_url = Expression::evaluateExpression($image_url, $formobj);
     } else {
         $image_url = Openbizx::$app->getImageUrl() . "/" . $image_url;
     }
     if ($this->link) {
         $link = $this->getLink();
         $target = $this->getTarget();
         $sHTML = "<a  id=\"{$id}\" href=\"{$link}\" {$target} {$func} {$style}><img src='{$image_url}' /></a>";
     } else {
         $sHTML = "<img id=\"{$id}\"  alt=\"" . $text . "\" title=\"" . $text . "\"  src='{$image_url}' />";
     }
     return $sHTML;
 }
Esempio n. 2
0
 public function getStyle()
 {
     $formobj = $this->getFormObj();
     $htmlClass = Expression::evaluateExpression($this->cssClass, $formobj);
     $htmlClass = "CLASS='{$htmlClass}'";
     if (!$htmlClass) {
         $htmlClass = null;
     }
     $style = '';
     if ($this->height && $this->height >= 0) {
         $style .= "height:" . $this->height . "px;";
     }
     if ($this->style) {
         $style .= $this->style;
     }
     if (!isset($style) && !$htmlClass) {
         return null;
     }
     if (isset($style)) {
         $style = Expression::evaluateExpression($style, $formobj);
         $style = "STYLE='{$style}'";
     }
     if ($formobj->errors[$this->objectName]) {
         $htmlClass = "CLASS='" . $this->cssErrorClass . "'";
     }
     if ($htmlClass) {
         $style = $htmlClass . " " . $style;
     }
     return $style;
 }
Esempio n. 3
0
 /**
  * Get style of element
  *
  * @return string style of Element
  */
 protected function getStyle()
 {
     $htmlClass = $this->cssClass ? "class='" . $this->cssClass . "' " : "class='editcombobox'";
     /*
      $width = $this->width ? $this->width : 146;
      $this->widthInput = ($width-18).'px';
      $this->width = $width.'px';
      $style = "position: absolute; width: $this->width; z-index: 1; clip: rect(auto, auto, auto, $this->widthInput);";
     */
     if ($this->style) {
         $style .= $this->style;
     }
     if (!isset($style) && !$htmlClass) {
         return null;
     }
     if (isset($style)) {
         $formObj = $this->getFormObj();
         $style = Expression::evaluateExpression($style, $formObj);
         $style = "style='{$style}'";
     }
     if ($htmlClass) {
         $style = $htmlClass . " " . $style;
     }
     return $style;
 }
Esempio n. 4
0
 /**
  * Get link that evaluated by Expression::evaluateExpression
  *
  * @return string link
  */
 protected function getLink()
 {
     if ($this->link == null) {
         return null;
     }
     $formobj = $this->getFormObj();
     return Expression::evaluateExpression($this->link, $formobj);
 }
Esempio n. 5
0
 /**
  * Get image title
  *
  * @return string
  */
 protected function getTitle()
 {
     if ($this->title == null) {
         return null;
     }
     $formobj = $this->getFormObj();
     return Expression::evaluateExpression($this->title, $formobj);
 }
Esempio n. 6
0
 protected function getHeight()
 {
     if ($this->height == null) {
         return null;
     }
     $formobj = $this->getFormObj();
     return Expression::evaluateExpression($this->height, $formobj);
 }
Esempio n. 7
0
 /**
  * Get text of element
  *
  * @return string
  */
 protected function getText()
 {
     if ($this->text == null) {
         return null;
     }
     $formObj = $this->getFormObj();
     return Expression::evaluateExpression($this->text, $formObj);
 }
Esempio n. 8
0
 public function render()
 {
     $fromList = array();
     $this->getFromList($fromList);
     $value = $this->getValue() != 'null' ? $this->getValue() : $this->getDefaultValue();
     $value = $value === null ? $this->getDefaultValue() : $value;
     $valueArray = explode(',', $value);
     $disabledStr = $this->getEnabled() == "N" ? "DISABLED=\"true\"" : "";
     $style = $this->getStyle();
     $func = $this->getFunction();
     $formobj = $this->GetFormObj();
     if ($formobj->errors[$this->objectName]) {
         $func .= "onclick=\"this.className='{$this->cssClass}'\"";
     } else {
         $func .= "onmouseover=\"this.className='{$this->cssFocusClass}'\" onmouseout=\"this.className='{$this->cssClass}'\"";
     }
     $sHTML = "<input type=\"hidden\" NAME=\"" . $this->objectName . "\" ID=\"" . $this->objectName . "\" value=\"" . $value . "\" {$disabledStr} {$this->htmlAttr} />";
     $sHTML .= "<ul id=\"image_list_" . $this->objectName . "\" {$style} {$func} >";
     if ($this->blankOption) {
         $entry = explode(",", $this->blankOption);
         $text = $entry[0];
         $value = $entry[1] != "" ? $entry[1] : null;
         $entryList = array(array("val" => $value, "txt" => $text));
         $fromList = array_merge($entryList, $fromList);
     }
     foreach ($fromList as $option) {
         $test = array_search($option['val'], $valueArray);
         if ($test === false) {
             $selectedStr = 'normal';
         } else {
             $selectedStr = "current";
         }
         if ($this->width) {
             $width_str = " width=\"" . $this->width . "\" ";
         }
         if ($this->height) {
             $height_str = " height=\"" . $this->height . "\" ";
         }
         $image_url = $option['pic'];
         if (preg_match("/\\{.*\\}/si", $image_url)) {
             $formobj = $this->getFormObj();
             $image_url = Expression::evaluateExpression($image_url, $formobj);
         } else {
             $image_url = Openbizx::$app->getImageUrl() . "/" . $image_url;
         }
         $sHTML .= "<a title=\"" . $option['txt'] . "\" \n            \t\t\t\thref=\"javascript:;\"\n            \t\t\t\tclass=\"{$selectedStr}\"\n            \t\t\t\tonclick =\"\$('" . $this->objectName . "').value='" . $option['val'] . "';            \t\t\t\t\t\t\t\n            \t\t\t\t\t\t\tOpenbizx.ImageSelector.reset('image_list_" . $this->objectName . "');\n            \t\t\t\t\t\t\tthis.className='current';\n            \t\t\t\t\t\t\t\"\t\n            \t\t\t>\n            \t\t\t<img\n            \t\t\t    {$width_str} {$height_str}\n            \t\t\t    src=\"" . $image_url . "\" \n            \t\t\t\ttitle=\"" . $option['txt'] . "\" \n            \t\t\t\t /></a>";
     }
     $sHTML .= "</ul>";
     return $sHTML;
 }
Esempio n. 9
0
 /**
  * Render, draw the element according to the mode
  *
  * @return string HTML text
  */
 public function render()
 {
     $value = $this->value;
     $name = $this->objectName . '[]';
     $style = $this->getStyle();
     if ($this->checkStatus) {
         $formObj = $this->getFormObj();
         $testResult = Expression::evaluateExpression($this->checkStatus, $formObj);
         if ($testResult) {
             $checkStatus = " checked=\"checked\" ";
         } else {
             $checkStatus = "";
         }
     } else {
         $checkStatus = "";
     }
     $sHTML = "<INPUT TYPE=\"CHECKBOX\" {$checkStatus} NAME=\"{$name}\" VALUE='{$value}' onclick=\"event.cancelBubble=true;\" {$this->htmlAttr} {$style}/>";
     return $sHTML;
 }
Esempio n. 10
0
 public function render()
 {
     $formobj = $this->getFormObj();
     $this->totalPage = Expression::evaluateExpression($this->totalPage, $formobj);
     $this->currentPage = Expression::evaluateExpression($this->currentPage, $formobj);
     $style = $this->getStyle();
     $id = $this->objectName;
     $func = $this->getFunction();
     $sHTML = "";
     $link = $this->getLink();
     $target = $this->getTarget();
     for ($i = 1; $i < $this->totalPage + 1; $i++) {
         if ($i == $this->currentPage) {
             $sHTML .= "<a id=\"{$id}\" href=\"" . $link . $i . "\" {$target} {$func} class=\"" . $this->currentCss . "\">" . $i . "</a>";
         } else {
             $sHTML .= "<a id=\"{$id}\" href=\"" . $link . $i . "\" {$target} {$func} {$style}>" . $i . "</a>";
         }
     }
     return $sHTML;
 }
Esempio n. 11
0
 /**
  * Render, draw the control according to the mode
  *
  * @return string HTML text
  */
 public function render()
 {
     $this->prefix = Expression::evaluateExpression($this->prefix, $formobj);
     $func = $this->getFunction();
     if ($this->width) {
         $width_str = " width=\"" . $this->width . "\" ";
     }
     if ($this->height) {
         $height_str = " height=\"" . $this->height . "\" ";
     }
     $value = $this->getText() ? $this->getText() : $this->getValue();
     if ($value) {
         if ($this->link) {
             $link = $this->getLink();
             $target = $this->getTarget();
             $sHTML = "<a href=\"{$link}\" {$target} {$func} {$style}>" . "<img src=\"" . $this->prefix . $value . "\"  border=\"0\" {$width_str} {$height_str} />" . "</a>";
         } else {
             $sHTML = "<img border=\"0\" src=\"" . $this->prefix . $value . "\" {$func} {$width_str} {$height_str} />";
         }
     }
     return $sHTML;
 }
Esempio n. 12
0
 public function render()
 {
     $value = $this->text ? $this->getText() : $this->value;
     if ($this->color) {
         $formObj = $this->getFormObj();
         $color = Expression::evaluateExpression($this->color, $formObj);
         if (!$color) {
             $color = '33b5fb';
         }
         $bgcolor_str = "background-color: #" . $color . ";";
     } else {
         $bgcolor_str = "background-color: #33b5fb;";
     }
     if ($this->displayFormat) {
         $value = sprintf($this->displayFormat, $value);
     }
     if ($this->percent == 'Y') {
         $value = sprintf("%.2f", $value * 100) . '%';
     }
     $style = $this->getStyle();
     $id = $this->objectName;
     $func = $this->getFunction();
     $height = $this->height;
     $width = $this->width - 80;
     $max_value = Expression::evaluateExpression($this->maxValue, $this->getFormObj());
     $width_rate = $value / $max_value;
     if ($width_rate > 1) {
         $width_rate = 1;
     }
     $width_bar = (int) ($width * $width_rate);
     if (!preg_match("/MSIE 6/si", $_SERVER['HTTP_USER_AGENT'])) {
         $bar_overlay = "<span class=\"bar_data_bg\" style=\"" . $bgcolor_str . "height:" . $height . "px;width:" . $width_bar . "px;\"></span>";
         $bar = "<span class=\"bar_data\" style=\"" . $bgcolor_str . "height:" . $height . "px;width:" . $width_bar . "px;\"></span>";
     } else {
         $bar = "<span class=\"bar_data\" style=\"" . $bgcolor_str . "height:" . $height . "px;width:" . $width_bar . "px;opacity: 0.4;filter: alpha(opacity=40);\"></span>";
     }
     $sHTML = "\n    \t<span id=\"{$id}\" {$func} {$style} >\n    \t\t\n    \t\t<span class=\"bar_bg\" style=\"height:" . $height . "px;width:" . $width . "px;\">    \t\t\t\n    \t\t{$bar_overlay}\n    \t\t{$bar}\t \n    \t\t</span>\n    \t\t\n    \t\t<span class=\"value\" style=\"text-align:left;text-indent:10px;\">{$value}" . $this->displayUnit . "</span>\n    \t</span>\n    \t";
     return $sHTML;
 }
Esempio n. 13
0
 /**
  * Convert search/sort rule to sql clause, replace [fieldName] with table.column
  * openbiz SQL expression as :
  * "[fieldName] opr 'Value' AND/OR [fieldName] opr 'Value'...". "()" is valid syntax
  *
  * @param BizDataObj $dataObj
  * @param string $rule "[fieldName] ..."
  * @return string sql statement
  * */
 private function _ruleToSql($dataObj, $rule)
 {
     $cacheKey = $dataObj->objectName . "-" . $rule;
     if (isset($this->_doRuleCache[$cacheKey])) {
         return $this->_doRuleCache[$cacheKey];
     }
     //echo " _ruleToSql ".$dataObj->objectName." ". $rule."\n";
     $dataSqlObj = $this->getDataSqlObj();
     $rule = Expression::evaluateExpression($rule, $dataObj);
     // replace all [field] with table.column
     // use regexp to find [] parts and replace with fields
     if (!preg_match_all("/\\[([0-9a-zA-Z_]+)\\]/", $rule, $m)) {
         $this->_doRuleCache[$cacheKey] = $rule;
         return $rule;
     }
     foreach ($m[1] as $fld) {
         $bizField = $dataObj->getField($fld);
         if (!$bizField) {
             continue;
         }
         $fld_pattern = "[" . $bizField->objectName . "]";
         if ($bizField->column && strpos($bizField->column, ',') != 0) {
             // handle composite key.
             if (!preg_match('/\\[' . $bizField->objectName . '\\].*=.*\'(.+)\'/', $rule, $matches)) {
                 continue;
             }
             //print_r($matches);
             $keyval = $matches[1];
             // replace the matching part [compkey field]='value'
             $compkey_value = $this->_compKeyRuleToSql($bizField->column, $keyval);
             $rule = $str_replace($matches[0], $compkey_value, $rule);
         } else {
             if ($bizField->aliasName) {
                 $rule = str_replace($fld_pattern, $bizField->aliasName, $rule);
             } elseif ($bizField->sqlExpression) {
                 $rule = str_replace($fld_pattern, $bizField->sqlExpression, $rule);
             } else {
                 $tableColumn = $dataSqlObj->getTableColumn($bizField->join, $bizField->column);
                 $rule = str_replace($fld_pattern, $tableColumn, $rule);
             }
         }
     }
     $this->_doRuleCache[$cacheKey] = $rule;
     return $rule;
 }
Esempio n. 14
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;
 }
Esempio n. 15
0
 /**
  * Render element, according to the mode
  *
  * @return string HTML text
  */
 public function render()
 {
     $style = $this->getStyle();
     $text = $this->getText();
     $id = $this->objectName;
     $func = $this->getFunction();
     switch ($this->getValue()) {
         case "0":
             $image_url = $this->myPrivateImg;
             break;
         case "1":
             $image_url = $this->mySharedImg;
             break;
         case "2":
             $image_url = $this->groupSharedImg;
             break;
         case "3":
             $image_url = $this->otherSharedImg;
             break;
         case "4":
             $image_url = $this->myAssignedImg;
             break;
         case "5":
             $image_url = $this->myDistributedImg;
             break;
         default:
             if ($this->defaultImg == '{OPENBIZ_RESOURCE_URL}/common/images/icon_data_shared_other.gif') {
                 $this->defaultImg = $this->otherSharedImg;
             }
             $image_url = $this->defaultImg;
             break;
     }
     if (preg_match("/\\{.*\\}/si", $image_url)) {
         $formobj = $this->getFormObj();
         $image_url = Expression::evaluateExpression($image_url, $formobj);
     } else {
         $image_url = Openbizx::$app->getImageUrl() . "/" . $image_url;
     }
     if ($this->width) {
         $width = "width=\"{$this->width}\"";
     }
     if ($this->link) {
         $link = $this->getLink();
         $target = $this->getTarget();
         $sHTML = "<a   id=\"{$id}\" href=\"{$link}\" {$target} {$func} {$style}><img {$width} src='{$image_url}' /></a>";
     } else {
         $sHTML = "<img id=\"{$id}\"  alt=\"" . $text . "\" title=\"" . $text . "\" {$width} src='{$image_url}' />";
     }
     return $sHTML;
 }
Esempio n. 16
0
 /**
  * Get output attributs as array
  *
  * @return array array of attributs
  * @todo rename to getOutputAttribute or getAttribute (2.5?)
  */
 public function outputAttrs()
 {
     $output['name'] = $this->objectName;
     $output['title'] = Expression::evaluateExpression($this->title, $this);
     $output['icon'] = $this->icon;
     return $output;
 }
Esempio n. 17
0
 public function getDefaultChecked()
 {
     $formObj = $this->getFormObj();
     return Expression::evaluateExpression($this->defaultChecked, $formObj);
 }
Esempio n. 18
0
 protected function getSelectFromSQL()
 {
     $formobj = $this->getFormObj();
     return Expression::evaluateExpression($this->selectFromSQL, $formobj);
 }
Esempio n. 19
0
 /**
  * Check if the field has valid value
  *
  * @return boolean true if validation is good
  */
 public function validate()
 {
     $ret = true;
     if ($this->validator) {
         $ret = Expression::evaluateExpression($this->validator, $this->getDataObj());
     }
     return $ret;
 }
Esempio n. 20
0
 /**
  * Execute action
  *
  * @param TriggerAction $triggerAction
  * @param BizDataObj $dataObj
  * @return void
  */
 protected function executeAction($triggerAction, $dataObj)
 {
     // action method
     $methodName = $triggerAction->action;
     // action method arguments
     if (method_exists($this, $methodName)) {
         // evaluate arguments as expression support
         foreach ($triggerAction->argList as $argName => $argValue) {
             $argList[$argName] = Expression::evaluateExpression($argValue, $dataObj);
         }
         // check the immediate flag
         if ($triggerAction->immediate == "Y") {
             // call the method if Immediate is "Y"
             $this->{$methodName}($argList);
         } else {
             // put it to a passive queue
             /* $passiveQueueSvc->Push($methodName,
                $argList,
                $triggerAction->delayMinutes,
                $triggerAction->repeatMinutes); */
         }
     }
 }
Esempio n. 21
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;
     }
 }
Esempio n. 22
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;
 }
Esempio n. 23
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;
 }
Esempio n. 24
0
 /**
  * Get output attributs as array
  *
  * @return array array of attributs
  * @todo rename to getOutputAttribute or getAttribute (2.5?)
  */
 public function outputAttrs()
 {
     $output['name'] = $this->objectName;
     $output['title'] = Expression::evaluateExpression($this->title, $this);
     $output['icon'] = $this->icon;
     $output['hasSubform'] = $this->subForms ? 1 : 0;
     $output['currentPage'] = $this->currentPage;
     $output['currentRecordId'] = $this->recordId;
     $output['totalPages'] = $this->totalPages;
     $output['totalRecords'] = $this->totalRecords;
     $output['description'] = str_replace('\\n', "<br />", Expression::evaluateExpression($this->objectDescription, $this));
     $output['elementSets'] = $this->getElementSet();
     $output['tabSets'] = $this->getTabSet();
     $output['ActionElementSets'] = $this->getElementSet($this->actionPanel);
     if ($output['icon']) {
         if (preg_match("/{.*}/si", $output['icon'])) {
             $output['icon'] = Expression::evaluateExpression($output['icon'], null);
         } else {
             $output['icon'] = OPENBIZ_THEME_URL . "/" . Openbizx::$app->getCurrentTheme() . "/images/" . $output['icon'];
         }
     }
     return $output;
 }
Esempio n. 25
0
 /**
  * Get output attributs
  * 
  * @return array
  * @todo need to raname to getOutputAttributs() or getAttributes
  */
 public function outputAttrs()
 {
     $out['name'] = $this->objectName;
     $out['module'] = $this->getModuleName($this->objectName);
     $out['description'] = $this->objectDescription;
     $out["keywords"] = $this->keywords;
     if ($this->title) {
         $title = Expression::evaluateExpression($this->title, $this);
     } else {
         $title = $this->objectDescription;
     }
     $out['title'] = $title;
     return $out;
 }
Esempio n. 26
0
 protected function getRequired()
 {
     $formObj = $this->getFormObj();
     return Expression::evaluateExpression($this->required, $formObj);
 }