getContainer() public method

Get a reference to the form's Container
public getContainer ( ) : Container
return FOF30\Container\Container
Example #1
0
File: Tag.php Project: Joal01/fof
 /**
  * Method to get a list of tags
  *
  * @return  array  The field option objects.
  *
  * @since   3.1
  */
 protected function getOptions()
 {
     $published = $this->element['published'] ? $this->element['published'] : array(0, 1);
     $db = $this->form->getContainer()->platform->getDbo();
     $query = $db->getQuery(true)->select('a.id AS value, a.path, a.title AS text, a.level, a.published')->from('#__tags AS a')->join('LEFT', $db->quoteName('#__tags') . ' AS b ON a.lft > b.lft AND a.rgt < b.rgt');
     if ($this->item instanceof DataModel) {
         $item = $this->item;
     } else {
         $item = $this->form->getModel();
     }
     if ($item instanceof DataModel) {
         // Fake value for selected tags
         $keyfield = $item->getKeyName();
         $content_id = $item->{$keyfield};
         $type = $item->getContentType();
         $selected_query = $db->getQuery(true);
         $selected_query->select('tag_id')->from('#__contentitem_tag_map')->where('content_item_id = ' . (int) $content_id)->where('type_alias = ' . $db->quote($type));
         $db->setQuery($selected_query);
         $this->value = $db->loadColumn();
     }
     // Ajax tag only loads assigned values
     if (!$this->isNested()) {
         // Only item assigned values
         $values = (array) $this->value;
         \JArrayHelper::toInteger($values);
         $query->where('a.id IN (' . implode(',', $values) . ')');
     }
     // Filter language
     if (!empty($this->element['language'])) {
         $query->where('a.language = ' . $db->quote($this->element['language']));
     }
     $query->where($db->quoteName('a.alias') . ' <> ' . $db->quote('root'));
     // Filter to only load active items
     // Filter on the published state
     if (is_numeric($published)) {
         $query->where('a.published = ' . (int) $published);
     } elseif (is_array($published)) {
         \JArrayHelper::toInteger($published);
         $query->where('a.published IN (' . implode(',', $published) . ')');
     }
     $query->group('a.id, a.title, a.level, a.lft, a.rgt, a.parent_id, a.published, a.path')->order('a.lft ASC');
     // Get the options.
     $db->setQuery($query);
     try {
         $options = $db->loadObjectList();
     } catch (\RuntimeException $e) {
         return false;
     }
     // Prepare nested data
     if ($this->isNested()) {
         $this->prepareOptionsNested($options);
     } else {
         $options = \JHelperTags::convertPathsToNames($options);
     }
     return $options;
 }
Example #2
0
 /**
  * Replace string with tags that reference fields
  *
  * @param   string  $text  Text to process
  *
  * @return  string         Text with tags replace
  */
 protected function parseFieldTags($text)
 {
     $ret = $text;
     // Replace [ITEM:ID] in the URL with the item's key value (usually:
     // the auto-incrementing numeric ID)
     $keyfield = $this->item->getKeyName();
     $replace = $this->item->{$keyfield};
     $ret = str_replace('[ITEM:ID]', $replace, $ret);
     // Replace the [ITEMID] in the URL with the current Itemid parameter
     $ret = str_replace('[ITEMID]', $this->form->getContainer()->input->getInt('Itemid', 0), $ret);
     // Replace other field variables in the URL
     $fields = $this->item->getTableFields();
     foreach ($fields as $fielddata) {
         $fieldname = $fielddata->Field;
         if (empty($fieldname)) {
             $fieldname = $fielddata->column_name;
         }
         $search = '[ITEM:' . strtoupper($fieldname) . ']';
         $replace = $this->item->{$fieldname};
         if (!is_string($replace)) {
             continue;
         }
         $ret = str_replace($search, $replace, $ret);
     }
     return $ret;
 }
