当前位置: 首页>>代码示例>>PHP>>正文


PHP Parser::getFieldsFromExpression方法代码示例

本文整理汇总了PHP中Parser::getFieldsFromExpression方法的典型用法代码示例。如果您正苦于以下问题:PHP Parser::getFieldsFromExpression方法的具体用法?PHP Parser::getFieldsFromExpression怎么用?PHP Parser::getFieldsFromExpression使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Parser的用法示例。


在下文中一共展示了Parser::getFieldsFromExpression方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: has_calc_field_with_link

 /**
  * Tests if the current module has a calculated field with a link.
  * if a link name is specified, it will return true when a field uses that specific link
  * Otherwise it will test for all link fields.
  * @param string $linkName
  * @return bool
  */
 function has_calc_field_with_link($linkName = "")
 {
     $links = array();
     if (empty($linkName)) {
         foreach ($this->field_defs as $field => $def) {
             if (!empty($def['type']) && $def['type'] == "link") {
                 $links[$field] = true;
             }
         }
     } else {
         $links[$linkName] = true;
     }
     if (!empty($links)) {
         foreach ($this->field_defs as $name => $def) {
             //Look through all calculated fields for uses of this link field
             if (!empty($def['formula'])) {
                 require_once "include/Expressions/Expression/Parser/Parser.php";
                 $fields = Parser::getFieldsFromExpression($def['formula']);
                 foreach ($fields as $var) {
                     if (!empty($links[$var])) {
                         return true;
                     }
                 }
             }
         }
     }
     return false;
 }
开发者ID:jglaine,项目名称:sugar761-ent,代码行数:35,代码来源:SugarBean.php

示例2: prepareCalculationFields

 /**
  * prepare Calculation Fields for creation formula
  *
  * @param array $fieldDefs The fields defs for the current module.
  * @param string $module current module.
  */
 protected function prepareCalculationFields($fieldDefs, $module)
 {
     $fields = array();
     foreach ($fieldDefs as $field => $def) {
         if (isset($def['calculated']) && $def['calculated'] && !empty($def['formula'])) {
             $triggerFields = Parser::getFieldsFromExpression($def['formula'], $fields);
             foreach ($triggerFields as $field_c) {
                 if (isset($fieldDefs[$field_c])) {
                     $fieldDefs[$field]['formula'] = str_replace($field_c, $fieldDefs[$field_c]['id'], $fieldDefs[$field]['formula']);
                 }
             }
             $temp_field = $fieldDefs[$field];
             $fieldDefs[$module . $field] = $temp_field;
             unset($fieldDefs[$field]);
         }
     }
     return $fieldDefs;
 }
开发者ID:jglaine,项目名称:sugar761-ent,代码行数:24,代码来源:TemplateHandler.php

示例3: expand_list_fields

 /**
  * Expands list fields by adding those ones which existing fields depend on.
  *
  * @param  SugarBean $bean   Instance of SugarBean which is displayed
  *                           in the subpanel
  * @param  array     $fields Definition if list fields
  *
  * @return array             Expanded definition
  */
 public function expand_list_fields(SugarBean $bean, array $fields)
 {
     $expanded = array();
     foreach (array_keys($fields) as $name) {
         if (!empty($bean->field_defs[$name]['dependency'])) {
             $expr = $bean->field_defs[$name]['dependency'];
             $extracted = Parser::getFieldsFromExpression($expr, $bean->field_defs);
             $extracted = array_flip($extracted);
             // remove fields that do not exist in field definitions
             $expanded += array_intersect_key($extracted, $bean->field_defs);
             // make the dependent field non-sortable since availability of the field
             // is calculated after the data is retrieved from database
             $fields[$name]['sortable'] = false;
         }
         // get currency symbol if this is a currency field
         if (isset($bean->field_defs[$name]['type']) && $bean->field_defs[$name]['type'] == 'currency' && !empty($bean->field_defs['currency_id'])) {
             $expanded['currency_id'] = $bean->field_defs['currency_id'];
             $fields[$name]['sortable'] = false;
         }
     }
     // ignore dependencies that already present in the list
     $expanded = array_diff_key($expanded, $fields);
     foreach (array_keys($expanded) as $name) {
         $fields[$name] = array('name' => $name, 'usage' => 'query_only');
     }
     return $fields;
 }
