From b298f73b908ba2cfa69d4170bf6339e7f09b6b7b Mon Sep 17 00:00:00 2001 From: Laurent Giovannoni <laurent.giovannoni@maarch.org> Date: Mon, 7 May 2012 14:04:15 +0000 Subject: [PATCH] tests --- core/trunk/install/class/class_install.php | 194 +++++++++++++++++++++ core/trunk/install/static/css/install.css | 0 core/trunk/install/static/js/install.js | 1 + core/trunk/install/static/lang/en.php | 14 ++ core/trunk/install/static/lang/fr.php | 15 ++ core/trunk/install/test.php | 28 +++ core/trunk/install/view/helloWorld.php | 1 + 7 files changed, 253 insertions(+) create mode 100644 core/trunk/install/static/css/install.css create mode 100644 core/trunk/install/static/js/install.js create mode 100644 core/trunk/install/test.php create mode 100644 core/trunk/install/view/helloWorld.php diff --git a/core/trunk/install/class/class_install.php b/core/trunk/install/class/class_install.php index e69de29bb2d..7ef5c6a88ec 100644 --- a/core/trunk/install/class/class_install.php +++ b/core/trunk/install/class/class_install.php @@ -0,0 +1,194 @@ +<?php + +/* +* Copyright 2008-2012 Maarch +* +* This file is part of Maarch Framework. +* +* Maarch Framework is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* Maarch Framework is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with Maarch Framework. If not, see <http://www.gnu.org/licenses/>. +*/ + +/** +* @brief class of install tools +* +* @file +* @author Laurent Giovannoni +* @date $date$ +* @version $Revision$ +* @ingroup install +*/ + +//Loads the required class +try { + require_once 'core/class/class_functions.php'; + require_once 'core/class/class_db.php'; +} catch (Exception $e) { + echo $e->getMessage() . ' // '; +} + + +class install extends functions +{ + private $lang; + + /** + * get languages available + * @return array of languages + */ + public function getlanguages() + { + $languages = array(); + $classScan = dir('install/static/lang/'); + while (($filescan = $classScan->read()) != false) { + if ($filescan == '.' || $filescan == '..' || $filescan == '.svn') { + continue; + } else { + array_push($languages, str_replace('.php', '', $filescan)); + } + } + return $languages; + } + + /** + * load the lang constant file + * @param $lang lang + * @return nothing + */ + public function loadLang($lang) + { + $this->lang = $lang; + include_once('install/static/lang/' . $lang . '.php'); + } + + /** + * load the header + * @return nothing + */ + public function loadHeader() + { + $header = '<head>'; + $header .= '<title>' . _INSTALL_TITLE . '</title>'; + $header .= '<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />'; + $header .= '<meta http-equiv="Content-Language" content="' . $this->lang . '" />'; + $header .= $this->loadCss(); + $header .= $this->loadjs(); + $header .= '</head>'; + return $header; + } + + /** + * load the css + * @return nothing + */ + private function loadCss() + { + $includeCss = '<link rel="stylesheet" type="text/css" href="static/css/install.css" media="screen" />'; + return $includeCss; + } + + /** + * load the js + * @return nothing + */ + private function loadJs() + { + $includeJs = '<script type="text/javascript" src="static/js/install.js"></script>'; + return $includeJs; + } + + /** + * load the current page + * @param $page string name of the page + * @return nothing + */ + public function loadView($viewName) + { + include 'install/view/' . $viewName . '.php'; + } + + /** + * load the footer + * @return nothing + */ + public function loadFooter() + { + echo ' ' . _POWERED_BY; + } + + /** + * test if the php version is alright + * @return boolean + */ + public function isPhpRequirements() + { + if (version_compare(PHP_VERSION, '5.3') < 0) { + return false; + } else { + return true; + } + } + + /** + * test if php postgres libray loaded + * @return boolean + */ + public function isPostgresRequirements() + { + if (!@extension_loaded('pgsql')) { + return false; + } else { + return true; + } + } + + /** + * test if php gd libray loaded + * @return boolean + */ + public function isGdRequirements() + { + if (!@extension_loaded('gd')) { + return false; + } else { + return true; + } + } + + /** + * test if php svn libray loaded + * @return boolean + */ + public function isSvnRequirements() + { + if (!@extension_loaded('svn')) { + return false; + } else { + return true; + } + } + + /** + * test if pear mime type libray loaded + * @return boolean + */ + public function isMimeTypeRequirements() + { + try { + require_once('MIME/Type.php'); + return true; + } catch (Exception $e) { + return false; + } + } +} diff --git a/core/trunk/install/static/css/install.css b/core/trunk/install/static/css/install.css new file mode 100644 index 00000000000..e69de29bb2d diff --git a/core/trunk/install/static/js/install.js b/core/trunk/install/static/js/install.js new file mode 100644 index 00000000000..9a2afcc3746 --- /dev/null +++ b/core/trunk/install/static/js/install.js @@ -0,0 +1 @@ +//window.alert('ici'); diff --git a/core/trunk/install/static/lang/en.php b/core/trunk/install/static/lang/en.php index e69de29bb2d..4e60a04bf3f 100644 --- a/core/trunk/install/static/lang/en.php +++ b/core/trunk/install/static/lang/en.php @@ -0,0 +1,14 @@ +<?php + +/************** test **************/ +if (!defined('_TEST')) { + define( '_TEST', 'this is a test'); +} + +if (!defined('_INSTALL_TITLE')) { + define( '_INSTALL_TITLE', 'Maarch Entreprise installation'); +} + +if (!defined('_POWERED_BY')) { + define('_POWERED_BY', 'Powered by Maarch™.'); +} diff --git a/core/trunk/install/static/lang/fr.php b/core/trunk/install/static/lang/fr.php index e69de29bb2d..4a6006b9f71 100644 --- a/core/trunk/install/static/lang/fr.php +++ b/core/trunk/install/static/lang/fr.php @@ -0,0 +1,15 @@ +<?php + +/************** test **************/ +if (!defined('_TEST')) { + define( '_TEST', 'ceci est un test'); +} + +if (!defined('_INSTALL_TITLE')) { + define( '_INSTALL_TITLE', 'Installation de Maarch Entreprise'); +} + +if (!defined('_POWERED_BY')) { + define('_POWERED_BY', 'Powered by Maarch™.'); +} + diff --git a/core/trunk/install/test.php b/core/trunk/install/test.php new file mode 100644 index 00000000000..6cd3c1ba7d5 --- /dev/null +++ b/core/trunk/install/test.php @@ -0,0 +1,28 @@ +<?php + +include_once '../core/init.php'; + +require_once 'install/class/class_install.php'; + +$install = new install(); +$languages = $install->getlanguages(); +$install->loadLang($languages[1]); + +echo '<html>'; +echo $install->loadHeader(); +echo '<body>'; +echo $install->loadview('helloWorld'); +echo '<br>'; +echo 'php version:' . $install->isPhpRequirements(); +echo '<br>'; +echo 'postgres library:' . $install->isPostgresRequirements(); +echo '<br>'; +echo 'GD library:' . $install->isGdRequirements(); +echo '<br>'; +echo 'Mime type:' . $install->isMimeTypeRequirements(); +echo '<br>'; +echo 'svn library (optionnal and only under linux system):' . $install->isSvnRequirements(); +echo '<br>'; +echo '</body>'; +echo $install->loadFooter(); +echo '</html>'; diff --git a/core/trunk/install/view/helloWorld.php b/core/trunk/install/view/helloWorld.php new file mode 100644 index 00000000000..a95200ff94e --- /dev/null +++ b/core/trunk/install/view/helloWorld.php @@ -0,0 +1 @@ +hello world ! -- GitLab