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

  • PimPlugin
  • PimPluginArchiveExtractor
  • PimPluginCollection
  • PimPluginRelations
  • PimPluginRelationsCollection
  • PimPluginSetup
  • PimPluginSetupInstall
  • PimPluginSetupStatus
  • PimPluginSetupUninstall
  • PimPluginSetupUpdate
  • Overview
  • Package
  • Class
  • Tree
  • Deprecated
  • Todo
  1: <?php
  2: /**
  3:  * This file contains Plugin Manager class.
  4:  *
  5:  * @package Plugin
  6:  * @subpackage PluginManager
  7:  * @version SVN Revision $Rev:$
  8:  *
  9:  * @author Frederic Schneider
 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: 
 16: defined('CON_FRAMEWORK') || die('Illegal call: Missing framework initialization - request aborted.');
 17: 
 18: /**
 19:  * Plugin Manager recipient class.
 20:  *
 21:  * @package     Plugin
 22:  * @subpackage  PluginManager
 23:  * @author Frederic Schneider
 24:  */
 25: class PimPluginCollection extends ItemCollection {
 26: 
 27:     /**
 28:      * Constructor Function
 29:      *
 30:      * @param none
 31:      */
 32:     public function __construct() {
 33:         global $cfg;
 34:         parent::__construct($cfg['tab']['plugins'], 'idplugin');
 35:         $this->_setItemClass('PimPlugin');
 36:     }
 37: 
 38:     /**
 39:      * Create a new plugin
 40:      *
 41:      * @param none
 42:      */
 43:     public function create($name, $description, $author, $copyright, $mail, $website, $version, $foldername, $uuId, $active, $execOrder = 0) {
 44:         global $client;
 45: 
 46:         $nextId = $this->_getNextId();
 47: 
 48:         // security checks
 49:         $client = cSecurity::toInteger($client);
 50:         $name = cSecurity::escapeString($name);
 51:         $description = cSecurity::escapeString($description);
 52:         $author = cSecurity::escapeString($author);
 53:         $copyright = cSecurity::escapeString($copyright);
 54:         $mail = cSecurity::escapeString($mail);
 55:         $website = cSecurity::escapeString($website);
 56:         $version = cSecurity::escapeString($version);
 57:         $foldername = cSecurity::escapeString($foldername);
 58:         $uuId = cSecurity::escapeString($uuId);
 59:         $active = cSecurity::toInteger($active);
 60: 
 61:         // create a new entry
 62:         $item = parent::createNewItem($nextId);
 63:         $item->set('idclient', $client);
 64:         $item->set('name', $name);
 65:         $item->set('description', $description);
 66:         $item->set('author', $author);
 67:         $item->set('copyright', $copyright);
 68:         $item->set('mail', $mail);
 69:         $item->set('website', $website);
 70:         $item->set('version', $version);
 71:         $item->set('folder', $foldername);
 72:         $item->set('uuid', $uuId);
 73:         $item->set('installed', date("Y-m-d H:i:s"), false);
 74:         $item->set('active', $active);
 75: 
 76:         // set execution order to the last of the list or to what was specified in create
 77:         if ($execOrder == 0) {
 78:             $this->select();
 79:             $execOrder = $this->count();
 80:         }
 81:         $item->set("executionorder", $execOrder);
 82: 
 83:         $item->store();
 84: 
 85:         return $item;
 86:     }
 87: 
 88:     /**
 89:      * Get the next id in table *_plugins
 90:      *
 91:      * @access protected
 92:      * @return int
 93:      */
 94:     protected function _getNextId() {
 95:         global $cfg;
 96: 
 97:         $sql = 'SELECT MAX(idplugin) AS id FROM ' . $cfg['tab']['plugins'];
 98:         $this->db->query($sql);
 99: 
100:         if ($this->db->nextRecord()) {
101: 
102:             $result = $this->db->f('id');
103: 
104:             // id must be over 10.000
105:             if ($result < 10000) {
106:                 $result = 10000;
107:             }
108: 
109:             // add ten
110:             $result = $result + 10;
111: 
112:             // removed the last number
113:             $result = substr($result, 0, strlen($result) - 1);
114: 
115:             // last number is always zero
116:             return cSecurity::toInteger($result . 0);
117:         }
118:     }
119: 
120: }
121: 
122: /**
123:  * Single Plugin Manager Item
124:  */
125: class PimPlugin extends Item {
126: 
127:     /**
128:      *
129:      * @var string Error storage
130:      * @access private
131:      */
132:     protected $_error;
133: 
134:     /**
135:      * Constructor Function
136:      *
137:      * @param $id mixed Specifies the id of item to load
138:      */
139:     public function __construct($id = false) {
140:         global $cfg;
141:         parent::__construct($cfg['tab']['plugins'], 'idplugin');
142:         $this->_error = '';
143:         if ($id !== false) {
144:             $this->loadByPrimaryKey($id);
145:         }
146:     }
147: 
148:     /**
149:      * Change the execution order of this plugin and update the order for every other plugin
150:      *
151:      * @param int $newOrder New execution order for this plugin
152:      */
153:     public function updateExecOrder($newOrder) {
154:         $oldOrder = $this->get('executionorder'); // get the old value
155:         $idplugin = $this->get("idplugin");
156: 
157:         $this->set('executionorder', $newOrder); // update this plugin to the new value
158:         $this->store();
159: 
160:         // move the other plugins up or down
161:         $pluginColl = new PimPluginCollection();
162:         $pluginColl->select('executionorder >= "' . min($newOrder, $oldOrder) . '" AND executionorder <= "' . max($newOrder, $oldOrder) . '" AND idplugin != "' . $idplugin . '"', NULL, 'executionorder'); // select every plugin that needs to be updated
163: 
164:         while ($plugin = $pluginColl->next()) {
165:             if ($newOrder < $oldOrder) {
166:                 $plugin->set("executionorder", $plugin->get("executionorder") + 1); // increment the execution order after we moved the plugin up
167:                 $plugin->store();
168:             } else if ($oldOrder < $newOrder) {
169:                 $plugin->set("executionorder", $plugin->get("executionorder") - 1); // decrement the execution value after we moved the plugin down
170:                 $plugin->store();
171:             }
172:         }
173:     }
174: }
175: 
CMS CONTENIDO 4.9.1 API documentation generated by ApiGen 2.8.0