/** * Builds the file upload control and initializes it's related javascript classes. * * To enable maximum compliance with the current state of the file upload's accept attribute, specify both any MIME * types and any corresponding extension. * @see http://www.whatwg.org/specs/web-apps/current-work/multipage/states-of-the-type-attribute.html#attr-input-accept * * @param object An optional Library\ObjectConfig object with configuration options */ public function upload($config = array()) { $config = new Library\ObjectConfig($config); $config->append(array('container' => 'document.body')); if (!$config->allowed_extensions || !$config->allowed_mimetypes) { $container = $this->getObject('com:files.database.table.containers')->select(array('slug' => 'attachments-attachments'), Library\Database::FETCH_ROW); $config->append(array('allowed_extensions' => $container->parameters->allowed_extensions, 'allowed_mimetypes' => $container->parameters->allowed_mimetypes)); } if ($config->container != 'document.body') { $config->container = '\'' . $config->container . '\''; } $extensions = json_encode($config->allowed_extensions->toArray()); $html = <<<END \t\t<script src="assets://attachments/js/attachments.upload.js" /> \t\t<script> \t\twindow.addEvent('domready', function() { \t\t\tnew Attachments.Upload({ \t\t\t\tcontainer: {$config->container}, \t\t\t extensions: {$extensions} \t\t\t}); \t\t}); \t\t</script> END; $accept = array(); foreach ($config->allowed_extensions->toArray() as $val) { $accept[] = '.' . $val; } $accept = array_merge($accept, $config->allowed_mimetypes->toArray()); $html .= '<input type="file" name="attachments[]" accept="' . implode(', ', $accept) . '" />'; return $html; }
public function languages($config = array()) { $config = new Library\ObjectConfig($config); $config->append(array('name' => 'language')); $result = ''; $result = ' <script> window.addEvent(\'domready\', function() { document.getElement(\'select[name=' . $config->name . ']\').addEvent(\'change\', function() { window.location = this.value; }); }); </script> '; $options = array(); $languages = $this->getObject('application.languages'); $active = $languages->getActive(); foreach ($languages as $language) { $route = $this->getTemplate()->getView()->getRoute('language=' . $language->slug); $options[] = $this->option(array('label' => $language->name, 'value' => $route)); if ($language->iso_code == $active->iso_code) { $config->selected = $route; } } $config->options = $options; $result .= parent::optionlist($config); return $result; }
protected function _initialize(Library\ObjectConfig $config) { $language = \JFactory::getLanguage(); $settings = array('directionality' => $language->isRTL() ? 'rtl' : 'ltr', 'editor_selector' => 'editable', 'mode' => 'specific_textareas', 'skin' => 'nooku', 'theme' => 'advanced', 'inline_styles' => true, 'gecko_spellcheck' => true, 'entity_encoding' => 'raw', 'extended_valid_elements' => '', 'invalid_elements' => 'script,applet,iframe', 'relative_urls' => false, 'remove_script_host' => true, 'document_base_url' => $this->getObject('request')->getBaseUrl()->getPath() . '/sites/' . $this->getObject('application')->getSite(), 'theme_advanced_toolbar_location' => 'top', 'theme_advanced_toolbar_align' => 'left', 'theme_advanced_source_editor_height' => '400', 'height' => '400', 'width' => '100%', 'theme_advanced_statusbar_location' => 'bottom', 'theme_advanced_resizing' => false, 'theme_advanced_resize_horizontal' => false, 'theme_advanced_path' => true, 'dialog_type' => 'modal', 'language' => substr($language->getTag(), 0, strpos($language->getTag(), '-')), 'theme_advanced_buttons1' => implode(',', array('bold', 'italic', 'strikethrough', 'underline', '|', 'bullist', 'numlist', 'blockquote', '|', 'justifyleft', 'justifycenter', 'justifyright', 'justifyfull', '|', 'link', 'unlink', '|', 'spellchecker', 'fullscreen', 'image', 'readmore', 'article', '|', 'advanced')), 'theme_advanced_buttons2' => implode(',', array('formatselect', 'forecolor', '|', 'pastetext', 'pasteword', 'removeformat', '|', 'media', 'charmap', '|', 'outdent', 'indent', '|', 'undo', 'redo')), 'theme_advanced_buttons3' => '', 'theme_advanced_buttons4' => ''); $config->append(array('codemirror' => true, 'codemirrorOptions' => array('stylesheet' => array($config->media_url . '/wysiwyg/codemirror/lib/codemirror.css'), 'path' => $config->media_url . '/wysiwyg/codemirror/'), 'editor_settings' => $settings)); parent::_initialize($config); }
protected function _initialize(Library\ObjectConfig $config) { $config->append(array('behaviors' => array('com:activities.controller.behavior.loggable', 'com:attachments.controller.behavior.attachable'), 'model' => 'com:categories.model.categories')); parent::_initialize($config); //Force the toolbars $config->toolbars = array('menubar', 'com:categories.controller.toolbar.category'); }
/** * Renders the reCAPTCHA widget. * * @param string $error The error message given by reCAPTCHA. * @param boolean $ssl Determines is the request should be made over SSL. * * @return string - The HTML to be embedded in the user's form. */ public function render($config = array()) { $config = new Library\ObjectConfig($config); $params = $this->getObject('application.extensions')->users->params; $config->append(array('captcha' => array('public_key' => $params->get('recaptcha_public_key', null), 'api_server' => 'http://www.google.com/recaptcha/api', 'api_secure_server' => 'https://www.google.com/recaptcha/api', 'options' => array('theme' => 'clean', 'lang' => 'en')), 'error' => '', 'ssl' => false)); $captcha = $config->captcha; $html = ''; if ($public_key = $captcha->public_key) { if ($config->ssl) { $server = $captcha->api_secure_server; } else { $server = $captcha->api_server; } if ($config->error) { $config->error = '&error=' . $config->error; } // Use options if any. if (count($options = $captcha->options)) { $options = Library\ObjectConfig::unbox($options); $html .= '<script type="text/javascript">'; $html .= 'var RecaptchaOptions = ' . json_encode($options); $html .= '</script> '; } $html .= '<script data-inline type="text/javascript" src="' . $server . '/challenge?k=' . $public_key . $config->error . '"></script> <noscript> <iframe src="' . $server . '/noscript?k=' . $public_key . $config->error . '" height="300" width="500" frameborder="0"></iframe><br/> <textarea name="recaptcha_challenge_field" rows="3" cols="40"></textarea> <input type="hidden" name="recaptcha_response_field" value="manual_challenge"/> </noscript>'; } return $html; }
public function link($config) { $config = new Library\ObjectConfig($config); $config->append(array('title' => '', 'current' => false, 'active' => false, 'offset' => 0, 'limit' => 0, 'rel' => '', 'attribs' => array())); $html = '<a class="btn ' . $config->rel . '" href="#">' . JText::_($config->title) . '</a>'; return $html; }
public function groups($config = array()) { $config = new Library\ObjectConfig($config); $config->append(array('name' => 'role_id')); $config->options = $this->options(array('entity' => $this->getObject('com:users.model.roles')->sort('id')->getRowset(), 'label' => 'name')); return $this->radiolist($config); }
protected function _initialize(Library\ObjectConfig $config) { $config->append(array('model' => 'com:tags.model.tags')); parent::_initialize($config); //Force the toolbars $config->toolbars = array('menubar', 'com:tags.controller.toolbar.tag'); }
public function tags($config = array()) { $config = new Library\ObjectConfig($config); $config->append(array('model' => 'tags', 'value' => 'id', 'text' => 'title', 'prompt' => false)); $config->text = 'title'; $config->sort = 'title'; return parent::_render($config); }
/** * Initializes the options for the object * * Called from {@link __construct()} as a first step of object instantiation. * * @param Library\ObjectConfig $config Configuration options * @return void */ protected function _initialize(Library\ObjectConfig $config) { //Make asset paths absolute $base = $this->getObject('request')->getBaseUrl(); $path = $this->getObject('request')->getBaseUrl()->getPath() . '/assets/'; $config->append(array('priority' => self::PRIORITY_LOW, 'aliases' => array('"/assets/' => '"' . $path))); parent::_initialize($config); }
public function gravatar($config = array()) { $config = new Library\ObjectConfig($config); $config->append(array('email' => '', 'size' => '32', 'attribs' => array())); $source = "http://www.gravatar.com/avatar/" . md5(strtolower(trim($config->email))) . "?s=" . $config->size; $html = '<img class="avatar" src="' . $source . '" />'; return $html; }
public function thumbnail($config = array()) { $config = new Library\ObjectConfig($config); $config->append(array('align' => 'right', 'class' => 'thumbnail article__thumbnail')); $image = $config->row; $html = '<img class="' . $config->class . '" align="' . $config->align . '" src="' . $image->thumbnail . '" />'; return $html; }
/** * Render a page link * * @param array An optional array with configuration options * @return string Html */ public function link($config) { $config = new Library\ObjectConfig($config); $config->append(array('title' => '', 'current' => false, 'active' => false, 'offset' => 0, 'limit' => 0, 'rel' => '', 'attribs' => array())); $route = $this->getTemplate()->getView()->getRoute('limit=' . $config->limit . '&offset=' . $config->offset); $rel = !empty($config->rel) ? 'rel="' . $config->rel . '"' : ''; $html = '<a ' . $this->buildAttributes($config->attribs) . ' href="' . $route . '" ' . $rel . '>' . $this->translate($config->title) . '</a>'; return $html; }
public function email($config = array()) { $config = new Library\ObjectConfig($config); $config->append(array('identifier' => 'com:clients.model.emails', 'name' => 'id')); //@TODO : Fix - Forcing config option because of name collisions $config->text = 'email'; $config->sort = 'email'; return parent::_render($config); }
/** * Initializes the options for the object * * Called from {@link __construct()} as a first step of object instantiation. * * @param Library\ObjectConfig $config Configuration options * @return void */ protected function _initialize(Library\ObjectConfig $config) { //Make images paths absolute $base = $this->getObject('request')->getBaseUrl(); $site = $this->getObject('application')->getSite(); $path = $base->getPath() . '/files/' . $site . '/files/'; $config->append(array('aliases' => array('files://' => $path, '"files/' => '"' . $path))); parent::_initialize($config); }
public function languages($config = array()) { $config = new Library\ObjectConfig($config); $config->append(array('value' => 'iso_code', 'label' => 'name', 'identifier' => 'com:languages.model.languages', 'filter' => array('application' => 'site', 'enabled' => 1))); $listbox = parent::_listbox($config); if (!$config->size) { $listbox = str_replace('size="1"', '', $listbox); } return $listbox; }
public function status($config = array()) { $config = new Library\ObjectConfig($config); $config->append(array('status' => '', 'original' => 0, 'deleted' => 0)); $statuses = array(DatabaseRowTranslation::STATUS_COMPLETED => 'Completed', DatabaseRowTranslation::STATUS_MISSING => 'Missing', DatabaseRowTranslation::STATUS_OUTDATED => 'Outdated'); $text = $config->original ? 'Original' : $statuses[$config->status]; $class = $config->original ? 'original' : strtolower($statuses[$config->status]); $class = $config->deleted ? 'deleted' : $class; return '<span class="label label-' . $class . '">' . JText::_($text) . '</span>'; }
public function product($config = array()) { $config = new Library\ObjectConfig($config); $config->append(array('layout' => null, 'format' => 'html')); $product = $config->row; $needles = array(array('view' => 'product', 'id' => $product->id)); $route = array('view' => 'product', 'id' => $product->id, 'layout' => $config->layout, 'format' => $config->format); if ($item = $this->_findPage($needles)) { $route['Itemid'] = $item->id; } return $this->getTemplate()->getView()->getRoute($route); }
public function select($config = array()) { $config = new Library\ObjectConfig($config); $config->append(array('name' => '', 'visible' => true, 'link' => '', 'link_text' => $this->translate('Select'), 'link_selector' => 'modal'))->append(array('value' => $config->name)); $input = '<input name="%1$s" id="%1$s" value="%2$s" %3$s size="40" />'; $link = '<a class="%s" rel="{\'ajaxOptions\': {\'method\': \'get\'}, \'handler\': \'iframe\', \'size\': {\'x\': 700}}" href="%s">%s</a>'; $html = sprintf($input, $config->name, $config->value, $config->visible ? 'type="text" readonly' : 'type="hidden"'); $html .= sprintf($link, $config->link_selector, $config->link, $config->link_text); return $html; }
/** * Render item pagination * * @param array An optional array with configuration options * @return string Html * @see http://developer.yahoo.com/ypatterns/navigation/pagination/ */ public function pagination($config = array()) { $config = new Library\ObjectConfig($config); $config->append(array('limit' => 0)); $html = ''; $html .= '<div class="pagination">'; $html .= '<div class="limit">' . $this->translate('Display NUM') . ' ' . $this->limit($config) . '</div>'; $html .= $this->pages($config); $html .= '<div class="limit"> ' . $this->translate('Page') . ' <span class="page-current">1</span>'; $html .= ' ' . $this->translate('of') . ' <span class="page-total">1</span></div>'; $html .= '</div>'; return $html; }
public function groups($config = array()) { $config = new Library\ObjectConfig($config); $config->append(array('name' => '', 'row' => '', 'package' => '', 'model' => 'groups', 'label' => 'title', 'deselect' => ''))->append(array('selected' => ''))->append(array('filter' => array('sort' => 'title'))); $identifier = 'com:products.model.' . ($config->model ? $config->model : Library\StringInflector::pluralize($config->package)); $categories = $this->getObject($identifier)->setState(Library\ObjectConfig::unbox($config->filter))->getRowset(); $options = $this->options(array('entity' => $categories, 'value' => 'id', 'label' => $config->label)); if ($config->deselect) { array_unshift($options, $this->option(array('label' => '-- Select --', 'value' => '0'))); } //Add the options to the config object $config->options = $options; return $this->optionlist($config); }
public function applications($config = array()) { $config = new Library\ObjectConfig($config); $config->append(array('name' => 'application', 'deselect' => true, 'prompt' => '- Select -')); $options = array(); if ($config->deselect) { $options[] = $this->option(array('text' => \JText::_($config->prompt))); } foreach (Library\ClassLoader::getInstance()->getApplications() as $application => $path) { $options[] = $this->option(array('text' => $application, 'value' => $application)); } $config->options = $options; return $this->optionlist($config); }
public function user($config = array()) { $config = new Library\ObjectConfig($config); $config->append(array('access' => null, 'layout' => null)); $route = array('view' => 'user', 'layout' => $config->layout); $needles = array('extensions_extension_id' => $this->getObject('application.extensions')->getExtension($this->getIdentifier()->package)->id, 'link' => array(array('view' => 'user'))); if (isset($config->access)) { $needles['access'] = $config->access; } if ($page = $this->getObject('application.pages')->find($needles)) { $route['Itemid'] = $page->id; } return $this->getTemplate()->getView()->getRoute($route); }
public function message($config = array()) { $config = new Library\ObjectConfig($config); $config->append(array('row' => '')); $row = $config->row; if ($row->name == 'session') { $item = $this->getTemplate()->getView()->getRoute('option=' . $row->type . '_' . $row->package . '&view=user&id=' . $row->created_by); $message = '<a href="' . $item . '">' . $row->title . '</a>'; $message .= ' <span class="action">' . $row->status . '</span>'; } else { $message = parent::message($config); } return $message; }
public function thumbnail($config = array()) { $config = new Library\ObjectConfig($config); $config->append(array('attachment' => false, 'attribs' => array())); //Make sure the attachment is set if ($config->attachment) { $thumbnail = $this->getObject('com:attachments.database.row.attachment')->set('id', $config->attachment)->load(); //Make sure the thumbnail exist if ($thumbnail) { $filename = ucfirst(preg_replace('#[-_\\s\\.]+#i', ' ', pathinfo($thumbnail->name, PATHINFO_FILENAME))); return '<img alt="' . $filename . '" ' . $this->buildAttributes($config->attribs) . ' src="attachments://' . $thumbnail->thumbnail . '" />'; } } return false; }
public function ordering($config = array()) { $config = new Library\ObjectConfig($config); if (!$config->row instanceof ArticlesDatabaseRowArticle) { throw new \InvalidArgumentException('The row is missing.'); } $article = $config->row; $config->append(array('name' => 'order', 'selected' => 0, 'filter' => array('sort' => 'ordering', 'direction' => 'ASC', 'category' => $article->category_id))); $list = $this->getObject('com:articles.model.articles')->set($config->filter)->getRowset(); foreach ($list as $item) { $options[] = $this->option(array('text' => '( ' . $item->ordering . ' ) ' . $item->title, 'value' => $item->ordering - $article->ordering)); } $config->options = $options; return $this->optionlist($config); }
public function category($config = array()) { $config = new Library\ObjectConfig($config); $config->append(array('layout' => null)); $category = $config->row; $needles = array(array('view' => 'contacts', 'category' => $category->id)); $route = array('view' => 'contacts', 'category' => $category->getSlug(), 'layout' => $config->layout); if ($page = $this->_findPage($needles)) { if (isset($page->getLink()->query['layout'])) { $route['layout'] = $page->getLink()->query['layout']; } $route['Itemid'] = $page->id; } return $this->getTemplate()->getView()->getRoute($route); }
/** * Render a page link * * @param array An optional array with configuration options * @return string Html */ public function link($config) { $config = new Library\ObjectConfig($config); $config->append(array('title' => '', 'current' => false, 'active' => false, 'offset' => 0, 'limit' => 0, 'rel' => '', 'attribs' => array())); $route = $this->getTemplate()->getView()->getRoute('limit=' . $config->limit . '&offset=' . $config->offset); $rel = !empty($config->rel) ? 'rel="' . $config->rel . '"' : ''; if (!$config->active && $config->current) { $html = '<a class="btn active" href="#">' . JText::_($config->title) . '</a>'; } elseif (!$config->active && !$config->current) { $html = '<a class="btn disabled" href="#">' . JText::_($config->title) . '</a>'; } else { $html = '<a class="btn" href="' . $route . '" ' . $rel . '>' . JText::_($config->title) . '</a>'; } return $html; }
public function categories($config = array()) { $config = new Library\ObjectConfig($config); $config->append(array('name' => 'categories_category_id', 'row' => '', 'uncategorised' => false, 'max_depth' => '9'))->append(array('selected' => $config->row->{$config->name}))->append(array('filter' => array('sort' => 'title', 'parent' => null, 'published' => null, 'table' => $config->row->getTable()->getBase()))); $categories = $this->getObject('com:categories.model.categories')->setState(Library\ObjectConfig::unbox($config->filter))->getRowset(); $iterator = new DatabaseIteratorNode($categories); $iterator->setMaxDepth($config->max_depth); $options = $this->options(array('entity' => $iterator, 'value' => 'id', 'label' => 'title')); if ($config->uncategorised) { array_unshift($options, $this->option(array('label' => $this->translate('Uncategorized'), 'value' => '0', 'id' => '0'))); } //Add the options to the config object $config->options = $options; return parent::radiolist($config); }
/** * Render the menubar * * @param array An optional array with configuration options * @return string Html */ public function render($config = array()) { $config = new Library\ObjectConfig($config); $config->append(array('attribs' => array('class' => array()))); $groups = $this->getObject('user')->getGroups(); // Make sure that pages without an assigned group are also included. $groups[] = 0; $result = ''; $menus = $this->getObject('com:pages.model.menus')->application('admin')->getRowset(); $menu = $menus->find(array('slug' => 'menubar')); if (count($menu)) { $pages = $this->getObject('application.pages')->find(array('pages_menu_id' => $menu->top()->id, 'hidden' => 0, 'users_group_id' => $groups)); $result = $this->pages(array('pages' => $pages, 'attribs' => $config->attribs)); } return $result; }