本文整理汇总了PHP中HtmlHelper::attr方法的典型用法代码示例。如果您正苦于以下问题:PHP HtmlHelper::attr方法的具体用法?PHP HtmlHelper::attr怎么用?PHP HtmlHelper::attr使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类HtmlHelper
的用法示例。
在下文中一共展示了HtmlHelper::attr方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: input
/**
* Creates a wordpress option formated input
*
* @param string $name
* @param string $options
* @param string $prefix
* @return void
* @author Armando Sosa
*/
function input($name, $options = null, $prefix = true)
{
// default options
$options = array_merge(array('label' => $name, 'inline' => 0, 'type' => 'text', 'description' => '', 'options' => array(), 'multiple' => false, 'attrs' => '', 'show_all_cats' => __('-- All'), 'show_none_cats' => ''), (array) $options);
// grab value from options table
if (!isset($options['value'])) {
$options['value'] = $this->Widget->getOption($name);
}
$name = $this->Widget->get_field_name($name);
// parse tag
switch ($options['type']) {
case 'select':
$input = $this->_select($name, $options);
break;
case 'categorySelect':
$input = $this->_categorySelect($name, $options);
break;
default:
if (is_array($options['attrs']) && !empty($options['attrs'])) {
$options['attrs'] = HtmlHelper::attr($options['attrs']);
}
$input = sprintf($this->inputTags[$options['type']], $name, $options['value'], $options['attrs']);
break;
}
if ($options['type'] == 'hidden') {
return $input;
}
if ($options['label']) {
if ($options['inline']) {
$output = "<label>{$options['label']} {$input} </label>";
} else {
$output = "<p><label for='{$name}'>{$options['label']}</label></p>";
$output .= "<p>{$input}</p>";
}
} else {
$output = $input;
}
return $output;
}
示例2: ajaxUrl
function ajaxUrl()
{
if ($this->alreadyPrintedAjaxUrl) {
return false;
}
$attributes = HtmlHelper::attr(array('name' => 'ajax_url', 'type' => 'hidden', 'value' => admin_url('admin-ajax.php')));
echo HtmlHelper::tag("input/", $attributes, null, null);
$this->alreadyPrintedAjaxUrl = true;
}
示例3: import
function import($type = null, $name = null, $charset = "utf-8")
{
switch ($type) {
case 'style':
$attribs = HtmlHelper::attr(array('rel' => 'stylesheet', 'href' => DUP_CORE_STYLES_URL . "{$name}.css", 'type' => 'text/css', 'media' => 'screen', 'title' => phraseize($name), 'charset' => $charset));
return HtmlHelper::tag('link/', $attribs);
break;
case 'script':
$attribs = HtmlHelper::attr(array('src' => DUP_CORE_STYLES_URL . "{$name}.css", 'type' => 'text/javascript', 'charset' => $charset));
return HtmlHelper::tag('script', $attribs, null, null, null) . HtmlHelper::tag('/script', null, null, null);
break;
}
}
示例4: _imageRadio
/**
* Image Radio Control
*
* Enhanced Javascript Control, that allows an array of images, to act as radio
*
* @param string $name
* @param string $options
* @return void
* @author Armando Sosa
*/
function _imageRadio($name, $options)
{
$options = set_merge(array('baseDir' => ''), (array) $options);
$input = HtmlHelper::tag('div.image-radio-group');
foreach ($options['options'] as $value => $image) {
$selected = $value == $options['value'] ? '.selected' : '';
$atts = HtmlHelper::attr(array('title' => $value, 'src' => $options['baseDir'] . $image));
$input .= HtmlHelper::tag('img.radio' . $selected, $atts);
}
$input .= $this->input($name, array('type' => 'hidden', 'value' => $value), false);
$input .= HtmlHelper::tag('/div.image-radio-group');
return $input;
}