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


PHP Theme::getTemplate方法代码示例

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


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

示例1: render

 /**
  * render
  * Finds and chooses the correct template, then renders the page
  *
  * @param string  $template  Template (or array of templates, in order of preference) to render the page with
  * @return string
  */
 public function render($template)
 {
     $html = '<p style="text-align:center; font-size:28px; font-style:italic; padding-top:50px;">No template found.</p>';
     $list = $template ? $list = array($template) : self::$_templates;
     $allow_php = Config::get('_allow_php', false);
     foreach ($list as $template) {
         $template_path = $this->getTemplatesDirectory() . '/templates/' . ltrim($template, '/');
         $template_type = 'html';
         if (file_exists($template_path . '.html') || file_exists($template_path . '.php')) {
             # standard lex-parsed template
             if (file_exists($template_path . '.html')) {
                 Statamic_View::$_dataStore = array_merge(Statamic_View::$_dataStore, $this->data);
                 $html = $this->parser->parse(Theme::getTemplate($template), Statamic_View::$_dataStore, array($this, 'callback'), $allow_php);
                 break;
                 # lets forge into raw data
             } elseif (file_exists($template_path . '.php')) {
                 $template_type = 'php';
                 extract($this->data);
                 ob_start();
                 require $template_path . ".php";
                 $html = ob_get_clean();
                 break;
             } else {
                 Log::error("Template does not exist: '{$template_path}'", 'core');
             }
         }
     }
     return $this->_render_layout($html, $template_type);
 }
开发者ID:nob,项目名称:joi,代码行数:36,代码来源:view.php

示例2: member__forgot_password

 public function member__forgot_password()
 {
     $globals = Statamic::loadAllConfigs();
     $username = filter_input(INPUT_POST, 'username', FILTER_SANITIZE_STRING);
     $token = filter_input(INPUT_POST, 'token', FILTER_SANITIZE_STRING);
     $return = filter_input(INPUT_POST, 'return', FILTER_SANITIZE_STRING);
     $reset_return = filter_input(INPUT_POST, 'reset_return', FILTER_SANITIZE_STRING);
     $referrer = Request::getReferrer();
     // validate form token
     if (!$this->tokens->validate($token)) {
         $this->flash->set('forgot_password_error', 'Invalid token.');
         URL::redirect($referrer);
     }
     // bail if member doesn't exist
     if (!($member = Member::load($username))) {
         $this->flash->set('forgot_password_error', Localization::fetch('member_doesnt_exist'));
         URL::redirect($referrer);
     }
     // cache reset data
     $token = $this->tokens->create();
     $reset_data = array('username' => $username);
     if (isset($reset_return)) {
         $reset_data['return'] = $reset_return;
     }
     $this->cache->putYAML($token, $reset_data);
     // generate reset url
     $reset_url = URL::makeFull($this->fetchConfig('reset_password_url', str_replace(Config::getSiteURL(), '', $referrer)));
     $reset_url .= '?H=' . $token;
     // send email
     $attributes = array('from' => $this->fetchConfig('email_sender', Config::get('email_sender'), null, false, false), 'to' => $member->get('email'), 'subject' => $this->fetchConfig('reset_password_subject', 'Password Reset', null, false, false));
     if ($html_template = $this->fetchConfig('reset_password_html_email', false, null, false, false)) {
         $attributes['html'] = Theme::getTemplate($html_template);
     }
     if ($text_template = $this->fetchConfig('reset_password_text_email', false, null, false, false)) {
         $attributes['text'] = Theme::getTemplate($text_template);
     }
     foreach ($attributes as $key => $value) {
         $attributes[$key] = Parse::template($value, array('reset_url' => $reset_url), array('statamic_view', 'callback'), $globals);
     }
     Email::send($attributes);
     $this->flash->set('forgot_password_sent', true);
     // redirect
     URL::redirect($return);
 }
开发者ID:andorpandor,项目名称:git-deploy.eu2.frbit.com-yr-prototype,代码行数:44,代码来源:hooks.member.php

