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

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