Example #3
0
File: Text.php Project: akeeba/fof
 /**
  * Replace string with tags that reference fields
  *
  * @param   string  $text  Text to process
  *
  * @return  string         Text with tags replace
  */
 protected function parseFieldTags($text)
 {
     $ret = $text;
     // Replace [ITEM:ID] in the URL with the item's key value (usually:
     // the auto-incrementing numeric ID)
     if (is_null($this->item)) {
         $this->item = $this->form->getModel();
     }
     $replace = $this->item->getId();
     $ret = str_replace('[ITEM:ID]', $replace, $ret);
     // Replace the [ITEMID] in the URL with the current Itemid parameter
     $ret = str_replace('[ITEMID]', $this->form->getContainer()->input->getInt('Itemid', 0), $ret);
     // Replace the [TOKEN] in the URL with the Joomla! form token
     $ret = str_replace('[TOKEN]', \JFactory::getSession()->getFormToken(), $ret);
     // Replace other field variables in the URL
     $data = $this->item->getData();
     foreach ($data as $field => $value) {
         // Skip non-processable values
         if (is_array($value) || is_object($value)) {
             continue;
         }
         $search = '[ITEM:' . strtoupper($field) . ']';
         $ret = str_replace($search, $value, $ret);
     }
     return $ret;
 }
Example #4
0
 /**
  * Translate a list of objects with JText::_().
  *
  * @param   \stdClass  $item  The component object
  * @param   string     $type  The extension type (e.g. component)
  *
  * @since   2.1
  *
  * @return  string  $text  The translated name of the extension
  *
  * @see administrator/com_installer/models/extension.php
  */
 public function translate($item, $type)
 {
     $platform = $this->form->getContainer()->platform;
     // Map the manifest cache to $item. This is needed to get the name from the
     // manifest_cache and NOT from the name column, else some JText::_() translations fails.
     $mData = json_decode($item->manifest_cache);
     if ($mData) {
         foreach ($mData as $key => $value) {
             if ($key == 'type') {
                 // Ignore the type field
                 continue;
             }
             $item->{$key} = $value;
         }
     }
     $lang = $platform->getLanguage();
     switch ($type) {
         case 'component':
             $source = JPATH_ADMINISTRATOR . '/components/' . $item->element;
             $lang->load("{$item->element}.sys", JPATH_ADMINISTRATOR, null, false, false) || $lang->load("{$item->element}.sys", $source, null, false, false) || $lang->load("{$item->element}.sys", JPATH_ADMINISTRATOR, $lang->getDefault(), false, false) || $lang->load("{$item->element}.sys", $source, $lang->getDefault(), false, false);
             break;
     }
     $text = JText::_($item->name);
     return $text;
 }
Example #5
0
 /**
  * Builds the query for the ordering list.
  *
  * @since 2.3.2
  *
  * @return \JDatabaseQuery  The query for the ordering form field
  */
 protected function getQuery()
 {
     $ordering = $this->name;
     $title = $this->element['ordertitle'] ? (string) $this->element['ordertitle'] : $this->item->getFieldAlias('title');
     $db = $this->form->getContainer()->platform->getDbo();
     $query = $db->getQuery(true);
     $query->select(array($db->quoteName($ordering, 'value'), $db->quoteName($title, 'text')))->from($db->quoteName($this->item->getTableName()))->order($ordering);
     return $query;
 }
Example #6
0
 /**
  * Returns the options for this control
  *
  * Adapted from JHtmlAccess::usergroup
  *
  * @return  \stdClass[]
  */
 protected function getOptions()
 {
     $db = $this->form->getContainer()->platform->getDbo();
     $query = $db->getQuery(true)->select('a.id AS value, a.title AS text, COUNT(DISTINCT b.id) AS level')->from($db->quoteName('#__usergroups') . ' AS a')->join('LEFT', $db->quoteName('#__usergroups') . ' AS b ON a.lft > b.lft AND a.rgt < b.rgt')->group('a.id, a.title, a.lft, a.rgt')->order('a.lft ASC');
     $db->setQuery($query);
     $options = $db->loadObjectList();
     for ($i = 0, $n = count($options); $i < $n; $i++) {
         $options[$i]->text = str_repeat('- ', $options[$i]->level) . $options[$i]->text;
     }
 }
