/** * if we are using a theming system, invoke theme, else just print the * content * * @param string $content the content that will be themed * @param boolean $print are we displaying to the screen or bypassing theming? * @param boolean $maintenance for maintenance mode * * @return void prints content on stdout * @access public */ function theme(&$content, $print = FALSE, $maintenance = FALSE) { $ret = FALSE; // TODO: Split up; this was copied verbatim from CiviCRM 4.0's multi-UF theming function // but the parts should be copied into cleaner subclass implementations $config = CRM_Core_Config::singleton(); if ($config->userSystem->is_drupal && function_exists('theme') && !$print) { if ($maintenance) { drupal_set_breadcrumb(''); drupal_maintenance_theme(); if ($region = CRM_Core_Region::instance('html-header', FALSE)) { CRM_Utils_System::addHTMLHead($region->render('')); } print theme('maintenance_page', array('content' => $content)); exit; } $ret = TRUE; // TODO: Figure out why D7 returns but everyone else prints } $out = $content; $config =& CRM_Core_Config::singleton(); if (!$print && $config->userFramework == 'WordPress') { if (is_admin()) { require_once ABSPATH . 'wp-admin/admin-header.php'; } else { // FIX ME: we need to figure out to replace civicrm content on the frontend pages } } if ($ret) { return $out; } else { print $out; } }
public function buildQuickForm() { CRM_Utils_System::addHTMLHead('<META NAME="ROBOTS" CONTENT="NOINDEX, NOFOLLOW">'); CRM_Utils_System::setTitle(ts('Please Confirm Your Opt Out')); $this->add('text', 'email_confirm', ts('Verify email address to opt out:')); $this->addRule('email_confirm', ts('Email address is required to opt out.'), 'required'); $buttons = array(array('type' => 'next', 'name' => 'Opt Out', 'isDefault' => TRUE), array('type' => 'cancel', 'name' => ts('Cancel'))); $this->addButtons($buttons); }
/** * @return string * @throws Exception */ public function run() { CRM_Utils_System::addHTMLHead('<META NAME="ROBOTS" CONTENT="NOINDEX, NOFOLLOW">'); $contact_id = CRM_Utils_Request::retrieve('cid', 'Integer', CRM_Core_DAO::$_nullObject); $subscribe_id = CRM_Utils_Request::retrieve('sid', 'Integer', CRM_Core_DAO::$_nullObject); $hash = CRM_Utils_Request::retrieve('h', 'String', CRM_Core_DAO::$_nullObject); $activity_id = CRM_Utils_Request::retrieve('a', 'String', CRM_Core_DAO::$_nullObject); $petition_id = CRM_Utils_Request::retrieve('pid', 'String', CRM_Core_DAO::$_nullObject); if (!$petition_id) { $petition_id = CRM_Utils_Request::retrieve('p', 'String', CRM_Core_DAO::$_nullObject); } if (!$contact_id || !$subscribe_id || !$hash) { CRM_Core_Error::fatal(ts("Missing input parameters")); } $result = $this->confirm($contact_id, $subscribe_id, $hash, $activity_id, $petition_id); if ($result === FALSE) { $this->assign('success', $result); } else { $this->assign('success', TRUE); // $this->assign( 'group' , $result ); } list($displayName, $email) = CRM_Contact_BAO_Contact_Location::getEmailDetails($contact_id); $this->assign('display_name', $displayName); $this->assign('email', $email); $this->assign('petition_id', $petition_id); $this->assign('survey_id', $petition_id); $pparams['id'] = $petition_id; $this->petition = array(); CRM_Campaign_BAO_Survey::retrieve($pparams, $this->petition); $this->assign('is_share', CRM_Utils_Array::value('is_share', $this->petition)); $this->assign('thankyou_title', CRM_Utils_Array::value('thankyou_title', $this->petition)); $this->assign('thankyou_text', CRM_Utils_Array::value('thankyou_text', $this->petition)); CRM_Utils_System::setTitle(CRM_Utils_Array::value('thankyou_title', $this->petition)); // send thank you email $params['contactId'] = $contact_id; $params['email-Primary'] = $email; $params['sid'] = $petition_id; $params['activityId'] = $activity_id; CRM_Campaign_BAO_Petition::sendEmail($params, CRM_Campaign_Form_Petition_Signature::EMAIL_THANK); return parent::run(); }
function run() { CRM_Utils_System::addHTMLHead('<META NAME="ROBOTS" CONTENT="NOINDEX, NOFOLLOW">'); $contact_id = CRM_Utils_Request::retrieve('cid', 'Integer', CRM_Core_DAO::$_nullObject); $subscribe_id = CRM_Utils_Request::retrieve('sid', 'Integer', CRM_Core_DAO::$_nullObject); $hash = CRM_Utils_Request::retrieve('h', 'String', CRM_Core_DAO::$_nullObject); if (!$contact_id || !$subscribe_id || !$hash) { CRM_Core_Error::fatal(ts("Missing input parameters")); } $result = CRM_Mailing_Event_BAO_Confirm::confirm($contact_id, $subscribe_id, $hash); if ($result === FALSE) { $this->assign('success', $result); } else { $this->assign('success', TRUE); $this->assign('group', $result); } list($displayName, $email) = CRM_Contact_BAO_Contact_Location::getEmailDetails($contact_id); $this->assign('display_name', $displayName); $this->assign('email', $email); return parent::run(); }
/** * * POST Param 'qrid': string, usually the name of the queue */ public function run() { $qrid = CRM_Utils_Request::retrieve('qrid', 'String', $this, TRUE); $runner = CRM_Queue_Runner::instance($qrid); if (!is_object($runner)) { CRM_Core_Error::fatal('Queue runner must be configured before execution.'); } CRM_Utils_System::setTitle($runner->title); $this->assign('queueRunnerData', array('qrid' => $runner->qrid, 'runNextAjax' => CRM_Utils_System::url($runner->pathPrefix . '/ajax/runNext', NULL, FALSE, NULL, FALSE), 'skipNextAjax' => CRM_Utils_System::url($runner->pathPrefix . '/ajax/skipNext', NULL, FALSE, NULL, FALSE), 'onEndAjax' => CRM_Utils_System::url($runner->pathPrefix . '/ajax/onEnd', NULL, FALSE, NULL, FALSE), 'completed' => 0, 'numberOfItems' => $runner->queue->numberOfItems(), 'buttons' => $runner->buttons)); if ($runner->isMinimal) { // Render page header if (!defined('CIVICRM_UF_HEAD') && ($region = CRM_Core_Region::instance('html-header', FALSE))) { CRM_Utils_System::addHTMLHead($region->render('')); } $smarty = CRM_Core_Smarty::singleton(); $content = $smarty->fetch('CRM/Queue/Page/Runner.tpl'); echo CRM_Utils_System::theme($content, $this->_print, TRUE); } else { parent::run(); } }
/** * used to load a template "inline", eg. for ajax, without having to build a menu for each template */ public static function loadTemplate() { $request = CRM_Utils_Request::retrieve('q', 'String'); if (FALSE !== strpos($request, '..')) { die("SECURITY FATAL: the url can't contain '..'. Please report the issue on the forum at civicrm.org"); } $request = explode('/', $request); $entity = _civicrm_api_get_camel_name($request[2]); $tplfile = _civicrm_api_get_camel_name($request[3]); $tpl = 'CRM/' . $entity . '/Page/Inline/' . $tplfile . '.tpl'; $smarty = CRM_Core_Smarty::singleton(); CRM_Utils_System::setTitle("{$entity}::{$tplfile} inline {$tpl}"); if (!$smarty->template_exists($tpl)) { header("Status: 404 Not Found"); die("Can't find the requested template file templates/{$tpl}"); } 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); unset($param['q']); $smarty->assign_by_ref("request", $param); if (!array_key_exists('HTTP_X_REQUESTED_WITH', $_SERVER) || $_SERVER['HTTP_X_REQUESTED_WITH'] != "XMLHttpRequest") { $smarty->assign('tplFile', $tpl); $config = CRM_Core_Config::singleton(); $content = $smarty->fetch('CRM/common/' . strtolower($config->userFramework) . '.tpl'); if (!defined('CIVICRM_UF_HEAD') && ($region = CRM_Core_Region::instance('html-header', FALSE))) { CRM_Utils_System::addHTMLHead($region->render('')); } CRM_Utils_System::appendTPLFile($tpl, $content); return CRM_Utils_System::theme($content); } else { $content = "<!-- .tpl file embeded: {$tpl} -->\n"; CRM_Utils_System::appendTPLFile($tpl, $content); echo $content . $smarty->fetch($tpl); CRM_Utils_System::civiExit(); } }
/** * Render the page using a custom templating system. * * @param CRM_Core_Form $page * The CRM_Core_Form page. */ public function renderForm(&$page) { $this->_setRenderTemplates($page); $template = CRM_Core_Smarty::singleton(); $form = $page->toSmarty(); // Deprecated - use snippet=6 instead of json=1 $json = CRM_Utils_Request::retrieve('json', 'Boolean', CRM_Core_DAO::$_nullObject); if ($json) { CRM_Utils_JSON::output($form); } $template->assign('form', $form); $template->assign('isForm', 1); $controller =& $page->controller; // Stop here if we are in embedded mode. Exception: displaying form errors via ajax if ($controller->getEmbedded() && !(!empty($form['errors']) && $controller->_QFResponseType == 'json')) { return; } $template->assign('action', $page->getAction()); $pageTemplateFile = $page->getHookedTemplateFileName(); $template->assign('tplFile', $pageTemplateFile); $content = $template->fetch($controller->getTemplateFile()); 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, $page->overrideExtraTemplateFileName()); //its time to call the hook. CRM_Utils_Hook::alterContent($content, 'form', $pageTemplateFile, $page); $print = $controller->getPrint(); if ($print) { $html =& $content; } else { $html = CRM_Utils_System::theme($content, $print); } if ($controller->_QFResponseType == 'json') { $response = array('content' => $html); if (!empty($page->ajaxResponse)) { $response += $page->ajaxResponse; } if (!empty($form['errors'])) { $response['status'] = 'form_error'; $response['errors'] = $form['errors']; } CRM_Core_Page_AJAX::returnJsonResponse($response); } if ($print) { if ($print == CRM_Core_Smarty::PRINT_PDF) { CRM_Utils_PDF_Utils::html2pdf($content, "{$page->_name}.pdf", FALSE, array('paper_size' => 'a3', 'orientation' => 'landscape')); } else { echo $html; } CRM_Utils_System::civiExit(); } print $html; }
/** * Display any final messages, clear caches, etc */ public function runFinish() { $upgrade = new CRM_Upgrade_Form(); $template = CRM_Core_Smarty::singleton(); // If we're redirected from queue-runner, then isUpgradePending=true. // If user then reloads the finish page, the isUpgradePending will be unset. (Because the session has been cleared.) if ($this->get('isUpgradePending')) { // TODO: Use structured message store $postUpgradeMessage = file_get_contents($this->get('postUpgradeMessageFile')); // This destroys $session, so do it after get('postUpgradeMessageFile') CRM_Upgrade_Form::doFinish(); } else { $postUpgradeMessage = ''; // Session was destroyed! Can't recover messages. } // do a version check - after doFinish() sets the final version list($currentVer, $latestVer) = $upgrade->getUpgradeVersions(); if ($error = $upgrade->checkCurrentVersion($currentVer, $latestVer)) { CRM_Core_Error::fatal($error); } $template->assign('message', $postUpgradeMessage); $template->assign('upgraded', TRUE); $template->assign('sid', CRM_Utils_System::getSiteID()); // Render page header if (!defined('CIVICRM_UF_HEAD') && ($region = CRM_Core_Region::instance('html-header', FALSE))) { CRM_Utils_System::addHTMLHead($region->render('')); } $content = $template->fetch('CRM/common/success.tpl'); echo CRM_Utils_System::theme($content, $this->_print, TRUE); }
/** * 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(); // Intermittent alert to admins 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'); } $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); }
/** * @param $args * @param $type * * @return bool */ public static function invoke(&$args, $type) { $info = self::_info(); $config = CRM_Core_Config::singleton(); $firstArg = CRM_Utils_Array::value(1, $args, ''); $secondArg = CRM_Utils_Array::value(2, $args, ''); foreach ($info as $name => $comp) { if (in_array($name, $config->enableComponents) && ($comp->info['url'] === $firstArg && $type == 'main' || $comp->info['url'] === $secondArg && $type == 'admin')) { if ($type == 'main') { // also set the smarty variables to the current component $template = CRM_Core_Smarty::singleton(); $template->assign('activeComponent', $name); if (!empty($comp->info[$name]['formTpl'])) { $template->assign('formTpl', $comp->info[$name]['formTpl']); } if (!empty($comp->info[$name]['css'])) { $styleSheets = '<style type="text/css">@import url(' . "{$config->resourceBase}css/{$comp->info[$name]['css']});</style>"; CRM_Utils_System::addHTMLHead($styleSheet); } } $inv = $comp->getInvokeObject(); $inv->{$type}($args); return TRUE; } } return FALSE; }
/** * render the page using a custom templating * system * * @param object $page the CRM_Core_Form page * @param boolean $ret should we echo or return output * * @return void * @access public */ function renderForm(&$page) { $this->_setRenderTemplates($page); $template = CRM_Core_Smarty::singleton(); $form = $page->toSmarty(); $json = CRM_Utils_Request::retrieve('json', 'Boolean', CRM_Core_DAO::$_nullObject); if ($json) { CRM_Utils_JSON::output($form); } $template->assign('form', $form); $template->assign('isForm', 1); $controller =& $page->controller; if ($controller->getEmbedded()) { return; } $template->assign('action', $page->getAction()); $pageTemplateFile = $page->getHookedTemplateFileName(); $template->assign('tplFile', $pageTemplateFile); $content = $template->fetch($controller->getTemplateFile()); 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, $page->overrideExtraTemplateFileName()); //its time to call the hook. CRM_Utils_Hook::alterContent($content, 'form', $pageTemplateFile, $page); $print = $controller->getPrint(); if ($print) { $html =& $content; } else { $html = CRM_Utils_System::theme($content, $print); } if ($controller->_QFResponseType == 'json') { $response = array('content' => $html); // CRM-11831 @see http://www.malsup.com/jquery/form/#file-upload $xhr = isset($_SERVER['HTTP_X_REQUESTED_WITH']) && $_SERVER['HTTP_X_REQUESTED_WITH'] == 'XMLHttpRequest'; if (!$xhr) { echo '<textarea>'; } echo json_encode($response); if (!$xhr) { echo '</textarea>'; } CRM_Utils_System::civiExit(); } if ($print) { if ($print == CRM_Core_Smarty::PRINT_PDF) { CRM_Utils_PDF_Utils::html2pdf($content, "{$page->_name}.pdf", FALSE, array('paper_size' => 'a3', 'orientation' => 'landscape')); } else { echo $html; } CRM_Utils_System::civiExit(); } print $html; }
function run() { CRM_Utils_System::addHTMLHead('<META NAME="ROBOTS" CONTENT="NOINDEX, NOFOLLOW">'); $this->_type = 'unsubscribe'; return parent::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; }
/** * 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; }