/** * Display dashboard * * @return array */ public function indexAction() { $data = array(); $data['version'] = Version::VERSION; $data['versionIsLatest'] = Version::isLatest(); $data['versionLatest'] = Version::getLatest(); $documents = new Collection(); $contentStats = array(); $contentStats['online_documents'] = array('count' => count($documents->getAvailableDocuments()), 'label' => 'Online documents', 'route' => 'content'); $contentStats['total_documents'] = array('count' => count($documents->select()->toArray()), 'label' => 'Total documents', 'route' => 'content'); $data['contentStats'] = $contentStats; $visitorModel = new Visitor(); $data['userStats'] = array('total_visitors' => array('count' => $visitorModel->getTotalVisitors(), 'label' => 'Total visitors', 'route' => 'statistics'), 'total_visits' => array('count' => $visitorModel->getTotalPageViews(), 'label' => 'Total page views', 'route' => 'statistics')); $coreConfig = $this->getServiceLocator()->get('CoreConfig'); $widgets = @unserialize($coreConfig->getValue('dashboard_widgets')); $data['dashboardSortable'] = !empty($widgets['sortable']) ? Json::encode($widgets['sortable']) : '{}'; $data['dashboardWelcome'] = !empty($widgets['welcome']); $data['customeWidgets'] = array(); $this->events()->trigger(__CLASS__, 'dashboard', $this, array('widgets' => &$data['customeWidgets'])); return $data; }
/** * Initialize update directory * * @return void */ public function init() { $this->setData('update_directory', GC_APPLICATION_PATH . '/data/update/' . Version::getLatest()); }
/** * Check version in info file * from $type directory * * @param array $directories List of directories * @param string $type Type of directory * @param array &$errors Insert in this all errors * * @return void */ protected function checkVersion(array $directories, $type, array &$errors) { $latestVersion = Version::getLatest(); foreach ($directories as $directory) { if (is_dir($directory)) { $filename = $directory . '/' . $type . '.info'; $info = new Info(); if ($info->fromFile($filename) === true) { $infos = $info->getInfos(); if (!empty($infos['cms_version'])) { preg_match('~(?<operator>[>=]*)(?<version>.+)~', $infos['cms_version'], $matches); if (empty($matches['operator'])) { if (version_compare($latestVersion, $matches['version']) === 1) { $errors[] = basename($directory); } } else { if (!version_compare($latestVersion, $matches['version'], $matches['operator'])) { $errors[] = $directory; } } } } } } }
/** * Test * * @return void */ public function testGetLatestVersion() { $this->assertEquals(\Gc\Version::getLatest(), $this->object->getLatestVersion()); }
/** * GetLatest version * * @return string */ public function getLatestVersion() { return Version::getLatest(); }