Example #7
0
File: Media.php Project: akeeba/fof
 /**
  * Method to get the field input markup.
  *
  * @param   array   $fieldOptions  Options to be passed into the field
  *
  * @return  string  The field HTML
  */
 public function getFieldContents(array $fieldOptions = array())
 {
     $imgattr = array();
     if (isset($fieldOptions['id'])) {
         $imgattr['id'] = $fieldOptions['id'];
     }
     if ($this->class || isset($fieldOptions['class']) && $fieldOptions['class']) {
         $imgattr['class'] = $this->class . (isset($fieldOptions['class']) ? ' ' . $fieldOptions['class'] : '');
     }
     if ($this->element['style']) {
         $imgattr['style'] = (string) $this->element['style'];
     }
     if ($this->element['width']) {
         $imgattr['width'] = (string) $this->element['width'];
     }
     if ($this->element['height']) {
         $imgattr['height'] = (string) $this->element['height'];
     }
     if ($this->element['align']) {
         $imgattr['align'] = (string) $this->element['align'];
     }
     if ($this->element['rel']) {
         $imgattr['rel'] = (string) $this->element['rel'];
     }
     if ($this->element['alt']) {
         $alt = JText::_((string) $this->element['alt']);
     } else {
         $alt = null;
     }
     if ($this->element['title']) {
         $imgattr['title'] = JText::_((string) $this->element['title']);
     }
     $directory = '';
     if ($this->element['directory']) {
         $directory = (string) $this->element['directory'];
         $directory = trim($directory, '/\\') . '/';
     }
     $imagePath = $directory . $this->value;
     $platform = $this->form->getContainer()->platform;
     $baseDirs = $platform->getPlatformBaseDirs();
     if ($this->value && file_exists($baseDirs['root'] . '/' . $imagePath)) {
         $src = $platform->URIroot() . '/' . $imagePath;
         return JHtml::image($src, $alt, $imgattr);
     }
     // JHtml::image returns weird stuff when an empty path is provided, so let's be safe than sorry and return empty
     return '';
 }
Example #8
0
 /**
  * Method to get the field input markup.
  *
  * @param   array   $fieldOptions  Options to be passed into the field
  *
  * @return  string  The field HTML
  */
 public function getFieldContents(array $fieldOptions = array())
 {
     $id = isset($fieldOptions['id']) ? 'id="' . $fieldOptions['id'] . '" ' : '';
     $class = $this->class . (isset($fieldOptions['class']) ? ' ' . $fieldOptions['class'] : '');
     $params = $this->getOptions();
     $db = $this->form->getContainer()->platform->getDbo();
     $query = $db->getQuery(true)->select('a.id AS value, a.title AS text')->from('#__viewlevels AS a')->group('a.id, a.title, a.ordering')->order('a.ordering ASC')->order($db->qn('title') . ' ASC');
     // Get the options.
     $options = $db->setQuery($query)->loadObjectList();
     // If params is an array, push these options to the array
     if (is_array($params)) {
         $options = array_merge($params, $options);
     } elseif ($params) {
         array_unshift($options, JHtml::_('select.option', '', JText::_('JOPTION_ACCESS_SHOW_ALL_LEVELS')));
     }
     return '<span ' . ($id ? $id : '') . 'class="' . $class . '">' . htmlspecialchars(GenericList::getOptionName($options, $this->value), ENT_COMPAT, 'UTF-8') . '</span>';
 }
