Overview

Packages

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

Classes

  • cUpgradeJob_0001
  • cUpgradeJob_0002
  • cUpgradeJob_0003
  • cUpgradeJob_0004
  • cUpgradeJob_0005
  • cUpgradeJob_0006
  • cUpgradeJob_0007
  • cUpgradeJob_0008
  • cUpgradeJob_0009
  • cUpgradeJob_0010
  • cUpgradeJob_0011
  • cUpgradeJob_0012
  • cUpgradeJob_0013
  • cUpgradeJob_0014
  • cUpgradeJob_0015
  • cUpgradeJob_0016
  • cUpgradeJob_0017
  • cUpgradeJob_0018
  • cUpgradeJobAbstract
  • cUpgradeJobMain
  • Overview
  • Package
  • Class
  • Tree
  • Deprecated
  • Todo
  1: <?php
  2: /**
  3:  * This file contains the upgrade job 2.
  4:  *
  5:  * @package Setup
  6:  * @subpackage UpgradeJob
  7:  * @author Murat Purc <murat@purc>
  8:  * @copyright four for business AG <www.4fb.de>
  9:  * @license http://www.contenido.org/license/LIZENZ.txt
 10:  * @link http://www.4fb.de
 11:  * @link http://www.contenido.org
 12:  */
 13: 
 14: defined('CON_FRAMEWORK') || die('Illegal call: Missing framework initialization - request aborted.');
 15: 
 16: global $cfg;
 17: checkAndInclude($cfg['path']['contenido'] . 'includes/functions.api.string.php');
 18: 
 19: /**
 20:  * Upgrade job 2.
 21:  * Runs the upgrade job to takeover new module concept.
 22:  *
 23:  * @package Setup
 24:  * @subpackage UpgradeJob
 25:  */
 26: class cUpgradeJob_0002 extends cUpgradeJobAbstract {
 27: 
 28:     public $maxVersion = "4.9.0-alpha1";
 29: 
 30:     /**
 31:      * This method will transfer the moduls from $cfg['tab']['mod'] to the
 32:      * file system.
 33:      * This Method will be called by setup
 34:      */
 35:     private function _convertModulesToFile($clientId) {
 36:         global $cfg;
 37: 
 38:         $db = getSetupMySQLDBConnection();
 39: 
 40:         $sql = sprintf("SELECT * FROM %s WHERE idclient='%s' ORDER BY idmod", $cfg['tab']['mod'], $clientId);
 41:         $db->query($sql);
 42: 
 43:         $moduleHandler = new cModuleHandler();
 44: 
 45:         while ($db->nextRecord()) {
 46:             // init the ModulHandler with all data of the modul
 47:             // inclusive client
 48:             $moduleHandler->initWithDatabaseRow($db);
 49: 
 50:             // make new module only if modul not exist in directory
 51:             if ($moduleHandler->modulePathExists() != true) {
 52:                 // we need no error handling here because module could still
 53:                 // exist from previous version
 54:                 if ($moduleHandler->createModule($db->f('input'), $db->f('output')) == true) {
 55:                     // save module translation
 56:                     $translations = new cModuleFileTranslation($db->f('idmod'));
 57:                     $translations->saveTranslations();
 58:                 }
 59:             }
 60:         }
 61: 
 62:         // update input and output fields
 63:         $sql = sprintf("UPDATE %s SET input = '', output = '' WHERE idclient='%s'", $cfg['tab']['mod'], $clientId);
 64:         $db->query($sql);
 65:     }
 66: 
 67:     public function _execute() {
 68:         global $cfg;
 69:         global $client, $lang, $cfgClient;
 70: 
 71:         if ($this->_setupType != 'upgrade') {
 72:             return;
 73:         }
 74: 
 75:         $sql = "SHOW COLUMNS FROM %s LIKE 'frontendpath'";
 76:         $sql = sprintf($sql, $cfg['tab']['clients']);
 77: 
 78:         $this->_oDb->query($sql);
 79:         if ($this->_oDb->numRows() != 0) {
 80:             $sql = "SELECT * FROM " . $cfg['tab']['clients'];
 81:             $this->_oDb->query($sql);
 82: 
 83:             while ($this->_oDb->nextRecord()) {
 84:                 updateClientCache($this->_oDb->f("idclient"), $this->_oDb->f("htmlpath"), $this->_oDb->f("frontendpath"));
 85:             }
 86: 
 87:             $sql = sprintf("ALTER TABLE %s DROP htmlpath", $cfg['tab']['clients']);
 88:             $this->_oDb->query($sql);
 89: 
 90:             $sql = sprintf("ALTER TABLE %s DROP frontendpath", $cfg['tab']['clients']);
 91:             $this->_oDb->query($sql);
 92:         }
 93: 
 94:         $cfgClient = updateClientCache();
 95: 
 96:         $clientBackup = $client;
 97:         $langBackup = $lang;
 98: 
 99:         $db2 = getSetupMySQLDBConnection();
100: 
101:         // Update module aliases
102:         $this->_oDb->query("SELECT * FROM `%s`", $cfg['tab']['mod']);
103:         while ($this->_oDb->nextRecord()) {
104:             $newName = cString::toLowerCase(cModuleHandler::getCleanName($this->_oDb->f('name')));
105:             $sql = $db2->prepare("UPDATE `%s` SET `alias` = '%s' WHERE `idmod` = %d", $cfg['tab']['mod'], $newName, $this->_oDb->f('idmod'));
106:             $db2->query($sql);
107:         }
108: 
109:         // Update layout aliases
110:         $this->_oDb->query("SELECT * FROM `%s`", $cfg['tab']['lay']);
111:         while ($this->_oDb->nextRecord()) {
112:             $newName = cModuleHandler::getCleanName(cString::toLowerCase($this->_oDb->f('name')));
113:             $sql = $db2->prepare("UPDATE `%s` SET `alias` = '%s' WHERE `idlay` = %d", $cfg['tab']['lay'], $newName, $this->_oDb->f('idlay'));
114:             $db2->query($sql);
115:         }
116: 
117:         // Makes the new concept of modules (save the modules to the file) save the translation
118:         foreach ($cfgClient as $iClient => $aClient) {
119:             if ((int) $iClient == 0) {
120:                 continue;
121:             }
122: 
123:             $client = $iClient; // this should work for all clients now
124: 
125:             // Save all modules from db-table to the filesystem if exists
126:             $this->_oDb->query("SHOW COLUMNS FROM `%s` LIKE 'output'", $cfg['tab']['mod']);
127:             if ($this->_oDb->numRows() > 0) {
128:                 $this->_convertModulesToFile($client);
129:             }
130: 
131:             // Save all layouts from db-table to the filesystem if exists
132:             $this->_oDb->query("SHOW COLUMNS FROM `%s` LIKE 'code'", $cfg['tab']['lay']);
133:             if ($this->_oDb->numRows() > 0) {
134:                 cLayoutHandler::upgrade($this->_oDb, $cfg, $client);
135:             }
136:         }
137: 
138:         $client = $clientBackup;
139:         $lang = $langBackup;
140:     }
141: }
142: 
CMS CONTENIDO 4.10.0 API documentation generated by ApiGen 2.8.0