Example #1
0
 /**
  * Method to get the lang tag
  * @return string lang iso tag
  */
 function &getLangTag()
 {
     if (is_null($this->lang_tag)) {
         $this->lang_tag = Lang::getTag();
         if (!Filesystem::exists(JPATH_BASE . '/help/' . $this->lang_tag)) {
             $this->lang_tag = 'en-GB';
             // use english as fallback
         }
     }
     return $this->lang_tag;
 }
    /**
     * @since	1.6
     */
    public function onContentBeforeDisplay($context, &$row, &$params, $page = 0)
    {
        $view = Request::getCmd('view');
        $print = Request::getBool('print');
        if ($print) {
            return false;
        }
        if ($params->get('show_item_navigation') && $context == 'com_content.article' && $view == 'article') {
            $html = '';
            $db = App::get('db');
            $nullDate = $db->getNullDate();
            $date = Date::of('now');
            $now = $date->toSql();
            $uid = $row->id;
            $option = 'com_content';
            $canPublish = User::authorise('core.edit.state', $option . '.article.' . $row->id);
            // The following is needed as different menu items types utilise a different param to control ordering.
            // For Blogs the `orderby_sec` param is the order controlling param.
            // For Table and List views it is the `orderby` param.
            $params_list = $params->toArray();
            if (array_key_exists('orderby_sec', $params_list)) {
                $order_method = $params->get('orderby_sec', '');
            } else {
                $order_method = $params->get('orderby', '');
            }
            // Additional check for invalid sort ordering.
            if ($order_method == 'front') {
                $order_method = '';
            }
            // Determine sort order.
            switch ($order_method) {
                case 'date':
                    $orderby = 'a.created';
                    break;
                case 'rdate':
                    $orderby = 'a.created DESC';
                    break;
                case 'alpha':
                    $orderby = 'a.title';
                    break;
                case 'ralpha':
                    $orderby = 'a.title DESC';
                    break;
                case 'hits':
                    $orderby = 'a.hits';
                    break;
                case 'rhits':
                    $orderby = 'a.hits DESC';
                    break;
                case 'order':
                    $orderby = 'a.ordering';
                    break;
                case 'author':
                    $orderby = 'a.created_by_alias, u.name';
                    break;
                case 'rauthor':
                    $orderby = 'a.created_by_alias DESC, u.name DESC';
                    break;
                case 'front':
                    $orderby = 'f.ordering';
                    break;
                default:
                    $orderby = 'a.ordering';
                    break;
            }
            $xwhere = ' AND (a.state = 1 OR a.state = -1)' . ' AND (publish_up = ' . $db->Quote($nullDate) . ' OR publish_up <= ' . $db->Quote($now) . ')' . ' AND (publish_down = ' . $db->Quote($nullDate) . ' OR publish_down >= ' . $db->Quote($now) . ')';
            // Array of articles in same category correctly ordered.
            $query = $db->getQuery(true);
            //sqlsrv changes
            $case_when = ' CASE WHEN ';
            $case_when .= $query->charLength('a.alias');
            $case_when .= ' THEN ';
            $a_id = $query->castAsChar('a.id');
            $case_when .= $query->concatenate(array($a_id, 'a.alias'), ':');
            $case_when .= ' ELSE ';
            $case_when .= $a_id . ' END as slug';
            $case_when1 = ' CASE WHEN ';
            $case_when1 .= $query->charLength('cc.alias');
            $case_when1 .= ' THEN ';
            $c_id = $query->castAsChar('cc.id');
            $case_when1 .= $query->concatenate(array($c_id, 'cc.alias'), ':');
            $case_when1 .= ' ELSE ';
            $case_when1 .= $c_id . ' END as catslug';
            $query->select('a.id, a.language,' . $case_when . ',' . $case_when1);
            $query->from('#__content AS a');
            $query->leftJoin('#__categories AS cc ON cc.id = a.catid');
            $query->where('a.catid = ' . (int) $row->catid . ' AND a.state = ' . (int) $row->state . ($canPublish ? '' : ' AND a.access = ' . (int) $row->access) . $xwhere);
            $query->order($orderby);
            if (\App::isSite() && \App::get('language.filter')) {
                $query->where('a.language in (' . $db->quote(Lang::getTag()) . ',' . $db->quote('*') . ')');
            }
            $db->setQuery($query);
            $list = $db->loadObjectList('id');
            // This check needed if incorrect Itemid is given resulting in an incorrect result.
            if (!is_array($list)) {
                $list = array();
            }
            reset($list);
            // Location of current content item in array list.
            $location = array_search($uid, array_keys($list));
            $rows = array_values($list);
            $row->prev = null;
            $row->next = null;
            if ($location - 1 >= 0) {
                // The previous content item cannot be in the array position -1.
                $row->prev = $rows[$location - 1];
            }
            if ($location + 1 < count($rows)) {
                // The next content item cannot be in an array position greater than the number of array postions.
                $row->next = $rows[$location + 1];
            }
            $pnSpace = "";
            if (Lang::txt('JGLOBAL_LT') || Lang::txt('JGLOBAL_GT')) {
                $pnSpace = " ";
            }
            if ($row->prev) {
                $row->prev = Route::url(ContentHelperRoute::getArticleRoute($row->prev->slug, $row->prev->catslug, $row->prev->language));
            } else {
                $row->prev = '';
            }
            if ($row->next) {
                $row->next = Route::url(ContentHelperRoute::getArticleRoute($row->next->slug, $row->next->catslug, $row->next->language));
            } else {
                $row->next = '';
            }
            // Output.
            if ($row->prev || $row->next) {
                $html = '
				<ul class="pagenav">';
                if ($row->prev) {
                    $html .= '
					<li class="pagenav-prev">
						<a href="' . $row->prev . '" rel="prev">' . Lang::txt('JGLOBAL_LT') . $pnSpace . Lang::txt('JPREV') . '</a>
					</li>';
                }
                if ($row->next) {
                    $html .= '
					<li class="pagenav-next">
						<a href="' . $row->next . '" rel="next">' . Lang::txt('JNEXT') . $pnSpace . Lang::txt('JGLOBAL_GT') . '</a>
					</li>';
                }
                $html .= '
				</ul>';
                $row->pagination = $html;
                $row->paginationposition = $this->params->get('position', 1);
                // This will default to the 1.5 and 1.6-1.7 behavior.
                $row->paginationrelative = $this->params->get('relative', 0);
            }
        }
        return;
    }
 public function onAfterInitialise()
 {
     $app = JFactory::getApplication();
     $app->menu_associations = $this->params->get('menu_associations', 0);
     if (App::isSite()) {
         self::$tag = Lang::getTag();
         $router = $app->getRouter();
         // attach build rules for language SEF
         $router->attachBuildRule(array($this, 'buildRule'));
         // attach parse rules for language SEF
         $router->attachParseRule(array($this, 'parseRule'));
         // Adding custom site name
         $languages = JLanguageHelper::getLanguages('lang_code');
         if (isset($languages[self::$tag]) && $languages[self::$tag]->sitename) {
             Config::set('sitename', $languages[self::$tag]->sitename);
         }
     }
 }
