本文整理汇总了PHP中CRM_Core_Smarty类的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Core_Smarty类的具体用法?PHP CRM_Core_Smarty怎么用?PHP CRM_Core_Smarty使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了CRM_Core_Smarty类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: run
function run()
{
// Add our template
CRM_Core_Smarty::singleton()->assign('isModulePermissionSupported', CRM_Core_Config::singleton()->userPermissionClass->isModulePermissionSupported());
CRM_Core_Region::instance('page-header')->add(array('template' => 'CRM/Volunteer/Form/Manage.tpl'));
parent::run();
}
示例2: 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;
}
示例3: 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 '';
}
示例4: smarty_block_ts
/**
* Smarty block function providing gettext support
*
* See CRM_Core_I18n class documentation for details.
*
* @param array $params
* Template call's parameters.
* @param string $text
* {ts} block contents from the template.
* @param CRM_Core_Smarty $smarty
* The Smarty object.
*
* @return string
* the string, translated by gettext
*/
function smarty_block_ts($params, $text, &$smarty)
{
if (!isset($params['domain'])) {
$params['domain'] = $smarty->get_template_vars('extensionKey');
}
return ts($text, $params);
}
示例5: 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;
}
}
示例6: smarty_block_crmScope
/**
* Smarty block function to temporarily define variables.
*
* Example:
*
* @code
* {tsScope x=1}
* Expect {$x}==1
* {tsScope x=2}
* Expect {$x}==2
* {/tsScope}
* Expect {$x}==1
* {/tsScope}
* @endcode
*
* @param array $params
* Must define 'name'.
* @param string $content
* Default content.
* @param CRM_Core_Smarty $smarty
* The Smarty object.
*
* @param $repeat
*
* @return string
*/
function smarty_block_crmScope($params, $content, &$smarty, &$repeat)
{
/** @var CRM_Core_Smarty $smarty */
if ($repeat) {
// open crmScope
$smarty->pushScope($params);
} else {
// close crmScope
$smarty->popScope();
}
return $content;
}
示例7: addResources
/**
* Load needed JS, CSS and settings for the backend Volunteer Management UI
*/
public static function addResources($entity_id, $entity_table)
{
static $loaded = FALSE;
if ($loaded) {
return;
}
$loaded = TRUE;
$config = CRM_Core_Config::singleton();
$ccr = CRM_Core_Resources::singleton();
// Vendor libraries
$ccr->addScriptFile('civicrm', 'packages/backbone/json2.js', 100, 'html-header', FALSE);
$ccr->addScriptFile('civicrm', 'packages/backbone/backbone-min.js', 120, 'html-header');
$ccr->addScriptFile('civicrm', 'packages/backbone/backbone.marionette.min.js', 125, 'html-header', FALSE);
// Our stylesheet
$ccr->addStyleFile('org.civicrm.volunteer', 'css/volunteer_app.css');
// Add all scripts for our js app
$weight = 0;
$baseDir = CRM_Extension_System::singleton()->getMapper()->keyToBasePath('org.civicrm.volunteer') . '/';
// This glob pattern will recurse the js directory up to 4 levels deep
foreach (glob($baseDir . 'js/{*,*/*,*/*/*,*/*/*/*}.js', GLOB_BRACE) as $file) {
$fileName = substr($file, strlen($baseDir));
$ccr->addScriptFile('org.civicrm.volunteer', $fileName, $weight++);
}
// Add our template
CRM_Core_Smarty::singleton()->assign('isModulePermissionSupported', CRM_Core_Config::singleton()->userPermissionClass->isModulePermissionSupported());
CRM_Core_Region::instance('page-header')->add(array('template' => 'CRM/Volunteer/Form/Manage.tpl'));
// Fetch event so we can set the default start time for needs
// FIXME: Not the greatest for supporting non-events
$entity = civicrm_api3(str_replace('civicrm_', '', $entity_table), 'getsingle', array('id' => $entity_id));
// Static variables
$ccr->addSetting(array('pseudoConstant' => array('volunteer_need_visibility' => array_flip(CRM_Volunteer_BAO_Need::buildOptions('visibility_id', 'validate')), 'volunteer_role' => CRM_Volunteer_BAO_Need::buildOptions('role_id', 'get'), 'volunteer_status' => CRM_Activity_BAO_Activity::buildOptions('status_id', 'validate')), 'volunteer' => array('default_date' => CRM_Utils_Array::value('start_date', $entity)), 'config' => array('timeInputFormat' => $config->timeInputFormat)));
// Check for problems
_volunteer_civicrm_check_resource_url();
}
示例8: run
function run()
{
$upgrade = new CRM_Upgrade_Form();
$message = ts('CiviCRM upgrade successful');
if ($upgrade->checkVersion($upgrade->latestVersion)) {
$message = ts('Your database has already been upgraded to CiviCRM %1', array(1 => $upgrade->latestVersion));
} elseif ($upgrade->checkVersion('2.1.2') || $upgrade->checkVersion('2.1.3') || $upgrade->checkVersion('2.1.4') || $upgrade->checkVersion('2.1.5')) {
// do nothing, db version is changed for all upgrades
} elseif ($upgrade->checkVersion('2.1.0') || $upgrade->checkVersion('2.1') || $upgrade->checkVersion('2.1.1')) {
// 2.1 to 2.1.2
$this->runTwoOneTwo();
} else {
// 2.0 to 2.1
for ($i = 1; $i <= 4; $i++) {
$this->runForm($i);
}
// 2.1 to 2.1.2
$this->runTwoOneTwo();
}
// just change the ver in the db, since nothing to upgrade
$upgrade->setVersion($upgrade->latestVersion);
// also cleanup the templates_c directory
$config = CRM_Core_Config::singleton();
$config->cleanup(1);
$template = CRM_Core_Smarty::singleton();
$template->assign('message', $message);
$template->assign('pageTitle', ts('Upgrade CiviCRM to Version %1', array(1 => $upgrade->latestVersion)));
$template->assign('menuRebuildURL', CRM_Utils_System::url('civicrm/menu/rebuild', 'reset=1'));
$contents = $template->fetch('CRM/common/success.tpl');
echo $contents;
}
示例9: run
function run()
{
list($ext, $suite) = $this->getRequestExtAndSuite();
if (empty($ext) || empty($suite)) {
throw new CRM_Core_Exception("FIXME: Not implemented: QUnit browser");
}
if (!preg_match('/^[a-zA-Z0-9_\\-\\.]+$/', $suite) || strpos($suite, '..') !== FALSE) {
throw new CRM_Core_Exception("Malformed suite name");
}
$path = CRM_Extension_System::singleton()->getMapper()->keyToBasePath($ext);
if (!is_dir("{$path}/tests/qunit/{$suite}")) {
throw new CRM_Core_Exception("Failed to locate test suite");
}
// Load the test suite -- including any PHP, TPL, or JS content
if (file_exists("{$path}/tests/qunit/{$suite}/test.php")) {
// e.g. load resources
require_once "{$path}/tests/qunit/{$suite}/test.php";
}
if (file_exists("{$path}/tests/qunit/{$suite}/test.tpl")) {
// e.g. setup markup and/or load resources
CRM_Core_Smarty::singleton()->addTemplateDir("{$path}/tests");
$this->assign('qunitTpl', "qunit/{$suite}/test.tpl");
}
if (file_exists("{$path}/tests/qunit/{$suite}/test.js")) {
CRM_Core_Resources::singleton()->addScriptFile($ext, "tests/qunit/{$suite}/test.js", 1000);
}
CRM_Utils_System::setTitle(ts('QUnit: %2 (%1)', array(1 => $ext, 2 => $suite)));
CRM_Core_Resources::singleton()->addScriptFile('civicrm', 'packages/qunit/qunit.js')->addStyleFile('civicrm', 'packages/qunit/qunit.css');
parent::run();
}
示例10: run
function run() {
$smarty= CRM_Core_Smarty::singleton( );
$dummy = NULL;
if (array_key_exists('id',$_GET)) {// special treatmenent, because it's often used
$smarty->assign ('id',(int)$_GET['id']);// an id is always positive
}
$pos = strpos (implode (array_keys ($_GET)),'<') ;
if ($pos !== false) {
die ("SECURITY FATAL: one of the param names contains <");
}
$param = array_map( 'htmlentities' , $_GET);
//TODO: sql escape the params too
unset($param['q']);
$smarty->assign_by_ref("request", $param);
CRM_Core_Resources::singleton()
->addScriptFile('eu.tttp.civisualize', 'js/d3.v3.js', 110, 'html-header', FALSE)
->addScriptFile('eu.tttp.civisualize', 'js/dc/dc.js', 110, 'html-header', FALSE)
->addScriptFile('eu.tttp.civisualize', 'js/dc/crossfilter.js', 110, 'html-header', FALSE)
->addStyleFile('eu.tttp.civisualize', 'js/dc/dc.css')
->addStyleFile('eu.tttp.civisualize', 'css/style.css');
require_once 'CRM/Core/Smarty/plugins/function.crmSQL.php';
$smarty->register_function("crmSQL", "smarty_function_crmSQL");
require_once 'CRM/Core/Smarty/plugins/function.crmRetrieve.php';
$smarty->register_function("crmRetrieve", "smarty_function_crmRetrieve");
require_once 'CRM/Core/Smarty/plugins/function.crmTitle.php';
$smarty->register_function("crmTitle", "smarty_function_crmTitle");
return parent::run();
}
示例11: buildChart
/**
* colours.
* @var array
* @static
*/
function buildChart(&$params, $chart)
{
$openFlashChart = array();
if ($chart && is_array($params) && !empty($params)) {
$chartInstance = new $chart($params);
$chartInstance->buildChart();
$chartObj = $chartInstance->getChart();
$openFlashChart = array();
if ($chartObj) {
// calculate chart size.
$xSize = CRM_Utils_Array::value('xSize', $params, 400);
$ySize = CRM_Utils_Array::value('ySize', $params, 300);
if ($chart == 'barChart') {
$ySize = CRM_Utils_Array::value('ySize', $params, 250);
$xSize = 60 * count($params['values']);
//hack to show tooltip.
if ($xSize < 200) {
$xSize = count($params['values']) > 1 ? 100 * count($params['values']) : 170;
} elseif ($xSize > 600 && count($params['values']) > 1) {
$xSize = (count($params['values']) + 400 / count($params['values'])) * count($params['values']);
}
}
// generate unique id for this chart instance
$uniqueId = md5(uniqid(rand(), TRUE));
$openFlashChart["chart_{$uniqueId}"]['size'] = array('xSize' => $xSize, 'ySize' => $ySize);
$openFlashChart["chart_{$uniqueId}"]['object'] = $chartObj;
// assign chart data to template
$template = CRM_Core_Smarty::singleton();
$template->assign('uniqueId', $uniqueId);
$template->assign("openFlashChartData", json_encode($openFlashChart));
}
}
return $openFlashChart;
}
开发者ID:eileenmcnaughton,项目名称:net.ourpowerbase.report.advancedfundraising,代码行数:39,代码来源:OpenFlashChart.php
示例12: addResources
/**
* Load needed JS, CSS and settings for the backend Volunteer Management UI
*/
public static function addResources($entity_id, $entity_table)
{
static $loaded = FALSE;
$ccr = CRM_Core_Resources::singleton();
if ($loaded || $ccr->isAjaxMode()) {
return;
}
$loaded = TRUE;
$config = CRM_Core_Config::singleton();
// Vendor libraries
$ccr->addScriptFile('civicrm', 'packages/backbone/json2.js', 100, 'html-header', FALSE);
$ccr->addScriptFile('civicrm', 'packages/backbone/backbone-min.js', 120, 'html-header', FALSE);
$ccr->addScriptFile('civicrm', 'packages/backbone/backbone.marionette.min.js', 125, 'html-header', FALSE);
// Our stylesheet
$ccr->addStyleFile('org.civicrm.volunteer', 'css/volunteer_app.css');
// Add all scripts for our js app
$weight = 0;
$baseDir = CRM_Extension_System::singleton()->getMapper()->keyToBasePath('org.civicrm.volunteer') . '/';
// This glob pattern will recurse the js directory up to 4 levels deep
foreach (glob($baseDir . 'js/backbone/{*,*/*,*/*/*,*/*/*/*}.js', GLOB_BRACE) as $file) {
$fileName = substr($file, strlen($baseDir));
$ccr->addScriptFile('org.civicrm.volunteer', $fileName, $weight++);
}
// Add our template
CRM_Core_Smarty::singleton()->assign('isModulePermissionSupported', CRM_Core_Config::singleton()->userPermissionClass->isModulePermissionSupported());
CRM_Core_Region::instance('page-header')->add(array('template' => 'CRM/Volunteer/Form/Manage.tpl'));
// Fetch event so we can set the default start time for needs
// FIXME: Not the greatest for supporting non-events
$entity = civicrm_api3(str_replace('civicrm_', '', $entity_table), 'getsingle', array('id' => $entity_id));
// Static variables
$ccr->addSetting(array('pseudoConstant' => array('volunteer_need_visibility' => array_flip(CRM_Volunteer_BAO_Need::buildOptions('visibility_id', 'validate')), 'volunteer_role' => CRM_Volunteer_BAO_Need::buildOptions('role_id', 'get'), 'volunteer_status' => CRM_Activity_BAO_Activity::buildOptions('status_id', 'validate')), 'volunteer' => array('default_date' => CRM_Utils_Array::value('start_date', $entity)), 'config' => array('timeInputFormat' => $config->timeInputFormat), 'constants' => array('CRM_Core_Action' => array('NONE' => 0, 'ADD' => 1, 'UPDATE' => 2, 'VIEW' => 4, 'DELETE' => 8, 'BROWSE' => 16, 'ENABLE' => 32, 'DISABLE' => 64, 'EXPORT' => 128, 'BASIC' => 256, 'ADVANCED' => 512, 'PREVIEW' => 1024, 'FOLLOWUP' => 2048, 'MAP' => 4096, 'PROFILE' => 8192, 'COPY' => 16384, 'RENEW' => 32768, 'DETACH' => 65536, 'REVERT' => 131072, 'CLOSE' => 262144, 'REOPEN' => 524288, 'MAX_ACTION' => 1048575))));
// Check for problems
_volunteer_checkResourceUrl();
}
示例13: civicrm_api3_job_rapportagenamailings_mail
/**
* Send a email to ?? with the mailing report of one mailing
*
* @param type $mailing_id
*/
function civicrm_api3_job_rapportagenamailings_mail($mailing_id)
{
global $base_root;
// create a new Cor Page
$page = new CRM_Core_Page();
$page->_mailing_id = $mailing_id;
// create a new template
$template = CRM_Core_Smarty::singleton();
// from CRM/Mailing/Page/Report.php
// check that the user has permission to access mailing id
CRM_Mailing_BAO_Mailing::checkPermission($mailing_id);
$report = CRM_Mailing_BAO_Mailing::report($mailing_id);
//get contents of mailing
CRM_Mailing_BAO_Mailing::getMailingContent($report, $page);
$subject = ts('Mailing Gereed: %1', array(1 => $report['mailing']['name']));
$template->assign('report', $report);
// inlcude $base_root
$template->assign('base_root', $base_root);
$template->assign('subject', $subject);
// from CRM/Core/page.php
// only print
$template->assign('tplFile', 'CRM/Rapportagenamailings/Page/RapportMailing.tpl');
$content = $template->fetch('CRM/common/print.tpl');
CRM_Utils_System::appendTPLFile('CRM/Rapportagenamailings/Page/RapportMailing.tpl', $content, $page->overrideExtraTemplateFileName());
//its time to call the hook.
CRM_Utils_Hook::alterContent($content, 'page', 'CRM/Rapportagenamailings/Page/RapportMailing.tpl', $page);
//echo $content;
// send mail
$params = array('from' => 'frontoffice@vnv.nl', 'toName' => 'Front Office VnV', 'toEmail' => 'frontoffice@vnv.nl', 'subject' => $subject, 'text' => $subject, 'html' => $content, 'replyTo' => 'frontoffice@vnv.nl');
CRM_Utils_Mail::send($params);
}
示例14: upgrade_4_1_alpha1
/**
* @param $rev
*/
public function upgrade_4_1_alpha1($rev)
{
$config = CRM_Core_Config::singleton();
if (in_array('CiviCase', $config->enableComponents)) {
if (!CRM_Case_BAO_Case::createCaseViews()) {
$template = CRM_Core_Smarty::singleton();
$afterUpgradeMessage = '';
if ($afterUpgradeMessage = $template->get_template_vars('afterUpgradeMessage')) {
$afterUpgradeMessage .= "<br/><br/>";
}
$afterUpgradeMessage .= '<div class="crm-upgrade-case-views-error" style="background-color: #E43D2B; padding: 10px;">' . ts("There was a problem creating CiviCase database views. Please create the following views manually before using CiviCase:");
$afterUpgradeMessage .= '<div class="crm-upgrade-case-views-query"><div>' . CRM_Case_BAO_Case::createCaseViewsQuery('upcoming') . '</div><div>' . CRM_Case_BAO_Case::createCaseViewsQuery('recent') . '</div>' . '</div></div>';
$template->assign('afterUpgradeMessage', $afterUpgradeMessage);
}
}
$upgrade = new CRM_Upgrade_Form();
$upgrade->processSQL($rev);
$this->transferPreferencesToSettings();
$this->createNewSettings();
// now modify the config so that the directories are now stored in the settings table
// CRM-8780
$params = array();
CRM_Core_BAO_ConfigSetting::add($params);
// also reset navigation
CRM_Core_BAO_Navigation::resetNavigation();
}
示例15: generatexml
function generatexml($id)
{
$xml = "";
$template = CRM_Core_Smarty::singleton();
$this->get((int) $id);
$template->assign("file", $this->toArray());
$txgroup = new CRM_Sepa_BAO_SEPATransactionGroup();
$txgroup->sdd_file_id = $this->id;
$txgroup->find();
$total = 0;
$nbtransactions = 0;
$fileFormats = array();
while ($txgroup->fetch()) {
$xml .= $txgroup->generateXML();
$total += $txgroup->total;
$nbtransactions += $txgroup->nbtransactions;
$fileFormats[] = $txgroup->fileFormat;
}
if (count(array_unique($fileFormats)) > 1) {
throw new Exception('Creditors with mismatching File Formats cannot be mixed in same File');
} else {
$fileFormatName = CRM_Utils_SepaOptionGroupTools::sanitizeFileFormat(reset($fileFormats));
}
$template->assign("file", $this->toArray());
$template->assign("total", $total);
$template->assign("nbtransactions", $nbtransactions);
$head = $template->fetch('../formats/' . $fileFormatName . '/transaction-header.tpl');
$footer = $template->fetch('../formats/' . $fileFormatName . '/transaction-footer.tpl');
return $head . $xml . $footer;
}