public function testEnable() { $this->assertFalse($this->app->get('en')); $this->assertFalse($this->app->enabled('en')); $this->app->enable('en'); $this->assertTrue($this->app->enabled('en')); $this->app->disable('en'); $this->assertFalse($this->app->enabled('en')); }
/** * @param string $config * * @return \Songbird\App */ public static function createApplication($config = '') { $app = new App(require __DIR__ . '/../config/di.php'); $app->add('Config', new Config($config)); $app->add('Symfony\\Component\\HttpFoundation\\Response', new Response()); $app->add('Symfony\\Component\\HttpFoundation\\Request', Request::createFromGlobals()); $app->add('Filesystem', 'League\\Flysystem\\Filesystem')->withArgument(new CachedAdapter(new Adapter($app->config('app.paths.resources')), new CacheStore())); $app->get('Logger')->pushHandler(new StreamHandler(vsprintf('%s/songbird-%s.log', [$app->config('app.paths.log'), date('Y-d-m')]), Logger::INFO)); $app->inflector('League\\Container\\ContainerAwareInterface')->invokeMethod('setContainer', [$app]); $app->inflector('League\\Event\\EmitterAwareInterface')->invokeMethod('setEmitter', [$app->get('Emitter')]); $app->inflector('Psr\\Log\\LoggerAwareInterface')->invokeMethod('setLogger', [$app->get('Logger')]); $app->inflector('Songbird\\FilesystemAwareInterface')->invokeMethod('setFilesystem', ['Filesystem']); $app->add('Repository', $app->get('RepositoryFactory')->createContentRepository()); return $app; }
/** * Display module * * @return void */ public function display() { // Instantiate database object $this->database = \App::get('db'); // Get mailing list details that we are wanting users to sign up for $sql = "SELECT * FROM `#__newsletter_mailinglists` WHERE deleted=0 AND private=0 AND id=" . $this->database->quote($this->params->get('mailinglist', 0)); $this->database->setQuery($sql); $this->mailinglist = $this->database->loadObject(); // Get mailing list subscription if not guest $this->subscription = null; $this->subscriptionId = null; if (!User::isGuest()) { $sql = "SELECT * FROM `#__newsletter_mailinglist_emails` WHERE mid=" . $this->database->quote($this->params->get('mailinglist', 0)) . " AND email=" . $this->database->quote(User::get('email')); $this->database->setQuery($sql); $this->subscription = $this->database->loadObject(); } // If we are unsubscribed... if (is_object($this->subscription) && $this->subscription->status == 'unsubscribed') { $this->subscriptionId = $this->subscription->id; $this->subscription = null; } // Add stylesheets and scripts $this->css()->js(); // Display module require $this->getLayoutPath(); }
/** * Return information about this hub * * @return array */ public function onSystemOverview($values = 'all') { if ($values != 'all') { return; } $response = new stdClass(); $response->name = 'tickets'; $response->label = 'Support Tickets'; $response->data = array(); $database = App::get('db'); $database->setQuery("SELECT COUNT(*) FROM `#__support_tickets` AS f WHERE f.`type` = '0'"); $response->data['total'] = $this->_obj('Total', intval($database->loadResult())); $database->setQuery("SELECT count(DISTINCT f.id) FROM `#__support_tickets` AS f WHERE f.`open` = '1' AND f.`type` = '0'"); $response->data['open'] = $this->_obj('Open', intval($database->loadResult())); $database->setQuery("SELECT count(DISTINCT f.id) FROM `#__support_tickets` AS f WHERE f.`open` = '1' AND f.`type` = '0' AND f.`status` = '0'"); $response->data['open_new'] = $this->_obj('(open) New', intval($database->loadResult())); $database->setQuery("SELECT count(DISTINCT f.id) FROM `#__support_tickets` AS f WHERE f.`open` = '1' AND f.`type` = '0' AND (f.`owner` = '' OR f.`owner` IS NULL)"); $response->data['open_unassigned'] = $this->_obj('(open) Unassigned', intval($database->loadResult())); $database->setQuery("SELECT count(DISTINCT f.id) FROM `#__support_tickets` AS f WHERE f.`open` = '1' AND f.`type` = '0' AND f.`status` = '1'"); $response->data['open_waiting'] = $this->_obj('(open) Waiting', intval($database->loadResult())); $database->setQuery("SELECT f.`created` FROM `#__support_tickets` AS f WHERE f.`open` = '1' AND f.`type` = '0' ORDER BY f.`created` ASC LIMIT 1"); $response->data['open_oldest'] = $this->_obj('(open) Oldest', $database->loadResult()); $database->setQuery("SELECT f.`created` FROM `#__support_tickets` AS f WHERE f.`open` = '1' AND f.`type` = '0' ORDER BY f.`created` DESC LIMIT 1"); $response->data['open_newest'] = $this->_obj('(open) Newest', $database->loadResult()); $database->setQuery("SELECT count(DISTINCT f.id) FROM `#__support_tickets` AS f WHERE f.`open` = '0' AND f.`type` = '0'"); $response->data['closed'] = $this->_obj('Closed', intval($database->loadResult())); return $response; }
/** * Constructor * * @param object $db * @return void */ public function __construct($db = null) { if (!$db) { $db = \App::get('db'); } $this->_db = $db; }
/** * Constructor * * @param mixed $oid Integer (ID), string (alias), object or array * @return void */ public function __construct($oid = null, $wish = null) { $this->_db = \App::get('db'); if ($this->_tbl_name) { $cls = $this->_tbl_name; $this->_tbl = new $cls($this->_db); if (!$this->_tbl instanceof \JTable) { $this->_logError(__CLASS__ . '::' . __FUNCTION__ . '(); ' . Lang::txt('Table class must be an instance of JTable.')); throw new \LogicException(Lang::txt('Table class must be an instance of JTable.')); } if ($oid) { if (is_numeric($oid) || is_string($oid)) { // Make sure $oid isn't empty // This saves a database call $this->_tbl->load($oid); } else { if (is_object($oid) || is_array($oid)) { $this->bind($oid); } } } else { if ($wish) { if ($plans = $this->_tbl->getPlan($wish)) { $this->bind($plans[0]); } } } } }
/** * Method to auto-populate the model state. * * Note. Calling getState in this method will result in recursion. * * @return void * @since 1.6 */ protected function populateState($ordering = 'ordering', $direction = 'ASC') { $app = JFactory::getApplication(); // List state information $value = Request::getUInt('limit', Config::get('list_limit', 0)); $this->setState('list.limit', $value); $value = Request::getUInt('limitstart', 0); $this->setState('list.start', $value); $orderCol = Request::getCmd('filter_order', 'a.ordering'); if (!in_array($orderCol, $this->filter_fields)) { $orderCol = 'a.ordering'; } $this->setState('list.ordering', $orderCol); $listOrder = Request::getCmd('filter_order_Dir', 'ASC'); if (!in_array(strtoupper($listOrder), array('ASC', 'DESC', ''))) { $listOrder = 'ASC'; } $this->setState('list.direction', $listOrder); $params = $app->getParams(); $this->setState('params', $params); if (!User::authorise('core.edit.state', 'com_content') && !User::authorise('core.edit', 'com_content')) { // filter on published for those who do not have edit or edit.state rights. $this->setState('filter.published', 1); } $this->setState('filter.language', App::get('language.filter')); // process show_noauth parameter if (!$params->get('show_noauth')) { $this->setState('filter.access', true); } else { $this->setState('filter.access', false); } $this->setState('layout', Request::getCmd('layout')); }
/** * Generate macro output * * @return string */ public function render() { //get the args passed in $args = explode(',', $this->args); // get feed url $url = $this->_getFeedUrl($args); // get feed details $limit = $this->_getFeedLimit($args, 5); $class = $this->_getFeedClass($args); // get feed $feed = \App::get('feed.parser'); $feed->set_feed_url($url); $feed->init(); //var to hold html $html = '<div class="feed ' . $class . '">'; // display title $title = $feed->get_title(); $link = $feed->get_permalink(); if ($title) { $html .= '<h3><a rel="external" href="' . $link . '">' . $title . '</a></h3>'; } // display description $desc = $feed->get_description(); if ($desc) { $html .= '<p>' . $desc . '</p>'; } // add each item foreach ($feed->get_items(0, $limit) as $item) { $html .= $this->_renderItem($item); } // close feed $html .= '</div>'; return $html; }
/** * Display the update dashboard * * @return void */ public function displayTask() { // Set any errors foreach ($this->getErrors() as $error) { $this->view->setError($error); } $source = Component::params('com_update')->get('git_repository_source', null); $this->view->repositoryVersion = json_decode(Cli::version()); $this->view->repositoryVersion = $this->view->repositoryVersion[0]; $this->view->repositoryMechanism = json_decode(Cli::mechanism()); $this->view->repositoryMechanism = $this->view->repositoryMechanism[0]; $this->view->databaseMechanism = Config::get('dbtype'); $this->view->databaseVersion = \App::get('db')->getVersion(); $this->view->status = json_decode(Cli::status()); $this->view->upcoming = json_decode(Cli::update(true, false, $source)); $this->view->migration = json_decode(Cli::migration()); if (!isset($this->view->repositoryMechanism)) { $this->view->message = 'Please ensure that the component is properly configured'; $this->view->setLayout('error'); } elseif ($this->view->repositoryMechanism != 'GIT') { $this->view->message = 'The CMS update component currently only supports repositories managed via GIT'; $this->view->setLayout('error'); } // Output the HTML $this->view->display(); }
public function onUserLoginFailure($response) { $errorlog = array(); switch ($response['status']) { case \Hubzero\Auth\Status::SUCCESS: $errorlog['status'] = $response['type'] . " CANCELED: "; $errorlog['comment'] = $response['error_message']; App::get('log')->logger('auth')->info(implode('', $errorlog)); break; case \Hubzero\Auth\Status::FAILURE: $errorlog['status'] = $response['type'] . " FAILURE: "; if ($this->params->get('log_username', 0)) { $errorlog['comment'] = $response['error_message'] . ' ("' . $response['username'] . '")'; } else { $errorlog['comment'] = $response['error_message']; } App::get('log')->logger('auth')->info(implode('', $errorlog)); break; default: $errorlog['status'] = $response['type'] . " UNKNOWN ERROR: "; $errorlog['comment'] = $response['error_message']; App::get('log')->logger('auth')->info(implode('', $errorlog)); break; } }
/** * @param int $itemid The menu item id */ static function association($itemid) { // Get the associations $associations = MenusHelper::getAssociations($itemid); // Get the associated menu items $db = App::get('db'); $query = $db->getQuery(true); $query->select('m.*'); $query->select('mt.title as menu_title'); $query->from('#__menu as m'); $query->leftJoin('#__menu_types as mt ON mt.menutype=m.menutype'); $query->where('m.id IN (' . implode(',', array_values($associations)) . ')'); $query->leftJoin('#__languages as l ON m.language=l.lang_code'); $query->select('l.image'); $query->select('l.title as language_title'); $db->setQuery($query); $items = $db->loadObjectList('id'); // Check for a database error. if ($error = $db->getErrorMsg()) { throw new Exception($error, 500); return false; } // Construct html $text = array(); foreach ($associations as $tag => $associated) { if ($associated != $itemid) { $text[] = Lang::txt('COM_MENUS_TIP_ASSOCIATED_LANGUAGE', Html::asset('image', 'mod_languages/' . $items[$associated]->image . '.gif', $items[$associated]->language_title, array('title' => $items[$associated]->language_title), true), $items[$associated]->title, $items[$associated]->menu_title); } } return JHtml::_('tooltip', implode('<br />', $text), Lang::txt('COM_MENUS_TIP_ASSOCIATION'), 'menu/icon-16-links.png'); }
/** * @return \App_Rest_Service */ protected function _getPybeService() { if (!isset($this->_pybeService)) { $this->_pybeService = \App::get(self::PYBE_SERVICE_NAME); } return $this->_pybeService; }
/** * Method to get the list of siblings in a menu. * The method requires that parent be set. * * @return array The field option objects or false if the parent field has not been set * @since 1.7 */ protected function getOptions() { // Initialize variables. $options = array(); // Get the parent $parent_id = $this->form->getValue('parent_id', 0); if (empty($parent_id)) { return false; } $db = App::get('db'); $query = $db->getQuery(true); $query->select('a.id AS value, a.title AS text'); $query->from('#__menu AS a'); $query->where('a.published >= 0'); $query->where('a.parent_id =' . (int) $parent_id); if ($menuType = $this->form->getValue('menutype')) { $query->where('a.menutype = ' . $db->quote($menuType)); } else { $query->where('a.menutype != ' . $db->quote('')); } $query->order('a.lft ASC'); // Get the options. $db->setQuery($query); $options = $db->loadObjectList(); // Check for a database error. if ($db->getErrorNum()) { throw new Exception($db->getErrorMsg(), 500); } $options = array_merge(array(array('value' => '-1', 'text' => Lang::txt('COM_MENUS_ITEM_FIELD_ORDERING_VALUE_FIRST'))), $options, array(array('value' => '-2', 'text' => Lang::txt('COM_MENUS_ITEM_FIELD_ORDERING_VALUE_LAST')))); // Merge any additional options in the XML definition. $options = array_merge(parent::getOptions(), $options); return $options; }
/** * Prepares the document */ protected function _prepareDocument() { $app = JFactory::getApplication(); $menus = \App::get('menu'); $title = null; // Because the application sets a default page title, // we need to get it from the menu item itself $menu = $menus->getActive(); if ($menu) { $this->params->def('page_heading', $this->params->get('page_title', $menu->title)); } else { $this->params->def('page_heading', Lang::txt('COM_CONTENT_FORM_EDIT_ARTICLE')); } $title = $this->params->def('page_title', Lang::txt('COM_CONTENT_FORM_EDIT_ARTICLE')); if (Config::get('sitename_pagetitles', 0) == 1) { $title = Lang::txt('JPAGETITLE', Config::get('sitename'), $title); } elseif (Config::get('sitename_pagetitles', 0) == 2) { $title = Lang::txt('JPAGETITLE', $title, Config::get('sitename')); } $this->document->setTitle($title); Pathway::append($title, ''); if ($this->params->get('menu-meta_description')) { $this->document->setDescription($this->params->get('menu-meta_description')); } if ($this->params->get('menu-meta_keywords')) { $this->document->setMetadata('keywords', $this->params->get('menu-meta_keywords')); } if ($this->params->get('robots')) { $this->document->setMetadata('robots', $this->params->get('robots')); } }
/** * Pull a list of records that were created within the time frame ($period) * * @param object $period Time period to pull results for * @param mixed $limit Number of records to pull * @param integer $limitstart Start of records to pull * @param array $areas Active area(s) * @param array $tagids Array of tag IDs * @return array */ public function onWhatsnew($period, $limit = 0, $limitstart = 0, $areas = null, $tagids = array()) { if (is_array($areas) && $limit) { if (!isset($areas[$this->_name]) && !in_array($this->_name, $areas)) { return array(); } } // Do we have a search term? if (!is_object($period)) { return array(); } $database = App::get('db'); // Build the query $f_count = "SELECT COUNT(*)"; $f_fields = "SELECT" . " f.id, " . " f.title, " . " 'kb' AS section, NULL AS subsection, " . " f.fulltxt AS text," . " CONCAT('index.php?option=com_kb&task=article&id=', f.id) AS href"; $f_from = " FROM #__kb_articles AS f"; $f_where = "f.state=1 AND f.created > '{$period->cStartDate}' AND f.created < '{$period->cEndDate}' AND f.access IN (" . implode(',', User::getAuthorisedViewLevels()) . ")"; $order_by = " ORDER BY created DESC, title"; $order_by .= $limit != 'all' ? " LIMIT {$limitstart},{$limit}" : ""; if (!$limit) { // Get a count $database->setQuery($f_count . $f_from . " WHERE " . $f_where); return $database->loadResult(); } else { // Get results $database->setQuery($f_fields . $f_from . " WHERE " . $f_where . $order_by); $rows = $database->loadObjectList(); foreach ($rows as $key => $row) { $rows[$key]->href = Route::url($row->href); } return $rows; } }
/** * Method to get the field input markup. * * @return string The field input markup. * @since 1.6 */ protected function getInput() { // Initialize variables. $html = array(); $attr = ''; // Initialize some field attributes. $attr .= $this->element['class'] ? ' class="' . (string) $this->element['class'] . '"' : ''; $attr .= (string) $this->element['disabled'] == 'true' ? ' disabled="disabled"' : ''; $attr .= $this->element['size'] ? ' size="' . (int) $this->element['size'] . '"' : ''; // Initialize JavaScript field attributes. $attr .= $this->element['onchange'] ? ' onchange="' . (string) $this->element['onchange'] . '"' : ''; // Get some field values from the form. $pluginId = (int) $this->form->getValue('extension_id'); $folder = $this->form->getValue('folder'); $db = App::get('db'); // Build the query for the ordering list. $query = 'SELECT ordering AS value, name AS text, type AS type, folder AS folder, extension_id AS extension_id' . ' FROM #__extensions' . ' WHERE (type =' . $db->Quote('plugin') . 'AND folder=' . $db->Quote($folder) . ')' . ' ORDER BY ordering'; // Create a read-only list (no name) with a hidden input to store the value. if ((string) $this->element['readonly'] == 'true') { $html[] = JHtml::_('list.ordering', '', $query, trim($attr), $this->value, $pluginId ? 0 : 1); $html[] = '<input type="hidden" name="' . $this->name . '" value="' . $this->value . '"/>'; } else { $html[] = JHtml::_('list.ordering', $this->name, $query, trim($attr), $this->value, $pluginId ? 0 : 1); } return implode($html); }
/** * Constructor * * @param mixed $oid ID (integer), alias (string), array or object * @param integer $pid Post ID * @return void */ public function __construct($oid = null, $pid = null) { $this->_db = \App::get('db'); $cls = $this->_tbl_name; $this->_tbl = new $cls($this->_db); if (!$this->_tbl instanceof \JTable) { $this->_logError(__CLASS__ . '::' . __FUNCTION__ . '(); ' . Lang::txt('Table class must be an instance of JTable.')); throw new LogicException(Lang::txt('Table class must be an instance of JTable.')); } if ($oid) { if (is_numeric($oid)) { $this->_tbl->load($oid); } else { if (is_string($oid)) { $this->_tbl->loadByAlias($oid, $section_id); } else { if (is_object($oid) || is_array($oid)) { $this->bind($oid); } } } } else { if ($pid) { $this->_tbl->loadByPost($pid); } } }
/** * Return data on a resource view (this will be some form of HTML) * * @param object $resource Current resource * @param string $option Name of the component * @param array $areas Active area(s) * @param string $rtrn Data to be returned * @return array */ public function onResources($model, $option, $areas, $rtrn = 'all') { $arr = array('area' => $this->_name, 'html' => '', 'metadata' => ''); // Check if our area is in the array of areas we want to return results for if (is_array($areas)) { if (!array_intersect($areas, $this->onResourcesAreas($model)) && !array_intersect($areas, array_keys($this->onResourcesAreas($model)))) { $rtrn = 'metadata'; } } // Display only for tools if (!$model->isTool()) { return $arr; } if ($rtrn == 'all' || $rtrn == 'html') { $database = App::get('db'); $tv = new \Components\Tools\Tables\Version($database); $rows = $tv->getVersions($model->resource->alias); // Get contribtool params $tconfig = Component::params('com_tools'); // Instantiate a view $view = $this->view('default', 'browse')->set('tconfig', $tconfig)->set('option', $option)->set('resource', $model->resource)->set('rows', $rows); // Return the output $arr['html'] = $view->loadTemplate(); } if ($rtrn == 'all' || $rtrn == 'metadata') { $arr['metadata'] = ''; } return $arr; }
/** * Constructor * * @param object &$subject Event observer * @param array $config Optional config values * @return void */ public function __construct(&$subject, $config) { parent::__construct($subject, $config); // load plugin parameters $this->_config = Component::params('com_projects'); $this->_database = App::get('db'); }
/** * Parse the segments of a URL. * * @param array &$segments The segments of the URL to parse. * @return array The URL attributes to be used by the application. */ public function parse(&$segments) { $vars = array(); if (isset($segments[0])) { $vars['controller'] = $segments[0]; // The next url segment should be the id // Task should already be set by the loader if (isset($segments[1])) { if (is_numeric($segments[1])) { $vars['id'] = $segments[1]; // Read needs to be set explictly because read, list, and the api docblock all use GETs if (\App::get('request')->method() == 'GET') { $vars['task'] = 'read'; } } else { throw new Exception(Lang::txt("COM_SUPPORT_TASK_NOT_FOUND"), 404); } } else { if (\App::get('request')->method() == 'GET') { $vars['task'] = 'list'; } } } return $vars; }
/** * Return data on a publication sub view (this will be some form of HTML) * * @param object $publication Current publication * @param string $option Name of the component * @param integer $miniview View style * @return array */ public function onPublicationSub($publication, $option, $miniview = 0) { $arr = array('html' => '', 'metadata' => '', 'name' => 'recommendations'); // Check if our area is in the array of areas we want to return results for $areas = array('recommendations'); if (!array_intersect($areas, $this->onPublicationSubAreas($publication)) && !array_intersect($areas, array_keys($this->onPublicationSubAreas($publication)))) { return false; } // Get some needed libraries include_once PATH_CORE . DS . 'plugins' . DS . 'publications' . DS . 'recommendations' . DS . 'publication.recommendation.php'; // Set some filters for returning results $filters = array('id' => $publication->get('id'), 'threshold' => $this->params->get('threshold', '0.21'), 'limit' => $this->params->get('display_limit', 10)); // Get recommendations $database = App::get('db'); $r = new PublicationRecommendation($database); $results = $r->getResults($filters); $view = new \Hubzero\Plugin\View(array('folder' => $this->_type, 'element' => $this->_name, 'name' => 'browse')); // Instantiate a view if ($miniview) { $view->setLayout('mini'); } // Pass the view some info $view->option = $option; $view->publication = $publication; $view->results = $results; if ($this->getError()) { $view->setError($this->getError()); } // Return the output $arr['html'] = $view->loadTemplate(); return $arr; }
/** * Pull a list of records that were created within the time frame ($period) * * @param object $period Time period to pull results for * @param mixed $limit Number of records to pull * @param integer $limitstart Start of records to pull * @param array $areas Active area(s) * @param array $tagids Array of tag IDs * @return array */ public function onWhatsnew($period, $limit = 0, $limitstart = 0, $areas = null, $tagids = array()) { if (is_array($areas) && $limit) { if (!isset($areas[$this->_name]) && !in_array($this->_name, $areas)) { return array(); } } // Do we have a search term? if (!is_object($period)) { return array(); } $database = App::get('db'); // Build the query $f_count = "SELECT COUNT(*)"; $f_fields = "SELECT\n\t\t\tf.id,\n\t\t\tf.title,\n\t\t\tf.fulltxt AS `text`,\n\t\t\tconcat('index.php?option=com_kb§ion=', coalesce(concat(c.path, '/'), ''), f.alias) AS href,\n\t\t\t'kb' AS section,\n\t\t\tc.alias AS subsection"; $f_from = " FROM `#__kb_articles` AS f\n\t\t\tLEFT JOIN `#__categories` AS c\n\t\t\t\tON c.id = f.category\n\t\t\tWHERE f.state=1\n\t\t\t\tAND c.published = 1\n\t\t\t\tAND f.created > " . $database->quote($period->cStartDat) . "\n\t\t\t\tAND f.created < " . $database->quote($period->cEndDate) . "\n\t\t\t\tAND f.access IN (" . implode(',', User::getAuthorisedViewLevels()) . ")"; $order_by = " ORDER BY f.created DESC, f.title"; $order_by .= $limit != 'all' ? " LIMIT {$limitstart},{$limit}" : ""; if (!$limit) { // Get a count $database->setQuery($f_count . $f_from); return $database->loadResult(); } else { // Get results $database->setQuery($f_fields . $f_from . $order_by); $rows = $database->loadObjectList(); foreach ($rows as $key => $row) { $rows[$key]->href = Route::url($row->href); } return $rows; } }
/** * Method to get the available menu item type options. * * @return array Array of groups with menu item types. * @since 1.6 */ public function getTypeOptions() { // Initialise variables. $lang = Lang::getRoot(); $list = array(); // Get the list of components. $db = App::get('db'); $query = $db->getQuery(true); $query->select('name, element AS ' . $db->qn('option')); $query->from('#__extensions'); $query->where('type = ' . $db->q('component')); $query->where('enabled = 1'); $query->order('name ASC'); $db->setQuery($query); $components = $db->loadObjectList(); foreach ($components as $component) { if ($options = $this->getTypeOptionsByComponent($component->option)) { $list[$component->name] = $options; // Create the reverse lookup for link-to-name. foreach ($options as $option) { if (isset($option->request)) { $this->rlu[MenusHelper::getLinkKey($option->request)] = $option->get('title'); if (isset($option->request['option'])) { $lang->load($option->request['option'] . '.sys', PATH_APP, null, false, true) || $lang->load($option->request['option'] . '.sys', PATH_CORE . '/components/' . $option->request['option'] . '/admin', null, false, true); } } } } } return $list; }
/** * Return data on a resource sub view (this will be some form of HTML) * * @param object $resource Current resource * @param string $option Name of the component * @param integer $miniview View style * @return array */ public function onResourcesSub($resource, $option, $miniview = 0) { $arr = array('area' => $this->_name, 'html' => '', 'metadata' => ''); // Get some needed libraries include_once __DIR__ . DS . 'resources.recommendation.php'; // Set some filters for returning results $filters = array('id' => $resource->id, 'threshold' => $this->params->get('threshold', '0.21'), 'limit' => $this->params->get('display_limit', 10)); $view = new \Hubzero\Plugin\View(array('folder' => $this->_type, 'element' => $this->_name, 'name' => 'browse')); // Instantiate a view if ($miniview) { $view->setLayout('mini'); } // Pass the view some info $view->option = $option; $view->resource = $resource; // Get recommendations $database = App::get('db'); $r = new ResourcesRecommendation($database); $view->results = $r->getResults($filters); if ($this->getError()) { $view->setError($this->getError()); } // Return the output $arr['html'] = $view->loadTemplate(); return $arr; }
/** * Get tags for a list of IDs * * @param array $ids Bulletin ids * @param integer $admin Admin flag * @return array */ public function getTagsForIds($ids = array(), $admin = 0) { $tt = Tag::blank(); $tj = Object::blank(); if (!is_array($ids) || empty($ids)) { return false; } $ids = array_map('intval', $ids); $sql = "SELECT t.tag, t.raw_tag, t.admin, rt.objectid\n\t\t\t\tFROM " . $tt->getTableName() . " AS t \n\t\t\t\tINNER JOIN " . $tj->getTableName() . " AS rt ON (rt.tagid = t.id) AND rt.tbl='" . $this->_scope . "' \n\t\t\t\tWHERE rt.objectid IN (" . implode(',', $ids) . ") "; switch ($admin) { case 1: $sql .= ""; break; case 0: default: $sql .= "AND t.admin=0 "; break; } $sql .= "ORDER BY raw_tag ASC"; $db = \App::get('db'); $db->setQuery($sql); $tags = array(); if ($items = $db->loadObjectList()) { foreach ($items as $item) { if (!isset($tags[$item->objectid])) { $tags[$item->objectid] = array(); } $tags[$item->objectid][] = $item; } } return $tags; }
/** * Get a list of articles * * @param object $params Registry * @return array */ public static function getList(&$params) { // Get database $db = \App::get('db'); $query = $db->getQuery(true); $query->select('MONTH(created) AS created_month, created, id, title, YEAR(created) AS created_year'); $query->from('#__content'); $query->where('state = 2 AND checked_out = 0'); $query->group('created_year DESC, created_month DESC'); // Filter by language if (App::get('languag.filter')) { $query->where('language in (' . $db->quote(Lang::getTag()) . ',' . $db->quote('*') . ')'); } $db->setQuery($query, 0, intval($params->get('count'))); $rows = (array) $db->loadObjectList(); $menu = App::get('menu'); $item = $menu->getItems('link', 'index.php?option=com_content&view=archive', true); $itemid = isset($item) && !empty($item->id) ? '&Itemid=' . $item->id : ''; $i = 0; $lists = array(); foreach ($rows as $row) { $date = Date::of($row->created); $created_month = $date->format('n'); $created_year = $date->format('Y'); $created_year_cal = Date::of($row->created)->toLocal('Y'); $month_name_cal = Date::of($row->created)->toLocal('F'); $lists[$i] = new stdClass(); $lists[$i]->link = Route::url('index.php?option=com_content&view=archive&year=' . $created_year . '&month=' . $created_month . $itemid); $lists[$i]->text = Lang::txt('MOD_ARTICLES_ARCHIVE_DATE', $month_name_cal, $created_year_cal); $i++; } return $lists; }
/** * Authorize * * @return void */ public function authorizeTask() { $oauth_token = \Request::getVar('oauth_token'); if (empty($oauth_token)) { throw new Exception('Forbidden', 403); } $db = \App::get('db'); $db->setQuery("SELECT * FROM `#__oauthp_tokens` WHERE token=" . $db->Quote($oauth_token) . " AND user_id=0 LIMIT 1;"); $result = $db->loadObject(); if ($result === false) { throw new Exception('Internal Server Error', 500); } if (empty($result)) { throw new Exception('Forbidden', 403); } if (Request::method() == 'GET') { $this->view->oauth_token = $oauth_token; $this->view->display(); return; } if (Request::method() == 'POST') { $token = Request::get('token', '' . 'post'); if ($token != sha1($this->verifier)) { throw new Exception('Forbidden', 403); } echo "posted"; return; } throw new Exception('Method Not Allowed', 405); }
/** * Parse the segments of a URL. * * @param array &$segments The segments of the URL to parse. * @return array The URL attributes to be used by the application. */ public function parse(&$segments) { $vars = array(); $vars['controller'] = 'collections'; if (isset($segments[0])) { // /billboards // /billboards/list // /billboards/## if (is_numeric($segments[0])) { $vars['id'] = $segments[0]; if (\App::get('request')->method() == 'GET') { $vars['task'] = 'read'; } } else { $vars['task'] = $segments[0]; } if (isset($segments[1])) { if ($segments[1] == 'boards') { $vars['controller'] = $segments[1]; $vars['task'] = 'list'; } else { $vars['task'] = $segments[1]; } } } return $vars; }
/** * Prepares the document. * * @since 1.6 */ protected function prepareDocument() { $menus = \App::get('menu'); $title = null; // Because the application sets a default page title, // we need to get it from the menu item itself $menu = $menus->getActive(); if ($menu) { $this->params->def('page_heading', $this->params->get('page_title', $menu->title)); } else { $this->params->def('page_heading', Lang::txt('COM_USERS_RESET')); } $title = $this->params->get('page_title', ''); if (empty($title)) { $title = Config::get('sitename'); } elseif (Config::get('sitename_pagetitles', 0) == 1) { $title = Lang::txt('JPAGETITLE', Config::get('sitename'), $title); } elseif (Config::get('sitename_pagetitles', 0) == 2) { $title = Lang::txt('JPAGETITLE', $title, Config::get('sitename')); } $this->document->setTitle($title); if ($this->params->get('menu-meta_description')) { $this->document->setDescription($this->params->get('menu-meta_description')); } if ($this->params->get('menu-meta_keywords')) { $this->document->setMetadata('keywords', $this->params->get('menu-meta_keywords')); } if ($this->params->get('robots')) { $this->document->setMetadata('robots', $this->params->get('robots')); } }
/** * Parse the segments of a URL. * * @param array &$segments The segments of the URL to parse. * @return array The URL attributes to be used by the application. */ public function parse(&$segments) { $vars = array(); $vars['controller'] = 'groups'; if (isset($segments[0])) { if (is_numeric($segments[0])) { $vars['id'] = $segments[0]; if (\App::get('request')->method() == 'GET') { $vars['task'] = 'read'; } } else { $vars['task'] = $segments[0]; } if (isset($segments[1])) { if ($segments[1] == 'members') { $vars['controller'] = $segments[1]; $vars['task'] = 'index'; if (isset($segments[2])) { $vars['task'] = $segments[2]; } } else { $vars['task'] = $segments[1]; } } } return $vars; }