Example #4
0
 /**
  * Get the master query for retrieving a list of articles subject to the model state.
  *
  * @return	JDatabaseQuery
  * @since	1.6
  */
 function getListQuery()
 {
     // Create a new query object.
     $db = $this->getDbo();
     $query = $db->getQuery(true);
     // Select the required fields from the table.
     $query->select($this->getState('list.select', 'a.id, a.title, a.alias, a.title_alias, a.introtext, a.language, ' . 'a.checked_out, a.checked_out_time, ' . 'a.catid, a.created, a.created_by, a.created_by_alias, ' . 'CASE WHEN a.modified = 0 THEN a.created ELSE a.modified END as modified, ' . 'a.modified_by, uam.name as modified_by_name,' . 'CASE WHEN a.publish_up = 0 THEN a.created ELSE a.publish_up END as publish_up,' . 'a.publish_down, a.images, a.urls, a.attribs, a.metadata, a.metakey, a.metadesc, a.access, ' . 'a.hits, a.xreference, a.featured,' . ' ' . $query->length('a.fulltext') . ' AS readmore'));
     // Process an Archived Article layout
     if ($this->getState('filter.published') == 2) {
         // If badcats is not null, this means that the article is inside an archived category
         // In this case, the state is set to 2 to indicate Archived (even if the article state is Published)
         $query->select($this->getState('list.select', 'CASE WHEN badcats.id is null THEN a.state ELSE 2 END AS state'));
     } else {
         // Process non-archived layout
         // If badcats is not null, this means that the article is inside an unpublished category
         // In this case, the state is set to 0 to indicate Unpublished (even if the article state is Published)
         $query->select($this->getState('list.select', 'CASE WHEN badcats.id is not null THEN 0 ELSE a.state END AS state'));
     }
     $query->from('#__content AS a');
     // Join over the frontpage articles.
     if ($this->context != 'com_content.featured') {
         $query->join('LEFT', '#__content_frontpage AS fp ON fp.content_id = a.id');
     }
     // Join over the categories.
     $query->select('c.title AS category_title, c.path AS category_route, c.access AS category_access, c.alias AS category_alias');
     $query->join('LEFT', '#__categories AS c ON c.id = a.catid');
     // Join over the users for the author and modified_by names.
     $query->select("CASE WHEN a.created_by_alias > ' ' THEN a.created_by_alias ELSE ua.name END AS author");
     $query->select("ua.email AS author_email");
     $query->join('LEFT', '#__users AS ua ON ua.id = a.created_by');
     $query->join('LEFT', '#__users AS uam ON uam.id = a.modified_by');
     // Get contact id
     $subQuery = $db->getQuery(true);
     $subQuery->select('MAX(contact.id) AS id');
     $subQuery->from('#__contact_details AS contact');
     $subQuery->where('contact.published = 1');
     $subQuery->where('contact.user_id = a.created_by');
     // Filter by language
     if ($this->getState('filter.language')) {
         $subQuery->where('(contact.language in (' . $db->quote(Lang::getTag()) . ',' . $db->quote('*') . ') OR contact.language IS NULL)');
     }
     // [!] Hubzero - Removed contact_details table
     //$query->select('(' . $subQuery . ') as contactid');
     $query->select('(0) as contactid');
     // Join over the categories to get parent category titles
     $query->select('parent.title as parent_title, parent.id as parent_id, parent.path as parent_route, parent.alias as parent_alias');
     $query->join('LEFT', '#__categories as parent ON parent.id = c.parent_id');
     // Join on voting table
     $query->select('ROUND(v.rating_sum / v.rating_count, 0) AS rating, v.rating_count as rating_count');
     $query->join('LEFT', '#__content_rating AS v ON a.id = v.content_id');
     // Join to check for category published state in parent categories up the tree
     $query->select('c.published, CASE WHEN badcats.id is null THEN c.published ELSE 0 END AS parents_published');
     $subquery = 'SELECT cat.id as id FROM #__categories AS cat JOIN #__categories AS parent ';
     $subquery .= 'ON cat.lft BETWEEN parent.lft AND parent.rgt ';
     $subquery .= 'WHERE parent.extension = ' . $db->quote('com_content');
     if ($this->getState('filter.published') == 2) {
         // Find any up-path categories that are archived
         // If any up-path categories are archived, include all children in archived layout
         $subquery .= ' AND parent.published = 2 GROUP BY cat.id ';
         // Set effective state to archived if up-path category is archived
         $publishedWhere = 'CASE WHEN badcats.id is null THEN a.state ELSE 2 END';
     } else {
         // Find any up-path categories that are not published
         // If all categories are published, badcats.id will be null, and we just use the article state
         $subquery .= ' AND parent.published != 1 GROUP BY cat.id ';
         // Select state to unpublished if up-path category is unpublished
         $publishedWhere = 'CASE WHEN badcats.id is null THEN a.state ELSE 0 END';
     }
     $query->join('LEFT OUTER', '(' . $subquery . ') AS badcats ON badcats.id = c.id');
     // Filter by access level.
     if ($access = $this->getState('filter.access')) {
         $groups = implode(',', User::getAuthorisedViewLevels());
         $query->where('a.access IN (' . $groups . ')');
         $query->where('c.access IN (' . $groups . ')');
     }
     // Filter by published state
     $published = $this->getState('filter.published');
     if (is_numeric($published)) {
         // Use article state if badcats.id is null, otherwise, force 0 for unpublished
         $query->where($publishedWhere . ' = ' . (int) $published);
     } elseif (is_array($published)) {
         \Hubzero\Utility\Arr::toInteger($published);
         $published = implode(',', $published);
         // Use article state if badcats.id is null, otherwise, force 0 for unpublished
         $query->where($publishedWhere . ' IN (' . $published . ')');
     }
     // Filter by featured state
     $featured = $this->getState('filter.featured');
     switch ($featured) {
         case 'hide':
             $query->where('a.featured = 0');
             break;
         case 'only':
             $query->where('a.featured = 1');
             break;
         case 'show':
         default:
             // Normally we do not discriminate
             // between featured/unfeatured items.
             break;
     }
     // Filter by a single or group of articles.
     $articleId = $this->getState('filter.article_id');
     if (is_numeric($articleId)) {
         $type = $this->getState('filter.article_id.include', true) ? '= ' : '<> ';
         $query->where('a.id ' . $type . (int) $articleId);
     } elseif (is_array($articleId)) {
         \Hubzero\Utility\Arr::toInteger($articleId);
         $articleId = implode(',', $articleId);
         $type = $this->getState('filter.article_id.include', true) ? 'IN' : 'NOT IN';
         $query->where('a.id ' . $type . ' (' . $articleId . ')');
     }
     // Filter by a single or group of categories
     $categoryId = $this->getState('filter.category_id');
     if (is_numeric($categoryId)) {
         $type = $this->getState('filter.category_id.include', true) ? '= ' : '<> ';
         // Add subcategory check
         $includeSubcategories = $this->getState('filter.subcategories', false);
         $categoryEquals = 'a.catid ' . $type . (int) $categoryId;
         if ($includeSubcategories) {
             $levels = (int) $this->getState('filter.max_category_levels', '1');
             // Create a subquery for the subcategory list
             $subQuery = $db->getQuery(true);
             $subQuery->select('sub.id');
             $subQuery->from('#__categories as sub');
             $subQuery->join('INNER', '#__categories as this ON sub.lft > this.lft AND sub.rgt < this.rgt');
             $subQuery->where('this.id = ' . (int) $categoryId);
             if ($levels >= 0) {
                 $subQuery->where('sub.level <= this.level + ' . $levels);
             }
             // Add the subquery to the main query
             $query->where('(' . $categoryEquals . ' OR a.catid IN (' . $subQuery->__toString() . '))');
         } else {
             $query->where($categoryEquals);
         }
     } elseif (is_array($categoryId) && count($categoryId) > 0) {
         \Hubzero\Utility\Arr::toInteger($categoryId);
         $categoryId = implode(',', $categoryId);
         if (!empty($categoryId)) {
             $type = $this->getState('filter.category_id.include', true) ? 'IN' : 'NOT IN';
             $query->where('a.catid ' . $type . ' (' . $categoryId . ')');
         }
     }
     // Filter by author
     $authorId = $this->getState('filter.author_id');
     $authorWhere = '';
     if (is_numeric($authorId)) {
         $type = $this->getState('filter.author_id.include', true) ? '= ' : '<> ';
         $authorWhere = 'a.created_by ' . $type . (int) $authorId;
     } elseif (is_array($authorId)) {
         \Hubzero\Utility\Arr::toInteger($authorId);
         $authorId = implode(',', $authorId);
         if ($authorId) {
             $type = $this->getState('filter.author_id.include', true) ? 'IN' : 'NOT IN';
             $authorWhere = 'a.created_by ' . $type . ' (' . $authorId . ')';
         }
     }
     // Filter by author alias
     $authorAlias = $this->getState('filter.author_alias');
     $authorAliasWhere = '';
     if (is_string($authorAlias)) {
         $type = $this->getState('filter.author_alias.include', true) ? '= ' : '<> ';
         $authorAliasWhere = 'a.created_by_alias ' . $type . $db->Quote($authorAlias);
     } elseif (is_array($authorAlias)) {
         $first = current($authorAlias);
         if (!empty($first)) {
             \Hubzero\Utility\Arr::toString($authorAlias);
             foreach ($authorAlias as $key => $alias) {
                 $authorAlias[$key] = $db->Quote($alias);
             }
             $authorAlias = implode(',', $authorAlias);
             if ($authorAlias) {
                 $type = $this->getState('filter.author_alias.include', true) ? 'IN' : 'NOT IN';
                 $authorAliasWhere = 'a.created_by_alias ' . $type . ' (' . $authorAlias . ')';
             }
         }
     }
     if (!empty($authorWhere) && !empty($authorAliasWhere)) {
         $query->where('(' . $authorWhere . ' OR ' . $authorAliasWhere . ')');
     } elseif (empty($authorWhere) && empty($authorAliasWhere)) {
         // If both are empty we don't want to add to the query
     } else {
         // One of these is empty, the other is not so we just add both
         $query->where($authorWhere . $authorAliasWhere);
     }
     // Define null and now dates
     $nullDate = $db->Quote($db->getNullDate());
     $nowDate = $db->Quote(Date::toSql());
     if (!User::authorise('core.edit.state', 'com_content') && !User::authorise('core.edit', 'com_content')) {
         // Filter by start and end dates.
         $query->where('(a.publish_up = ' . $nullDate . ' OR a.publish_up <= ' . $nowDate . ')');
         $query->where('(a.publish_down = ' . $nullDate . ' OR a.publish_down >= ' . $nowDate . ')');
     }
     // Filter by Date Range or Relative Date
     $dateFiltering = $this->getState('filter.date_filtering', 'off');
     $dateField = $this->getState('filter.date_field', 'a.created');
     switch ($dateFiltering) {
         case 'range':
             $startDateRange = $db->Quote($this->getState('filter.start_date_range', $nullDate));
             $endDateRange = $db->Quote($this->getState('filter.end_date_range', $nullDate));
             $query->where('(' . $dateField . ' >= ' . $startDateRange . ' AND ' . $dateField . ' <= ' . $endDateRange . ')');
             break;
         case 'relative':
             $relativeDate = (int) $this->getState('filter.relative_date', 0);
             $query->where($dateField . ' >= DATE_SUB(' . $nowDate . ', INTERVAL ' . $relativeDate . ' DAY)');
             break;
         case 'off':
         default:
             break;
     }
     // process the filter for list views with user-entered filters
     $params = $this->getState('params');
     if (is_object($params) && $params->get('filter_field') != 'hide' && ($filter = $this->getState('list.filter'))) {
         // clean filter variable
         $filter = JString::strtolower($filter);
         $hitsFilter = intval($filter);
         $filter = $db->Quote('%' . $db->escape($filter, true) . '%', false);
         switch ($params->get('filter_field')) {
             case 'author':
                 $query->where('LOWER( CASE WHEN a.created_by_alias > ' . $db->quote(' ') . ' THEN a.created_by_alias ELSE ua.name END ) LIKE ' . $filter . ' ');
                 break;
             case 'hits':
                 $query->where('a.hits >= ' . $hitsFilter . ' ');
                 break;
             case 'title':
             default:
                 // default to 'title' if parameter is not valid
                 $query->where('LOWER( a.title ) LIKE ' . $filter);
                 break;
         }
     }
     // Filter by language
     if ($this->getState('filter.language')) {
         $query->where('a.language in (' . $db->quote(Lang::getTag()) . ',' . $db->quote('*') . ')');
     }
     // Add the list ordering clause.
     $query->order($this->getState('list.ordering', 'a.ordering') . ' ' . $this->getState('list.direction', 'ASC'));
     return $query;
 }
