/** * Create a route for a document * * @param array|KObjectConfig $config * @param bool $fqr * @param bool $escape * @return string Routed URL */ public function document($config = array(), $fqr = false, $escape = true) { $config = new KObjectConfigJson($config); $config->append(array('admin_link' => JFactory::getApplication()->isAdmin())); // Return a generic link for administrator if ($config->admin_link) { return $this->entity($config); } unset($config->admin_link); $document = $config->entity; $query = array('option' => 'com_docman', 'view' => 'document', 'alias' => $document->alias); if ($document->category_slug) { $query['category_slug'] = $document->category_slug; } if (!$config->Itemid) { $menu = JApplication::getInstance('site')->getMenu()->getActive(); if ($menu && $menu->query['view'] === 'userlist') { $query['Itemid'] = $document->itemid; } } $config->append($query); $route = $this->_getRoute($config, $fqr, $escape); $query = $route->getQuery(true); if (isset($query['view']) && $query['view'] === 'download') { unset($query['format']); $route->setQuery($query); } return $route; }
public function manage($config = array()) { $config = new KObjectConfigJson($config); if ($entity = $config->entity) { $table = $entity->getTable(); $config->append(array('table' => $table->getBase(), 'row' => $entity->id)); } $config->append(array('id' => 'attachments-manage', 'value' => array(), 'callback' => 'attachmentsCallback', 'multiple' => true, 'text' => $this->getObject('translator')->translate('Manage'), 'attribs' => array('data-k-modal' => htmlentities(json_encode(array('mainClass' => 'koowa_dialog_modal koowa_dialog_modal--halfheight'))))))->append(array('link' => $this->getTemplate()->route('view=attachments&layout=manage&tmpl=koowa&table=' . urlencode($config->table) . '&row=' . urlencode($config->row) . '&callback=' . urlencode($config->callback)))); $html = '<span class="input-group-btn">'; $html .= sprintf('<a id="%s" class="btn mfp-iframe" %s href="%s">%s</a>', $config->id, $config->attribs, $config->link, $config->text); $html .= '</span>'; $html .= $this->getTemplate()->createHelper('behavior')->modal(); return $html; }
/** * Render item pagination * * @param array $config An optional array with configuration options * @return string Html * @see http://developer.yahoo.com/ypatterns/navigation/pagination/ */ public function pagination($config = array()) { $config = new KObjectConfigJson($config); $config->append(array( 'limit' => 0, )); $translator = $this->getObject('translator'); $html = '<div class="container" id="files-paginator-container">'; $html .= '<div class="pagination pagination-toolbar" id="files-paginator">'; $html .= '<div class="limit">'.$this->limit($config->toArray()).'</div>'; $html .= '<span class="start hidden"><a></a></span>'; $html .= '<ul class="pagination-list">'; $html .= $this->_pages(array()); $html .= '</ul>'; $html .= '<span class="end hidden"><a></a></span>'; $html .= '<div class="limit pull-right"> '; $html .= sprintf($translator->translate('JLIB_HTML_PAGE_CURRENT_OF_TOTAL'), '<strong class="page-current">1</strong>', '<strong class="page-total">1</strong></div>'); $html .= '</div>'; $html .= '</div>'; return $html; }
public function rules($config = array()) { $config = new KObjectConfigJson($config); $config->append(array( 'component' => 'com_docman', 'section' => 'component', 'name' => 'rules', 'asset' => null, 'asset_id' => 0 ))->append(array( 'id' => $config->name )); $xml = <<<EOF <form> <fieldset> <field name="asset_id" type="hidden" value="{$config->asset_id}" /> <field name="{$config->name}" type="rules" label="JFIELD_RULES_LABEL" translate_label="false" class="inputbox" filter="rules" component="{$config->component}" section="{$config->section}" validate="rules" id="{$config->id}" /> </fieldset> </form> EOF; $form = JForm::getInstance('com_docman.document.acl', $xml); $form->setValue('asset_id', null, $config->asset_id); return $form->getInput('rules'); }
/** * Render the action bar title * * @param array $config An optional array with configuration options * @return string Html */ public function title($config = array()) { $config = new KObjectConfigJson($config); $config->append(array('command' => NULL)); $title = $this->getObject('translator')->translate($config->command->title); $icon = $config->command->icon; $html = ''; if (!empty($title)) { if (JFactory::getApplication()->isAdmin() && version_compare(JVERSION, '3.2', 'ge')) { $layout = new JLayoutFile('joomla.toolbar.title'); $html = $layout->render(array('title' => $title, 'icon' => $icon)); } elseif ($this->_useBootstrap()) { // Strip the extension. $icons = explode(' ', $icon); foreach ($icons as &$icon) { $icon = 'pagetitle--' . preg_replace('#\\.[^.]*$#', '', $icon); } $html = '<div class="pagetitle ' . htmlspecialchars(implode(' ', $icons)) . '"><h2>' . $title . '</h2></div>'; } else { $html = '<div class="header pagetitle icon-48-' . $icon . '">'; $html .= '<h2>' . $title . '</h2>'; $html .= '</div>'; } if (JFactory::getApplication()->isAdmin()) { $app = JFactory::getApplication(); $app->JComponentTitle = $html; $html = ''; JFactory::getDocument()->setTitle($app->getCfg('sitename') . ' - ' . JText::_('JADMINISTRATION') . ' - ' . $title); } } return $html; }
/** * Creates a tab panel with title and starts that panel * * @param array|KObjectConfig $config An optional array with configuration options * @return string Html */ public function startPanel($config = array()) { $translator = $this->getObject('translator'); $config = new KObjectConfigJson($config); $config->append(array('title' => $translator->translate('Slide'), 'id' => '', 'translate' => true)); $title = $config->translate ? $translator->translate($config->title) : $config->title; return JHtml::_('sliders.panel', $title, KObjectConfig::unbox($config->attribs)); }
public function truncate($config = array()) { $config = new KObjectConfigJson($config); $config->append(array('text' => '', 'offset' => 0, 'length' => 100, 'pad' => '...')); // Don't show endstring if actual string length is less than cutting length $config->pad = mb_strlen($config->text) < $config->length ? '' : $config->pad; return mb_substr(strip_tags($config->text), $config->offset, $config->length) . $config->pad; }
/** * Render an state field * * @param array $config An optional array with configuration options * @return string Html */ public function state($config = array()) { $config = new KObjectConfigJson($config); $config->append(array( 'entity' => null, 'field' => 'enabled', 'clickable' => true ))->append(array( 'data' => array($config->field => $config->entity->{$config->field}) )); $entity = $config->entity; $translator = $this->getObject('translator'); // Enabled, but pending if ($entity->enabled && !$entity->published && !$entity->expired && $entity->publish_on !== null) { $access = 0; $group = $translator->translate('Pending'); $date = $this->getTemplate()->helper('date.humanize', array('date' => $entity->publish_on)); $tip = $translator->translate('Will be published {date}, click to unpublish item', array( 'date' => $date)); $color = '#c09853'; } // Enabled, but expired else if ($entity->enabled && !$entity->published && $entity->expired && $entity->unpublish_on !== null) { $access = 0; $group = $translator->translate('Expired'); $date = $this->getTemplate()->helper('date.humanize', array('date' => $entity->unpublish_on)); $tip = $translator->translate('Expired {on}, click to unpublish item', array('on' => $date)); $color = '#3a87ad'; } elseif (!$entity->enabled) { $access = 1; $group = $translator->translate('Unpublished'); $tip = $translator->translate('Publish item'); $color = '#b94a48'; } else { $access = 0; $group = $translator->translate('Published'); $tip = $translator->translate('Unpublish item'); $color = '#468847'; } $config->data->{$config->field} = $access; $data = str_replace('"', '"', $config->data); $html = '<span style="cursor: pointer;color:'.$color.'" data-action="edit" data-data="'.$data.'" title="'.$tip.'">'.$group.'</span>'; return $html; }
/** * Creates a tab panel with title and starts that panel * * @param array $config An optional array with configuration options * @return string Html */ public function startPanel($config = array()) { $config = new KObjectConfigJson($config); $config->append(array('title' => '', 'class' => '', 'translate' => true)); $title = $config->translate ? $this->getObject('translator')->translate($config->title) : $config->title; $class = KObjectConfig::unbox($config->class); if (is_array($class)) { $class = implode(' ', $class); } return JHtml::_('tabs.panel', $title, $class); }
/** * Generates an HTML editor * * @param array $config An optional array with configuration options * @return string Html */ public function display($config = array()) { $config = new KObjectConfigJson($config); $config->append(array('editor' => null, 'name' => 'description', 'value' => '', 'width' => '100%', 'height' => '500', 'cols' => '75', 'rows' => '20', 'buttons' => true, 'options' => array())); $editor = JFactory::getEditor($config->editor); $options = KObjectConfig::unbox($config->options); $result = $editor->display($config->name, $config->value, $config->width, $config->height, $config->cols, $config->rows, KObjectConfig::unbox($config->buttons), $config->name, null, null, $options); // Some editors like CKEditor return inline JS. $result = str_replace('<script', '<script data-inline', $result); return $result; }
/** * Render the menu bar * * @param array $config An optional array with configuration options * @return string Html */ public function render($config = array()) { $config = new KObjectConfigJson($config); $config->append(array('toolbar' => null)); foreach ($config->toolbar->getCommands() as $command) { if (!empty($command->href)) { $command->href = $this->getTemplate()->route($command->href); } JSubmenuHelper::addEntry($this->getObject('translator')->translate($command->label), $command->href, $command->active); } return ''; }
/** * Generates an HTML access listbox * * @param array $config An optional array with configuration options * @return string Html */ public function access($config = array()) { $config = new KObjectConfigJson($config); $config->append(array('name' => 'access', 'attribs' => array(), 'deselect_value' => '', 'deselect' => true, 'prompt' => '- ' . $this->getObject('translator')->translate('Select') . ' -'))->append(array('selected' => $config->{$config->name})); $prompt = false; // without Joomla strips the last hyphen of the prompt if ($config->deselect) { $prompt = array((object) array('value' => $config->deselect_value, 'text' => $config->prompt . ' ')); } $html = JHtml::_('access.level', $config->name, $config->selected, $config->attribs->toArray(), $prompt); return $html; }
/** * Makes links delete actions * * Used in frontend delete buttons * * @param array $config * @return string */ public function deletable($config = array()) { $config = new KObjectConfigJson($config); $config->append(array('selector' => '.todo-deletable', 'confirm_message' => $this->getObject('translator')->translate('You will not be able to bring this task back if you delete it. Would you like to continue?'))); $html = $this->koowa(); $signature = md5(serialize(array($config->selector, $config->confirm_message))); if (!isset(self::$_loaded[$signature])) { $html .= "\n <script>\n kQuery(function(\$) {\n \$('{$config->selector}').on('click', function(event){\n event.preventDefault();\n\n var target = \$(event.target);\n\n if (!target.hasClass('disabled') && confirm('{$config->confirm_message}')) {\n new Koowa.Form(\$.parseJSON(target.prop('rel'))).submit();\n }\n });\n });\n </script>\n "; self::$_loaded[$signature] = true; } return $html; }
/** * Render item pagination * * @param array $config An optional array with configuration options * @return string Html * @see http://developer.yahoo.com/ypatterns/navigation/pagination/ */ public function pagination($config = array()) { $config = new KObjectConfigJson($config); $config->append(array('limit' => 0)); $html = '<div class="k-pagination" id="files-paginator">'; $html .= '<div class="k-pagination__limit">' . $this->limit($config->toArray()) . '</div>'; $html .= '<span class="start hidden"><a></a></span>'; $html .= '<ul class="k-pagination__pages pagination">'; $html .= $this->_pages(array()); $html .= '</ul>'; $html .= '<span class="end hidden"><a></a></span>'; return $html; }
public function script($config = array()) { $config = new KObjectConfigJson($config); $config->append(array('strings' => array())); $strings = KObjectConfig::unbox($config->strings); $translator = $this->getObject('translator'); $translations = array(); foreach ($strings as $string) { $translations[$string] = $translator->translate($string); } $html = ''; $html .= $this->getTemplate()->helper('behavior.koowa') . "<script>\n if (typeof Koowa === 'object' && Koowa !== null) {\n if (typeof Koowa.translator === 'object' && Koowa.translator !== null) {\n Koowa.translator.loadTranslations(" . json_encode($translations) . ");\n }\n }\n </script>\n "; return $html; }
public function icon($config = array()) { $config = new KObjectConfigJson($config); $config->append(array('name' => '', 'attribs' => array(), 'visible' => true, 'link' => '', 'callback' => 'Docman.selectIcon'))->append(array('id' => $config->name, 'value' => $config->name)); if ($config->callback) { $config->link .= '&callback=' . urlencode($config->callback); } $attribs = $this->buildAttributes($config->attribs); $link = '<a class="koowa-modal mfp-iframe" data-koowa-modal="%s" href="%s">%s</a>'; $html = sprintf($link, htmlentities(json_encode(array('mainClass' => 'koowa_dialog_modal'))), $config->link, $config->link_text); $input = '<input name="%1$s" id="%2$s" value="%3$s" %4$s size="40" %5$s style="display:none" />'; $html .= sprintf($input, $config->name, $config->id, $config->value, $config->visible ? 'type="text" readonly' : 'type="hidden"', $attribs); $html .= $this->getTemplate()->createHelper('behavior')->modal(); return $html; }
/** * Gets the icon for the given extension * * @param array|KObjectConfig $config * @return string Icon class, "default" if the extension doesn't exist in the map */ public function icon($config = array()) { $config = new KObjectConfigJson($config); $config->append(array('extension' => null)); $icon = 'default'; if ($config->extension) { $extension = strtolower($config->extension); foreach (self::$icon_extension_map as $type => $extensions) { if (in_array($extension, $extensions)) { $icon = $type; break; } } } return $icon; }
/** * Loads necessary Bootstrap files * * {@inheritdoc} */ public function load($config = array()) { $config = new KObjectConfigJson($config); if ($menu = JFactory::getApplication()->getMenu()->getActive()) { if ($suffix = htmlspecialchars($menu->params->get('pageclass_sfx'))) { $config->append(array( 'class' => array($suffix) )); } } return parent::load($config); }
public function humanize($config = array()) { $config = new KObjectConfigJson($config); $config->append(array('sizes' => array('B', 'KB', 'MB', 'GB', 'TB', 'PB'))); $bytes = $config->size; $result = ''; $format = ($bytes > 1024 * 1024 && $bytes % 1024 !== 0 ? '%.2f' : '%d') . ' %s'; foreach ($config->sizes as $s) { $size = $s; if ($bytes < 1024) { $result = $bytes; break; } $bytes /= 1024; } return sprintf($format, $result, $this->getObject('translator')->translate($size)); }
/** * Render an access field * * @param array $config An optional array with configuration options * @return string Html */ public function access($config = array()) { $config = new KObjectConfigJson($config); $config->append(array('entity' => null, 'field' => 'access')); $db = JFactory::getDbo(); $query = $db->getQuery(true); $query->select('a.title AS text'); $query->from('#__viewlevels AS a'); $query->where('id = ' . (int) $config->entity->{$config->field}); $query->group('a.id, a.title, a.ordering'); $query->order('a.ordering ASC'); $query->order($query->qn('title') . ' ASC'); // Get the options. $db->setQuery($query); $html = $db->loadResult(); return $html; }
public function select($config = array()) { $config = new KObjectConfigJson($config); $config->append(array('name' => '', 'attribs' => array(), 'button_attribs' => array(), 'visible' => true, 'link' => '', 'link_text' => $this->getObject('translator')->translate('Select'), 'callback' => ''))->append(array('id' => $config->name, 'value' => $config->name)); if ($config->callback) { $config->link .= '&callback=' . urlencode($config->callback); } $config->link = preg_replace_callback('#folder=(.*?)&#i', array($this, '_encodingFixer'), $config->link); $attribs = $this->buildAttributes($config->attribs); $button_attribs = $this->buildAttributes($config->button_attribs); $input = '<input name="%1$s" id="%2$s" value="%3$s" %4$s size="40" %5$s />'; $html = sprintf($input, $config->name, $config->id, $this->getTemplate()->escape($config->value), $config->visible ? 'type="text" readonly' : 'type="hidden"', $attribs); $html .= '<span class="input-group-btn">'; $html .= sprintf('<a data-k-modal class="btn mfp-iframe" %s href="%s">%s</a>', $button_attribs, $config->link, $config->link_text); $html .= '</span>'; $html .= $this->getTemplate()->createHelper('behavior')->modal(); return $html; }
/** * Render item pagination * * @see http://developer.yahoo.com/ypatterns/navigation/pagination/ * * @param array $config An optional array with configuration options * * @return string Html */ public function pagination($config = array()) { $config = new KObjectConfigJson($config); $config->append(array('total' => 0, 'display' => 2, 'offset' => 0, 'limit' => 0, 'show_limit' => true, 'show_count' => false, 'show_pages' => true)); $this->_initialize($config); $translator = $this->getObject('translator'); $html = '<div class="pagination pagination-toolbar">'; if ($config->show_limit) { $html .= '<div class="limit">' . $this->limit($config) . '</div>'; } if ($config->show_pages) { $html .= '<ul class="pagination-list">'; $html .= $this->_pages($this->_items($config)); $html .= '</ul>'; } if ($config->show_count) { $html .= sprintf($translator->translate('JLIB_HTML_PAGE_CURRENT_OF_TOTAL'), $config->current, $config->count); } $html .= '</div>'; return $html; }
public function uploader($config = array()) { $config = new KObjectConfigJson($config); $config->append(array('element' => null, 'attributes' => array('class' => array('k-upload')), 'options' => array('url' => null, 'multipart_params' => array('csrf_token' => $this->getObject('user')->getSession()->getToken()), 'multi_selection' => false, 'autostart' => true)))->append(array('selector' => $config->element)); $html = ''; if (!isset(static::$_loaded['uploader'])) { $template = $this->getTemplate(); if ($template->hasFilter('wrapper')) { $filter = $template->getFilter('wrapper'); $wrapper = $filter->getWrapper(); $filter->setWrapper(null); } $html .= $template->loadFile('com:files.files.uploader_scripts.html')->render(); if ($template->hasFilter('wrapper')) { $filter->setWrapper($wrapper); } self::$_loaded['uploader'] = true; } if (is_object($config->options->url)) { $config->options->url = (string) $config->options->url; } $html .= '<script> kQuery(function($){ $("' . $config->selector . '").uploader(' . $config->options . '); });</script>'; if ($config->element) { $element = $config->element; $attributes = $config->attributes->toArray(); if ($element[0] === '#') { $attributes['id'] = substr($element, 1); } else { $attributes['class'][] = substr($element, 1); } $html .= sprintf('<div %s></div>', $this->buildAttributes($attributes)); } return $html; }
/** * Loads the Koowa customized jQtree behavior and renders a sidebar-nav list useful in split views * * @see http://mbraak.github.io/jqTree/ * * @note If no 'element' option is passed, then only assets will be loaded. * * @param array|KObjectConfig $config * @throws InvalidArgumentException * @return string The html output */ public function tree($config = array()) { $config = new KObjectConfigJson($config); $config->append(array('debug' => false, 'element' => '', 'selected' => '', 'list' => array()))->append(array('options' => array('selected' => $config->selected))); $html = ''; /** * Loading the assets, if not already loaded */ if (!isset(self::$_loaded['tree'])) { $html .= $this->koowa(); $html .= '<ktml:script src="media://koowa/com_koowa/js/tree.jquery' . ($config->debug ? '' : '.min') . '.js" />'; $html .= '<ktml:script src="media://koowa/com_koowa/js/koowa.tree' . ($config->debug ? '' : '.min') . '.js" />'; self::$_loaded['tree'] = true; } /** * Parse and validate list data, if any. And load the inline js that initiates the tree on specified html element */ $signature = md5('tree-' . $config->element); if ($config->element && !isset(self::$_loaded[$signature])) { /** * If there's a list set, but no 'data' in the js options, parse it */ if (isset($config->list) && !isset($config->options->data)) { $data = array(); foreach ($config->list as $item) { $parts = explode('/', $item->path); array_pop($parts); // remove current id $data[] = array('label' => $item->title, 'id' => (int) $item->id, 'level' => (int) $item->level, 'path' => $item->path, 'parent' => (int) array_pop($parts)); } $config->options->append(array('data' => $data)); } elseif (isset($config->options->data, $config->options->data[0])) { $data = $config->options->data[0]; $required = array('label', 'id', 'level', 'path', 'parent'); foreach ($required as $key) { if (!isset($data[$key])) { throw new InvalidArgumentException('Data must contain required param: ' . $key); } } } $options = $config->options; $html .= '<script> kQuery(function($){ new Koowa.Tree(' . json_encode($config->element) . ', ' . $options . '); });</script>'; self::$_loaded[$signature] = true; } return $html; }
/** * Get the locked information * * @param array|KObjectConfig $config An optional configuration array. * @throws UnexpectedValueException * @return string The locked by "name" "date" message */ public function lock_message($config = array()) { $config = new KObjectConfigJson($config); $config->append(array('entity' => null)); if (!$config->entity instanceof KModelEntityInterface) { throw new UnexpectedValueException('$config->entity should be a KModelEntityInterface instance'); } $entity = $config->entity; $message = ''; if ($entity->isLockable() && $entity->isLocked()) { $user = $entity->getLocker(); $date = $this->getObject('date', array('date' => $entity->locked_on)); $message = $this->getObject('translator')->translate('Locked by {name} {date}', array('name' => $user->getName(), 'date' => $date->humanize())); } return $message; }
/** * Removes Joomla root from a filename replacing them with the plain text equivalents. * * @param array $config An optional array with configuration options * @return string Html */ public function path($config = array()) { $config = new KObjectConfigJson($config); $config->append(array('root' => JPATH_ROOT)); return parent::path($config); }
/** * Renders a listbox with autocomplete behavior * * @see ComKoowaTemplateHelperBehavior::_listbox * * @param array|KObjectConfig $config * @return string The html output */ protected function _autocomplete($config = array()) { $config = new KObjectConfigJson($config); $config->append(array('name' => '', 'attribs' => array(), 'model' => KStringInflector::pluralize($this->getIdentifier()->package), 'validate' => true, 'filter' => array()))->append(array('element' => $config->attribs->id ? '#' . $config->attribs->id : 'input[name=' . $config->name . ']', 'options' => array('multiple' => (bool) $config->attribs->multiple), 'deselect' => true, 'prompt' => '- ' . $this->getObject('translator')->translate('Select') . ' -', 'unique' => true, 'select2' => false, 'value' => $config->name, 'selected' => $config->{$config->name}, 'identifier' => 'com://' . $this->getIdentifier()->domain . '/' . $this->getIdentifier()->package . '.model.' . $config->model))->append(array('label' => $config->value))->append(array('text' => $config->label, 'filter' => array('sort' => $config->label))); if (!$config->url) { $identifier = $this->getIdentifier($config->identifier); $parts = array('component' => $identifier->package, 'view' => $identifier->name, 'format' => 'json'); if ($config->filter) { $parts = array_merge($parts, KObjectConfig::unbox($config->filter)); } $config->url = $this->getTemplate()->route($parts, false, false); } $html = ''; // TODO: Remove when select2 properly support AJAX multiple listboxes by sending choices // as an array (presumably for v4). if ($config->attribs->multiple) { $html .= '<script> kQuery(function($) { var el = $("' . $config->element . '"); var form = el.closest("form"); var explode = function(e) { if (el.val()) { if (el.attr("name").substr(-2) !== "[]") { // Make the input an array. el.attr("name", el.attr("name") + "[]"); } var values = el.val().split(","); $.each(values, function(idx, value) { form.append(el.clone().val(value)); }); el.remove(); } else { // If there is no value, then we remove the element anyways to mimic a real select box. el.remove(); } }; if (form.hasClass("-koowa-form") || form.hasClass("-koowa-grid")) { form.submit(explode); } else { // See: https://github.com/joomla/joomla-cms/pull/5914 for why we use onsubmit var element = form.get(0), previous = element.onsubmit; element.onsubmit = function() { if (typeof previous === "function") { previous(); } explode(); // Avoid explode to be executed more than once. element.onsubmit = previous; }; } });</script>'; } $html .= $this->getTemplate()->createHelper('behavior')->autocomplete($config); $config->attribs->name = $config->name; if ($config->selected) { //Compose the selected array if ($config->selected instanceof KModelEntityInterface) { $selected = array(); foreach ($config->selected as $entity) { $selected[] = $entity->{$config->value}; } $config->selected = $selected; } $config->attribs->value = json_encode(KObjectConfig::unbox($config->selected)); } $attribs = $this->buildAttributes($config->attribs); $html .= "<input type=\"hidden\" {$attribs} />"; return $html; }
/** * Returns formatted date according to current local * * @param array $config An optional array with configuration options. * @return string Formatted date. */ public function format($config = array()) { $config = new KObjectConfigJson($config); $config->append(array('date' => 'now', 'timezone' => true, 'format' => $this->getObject('translator')->translate('DATE_FORMAT_LC3'))); return JHtml::_('date', $config->date, $config->format, $config->timezone); }
/** * Returns an array of HTML strings that represent each step in the backtrace. * * @param array $config An optional array with configuration options * @return string Html */ public function trace($config = array()) { $config = new KObjectConfigJson($config); $config->append(array('trace' => null, 'statements' => array('include', 'include_once', 'require', 'require_once'))); $trace = $config->trace; // Start a new trace if ($trace === NULL) { $trace = debug_backtrace(); } $output = array(); foreach ($trace as $step) { // Invalid trace step if (!isset($step['function'])) { continue; } // Include the source of this step if (isset($step['file']) and isset($step['line'])) { $source = $this->source(array('file' => $step['file'], 'line' => $step['line'])); } if (isset($step['file'])) { $file = $step['file']; if (isset($step['line'])) { $line = $step['line']; } } // function() $function = $step['function']; // Non-standard function calls if (in_array($step['function'], $config->statements->toArray())) { // No arguments if (empty($step['args'])) { $args = array(); } else { $args = array($step['args'][0]); } } elseif (isset($step['args'])) { $params = NULL; // Introspection on closures or language constructs in a stack trace is impossible if (function_exists($step['function']) || strpos($step['function'], '{closure}') === FALSE) { if (isset($step['class'])) { if (method_exists($step['class'], $step['function'])) { $reflection = new ReflectionMethod($step['class'], $step['function']); } else { $reflection = new ReflectionMethod($step['class'], '__call'); } } else { $reflection = new ReflectionFunction($step['function']); } // Get the function parameters $params = $reflection->getParameters(); } $args = array(); foreach ($step['args'] as $i => $arg) { if (isset($params[$i])) { $args[$params[$i]->name] = $arg; // Assign the argument by the parameter name } else { $args[$i] = $arg; // Assign the argument by number } } } // Class->method() or Class::method() if (isset($step['class'])) { $type = $step['type']; //Support for xdebug if ($step['type'] == "dynamic") { $type = '->'; } //Support for xdebug if ($step['type'] == "static") { $type = '::'; } $function = $step['class'] . $type . $step['function']; } $output[] = array('function' => $function, 'args' => isset($args) ? $args : NULL, 'file' => isset($file) ? $file : NULL, 'line' => isset($line) ? $line : NULL, 'source' => isset($source) ? $source : NULL); unset($function, $args, $file, $line, $source); } return $output; }
/** * Loads the Koowa customized jQtree behavior and renders a sidebar-nav list useful in split views * * @see http://mbraak.github.io/jqTree/ * * @note If no 'element' option is passed, then only assets will be loaded. * * @param array|KObjectConfig $config * @throws InvalidArgumentException * @return string The html output */ public function tree($config = array()) { $config = new KObjectConfigJson($config); $config->append(array('debug' => JFactory::getApplication()->getCfg('debug'))); return parent::tree($config); }