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


PHP CRM_Core_Smarty::assign方法代码示例

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


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

示例1: smarty_function_isValueChange

/**
 * Smarty function for checking change in a property's value, for example
 * when looping through an array.
 *
 * Smarty param:  string $key     unique identifier for this property (REQUIRED)
 * Smarty param:  mixed  $value   the current value of the property
 * Smarty param:  string $assign  name of template variable to which to assign result
 *
 *
 * @param array $params
 *   Template call's parameters.
 * @param CRM_Core_Smarty $smarty
 *   The Smarty object.
 *
 * @return NULL
 */
function smarty_function_isValueChange($params, &$smarty)
{
    static $values = array();
    if (empty($params['key'])) {
        $smarty->trigger_error("Missing required parameter, 'key', in isValueChange plugin.");
        return NULL;
    }
    $is_changed = FALSE;
    if (!array_key_exists($params['key'], $values) || strcasecmp($params['value'], $values[$params['key']]) !== 0) {
        // if we have a new value
        $is_changed = TRUE;
        $values[$params['key']] = $params['value'];
        // clear values on all properties added below/after this property
        $clear = FALSE;
        foreach ($values as $k => $dontcare) {
            if ($clear) {
                unset($values[$k]);
            } elseif ($params['key'] == $k) {
                $clear = TRUE;
            }
        }
    }
    if ($params['assign']) {
        $smarty->assign($params['assign'], $is_changed);
    }
    return NULL;
}
开发者ID:kcristiano,项目名称:civicrm-core,代码行数:43,代码来源:function.isValueChange.php

示例2: smarty_function_simpleActivityContacts

/**
 * Get details for the target and assignee contact of an activity.
 *
 * This is "simple" in that it is only appropriate for activities in which the business-process
 * guarantees that there is only one target and one assignee. If the business-process permits
 * multiple targets or multiple assignees, then consider the more versatile (but less sugary)
 * function "crmAPI".
 *
 * Note: This will perform like a dog, but who cares -- at most, we deal with O(100) iterations
 * as part of a background task.
 *
 * @param array $params
 *   , Array with keys:
 *   - activity_id: int, required
 *   - target_var: string, optional; name of a variable which will store the first/only target contact; default "target"
 *   - assignee_var: string, optional; name of a variable which will store the first/only assignee contact; default "assignee"
 *   - return: string, optional; comma-separated list of fields to return for each contact
 *
 * @param CRM_Core_Smarty $smarty
 *
 * @return string
 */
function smarty_function_simpleActivityContacts($params, &$smarty)
{
    if (empty($params['activity_id'])) {
        $smarty->trigger_error('assign: missing \'activity_id\' parameter');
    }
    if (!isset($params['target_var'])) {
        $params['target_var'] = 'target';
    }
    if (!isset($params['assignee_var'])) {
        $params['assignee_var'] = 'assignee';
    }
    if (!isset($params['return'])) {
        $params['return'] = 'contact_id,contact_type,display_name,sort_name,first_name,last_name';
    }
    require_once 'api/api.php';
    require_once 'api/v3/utils.php';
    $activity = civicrm_api('activity', 'getsingle', array('version' => 3, 'id' => $params['activity_id'], 'return.target_contact_id' => 1, 'return.assignee_contact_id' => 1));
    $baseContactParams = array('version' => 3);
    foreach (explode(',', $params['return']) as $field) {
        $baseContactParams['return.' . $field] = 1;
    }
    foreach (array('target', 'assignee') as $role) {
        $contact = array();
        if (!empty($activity[$role . '_contact_id'])) {
            $contact_id = array_shift($activity[$role . '_contact_id']);
            $contact = civicrm_api('contact', 'getsingle', $baseContactParams + array('contact_id' => $contact_id));
        }
        $smarty->assign($params[$role . '_var'], $contact);
    }
    return '';
}
开发者ID:FundingWorks,项目名称:civicrm-core,代码行数:53,代码来源:function.simpleActivityContacts.php

示例3: smarty_function_help

/**
 * Adds inline help
 *
 * @param array $params
 *   The function params.
 * @param CRM_Core_Smarty $smarty
 *   Reference to the smarty object.
 *
 * @return string
 *   the help html to be inserted
 */
