本文整理汇总了PHP中HtmlHelper::encodeParams方法的典型用法代码示例。如果您正苦于以下问题:PHP HtmlHelper::encodeParams方法的具体用法?PHP HtmlHelper::encodeParams怎么用?PHP HtmlHelper::encodeParams使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类HtmlHelper
的用法示例。
在下文中一共展示了HtmlHelper::encodeParams方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getDbRoutes
/**
* Returns the routes defined in the CP.
*
* @return array
*/
public function getDbRoutes()
{
$routes = array();
$results = craft()->db->createCommand()->select('id, locale, urlParts, template')->from('routes')->order('sortOrder')->queryAll();
foreach ($results as $result) {
$urlDisplayHtml = '';
$urlParts = JsonHelper::decode($result['urlParts']);
foreach ($urlParts as $part) {
if (is_string($part)) {
$urlDisplayHtml .= $part;
} else {
$urlDisplayHtml .= HtmlHelper::encodeParams('<span class="token" data-name="{partZero}" data-value="{partOne}"><span>{partZero}</span></span>', array('partZero' => $part[0], 'partOne' => $part[1]));
}
}
$routes[] = array('id' => $result['id'], 'locale' => $result['locale'], 'urlDisplayHtml' => $urlDisplayHtml, 'template' => $result['template']);
}
return $routes;
}
示例2: getAssetTableAttributeHtml
/**
* Hook for formatting the HTML for embedded asset attributes in the Assets manager.
*
* @param $element
* @param $attribute
* @return null|string
*/
public function getAssetTableAttributeHtml($element, $attribute)
{
if ($element instanceof AssetFileModel) {
$embed = craft()->embeddedAssets->getEmbeddedAsset($element);
if ($embed) {
switch ($attribute) {
case 'filename':
return HtmlHelper::encodeParams('<a href="{url}" target="_blank" style="word-break: break-word;">{name}</a>', array('url' => $embed->url, 'name' => mb_strimwidth($embed->url, 0, 50, '...')));
case 'provider':
return HtmlHelper::encodeParams('<a href="{url}" target="_blank" data-provider="{data}">{name}</a>', array('url' => $embed->providerUrl, 'data' => StringHelper::toCamelCase($embed->providerName), 'name' => $embed->providerName));
case 'size':
return '';
case 'kind':
switch ($embed->type) {
case 'photo':
return Craft::t("Embedded Image");
case 'video':
return Craft::t("Embedded Video");
case 'link':
return Craft::t("Embedded Link");
}
return Craft::t("Embedded Media");
case 'imageSize':
if ($embed->type == 'image') {
$width = $embed->width;
$height = $embed->height;
if ($width && $height) {
return $width . ' × ' . $height;
} else {
return null;
}
} else {
return '';
}
case 'width':
case 'height':
if ($embed->type == 'image') {
$size = $embed->{$attribute};
return $size ? $size . 'px' : null;
} else {
return '';
}
}
}
}
if ($attribute === 'provider') {
return '';
}
return null;
}
示例3: getInputHtml
/**
* @inheritDoc IFieldType::getInputHtml()
*
* @param string $name
* @param mixed $value
*
* @return string
*/
public function getInputHtml($name, $value)
{
return HtmlHelper::encodeParams('<textarea name="{name}">{value}</textarea>', array('name' => $name, 'value' => $value));
}
示例4: getTableAttributeHtml
/**
* @inheritDoc IElementType::getTableAttributeHtml()
*
* @param BaseElementModel $element
* @param string $attribute
*
* @return string
*/
public function getTableAttributeHtml(BaseElementModel $element, $attribute)
{
// First give plugins a chance to set this
$pluginAttributeHtml = craft()->plugins->callFirst('getUserTableAttributeHtml', array($element, $attribute), true);
if ($pluginAttributeHtml !== null) {
return $pluginAttributeHtml;
}
switch ($attribute) {
case 'email':
$email = $element->email;
if ($email) {
return HtmlHelper::encodeParams('<a href="mailto:{email}">{email}</a>', array('email' => $email));
} else {
return '';
}
default:
return parent::getTableAttributeHtml($element, $attribute);
}
}
示例5: getTableAttributeHtml
/**
* @inheritDoc IElementType::getTableAttributeHtml()
*
* @param BaseElementModel $element
* @param string $attribute
*
* @return string
*/
public function getTableAttributeHtml(BaseElementModel $element, $attribute)
{
// First give plugins a chance to set this
$pluginAttributeHtml = craft()->plugins->callFirst('getAssetTableAttributeHtml', array($element, $attribute), true);
if ($pluginAttributeHtml !== null) {
return $pluginAttributeHtml;
}
switch ($attribute) {
case 'filename':
return HtmlHelper::encodeParams('<span style="word-break: break-word;">{fileName}</span>', array('fileName' => $element->filename));
case 'kind':
return IOHelper::getFileKindLabel($element->kind);
case 'size':
if ($element->size) {
return craft()->formatter->formatSize($element->size);
} else {
return '';
}
case 'imageSize':
if (($width = $element->getWidth()) && ($height = $element->getHeight())) {
return "{$width} × {$height}";
} else {
return '';
}
case 'width':
case 'height':
$size = $element->{$attribute};
return $size ? $size . 'px' : '';
default:
return parent::getTableAttributeHtml($element, $attribute);
}
}
示例6: getHeadHtml
/**
* Returns the HTML prepared for inclusion in the `<head>` of the template, and flushes out the head HTML queue.
*
* This will include:
*
* - Any CSS files included using {@link includeCssFile()} or {@link includeCssResource()}
* - Any CSS included using {@link includeCss()} or {@link includeHiResCss()}
* - Any HTML included using {@link includeHeadHtml()}
*
* @return string
*/
public function getHeadHtml()
{
// Are there any CSS files to include?
if (!empty($this->_cssFiles)) {
foreach ($this->_cssFiles as $url) {
$node = HtmlHelper::encodeParams('<link rel="stylesheet" type="text/css" href="{url}"/>', array('url' => $url));
$this->includeHeadHtml($node);
}
$this->_cssFiles = array();
}
// Is there any hi-res CSS to include?
if (!empty($this->_hiResCss)) {
$this->includeCss("@media only screen and (-webkit-min-device-pixel-ratio: 1.5),\n" . "only screen and ( -moz-min-device-pixel-ratio: 1.5),\n" . "only screen and ( -o-min-device-pixel-ratio: 3/2),\n" . "only screen and ( min-device-pixel-ratio: 1.5),\n" . "only screen and ( min-resolution: 1.5dppx){\n" . implode("\n\n", $this->_hiResCss) . "\n" . '}');
$this->_hiResCss = array();
}
// Is there any CSS to include?
if (!empty($this->_css)) {
$css = implode("\n\n", $this->_css);
$node = "<style type=\"text/css\">\n" . $css . "\n</style>";
$this->includeHeadHtml($node);
$this->_css = array();
}
if (!empty($this->_headHtml)) {
$headNodes = implode("\n", $this->_headHtml);
$this->_headHtml = array();
return $headNodes;
}
}
示例7: getTableAttributeHtml
/**
* @inheritDoc IElementType::getTableAttributeHtml()
*
* @param BaseElementModel $element
* @param string $attribute
*
* @return string
*/
public function getTableAttributeHtml(BaseElementModel $element, $attribute)
{
// First give plugins a chance to set this
$pluginAttributeHtml = craft()->plugins->callFirst('getAssetTableAttributeHtml', array($element, $attribute), true);
if ($pluginAttributeHtml !== null) {
return $pluginAttributeHtml;
}
switch ($attribute) {
case 'filename':
return HtmlHelper::encodeParams('<span style="word-break: break-word;">{fileName}</span>', array('fileName' => $element->filename));
case 'size':
if ($element->size) {
return craft()->formatter->formatSize($element->size);
} else {
return '';
}
default:
return parent::getTableAttributeHtml($element, $attribute);
}
}
示例8: getStaticHtml
/**
* @inheritDoc IFieldType::getStaticHtml()
*
* @param mixed $value
*
* @return string
*/
public function getStaticHtml($value)
{
if ($value) {
return HtmlHelper::encodeParams('<div class="color" style="cursor: default;"><div class="colorpreview" style="background-color: {bgColor};"></div></div>' . '<div class="colorhex code">{bgColor}</div>', array('bgColor' => $value));
}
}
示例9: _getCpElementHtml
/**
* Returns the HTML for an element in the CP.
*
* @param array &$context
*
* @return string
*/
private function _getCpElementHtml(&$context)
{
if (!isset($context['element'])) {
return;
}
if (!isset($context['context'])) {
$context['context'] = 'index';
}
if (!isset($context['viewMode'])) {
$context['viewMode'] = 'table';
}
$thumbClass = 'elementthumb' . $context['element']->id;
$iconClass = 'elementicon' . $context['element']->id;
if ($context['viewMode'] == 'thumbs') {
$thumbSize = 100;
$iconSize = 90;
$thumbSelectorPrefix = '.thumbsview ';
} else {
$thumbSize = 30;
$iconSize = 20;
$thumbSelectorPrefix = '';
}
$thumbUrl = $context['element']->getThumbUrl($thumbSize);
if ($thumbUrl) {
$this->includeCss($thumbSelectorPrefix . '.' . $thumbClass . " { background-image: url('" . $thumbUrl . "'); }");
$this->includeHiResCss($thumbSelectorPrefix . '.' . $thumbClass . " { background-image: url('" . $context['element']->getThumbUrl($thumbSize * 2) . "'); background-size: " . $thumbSize . 'px; }');
} else {
$iconUrl = $context['element']->getIconUrl($iconSize);
if ($iconUrl) {
$this->includeCss($thumbSelectorPrefix . '.' . $iconClass . " { background-image: url('" . $iconUrl . "'); }");
$this->includeHiResCss($thumbSelectorPrefix . '.' . $iconClass . " { background-image: url('" . $context['element']->getIconUrl($iconSize * 2) . "); background-size: " . $iconSize . 'px; }');
}
}
$html = '<div class="element';
if ($context['context'] == 'field') {
$html .= ' removable';
}
if ($thumbUrl) {
$html .= ' hasthumb';
} else {
if ($iconUrl) {
$html .= ' hasicon';
}
}
$label = $context['element'];
$html .= '" data-id="' . $context['element']->id . '" data-locale="' . $context['element']->locale . '" data-status="' . $context['element']->getStatus() . '" data-label="' . $label . '" data-url="' . $context['element']->getUrl() . '"';
if ($context['element']->level) {
$html .= ' data-level="' . $context['element']->level . '"';
}
$isEditable = ElementHelper::isElementEditable($context['element']);
if ($isEditable) {
$html .= ' data-editable';
}
$html .= '>';
if ($context['context'] == 'field' && isset($context['name'])) {
$html .= '<input type="hidden" name="' . $context['name'] . '[]" value="' . $context['element']->id . '">';
$html .= '<a class="delete icon" title="' . Craft::t('Remove') . '"></a> ';
}
if ($thumbUrl) {
$html .= '<div class="elementthumb ' . $thumbClass . '"></div> ';
} else {
if ($iconUrl) {
$html .= '<div class="elementicon ' . $iconClass . '"></div> ';
}
}
$html .= '<div class="label">';
if (isset($context['elementType'])) {
$elementType = $context['elementType'];
} else {
$elementType = craft()->elements->getElementType($context['element']->getElementType());
}
if ($elementType->hasStatuses()) {
$html .= '<span class="status ' . $context['element']->getStatus() . '"></span>';
}
$html .= '<span class="title">';
if ($context['context'] == 'index' && ($cpEditUrl = $context['element']->getCpEditUrl())) {
$html .= HtmlHelper::encodeParams('<a href="{cpEditUrl}">{label}</a>', array('cpEditUrl' => $cpEditUrl, 'label' => $label));
} else {
$html .= HtmlHelper::encode($label);
}
$html .= '</span></div></div>';
return $html;
}
示例10: _getCpElementHtml
/**
* Returns the HTML for an element in the CP.
*
* @param array &$context
*
* @return string
*/
private function _getCpElementHtml(&$context)
{
if (!isset($context['element'])) {
return;
}
if (!isset($context['context'])) {
$context['context'] = 'index';
}
if (isset($context['elementType'])) {
$elementType = $context['elementType'];
} else {
$elementType = craft()->elements->getElementType($context['element']->getElementType());
}
// How big is the element going to be?
if (isset($context['size']) && ($context['size'] == 'small' || $context['size'] == 'large')) {
$elementSize = $context['size'];
} else {
if (isset($context['viewMode']) && $context['viewMode'] == 'thumbs') {
$elementSize = 'large';
} else {
$elementSize = 'small';
}
}
// Create the thumb/icon image, if there is one
// ---------------------------------------------------------------------
$thumbUrl = $context['element']->getThumbUrl(self::$_elementThumbSizes[0]);
if ($thumbUrl) {
$srcsets = array();
foreach (self::$_elementThumbSizes as $i => $size) {
if ($i == 0) {
$srcset = $thumbUrl;
} else {
$srcset = $context['element']->getThumbUrl($size);
}
$srcsets[] = $srcset . ' ' . $size . 'w';
}
$imgHtml = '<div class="elementthumb">' . '<img ' . 'sizes="' . ($elementSize == 'small' ? self::$_elementThumbSizes[0] : self::$_elementThumbSizes[2]) . 'px" ' . 'srcset="' . implode(', ', $srcsets) . '" ' . 'alt="">' . '</div> ';
} else {
$imgHtml = '';
}
$html = '<div class="element ' . $elementSize;
if ($context['context'] == 'field') {
$html .= ' removable';
}
if ($elementType->hasStatuses()) {
$html .= ' hasstatus';
}
if ($thumbUrl) {
$html .= ' hasthumb';
}
$label = $context['element'];
$html .= '" data-id="' . $context['element']->id . '" data-locale="' . $context['element']->locale . '" data-status="' . $context['element']->getStatus() . '" data-label="' . $label . '" data-url="' . $context['element']->getUrl() . '"';
if ($context['element']->level) {
$html .= ' data-level="' . $context['element']->level . '"';
}
$isEditable = ElementHelper::isElementEditable($context['element']);
if ($isEditable) {
$html .= ' data-editable';
}
$html .= '>';
if ($context['context'] == 'field' && isset($context['name'])) {
$html .= '<input type="hidden" name="' . $context['name'] . '[]" value="' . $context['element']->id . '">';
$html .= '<a class="delete icon" title="' . Craft::t('Remove') . '"></a> ';
}
if ($elementType->hasStatuses()) {
$html .= '<span class="status ' . $context['element']->getStatus() . '"></span>';
}
$html .= $imgHtml;
$html .= '<div class="label">';
$html .= '<span class="title">';
if ($context['context'] == 'index' && ($cpEditUrl = $context['element']->getCpEditUrl())) {
$html .= HtmlHelper::encodeParams('<a href="{cpEditUrl}">{label}</a>', array('cpEditUrl' => $cpEditUrl, 'label' => $label));
} else {
$html .= HtmlHelper::encode($label);
}
$html .= '</span></div></div>';
return $html;
}