本文整理汇总了PHP中CRM_Core_Smarty::fetch方法的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Core_Smarty::fetch方法的具体用法?PHP CRM_Core_Smarty::fetch怎么用?PHP CRM_Core_Smarty::fetch使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CRM_Core_Smarty
的用法示例。
在下文中一共展示了CRM_Core_Smarty::fetch方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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>';
}
示例2: run
/**
* This function takes care of all the things common to all
* pages. This typically involves assigning the appropriate smarty
* variable :)
*
* @return void|string
* The content generated by running this page
*/
public function run()
{
if ($this->_embedded) {
return NULL;
}
self::$_template->assign('mode', $this->_mode);
$pageTemplateFile = $this->getHookedTemplateFileName();
self::$_template->assign('tplFile', $pageTemplateFile);
// invoke the pagRun hook, CRM-3906
CRM_Utils_Hook::pageRun($this);
if ($this->_print) {
if (in_array($this->_print, array(CRM_Core_Smarty::PRINT_SNIPPET, CRM_Core_Smarty::PRINT_PDF, CRM_Core_Smarty::PRINT_NOFORM, CRM_Core_Smarty::PRINT_JSON))) {
$content = self::$_template->fetch('CRM/common/snippet.tpl');
} else {
$content = self::$_template->fetch('CRM/common/print.tpl');
}
CRM_Utils_System::appendTPLFile($pageTemplateFile, $content, $this->overrideExtraTemplateFileName());
//its time to call the hook.
CRM_Utils_Hook::alterContent($content, 'page', $pageTemplateFile, $this);
if ($this->_print == CRM_Core_Smarty::PRINT_PDF) {
CRM_Utils_PDF_Utils::html2pdf($content, "{$this->_name}.pdf", FALSE, array('paper_size' => 'a3', 'orientation' => 'landscape'));
} elseif ($this->_print == CRM_Core_Smarty::PRINT_JSON) {
$this->ajaxResponse['content'] = $content;
CRM_Core_Page_AJAX::returnJsonResponse($this->ajaxResponse);
} else {
echo $content;
}
CRM_Utils_System::civiExit();
}
$config = CRM_Core_Config::singleton();
// Version check and intermittent alert to admins
CRM_Utils_VersionCheck::singleton()->versionAlert();
CRM_Utils_Check::singleton()->showPeriodicAlerts();
if ($this->useLivePageJS && CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'ajaxPopupsEnabled', NULL, TRUE)) {
CRM_Core_Resources::singleton()->addScriptFile('civicrm', 'js/crm.livePage.js', 1, 'html-header');
$this->assign('includeWysiwygEditor', TRUE);
}
$content = self::$_template->fetch('CRM/common/' . strtolower($config->userFramework) . '.tpl');
// Render page header
if (!defined('CIVICRM_UF_HEAD') && ($region = CRM_Core_Region::instance('html-header', FALSE))) {
CRM_Utils_System::addHTMLHead($region->render(''));
}
CRM_Utils_System::appendTPLFile($pageTemplateFile, $content);
//its time to call the hook.
CRM_Utils_Hook::alterContent($content, 'page', $pageTemplateFile, $this);
echo CRM_Utils_System::theme($content, $this->_print);
}
示例3: run
/**
* This function takes care of all the things common to all
* pages. This typically involves assigning the appropriate
* smarty variable :)
*
* @return string The content generated by running this page
*/
function run()
{
if ($this->_embedded) {
return;
}
self::$_template->assign('mode', $this->_mode);
self::$_template->assign('tplFile', $this->getTemplateFileName());
// invoke the pagRun hook, CRM-3906
require_once 'CRM/Utils/Hook.php';
CRM_Utils_Hook::pageRun($this);
if ($this->_print) {
if ($this->_print == CRM_Core_Smarty::PRINT_SNIPPET || $this->_print == CRM_Core_Smarty::PRINT_PDF) {
$content = self::$_template->fetch('CRM/common/snippet.tpl');
} else {
$content = self::$_template->fetch('CRM/common/print.tpl');
}
if ($this->_print == CRM_Core_Smarty::PRINT_PDF) {
require_once 'CRM/Utils/PDF/Utils.php';
CRM_Utils_PDF_Utils::domlib($content, "{$this->_name}.pdf");
} else {
echo $content;
}
exit;
}
$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);
return;
}
示例4: 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);
}
示例5: run
/**
* This function takes care of all the things common to all
* pages. This typically involves assigning the appropriate
* smarty variable :)
*
* @return string The content generated by running this page
*/
function run()
{
if ($this->_embedded) {
return;
}
self::$_template->assign('mode', $this->_mode);
$pageTemplateFile = $this->getHookedTemplateFileName();
self::$_template->assign('tplFile', $pageTemplateFile);
// invoke the pagRun hook, CRM-3906
CRM_Utils_Hook::pageRun($this);
if ($this->_print) {
if (in_array($this->_print, array(CRM_Core_Smarty::PRINT_SNIPPET, CRM_Core_Smarty::PRINT_PDF, CRM_Core_Smarty::PRINT_NOFORM, CRM_Core_Smarty::PRINT_JSON))) {
$content = self::$_template->fetch('CRM/common/snippet.tpl');
} else {
$content = self::$_template->fetch('CRM/common/print.tpl');
}
CRM_Utils_System::appendTPLFile($pageTemplateFile, $content, $this->overrideExtraTemplateFileName());
//its time to call the hook.
CRM_Utils_Hook::alterContent($content, 'page', $pageTemplateFile, $this);
if ($this->_print == CRM_Core_Smarty::PRINT_PDF) {
CRM_Utils_PDF_Utils::html2pdf($content, "{$this->_name}.pdf", FALSE, array('paper_size' => 'a3', 'orientation' => 'landscape'));
} elseif ($this->_print == CRM_Core_Smarty::PRINT_JSON) {
$this->ajaxResponse['content'] = $content;
CRM_Core_Page_AJAX::returnJsonResponse($this->ajaxResponse);
} else {
echo $content;
}
CRM_Utils_System::civiExit();
}
$config = CRM_Core_Config::singleton();
// TODO: Is there a better way to ensure these actions don't happen during AJAX requests?
if (empty($_GET['snippet'])) {
// Version check and intermittent alert to admins
CRM_Utils_VersionCheck::singleton()->versionAlert();
CRM_Utils_Check_Security::singleton()->showPeriodicAlerts();
// Debug msg once per hour
if ($config->debug && CRM_Core_Permission::check('administer CiviCRM') && CRM_Core_Session::singleton()->timer('debug_alert', 3600)) {
$msg = ts('Warning: Debug is enabled in <a href="%1">system settings</a>. This should not be enabled on production servers.', array(1 => CRM_Utils_System::url('civicrm/admin/setting/debug', 'reset=1')));
CRM_Core_Session::setStatus($msg, ts('Debug Mode'));
}
}
$content = self::$_template->fetch('CRM/common/' . strtolower($config->userFramework) . '.tpl');
// Render page header
if (!defined('CIVICRM_UF_HEAD') && ($region = CRM_Core_Region::instance('html-header', FALSE))) {
CRM_Utils_System::addHTMLHead($region->render(''));
}
CRM_Utils_System::appendTPLFile($pageTemplateFile, $content);
//its time to call the hook.
CRM_Utils_Hook::alterContent($content, 'page', $pageTemplateFile, $this);
echo CRM_Utils_System::theme($content, $this->_print);
return;
}
示例6: run
/**
* This function takes care of all the things common to all
* pages. This typically involves assigning the appropriate
* smarty variable :)
*
* @return string The content generated by running this page
*/
function run()
{
if ($this->_embedded) {
return;
}
self::$_template->assign('mode', $this->_mode);
$pageTemplateFile = $this->getTemplateFileName();
self::$_template->assign('tplFile', $pageTemplateFile);
// invoke the pagRun hook, CRM-3906
CRM_Utils_Hook::pageRun($this);
if ($this->_print) {
if (in_array($this->_print, array(CRM_Core_Smarty::PRINT_SNIPPET, CRM_Core_Smarty::PRINT_PDF, CRM_Core_Smarty::PRINT_NOFORM))) {
$content = self::$_template->fetch('CRM/common/snippet.tpl');
} else {
$content = self::$_template->fetch('CRM/common/print.tpl');
}
CRM_Utils_System::appendTPLFile($pageTemplateFile, $content, $this->overrideExtraTemplateFileName());
//its time to call the hook.
CRM_Utils_Hook::alterContent($content, 'page', $pageTemplateFile, $this);
if ($this->_print == CRM_Core_Smarty::PRINT_PDF) {
CRM_Utils_PDF_Utils::html2pdf($content, "{$this->_name}.pdf", FALSE, array('paper_size' => 'a3', 'orientation' => 'landscape'));
} else {
echo $content;
}
CRM_Utils_System::civiExit();
}
$config = CRM_Core_Config::singleton();
$content = self::$_template->fetch('CRM/common/' . strtolower($config->userFramework) . '.tpl');
if ($region = CRM_Core_Region::instance('html-header', FALSE)) {
CRM_Utils_System::addHTMLHead($region->render(''));
}
CRM_Utils_System::appendTPLFile($pageTemplateFile, $content);
//its time to call the hook.
CRM_Utils_Hook::alterContent($content, 'page', $pageTemplateFile, $this);
echo CRM_Utils_System::theme('page', $content, TRUE, $this->_print);
return;
}