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

  • mpClassMapFileCreator
  • mpClassMapFileCreatorContenido
  • mpClassTypeFinder
  • Overview
  • Package
  • Class
  • Tree
  • Deprecated
  • Todo
  1: <?php
  2: 
  3: /**
  4:  * Contains class to create a class map file.
  5:  *
  6:  * @category Development
  7:  * @package mpAutoloaderClassMap
  8:  * @author Murat Purc <murat@purc.de>
  9:  * @copyright Copyright (c) 2009-2010 Murat Purc (http://www.purc.de)
 10:  * @license http://www.gnu.org/licenses/gpl-2.0.html - GNU General Public
 11:  *          License, version 2
 12:  * @version $Id$
 13:  */
 14: 
 15: /**
 16:  * Class to create a PHP file which contains a assoziative PHP array.
 17:  *
 18:  * Generated file will contain a PHP array as following:
 19:  * <code>
 20:  * return array(
 21:  * '{classname}' => '{path_to_classfile}',
 22:  * '{classname2}' => '{path_to_classfile2}',
 23:  * );
 24:  * </code>
 25:  *
 26:  * @category Development
 27:  * @package mpAutoloaderClassMap
 28:  * @author Murat Purc <murat@purc.de>
 29:  */
 30: class mpClassMapFileCreator {
 31: 
 32:     /**
 33:      * Class map file template
 34:      *
 35:      * @var string
 36:      */
 37:     protected $_template = '';
 38: 
 39:     /**
 40:      * Template replacements
 41:      *
 42:      * @var stdClass
 43:      */
 44:     protected $_data = '';
 45: 
 46:     /**
 47:      * Sets template and template replacements
 48:      */
 49:     public function __construct() {
 50:         $this->_template = trim('
 51: <?php
 52: /**
 53:  {DESCRIPTION}
 54:  *
 55:  * @package    {PACKAGE}
 56:  * @subpackage {SUBPACKAGE}
 57:  * @version    {VERSION}
 58:  * @author     {AUTHOR}
 59:  * @copyright  {COPYRIGHT}
 60:  * @license    {LICENSE}
 61:  */
 62: 
 63: {CONTENT}
 64: ');
 65:         $this->_data = new stdClass();
 66:         $this->_data->content = '';
 67:         $this->_data->description = trim('
 68:  * Autoloader classmap file. Contains all available classes/interfaces and
 69:  * related class files.
 70:  *
 71:  * NOTES:
 72:  * - Don\'t edit this file manually!
 73:  * - It was generated by ' . __CLASS__ . '
 74:  * - Use ' . __CLASS__ . ' again, if you want to regenerate this file
 75:  *');
 76: 
 77:         $this->_data->package = __CLASS__;
 78:         $this->_data->subpackage = 'Classmap';
 79:         $this->_data->version = '0.1';
 80:         $this->_data->author = 'System';
 81:         $this->_data->copyright = 'Copyright (c) 2009-2010 Murat Purc (http://www.purc.de)';
 82:         $this->_data->license = 'http://www.gnu.org/licenses/gpl-2.0.html - GNU General Public License, version 2';
 83:     }
 84: 
 85:     /**
 86:      * Creates classmap file with passed data list
 87:      *
 88:      * @param array $data
 89:      *         Assoziative list which contains class type tokens
 90:      *         and the related path to the class file.
 91:      * @param string $file
 92:      *         Destination class map file
 93:      * @return bool
 94:      */
 95:     public function create(array $data, $file) {
 96:         $this->_createClassMap($data);
 97: 
 98:         return (bool) file_put_contents($file, $this->_renderTemplate());
 99:     }
100: 
101:     /**
102:      * Fills template replacement variable with generated assoziative PHP array
103:      *
104:      * @param array $data
105:      *         Assoziative list with class type tokens and files
106:      */
107:     protected function _createClassMap(array $data) {
108:         $classMapTpl = "\r\nreturn array(\r\n%s\r\n);\r\n";
109:         $classMapContent = '';
110:         foreach ($data as $classToken => $path) {
111:             $classMapContent .= sprintf("    '%s' => '%s',\r\n", addslashes($classToken), addslashes($path));
112:         }
113:         $classMapContent = substr($classMapContent, 0, -3);
114: 
115:         $this->_data->content .= sprintf($classMapTpl, $classMapContent);
116:     }
117: 
118:     /**
119:      * Replaces all wildcards in template with related template variables.
120:      *
121:      * @return string
122:      *         Replaced template
123:      */
124:     protected function _renderTemplate() {
125:         $template = $this->_template;
126:         foreach ($this->_data as $name => $value) {
127:             $template = str_replace('{' . strtoupper($name) . '}', $value, $template);
128:         }
129: 
130:         return $template;
131:     }
132: 
133: }
134: 
CMS CONTENIDO 4.9.11 API documentation generated by ApiGen 2.8.0