Example #5
0
 /**
  * Get array of help pages for component
  *
  * @param   string  $component  Component to get pages for
  * @return  array
  */
 public static function pages($component)
 {
     $database = \App::get('db');
     // Get component name from database
     $database->setQuery("SELECT `name`\n\t\t\tFROM `#__extensions`\n\t\t\tWHERE `type`=" . $database->quote('component') . "\n\t\t\tAND `element`=" . $database->quote($component) . "\n\t\t\tAND `enabled`=1");
     $name = $database->loadResult();
     // Make sure we have a component
     if ($name == '') {
         $name = str_replace('com_', '', $component);
         return array('name' => ucfirst($name), 'option' => $component, 'pages' => array());
     }
     // Path to help pages
     $helpPagesPath = self::path($component) . DS . 'help' . DS . \Lang::getTag();
     // Make sure directory exists
     $pages = array();
     if (is_dir($helpPagesPath)) {
         // Get help pages for this component
         $pages = \Filesystem::files($helpPagesPath, '.' . self::$ext);
     }
     $pages = array_map(function ($file) {
         return ltrim($file, DS);
     }, $pages);
     // Return pages
     return array('name' => $name, 'option' => $component, 'pages' => $pages);
 }
Example #6
0
 /**
  * Method to build an SQL query to load the list data.
  *
  * @return	string	An SQL query
  * @since	1.6
  */
 protected function getListQuery()
 {
     $user = User::getRoot();
     $groups = implode(',', $user->getAuthorisedViewLevels());
     // Create a new query object.
     $db = $this->getDbo();
     $query = $db->getQuery(true);
     // Select required fields from the categories.
     $query->select($this->getState('list.select', 'a.*'));
     $query->from($db->quoteName('#__newsfeeds') . ' AS a');
     $query->where('a.access IN (' . $groups . ')');
     // Filter by category.
     if ($categoryId = $this->getState('category.id')) {
         $query->where('a.catid = ' . (int) $categoryId);
         $query->join('LEFT', '#__categories AS c ON c.id = a.catid');
         $query->where('c.access IN (' . $groups . ')');
     }
     // Filter by state
     $state = $this->getState('filter.published');
     if (is_numeric($state)) {
         $query->where('a.published = ' . (int) $state);
     }
     // Filter by start and end dates.
     $nullDate = $db->Quote($db->getNullDate());
     $date = Date::of('now');
     $nowDate = $db->Quote($date->format($db->getDateFormat()));
     if ($this->getState('filter.publish_date')) {
         $query->where('(a.publish_up = ' . $nullDate . ' OR a.publish_up <= ' . $nowDate . ')');
         $query->where('(a.publish_down = ' . $nullDate . ' OR a.publish_down >= ' . $nowDate . ')');
     }
     // Filter by language
     if ($this->getState('filter.language')) {
         $query->where('a.language in (' . $db->Quote(Lang::getTag()) . ',' . $db->Quote('*') . ')');
     }
     // Add the list ordering clause.
     $query->order($db->escape($this->getState('list.ordering', 'a.ordering')) . ' ' . $db->escape($this->getState('list.direction', 'ASC')));
     return $query;
 }
