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


PHP TemplateHelper类代码示例

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


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

示例1: getHtmlLink

 public function getHtmlLink($attributes = false)
 {
     $url = $this->getUrl();
     $text = $this->getText();
     if ($url && $text) {
         // Open  Link
         $htmlLink = '<a href="' . $url . '"';
         // Add Title (if not in attributes)
         if (!is_array($attributes) || !array_key_exists('title', $attributes)) {
             $htmlLink .= ' title="' . $text . '"';
         }
         // Add Target (if not in attributes)
         if ((!is_array($attributes) || !array_key_exists('title', $attributes)) && $this->target) {
             $htmlLink .= ' target="' . $this->target . '"';
         }
         // Add Attributes
         if (is_array($attributes)) {
             foreach ($attributes as $attr => $value) {
                 $htmlLink .= ' ' . $attr . '="' . $value . '"';
             }
         }
         // Close Up Link
         $htmlLink .= '>' . $text . '</a>';
         // Get Raw
         return TemplateHelper::getRaw($htmlLink);
     }
     return false;
 }
开发者ID:mrpaulphan,项目名称:mrpaulphan,代码行数:28,代码来源:FruitLinkIt_LinkModel.php

示例2: get

 /**
  * Get either a Gravatar URL or complete image tag for a specified email address.
  *
  * @param string $email The email address
  * @param string $size Size in pixels, defaults to 80px [ 1 - 2048 ]
  * @param string $default Default imageset to use [ 404 | mm | identicon | monsterid | wavatar ]
  * @param string $rating Maximum rating (inclusive) [ g | pg | r | x ]
  * @param boole $img True to return a complete IMG tag False for just the URL
  * @param array $attr Optional, additional key/value attributes to include in the IMG tag
  * @return String containing either just a URL or a complete image tag
  * @source http://gravatar.com/site/implement/images/php/
  */
 public function get($email, $criteria, $img)
 {
     if (isset($criteria['size'])) {
         $size = $criteria['size'];
     } else {
         $size = 80;
     }
     if (isset($criteria['default'])) {
         $default = $criteria['default'];
     } else {
         $default = 'mm';
     }
     if (isset($criteria['rating'])) {
         $rating = $criteria['rating'];
     } else {
         $rating = 'g';
     }
     $url = '//www.gravatar.com/avatar/';
     $url .= md5(strtolower(trim($email)));
     $url .= "?s={$size}&d={$default}&r={$rating}";
     if ($img) {
         $url = '<img src="' . $url . '"';
         if (isset($criteria['attr'])) {
             foreach ($criteria['attr'] as $key => $val) {
                 $url .= ' ' . $key . '="' . $val . '"';
             }
         }
         $url .= ' />';
     }
     return TemplateHelper::getRaw($url);
 }
开发者ID:kamicrafted,项目名称:designhub,代码行数:43,代码来源:GravatarService.php

示例3: getIcon

 /**
  * Получение иконки:
  */
 public static function getIcon($site)
 {
     $site = str_replace('www.', '', parse_url($site, PHP_URL_HOST));
     if (is_file(WEB_DIR . '/ico/favicons/' . $site . '.gif')) {
         return 'http://' . TemplateHelper::getSiteUrl() . '/ico/favicons/' . $site . '.gif';
     }
     return 'http://favicon.yandex.net/favicon/' . $site;
 }
开发者ID:postman0,项目名称:1chan,代码行数:11,代码来源:template.helper.php

示例4: renderFormCustomMacro

 public function renderFormCustomMacro($macro, array $args)
 {
     $oldPath = craft()->path->getTemplatesPath();
     $newPath = craft()->path->getPluginsPath() . 'teammanager/templates';
     craft()->path->setTemplatesPath($newPath);
     $html = craft()->templates->renderMacro('_includes/forms', $macro, array($args));
     craft()->path->setTemplatesPath($oldPath);
     return TemplateHelper::getRaw($html);
 }
开发者ID:JameelJiwani,项目名称:TeamManager_Plugin,代码行数:9,代码来源:TeamManagerVariable.php

示例5: getInputHtml

 /**
  * @param FieldModel $field
  * @param mixed      $value
  * @param mixed      $settings
  * @param array|null $renderingOptions
  *
  * @return \Twig_Markup
  */
 public function getInputHtml($field, $value, $settings, array $renderingOptions = null)
 {
     $this->beginRendering();
     $options = $settings['options'];
     $options = craft()->sproutFields_emailSelectField->obfuscateEmailAddresses($options);
     $rendered = craft()->templates->render('emailselect/input', array('name' => $field->handle, 'value' => $value, 'options' => $options, 'settings' => $settings, 'field' => $field));
     $this->endRendering();
     return TemplateHelper::getRaw($rendered);
 }
