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
    • NavigationMain
    • 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 2865 2012-08-13 07:47:27Z simon.sprankel $
 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:      * @return void
 49:      */
 50:     public function __construct() {
 51:         $this->_template = trim('
 52: <?php
 53: /**
 54:  {DESCRIPTION}
 55:  *
 56:  * @package    {PACKAGE}
 57:  * @subpackage {SUBPACKAGE}
 58:  * @version    {VERSION}
 59:  * @author     {AUTHOR}
 60:  * @copyright  {COPYRIGHT}
 61:  * @license    {LICENSE}
 62:  */
 63: 
 64: {CONTENT}
 65: ');
 66:         $this->_data = new stdClass();
 67:         $this->_data->content = '';
 68:         $this->_data->description = trim('
 69:  * Autoloader classmap file. Contains all available classes/interfaces and
 70:  * related class files.
 71:  *
 72:  * NOTES:
 73:  * - Don\'t edit this file manually!
 74:  * - It was generated by ' . __CLASS__ . '
 75:  * - Use ' . __CLASS__ . ' again, if you want to regenerate this file
 76:  *');
 77: 
 78:         $this->_data->package = __CLASS__;
 79:         $this->_data->subpackage = 'Classmap';
 80:         $this->_data->version = '0.1';
 81:         $this->_data->author = 'System';
 82:         $this->_data->copyright = 'Copyright (c) 2009-2010 Murat Purc (http://www.purc.de)';
 83:         $this->_data->license = 'http://www.gnu.org/licenses/gpl-2.0.html - GNU General Public License, version 2';
 84:     }
 85: 
 86:     /**
 87:      * Creates classmap file with passed data list
 88:      *
 89:      * @param array $data Assoziative list which contains class type tokens and
 90:      *        the related path to the class file.
 91:      * @param string $file Destination class map file
 92:      * @return void
 93:      */
 94:     public function create(array $data, $file) {
 95:         $this->_createClassMap($data);
 96: 
 97:         return (bool) file_put_contents($file, $this->_renderTemplate());
 98:     }
 99: 
100:     /**
101:      * Fills template replacement variable with generated assoziative PHP array
102:      *
103:      * @var array $data Assoziative list with class type tokens and files
104:      * @return void
105:      */
106:     protected function _createClassMap(array $data) {
107:         $classMapTpl = "\r\nreturn array(\r\n%s\r\n);\r\n";
108:         $classMapContent = '';
109:         foreach ($data as $classToken => $path) {
110:             $classMapContent .= sprintf("    '%s' => '%s',\r\n", addslashes($classToken), addslashes($path));
111:         }
112:         $classMapContent = substr($classMapContent, 0, -3);
113: 
114:         $this->_data->content .= sprintf($classMapTpl, $classMapContent);
115:     }
116: 
117:     /**
118:      * Replaces all wildcards in template with related template variables.
119:      *
120:      * @return string Replaced template
121:      */
122:     protected function _renderTemplate() {
123:         $template = $this->_template;
124:         foreach ($this->_data as $name => $value) {
125:             $template = str_replace('{' . strtoupper($name) . '}', $value, $template);
126:         }
127: 
128:         return $template;
129:     }
130: 
131: }
132: 
CMS CONTENIDO 4.9.0 API documentation generated by ApiGen 2.8.0