开发者ID:jglaine,项目名称:sugar761-ent,代码行数:36,代码来源:SubPanelDefinitions.php

示例4: getModuleDependenciesForAction

 /**
  * Returns the set of the custom SugarLogic Dependencies defined in the dependency metadata
  * for a module that are valid for the given action.
  * @static
  * @param string $module Primary module for this action
  * @param string $action name of the action to get dependencies for ("edit", "view", "save", ect)
  * @param string $form name of the form element used on html forms
  * @return array<Dependency>
  */
 public static function getModuleDependenciesForAction($module, $action, $form = "EditView")
 {
     $meta = self::getModuleDependencyMetadata($module);
     $deps = array();
     foreach ($meta as $key => $def) {
         $hooks = empty($def['hooks']) ? array("all") : $def['hooks'];
         if (!is_array($hooks)) {
             $hooks = array($hooks);
         }
         if (in_array('all', $hooks) || in_array($action, $hooks)) {
             self::filterActionDefinitionsForView($def, $action);
             if (empty($def['actions']) && empty($def['notActions'])) {
                 continue;
                 // Skip if no actions left after filtering
             }
             $triggerExp = empty($def['trigger']) ? self::$default_trigger : $def['trigger'];
             $triggerFields = empty($def['triggerFields']) ? Parser::getFieldsFromExpression($triggerExp) : $def['triggerFields'];
             $actions = empty($def['actions']) || !is_array($def['actions']) ? array() : $def['actions'];
             $notActions = empty($def['notActions']) || !is_array($def['notActions']) ? array() : $def['notActions'];
             $dep = new Dependency("{$module}{$form}_{$key}");
             $dep->setTrigger(new Trigger($triggerExp, $triggerFields));
             foreach ($actions as $aDef) {
                 $dep->addAction(ActionFactory::getNewAction($aDef['name'], $aDef['params']));
             }
             foreach ($notActions as $aDef) {
                 $dep->addFalseAction(ActionFactory::getNewAction($aDef['name'], $aDef['params']));
             }
             $dep->setFireOnLoad(!isset($def['onload']) || $def['onload'] !== false);
             $deps[] = $dep;
         }
     }
     return $deps;
 }
开发者ID:jglaine,项目名称:sugar761-ent,代码行数:42,代码来源:DependencyManager.php

示例5: replaceVariables

 /**
  * @deprecated
  * returns the expression with the variables replaced with the values in target.
  *
  * @param string $expr
  * @param Array/SugarBean $target
  */
 static function replaceVariables($expr, $target)
 {
     $target->load_relationships();
     $variables = Parser::getFieldsFromExpression($expr);
     $ret = $expr;
     foreach ($variables as $field) {
         if (is_array($target)) {
             if (isset($target[$field])) {
                 $val = Parser::getFormatedValue($target[$field], $field);
                 $ret = str_replace("\${$field}", $val, $ret);
             } else {
                 continue;
                 //throw new Exception("Unknown variable $$field in formula: $expr");
                 //return;
             }
         } else {
             //Special case for link fields
             if (isset($target->field_defs[$field]) && $target->field_defs[$field]['type'] == "link") {
                 $val = "link(\"{$field}\")";
                 $ret = str_replace("\${$field}", $val, $ret);
             } else {
                 if (isset($target->{$field})) {
                     $val = Parser::getFormatedValue($target->{$field}, $field);
                     $ret = str_replace("\${$field}", $val, $ret);
                 } else {
                     continue;
                     // throw new Exception("Unknown variable $$field in formula: $expr");
                     // return;
                 }
             }
         }
     }
     return $ret;
 }
开发者ID:jglaine,项目名称:sugar761-ent,代码行数:41,代码来源:Parser.php


注:本文中的Parser::getFieldsFromExpression方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。