开发者ID:andyra,项目名称:tes,代码行数:17,代码来源:SproutFieldsEmailSelectField.php

示例6: parsedownFilter

 /**
  * The Parsedown filter
  *
  * @param string $text The text to be parsed
  * @param string $mode The parsing mode ('text' or 'line').
  * @param mixed $tags
  * @return string
  */
 public function parsedownFilter($text, $parseAs = 'text')
 {
     if ($parseAs == 'line') {
         $parsed = craft()->parsedown->parseLine($text);
     } else {
         $parsed = craft()->parsedown->parseText($text);
     }
     return TemplateHelper::getRaw($parsed);
 }
开发者ID:luwes,项目名称:Parsedown,代码行数:17,代码来源:ParsedownTwigExtension.php

示例7: getInputHtml

 /**
  * @param FieldModel $field
  * @param mixed      $value
  * @param mixed      $settings
  * @param array|null $renderingOptions
  *
  * @return \Twig_Markup
  */
 public function getInputHtml($field, $value, $settings, array $renderingOptions = null)
 {
     $this->beginRendering();
     $attributes = $field->getAttributes();
     $errorMessage = craft()->sproutFields_emailField->getErrorMessage($attributes['name'], $settings);
     $placeholder = isset($settings['placeholder']) ? $settings['placeholder'] : '';
     $rendered = craft()->templates->render('email/input', array('name' => $field->handle, 'value' => $value, 'field' => $field, 'pattern' => $settings['customPattern'], 'errorMessage' => $errorMessage, 'renderingOptions' => $renderingOptions, 'placeholder' => $placeholder));
     $this->endRendering();
     return TemplateHelper::getRaw($rendered);
 }
开发者ID:andyra,项目名称:tes,代码行数:18,代码来源:SproutFieldsEmailField.php

示例8: getSettingsHtml

 public function getSettingsHtml()
 {
     // If not set, create a default row
     if (!$this->_matrixBlockColors) {
         $this->_matrixBlockColors = array(array('blockType' => '', 'backgroundColor' => ''));
     }
     // Generate table
     $matrixBlockColorsTable = craft()->templates->renderMacro('_includes/forms', 'editableTableField', array(array('label' => Craft::t('Block Type Colors'), 'instructions' => Craft::t('Add background colors to your matrix block types'), 'id' => 'matrixBlockColors', 'name' => 'matrixBlockColors', 'cols' => array('blockType' => array('heading' => Craft::t('Block Type Handle'), 'type' => 'singleline'), 'backgroundColor' => array('heading' => Craft::t('CSS Background Color'), 'type' => 'singleline', 'class' => 'code')), 'rows' => $this->_matrixBlockColors, 'addRowLabel' => Craft::t('Add a block type color'))));
     // Output settings template
     return craft()->templates->render('matrixcolors/_settings', array('matrixBlockColorsTable' => TemplateHelper::getRaw($matrixBlockColorsTable)));
 }
开发者ID:daituzhang,项目名称:craft-starter,代码行数:11,代码来源:MatrixColorsPlugin.php

示例9: getInputHtml

 /**
  * I'm invisible, I don't need to show up on the front end
  * I do need to save my value to session to retrieve it via prepValueFromPost()
  * You should also know that prepValueFromPost() won't be called unless you:
  * - Set a hidden field to an empty value with my name
  *
  * @param FieldModel $field
  * @param mixed      $value
  * @param mixed      $settings
  * @param array|null $renderingOptions
  *
  * @return \Twig_Markup
  */
 public function getInputHtml($field, $value, $settings, array $renderingOptions = null)
 {
     try {
         $value = craft()->templates->renderObjectTemplate($settings['value'], parent::getFieldVariables());
     } catch (\Exception $e) {
         SproutInvisibleFieldPlugin::log($e->getMessage());
     }
     craft()->httpSession->add($field->handle, $value);
     // We really don't need the extra processing that it takes to render a template
     return TemplateHelper::getRaw(sprintf('<input type="hidden" name="%s" />', $field->handle));
 }
开发者ID:andyra,项目名称:tes,代码行数:24,代码来源:SproutFieldsInvisibleField.php

示例10: staticMap

 public function staticMap($data, $options = array())
 {
     if ($data instanceof GoogleMaps_MapDataModel) {
         $model = $data->getStaticMapModel($options);
         return TemplateHelper::getRaw(craft()->googleMaps_staticMap->image($model, $options));
     } else {
         $options = array_merge($options, $data);
         $model = GoogleMaps_StaticMapModel::populateModel($options);
         return TemplateHelper::getRaw(craft()->googleMaps_staticMap->image($model, $options));
     }
 }
开发者ID:bhuvidya,项目名称:Google-Maps-for-Craft,代码行数:11,代码来源:GoogleMaps_TemplatesService.php

