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


PHP Parser::evaluate方法代码示例

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


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

示例1: evaluate

 function evaluate($target)
 {
     $result = Parser::evaluate($this->conditionFunction, $target)->evaluate();
     if ($result == AbstractExpression::$TRUE) {
         return true;
     } else {
         return false;
     }
 }
开发者ID:jglaine,项目名称:sugar761-ent,代码行数:9,代码来源:Trigger.php

示例2: fire

 /**
  * Applies the Action to the target.
  *
  * @param SugarBean $target
  */
 function fire(&$target)
 {
     require_once "include/Expressions/Expression/AbstractExpression.php";
     $result = Parser::evaluate($this->expression, $target)->evaluate();
     if ($result === AbstractExpression::$FALSE) {
         $target->field_defs[$this->targetField]['hidden'] = true;
     } else {
         $target->field_defs[$this->targetField]['hidden'] = false;
     }
 }
开发者ID:jglaine,项目名称:sugar761-ent,代码行数:15,代码来源:VisibilityAction.php

示例3: fire

 /**
  * Applies the Action to the target.
  *
  * @param SugarBean $target
  */
 function fire(&$target)
 {
     require_once 'modules/Home/quicksearchQuery.php';
     require_once 'include/QuickSearchDefaults.php';
     $json = getJSONobj();
     $userName = Parser::evaluate($this . expr, $target) . evaluate();
     $qsd = QuickSearchDefaults::getQuickSearchDefaults();
     $data = $qsd->getQSUser();
     $data['modules'] = array("Users");
     $data['conditions'][0]['value'] = $userName;
     $qs = new quicksearchQuery();
     $result = $qs->query($data);
     $resultBean = $json->decodeReal($result);
     print_r($resultBean);
 }
开发者ID:jglaine,项目名称:sugar761-ent,代码行数:20,代码来源:AssignToUserAction.php

示例4: display

 function display()
 {
     //First load the primary bean
     $focus = BeanFactory::getBean($this->tmodule, $this->id);
     $params = implode(",", json_decode(html_entity_decode($this->params)));
     $result = Parser::evaluate("{$this->function}({$params})", $focus)->evaluate();
     //If the target field isn't a date, convert it to a user formated string
     if ($result instanceof DateTime) {
         global $timedate;
         if (isset($result->isDate) && $result->isDate) {
             $result = $timedate->asUserDate($result);
         } else {
             $result = $timedate->asUser($result);
         }
     }
     echo json_encode($result);
 }
开发者ID:jglaine,项目名称:sugar761-ent,代码行数:17,代码来源:view.execfunction.php

示例5: fire

 /**
  * Applies the Action to the target.
  *
  * @param SugarBean $target
  */
 function fire(&$target)
 {
     set_error_handler('handleExpressionError', E_ERROR);
     try {
         $result = Parser::evaluate($this->expression, $target)->evaluate();
     } catch (Exception $e) {
         $GLOBALS['log']->fatal("Exception evaluating expression in SetValueAction, {$this->expression} : {$e->getMessage()}\n{$e->getTraceAsString()}");
         $result = "";
     }
     restore_error_handler();
     $field = $this->targetField;
     $def = array();
     if (!empty($target->field_defs[$field])) {
         $def = $target->field_defs[$field];
     }
     if ($result instanceof DateTime) {
         global $timedate;
         if (isset($def['type']) && ($def['type'] == "datetime" || $def['type'] == "datetimecombo")) {
             $result = DateExpression::roundTime($result);
             $target->{$field} = $timedate->asDb($result);
         } else {
             if (isset($def['type']) && $def['type'] == "date") {
                 $result = DateExpression::roundTime($result);
                 $target->{$field} = $timedate->asDbDate($result);
             } else {
                 //If the target field isn't a date, convert it to a user formated string
                 if (isset($result->isDate) && $result->isDate) {
                     $target->{$field} = $timedate->asUserDate($result);
                 } else {
                     $target->{$field} = $timedate->asUser($result);
                 }
             }
         }
     } else {
         if (isset($def['type']) && $def['type'] == "bool") {
             $target->{$field} = $result === true || $result === AbstractExpression::$TRUE;
         } else {
             if (is_array($result) && $def['type'] != 'multienum') {
                 $target->{$field} = implode(', ', $result);
             } else {
                 $target->{$field} = $result;
             }
         }
     }
 }