Example #9
0
 /**
  * Returns the rendered view template
  *
  * @return string
  */
 protected function getRenderedTemplate($isRepeatable = false)
 {
     $sourceTemplate = isset($this->element['source']) ? (string) $this->element['source'] : null;
     $sourceView = isset($this->element['source_view']) ? (string) $this->element['source_view'] : null;
     $sourceViewType = isset($this->element['source_view_type']) ? (string) $this->element['source_view_type'] : 'html';
     $sourceComponent = isset($this->element['source_component']) ? (string) $this->element['source_component'] : null;
     if (empty($sourceTemplate)) {
         return '';
     }
     $sourceContainer = empty($sourceComponent) ? $this->form->getContainer() : Container::getInstance($sourceComponent);
     if (empty($sourceView)) {
         $viewObject = new View($sourceContainer, array('name' => 'FAKE_FORM_VIEW'));
     } else {
         $viewObject = $sourceContainer->factory->view($sourceView, $sourceViewType);
     }
     $viewObject->populateFromModel($this->form->getModel());
     return $viewObject->loadAnyTemplate($sourceTemplate, array('model' => $isRepeatable ? $this->item : $this->form->getModel(), 'form' => $this->form, 'formType' => $this->form->getAttribute('type', 'edit'), 'fieldValue' => $this->value, 'fieldElement' => $this->element));
 }
Example #10
0
 /**
  * Method to get the field input markup.
  *
  * @param   array   $fieldOptions  Options to be passed into the field
  *
  * @return  string  The field HTML
  */
 public function getFieldContents(array $fieldOptions = array())
 {
     $imgattr = array();
     if ($fieldOptions['id']) {
         $imgattr['id'] = $fieldOptions['id'];
     }
     if ($this->class || $fieldOptions['class']) {
         $imgattr['class'] = $this->class . (isset($fieldOptions['class']) ? ' ' . $fieldOptions['class'] : '');
     }
     if ($this->element['style']) {
         $imgattr['style'] = (string) $this->element['style'];
     }
     if ($this->element['width']) {
         $imgattr['width'] = (string) $this->element['width'];
     }
     if ($this->element['height']) {
         $imgattr['height'] = (string) $this->element['height'];
     }
     if ($this->element['align']) {
         $imgattr['align'] = (string) $this->element['align'];
     }
     if ($this->element['rel']) {
         $imgattr['rel'] = (string) $this->element['rel'];
     }
     if ($this->element['alt']) {
         $alt = JText::_((string) $this->element['alt']);
     } else {
         $alt = null;
     }
     if ($this->element['title']) {
         $imgattr['title'] = JText::_((string) $this->element['title']);
     }
     $path = (string) $this->element['directory'];
     $path = trim($path, '/' . DIRECTORY_SEPARATOR);
     if ($this->value && file_exists(JPATH_ROOT . '/' . $path . '/' . $this->value)) {
         $src = $this->form->getContainer()->platform->URIroot() . '/' . $path . '/' . $this->value;
     } else {
         $src = '';
     }
     return JHtml::image($src, $alt, $imgattr);
 }
Example #11
0
 /**
  * Get the rendering of this field type for a repeatable (grid) display,
  * e.g. in a view listing many item (typically a "browse" task)
  *
  * @since 2.0
  *
  * @return  string  The field HTML
  *
  * @throws  DataModelRequired
  */
 public function getRepeatable()
 {
     // Should I support checked-out elements?
     $checkoutSupport = false;
     if (isset($this->element['checkout'])) {
         $checkoutSupportValue = (string) $this->element['checkout'];
         $checkoutSupport = in_array(strtolower($checkoutSupportValue), array('yes', 'true', 'on', 1));
     }
     if (!$this->item instanceof DataModel) {
         throw new DataModelRequired(__CLASS__);
     }
     // Is this record checked out?
     $userId = $this->form->getContainer()->platform->getUser()->get('id', 0);
     $checked_out = false;
     if ($checkoutSupport) {
         $checked_out = $this->item->isLocked($userId);
     }
     // Get the key id for this record
     $key_field = $this->item->getKeyName();
     $key_id = $this->item->{$key_field};
     // Get the HTML
     return JHtml::_('grid.id', $this->rowid, $key_id, $checked_out);
 }
