本文整理汇总了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;
}
示例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 '';
}
示例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;\'> </a>';
}
示例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;
}
}
示例5: assign
/**
* @param $var
* @param null $value
*/
public function assign($var, $value = NULL)
{
self::$_template->assign($var, $value);
}
示例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);
}
示例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);
}
}
示例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);
}
示例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);
}
示例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));
}
示例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);
}
示例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);
}