Example #7
0
 /**
  * Load login modules.
  *
  * Note that we load regardless of state or access level since access
  * for public is the only thing that makes sense since users are not logged in
  * and the module lets them log in.
  * This is put in as a failsafe to avoid super user lock out caused by an unpublished
  * login module or by a module set to have a viewing access level that is not Public.
  *
  * @param   string  $name   The name of the module
  * @return  array
  */
 protected static function _load($module)
 {
     static $clean;
     if (isset($clean)) {
         return $clean;
     }
     $lang = \Lang::getTag();
     $clientId = (int) \App::get('client')->id;
     $cache = \App::get('cache');
     $cacheid = 'com_modules.' . md5(serialize(array($clientId, $lang)));
     $loginmodule = array();
     try {
         $clean = $cache->get($cacheid);
     } catch (\Exception $e) {
         $clean = null;
     }
     if (!$clean) {
         $db = \App::get('db');
         $query = $db->getQuery(true);
         $query->select('m.id, m.title, m.module, m.position, m.showtitle, m.params');
         $query->from('#__modules AS m');
         $query->where('m.module =' . $db->Quote($module) . ' AND m.client_id = 1');
         $query->join('LEFT', '#__extensions AS e ON e.element = m.module AND e.client_id = m.client_id');
         $query->where('e.enabled = 1');
         // Filter by language
         if (\App::isSite() && \App::get('language.filter')) {
             $query->where('m.language IN (' . $db->Quote($lang) . ',' . $db->Quote('*') . ')');
         }
         $query->order('m.position, m.ordering');
         // Set the query
         $db->setQuery($query);
         $modules = $db->loadObjectList();
         if ($db->getErrorNum()) {
             \App::abort(500, \Lang::txt('JLIB_APPLICATION_ERROR_MODULE_LOAD', $db->getErrorMsg()));
             return $loginmodule;
         }
         // Return to simple indexing that matches the query order.
         $loginmodule = $modules;
         $cache->put($cacheid, $loginmodule, App::get('config')->get('cachetime', 15));
     }
     return $loginmodule;
 }