Example #12
0
 /**
  * Returns the rendered view template
  *
  * @return string
  */
 protected function getCallbackResults()
 {
     $source_file = empty($this->element['source_file']) ? '' : (string) $this->element['source_file'];
     $source_class = empty($this->element['source_class']) ? '' : (string) $this->element['source_class'];
     $source_method = empty($this->element['source_method']) ? '' : (string) $this->element['source_method'];
     if (empty($source_class) || empty($source_method)) {
         return '';
     }
     // Maybe we have to load a file?
     if (!empty($source_file)) {
         $source_file = $this->form->getContainer()->template->parsePath($source_file, true);
         if ($this->form->getContainer()->filesystem->fileExists($source_file)) {
             include_once $source_file;
         }
     }
     // Make sure the class exists
     if (class_exists($source_class, true)) {
         // ...and so does the option
         if (in_array($source_method, get_class_methods($source_class))) {
             return $source_class::$source_method(array('model' => $this->form->getModel(), 'form' => $this->form, 'formType' => $this->form->getAttribute('type', 'edit'), 'fieldValue' => $this->value, 'fieldElement' => $this->element));
         }
     }
     return '';
 }
Example #13
0
File: Tag.php Project: akeeba/fof
 /**
  * Method to get the field input markup.
  *
  * @param   array   $fieldOptions  Options to be passed into the field
  *
  * @return  string  The field HTML
  */
 public function getFieldContents(array $fieldOptions = array())
 {
     $id = isset($fieldOptions['id']) ? 'id="' . $fieldOptions['id'] . '" ' : '';
     $class = $this->class . (isset($fieldOptions['class']) ? ' ' . $fieldOptions['class'] : '');
     $front_link = $this->element['front_link'] ? (string) $this->element['front_link'] : false;
     $translate = $this->element['translate'] ? (string) $this->element['translate'] : false;
     $tagIds = is_array($this->value) ? implode(',', $this->value) : $this->value;
     if (!$this->item instanceof DataModel) {
         $this->item = $this->form->getModel();
     }
     if ($tagIds && $this->item instanceof DataModel) {
         $db = $this->form->getContainer()->platform->getDbo();
         $query = $db->getQuery(true)->select(array($db->quoteName('id'), $db->quoteName('title')))->from($db->quoteName('#__tags'))->where($db->quoteName('id') . ' IN (' . $tagIds . ')');
         $query->order($db->quoteName('title'));
         $db->setQuery($query);
         $tags = $db->loadObjectList();
         $html = '';
         foreach ($tags as $tag) {
             $html .= '<span>';
             if ($front_link) {
                 \JLoader::register('TagsHelperRoute', \JPATH_SITE . '/components/com_tags/helpers/route.php');
                 $html .= '<a href="' . \JRoute::_(\TagsHelperRoute::getTagRoute($tag->id)) . '">';
             }
             if ($translate == true) {
                 $html .= \JText::_($tag->title);
             } else {
                 $html .= $tag->title;
             }
             if ($front_link) {
                 $html .= '</a>';
             }
             $html .= '</span>';
         }
     }
     return '<span ' . ($id ? $id : '') . 'class="' . $class . '">' . $html . '</span>';
 }
