Overview

Packages

  • Core
    • Authentication
    • Backend
    • Cache
    • CEC
    • Chain
    • ContentType
    • Database
    • Datatype
    • Debug
    • Exception
    • Frontend
      • Search
      • URI
      • Util
    • GenericDB
      • Model
    • GUI
      • HTML
    • I18N
    • LayoutHandler
    • Log
    • Security
    • Session
    • Util
    • Validation
    • Versioning
    • XML
  • Module
    • ContentSitemapHtml
    • ContentSitemapXml
    • ContentUserForum
    • NavigationTop
  • mpAutoloaderClassMap
  • None
  • Plugin
    • ContentAllocation
    • CronjobOverview
    • FormAssistant
    • FrontendLogic
    • FrontendUsers
    • Linkchecker
    • ModRewrite
    • Newsletter
    • Repository
      • FrontendNavigation
      • KeywordDensity
    • SearchSolr
    • SmartyWrapper
    • UrlShortener
    • UserForum
    • Workflow
  • PluginManager
  • Setup
    • Form
    • GUI
    • Helper
      • Environment
      • Filesystem
      • MySQL
      • PHP
    • UpgradeJob

Classes

  • cSetupAdminPassword
  • cSetupClientAdjust
  • cSetupClientMode
  • cSetupConfigMode
  • cSetupInstaller
  • cSetupPath
  • cSetupResults
  • cSetupSetupSummary
  • cSetupSystemData
  • cSetupSystemtest
  • Overview
  • Package
  • Class
  • Tree
  • Deprecated
  • Todo
  1: <?php
  2: /**
  3:  * This file contains the system test setup mask.
  4:  *
  5:  * @package Setup
  6:  * @subpackage Form
  7:  * @version SVN Revision $Rev:$
  8:  *
  9:  * @author Unknown
 10:  * @copyright four for business AG <www.4fb.de>
 11:  * @license http://www.contenido.org/license/LIZENZ.txt
 12:  * @link http://www.4fb.de
 13:  * @link http://www.contenido.org
 14:  */
 15: defined('CON_FRAMEWORK') || die('Illegal call: Missing framework initialization - request aborted.');
 16: 
 17: /**
 18:  * System test setup mask.
 19:  *
 20:  * @package Setup
 21:  * @subpackage Form
 22:  */
 23: class cSetupSystemtest extends cSetupMask {
 24: 
 25:     private $systemtest;
 26: 
 27:     function cSetupSystemtest($step, $previous, $next) {
 28:         global $cfg;
 29: 
 30:         cSetupMask::cSetupMask("templates/setup/forms/systemtest.tpl", $step);
 31: 
 32:         $errors = false;
 33: 
 34:         $this->setHeader(i18n("System Test", "setup"));
 35:         $this->_oStepTemplate->set("s", "TITLE", i18n("System Test", "setup"));
 36:         $this->_oStepTemplate->set("s", "DESCRIPTION", i18n("Your system has been tested for compatibility with CONTENIDO:", "setup"));
 37: 
 38:         // reload i18n for contenido locale
 39:         i18nInit('../data/locale/', $_SESSION['language']);
 40: 
 41:         // Initializing cfgClient
 42:         if ($_SESSION['setuptype'] == 'upgrade') {
 43:             setupInitializeCfgClient(true);
 44:         }
 45: 
 46:         $this->systemtest = new cSystemtest($cfg);
 47:         $this->systemtest->runTests(false);
 48:         $this->systemtest->testFilesystem($_SESSION["configmode"] == "save", $_SESSION['setuptype'] == 'upgrade');
 49:         if ($_SESSION['setuptype'] == 'setup') {
 50:             $this->systemtest->testFrontendFolderCreation();
 51:         }
 52: 
 53:         $cHTMLErrorMessageList = new cHTMLErrorMessageList();
 54: 
 55:         if (is_null(getMySQLDatabaseExtension())) {
 56:             $this->systemtest->storeResult(false, cSystemtest::C_SEVERITY_ERROR, i18n("PHP MySQL Extension missing", "setup"), i18n("CONTENIDO requires the MySQL or MySQLi extension to access MySQL databases. Please configure PHP to use either MySQL or MySQLi.", "setup"));
 57:         } else if ($this->systemtest->testMySQL($_SESSION["dbhost"], $_SESSION["dbuser"], $_SESSION["dbpass"]) == cSystemtest::CON_MYSQL_OK) {
 58:             $this->initDB();
 59:         }
 60: 
 61:         $this->checkCountryLanguageCode();
 62: 
 63:         $cHTMLFoldableErrorMessages = array();
 64: 
 65:         if ($_SESSION["setuptype"] == 'upgrade') {
 66:             // Check if there is an old version of integrated plugins installed
 67:             // in upgrademode.
 68:             $this->doExistingOldPluginTests();
 69: 
 70:             // Check if user updates a system lower than 4.9
 71:             $this->doChangedDirsFilesTest();
 72:         }
 73: 
 74:         if ((int) ini_get('max_execution_time') < 60) {
 75:             $this->systemtest->storeResult(false, cSystemtest::C_SEVERITY_WARNING, i18n("Unable to set max_execution_time", "setup"), i18n("Your PHP configuration for max_execution_time can not be changed via this script. We recommend setting the value for the installation or upgrade process to 60 seconds. You can try to execute the process with your current configuration. If the process is stopped, the system is not usable (any longer)", "setup"));
 76:         }
 77: 
 78:         $results = $this->systemtest->getResults();
 79: 
 80:         foreach ($results as $result) {
 81:             if ($result["result"]) {
 82:                 continue;
 83:             }
 84: 
 85:             switch ($result["severity"]) {
 86:                 case cSystemtest::C_SEVERITY_INFO:
 87:                     $icon = "images/icons/info.png";
 88:                     $iconDescription = i18n("Information", "setup");
 89:                     break;
 90:                 case cSystemtest::C_SEVERITY_WARNING:
 91:                     $icon = "images/icons/warning.png";
 92:                     $iconDescription = i18n("Warning", "setup");
 93:                     break;
 94:                 case cSystemtest::C_SEVERITY_ERROR:
 95:                     $icon = "images/icons/error.png";
 96:                     $iconDescription = i18n("Fatal error", "setup");
 97:                     $errors = true;
 98:                     break;
 99:             }
100:             $cHTMLFoldableErrorMessages[] = new cHTMLFoldableErrorMessage($result["headline"], $result["message"], $icon, $iconDescription);
101:         }
102: 
103:         if (count($cHTMLFoldableErrorMessages) == 0) {
104:             $cHTMLFoldableErrorMessages[] = new cHTMLFoldableErrorMessage(i18n("No problems detected", "setup"), i18n("Setup could not detect any problems with your system environment", "setup"), "images/icons/info.png");
105:         }
106: 
107:         $cHTMLErrorMessageList->setContent($cHTMLFoldableErrorMessages);
108: 
109:         $this->_oStepTemplate->set("s", "CONTROL_TESTRESULTS", $cHTMLErrorMessageList->render());
110: 
111:         if ($errors == true) {
112:             $this->setNavigation($previous, "");
113: 
114:             switch ($_SESSION['setuptype']) {
115:                 case "upgrade":
116:                     $thisStep = 'upgrade' . $step;
117:                     break;
118:                 case "setup":
119:                 default:
120:                     $thisStep = 'setup' . $step;
121:                     break;
122:             }
123: 
124:             $link = new cHTMLLink("#");
125:             $link->attachEventDefinition("pageAttach", "onclick", "document.setupform.step.value = '" . $thisStep . "';");
126:             $link->attachEventDefinition("submitAttach", "onclick", "document.setupform.submit();");
127:             $link->setClass("nav navRefresh");
128:             $link->setContent("<span>R</span>"); // @todo traslation for
129:                                                  // "refresh"
130: 
131:             $this->_oStepTemplate->set("s", "NEXT", $link->render());
132:         } else {
133:             $this->setNavigation($previous, $next);
134:         }
135:     }
136: 
137:     function doExistingOldPluginTests() {
138:         $db = getSetupMySQLDBConnection(false);
139:         $message = '';
140: 
141:         // get all tables in database and list it into array
142:         $avariableTableNames = array();
143:         $tableNames = $db->getTableNames();
144:         if (!is_array($tableNames)) {
145:             return;
146:         }
147: 
148:         foreach ($tableNames as $table) {
149:             $avariableTableNames[] = $table['table_name'];
150:         }
151: 
152:         // list of plugin tables to copy into new plugin tables
153:         $oldPluginTables = array(
154:             'Workflow' => array(
155:                 'piwf_actions',
156:                 'piwf_allocation',
157:                 'piwf_art_allocation',
158:                 'piwf_items',
159:                 'piwf_user_sequences',
160:                 'piwf_workflow'
161:             ),
162:             'Content allocation' => array(
163:                 'pica_alloc',
164:                 'pica_alloc_con',
165:                 'pica_lang'
166:             ),
167:             'Linkchecker' => array(
168:                 'pi_externlinks',
169:                 'pi_linkwhitelist'
170:             )
171:         );
172: 
173:         foreach ($oldPluginTables as $plugin => $tables) {
174:             $pluginExists = false;
175:             foreach ($tables as $currentTable) {
176:                 if (in_array($currentTable, $avariableTableNames)) {
177:                     $pluginExists = true;
178:                 }
179:             }
180: 
181:             if ($pluginExists) {
182:                 $message .= sprintf(i18n('An old Version of Plugin %s is installed on your system.', "setup") . "<br>\n", $plugin);
183:             }
184:         }
185: 
186:         if ($message) {
187:             $message .= '<br>' . i18n('Please remove all old plugins before you continue. To transfer old plugin data, please copy the old plugin data tables into the new plugin data tables after the installation. The new plugintable names are the same, but contains the table prefix of CONTENIDO. Also delete the old plugin tables after data transfer.', "setup");
188: 
189:             $this->systemtest->storeResult(false, cSystemtest::C_SEVERITY_WARNING, i18n("Old Plugins are still installed", "setup"), $message);
190:         }
191:     }
192: 
193:     function doChangedDirsFilesTest() {
194:         global $cfg;
195: 
196:         $db = getSetupMySQLDBConnection(false);
197:         $version = getContenidoVersion($db, $cfg['tab']['system_prop']);
198: 
199:         // Display message about changed directories/files when user updates a
200:         // system lower than 4.9
201:         if ($version && version_compare('4.9', $version) > 0) {
202:             $message = i18n("You are updating a previous version of CONTENIDO to %s. Some directories/files have been moved to other sections in %s.\n\nPlease ensure to copy contenido/includes/config.php to data/config/production/config.php and also other configuration files within contenido/includes/ to data/config/production/.", "setup");
203:             $message = sprintf($message, '4.9', '4.9');
204:             $message = nl2br($message);
205:             $this->systemtest->storeResult(false, cSystemtest::C_SEVERITY_WARNING, i18n("Attention: Some directories/files have been moved", "setup"), $message);
206:         }
207:     }
208: 
209:     function checkCountryLanguageCode() {
210:         if ($_SESSION["setuptype"] != 'upgrade') {
211:             return;
212:         }
213: 
214:         $errors = array();
215: 
216:         cDb::setDefaultConfiguration($GLOBALS['cfg']['db']);
217: 
218:         $clientLanguageCollection = new cApiClientLanguageCollection();
219:         $clientLanguageCollection->query();
220: 
221:         while ($item = $clientLanguageCollection->next()) {
222:             $client = $item->getField('idclient');
223:             $lang = $item->getField('idlang');
224: 
225:             $oLanguage = new cApiLanguage();
226:             $oLanguage->loadByPrimaryKey($lang);
227: 
228:             $languageCode = $oLanguage->getProperty("language", "code", $client);
229:             $contryCode = $oLanguage->getProperty("country", "code", $client);
230: 
231:             $oClient = new cApiClient();
232:             $oClient->loadByPrimaryKey($client);
233:             $clientName = $oClient->getField('name');
234: 
235:             if (strlen($languageCode) == 0 || strlen($contryCode) == 0) {
236:                 $langName = $oLanguage->getField('name');
237: 
238:                 $oClient = new cApiClient();
239:                 $oClient->loadByPrimaryKey($client);
240: 
241:                 array_push($errors, sprintf(i18n('Language "%s" (%s) of the client "%s" (%s) is configured without ISO language code.', "setup"), $langName, $lang, $clientName, $client));
242:             }
243:         }
244: 
245:         if (count($errors) > 0) {
246:             $this->systemtest->storeResult(false, cSystemtest::C_SEVERITY_ERROR, i18n("The ISO codes are necessary to convert module translations.", "setup"), implode('<br/>', $errors));
247:         }
248:     }
249: 
250:     function initDB() {
251:         $this->systemtest->checkSetupMysql($_SESSION['setuptype'], $_SESSION['dbname'], $_SESSION['dbprefix']);
252:     }
253: 
254: }
CMS CONTENIDO 4.9.3 API documentation generated by ApiGen 2.8.0