Example #8
0
 /**
  * Initialises the Editor.
  *
  * @return  string  JavaScript Initialization string
  */
 public function onInit()
 {
     $mode = (int) $this->params->get('mode', 1);
     $theme = array('simple', 'advanced', 'advanced');
     $skin = $this->params->get('skin', '0');
     switch ($skin) {
         case '3':
             $skin = 'skin : "o2k7", skin_variant : "black",';
             break;
         case '2':
             $skin = 'skin : "o2k7", skin_variant : "silver",';
             break;
         case '1':
             $skin = 'skin : "o2k7",';
             break;
         case '0':
         default:
             $skin = 'skin : "default",';
     }
     $entity_encoding = $this->params->def('entity_encoding', 'raw');
     $langMode = $this->params->def('lang_mode', 0);
     $langPrefix = $this->params->def('lang_code', 'en');
     if ($langMode) {
         $langPrefix = substr(Lang::getTag(), 0, strpos(Lang::getTag(), '-'));
     }
     $text_direction = 'ltr';
     if ($language->isRTL()) {
         $text_direction = 'rtl';
     }
     $use_content_css = $this->params->def('content_css', 1);
     $content_css_custom = $this->params->def('content_css_custom', '');
     // Lets get the default template for the site application
     $db = App::get('db');
     $query = $db->getQuery(true);
     $query->select('template');
     $query->from('#__template_styles');
     $query->where('client_id=0 AND home=1');
     $db->setQuery($query);
     $template = $db->loadResult();
     $content_css = '';
     $templates_path = PATH_ROOT . '/templates';
     // loading of css file for 'styles' dropdown
     if ($content_css_custom) {
         // If URL, just pass it to $content_css
         if (strpos($content_css_custom, 'http') !== false) {
             $content_css = 'content_css : "' . $content_css_custom . '",';
         } else {
             $content_css = 'content_css : "' . Request::root() . 'templates/' . $template . '/css/' . $content_css_custom . '",';
             // Issue warning notice if the file is not found (but pass name to $content_css anyway to avoid TinyMCE error
             if (!file_exists($templates_path . '/' . $template . '/css/' . $content_css_custom)) {
                 $msg = sprintf(Lang::txt('PLG_TINY_ERR_CUSTOMCSSFILENOTPRESENT'), $content_css_custom);
                 Notify::warning($msg);
             }
         }
     } else {
         // process when use_content_css is Yes and no custom file given
         if ($use_content_css) {
             // first check templates folder for default template
             // if no editor.css file in templates folder, check system template folder
             if (!file_exists($templates_path . '/' . $template . '/css/editor.css')) {
                 $template = 'system';
                 // if no editor.css file in system folder, show alert
                 if (!file_exists($templates_path . '/system/css/editor.css')) {
                     Notify::warning(Lang::txt('PLG_TINY_ERR_EDITORCSSFILENOTPRESENT'));
                 } else {
                     $content_css = 'content_css : "' . Request::root() . 'templates/system/css/editor.css",';
                 }
             } else {
                 $content_css = 'content_css : "' . Request::root() . 'templates/' . $template . '/css/editor.css",';
             }
         }
     }
     $relative_urls = $this->params->def('relative_urls', '1');
     if ($relative_urls) {
         // relative
         $relative_urls = "true";
     } else {
         // absolute
         $relative_urls = "false";
     }
     $newlines = $this->params->def('newlines', 0);
     if ($newlines) {
         // br
         $forcenewline = "force_br_newlines : true, force_p_newlines : false, forced_root_block : '',";
     } else {
         // p
         $forcenewline = "force_br_newlines : false, force_p_newlines : true, forced_root_block : 'p',";
     }
     $invalid_elements = $this->params->def('invalid_elements', 'script,applet,iframe');
     $extended_elements = $this->params->def('extended_elements', '');
     // theme_advanced_* settings
     $toolbar = $this->params->def('toolbar', 'top');
     $toolbar_align = $this->params->def('toolbar_align', 'left');
     $html_height = $this->params->def('html_height', '550');
     $html_width = $this->params->def('html_width', '750');
     $resizing = $this->params->def('resizing', 'true');
     $resize_horizontal = $this->params->def('resize_horizontal', 'false');
     $element_path = '';
     if ($this->params->get('element_path', 1)) {
         $element_path = 'theme_advanced_statusbar_location : "bottom", theme_advanced_path : true';
     } else {
         $element_path = 'theme_advanced_statusbar_location : "none", theme_advanced_path : false';
     }
     $buttons1_add_before = $buttons1_add = array();
     $buttons2_add_before = $buttons2_add = array();
     $buttons3_add_before = $buttons3_add = array();
     $buttons4 = array();
     $plugins = array();
     if ($extended_elements != "") {
         $elements = explode(',', $extended_elements);
     }
     // Initial values for buttons
     array_push($buttons4, 'cut', 'copy', 'paste');
     // array_push($buttons4,'|');
     // Plugins
     // fonts
     $fonts = $this->params->def('fonts', 1);
     if ($fonts) {
         $buttons1_add[] = 'fontselect,fontsizeselect';
     }
     // paste
     $paste = $this->params->def('paste', 1);
     if ($paste) {
         $plugins[] = 'paste';
         $buttons4[] = 'pastetext';
         $buttons4[] = 'pasteword';
         $buttons4[] = 'selectall,|';
     }
     // search & replace
     $searchreplace = $this->params->def('searchreplace', 1);
     if ($searchreplace) {
         $plugins[] = 'searchreplace';
         $buttons2_add_before[] = 'search,replace,|';
     }
     // insert date and/or time plugin
     $insertdate = $this->params->def('insertdate', 1);
     $format_date = $this->params->def('format_date', '%Y-%m-%d');
     $inserttime = $this->params->def('inserttime', 1);
     $format_time = $this->params->def('format_time', '%H:%M:%S');
     if ($insertdate or $inserttime) {
         $plugins[] = 'insertdatetime';
         if ($insertdate) {
             $buttons2_add[] = 'insertdate';
         }
         if ($inserttime) {
             $buttons2_add[] = 'inserttime';
         }
     }
     // colors
     $colors = $this->params->def('colors', 1);
     if ($colors) {
         $buttons2_add[] = 'forecolor,backcolor';
     }
     // table
     $table = $this->params->def('table', 1);
     if ($table) {
         $plugins[] = 'table';
         $buttons3_add_before[] = 'tablecontrols';
     }
     // emotions
     $smilies = $this->params->def('smilies', 1);
     if ($smilies) {
         $plugins[] = 'emotions';
         $buttons3_add[] = 'emotions';
     }
     //media plugin
     $media = $this->params->def('media', 1);
     if ($media) {
         $plugins[] = 'media';
         $buttons3_add[] = 'media';
     }
     // horizontal line
     $hr = $this->params->def('hr', 1);
     if ($hr) {
         $plugins[] = 'advhr';
         $elements[] = 'hr[id|title|alt|class|width|size|noshade|style]';
         $buttons3_add[] = 'advhr';
     } else {
         $elements[] = 'hr[id|class|title|alt]';
     }
     // rtl/ltr buttons
     $directionality = $this->params->def('directionality', 1);
     if ($directionality) {
         $plugins[] = 'directionality';
         $buttons3_add[] = 'ltr,rtl';
     }
     // fullscreen
     $fullscreen = $this->params->def('fullscreen', 1);
     if ($fullscreen) {
         $plugins[] = 'fullscreen';
         $buttons2_add[] = 'fullscreen';
     }
     // layer
     $layer = $this->params->def('layer', 1);
     if ($layer) {
         $plugins[] = 'layer';
         $buttons4[] = 'insertlayer';
         $buttons4[] = 'moveforward';
         $buttons4[] = 'movebackward';
         $buttons4[] = 'absolute';
     }
     // style
     $style = $this->params->def('style', 1);
     if ($style) {
         $plugins[] = 'style';
         $buttons4[] = 'styleprops';
     }
     // XHTMLxtras
     $xhtmlxtras = $this->params->def('xhtmlxtras', 1);
     if ($xhtmlxtras) {
         $plugins[] = 'xhtmlxtras';
         $buttons4[] = 'cite,abbr,acronym,ins,del,attribs';
     }
     // visualchars
     $visualchars = $this->params->def('visualchars', 1);
     if ($visualchars) {
         $plugins[] = 'visualchars';
         $buttons4[] = 'visualchars';
     }
     // visualblocks
     $visualblocks = $this->params->def('visualblocks', 1);
     if ($visualblocks) {
         $plugins[] = 'visualblocks';
         $buttons4[] = 'visualblocks';
     }
     // non-breaking
     $nonbreaking = $this->params->def('nonbreaking', 1);
     if ($nonbreaking) {
         $plugins[] = 'nonbreaking';
         $buttons4[] = 'nonbreaking';
     }
     // blockquote
     $blockquote = $this->params->def('blockquote', 1);
     if ($blockquote) {
         $buttons4[] = 'blockquote';
     }
     // wordcount
     $wordcount = $this->params->def('wordcount', 1);
     if ($wordcount) {
         $plugins[] = 'wordcount';
     }
     // template
     $template = $this->params->def('template', 1);
     if ($template) {
         $plugins[] = 'template';
         $buttons4[] = 'template';
     }
     // advimage
     $advimage = $this->params->def('advimage', 1);
     if ($advimage) {
         $plugins[] = 'advimage';
         $elements[] = 'img[class|src|border=0|alt|title|hspace|vspace|width|height|align|onmouseover|onmouseout|name|style]';
     }
     // advlink
     $advlink = $this->params->def('advlink', 1);
     if ($advlink) {
         $plugins[] = 'advlink';
         $elements[] = 'a[id|class|name|href|hreflang|target|title|onclick|rel|style]';
     }
     //advlist
     $advlist = $this->params->def('advlist', 1);
     if ($advlist) {
         $plugins[] = 'advlist';
     }
     // autosave
     $autosave = $this->params->def('autosave', 1);
     if ($autosave) {
         $plugins[] = 'autosave';
     }
     // context menu
     $contextmenu = $this->params->def('contextmenu', 1);
     if ($contextmenu) {
         $plugins[] = 'contextmenu';
     }
     // inline popups
     $inlinepopups = $this->params->def('inlinepopups', 1);
     if ($inlinepopups) {
         $plugins[] = 'inlinepopups';
         $dialog_type = 'dialog_type : "modal",';
     } else {
         $dialog_type = "";
     }
     $custom_plugin = $this->params->def('custom_plugin', '');
     if ($custom_plugin != "") {
         $plugins[] = $custom_plugin;
     }
     $custom_button = $this->params->def('custom_button', '');
     if ($custom_button != "") {
         $buttons4[] = $custom_button;
     }
     // Prepare config variables
     $buttons1_add_before = implode(',', $buttons1_add_before);
     $buttons2_add_before = implode(',', $buttons2_add_before);
     $buttons3_add_before = implode(',', $buttons3_add_before);
     $buttons1_add = implode(',', $buttons1_add);
     $buttons2_add = implode(',', $buttons2_add);
     $buttons3_add = implode(',', $buttons3_add);
     $buttons4 = implode(',', $buttons4);
     $plugins = implode(',', $plugins);
     $elements = implode(',', $elements);
     switch ($mode) {
         case 0:
             /* Simple mode*/
             $load = "\t<script type=\"text/javascript\" src=\"" . Request::root() . $this->_basePath . "/tiny_mce.js\"></script>\n";
             $return = $load . "\t<script type=\"text/javascript\">\n\t\t\t\ttinyMCE.init({\n\t\t\t\t\t// General\n\t\t\t\t\tdirectionality: \"{$text_direction}\",\n\t\t\t\t\teditor_selector : \"mce_editable\",\n\t\t\t\t\tlanguage : \"" . $langPrefix . "\",\n\t\t\t\t\tmode : \"specific_textareas\",\n\t\t\t\t\t{$skin}\n\t\t\t\t\ttheme : \"{$theme[$mode]}\",\n\t\t\t\t\t// Cleanup/Output\n\t\t\t\t\tinline_styles : true,\n\t\t\t\t\tgecko_spellcheck : true,\n\t\t\t\t\tentity_encoding : \"{$entity_encoding}\",\n\t\t\t\t\t{$forcenewline}\n\t\t\t\t\t// URL\n\t\t\t\t\trelative_urls : {$relative_urls},\n\t\t\t\t\tremove_script_host : false,\n\t\t\t\t\t// Layout\n\t\t\t\t\t{$content_css}\n\t\t\t\t\tdocument_base_url : \"" . Request::root() . "\"\n\t\t\t\t});\n\t\t\t\t</script>";
             break;
         case 1:
             /* Advanced mode*/
             $load = "\t<script type=\"text/javascript\" src=\"" . Request::root() . $this->_basePath . "/tiny_mce.js\"></script>\n";
             $return = $load . "\t<script type=\"text/javascript\">\n\t\t\t\ttinyMCE.init({\n\t\t\t\t\t// General\n\t\t\t\t\tdirectionality: \"{$text_direction}\",\n\t\t\t\t\teditor_selector : \"mce_editable\",\n\t\t\t\t\tlanguage : \"" . $langPrefix . "\",\n\t\t\t\t\tmode : \"specific_textareas\",\n\t\t\t\t\t{$skin}\n\t\t\t\t\ttheme : \"{$theme[$mode]}\",\n\t\t\t\t\t// Cleanup/Output\n\t\t\t\t\tinline_styles : true,\n\t\t\t\t\tgecko_spellcheck : true,\n\t\t\t\t\tentity_encoding : \"{$entity_encoding}\",\n\t\t\t\t\textended_valid_elements : \"{$elements}\",\n\t\t\t\t\t{$forcenewline}\n\t\t\t\t\tinvalid_elements : \"{$invalid_elements}\",\n\t\t\t\t\t// URL\n\t\t\t\t\trelative_urls : {$relative_urls},\n\t\t\t\t\tremove_script_host : false,\n\t\t\t\t\tdocument_base_url : \"" . Request::root() . "\",\n\t\t\t\t\t// Layout\n\t\t\t\t\t{$content_css}\n\t\t\t\t\t// Advanced theme\n\t\t\t\t\ttheme_advanced_toolbar_location : \"{$toolbar}\",\n\t\t\t\t\ttheme_advanced_toolbar_align : \"{$toolbar_align}\",\n\t\t\t\t\ttheme_advanced_source_editor_height : \"{$html_height}\",\n\t\t\t\t\ttheme_advanced_source_editor_width : \"{$html_width}\",\n\t\t\t\t\ttheme_advanced_resizing : {$resizing},\n\t\t\t\t\ttheme_advanced_resize_horizontal : {$resize_horizontal},\n\t\t\t\t\t{$element_path}\n\t\t\t\t});\n\t\t\t\t</script>";
             break;
         case 2:
             /* Extended mode*/
             $load = "\t<script type=\"text/javascript\" src=\"" . Request::root() . $this->_basePath . "/tiny_mce.js\"></script>\n";
             $return = $load . "\t<script type=\"text/javascript\">\n\t\t\t\ttinyMCE.init({\n\t\t\t\t\t// General\n\t\t\t\t\t{$dialog_type}\n\t\t\t\t\tdirectionality: \"{$text_direction}\",\n\t\t\t\t\teditor_selector : \"mce_editable\",\n\t\t\t\t\tlanguage : \"" . $langPrefix . "\",\n\t\t\t\t\tmode : \"specific_textareas\",\n\t\t\t\t\tplugins : \"{$plugins}\",\n\t\t\t\t\t{$skin}\n\t\t\t\t\ttheme : \"{$theme[$mode]}\",\n\t\t\t\t\t// Cleanup/Output\n\t\t\t\t\tinline_styles : true,\n\t\t\t\t\tgecko_spellcheck : true,\n\t\t\t\t\tentity_encoding : \"{$entity_encoding}\",\n\t\t\t\t\textended_valid_elements : \"{$elements}\",\n\t\t\t\t\t{$forcenewline}\n\t\t\t\t\tinvalid_elements : \"{$invalid_elements}\",\n\t\t\t\t\t// URL\n\t\t\t\t\trelative_urls : {$relative_urls},\n\t\t\t\t\tremove_script_host : false,\n\t\t\t\t\tdocument_base_url : \"" . Request::root() . "\",\n\t\t\t\t\t//Templates\n\t\t\t\t\ttemplate_external_list_url :  \"" . Request::root() . "plugins/editors/tinymce/assets/templates/template_list.js\",\n\t\t\t\t\t// Layout\n\t\t\t\t\t{$content_css}\n\t\t\t\t\t// Advanced theme\n\t\t\t\t\ttheme_advanced_toolbar_location : \"{$toolbar}\",\n\t\t\t\t\ttheme_advanced_toolbar_align : \"{$toolbar_align}\",\n\t\t\t\t\ttheme_advanced_source_editor_height : \"{$html_height}\",\n\t\t\t\t\ttheme_advanced_source_editor_width : \"{$html_width}\",\n\t\t\t\t\ttheme_advanced_resizing : {$resizing},\n\t\t\t\t\ttheme_advanced_resize_horizontal : {$resize_horizontal},\n\t\t\t\t\t{$element_path},\n\t\t\t\t\ttheme_advanced_buttons1_add_before : \"{$buttons1_add_before}\",\n\t\t\t\t\ttheme_advanced_buttons2_add_before : \"{$buttons2_add_before}\",\n\t\t\t\t\ttheme_advanced_buttons3_add_before : \"{$buttons3_add_before}\",\n\t\t\t\t\ttheme_advanced_buttons1_add : \"{$buttons1_add}\",\n\t\t\t\t\ttheme_advanced_buttons2_add : \"{$buttons2_add}\",\n\t\t\t\t\ttheme_advanced_buttons3_add : \"{$buttons3_add}\",\n\t\t\t\t\ttheme_advanced_buttons4 : \"{$buttons4}\",\n\t\t\t\t\tplugin_insertdate_dateFormat : \"{$format_date}\",\n\t\t\t\t\tplugin_insertdate_timeFormat : \"{$format_time}\",\n\t\t\t\t\tfullscreen_settings : {\n\t\t\t\t\t\ttheme_advanced_path_location : \"top\"\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t\t</script>";
             break;
     }
     return $return;
 }
