本文整理汇总了PHP中KHelperArray::toString方法的典型用法代码示例。如果您正苦于以下问题:PHP KHelperArray::toString方法的具体用法?PHP KHelperArray::toString怎么用?PHP KHelperArray::toString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类KHelperArray
的用法示例。
在下文中一共展示了KHelperArray::toString方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _renderLink
/**
* Render script information
*
* @param string The script information
* @param array Associative array of attributes
* @return string
*/
protected function _renderLink($link, $attribs = array())
{
$attribs = KHelperArray::toString($attribs);
$html = '<link href="'.$link.'" '.$attribs.'/>'."\n";
return $html;
}
示例2: radiolist
public function radiolist($config = array())
{
$config = new KConfig($config);
$config->append(array('list' => null, 'name' => 'id', 'attribs' => array(), 'key' => 'id', 'text' => 'title', 'selected' => null, 'translate' => false));
$name = $config->name;
$attribs = KHelperArray::toString($config->attribs);
$html = array();
foreach ($config->list as $row) {
$key = $row->{$config->key};
$text = $config->translate ? JText::_($row->{$config->text}) : $row->{$config->text};
$id = isset($row->id) ? $row->id : null;
$extra = '';
if ($config->selected instanceof KConfig) {
foreach ($config->selected as $value) {
$sel = is_object($value) ? $value->{$config->key} : $value;
if ($key == $sel) {
$extra .= 'selected="selected"';
break;
}
}
} else {
$extra .= $key == $config->selected ? 'checked="checked"' : '';
}
$html[] = '<label class="radio" for="' . $name . $id . '">' . $text;
$html[] = '<input type="radio" name="' . $name . '" id="' . $name . $id . '" value="' . $key . '" ' . $extra . ' ' . $attribs . ' />';
$html[] = '</label>';
}
return implode(PHP_EOL, $html);
}
示例3: groups
public function groups(array $config = array())
{
$config = new KConfig($config);
$config->append(array('name' => 'group', 'core' => null));
$attribs = KHelperArray::toString($config->attribs);
$groups = $this->getService('com://admin/groups.model.groups')->set('core', is_null($config->core) ? null : $config->core)->getList();
if ($config->exclude instanceof KDatabaseRowInterface && $config->exclude->id) {
foreach (clone $groups as $group) {
if ($group->lft >= $config->exclude->lft && $group->rgt <= $config->exclude->rgt) {
$groups->extract($group);
}
}
}
foreach ($groups as $group) {
$checked = $config->selected == $group->id ? ' checked' : '';
if ($group->depth) {
$html[] = '<div style="padding-left: ' . $group->depth * 15 . 'px" class="clearfix">';
$html[] = '<input type="radio" name="' . $config->name . '" id="' . $config->name . $group->id . '" value="' . $group->id . '"' . $checked . ' ' . $attribs . '/>';
$html[] = '<label for="' . $config->name . $group->id . '">' . $group->name . '</label>';
$html[] = '</div>';
} else {
$html[] = '<h4>' . $group->name . '</h4>';
}
}
return implode(PHP_EOL, $html);
}
示例4: _calendar
/**
* Loads the calendar behavior and attaches it to a specified element
*
* @TODO generate patch for 12.3 making this bootstrap friendly
*
* @return string The html output
*/
private function _calendar($config = array())
{
$config = new KConfig($config);
$config->append(array('date' => gmdate("M d Y H:i:s"), 'name' => '', 'format' => '%Y-%m-%d %H:%M:%S', 'attribs' => array('size' => 25, 'maxlenght' => 19, 'class' => 'input-small', 'placeholder' => ''), 'gmt_offset' => JFactory::getConfig()->get('config.offset') * 3600));
if ($config->date && $config->date != '0000-00-00 00:00:00' && $config->date != '0000-00-00') {
$config->date = strftime($config->format, strtotime($config->date));
} else {
$config->date = '';
}
$html = '';
// Load the necessary files if they haven't yet been loaded
if (!isset(self::$_loaded['calendar'])) {
$html .= '<script src="media://lib_koowa/js/calendar.js" />';
$html .= '<script src="media://lib_koowa/js/calendar-setup.js" />';
$html .= '<style src="media://lib_koowa/css/calendar.css" />';
$html .= '<script>' . $this->_calendarTranslation() . '</script>';
self::$_loaded['calendar'] = true;
}
$html .= "<script>\n\t\t\t\t\twindow.addEvent('domready', function() {Calendar.setup({\n \t\t\t\tinputField : '" . $config->name . "',\n \t\t\t\tifFormat : '" . $config->format . "',\n \t\t\t\tbutton : 'button-" . $config->name . "',\n \t\t\t\talign : 'Tl',\n \t\t\t\tsingleClick : true,\n \t\t\t\tshowsTime\t : false\n \t\t\t\t});});\n \t\t\t</script>";
$attribs = KHelperArray::toString($config->attribs);
$html .= '<div class="input-append">';
$html .= '<input type="text" name="' . $config->name . '" id="' . $config->name . '" value="' . $config->date . '" ' . $attribs . ' />';
$html .= '<button type="button" id="button-' . $config->name . '" class="btn" >';
$html .= '<i class="icon-calendar"></i>‌';
//‌ is a zero width non-joiner, helps the button get the right height without adding to the width (like with )
$html .= '</button>';
$html .= '</div>';
return $html;
}
示例5: template
/**
* Checks to see if an image exists in the current templates image directory
* if it does it loads this image. Otherwise the default image is loaded.
*
* @param string The file name, eg foobar.png
* @param string The path to the image
* @param string Alt text
* @param array An associative array of attributes to add
* @param boolean True (default) to display full tag, false to return just the path
*/
public static function template($file, $folder = 'media/', $alt = NULL, $attribs = null, $toHtml = 1)
{
static $paths;
if (!$paths) {
$paths = array();
}
if (is_array($attribs)) {
$attribs = KHelperArray::toString($attribs);
}
$template = KFactory::get('lib.joomla.application')->getTemplate();
$path = JPATH_BASE . '/templates/' . $template . '/images/' . $file;
if (!isset($paths[$path])) {
if (file_exists(JPATH_BASE . '/templates/' . $template . '/images/' . $file)) {
$paths[$path] = 'templates/' . $template . '/images/' . $file;
} else {
// outputs only path to image
$paths[$path] = $folder . $file;
}
}
$src = $paths[$path];
// Prepend the base path
$src = JURI::base(true) . '/' . $src;
// outputs actual html <img> tag
if ($toHtml) {
return '<img src="' . $src . '" alt="' . html_entity_decode($alt) . '" ' . $attribs . ' />';
}
return $src;
}
示例6: startPanel
/**
* Creates a tab panel with title and starts that panel
*
* @param array An optional array with configuration options
* @return string Html
*/
public function startPanel($config = array())
{
$config = new KConfig($config);
$config->append(array('title' => '', 'attribs' => array(), 'options' => array(), 'translate' => true));
$title = $config->translate ? JText::_($config->title) : $config->title;
$attribs = KHelperArray::toString($config->attribs);
return '<dt ' . $attribs . '><span>' . $title . '</span></dt><dd>';
}
示例7: startPanel
/**
* Creates a tab panel with title and starts that panel
*
* @param string The title of the tab
* @param array An associative array of pane attributes
*/
public function startPanel($config = array())
{
$config = new KConfig($config);
$config->append(array('title' => 'Slide', 'attribs' => array(), 'translate' => true));
$title = $config->translate ? JText::_($config->title) : $config->title;
$attribs = KHelperArray::toString($config->attribs);
$html = '<div class="panel"><h3 class="jpane-toggler title" ' . $attribs . '><span>' . $title . '</span></h3><div class="jpane-slider content">';
return $html;
}
示例8: fetchElement
public function fetchElement($name, $value, &$node, $control_name)
{
$config = new KConfig();
$config->append(array('name' => 'id', 'attribs' => array(), 'key' => 'id', 'text' => 'title', 'selected' => $value, 'translate' => false));
$name = $config->name;
$attribs = KHelperArray::toString($config->attribs);
$options = array();
foreach ($node->children() as $option) {
$options[] = (object) array($config->key => $option['value'], $config->text => (string) $option);
}
$config->list = $options;
$class = isset($node['class']) ? $node['class'] : 'value';
$html = array('<ul id="' . $this->name . '_id" class="' . $class . '">');
foreach ($config->list as $row) {
$key = $row->{$config->key};
$text = $config->translate ? JText::_($row->{$config->text}) : $row->{$config->text};
$id = isset($row->id) ? $row->id : null;
$extra = '';
if ($config->selected instanceof KConfig) {
foreach ($config->selected as $value) {
$sel = is_object($value) ? $value->{$config->key} : $value;
if ($key == $sel) {
$extra .= 'checked="checked"';
break;
}
}
} else {
$extra .= $key == $config->selected ? 'checked="checked"' : '';
}
$html[] = '<li class="value">';
$html[] = '<label for="' . $this->name . '_' . $key . '"><input type="checkbox" name="' . $this->name . '[]" id="' . $this->name . '_' . $key . '" value="' . $key . '" ' . $extra . ' ' . $attribs . ' />' . $text . '</label>';
$html[] = '</li>';
}
$html[] = '</ul>';
return implode(PHP_EOL, $html);
$options = array();
foreach ($node->children() as $option) {
$val = (string) $option['value'];
$text = (string) $option;
$options[] = (object) array('value' => $val, 'text' => $text);
}
$vertical = isset($node['vertical']) ? ' vertical' : null;
$html[] = '<ul class="group' . $vertical . '">';
$realname = $this->field . '[' . $this->group . '][' . $name . ']';
$idname = $this->field . '_' . $this->group . '_' . $name;
$checklist = KTemplateHelperSelect::checklist($options, $realname, $value, array('id' => '{id}'), 'value', 'text');
$search = array('for="' . $realname, 'id="' . $realname);
$replace = array('for="' . $idname, 'id="' . $idname);
$checklist = str_replace($search, $replace, $checklist);
foreach (explode('</label>', $checklist) as $check) {
$html[] = '<li class="value">';
$html[] = $check;
$html[] = '</label></li>';
}
$html[] = '</ul>';
return implode($html);
}
示例9: input
/**
* Renders the input element, with the accept attribute set when needed
*
* @author Stian Didriksen <stian@ninjaforge.com>
* @return string
*/
public function input($config = array())
{
$config = new KConfig($config);
$config->append(array('attributes' => array('name' => 'attachments[]', 'type' => 'file')));
$params = JComponentHelper::getParams('com_media');
if (!$params->get('check_mime', false)) {
$config->attributes->append(array('accept' => htmlspecialchars($params->get('upload_mime'))));
}
return '<input ' . KHelperArray::toString($config->attributes->toArray()) . '/>';
}
示例10: _renderStyle
/**
* Render style information
*
* @param string The style information
* @param boolean True, if the style information is a URL
* @param array Associative array of attributes
* @return string
*/
protected function _renderStyle($style, $link, $attribs = array())
{
$attribs = KHelperArray::toString($attribs);
if (!$link) {
$html = '<style type="text/css" ' . $attribs . '>' . "\n";
$html .= trim($style['data']);
$html .= '</style>' . "\n";
} else {
$html = '<link type="text/css" rel="stylesheet" href="' . $style . '" ' . $attribs . ' />' . "\n";
}
return $html;
}
示例11: _renderScript
/**
* Render script information
*
* @param string The script information
* @param boolean True, if the script information is a URL.
* @param array Associative array of attributes
* @return string
*/
protected function _renderScript($script, $link, $attribs = array())
{
$attribs = KHelperArray::toString($attribs);
if (!$link) {
$html = '<script type="text/javascript" ' . $attribs . '>' . "\n";
$html .= trim($script);
$html .= '</script>' . "\n";
} else {
$html = '<script type="text/javascript" src="' . $script . '" ' . $attribs . '></script>' . "\n";
}
return $html;
}
示例12: write
/**
* Fixes blockquotes.
*
* @param string Block of text to parse
*
* @return KTemplateFilterLink
*/
public function write(&$text)
{
$matches = array();
if (preg_match_all('/<a(.*?)>/', $text, $matches)) {
foreach ($matches[1] as $index => $match) {
$attribs = $this->_parseAttributes($match);
$attribs['style'] = 'color:#076da0;text-decoration:none';
$attribs = KHelperArray::toString($attribs);
$text = str_replace($matches[0][$index], '<a ' . $attribs . ' >', $text);
}
}
return $this;
}
示例13: select
public function select($config = array())
{
$config = new KConfig($config);
$config->append(array('name' => '', 'attribs' => array(), 'visible' => true, 'link' => '', 'link_text' => $this->translate('Select'), 'link_selector' => 'modal'))->append(array('id' => $config->name, 'value' => $config->name));
$attribs = KHelperArray::toString($config->attribs);
$input = '<input name="%1$s" id="%2$s" value="%3$s" %4$s size="40" %5$s />';
$link = '<a class="%s btn"
rel="{\'handler\': \'iframe\', \'size\': {\'x\': 690}}"
href="%s">%s</a>';
$html = sprintf($input, $config->name, $config->id, $config->value, $config->visible ? 'type="text" readonly' : 'type="hidden"', $attribs);
$html .= sprintf($link, $config->link_selector, $config->link, $config->link_text);
return $html;
}
示例14: calendar
public function calendar($config = array())
{
$config = new KConfig($config);
$config->append(array(
'date' => gmdate("M d Y H:i:s"),
'name' => '',
'format' => '%Y-%m-%d %H:%M:%S',
'attribs' => array('size' => 25, 'maxlenght' => 19),
'gmt_offset' => KFactory::get('joomla:config')->getValue('config.offset') * 3600
));
if(!is_numeric($config->date)) {
$config->date = strtotime($config->date);
}
if($config->date) {
$config->date = strftime($config->format, $config->date /*+ $config->gmt_offset*/);
}
$html = '';
// Load the necessary files if they haven't yet been loaded
if (!isset(self::$_loaded['calendar']))
{
$html .= '<script src="media://system/js/calendar.js" />';
$html .= '<script src="media://system/js/calendar-setup.js" />';
$html .= '<style src="media://system/css/calendar-jos.css" />';
$html .= '<script>'.$this->_calendartranslation().'</script>';
self::$_loaded['calendar'] = true;
}
$html .= "<script>
window.addEvent('domready', function() {Calendar.setup({
inputField : '".$config->name."',
ifFormat : '".$config->format."',
button : 'button-".$config->name."',
align : 'Tl',
singleClick : true,
showsTime : false
});});
</script>";
$attribs = KHelperArray::toString($config->attribs);
$html .= '<input type="text" name="'.$config->name.'" id="'.$config->name.'" value="'.$config->date.'" '.$attribs.' />';
$html .= '<img class="calendar" src="media://system/images/calendar.png" alt="calendar" id="button-'.$config->name.'" />';
return $html;
}
示例15: original
public function original($config)
{
$config = new KConfig($config);
$config->append(array('attribs' => array('class' => 'original-lang')));
$item = $config->item;
$html = '';
if ($item->isTranslatable() && !$item->translated) {
$original = $this->getService('com://admin/translations.model.translations')->table($item->getTable()->getName())->row($item->id)->original(1)->getItem();
if ($original->iso_code != $item->language && $original->id) {
$html .= '<span ' . KHelperArray::toString($config->attribs) . '>' . $this->translate('ONLY_AVAILABLE_' . strtoupper($original->lang) . '_SHORT') . '</span>';
}
}
return $html;
}