Example #14
0
File: Rules.php Project: akeeba/fof
 /**
  * At the timing of this writing (2013-12-03), the Joomla "rules" field is buggy. When you are
  * dealing with a new record it gets the default permissions from the root asset node, which
  * is fine for the default permissions of Joomla articles, but unsuitable for third party software.
  * We had to copy & paste the whole code, since we can't "inject" the correct asset id if one is
  * not found. Our fixes are surrounded by `FOF Library fix` remarks.
  *
  * @return  string  The input field's HTML for this field type
  */
 protected function getInput()
 {
     JHtml::_('bootstrap.tooltip');
     // Initialise some field attributes.
     $section = $this->section;
     $component = $this->component;
     $assetField = $this->assetField;
     // Get the actions for the asset.
     $actions = \JAccess::getActions($component, $section);
     // Iterate over the children and add to the actions.
     /** @var \SimpleXMLElement $el */
     foreach ($this->element->children() as $el) {
         if ($el->getName() == 'action') {
             $actions[] = (object) array('name' => (string) $el['name'], 'title' => (string) $el['title'], 'description' => (string) $el['description']);
         }
     }
     // Get the explicit rules for this asset.
     if ($section == 'component') {
         // Need to find the asset id by the name of the component.
         $db = $this->form->getContainer()->platform->getDbo();
         $query = $db->getQuery(true)->select($db->quoteName('id'))->from($db->quoteName('#__assets'))->where($db->quoteName('name') . ' = ' . $db->quote($component));
         $assetId = (int) $db->setQuery($query)->loadResult();
     } else {
         // Find the asset id of the content.
         // Note that for global configuration, com_config injects asset_id = 1 into the form.
         $assetId = $this->form->getValue($assetField);
         // ==== FOF Library fix - Start ====
         // If there is no assetId (let's say we are dealing with a new record), let's ask the table
         // to give it to us. Here you should implement your logic (ie getting default permissions from
         // the component or from the category)
         if (!$assetId) {
             $table = $this->form->getModel();
             $assetId = $table->getAssetParentId();
         }
         // ==== FOF Library fix - End   ====
     }
     // Full width format.
     // Get the rules for just this asset (non-recursive).
     $assetRules = \JAccess::getAssetRules($assetId);
     // Get the available user groups.
     $groups = $this->getUserGroups();
     // Prepare output
     $html = array();
     // Description
     $html[] = '<p class="rule-desc">' . JText::_('JLIB_RULES_SETTINGS_DESC') . '</p>';
     // Begin tabs
     $html[] = '<div id="permissions-sliders" class="tabbable tabs-left">';
     // Building tab nav
     $html[] = '<ul class="nav nav-tabs">';
     foreach ($groups as $group) {
         // Initial Active Tab
         $active = "";
         if ($group->value == 1) {
             $active = "active";
         }
         $html[] = '<li class="' . $active . '">';
         $html[] = '<a href="#permission-' . $group->value . '" data-toggle="tab">';
         $html[] = str_repeat('<span class="level">&ndash;</span> ', $curLevel = $group->level) . $group->text;
         $html[] = '</a>';
         $html[] = '</li>';
     }
     $html[] = '</ul>';
     $html[] = '<div class="tab-content">';
     // Start a row for each user group.
     foreach ($groups as $group) {
         // Initial Active Pane
         $active = "";
         if ($group->value == 1) {
             $active = " active";
         }
         $html[] = '<div class="tab-pane' . $active . '" id="permission-' . $group->value . '">';
         $html[] = '<table class="table table-striped">';
         $html[] = '<thead>';
         $html[] = '<tr>';
         $html[] = '<th class="actions" id="actions-th' . $group->value . '">';
         $html[] = '<span class="acl-action">' . JText::_('JLIB_RULES_ACTION') . '</span>';
         $html[] = '</th>';
         $html[] = '<th class="settings" id="settings-th' . $group->value . '">';
         $html[] = '<span class="acl-action">' . JText::_('JLIB_RULES_SELECT_SETTING') . '</span>';
         $html[] = '</th>';
         // The calculated setting is not shown for the root group of global configuration.
         $canCalculateSettings = $group->parent_id || !empty($component);
         if ($canCalculateSettings) {
             $html[] = '<th id="aclactionth' . $group->value . '">';
             $html[] = '<span class="acl-action">' . JText::_('JLIB_RULES_CALCULATED_SETTING') . '</span>';
             $html[] = '</th>';
         }
         $html[] = '</tr>';
         $html[] = '</thead>';
         $html[] = '<tbody>';
         foreach ($actions as $action) {
             $html[] = '<tr>';
             $html[] = '<td headers="actions-th' . $group->value . '">';
             $html[] = '<label for="' . $this->id . '_' . $action->name . '_' . $group->value . '" class="hasTooltip" title="' . htmlspecialchars(JText::_($action->title) . ' ' . JText::_($action->description), ENT_COMPAT, 'UTF-8') . '">';
             $html[] = JText::_($action->title);
             $html[] = '</label>';
             $html[] = '</td>';
             $html[] = '<td headers="settings-th' . $group->value . '">';
             $html[] = '<select class="input-small" name="' . $this->name . '[' . $action->name . '][' . $group->value . ']" id="' . $this->id . '_' . $action->name . '_' . $group->value . '" title="' . JText::sprintf('JLIB_RULES_SELECT_ALLOW_DENY_GROUP', JText::_($action->title), trim($group->text)) . '">';
             $inheritedRule = \JAccess::checkGroup($group->value, $action->name, $assetId);
             // Get the actual setting for the action for this group.
             $assetRule = $assetRules->allow($action->name, $group->value);
             // Build the dropdowns for the permissions sliders
             // The parent group has "Not Set", all children can rightly "Inherit" from that.
             $html[] = '<option value=""' . ($assetRule === null ? ' selected="selected"' : '') . '>' . JText::_(empty($group->parent_id) && empty($component) ? 'JLIB_RULES_NOT_SET' : 'JLIB_RULES_INHERITED') . '</option>';
             $html[] = '<option value="1"' . ($assetRule === true ? ' selected="selected"' : '') . '>' . JText::_('JLIB_RULES_ALLOWED') . '</option>';
             $html[] = '<option value="0"' . ($assetRule === false ? ' selected="selected"' : '') . '>' . JText::_('JLIB_RULES_DENIED') . '</option>';
             $html[] = '</select>&#160; ';
             // If this asset's rule is allowed, but the inherited rule is deny, we have a conflict.
             if ($assetRule === true && $inheritedRule === false) {
                 $html[] = JText::_('JLIB_RULES_CONFLICT');
             }
             $html[] = '</td>';
             // Build the Calculated Settings column.
             // The inherited settings column is not displayed for the root group in global configuration.
             if ($canCalculateSettings) {
                 $html[] = '<td headers="aclactionth' . $group->value . '">';
                 // This is where we show the current effective settings considering currrent group, path and cascade.
                 // Check whether this is a component or global. Change the text slightly.
                 if (\JAccess::checkGroup($group->value, 'core.admin', $assetId) !== true) {
                     if ($inheritedRule === null) {
                         $html[] = '<span class="label label-important">' . JText::_('JLIB_RULES_NOT_ALLOWED') . '</span>';
                     } elseif ($inheritedRule === true) {
                         $html[] = '<span class="label label-success">' . JText::_('JLIB_RULES_ALLOWED') . '</span>';
                     } elseif ($inheritedRule === false) {
                         if ($assetRule === false) {
                             $html[] = '<span class="label label-important">' . JText::_('JLIB_RULES_NOT_ALLOWED') . '</span>';
                         } else {
                             $html[] = '<span class="label"><i class="icon-lock icon-white"></i> ' . JText::_('JLIB_RULES_NOT_ALLOWED_LOCKED') . '</span>';
                         }
                     }
                 } elseif (!empty($component)) {
                     $html[] = '<span class="label label-success"><i class="icon-lock icon-white"></i> ' . JText::_('JLIB_RULES_ALLOWED_ADMIN') . '</span>';
                 } else {
                     // Special handling for  groups that have global admin because they can't  be denied.
                     // The admin rights can be changed.
                     if ($action->name === 'core.admin') {
                         $html[] = '<span class="label label-success">' . JText::_('JLIB_RULES_ALLOWED') . '</span>';
                     } elseif ($inheritedRule === false) {
                         // Other actions cannot be changed.
                         $html[] = '<span class="label label-important"><i class="icon-lock icon-white"></i> ' . JText::_('JLIB_RULES_NOT_ALLOWED_ADMIN_CONFLICT') . '</span>';
                     } else {
                         $html[] = '<span class="label label-success"><i class="icon-lock icon-white"></i> ' . JText::_('JLIB_RULES_ALLOWED_ADMIN') . '</span>';
                     }
                 }
                 $html[] = '</td>';
             }
             $html[] = '</tr>';
         }
         $html[] = '</tbody>';
         $html[] = '</table></div>';
     }
     $html[] = '</div></div>';
     $html[] = '<div class="alert">';
     if ($section == 'component' || $section == null) {
         $html[] = JText::_('JLIB_RULES_SETTING_NOTES');
     } else {
         $html[] = JText::_('JLIB_RULES_SETTING_NOTES_ITEM');
     }
     $html[] = '</div>';
     return implode("\n", $html);
 }
