/** * Registers the service provider with a DI container. * * @param Container $container The DI container. * * @return void */ public function register(Container $container) { $closure = function (Container $container) { return new \S3($container->get('app')->get('amazon.access_key'), $container->get('app')->get('amazon.secret_key')); }; Ioc::getContainer()->share('s3', $closure); }
/** * createInfoBox * * @param Container $container * @param \stdClass $article * @param mixed $params * * @return string */ public static function createInfoBox(Container $container, $article, $params = null) { // Include Component Core $param = ExtensionHelper::getParams('com_userxtd'); $doc = \JFactory::getDocument(); $app = $container->get('app'); LanguageHelper::loadLanguage('com_userxtd', 'admin'); // init params $image_field = $param->get('UserInfo_ImageField', 'BASIC_AVATAR'); $website_field = $param->get('UserInfo_WebiteField', 'BASIC_WEBSITE'); $include_css = $param->get('UserInfo_IncludeCSS_Article', 1); // Image params $width = $param->get('UserInfo_ImageWidth', 150); $height = $param->get('UserInfo_ImageHeight', 150); $crop = $param->get('UserInfo_ImageCrop', 1) ? \JImage::CROP_RESIZE : false; // Include CSS if ($include_css) { /** @var $asset \Windwalker\Helper\AssetHelper */ $asset = $container->get('helper.asset'); $asset->addCss('userxtd-userinfo.css', 'com_userxtd'); } $user = \UXFactory::getUser($article->created_by); // Images $image = $user->get($image_field); $thumb = new Thumb(null, 'com_userxtd'); $image = $thumb->resize($image, $width, $height, $crop); // Link $query = array('option' => 'com_users', 'view' => 'profile', 'id' => $user->get('id')); $link = \JRoute::_('index.php?' . http_build_query($query)); //Route::_('com_userxtd.user_id', array('id' => $user->get('id'))); // Website $website_link = $user->get($website_field); // Render return with(new FileLayout('userxtd.content.userinfo', null, array('component' => 'com_userxtd')))->render(array('params' => $param, 'article' => $article, 'link' => $link, 'website_link' => $website_link, 'image' => $image, 'user' => $user)); }
/** * Method to test createConsole(). * * @return void * * @covers Windwalker\Provider\CliProvider::createConsole */ public function testCreateConsole() { $container = new Container(); $provider = new CliProvider(); $container->share('windwalker.config', new Registry(array('bundle' => array()))); $container->share('io', new IO()); $this->assertInstanceOf('Windwalker\\Console\\Application\\Console', $provider->createConsole($container)); }
/** * Registers the service provider with a DI container. * * @param Container $container The DI container. * * @return Container Returns itself to support chaining. * * @since 1.0 */ public function register(Container $container) { $ioClass = 'Phoenix\\IO\\IO'; $container->alias('io', $ioClass)->alias('Muse\\IO\\IO', $ioClass)->alias('Muse\\IO\\IOInterface', $ioClass)->share($ioClass, new IO($this->controller->getCommand())); $container->alias('operator.copy', 'Phoenix\\Generaotr\\FileOperator\\CopyOperator')->createObject('Phoenix\\Generaotr\\FileOperator\\CopyOperator'); $closure = function (Container $container) { return new OperatorFactory($container->get('io'), $this->controller->getTagVariables()); }; $container->share('operator.factory', $closure); }
/** * create * * @param string $storage * * @return ImageUploaderManager */ public function create($storage = null) { $config = $this->container->get('config'); $storage = $storage ?: $config->get('unidev.image.storage'); if (!$storage) { throw new \DomainException('No image storage provider.'); } if (is_string($storage)) { $class = __NAMESPACE__ . '\\Storage\\' . ucfirst($storage) . 'ImageStorage'; $storage = new $class($this->container->get('unidev.storage.' . strtolower($storage)), $config->extract('unidev.' . $storage)); } return new ImageUploaderManager($storage); }
/** * StubContainer constructor * * @param Container $parent */ function __construct(Container $parent = null) { parent::__construct($parent); // Add fake root $instance and children self::$instance = new \ArrayObject(); self::$children['foo'] = new \ArrayObject(); }
/** * Refresh the list of include paths * * @return void */ protected function refreshIncludePaths() { $app = Container::getInstance()->get('app'); // Reset includePaths $this->includePaths = array(); // (1 - lower priority) Frontend base layouts $this->addIncludePaths(JPATH_ROOT . '/layouts'); // (2) Windwalker layouts. $this->addIncludePaths(WINDWALKER . '/resource/layouts'); // (3) Standard Joomla! template override $this->addIncludePaths(JPATH_THEMES . '/' . $app->getTemplate() . '/html/layouts'); // Component layouts & overrides if exist $component = $this->options->get('component', null); if (!empty($component)) { // (4) Component path if ($this->options->get('client') == 0) { $this->addIncludePaths(JPATH_SITE . '/components/' . $component . '/layouts'); } else { $this->addIncludePaths(JPATH_ADMINISTRATOR . '/components/' . $component . '/layouts'); } // (5) Component template overrides path $this->addIncludePath(JPATH_THEMES . '/' . $app->getTemplate() . '/html/layouts/' . $component); } // (6 - highest priority) Received a custom high priority path ? if (!is_null($this->basePath)) { $this->addIncludePath(rtrim($this->basePath, DIRECTORY_SEPARATOR)); } }
/** * Get the DI container. * * @return Container * * @since 1.0 * * @throws \UnexpectedValueException May be thrown if the container has not been set. */ public function getContainer() { if (!$this->container) { $this->container = Container::getInstance($this->getName()); } return $this->container; }
/** * Add JS to head. * * @return void */ public function addFieldJs() { JHtmlBehavior::framework(true); $asset = $this->container->get('helper.asset'); $input = $this->container->get('input'); $asset->addJS('cck/fields.js', $input->get('option')); }
/** * Render the profiler log data, and echo it.. * * @param string $namespace The JProfiler instance ID. Default is the core profiler "Application". * @param boolean $asString Return as string. * * @return string */ public static function render($namespace = 'Windwalker', $asString = false) { $app = Container::getInstance()->get('app'); if ($namespace == 'core' || !$namespace) { $namespace = 'Application'; } $buffer = 'No Profiler data.'; if (isset(self::$profiler[$namespace])) { $_PROFILER = self::$profiler[$namespace]; $buffer = $_PROFILER->getBuffer(); $buffer = implode("\n<br />\n", $buffer); } else { $buffer = $app->getUserState('windwalker.system.profiler.' . $namespace); $buffer = $buffer ? implode("\n<br />\n", $buffer) : ''; } $buffer = $buffer ? $buffer : 'No Profiler data.'; // Get last page logs $state_buffer = \JArrayHelper::getValue(self::$stateBuffer, $namespace); if ($state_buffer) { $state_buffer = implode("\n<br />\n", $state_buffer); $buffer = $state_buffer . "\n<br />---------<br />\n" . $buffer; } // Render $buffer = "<pre><h3>WindWalker Debug [namespace: {$namespace}]: </h3>" . $buffer . '</pre>'; $app->setUserState('windwalker.system.profiler.' . $namespace, ''); if ($asString) { return $buffer; } echo $buffer; return ''; }
/** * Add an quick add button & modal * * @return string The quickadd button. */ public function quickadd() { // Prepare Element $readonly = $this->getElement('readonly', false); $disabled = $this->getElement('disabled', false); if ($readonly || $disabled) { return ''; } $container = Container::getInstance(); $input = $container->get('input'); $quickadd = $this->getElement('quickadd', false); $table_name = $this->getElement('table', '#__' . $this->component . '_' . $this->view_list); $key_field = $this->getElement('key_field', 'id'); $value_field = $this->getElement('value_field', 'title'); $formpath = WINDWALKER_SOURCE . "/Form/Forms/quickadd/category.xml"; $quickadd_handler = $this->getElement('quickadd_handler', $input->get('option')); $title = $this->getElement('quickadd_label', 'LIB_WINDWALKER_QUICKADD_TITLE'); $qid = $this->id . '_quickadd'; if (!$quickadd) { return ''; } // Prepare Script & Styles /** @var Windwalker\Helper\AssetHelper $asset */ $asset = Container::getInstance($quickadd_handler)->get('helper.asset'); $asset->addJs('js/quickadd.js'); // Set AKQuickAddOption $config['task'] = $this->view_item . '.ajax.legacyquickadd'; $config['quickadd_handler'] = $quickadd_handler; $config['cat_extension'] = (string) $this->element['extension']; $config['extension'] = 'com_' . $this->component; $config['component'] = $this->component; $config['table'] = $table_name; $config['model_name'] = 'category'; $config['key_field'] = $key_field; $config['value_field'] = $value_field; $config['joomla3'] = JVERSION >= 3; $config = HtmlHelper::getJSObject($config); $script = <<<QA window.addEvent('domready', function(){ var AKQuickAddOption = {$config} ; AKQuickAdd.init('{$qid}', AKQuickAddOption); }); QA; $asset->internalJS($script); // Load Language & Form LanguageHelper::loadLanguage('com_' . $this->component, null); $formpath = str_replace(JPATH_ROOT, '', $formpath); $content = ModalHelper::getQuickaddForm($qid, $formpath, (string) $this->element['extension']); // Prepare HTML $html = ''; $button_title = $title; $modal_title = $button_title; $button_class = 'btn btn-small btn-success delicious green light fltlft quickadd_button'; $footer = "<button class=\"btn delicious\" type=\"button\" onclick=\"\$\$('#{$qid} input', '#{$qid} select').set('value', '');AKQuickAdd.closeModal('{$qid}');\" data-dismiss=\"modal\">" . JText::_('JCANCEL') . "</button>"; $footer .= "<button class=\"btn btn-primary delicious blue\" type=\"submit\" onclick=\"AKQuickAdd.submit('{$qid}', event);\">" . JText::_('JSUBMIT') . "</button>"; $html .= ModalHelper::modalLink(JText::_($button_title), $qid, array('class' => $button_class, 'icon' => 'icon-new icon-white')); $html .= ModalHelper::renderModal($qid, $content, array('title' => JText::_($modal_title), 'footer' => $footer)); return $html; }
/** * Method to attach a JForm object to the field. * Catch upload files when form setup. * * @param SimpleXMLElement $element The JXmlElement object representing the <field /> tag for the form field object. * @param mixed $value The form field value to validate. * @param string $group The field name group control value. This acts as as an array container for the field. * For example if the field has name="foo" and the group value is set to "bar" then the * full field name would end up being "bar[foo]". * * @return boolean True on success. */ public function setup(SimpleXMLElement $element, $value, $group = null) { parent::setup($element, $value, $group); $container = \Windwalker\DI\Container::getInstance(); $input = $container->get('input'); $delete = isset($_REQUEST['jform']['profile'][$this->element['name'] . '_delete']) ? $_REQUEST['jform']['profile'][$this->element['name'] . '_delete'] : 0; if ($delete == 1) { $this->value = ''; } else { // Upload Image // =============================================== if (isset($_FILES['jform']['name']['profile'])) { foreach ($_FILES['jform']['name']['profile'] as $key => $var) { if (!$var) { continue; } // Get Field Attr $width = $this->element['save_width'] ? $this->element['save_width'] : 800; $height = $this->element['save_height'] ? $this->element['save_height'] : 800; // Build File name $src = $_FILES['jform']['tmp_name']['profile'][$key]; $var = explode('.', $var); $date = DateHelper::getDate(); $name = md5((string) $date . $width . $height . $src) . '.' . array_pop($var); $url = "images/cck/{$date->year}/{$date->month}/{$date->day}/" . $name; // A Event for extend. $container->get('event.dispatcher')->trigger('onCCKEngineUploadImage', array(&$url, &$this, &$this->element)); $dest = JPATH_ROOT . '/' . $url; // Upload First JFile::upload($src, $dest); // Resize image $img = new JImage(); $img->loadFile(JPATH_ROOT . '/' . $url); $img = $img->resize($width, $height); switch (array_pop($var)) { case 'gif': $type = IMAGETYPE_GIF; break; case 'png': $type = IMAGETYPE_PNG; break; default: $type = IMAGETYPE_JPEG; break; } // Save $img->toFile($dest, $type, array('quality' => 85)); // Set in Value $this->value = $url; // Clean cache $thumb = $this->getThumbPath(); if (is_file(JPATH_ROOT . '/' . $thumb)) { \JFile::delete(JPATH_ROOT . '/' . $thumb); } } } } return true; }
/** * Return the {@link JDate} object * * @param mixed $time The initial time for the JDate object * @param mixed $tzOffset The timezone offset. * * @return \JDate object */ public static function getDate($time = 'now', $tzOffset = null) { if (!$tzOffset) { $config = Container::getInstance()->get('joomla.config'); $tzOffset = $config->get('offset'); } return \JFactory::getDate($time, $tzOffset); }
/** * Restore original Application instance * * @return void */ public static function restoreApplication() { $container = Container::getInstance(); $className = get_class(static::$originalApplication); $container->alias('app', $className); $container->share($className, static::$originalApplication); \JFactory::$application = static::$originalApplication; }
/** * Get a query string to filter the publishing items now. * * Will return: '( publish_up < 'xxxx-xx-xx' OR publish_up = '0000-00-00' ) * AND ( publish_down > 'xxxx-xx-xx' OR publish_down = '0000-00-00' )' * * @param string $prefix Prefix to columns name, eg: 'a.' will use `a`.`publish_up`. * * @return string Query string. */ public static function publishingPeriod($prefix = '') { $db = Container::getInstance()->get('db'); $nowDate = $date = DateHelper::getDate()->toSQL(); $nullDate = $db->getNullDate(); $date_where = " ( {$prefix}publish_up < '{$nowDate}' OR {$prefix}publish_up = '{$nullDate}') AND " . " ( {$prefix}publish_down > '{$nowDate}' OR {$prefix}publish_down = '{$nullDate}') "; return $date_where; }
/** * Method to get the user field input markup. * * @return string The field input markup. */ protected function getInput() { $html = array(); $groups = $this->getGroups(); $excluded = $this->getExcluded(); $link = 'index.php?option=com_users&view=users&layout=modal&tmpl=component&field=' . $this->id . (isset($groups) ? '&groups=' . base64_encode(json_encode($groups)) : '') . (isset($excluded) ? '&excluded=' . base64_encode(json_encode($excluded)) : ''); // Initialize some field attributes. $attr = $this->element['class'] ? ' class="' . (string) $this->element['class'] . '"' : ''; $attr .= $this->element['size'] ? ' size="' . (int) $this->element['size'] . '"' : ''; // Initialize JavaScript field attributes. $onchange = (string) $this->element['onchange']; // Load the modal behavior script. WindwalkerScript::modal('.hasUserModal'); JQueryScript::ui(array('effect')); // Build the script. $js = <<<JS function jSelectUser_{$this->id}(id, title) { \tvar input = jQuery('#{$this->id}_id'); \tvar oldId = input.val(); \tif (oldId != id) { \t\tinput.val(id); \t\tjQuery('#{$this->id}_name').val(title).removeClass('invalid').delay(300).effect('highlight'); \t} \t{$onchange}; \tWindwalker.Modal.hide(); }; JS; // Add the script to the document head. $asset = Container::getInstance()->get('helper.asset'); $asset->internalJS($js); // Load the current username if available. $table = JTable::getInstance('user'); if ($this->value) { $table->load($this->value); } elseif (strtoupper($this->value) == 'CURRENT') { // 'CURRENT' is not a reasonable value to be placed in the html $this->value = JFactory::getUser()->id; $table->load($this->value); } else { $table->name = JText::_('JLIB_FORM_SELECT_USER'); } // Create a dummy text field with the user name. $html[] = '<div class="input-append">'; $html[] = ' <input type="text" id="' . $this->id . '_name" value="' . htmlspecialchars($table->name, ENT_COMPAT, 'UTF-8') . '"' . ' readonly' . $attr . ' />'; // Create the user select button. if (!XmlHelper::getBool($this->element, 'readonly', false)) { $html[] = ' <a class="btn btn-primary hasUserModal modal_' . $this->id . '" title="' . JText::_('JLIB_FORM_CHANGE_USER') . '" href="' . $link . '"' . ' rel="{handler: \'iframe\', size: {x: 800, y: 500}}">'; $html[] = '<i class="icon-user"></i></a>'; } $html[] = '</div>'; // Create the real field, hidden, that stored the user id. $html[] = '<input type="hidden" id="' . $this->id . '_id" name="' . $this->name . '" value="' . $this->value . '" />'; return implode("\n", $html); }
/** * Register Bundles * * @param Container $container DI container. * * @return void */ protected function registerBundles(Container $container) { if (!is_dir(WINDWALKER_BUNDLE)) { return; } $paths = new PathCollection(array(WINDWALKER . '/bundles', WINDWALKER_BUNDLE)); $bundles = $paths->find('Bundle$'); $config = $container->get('windwalker.config'); foreach ($bundles as $bundle) { $bundleName = $bundle->getBasename(); $class = $bundleName . '\\' . $bundleName; \JLoader::registerNamespace($bundleName, dirname((string) $bundle)); if (class_exists($class) && is_subclass_of($class, 'Windwalker\\Bundle\\AbstractBundle')) { $config->set('bundle.' . $bundleName, $class); $class::registerProvider($container); } } }
/** * Registers the service provider with a DI container. * * @param Container $container The DI container. * * @return void */ public function register(Container $container) { if ($container->getParent()) { $container = $container->getParent(); } if ($this->package->app->isConsole()) { return; } // Html document $closure = function (Container $container) { return $container->newInstance(HtmlHeaderManager::class); }; $container->share(HtmlHeaderManager::class, $closure)->alias('html.header', HtmlHeaderManager::class); $container->extend(RendererManager::class, function (RendererManager $manager, Container $container) { $manager->addGlobalPath(PHOENIX_SOURCE . '/Resources/templates', PriorityQueue::LOW - 25); return $manager; }); }
/** * Object constructor to set table and key fields. In most cases this will * be overridden by child classes to explicitly set the table and key fields * for a particular database table. * * @param string $table Name of the table to model. * @param mixed $key Name of the primary key field in the table or array of field names that compose the primary key. * @param \JDatabaseDriver $db JDatabaseDriver object. */ public function __construct($table, $key = 'id', $db = null) { $db = $db ?: Container::getInstance()->get('db'); parent::__construct($table, $key, $db); // Prepare Relation handler $this->_relation = new Relation($this, $this->getPrefix()); RelationObserver::createObserver($this); $this->configure(); $this->_observers->update('onAfterConstruction', array()); }
/** * Get the raw data assigned to a key. * * @param string $key The key for which to get the stored item. * * @return DataStore * * @since 2.0 */ protected function getRaw($key) { $key = $this->resolveAlias($key); if (isset($this->dataStore[$key])) { return $this->dataStore[$key]; } elseif ($this->parent instanceof Container) { return $this->parent->getRaw($key); } return null; }
/** * If default value exists. */ public function setFieldData() { $input = $this->container->get('input'); if (!$input->get('id')) { $app = JFactory::getApplication(); $app->setUserState('lib_windwalker.cck.fields', null); } $type = $input->get('field_type'); $this->value = $type ?: $this->value; }
/** * executeSql * * @param string $sql * * @return void */ protected function executeSql($sql) { $db = Container::getInstance()->get('db'); $queries = $db->splitSql($sql); foreach ($queries as $query) { if (!trim($query)) { continue; } $db->setQuery($query)->execute(); } }
/** * constructor. * * @param Command $command * @param Container $container * @param IOInterface $io */ public function __construct(Command $command, Container $container = null, IOInterface $io = null) { $this->command = $command; $container = $container ?: Container::getInstance(); $this->container = $container; $container->registerServiceProvider(new GeneratorBundleProvider($command)); $io = $io ?: $container->get('io'); $io->setCommand($command); parent::__construct($container, $io); $container->registerServiceProvider(new OperatorProvider($command)); }
/** * Detach a listener. * * @param \JEvent|string|array $listener The listener name to detach. * @param \JEventDispatcher $dispatcher The EventDispatcher. * * @return boolean True if the observer object was detached. */ protected static function detach($listener, $dispatcher = null) { $dispatcher = $dispatcher ?: Container::getInstance()->get('event.dispatcher'); if (is_string($listener) && class_exists($listener)) { if (empty(static::$listener[$listener])) { static::$listener[$listener] = $listener = new $listener($dispatcher); } else { $listener = static::$listener[$listener]; } } return $dispatcher->detach($listener); }
/** * Add JS to head. */ public function addScript($num = 0) { $script = <<<SCRIPT ;jQuery(document).ready(function(\$) { \twindow.WindwalkerCCKList.init({}); }); SCRIPT; $asset = $this->container->get('helper.asset'); $asset->addJs('cck/list.js'); $asset->internalJS($script); }
/** * init * * @param \JDocument $template JDcoument object. * @param \JRegistry $params Template params. * * @return Template */ public function init(\JDocument $template, \JRegistry $params) { include_once static::windwalkerPath(); static::$template = $template; static::$params = $params; static::$asset = Container::getInstance('tpl_' . static::$name)->get('helper.asset'); // Reset AssetHelper static::$asset->resetPaths(); static::$asset->setDoc($template); static::registerStylesheet($template); static::registerScript($template); return $this; }
/** * Pass Relation object to Parent Table. * * @return void */ public function onAfterConstruction() { $relation = $this->mapper->getRelation(); $this->parentTable = $relation->getParent(); $this->parentTable->_relation = $relation; // Pass global relation configuration into parent. $relations = Container::getInstance()->get('relation.container')->getRelation($this->mapper->getTable()); /** @var Relation $relations */ foreach ($relations->getRelations() as $relation) { /** @var AbstractRelationHandler $relation */ $relation->setParent($this->parentTable); $this->parentTable->_relation->setRelation($relation->getField(), $relation); } }
/** * Pass Relation object to Parent Table. * * @return void */ public function onAfterConstruction() { if (!$this->table instanceof Table) { return; } // Pass global relation configuration into parent. $relations = Container::getInstance()->get('relation.container')->getRelation($this->table->getTableName()); /** @var Relation $relations */ foreach ($relations->getRelations() as $relation) { /** @var AbstractRelationHandler $relation */ $relation->setParent($this->table); $this->table->_relation->setRelation($relation->getField(), $relation); } }
/** * Add an quick add button & modal * * @return string The quickadd button. */ public function quickadd() { // Prepare Element $readonly = $this->getElement('readonly', false); $disabled = $this->getElement('disabled', false); if ($readonly || $disabled) { return ''; } $container = Container::getInstance(); $input = $container->get('input'); $quickadd = $this->getElement('quickadd', false); $table_name = $this->getElement('table', '#__' . $this->component . '_' . $this->view_list); $key_field = $this->getElement('key_field', 'id'); $value_field = $this->getElement('value_field', 'title'); $formpath = WINDWALKER_SOURCE . "/Form/Forms/quickadd/category.xml"; $quickadd_handler = $this->getElement('quickadd_handler', $input->get('option')); $title = $this->getElement('quickadd_label', 'LIB_WINDWALKER_QUICKADD_TITLE'); $qid = $this->id . '_quickadd'; if (!$quickadd) { return ''; } // Set AKQuickAddOption $config['task'] = $this->view_item . '.ajax.legacyquickadd'; $config['quickadd_handler'] = $quickadd_handler; $config['cat_extension'] = (string) $this->element['extension']; $config['extension'] = 'com_' . $this->component; $config['component'] = $this->component; $config['table'] = $table_name; $config['model_name'] = 'category'; $config['key_field'] = $key_field; $config['value_field'] = $value_field; $config['joomla3'] = JVERSION >= 3; WindwalkerScript::quickadd('#' . $qid, $config); // Load Language & Form LanguageHelper::loadLanguage('com_' . $this->component, null); $formpath = str_replace(JPATH_ROOT, '', $formpath); $content = ModalHelper::getQuickaddForm($qid, $formpath, (string) $this->element['extension']); // Prepare HTML $html = ''; $button_title = $title; $modal_title = $button_title; $button_class = 'btn btn-small btn-success quickadd_button'; $footer = "<button class=\"btn\" type=\"button\" data-dismiss=\"modal\">" . JText::_('JCANCEL') . "</button>"; $footer .= "<button class=\"btn btn-primary\" type=\"submit\">" . JText::_('JSUBMIT') . "</button>"; $html .= ModalHelper::modalLink(JText::_($button_title), $qid, array('class' => $button_class, 'icon' => 'icon-new icon-white')); $html .= ModalHelper::renderModal($qid, $content, array('title' => JText::_($modal_title), 'footer' => $footer)); return $html; }
/** * viewLevel * * @param Data $item * @param Data $category * @param \JRegistry $state * @param \JRegistry $params * * @return void */ public static function viewLevel(Data $item, Data $category, \JRegistry $state, \JRegistry $params) { $user = Container::getInstance()->get('user'); if ($access = $state->get('filter.access')) { // If the access filter has been set, we already know this user can view. $params->set('access-view', true); } else { // If no access filter is set, the layout takes some responsibility for display of limited information. $groups = $user->getAuthorisedViewLevels(); if (!$item->catid || empty($category->access)) { $params->set('access-view', in_array($item->access, $groups)); } else { $params->set('access-view', in_array($item->access, $groups) && in_array($category->access, $groups)); } } }