/** * Method to build an SQL query to load the list data. * * @return string An SQL query * @since 1.6 */ protected function _getListQuery() { // Create a new query object. $query = new JQuery(); // Select all fields from the users table. $query->select($this->getState('list.select', 'a.*')); $query->from('`#__languages` AS a'); // Filter on the published state. $published = $this->getState('filter.published'); if (is_numeric($published)) { $query->where('a.published = ' . (int) $published); } else { if ($published === '') { $query->where('(a.published IN (0, 1))'); } } // Filter by search in title $search = $this->getState('filter.search'); if (!empty($search)) { $search = $this->_db->Quote('%' . $this->_db->getEscaped($search, true) . '%', false); $query->where('(a.title LIKE ' . $search . ')'); } // Add the list ordering clause. $query->order($this->_db->getEscaped($this->getState('list.ordering', 'a.ordering')) . ' ' . $this->_db->getEscaped($this->getState('list.direction', 'ASC'))); return $query; }
/** * Get the parent asset id for the record * * @return int */ protected function _getAssetParentId() { // Initialise variables. $assetId = null; // This is a category under a category. if ($this->parent_id > 1) { // Build the query to get the asset id for the parent category. $query = new JQuery(); $query->select('asset_id'); $query->from('#__categories'); $query->where('id = ' . (int) $this->parent_id); // Get the asset id from the database. $this->_db->setQuery($query); if ($result = $this->_db->loadResult()) { $assetId = (int) $result; } } elseif ($assetId === null) { // Build the query to get the asset id for the parent category. $query = new JQuery(); $query->select('id'); $query->from('#__assets'); $query->where('name = ' . $this->_db->quote($this->extension)); // Get the asset id from the database. $this->_db->setQuery($query); if ($result = $this->_db->loadResult()) { $assetId = (int) $result; } } // Return the asset id. if ($assetId) { return $assetId; } else { return parent::_getAssetParentId(); } }
/** * Method to get a list of options for a list input. * * @return array An array of JHtml options. */ protected function _getOptions() { $db =& JFactory::getDbo(); $query = new JQuery(); $query->select('a.id AS value, a.title AS text, a.level'); $query->from('#__categories AS a'); $query->join('LEFT', '`#__categories` AS b ON a.lft > b.lft AND a.rgt < b.rgt'); // Filter by the type if ($extension = $this->_form->getValue('extension')) { $query->where('(a.extension = ' . $db->quote($extension) . ' OR a.parent_id = 0)'); } // Prevent parenting to children of this item. if ($id = $this->_form->getValue('id')) { $query->join('LEFT', '`#__categories` AS p ON p.id = ' . (int) $id); $query->where('NOT(a.lft >= p.lft AND a.rgt <= p.rgt)'); } $query->group('a.id'); $query->order('a.lft ASC'); // Get the options. $db->setQuery($query); $options = $db->loadObjectList(); // Check for a database error. if ($db->getErrorNum()) { JError::raiseWarning(500, $db->getErrorMsg()); } // Pad the option text with spaces using depth level as a multiplier. for ($i = 0, $n = count($options); $i < $n; $i++) { $options[$i]->text = str_repeat('- ', $options[$i]->level) . $options[$i]->text; } $options = array_merge(parent::_getOptions(), $options); return $options; }
/** * Build an SQL query to load the list data. * * @return JQuery */ protected function _getListQuery() { // Create a new query object. $query = new JQuery(); // Select the required fields from the table. $query->select($this->getState('list.select', 'a.*')); $query->from('`#__usergroups` AS a'); // Add the level in the tree. $query->select('COUNT(DISTINCT c2.id) AS level'); $query->join('LEFT OUTER', '`#__usergroups` AS c2 ON a.lft > c2.lft AND a.rgt < c2.rgt'); $query->group('a.id'); // Count the objects in the user group. $query->select('COUNT(DISTINCT map.user_id) AS user_count'); $query->join('LEFT', '`#__user_usergroup_map` AS map ON map.group_id = a.id'); $query->group('a.id'); // Filter the comments over the search string if set. $search = $this->getState('filter.search'); if (!empty($search)) { if (stripos($search, 'id:') === 0) { $query->where('a.id = ' . (int) substr($search, 3)); } else { $search = $this->_db->Quote('%' . $this->_db->getEscaped($search, true) . '%'); $query->where('a.title LIKE ' . $search); } } // Add the list ordering clause. $query->order($this->_db->getEscaped($this->getState('list.ordering', 'a.lft')) . ' ' . $this->_db->getEscaped($this->getState('list.direction', 'ASC'))); //echo nl2br(str_replace('#__','jos_',$query)); return $query; }
/** * Build an SQL query to load the list data. * * @return JQuery */ protected function _getListQuery() { // Create a new query object. $query = new JQuery(); // Select the required fields from the table. $query->select($this->getState('list.select', 'a.id, a.title, a.position, a.module, ' . 'a.checked_out, a.checked_out_time, a.published, a.access, a.ordering, a.language')); $query->from('`#__modules` AS a'); // Join over the users for the checked out user. $query->select('uc.name AS editor'); $query->join('LEFT', '#__users AS uc ON uc.id=a.checked_out'); // Join over the asset groups. $query->select('ag.title AS access_level'); $query->join('LEFT', '#__viewlevels AS ag ON ag.id = a.access'); // Join over the module menus $query->select('MIN(mm.menuid) AS pages'); $query->join('LEFT', '#__modules_menu AS mm ON mm.moduleid = a.id'); $query->group('a.id'); // Filter by access level. if ($access = $this->getState('filter.access')) { $query->where('a.access = ' . (int) $access); } // Filter by published state $state = $this->getState('filter.state'); if (is_numeric($state)) { $query->where('a.published = ' . (int) $state); } else { if ($state === '') { $query->where('(a.published IN (0, 1))'); } } // Filter by position $position = $this->getState('filter.position'); if ($position) { $query->where('a.position = ' . $this->_db->Quote($position)); } // Filter by module $module = $this->getState('filter.module'); if ($module) { $query->where('a.module = ' . $this->_db->Quote($module)); } // Filter by client. $clientId = $this->getState('filter.client_id'); if (is_numeric($clientId)) { $query->where('a.client_id = ' . (int) $clientId); } // Filter by search in title $search = $this->getState('filter.search'); if (!empty($search)) { if (stripos($search, 'id:') === 0) { $query->where('a.id = ' . (int) substr($search, 3)); } else { $search = $this->_db->Quote('%' . $this->_db->getEscaped($search, true) . '%'); $query->where('a.title LIKE ' . $search); } } // Add the list ordering clause. $query->order($this->_db->getEscaped($this->getState('list.ordering', 'a.ordering')) . ' ' . $this->_db->getEscaped($this->getState('list.direction', 'ASC'))); //echo nl2br(str_replace('#__','jos_',$query)); return $query; }
/** * Build an SQL query to load the list data. * * @return JQuery */ protected function _getListQuery() { // Create a new query object. $query = new JQuery(); // Select the required fields from the table. $query->select($this->getState('list.select', 'a.*')); $query->from('`#__redirect_links` AS a'); // Filter by published state $state = $this->getState('filter.state'); if (is_numeric($state)) { $query->where('a.published = ' . (int) $state); } else { if ($state === '') { $query->where('(a.published IN (0,1,2))'); } } // Filter the items over the search string if set. $search = $this->getState('filter.search'); if (!empty($search)) { if (stripos($search, 'id:') === 0) { $query->where('a.id = ' . (int) substr($search, 3)); } else { $search = $this->_db->Quote('%' . $this->_db->getEscaped($search, true) . '%'); $query->where('(`old_url` LIKE ' . $search . ' OR `new_url` LIKE ' . $search . ' OR `comment` LIKE ' . $search . ' OR `referer` LIKE ' . $search . ')'); } } // Add the list ordering clause. $query->order($this->_db->getEscaped($this->getState('list.ordering', 'a.old_url')) . ' ' . $this->_db->getEscaped($this->getState('list.direction', 'ASC'))); //echo nl2br(str_replace('#__','jos_',$query)); return $query; }
/** * Method to get the field input. * * @return string The field input. */ protected function _getGroups() { $client = $this->_element->attributes('client'); $client_id = $client == 'administrator' ? 1 : 0; $db = JFactory::getDBO(); $query = new JQuery(); $query->select($db->nameQuote('id')); $query->select($db->nameQuote('title')); $query->select($db->nameQuote('template')); $query->from($db->nameQuote('#__template_styles')); $query->where($db->nameQuote('client_id') . '=' . (int) $client_id); $query->order($db->nameQuote('template')); $query->order($db->nameQuote('title')); $db->setQuery($query); $styles = $db->loadObjectList(); // Pre-process into groups. $last = null; $groups = array(); foreach ($styles as $style) { if ($style->template != $last) { $last = $style->template; $groups[$last] = array(); } $groups[$last][] = JHtml::_('select.option', $style->id, $style->title); } // Merge any additional options in the XML definition. $groups = array_merge(parent::_getGroups(), $groups); return $groups; }
/** * Method to build an SQL query to load the list data. * * @access protected * @return string An SQL query * @since 1.0 */ function _getListQuery() { $query = new JQuery(); // Select the required fields from the table. $query->select($this->getState('list.select', 'a.*')); $query->from('`#__social_threads` AS a'); // Join on the comments table. $query->select('COUNT(c.id) AS comment_count'); $query->leftJoin('#__social_comments AS c ON c.thread_id = a.id'); // Join on the ratings table. $query->select('pscore_count'); $query->leftJoin('#__social_ratings AS r ON r.thread_id = a.id'); $query->group('a.id'); // Filter the items over the context if set. if ($context = $this->getState('filter.context')) { $query->where('a.context = ' . $this->_db->Quote($context)); } // Filter by search string. if ($search = $this->getState('filter.search')) { if (stripos($search, 'id:') === 0) { $query->where('a.id = ' . (int) substr($search, 3)); } else { $search = $this->_db->Quote('%' . $this->_db->getEscaped($search, true) . '%'); $query->where('a.page_title LIKE ' . $search); } } // Add the list ordering clause. $query->order($this->_db->getEscaped($this->getState('list.ordering', 'a.id') . ' ' . $this->getState('list.direction', 'asc'))); //echo nl2br(str_replace('#__','jos_',$query)); return $query; }
/** * @param boolean True to join selected foreign information * * @return string */ function _getListQuery($resolveFKs = true) { // Create a new query object. $query = new JQuery(); // Select the required fields from the table. $query->select($this->getState('list.select', 'a.id, a.name, a.alias, a.checked_out, a.checked_out_time, a.published, a.access, a.ordering, a.catid')); $query->from('#__contact_details AS a'); // Join over the users for the checked out user. $query->select('uc.name AS editor'); $query->join('LEFT', '#__users AS uc ON uc.id=a.checked_out'); // Join over the asset groups. $query->select('ag.title AS access_level'); $query->join('LEFT', '#__viewlevels AS ag ON ag.id = a.access'); // Join over the categories. $query->select('c.title AS category_title'); $query->join('LEFT', '#__categories AS c ON c.id = a.catid'); // Filter by access level. if ($access = $this->getState('filter.access')) { $query->where('a.access = ' . (int) $access); } // Filter by published state $published = $this->getState('filter.published'); if (is_numeric($published)) { $query->where('a.published = ' . (int) $published); } else { if ($published === '') { $query->where('(a.published = 0 OR a.published = 1)'); } } // Filter by category. $categoryId = $this->getState('filter.category_id'); if (is_numeric($categoryId)) { $query->where('a.catid = ' . (int) $categoryId); } // Filter by search in name $search = $this->getState('filter.search'); if (!empty($search)) { if (stripos($search, 'id:') === 0) { $query->where('a.id = ' . (int) substr($search, 3)); } else { if (stripos($search, 'author:') === 0) { $search = $this->_db->Quote('%' . $this->_db->getEscaped(substr($search, 7), true) . '%'); $query->where('ua.name LIKE ' . $search . ' OR ua.username LIKE ' . $search); } else { $search = $this->_db->Quote('%' . $this->_db->getEscaped($search, true) . '%'); $query->where('a.name LIKE ' . $search . ' OR a.alias LIKE ' . $search); } } } // Add the list ordering clause. $query->order($this->_db->getEscaped($this->getState('list.ordering', 'a.name')) . ' ' . $this->_db->getEscaped($this->getState('list.direction', 'ASC'))); //echo nl2br(str_replace('#__','jos_',$query)); return $query; }
/** * Build an SQL query to load the list data. * * @return JQuery */ protected function _getListQuery() { // Create a new query object. $query = new JQuery(); // Select the required fields from the table. $query->select($this->getState('list.select', 'a.*')); $query->from('`#__viewlevels` AS a'); // Add the level in the tree. $query->group('a.id'); // Filter the items over the search string if set. $search = $this->getState('filter.search'); if (!empty($search)) { if (stripos($search, 'id:') === 0) { $query->where('a.id = ' . (int) substr($search, 3)); } else { $search = $this->_db->Quote('%' . $this->_db->getEscaped($search, true) . '%'); $query->where('a.title LIKE ' . $search); } } $query->group('a.id'); // Add the list ordering clause. $query->order($this->_db->getEscaped($this->getState('list.ordering', 'a.lft')) . ' ' . $this->_db->getEscaped($this->getState('list.direction', 'ASC'))); //echo nl2br(str_replace('#__','jos_',$query)); return $query; }
/** * Method to build an SQL query to load the list data. * * @return string An SQL query * @since 1.6 */ protected function _getListQuery() { $user =& JFactory::getUser(); $groups = implode(',', $user->authorisedLevels()); // Create a new query object. $query = new JQuery(); // Select required fields from the categories. $query->select($this->getState('list.select', 'a.*')); $query->from('`#__weblinks` 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.state'); if (is_numeric($state)) { $query->where('a.state = ' . (int) $state); } // Add the list ordering clause. $query->order($this->_db->getEscaped($this->getState('list.ordering', 'a.ordering')) . ' ' . $this->_db->getEscaped($this->getState('list.direction', 'ASC'))); return $query; }
/** * Method to get a list of options for a list input. * * @return array An array of JHtml options. */ protected function _getOptions() { $db = JFactory::getDbo(); $query = new JQuery(); $clientId = (int) $this->_form->getValue('client_id'); $client = JApplicationHelper::getClientInfo($clientId); jimport('joomla.filesystem.folder'); // template assignment filter $query = new JQuery(); $query->select('DISTINCT(template)'); $query->from('#__template_styles'); $query->where('client_id = ' . (int) $clientId); $db->setQuery($query); $templates = $db->loadResultArray(); if ($error = $db->getErrorMsg()) { JError::raiseWarning(500, $error); return false; } $query = new JQuery(); $query->select('DISTINCT(position)'); $query->from('#__modules'); $query->where('`client_id` = ' . (int) $clientId); $db->setQuery($query); $positions = $db->loadResultArray(); if ($error = $db->getErrorMsg()) { JError::raiseWarning(500, $error); return false; } // Load the positions from the installed templates. foreach ($templates as $template) { $path = JPath::clean($client->path . '/templates/' . $template . '/templateDetails.xml'); if (file_exists($path)) { $xml = simplexml_load_file($path); if (isset($xml->positions[0])) { foreach ($xml->positions[0] as $position) { $positions[] = (string) $position; } } } } $positions = array_unique($positions); sort($positions); $options = array(); foreach ($positions as $position) { $options[] = JHtml::_('select.option', $position, $position); } // Merge any additional options in the XML definition. $options = array_merge(parent::_getOptions(), $options); return $options; }
function getUsers($params) { $db =& JFactory::getDbo(); $result = null; $query = new JQuery(); $query->select('a.id, a.name, a.username, a.activation'); $query->order('a.activation DESC'); $query->from('#__users AS a'); $db->setQuery($query, 0, $params->get('shownumber')); $result = $db->loadObjectList(); if ($db->getErrorNum()) { JError::raiseWarning(500, $db->stderr()); } return $result; }
/** * Get a list of the thread contexts * * @return mixed An array if successful, false otherwise and the internal error is set. */ function getContextOptions() { $db = JFactory::getDbo(); $query = new JQuery(); $query->select('DISTINCT(context) AS value, context AS text'); $query->from('#__social_threads'); $query->order('context'); $db->setQuery($query); $result = $db->loadObjectList(); if ($error = $db->getErrorMsg()) { $this->setError($error); return false; } return $result; }
/** * Method to get a list of options for a list input. * * @return array An array of JHtml options. */ protected function _getOptions() { $db = JFactory::getDbo(); $query = new JQuery(); $query->select('id As value, name As text'); $query->from('#__newsfeeds AS a'); $query->order('a.name'); // Get the options. $db->setQuery($query); $options = $db->loadObjectList(); // Check for a database error. if ($db->getErrorNum()) { JError::raiseWarning(500, $db->getErrorMsg()); } $options = array_merge(parent::_getOptions(), $options); return $options; }
function fetchElement($name, $value, &$node, $control_name) { $access = JFactory::getACL(); // Include user in groups that have access to edit their articles, other articles, or manage content. $action = array('com_content.article.edit_own', 'com_content.article.edit_article', 'com_content.manage'); $groups = $access->getAuthorisedUsergroups($action, true); // Check the results of the access check. if (!$groups) { return false; } // Clean up and serialize. JArrayHelper::toInteger($groups); $groups = implode(',', $groups); // Build the query to get the users. $query = new JQuery(); $query->select('u.id AS value'); $query->select('u.name AS text'); $query->from('#__users AS u'); $query->join('INNER', '#__user_usergroup_map AS m ON m.user_id = u.id'); $query->where('u.block = 0'); $query->where('m.group_id IN (' . $groups . ')'); // Get the users. $db = JFactory::getDbo(); $db->setQuery((string) $query); $users = $db->loadObjectList(); // Check for a database error. if ($db->getErrorNum()) { JError::raiseNotice(500, $db->getErrorMsg()); return false; } return JHtml::_('select.genericlist', $users, $name, 'class="inputbox" size="1"', 'value', 'text', $value); }
/** * Build an SQL query to load the list data. * * @return JQuery */ protected function _getListQuery() { // Create a new query object. $query = new JQuery(); $user = JFactory::getUser(); // Select the required fields from the table. $query->select($this->getState('list.select', 'a.*, ' . 'u.name AS user_from')); $query->from('#__messages AS a'); // Join over the users for message owner. $query->join('INNER', '#__users AS u ON u.id = a.user_id_from'); $query->where('a.user_id_to = ' . (int) $user->get('id')); // Filter by published state. $state = $this->getState('filter.state'); if (is_numeric($state)) { $query->where('a.state = ' . (int) $state); } else { if ($state === '') { $query->where('(a.state IN (0, 1))'); } } // Filter by search in subject or message. $search = $this->getState('filter.search'); if (!empty($search)) { $search = $this->_db->Quote('%' . $this->_db->getEscaped($search, true) . '%', false); $query->where('a.subject LIKE ' . $search . ' OR a.message LIKE ' . $search . ')'); } // Add the list ordering clause. $query->order($this->_db->getEscaped($this->getState('list.ordering', 'a.date_time')) . ' ' . $this->_db->getEscaped($this->getState('list.direction', 'DESC'))); //echo nl2br(str_replace('#__','jos_',$query)); return $query; }
/** * Build an SQL query to load the list data. * * @return JQuery */ protected function _getListQuery() { // Create a new query object. $query = new JQuery(); // Select the required fields from the table. $query->select($this->getState('list.select', 'a.id, a.template, a.title, a.home, a.client_id')); $query->from('`#__template_styles` AS a'); // Join on menus. $query->select('COUNT(m.template_style_id) AS assigned'); $query->leftjoin('#__menu AS m ON m.template_style_id = a.id'); $query->group('a.id'); // Filter by template. if ($template = $this->getState('filter.template')) { $query->where('a.template = ' . $this->_db->quote($template)); } // Filter by client. $clientId = $this->getState('filter.client_id'); if (is_numeric($clientId)) { $query->where('a.client_id = ' . (int) $clientId); } // Filter by search in title $search = $this->getState('filter.search'); if (!empty($search)) { if (stripos($search, 'id:') === 0) { $query->where('a.id = ' . (int) substr($search, 3)); } else { $search = $this->_db->Quote('%' . $this->_db->getEscaped($search, true) . '%'); $query->where('a.template LIKE ' . $search . ' OR a.title LIKE ' . $search); } } // Add the list ordering clause. $query->order($this->_db->getEscaped($this->getState('list.ordering', 'a.name')) . ' ' . $this->_db->getEscaped($this->getState('list.direction', 'ASC'))); //echo nl2br(str_replace('#__','jos_',$query)); return $query; }
/** * Method to get a single record. * * @param integer The id of the primary key. * * @return mixed Object on success, false on failure. */ public function &getItem($pk = null) { // Initialise variables. $pk = !empty($pk) ? $pk : (int) $this->getState('message.id'); $false = false; // Get a row instance. $table = $this->getTable(); // Attempt to load the row. $return = $table->load($pk); // Check for a table object error. if ($return === false && $table->getError()) { $this->setError($table->getError()); return $false; } // Convert to the JObject before adding other data. $value = JArrayHelper::toObject($table->getProperties(1), 'JObject'); // Prime required properties. if (empty($table->id)) { // Prepare data for a new record. if ($replyId = $this->getState('reply.id')) { // If replying to a message, preload some data. $db = $this->getDbo(); $query = new JQuery(); $query->select('subject, user_id_from'); $query->from('#__messages'); $query->where('message_id = ' . (int) $replyId); $message = $db->setQuery($query)->loadObject(); if ($error = $db->getErrorMsg()) { $this->setError($error); return false; } $value->set('user_id_to', $message->user_id_from); $re = JText::_('Messages_Re'); if (stripos($message->subject, $re) !== 0) { $value->set('subject', $re . $message->subject); } } } else { // Get the user name for an existing messasge. if ($table->user_id_from && ($fromUser = new JUser($table->user_id_from))) { $value->set('from_user_name', $fromUser->name); } } return $value; }
/** * Count the number of unread messages. * * @return mixed The number of unread messages, or false on error. */ public static function getCount() { jimport('joomla.database.query'); // Initialise variables. $db = JFactory::getDbo(); $user = JFactory::getUser(); // Get the number of unread messages in your inbox. $query = new JQuery(); $query->select('COUNT(*)'); $query->from('#__messages'); $query->where('state = 0 AND user_id_to = ' . (int) $user->get('id')); $result = (int) $db->setQuery($query)->loadResult(); if ($error = $db->getErrorMsg()) { JError::raiseWarning(500, $error); return false; } return $result; }
/** * Count the number of users online. * * @return mixed The number of users online, or false on error. */ public static function getOnlineCount() { jimport('joomla.database.query'); $db = JFactory::getDbo(); $session = JFactory::getSession(); $sessionId = $session->getId(); $query = new JQuery(); $query->select('COUNT(a.session_id)'); $query->from('#__session AS a'); $query->where('a.session_id <> ' . $db->Quote($sessionId)); $db->setQuery($query); $result = (int) $db->loadResult(); if ($error = $db->getErrorMsg()) { JError::raiseWarning(500, $error); return false; } return $result; }
/** * Gets the HTML head entries needed for jQuery * * @return SwatHtmlHeadEntrySet the HTML head entries needed for jQuery. */ public function getHtmlHeadEntrySet() { if (!self::$html_head_entries instanceof SwatHtmlHeadEntrySet) { $filename = sprintf('jquery-%s.js', self::VERSION); self::$html_head_entries = new SwatHtmlHeadEntrySet(); self::$html_head_entries->addEntry(new SwatJavaScriptHtmlHeadEntry('packages/jquery/javascript/' . $filename)); } return self::$html_head_entries; }
public static function Load() { // jqueryui is a dependency. JQuery::IncludeJQueryUI(); \Core\view()->addScript('js/jquery/jquery.browser.js'); \Core\view()->addScript('js/jquery/jquery.contextMenu.js'); \Core\view()->addStylesheet('css/jquery.contextMenu.css'); // IMPORTANT! Tells the script that the include succeeded! return true; }
/** * Method to get a single record. * * @param integer The id of the primary key. * * @return mixed Object on success, false on failure. */ public function &getItem() { // Initialise variables. $item = new JObject(); $query = new JQuery(); $query->select('cfg_name, cfg_value'); $query->from('#__messages_cfg'); $query->where('user_id = ' . (int) $this->getState('user.id')); $this->_db->setQuery($query); $rows = $this->_db->loadObjectList(); if ($error = $this->_db->getErrorMsg()) { $this->setError($error); return false; } foreach ($rows as $row) { $item->set($row->cfg_name, $row->cfg_value); } return $item; }
/** * Loads the entire menu table into memory. * * @return array */ public function load() { $cache =& JFactory::getCache('_system', 'output'); if (!($data = $cache->get('menu_items'))) { jimport('joomla.database.query'); // Initialise some variables. $db =& JFactory::getDbo(); $query = new JQuery(); $query->select('m.id, m.menutype, m.title, m.alias, m.path AS route, m.link, m.type, m.level'); $query->select('m.browserNav, m.access, m.params, m.home, m.img, m.template_style_id, m.component_id, m.parent_id'); $query->select('e.element as component'); $query->from('#__menu AS m'); $query->leftJoin('#__extensions AS e ON m.component_id = e.extension_id'); $query->where('m.published = 1'); $query->where('m.parent_id > 0'); $query->order('m.lft'); $db->setQuery($query); if (!($menus = $db->loadObjectList('id'))) { JError::raiseWarning(500, "Error loading Menus: " . $db->getErrorMsg()); return false; } foreach ($menus as &$menu) { // Get parent information. $parent_tree = array(); if (($parent = $menu->parent_id) && isset($menus[$parent]) && is_object($menus[$parent]) && isset($menus[$parent]->route) && isset($menus[$parent]->tree)) { $parent_tree = $menus[$parent]->tree; } // Create tree. array_push($parent_tree, $menu->id); $menu->tree = $parent_tree; // Create the query array. $url = str_replace('index.php?', '', $menu->link); if (strpos($url, '&') !== false) { $url = str_replace('&', '&', $url); } parse_str($url, $menu->query); } $cache->store(serialize($menus), 'menu_items'); $this->_items = $menus; } else { $this->_items = unserialize($data); } }
/** * Build an SQL query to load the list data. * * @return JQuery */ protected function _getListQuery() { // Create a new query object. $query = new JQuery(); // Select the required fields from the table. $query->select($this->getState('list.select', 'a.*')); $query->from('`#__users` AS a'); // Join over the group mapping table. $query->select('COUNT(map.group_id) AS group_count'); $query->join('LEFT', '#__user_usergroup_map AS map ON map.user_id = a.id'); $query->group('a.id'); // Join over the user groups table. $query->select('GROUP_CONCAT(g2.title SEPARATOR ' . $this->_db->Quote("\n") . ') AS group_names'); $query->join('LEFT', '#__usergroups AS g2 ON g2.id = map.group_id'); // If the model is set to check item state, add to the query. $state = $this->getState('filter.state'); if (is_numeric($state)) { $query->where('a.block = ' . (int) $state); } // If the model is set to check the activated state, add to the query. $active = $this->getState('filter.active'); if (is_numeric($active)) { if ($active == '0') { $query->where('a.activation = ""'); } else { if ($active == '1') { $query->where('LENGTH(a.activation) = 32'); } } } // Filter the items over the group id if set. if ($groupId = $this->getState('filter.group_id')) { $query->join('LEFT', '#__user_usergroup_map AS map2 ON map2.user_id = a.id'); $query->where('map2.group_id = ' . (int) $groupId); } // Filter the items over the search string if set. if ($this->getState('filter.search') !== '') { // Escape the search token. $token = $this->_db->Quote('%' . $this->_db->getEscaped($this->getState('filter.search')) . '%'); // Compile the different search clauses. $searches = array(); $searches[] = 'a.name LIKE ' . $token; $searches[] = 'a.username LIKE ' . $token; $searches[] = 'a.email LIKE ' . $token; // Add the clauses to the query. $query->where('(' . implode(' OR ', $searches) . ')'); } // Add the list ordering clause. $query->order($this->_db->getEscaped($this->getState('list.ordering', 'a.name')) . ' ' . $this->_db->getEscaped($this->getState('list.direction', 'ASC'))); //echo nl2br(str_replace('#__','jos_',$query)); return $query; }
public static function Load2() { JQuery::IncludeJQuery(); if (self::$_IncludedVersion === null || self::$_IncludedVersion === 2) { \Core\view()->addScript('js/jquery.cycle2.js'); // IMPORTANT! Tells the script that the include succeeded! self::$_IncludedVersion = 2; return true; } else { return false; } }
function getList(&$params) { //get database $db =& JFactory::getDbo(); $query = new JQuery(); $query->select('MONTH(created) AS created_month, created, id, title, YEAR(created) AS created_year'); $query->from('#__content'); $query->where('state = -1 AND checked_out = 0'); $query->group('created_year DESC, created_month DESC'); // $query = 'SELECT MONTH(created) AS created_month, created, id, title, YEAR(created) AS created_year' . // ' FROM #__content' . // ' WHERE (state = -1 AND checked_out = 0)' . // ' GROUP BY created_year DESC, created_month DESC'; $db->setQuery($query, 0, intval($params->get('count'))); $rows = $db->loadObjectList(); $menu =& JSite::getMenu(); $item = $menu->getItems('link', 'index.php?option=com_content&view=archive', true); $itemid = isset($item) ? '&Itemid=' . $item->id : ''; $i = 0; $lists = array(); foreach ($rows as $row) { $date =& JFactory::getDate($row->created); $created_month = $date->toFormat("%m"); $month_name = $date->toFormat("%B"); $created_year = $date->toFormat("%Y"); $lists[$i]->link = JRoute::_('index.php?option=com_content&view=archive&year=' . $created_year . '&month=' . $created_month . $itemid); $lists[$i]->text = $month_name . ', ' . $created_year; $i++; } return $lists; }
/** * Build an SQL query to load the list data. * * @return JQuery */ protected function _getListQuery() { // Create a new query object. $query = new JQuery(); // Select the required fields from the table. $query->select($this->getState('list.select', 'a.extension_id, a.name, a.element, a.client_id')); $query->from('`#__extensions` AS a'); // Filter by extension type. $query->where('`type` = ' . $this->_db->quote('template')); // Filter by client. $clientId = $this->getState('filter.client_id'); if (is_numeric($clientId)) { $query->where('a.client_id = ' . (int) $clientId); } // Filter by search in title $search = $this->getState('filter.search'); if (!empty($search)) { if (stripos($search, 'id:') === 0) { $query->where('a.id = ' . (int) substr($search, 3)); } else { $search = $this->_db->Quote('%' . $this->_db->getEscaped($search, true) . '%'); $query->where('a.element LIKE ' . $search . ' OR a.name LIKE ' . $search); } } // Add the list ordering clause. $query->order($this->_db->getEscaped($this->getState('list.ordering', 'a.folder')) . ' ' . $this->_db->getEscaped($this->getState('list.direction', 'ASC'))); //echo nl2br(str_replace('#__','jos_',$query)); return $query; }
/** * Build an SQL query to load the list data. * * @return JQuery */ protected function _getListQuery() { // Create a new query object. $query = new JQuery(); // Select the required fields from the table. $query->select($this->getState('list.select', 'a.*')); $query->from('`#__core_log_searches` AS a'); // Filter by access level. if ($access = $this->getState('filter.access')) { $query->where('a.access = ' . (int) $access); } // Filter by search in title $search = $this->getState('filter.search'); if (!empty($search)) { $search = $this->_db->Quote('%' . $this->_db->getEscaped($search, true) . '%'); $query->where('a.search_term LIKE ' . $search); } // Add the list ordering clause. $query->order($this->_db->getEscaped($this->getState('list.ordering', 'a.hits')) . ' ' . $this->_db->getEscaped($this->getState('list.direction', 'ASC'))); //echo nl2br(str_replace('#__','jos_',$query)); return $query; }