Example #9
0
 /**
  * Get the language tag or a custom translation
  *
  * @return string
  *
  * @since  2.5
  */
 private function _getLanguage()
 {
     $tag = explode('-', Lang::getTag());
     $tag = $tag[0];
     $available = array('en', 'pt', 'fr', 'de', 'nl', 'ru', 'es', 'tr');
     if (in_array($tag, $available)) {
         return "lang : '" . $tag . "',";
     }
     // If the default language is not available, let's search for a custom translation
     if ($language->hasKey('PLG_RECAPTCHA_CUSTOM_LANG')) {
         $custom[] = 'custom_translations : {';
         $custom[] = "\t" . 'instructions_visual : "' . Lang::txt('PLG_RECAPTCHA_INSTRUCTIONS_VISUAL') . '",';
         $custom[] = "\t" . 'instructions_audio : "' . Lang::txt('PLG_RECAPTCHA_INSTRUCTIONS_AUDIO') . '",';
         $custom[] = "\t" . 'play_again : "' . Lang::txt('PLG_RECAPTCHA_PLAY_AGAIN') . '",';
         $custom[] = "\t" . 'cant_hear_this : "' . Lang::txt('PLG_RECAPTCHA_CANT_HEAR_THIS') . '",';
         $custom[] = "\t" . 'visual_challenge : "' . Lang::txt('PLG_RECAPTCHA_VISUAL_CHALLENGE') . '",';
         $custom[] = "\t" . 'audio_challenge : "' . Lang::txt('PLG_RECAPTCHA_AUDIO_CHALLENGE') . '",';
         $custom[] = "\t" . 'refresh_btn : "' . Lang::txt('PLG_RECAPTCHA_REFRESH_BTN') . '",';
         $custom[] = "\t" . 'help_btn : "' . Lang::txt('PLG_RECAPTCHA_HELP_BTN') . '",';
         $custom[] = "\t" . 'incorrect_try_again : "' . Lang::txt('PLG_RECAPTCHA_INCORRECT_TRY_AGAIN') . '",';
         $custom[] = '},';
         $custom[] = "lang : '" . $tag . "',";
         return implode("\n", $custom);
     }
     // If nothing helps fall back to english
     return '';
 }