开发者ID:jglaine,项目名称:sugar761-ent,代码行数:50,代码来源:SetValueAction.php

示例6: fire

 /**
  * Applies the Action to the target.
  *
  * @param SugarBean $target
  *
  * Should only be fired when saving from an edit view and the expression is false.
  */
 public function fire(&$target)
 {
     $result = Parser::evaluate($this->expression, $target)->evaluate();
     if ($result === AbstractExpression::$FALSE) {
         require_once 'modules/ModuleBuilder/parsers/ParserFactory.php';
         require_once 'modules/ModuleBuilder/parsers/constants.php';
         $view = isModuleBWC($target->module_name) ? MB_EDITVIEW : MB_RECORDVIEW;
         $parser = ParserFactory::getParser($view, $target->module_dir);
         $fields = $parser->getFieldsInPanel($this->targetPanel);
         foreach ($fields as $field) {
             unset($target->{$field});
         }
     }
 }
开发者ID:jglaine,项目名称:sugar761-ent,代码行数:21,代码来源:PanelVisibilityAction.php

示例7: get_fields_influencing_linked_bean_calc_fields

 /**
  * Returns array of linked bean's calculated fields which use relation to
  * the current bean in their formulas
  *
  * @param string $linkName Name of current bean's link
  * @return array
  */
 protected function get_fields_influencing_linked_bean_calc_fields($linkName)
 {
     global $dictionary;
     $result = array();
     if (!$this->load_relationship($linkName)) {
         return $result;
     }
     /** @var Link2 $link */
     $link = $this->{$linkName};
     $relatedModuleName = $link->getRelatedModuleName();
     $relatedBeanName = BeanFactory::getObjectName($relatedModuleName);
     $relatedLinkName = $link->getRelatedModuleLinkName();
     if (empty($relatedBeanName) || empty($dictionary[$relatedBeanName])) {
         $GLOBALS['log']->fatal("Cannot load field defs for {$relatedBeanName}");
         return $result;
     }
     // iterate over related bean fields
     foreach ($dictionary[$relatedBeanName]['fields'] as $def) {
         if (!empty($def['formula'])) {
             $expr = Parser::evaluate($def['formula'], $this);
             $fields = $this->get_formula_related_fields($expr, $relatedLinkName);
             $result = array_merge($result, $fields);
         }
     }
     return array_unique($result);
 }
开发者ID:jglaine,项目名称:sugar761-ent,代码行数:33,代码来源:SugarBean.php

示例8: chdir

 * You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
 * SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
 * 
 * The interactive user interfaces in modified source and object code versions
 * of this program must display Appropriate Legal Notices, as required under
 * Section 5 of the GNU Affero General Public License version 3.
 * 
 * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
 * these Appropriate Legal Notices must retain the display of the "Powered by
 * SugarCRM" logo. If the display of the logo is not reasonably feasible for
 * technical reasons, the Appropriate Legal Notices must display the words
 * "Powered by SugarCRM".
 ********************************************************************************/
//change directories to where this file is located.
//this is to make sure it can find dce_config.php
chdir("../../");
require_once 'include/entryPoint.php';
require_once 'include/Expressions/Expression/Parser/Parser.php';
require_once 'modules/Users/User.php';
if (!empty($_REQUEST['expression'])) {
    $admin = new User();
    $admin = $admin->retrieve(1);
    global $current_user, $timezones;
    $current_user = $admin;
    try {
        $expression = Parser::evaluate(from_html($_REQUEST['expression']));
        print_r($expression->evaluate());
    } catch (Exception $e) {
        echo $e->getMessage();
    }
}
开发者ID:nickpro,项目名称:sugarcrm_dev,代码行数:31,代码来源:expression_engine_eval.php

示例9: catch

/*
 * Your installation or use of this SugarCRM file is subject to the applicable
 * terms available at
 * http://support.sugarcrm.com/06_Customer_Center/10_Master_Subscription_Agreements/.
 * If you do not agree to all of the applicable terms or do not have the
 * authority to bind the entity as an authorized representative, then do not
 * install or use this SugarCRM file.
 *
 * Copyright (C) SugarCRM Inc. All rights reserved.
 */
