/default_www/backend/modules/search/actions/statistics.php

https://github.com/pban02/forkcms · PHP · 92 lines · 32 code · 17 blank · 43 comment · 1 complexity · bf87fa0233d1bf0244dc5967ab97832c MD5 · raw file

  1. <?php
  2. /**
  3. * This is the statistics-action, it will display the overview of search statistics
  4. *
  5. * @package backend
  6. * @subpackage search
  7. *
  8. * @author Matthias Mullie <matthias@netlash.com>
  9. * @since 2.0
  10. */
  11. class BackendSearchStatistics extends BackendBaseActionIndex
  12. {
  13. /**
  14. * Execute the action
  15. *
  16. * @return void
  17. */
  18. public function execute()
  19. {
  20. // call parent, this will probably add some general CSS/JS or other required files
  21. parent::execute();
  22. // load datagrids
  23. $this->loadDataGrid();
  24. // parse page
  25. $this->parse();
  26. // display the page
  27. $this->display();
  28. }
  29. /**
  30. * Loads the datagrids
  31. *
  32. * @return void
  33. */
  34. private function loadDataGrid()
  35. {
  36. // create datagrid
  37. $this->dataGrid = new BackendDataGridDB(BackendSearchModel::QRY_DATAGRID_BROWSE_STATISTICS, BL::getWorkingLanguage());
  38. // hide column
  39. $this->dataGrid->setColumnsHidden('data');
  40. // create column
  41. $this->dataGrid->addColumn('referrer', BL::lbl('Referrer'));
  42. // header labels
  43. $this->dataGrid->setHeaderLabels(array('time' => ucfirst(BL::lbl('SearchedOn'))));
  44. // set column function
  45. $this->dataGrid->setColumnFunction(array(__CLASS__, 'setReferrer'), '[data]', 'referrer');
  46. $this->dataGrid->setColumnFunction(array('BackendDataGridFunctions', 'getLongDate'), array('[time]'), 'time', true);
  47. // sorting columns
  48. $this->dataGrid->setSortingColumns(array('time', 'term'), 'time');
  49. $this->dataGrid->setSortParameter('desc');
  50. }
  51. /**
  52. * Parse & display the page
  53. *
  54. * @return void
  55. */
  56. private function parse()
  57. {
  58. // assign the datagrid
  59. $this->tpl->assign('dataGrid', ($this->dataGrid->getNumResults() != 0) ? $this->dataGrid->getContent() : false);
  60. }
  61. /**
  62. * Set column referrer
  63. *
  64. * @return string
  65. * @param string $data The source data.
  66. */
  67. public static function setReferrer($data)
  68. {
  69. // unserialize
  70. $data = unserialize($data);
  71. // return correct data
  72. return (isset($data['server']['HTTP_REFERER'])) ? '<a href="' . $data['server']['HTTP_REFERER'] . '">' . $data['server']['HTTP_REFERER'] . '</a>' : '';
  73. }
  74. }
  75. ?>