Example #10
0
 /**
  * Method to get article data.
  *
  * @param	integer	The id of the article.
  *
  * @return	mixed	Menu item data object on success, false on failure.
  */
 public function &getItem($pk = null)
 {
     // Initialise variables.
     $pk = !empty($pk) ? $pk : (int) $this->getState('article.id');
     if ($this->_item === null) {
         $this->_item = array();
     }
     if (!isset($this->_item[$pk])) {
         try {
             $db = $this->getDbo();
             $query = $db->getQuery(true);
             $query->select($this->getState('item.select', 'a.id, a.asset_id, a.title, a.alias, a.title_alias, a.introtext, a.fulltext, ' . 'CASE WHEN badcats.id is null THEN a.state ELSE 0 END AS state, ' . 'a.mask, a.catid, a.created, a.created_by, a.created_by_alias, ' . 'CASE WHEN a.modified = 0 THEN a.created ELSE a.modified END as modified, ' . 'a.modified_by, a.checked_out, a.checked_out_time, a.publish_up, a.publish_down, ' . 'a.images, a.urls, a.attribs, a.version, a.parentid, a.ordering, ' . 'a.metakey, a.metadesc, a.access, a.hits, a.metadata, a.featured, a.language, a.xreference'));
             $query->from('#__content AS a');
             // Join on category table.
             $query->select('c.title AS category_title, c.alias AS category_alias, c.access AS category_access');
             $query->join('LEFT', '#__categories AS c on c.id = a.catid');
             // Join on user table.
             $query->select('u.name AS author');
             $query->join('LEFT', '#__users AS u on u.id = a.created_by');
             // Get contact id
             $subQuery = $db->getQuery(true);
             $subQuery->select('MAX(contact.id) AS id');
             $subQuery->from('#__contact_details AS contact');
             $subQuery->where('contact.published = 1');
             $subQuery->where('contact.user_id = a.created_by');
             // Filter by language
             if ($this->getState('filter.language')) {
                 $subQuery->where('(contact.language in (' . $db->quote(Lang::getTag()) . ',' . $db->quote('*') . ') OR contact.language IS NULL)');
             }
             // [!] Hubzero - Removed contact_details table
             //$query->select('(' . $subQuery . ') as contactid');
             $query->select('(0) as contactid');
             // Filter by language
             if ($this->getState('filter.language')) {
                 $query->where('a.language in (' . $db->quote(Lang::getTag()) . ',' . $db->quote('*') . ')');
             }
             // Join over the categories to get parent category titles
             $query->select('parent.title as parent_title, parent.id as parent_id, parent.path as parent_route, parent.alias as parent_alias');
             $query->join('LEFT', '#__categories as parent ON parent.id = c.parent_id');
             // Join on voting table
             $query->select('ROUND(v.rating_sum / v.rating_count, 0) AS rating, v.rating_count as rating_count');
             $query->join('LEFT', '#__content_rating AS v ON a.id = v.content_id');
             $query->where('a.id = ' . (int) $pk);
             if (!User::authorise('core.edit.state', 'com_content') && !User::authorise('core.edit', 'com_content')) {
                 // Filter by start and end dates.
                 $nullDate = $db->Quote($db->getNullDate());
                 $date = Date::of('now');
                 $nowDate = $db->Quote($date->toSql());
                 $query->where('(a.publish_up = ' . $nullDate . ' OR a.publish_up <= ' . $nowDate . ')');
                 $query->where('(a.publish_down = ' . $nullDate . ' OR a.publish_down >= ' . $nowDate . ')');
             }
             // Join to check for category published state in parent categories up the tree
             // If all categories are published, badcats.id will be null, and we just use the article state
             $subquery = ' (SELECT cat.id as id FROM #__categories AS cat JOIN #__categories AS parent ';
             $subquery .= 'ON cat.lft BETWEEN parent.lft AND parent.rgt ';
             $subquery .= 'WHERE parent.extension = ' . $db->quote('com_content');
             $subquery .= ' AND parent.published <= 0 GROUP BY cat.id)';
             $query->join('LEFT OUTER', $subquery . ' AS badcats ON badcats.id = c.id');
             // Filter by published state.
             $published = $this->getState('filter.published');
             $archived = $this->getState('filter.archived');
             if (is_numeric($published)) {
                 $query->where('(a.state = ' . (int) $published . ' OR a.state =' . (int) $archived . ')');
             }
             $db->setQuery($query);
             $data = $db->loadObject();
             if ($error = $db->getErrorMsg()) {
                 throw new Exception($error);
             }
             if (empty($data)) {
                 return App::abort(404, Lang::txt('COM_CONTENT_ERROR_ARTICLE_NOT_FOUND'));
             }
             // Check for published state if filter set.
             if ((is_numeric($published) || is_numeric($archived)) && ($data->state != $published && $data->state != $archived)) {
                 return App::abort(404, Lang::txt('COM_CONTENT_ERROR_ARTICLE_NOT_FOUND'));
             }
             // Convert parameter fields to objects.
             $registry = new \Hubzero\Config\Registry($data->attribs);
             $data->params = clone $this->getState('params');
             $data->params->merge($registry);
             $registry = new \Hubzero\Config\Registry($data->metadata);
             $data->metadata = $registry;
             // Technically guest could edit an article, but lets not check that to improve performance a little.
             if (!User::isGuest()) {
                 $userId = User::get('id');
                 $asset = 'com_content.article.' . $data->id;
                 // Check general edit permission first.
                 if (User::authorise('core.edit', $asset)) {
                     $data->params->set('access-edit', true);
                 } elseif (!empty($userId) && User::authorise('core.edit.own', $asset)) {
                     // Check for a valid user and that they are the owner.
                     if ($userId == $data->created_by) {
                         $data->params->set('access-edit', true);
                     }
                 }
             }
             // Compute view access permissions.
             if ($access = $this->getState('filter.access')) {
                 // If the access filter has been set, we already know this user can view.
                 $data->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 ($data->catid == 0 || $data->category_access === null) {
                     $data->params->set('access-view', in_array($data->access, $groups));
                 } else {
                     $data->params->set('access-view', in_array($data->access, $groups) && in_array($data->category_access, $groups));
                 }
             }
             $this->_item[$pk] = $data;
         } catch (Exception $e) {
             if ($e->getCode() == 404) {
                 // Need to go thru the error handler to allow Redirect to work.
                 App::abort(404, $e->getMessage());
             } else {
                 $this->setError($e);
                 $this->_item[$pk] = false;
             }
         }
     }
     return $this->_item[$pk];
 }