function smarty_function_help($params, &$smarty)
{
    if (!isset($params['id']) || !isset($smarty->_tpl_vars['config'])) {
        return NULL;
    }
    if (empty($params['file']) && isset($smarty->_tpl_vars['tplFile'])) {
        $params['file'] = $smarty->_tpl_vars['tplFile'];
    } elseif (empty($params['file'])) {
        return NULL;
    }
    $params['file'] = str_replace(array('.tpl', '.hlp'), '', $params['file']);
    if (empty($params['title'])) {
        $vars = $smarty->get_template_vars();
        $smarty->assign('id', $params['id'] . '-title');
        $name = trim($smarty->fetch($params['file'] . '.hlp'));
        $additionalTPLFile = $params['file'] . '.extra.hlp';
        if ($smarty->template_exists($additionalTPLFile)) {
            $name .= trim($smarty->fetch($additionalTPLFile));
        }
        // Ensure we didn't change any existing vars CRM-11900
        foreach ($vars as $key => $value) {
            if ($smarty->get_template_vars($key) !== $value) {
                $smarty->assign($key, $value);
            }
        }
    } else {
        $name = trim(strip_tags($params['title']));
    }
    $class = "helpicon";
    if (!empty($params['class'])) {
        $class .= " {$params['class']}";
    }
    // Escape for html
    $title = htmlspecialchars(ts('%1 Help', array(1 => $name)));
    // Escape for html and js
    $name = htmlspecialchars(json_encode($name), ENT_QUOTES);
    // Format params to survive being passed through json & the url
    unset($params['text'], $params['title']);
    foreach ($params as &$param) {
        $param = is_bool($param) || is_numeric($param) ? (int) $param : (string) $param;
    }
    return '<a class="' . $class . '" title="' . $title . '" href="#" onclick=\'CRM.help(' . $name . ', ' . json_encode($params) . '); return false;\'>&nbsp;</a>';
}
开发者ID:hyebahi,项目名称:civicrm-core,代码行数:54,代码来源:function.help.php

示例4: smarty_function_crmGetAttribute

/**
 * Fetch an attribute from html
 *
 * @param array $params
 * @param CRM_Core_Smarty $smarty
 *
 * @return string
 */
function smarty_function_crmGetAttribute($params, &$smarty)
{
    $ret = '';
    if (preg_match('#\\W' . $params['attr'] . '="([^"]+)#', $params['html'], $matches)) {
        $ret = $matches[1];
    }
    if (!empty($params['assign'])) {
        $smarty->assign($params['assign'], $ret);
    } else {
        return $ret;
    }
}
开发者ID:kidaa30,项目名称:yes,代码行数:20,代码来源:function.crmGetAttribute.php

示例5: assign

 /**
  * @param $var
  * @param null $value
  */
 public function assign($var, $value = NULL)
 {
     self::$_template->assign($var, $value);
 }
开发者ID:kidaa30,项目名称:yes,代码行数:8,代码来源:ExportFormat.php

示例6: assign

 /**
  * assign value to name in template
  *
  * @param array|string $name  name  of variable
  * @param mixed $value value of varaible
  *
  * @return void
  * @access public
  */
 function assign($var, $value = null)
 {
     self::$_template->assign($var, $value);
 }
开发者ID:ksecor,项目名称:civicrm,代码行数:13,代码来源:Controller.php

示例7: profileDisplay

 /**
  * Assign uf fields to template.
  *
  * @param int $gid
  *   Group id.
  * @param array $values
  * @param CRM_Core_Smarty $template
  */
 public function profileDisplay($gid, $values, $template)
 {
     $groupTitle = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_UFGroup', $gid, 'title');
     $template->assign('grouptitle', $groupTitle);
     if (count($values)) {
         $template->assign('values', $values);
     }
 }
开发者ID:rollox,项目名称:civicrm-core,代码行数:16,代码来源:UFGroup.php

示例8: statusCheck

 /**
  * Show status in the footer
  *
  * @param CRM_Core_Smarty $template
  */
 public static function statusCheck($template)
 {
     if (CRM_Core_Config::isUpgradeMode()) {
         return;
     }
     $statusSeverity = 0;
     $statusMessage = ts('System status OK');
     // TODO: get status from CRM_Utils_Check, if cached
     $template->assign('footer_status_severity', $statusSeverity);
     $template->assign('footer_status_message', $statusMessage);
 }
开发者ID:rameshrr99,项目名称:civicrm-core,代码行数:16,代码来源:Invoke.php