Example #15
0
 /**
  * Method to get the calendar input markup.
  *
  * @param   string  $display  The display to render ('static' or 'repeatable')
  *
  * @return  string	The field input markup.
  *
  * @since   2.1.rc4
  */
 protected function getCalendar($display)
 {
     // Initialize some field attributes.
     $format = $this->format ? $this->format : '%Y-%m-%d';
     $class = $this->class ? $this->class : '';
     $default = $this->element['default'] ? (string) $this->element['default'] : '';
     // Get some system objects.
     $config = $this->form->getContainer()->platform->getConfig();
     $user = $this->form->getContainer()->platform->getUser();
     // Check for empty date values
     if (empty($this->value) || $this->value == $this->form->getContainer()->platform->getDbo()->getNullDate() || $this->value == '0000-00-00') {
         $this->value = $default;
     }
     // Handle the special case for "now".
     if (strtoupper($this->value) == 'NOW') {
         $this->value = strftime($format);
     }
     // If a known filter is given use it.
     switch (strtoupper($this->filter)) {
         case 'SERVER_UTC':
             // Convert a date to UTC based on the server timezone.
             if ((int) $this->value) {
                 // Get a date object based on the correct timezone.
                 $date = \JFactory::getDate($this->value, 'UTC');
                 $date->setTimezone(new \DateTimeZone($config->get('offset')));
                 // Transform the date string.
                 $this->value = $date->format('Y-m-d H:i:s', true, false);
             }
             break;
         case 'USER_UTC':
             // Convert a date to UTC based on the user timezone.
             if ((int) $this->value) {
                 // Get a date object based on the correct timezone.
                 $date = \JFactory::getDate($this->value, 'UTC');
                 $date->setTimezone(new \DateTimeZone($user->getParam('timezone', $config->get('offset'))));
                 // Transform the date string.
                 $this->value = $date->format('Y-m-d H:i:s', true, false);
             }
             break;
     }
     if ($display == 'static') {
         // Build the attributes array.
         $attributes = array();
         if ($this->size) {
             $attributes['size'] = $this->size;
         }
         if ($this->maxlength) {
             $attributes['maxlength'] = $this->maxlength;
         }
         if ($this->class) {
             $attributes['class'] = $this->class;
         }
         if ($this->readonly) {
             $attributes['readonly'] = 'readonly';
         }
         if ($this->disabled) {
             $attributes['disabled'] = 'disabled';
         }
         if ($this->onchange) {
             $attributes['onchange'] = $this->onchange;
         }
         if ($this->required) {
             $attributes['required'] = 'required';
             $attributes['aria-required'] = 'true';
         }
         // Including fallback code for HTML5 non supported browsers.
         JHtml::_('jquery.framework');
         JHtml::_('script', 'system/html5fallback.js', false, true);
         return JHtml::_('calendar', $this->value, $this->name, $this->id, $format, $attributes);
     } else {
         if (!$this->value && (string) $this->element['empty_replacement']) {
             $value = $this->element['empty_replacement'];
         } else {
             $jDate = new \JDate($this->value);
             $value = strftime($format, $jDate->getTimestamp());
         }
         return '<span class="' . $this->id . ' ' . $class . '">' . htmlspecialchars($value, ENT_COMPAT, 'UTF-8') . '</span>';
     }
 }