Example #11
0
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 * THE SOFTWARE.
 *
 * HUBzero is a registered trademark of Purdue University.
 *
 * @package   hubzero-cms
 * @copyright Copyright 2005-2015 HUBzero Foundation, LLC.
 * @license   http://opensource.org/licenses/MIT MIT
 */
defined('_HZEXEC_') or die;
Toolbar::title(Lang::txt('COM_OAIPMH_SETTINGS'), 'generic.png');
Toolbar::preferences('com_oaipmh', 500);
Toolbar::spacer();
Toolbar::help('oaipmh');
$this->css();
$lang = \Lang::getTag();
?>

<form action="<?php 
echo Route::url('index.php?option=' . $this->option);
?>
" method="post" name="adminForm" id="item-form">
	<input type="hidden" name="option" value="<?php 
echo $this->option;
?>
" />
	<input type="hidden" name="task" value="save" />
	<input type="hidden" name="controller" value="<?php 
echo $this->controller;
?>
" />
Example #12
0
 * HUBzero is a registered trademark of Purdue University.
 *
 * @package   hubzero-cms
 * @copyright Copyright 2005-2015 HUBzero Foundation, LLC.
 * @license   http://opensource.org/licenses/MIT MIT
 */
defined('_HZEXEC_') or die;
$canDo = \Components\Oaipmh\Helpers\Permissions::getActions('component');
Toolbar::title(Lang::txt('COM_OAIPMH_SETTINGS'), 'generic.png');
if ($canDo->get('core.admin')) {
    Toolbar::preferences('com_oaipmh', 500);
    Toolbar::spacer();
}
Toolbar::help('oaipmh');
$this->css();
$lang = Lang::getTag();
?>

<form action="<?php 
echo Route::url('index.php?option=' . $this->option);
?>
" method="post" name="adminForm" id="item-form">
	<input type="hidden" name="option" value="<?php 
echo $this->option;
?>
" />
	<input type="hidden" name="task" value="save" />
	<input type="hidden" name="controller" value="<?php 
echo $this->controller;
?>
" />