require_once 'Expression/Parser/Parser.php';
if (!empty($_GET['expression'])) {
    $expr = $_GET['expression'];
    try {
        echo Parser::evaluate($expr)->evaluate();
    } catch (Exception $e) {
        echo $e;
    }
    die;
}
?>



<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">

<title>SUGAR Arithmetic Engine (JS)</title>
开发者ID:jglaine,项目名称:sugar761-ent,代码行数:30,代码来源:index.php

示例10: evaluate

 /**
  * Evaluates an expression.
  *
  * @param string	the expression to evaluate
  *
  */
 static function evaluate($expr, $context = false)
 {
     // the function map
     static $FUNCTION_MAP = array();
     // trim spaces, left and right, and remove newlines
     $expr = str_replace("\n", "", trim($expr));
     // check if its a constant and return a constant expression
     $const = Parser::toConstant($expr);
     if (isset($const)) {
         return $const;
     }
     if (preg_match('/^\\$[a-zA-Z0-9_\\-]+$/', $expr)) {
         $var = substr($expr, 1);
         $ret = new SugarFieldExpression($var);
         if ($context) {
             $ret->context = $context;
         }
         return $ret;
     }
     //Related field shorthand
     if (preg_match('/^\\$[a-zA-Z0-9_\\-]+\\.[a-zA-Z0-9_\\-]+$/', $expr)) {
         $link = substr($expr, 1, strpos($expr, ".") - 1);
         $related = substr($expr, strpos($expr, ".") + 1);
         $linkField = new SugarFieldExpression($link);
         if ($context) {
             $linkField->context = $context;
         }
         return new RelatedFieldExpression(array($linkField, Parser::toConstant('"' . $related . '"')));
     }
     // VALIDATE: expression format
     if (!preg_match('/^[a-zA-Z0-9_\\-$]+\\(.*\\)$/', $expr)) {
         throw new Exception("Attempted to evaluate expression with an invalid format: {$expr}");
         return;
     }
     // EXTRACT: Function
     $open_paren_loc = strpos($expr, '(');
     // if no open-paren '(' found
     if ($open_paren_loc < 0) {
         throw new Exception("Attempted to evaluate expression with a Syntax Error (No opening paranthesis found): {$expr}");
         return;
     }
     // get the function
     $func = substr($expr, 0, $open_paren_loc);
     // handle if function is not valid
     if (empty($FUNCTION_MAP)) {
         if (!file_exists(sugar_cached('Expressions/functionmap.php'))) {
             $GLOBALS['updateSilent'] = true;
             include "include/Expressions/updatecache.php";
         }
         require_once sugar_cached('Expressions/functionmap.php');
     }
     if (!isset($FUNCTION_MAP[$func])) {
         throw new Exception("Attempted to evaluate expression with an invalid function '{$func}': {$expr}");
         return;
     }
     // EXTRACT: Parameters
     $params = substr($expr, $open_paren_loc + 1, -1);
     // now parse the individual parameters recursively
     $level = 0;
     $length = strlen($params);
     $argument = "";
     $args = array();
     // flags
     $char = null;
     $lastCharRead = null;
     $justReadString = false;
     // did i just read in a string
     $isInQuotes = false;
     // am i currently reading in a string
     $isPrevCharBK = false;
     // is my previous character a backslash
     $isInVariable = false;
     // is my previous character a backslash
     for ($i = 0; $i <= $length; $i++) {
         // store the last character read
         $lastCharRead = $char;
         // the last parameter
         if ($i == $length) {
             if ($argument != "") {
                 $subExp = Parser::evaluate($argument, $context);
                 $subExp->context = $context;
                 $args[] = $subExp;
             }
             break;
         }
         // set isprevcharbk
         $isPrevCharBK = $lastCharRead == '\\';
         // get the charAt index $i
         $char = $params[$i];
         // if i am in quotes, then keep reading
         if ($isInQuotes && $char != '"' && !$isPrevCharBK) {
             $argument .= $char;
             continue;
         }
//.........这里部分代码省略.........
开发者ID:jglaine,项目名称:sugar761-ent,代码行数:101,代码来源:Parser.php


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