示例3: forgot_password_form

 public function forgot_password_form()
 {
     // parse parameters and vars
     $attr_string = '';
     $site_root = Config::getSiteRoot();
     $return = $this->fetchParam('return', URL::getCurrent(), null, false, false);
     $reset_return = $this->fetchParam('reset_return', null, null, false, false);
     $allow_request_return = $this->fetchParam('allow_request_return', false, null, true, false);
     $logged_in_redirect = $this->fetchParam('logged_in_redirect', $return, null, false, false);
     $attr = $this->fetchParam('attr', false);
     // check that email template(s) exist
     if (!Theme::getTemplate($this->fetchConfig('reset_password_html_email', false, null, false, false)) && !Theme::getTemplate($this->fetchConfig('reset_password_text_email', false, null, false, false))) {
         throw new Exception('Your reset password email template(s) must exist and contain a {{ reset_url }}.');
     }
     // grab request return
     $get_return = filter_input(INPUT_GET, 'return', FILTER_SANITIZE_URL);
     $post_return = filter_input(INPUT_POST, 'return', FILTER_SANITIZE_URL);
     $request_return = Helper::pick($post_return, $get_return);
     // is user already logged in? forward as needed
     if (Auth::isLoggedIn()) {
         URL::redirect($logged_in_redirect, 302);
     }
     // if we're letting return values to be set in URL and one exists, grab it
     if ($allow_request_return && $request_return) {
         $return = $request_return;
     }
     // set up any data to be parsed into content
     $data = array('error' => $this->flash->get('forgot_password_error', ''), 'email_sent' => $this->flash->get('forgot_password_sent'));
     // set up attributes
     if ($attr) {
         $attributes_array = Helper::explodeOptions($attr, true);
         foreach ($attributes_array as $key => $value) {
             $attr_string .= ' ' . $key . '="' . $value . '"';
         }
     }
     // set up form HTML
     $html = '<form method="post" action="' . Path::tidy($site_root . "/TRIGGER/member/forgot_password") . '" ' . $attr_string . '>';
     $html .= '<input type="hidden" name="return" value="' . $return . '">';
     if ($reset_return) {
         $html .= '<input type="hidden" name="reset_return" value="' . $reset_return . '">';
     }
     $html .= '<input type="hidden" name="token" value="' . $this->tokens->create() . '">';
     $html .= Parse::template($this->content, $data);
     $html .= '</form>';
     // return that HTML
     return $html;
 }
开发者ID:andorpandor,项目名称:git-deploy.eu2.frbit.com-yr-prototype,代码行数:47,代码来源:pi.member.php

示例4: send

 /**
  * Send a notification/response email
  *
  * @param array  $submission  Array of submitted values
  * @param array  $config  Array of config values
  * @return void
  */
 private function send($submission, $config)
 {
     if (array_get($this->config, 'master_killswitch')) {
         return;
     }
     $email = array_get($config, 'email', false);
     if ($email) {
         $attributes = array_intersect_key($email, array_flip(Email::$allowed));
         if (array_get($email, 'automagic') || array_get($email, 'automatic')) {
             $automagic_email = $this->buildAutomagicEmail($submission);
             $attributes['html'] = $automagic_email['html'];
             $attributes['text'] = $automagic_email['text'];
         }
         if ($html_template = array_get($email, 'html_template', false)) {
             $attributes['html'] = Theme::getTemplate($html_template);
         }
         if ($text_template = array_get($email, 'text_template', false)) {
             $attributes['text'] = Theme::getTemplate($text_template);
         }
         /*
         |--------------------------------------------------------------------------
         | Parse all fields
         |--------------------------------------------------------------------------
         |
         | All email settings are parsed with the form data, allowing you, for
         | example, to send an email to a submitted email address.
         |
         |
         */
         foreach ($attributes as $key => $value) {
             $attributes[$key] = Parse::template($value, $submission);
         }
         $attributes['email_handler'] = array_get($config, 'email_handler', false);
         $attributes['email_handler_key'] = array_get($config, 'email_handler_key', false);
         Email::send($attributes);
     }
 }
开发者ID:jeffreyDcreative,项目名称:gkp,代码行数:44,代码来源:hooks.raven.php

示例5: send

 /**
  * Send a notification/response email
  *
  * @param array $submission Array of submitted values
  * @param array $email Array of email config values
  * @param array $config Array of config values
  */
 private function send($submission, $email, $config)
 {
     $attributes = array_intersect_key($email, array_flip(Email::$allowed));
     if (array_get($email, 'automagic') || array_get($email, 'automatic')) {
         $automagic_email = $this->buildAutomagicEmail($submission);
         $attributes['html'] = $automagic_email['html'];
         $attributes['text'] = $automagic_email['text'];
     }
     if ($html_template = array_get($email, 'html_template', false)) {
         $attributes['html'] = Theme::getTemplate($html_template);
     }
     if ($text_template = array_get($email, 'text_template', false)) {
         $attributes['text'] = Theme::getTemplate($text_template);
     }
     /*
     |--------------------------------------------------------------------------
     | Parse all fields
     |--------------------------------------------------------------------------
     |
     | All email settings are parsed with the form data, allowing you, for
     | example, to send an email to a submitted email address.
     |
     |
     */
     $globals = Config::getAll();
     array_walk_recursive($attributes, function (&$value, $key) use($submission, $globals) {
         $value = Parse::contextualTemplate($value, $submission, $globals);
     });
     $attributes['email_handler'] = array_get($config, 'email_handler', null);
     $attributes['email_handler_key'] = array_get($config, 'email_handler_key', null);
     $attributes['smtp'] = array_get($config, 'smtp', null);
     Email::send($attributes);
 }
开发者ID:Synergy23,项目名称:RealEstate,代码行数:40,代码来源:hooks.raven.php


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