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
    • ContentRssCreator
    • ContentSitemapHtml
    • ContentSitemapXml
    • ContentUserForum
    • NavigationTop
    • ScriptCookieDirective
  • 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

  • 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
  • cUpgradeJobAbstract
  • cUpgradeJobMain
  • Overview
  • Package
  • Class
  • Tree
  • Deprecated
  • Todo
  1: <?php
  2: /**
  3:  * This file contains the abstract upgrade job class.
  4:  *
  5:  * @package    Setup
  6:  * @subpackage UpgradeJob
  7:  * @author     Murat Purc <murat@purc.de>
  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: /**
 17:  * Abstract upgrade job class.
 18:  *
 19:  * @package Setup
 20:  * @subpackage UpgradeJob
 21:  */
 22: abstract class cUpgradeJobAbstract {
 23: 
 24:     /**
 25:      * @var cDb
 26:      */
 27:     protected $_oDb;
 28: 
 29:     /**
 30:      * @var array
 31:      */
 32:     protected $_aCfg;
 33: 
 34:     /**
 35:      * @var string
 36:      */
 37:     protected $_setupType;
 38: 
 39:     /**
 40:      * @var string
 41:      */
 42:     protected $_version;
 43: 
 44:     /**
 45:      * @var cApiClient[]
 46:      */
 47:     protected static $_clients;
 48: 
 49:     /**
 50:      * @var cApiLanguage[]
 51:      */
 52:     protected static $_languages;
 53: 
 54:     /**
 55:      * @var string
 56:      */
 57:     protected static $_rootPath;
 58: 
 59:     /**
 60:      * @var string
 61:      */
 62:     protected static $_rootHttpPath;
 63: 
 64:     /**
 65:      * This must be set. 0 means this upgrade job will be executed every time.
 66:      * Anyhting else should be a valid CONTENIDO version. Only if the upgraded version
 67:      * is older than this string the job will be executed.
 68:      *
 69:      * Setting this to '4.8.18' would mean that any version lower than 4.8.18 will get the upgrade job.
 70:      * @var string
 71:      */
 72:      public $maxVersion = "0";
 73: 
 74:     /**
 75:      * Constructor, sets some properties
 76:      * @param  cDb $db
 77:      * @param  array  $cfg  Main configuration array
 78:      * @param  array  $cfgClient  Clients configuration array
 79:      * @param  string $version The CONTENIDO version which is upgraded
 80:      */
 81:     public function __construct(cDb $db, $cfg, $cfgClient, $version) {
 82:         $this->_version = $version;
 83:         $this->_oDb = $db;
 84:         $this->_aCfg = (is_array($cfg)) ? $cfg : $GLOBALS['cfg'];
 85:         $this->_aCfgClient = (is_array($cfgClient)) ? $cfg : $GLOBALS['cfgClient'];
 86:         $this->_setupType = $_SESSION['setuptype'];
 87:         // set default configuration for DB connection
 88:         cDb::setDefaultConfiguration($cfg['db']);
 89: 
 90:         if (!isset(self::$_rootPath)) {
 91:             list($rootPath, $rootHttpPath) = getSystemDirectories();
 92:             self::$_rootPath = $rootPath;
 93:             self::$_rootHttpPath = $rootHttpPath;
 94:         }
 95: 
 96:         if (!isset(self::$_clients)) {
 97:             self::$_clients = $this->_getAllClients();
 98:         }
 99:         if (!isset(self::$_languages)) {
100:             self::$_languages = $this->_getAllLanguages();
101:         }
102:     }
103: 
104:     /**
105:      * This function will perform the version check and execute the job if it succeeds.
106:      *
107:      * Do not override this.
108:      */
109:     final public function execute() {
110:         if (version_compare($this->_version, $this->maxVersion, "<") || $this->maxVersion === "0") {
111:             $this->_execute();
112:         }
113:     }
114: 
115:     /**
116:      * Main function for each upgrade job. Each upgrade job has to implement this!
117:      */
118:     public abstract function _execute();
119: 
120:     /**
121:      * Returns list of all available clients
122:      * @return cApiClient[]
123:      */
124:     protected function _getAllClients() {
125:         $aClients = array();
126:         $oClientColl = new cApiClientCollection();
127:         $oClientColl->select();
128:         while (($oClient = $oClientColl->next()) !== false) {
129:             $obj = clone $oClient;
130:             $aClients[$obj->get('idclient')] = $obj;
131:         }
132:         return $aClients;
133:     }
134: 
135:     /**
136:      * Returns list of all available languages
137:      * @return cApiLanguage[]
138:      */
139:     protected function _getAllLanguages() {
140:         $aLanguages = array();
141:         $oLanguageColl = new cApiLanguageCollection();
142:         $oLanguageColl->select();
143:         while (($oLang = $oLanguageColl->next()) !== false) {
144:             $obj = clone $oLang;
145:             $aLanguages[$obj->get('idlang')] = $obj;
146:         }
147:         return $aLanguages;
148:     }
149: 
150:     /**
151:      * Logs passed setup error, wrapper for logSetupFailure() function
152:      * @param  string  $errorMsg
153:      */
154:     protected function _logError($errorMsg) {
155:         $className = get_class($this);
156:         logSetupFailure($className . ': ' . $errorMsg. "\n");
157:     }
158: }
159: 
CMS CONTENIDO 4.9.11 API documentation generated by ApiGen 2.8.0