本文整理汇总了PHP中TemplateHelper类的典型用法代码示例。如果您正苦于以下问题:PHP TemplateHelper类的具体用法?PHP TemplateHelper怎么用?PHP TemplateHelper使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了TemplateHelper类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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
示例16: getSettingsHtml
public function getSettingsHtml()
{
// If Craft Pro
if (craft()->getEdition() == Craft::Pro) {
$options = array();
$userGroups = craft()->userGroups->getAllGroups();
foreach ($userGroups as $group) {
$options[] = array('label' => $group->name, 'value' => $group->id);
}
$checkboxes = craft()->templates->render('_includes/forms/checkboxGroup', array('name' => 'userGroups', 'options' => $options, 'values' => $this->getSettings()->userGroups));
$noGroups = '<p class="error">No user groups exist. <a href="' . UrlHelper::getCpUrl('settings/users/groups/new') . '">Create one now...</a></p>';
craft()->templates->includeCssResource('autoassignusergroup/css/settings.css');
return craft()->templates->render('autoassignusergroup/_settings', array('userGroupsField' => TemplateHelper::getRaw(count($userGroups) ? $checkboxes : $noGroups)));
} else {
craft()->templates->includeJs('$(".btn.submit").val("Continue");');
$output = '<h2>Craft Upgrade Required</h2>';
$output .= '<p>In order to use this plugin, Craft Pro is required.</p>';
return craft()->templates->renderString($output);
}
}
开发者ID:floodhelpers,项目名称:floodhelpers,代码行数:20,代码来源:AutoAssignUserGroupPlugin.php
示例17: parse
/**
* Parses source markdown into valid html using various rules and parsers
*
* @param string $source The markdown source to parse
* @param array $options Passed in parameters via a template filter call
*
* @return \Twig_Markup|DoxterModel The parsed content flagged as safe to output
*/
public function parse($source, array $options = array())
{
if ($source instanceof DoxterModel) {
return $source;
}
$codeBlockSnippet = null;
$addHeaderAnchors = true;
$addHeaderAnchorsTo = array('h1', 'h2', 'h3');
$addTypographyStyles = true;
$startingHeaderLevel = 1;
$parseReferenceTags = true;
$parseShortcodes = true;
$options = array_merge(craft()->plugins->getPlugin('doxter')->getSettings()->getAttributes(), $options);
extract($options);
// Parsing reference tags first so that we can parse markdown within them
if ($parseReferenceTags) {
if ($this->onBeforeReferenceTagParsing(compact('source', 'options'))) {
$source = $this->parseReferenceTags($source, $options);
}
}
if ($parseShortcodes) {
if ($this->onBeforeShortcodeParsing(compact('source'))) {
$source = $this->parseShortcodes($source);
}
}
if ($this->onBeforeMarkdownParsing(compact('source'))) {
$source = $this->parseMarkdown($source);
}
if ($this->onBeforeCodeBlockParsing(compact('source', 'codeBlockSnippet'))) {
$source = $this->parseCodeBlocks($source, compact('codeBlockSnippet'));
}
if ($addHeaderAnchors) {
if ($this->onBeforeHeaderParsing(compact('source', 'addHeaderAnchorsTo'))) {
$source = $this->parseHeaders($source, compact('addHeaderAnchorsTo', 'startingHeaderLevel'));
}
}
if ($addTypographyStyles) {
$source = $this->addTypographyStyles($source, $options);
}
return TemplateHelper::getRaw($source);
}
开发者ID:kamicrafted,项目名称:designhub,代码行数:49,代码来源:DoxterService.php
示例18: injector
protected function injector($text, $class = 'chars', $after = '')
{
switch ($class) {
case 'words':
$parts = explode(' ', trim(strip_tags($text)));
break;
case 'lines':
$parts = preg_split('/<br[^>]*>/i', strip_tags(nl2br(trim($text)), '<br>'));
break;
default:
$parts = str_split(trim(strip_tags($text)));
break;
}
$count = 1;
$formattedParts = array_map(function ($part) use(&$count, $class, $after) {
$part = '<span class="' . substr($class, 0, -1) . $count . '" aria-hidden="true">' . $part . '</span>' . $after;
$count = $count + 1;
return $part;
}, $parts);
$ariaLabel = TemplateHelper::getRaw(' aria-label="' . trim(strip_tags($text)) . '"');
$joined = TemplateHelper::getRaw(implode('', $formattedParts));
$result = ['original' => $text, 'ariaLabel' => $ariaLabel, $class => $joined];
return $result;
}
开发者ID:sjelfull,项目名称:Craft-Lettering,代码行数:24,代码来源:LetteringService.php
示例19: uploadFile
/**
* Upload new file.
*
* @param string $file The name of the file.
* @param string $location Location for the new file.
*
* @return boolean True if file uploaded successfully, false otherwise
*
* @since 3.2
*/
public function uploadFile($file, $location)
{
jimport('joomla.filesystem.folder');
if ($template = $this->getTemplate()) {
$app = JFactory::getApplication();
$client = JApplicationHelper::getClientInfo($template->client_id);
$path = JPath::clean($client->path . '/templates/' . $template->element . '/');
$fileName = JFile::makeSafe($file['name']);
$err = null;
JLoader::register('TemplateHelper', JPATH_COMPONENT_ADMINISTRATOR . '/helpers/template.php');
if (!TemplateHelper::canUpload($file, $err)) {
// Can't upload the file
return false;
}
if (file_exists(JPath::clean($path . '/' . $location . '/' . $file['name']))) {
$app->enqueueMessage(JText::_('COM_TEMPLATES_FILE_EXISTS'), 'error');
return false;
}
if (!JFile::upload($file['tmp_name'], JPath::clean($path . '/' . $location . '/' . $fileName))) {
$app->enqueueMessage(JText::_('COM_TEMPLATES_FILE_UPLOAD_ERROR'), 'error');
return false;
}
$url = JPath::clean($location . '/' . $fileName);
return $url;
}
}
开发者ID:brenot,项目名称:forumdesenvolvimento,代码行数:36,代码来源:template.php
示例20:
}
?>
" /> <img src="http://<?php
echo TemplateHelper::getSiteUrl();
?>
/ico/key.gif" width="16" height="16" alt="" class="js-key-icon<?php
if (empty($room['password'])) {
?>
g-hidden<?php
}
?>
"/>
</div>
<div class="b-chat-rooms_b-room_b-info">
<em><?php
echo TemplateHelper::ending(Chat_ChatRoomsModel::GetRoomOnline($room['room_id']), 'участник', 'участника', 'участников');
?>
</em>
</div>
<div class="b-chat-rooms_b-room_b-description">
<p><?php
echo $room['description'];
?>
</p>
</div>
</div>
<?php
}
?>
</div>
开发者ID:postman0,项目名称:1chan,代码行数:31,代码来源:index.php
注:本文中的TemplateHelper类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论