示例9: moveFromSessionToTemplate

 /**
  * Move the variables from the session to the template
  *
  * @return void
  * @access public
  */
 function moveFromSessionToTemplate()
 {
     self::$_template->assign_by_ref("{$this->_prefix}pager", $this->_pager);
     $rows = $this->_store->get("{$this->_prefix}rows");
     if ($rows) {
         if ($this->_dynamicAction) {
             $this->_object->addActions($rows);
         }
         self::$_template->assign("{$this->_prefix}aToZ", $this->_store->get("{$this->_prefix}AToZBar"));
     }
     self::$_template->assign_by_ref("{$this->_prefix}sort", $this->_sort);
     self::$_template->assign("{$this->_prefix}columnHeaders", $this->_store->get("{$this->_prefix}columnHeaders"));
     self::$_template->assign("{$this->_prefix}rows", $rows);
     self::$_template->assign("{$this->_prefix}rowsEmpty", $this->_store->get("{$this->_prefix}rowsEmpty"));
     self::$_template->assign("{$this->_prefix}qill", $this->_store->get("{$this->_prefix}qill"));
     self::$_template->assign("{$this->_prefix}summary", $this->_store->get("{$this->_prefix}summary"));
     if ($this->_embedded) {
         return;
     }
     self::$_template->assign('tplFile', $this->_object->getTemplateFileName());
     if ($this->_print) {
         $content = self::$_template->fetch('CRM/common/print.tpl');
     } else {
         $config = CRM_Core_Config::singleton();
         $content = self::$_template->fetch('CRM/common/' . strtolower($config->userFramework) . '.tpl');
     }
     echo CRM_Utils_System::theme('page', $content, TRUE, $this->_print);
 }
开发者ID:peteainsworth,项目名称:civicrm-4.2.9-drupal,代码行数:34,代码来源:Controller.php

示例10: statusCheck

 /**
  * Show status in the footer (admin only)
  *
  * @param CRM_Core_Smarty $template
  */
 public static function statusCheck($template)
 {
     if (CRM_Core_Config::isUpgradeMode() || !CRM_Core_Permission::check('administer CiviCRM')) {
         return;
     }
     // always use cached results - they will be refreshed by the session timer
     $status = Civi::settings()->get('systemStatusCheckResult');
     $template->assign('footer_status_severity', $status);
     $template->assign('footer_status_message', CRM_Utils_Check::toStatusLabel($status));
 }
开发者ID:nielosz,项目名称:civicrm-core,代码行数:15,代码来源:Invoke.php

示例11: versionCheck

 /**
  * Show the message about CiviCRM versions.
  *
  * @param CRM_Core_Smarty $template
  */
 public static function versionCheck($template)
 {
     if (CRM_Core_Config::isUpgradeMode()) {
         return;
     }
     $newerVersion = $securityUpdate = NULL;
     if (CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'versionAlert', NULL, 1) & 1) {
         $newerVersion = CRM_Utils_VersionCheck::singleton()->isNewerVersionAvailable();
     }
     if (CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'securityUpdateAlert', NULL, 3) & 1) {
         $securityUpdate = CRM_Utils_VersionCheck::singleton()->isSecurityUpdateAvailable();
     }
     $template->assign('newer_civicrm_version', $newerVersion);
     $template->assign('security_update', $securityUpdate);
 }
开发者ID:kidaa30,项目名称:yes,代码行数:20,代码来源:Invoke.php

示例12: statusCheck

 /**
  * Show status in the footer
  *
  * @param CRM_Core_Smarty $template
  */
 public static function statusCheck($template)
 {
     if (CRM_Core_Config::isUpgradeMode()) {
         return;
     }
     //  check date of last cache and compare to today's date
     $systemCheckDate = Civi::cache()->get('systemCheckDate');
     if ($systemCheckDate > strtotime("one day ago")) {
         $statusSeverity = Civi::cache()->get('systemCheckSeverity');
     }
     //  calls helper function in CRM_Utils_Check
     if (empty($statusSeverity)) {
         $statusSeverity = CRM_Utils_Check::checkAll(TRUE);
     }
     switch ($statusSeverity) {
         case 7:
             $statusMessage = ts('System Status: Emergency');
             break;
         case 6:
             $statusMessage = ts('System Status: Alert');
             break;
         case 5:
             $statusMessage = ts('System Status: Critical');
             break;
         case 4:
             $statusMessage = ts('System Status: Error');
             break;
         case 3:
             $statusMessage = ts('System Status: Warning');
             break;
         case 2:
             $statusMessage = ts('System Status: Notice');
             break;
         default:
             $statusMessage = ts('System Status: Ok');
     }
     // TODO: get status from CRM_Utils_Check, if cached
     $template->assign('footer_status_severity', $statusSeverity);
     $template->assign('footer_status_message', $statusMessage);
 }
开发者ID:nyimbi,项目名称:civicrm-core,代码行数:45,代码来源:Invoke.php


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