本文整理汇总了PHP中K2HelperHTML::radiolist方法的典型用法代码示例。如果您正苦于以下问题:PHP K2HelperHTML::radiolist方法的具体用法?PHP K2HelperHTML::radiolist怎么用?PHP K2HelperHTML::radiolist使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类K2HelperHTML
的用法示例。
在下文中一共展示了K2HelperHTML::radiolist方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getInput
public function getInput()
{
// Load javascript
JHtml::_('jquery.framework');
$document = JFactory::getDocument();
$document->addScript(JURI::root(true) . '/media/k2app/assets/js/fields.js?v=3.0.0');
// Set values if are not set
if (!is_array($this->value)) {
$this->value = array();
}
if (!isset($this->value['enabled'])) {
$this->value['enabled'] = '0';
}
if (!isset($this->value['categories'])) {
$this->value['categories'] = '';
}
if (!isset($this->value['recursive'])) {
$this->value['recursive'] = '';
}
// Get some variables from XML
$this->multiple = (bool) $this->element['k2multiple'];
$this->recursive = (string) $this->element['k2recursive'];
$this->mode = (string) $this->element['k2mode'];
$this->size = (int) $this->element['size'];
// Build attributes string
$attributes = '';
if ($this->multiple) {
$attributes .= ' multiple="multiple"';
}
if ($this->size) {
$attributes .= ' size="' . $this->size . '"';
}
if ($this->mode == 'menu') {
$attributes .= ' data-mode="k2categoriesmenu"';
}
// Init output
$output = '';
// First show the category filter switch for multiple instances
if ($this->multiple) {
$options = array();
$options[] = JHtml::_('select.option', '0', JText::_('K2_ALL'));
$options[] = JHtml::_('select.option', '1', JText::_('K2_SELECT'));
$output .= K2HelperHTML::radiolist($options, $this->name . '[enabled]', $this->value['enabled'], false, 'data-categories="' . $this->name . '[categories][]"');
$placeholder = null;
} else {
$output .= '<input type="hidden" name="' . $this->name . '[enabled]" value="1" />';
$placeholder = 'K2_NONE_ONSELECTLISTS';
}
// Then the categories list
$output .= K2HelperHTML::categories($this->name . '[categories][]', $this->value['categories'], $placeholder, null, $attributes);
// And finally the recursive switch
if ($this->recursive == 'select') {
$options = array();
$options[] = JHtml::_('select.option', '1', JText::_('K2_YES'));
$options[] = JHtml::_('select.option', '0', JText::_('K2_NO'));
$output .= '<label>' . JText::_('K2_APPLY_RECUSRIVELY') . '</label>' . K2HelperHTML::radiolist($options, $this->name . '[recursive]', $this->value['recursive'], true);
} else {
$output .= '<input type="hidden" name="' . $this->name . '[recursive]" value="' . $this->recursive . '" />';
}
// Return
return $output;
}
示例2: categories
public static function categories($name = 'catid', $value = null, $none = false, $exclude = null, $attributes = '', $recursive = false, $valueProperty = 'id', $inheritance = false, $batch = false)
{
$model = K2Model::getInstance('Categories', 'K2Model');
$model->setState('sorting', 'ordering');
$rows = $model->getRows();
$options = array();
if ($none) {
$noneValue = $none === 'K2_LEAVE_UNCHANGED' ? '' : '0';
$options[] = JHtml::_('select.option', $noneValue, JText::_($none));
}
if ($inheritance) {
$options[] = JHtml::_('select.option', '1', JText::_('K2_FROM_K2_CATEGORY_PARAMETERS'));
}
if ($batch) {
$options[] = JHtml::_('select.option', '1', JText::_('K2_NONE'));
}
foreach ($rows as $row) {
if ($exclude != $row->id) {
$title = str_repeat('-', intval($row->level) - 1) . $row->title;
if ($row->state == -1) {
$title .= JText::_('K2_TRASHED_CATEGORY_NOTICE');
} else {
if ($row->state == 0) {
$title .= JText::_('K2_UNPUBLISHED_CATEGORY_NOTICE');
}
}
$optionValue = $row->{$valueProperty};
$options[] = JHtml::_('select.option', $optionValue, $title);
}
}
$output = JHtml::_('select.genericlist', $options, $name, $attributes, 'value', 'text', $value);
if ($recursive) {
$options = array();
$options[] = JHtml::_('select.option', '0', JText::_('K2_NO'));
$options[] = JHtml::_('select.option', '1', JText::_('K2_YES'));
$output .= '<label>' . JText::_($recursive->label) . '</label>' . K2HelperHTML::radiolist($options, $recursive->name, $recursive->value, true);
}
return $output;
}