示例11: getInputHtml

 /**
  * @param FieldModel $field
  * @param mixed      $value
  * @param mixed      $settings
  * @param array|null $renderingOptions
  *
  * @return \Twig_Markup
  */
 public function getInputHtml($field, $value, $settings, array $renderingOptions = null)
 {
     $this->beginRendering();
     $name = $field->handle;
     $namespaceInputId = $this->getNamespace() . '-' . $name;
     $selectedStyle = $settings['style'];
     $pluginSettings = craft()->plugins->getPlugin('sproutfields')->getSettings()->getAttributes();
     $selectedStyleCss = str_replace("{{ name }}", $name, $pluginSettings[$selectedStyle]);
     $rendered = craft()->templates->render('notes/input', array('settings' => $settings, 'selectedStyleCss' => $selectedStyleCss));
     $this->endRendering();
     return TemplateHelper::getRaw($rendered);
 }
开发者ID:andyra,项目名称:tes,代码行数:20,代码来源:SproutFieldsNotesField.php

示例12: getInputHtml

 /**
  * @param FieldModel $field
  * @param mixed      $value
  * @param mixed      $settings
  * @param array|null $renderingOptions
  *
  * @return \Twig_Markup
  */
 public function getInputHtml($field, $value, $settings, array $renderingOptions = null)
 {
     $this->beginRendering();
     try {
         $value = craft()->templates->renderObjectTemplate($settings['value'], parent::getFieldVariables());
     } catch (\Exception $e) {
         SproutFieldsPlugin::log($e->getMessage(), LogLevel::Error);
     }
     $rendered = craft()->templates->render('hidden/input', array('name' => $field->handle, 'value' => $value, 'field' => $field, 'renderingOptions' => $renderingOptions));
     $this->endRendering();
     return TemplateHelper::getRaw($rendered);
 }
开发者ID:andyra,项目名称:tes,代码行数:20,代码来源:SproutFieldsHiddenField.php

示例13: getInputHtml

 /**
  * @param FieldModel $field
  * @param mixed      $value
  * @param mixed      $settings
  * @param array|null $renderingOptions
  *
  * @return \Twig_Markup
  */
 public function getInputHtml($field, $value, $settings, array $renderingOptions = null)
 {
     $this->beginRendering();
     $name = $field->handle;
     $namespaceInputId = $this->getNamespace() . '-' . $name;
     $pattern = craft()->sproutFields_phoneField->convertMaskToRegEx($settings['mask']);
     $pattern = trim($pattern, '/');
     $attributes = $field->getAttributes();
     $errorMessage = craft()->sproutFields_phoneField->getErrorMessage($attributes['name'], $settings);
     $rendered = craft()->templates->render('phone/input', array('name' => $name, 'value' => $value, 'settings' => $settings, 'field' => $field, 'pattern' => $pattern, 'errorMessage' => $errorMessage, 'namespaceInputId' => $namespaceInputId, 'renderingOptions' => $renderingOptions));
     $this->endRendering();
     return TemplateHelper::getRaw($rendered);
 }
开发者ID:andyra,项目名称:tes,代码行数:21,代码来源:SproutFieldsPhoneField.php

示例14: switchAction

 /**
  * Смена темы:
  */
 public function switchAction(Application $application, Template $template)
 {
     $session = Session::getInstance();
     if ($_GET['theme'] == 'normal') {
         $session->persistenceSet('global_theme', false);
     } else {
         if (is_file(VIEWS_DIR . '/layout_' . str_replace('/', '', $_GET['theme']) . '.php')) {
             $session->persistenceSet('global_theme', 'layout_' . $_GET['theme']);
         }
     }
     $template->headerSeeOther('http://' . TemplateHelper::getSiteUrl() . '/');
     return false;
 }
开发者ID:postman0,项目名称:1chan,代码行数:16,代码来源:theme.controller.php

示例15: getFeedItems

 /**
  * @param string $url
  * @param int    $limit
  * @param int    $offset
  * @param null   $cacheDuration
  *
  * @return array
  */
 public function getFeedItems($url, $limit = 0, $offset = 0, $cacheDuration = null)
 {
     $limit = NumberHelper::makeNumeric($limit);
     $offset = NumberHelper::makeNumeric($offset);
     $items = craft()->feeds->getFeedItems($url, $limit, $offset, $cacheDuration);
     // Prevent everyone from having to use the |raw filter when outputting the title and content
     $rawProperties = array('title', 'content', 'summary');
     foreach ($items as &$item) {
         foreach ($rawProperties as $prop) {
             $item[$prop] = TemplateHelper::getRaw($item[$prop]);
         }
     }
     return $items;
 }
开发者ID:jmstan,项目名称:craft-website,代码行数:22,代码来源:FeedsVariable.php


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