/** * Display usage data * * @return void */ public function defaultTask() { // Set some common variables $thisyear = date("Y"); $months = array('01' => 'Jan', '02' => 'Feb', '03' => 'Mar', '04' => 'Apr', '05' => 'May', '06' => 'Jun', '07' => 'Jul', '08' => 'Aug', '09' => 'Sep', '10' => 'Oct', '11' => 'Nov', '12' => 'Dec'); $monthsReverse = array_reverse($months, TRUE); // Incoming $enddate = Request::getVar('selectedPeriod', 0, 'post'); // Establish a connection to the usage database $udb = Helper::getUDBO(); if (!is_object($udb)) { throw new Exception(Lang::txt('COM_USAGE_ERROR_CONNECTING_TO_DATABASE'), 500); } $this->view->no_html = Request::getVar('no_html', 0); // Trigger the functions that return the areas we'll be using $this->view->cats = Event::trigger('usage.onUsageAreas'); if (is_array($this->view->cats)) { if (!$this->_task || $this->_task == 'default') { $this->_task = isset($this->view->cats[0]) && is_array($this->view->cats[0]) ? key($this->view->cats[0]) : 'overview'; } } $this->_task = $this->_task ? $this->_task : 'overview'; $this->view->task = $this->_task; // Set the pathway if (Pathway::count() <= 0) { Pathway::append(Lang::txt(strtoupper($this->_option)), 'index.php?option=' . $this->_option); } if ($this->_task) { Pathway::append(Lang::txt('PLG_' . strtoupper($this->_name) . '_' . strtoupper($this->_task)), 'index.php?option=' . $this->_option . '&task=' . $this->_task); } // Get the sections $this->view->sections = Event::trigger('usage.onUsageDisplay', array($this->_option, $this->_task, $udb, $months, $monthsReverse, $enddate)); // Build the page title $this->view->title = Lang::txt(strtoupper($this->_option)); $this->view->title .= $this->_task ? ': ' . Lang::txt('PLG_' . strtoupper($this->_name) . '_' . strtoupper($this->_task)) : ''; // Set the page title Document::setTitle($this->view->title); // Output HTML foreach ($this->getErrors() as $error) { $this->view->setError($error); } $this->view->setLayout('default')->display(); }
/** * Display module content * * @return void */ public function display() { $database = \App::get('db'); include_once \Component::path('com_usage') . DS . 'helpers' . DS . 'helper.php'; $udb = \Components\Usage\Helpers\Helper::getUDBO(); $this->cls = trim($this->params->get('moduleclass_sfx')); if ($udb) { $udb->setQuery('SELECT value FROM summary_user_vals WHERE datetime = (SELECT CAST(MAX(datetime) AS CHAR) FROM summary_user_vals) AND period = "12" AND colid = "1" AND rowid = "1"'); $this->users = $udb->loadResult(); $udb->setQuery('SELECT value FROM summary_simusage_vals WHERE datetime = (SELECT CAST(MAX(datetime) AS CHAR) FROM summary_simusage_vals) AND period = "12" AND colid = "1" AND rowid = "2"'); $this->sims = $udb->loadResult(); } else { $database->setQuery("SELECT COUNT(*) FROM `#__users`"); $this->users = $database->loadResult(); $this->sims = 0; } $database->setQuery("SELECT COUNT(*) FROM `#__resources` WHERE standalone=1 AND published=1 AND access!=1 AND access!=4"); $this->resources = $database->loadResult(); $database->setQuery("SELECT COUNT(*) FROM `#__resources` WHERE standalone=1 AND published=1 AND access!=1 AND access!=4 AND type=7"); $this->tools = $database->loadResult(); require $this->getLayoutPath(); }