예제 #1
0
 /**
  * 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();
 }
예제 #2
0
 /**
  * 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();
 }
예제 #3
0
 /**
  * Event call for displaying usage data
  *
  * @param      string $option        Component name
  * @param      string $task          Component task
  * @param      object $db            JDatabase
  * @param      array  $months        Month names (Jan -> Dec)
  * @param      array  $monthsReverse Month names in reverse (Dec -> Jan)
  * @param      string $enddate       Time period
  * @return     string HTML
  */
 public function onUsageDisplay($option, $task, $db, $months, $monthsReverse, $enddate)
 {
     // Check if our task is the area we want to return results for
     if ($task) {
         if (!in_array($task, $this->onUsageAreas()) && !in_array($task, array_keys($this->onUsageAreas()))) {
             return '';
         }
     }
     // Set some vars
     $thisyear = date("Y");
     $o = \Components\Usage\Helpers\Helper::options($db, $enddate, $thisyear, $monthsReverse, 'check_for_regiondata');
     // Build HTML
     $html = '<form method="post" action="' . Route::url('index.php?option=' . $option . '&task=' . $task) . '">' . "\n";
     $html .= "\t" . '<fieldset class="filters">' . "\n";
     $html .= "\t\t" . '<label>' . "\n";
     $html .= "\t\t\t" . Lang::txt('PLG_USAGE_SHOW_DATA_FOR') . ': ' . "\n";
     $html .= "\t\t\t" . '<select name="selectedPeriod" id="selectedPeriod">' . "\n";
     $html .= $o;
     $html .= "\t\t\t" . '</select>' . "\n";
     $html .= "\t\t" . '</label> <input type="submit" value="' . Lang::txt('PLG_USAGE_VIEW') . '" />' . "\n";
     $html .= "\t" . '</fieldset>' . "\n";
     $html .= '</form>' . "\n";
     $html .= \Components\Usage\Helpers\Helper::toplist($db, 10, 1, $enddate);
     $html .= \Components\Usage\Helpers\Helper::toplist($db, 17, 2, $enddate);
     $html .= \Components\Usage\Helpers\Helper::toplist($db, 11, 3, $enddate);
     $html .= \Components\Usage\Helpers\Helper::toplist($db, 9, 4, $enddate);
     $html .= \Components\Usage\Helpers\Helper::toplist($db, 12, 5, $enddate);
     $html .= \Components\Usage\Helpers\Helper::toplist($db, 19, 6, $enddate);
     $html .= \Components\Usage\Helpers\Helper::toplist($db, 18, 7, $enddate);
     $html .= \Components\Usage\Helpers\Helper::toplist($db, 7, 8, $enddate);
     // Return HTML
     return $html;
 }