Overview

Namespaces

  • MOC
    • Adapter
    • Core
      • Changelog
      • Depending
      • Drive
        • Directory
        • File
      • Error
        • Register
        • Type
      • Journal
      • Proxy
      • Template
      • Xml
    • Extension
      • Excel
      • Flot
      • Mail
      • Pdf
      • Word
      • Xml
      • YUICompressor
      • Zip
    • Generic
      • Common
      • Device
        • Extension
        • Widget
    • Module
      • Database
        • Driver
      • Drive
      • Image
        • Font
      • Installer
      • Network
        • Ftp
          • Directory
          • File
          • Transport
        • Http
        • ParcelTracker
          • Carrier
      • Office
        • Chart
          • Axis
        • Document
          • Excel
            • Cell
              • Format
              • Style
                • Border
                  • Bottom
                  • Left
                  • Right
                  • Top
                • Font
            • Close
            • Page
            • Worksheet
          • Pdf
            • Close
            • Font
            • Page
              • Margin
              • Position
            • Text
          • Xml
            • Close
        • Image
        • Mail
          • Address
          • Content
      • Packer
        • Yui
        • Zip
      • Template
    • Plugin
      • Gateway
      • Repository
      • Shared
  • PHP

Classes

  • Cache
  • Changelog
  • Depending
  • Drive
  • Encoding
  • Error
  • Journal
  • Proxy
  • Session
  • Template
  • Version
  • Xml
  • Overview
  • Namespace
  • Class
  • Tree
  • Deprecated
  • Todo
  • Download
  1: <?php
  2: /**
  3:  * LICENSE (BSD)
  4:  *
  5:  * Copyright (c) 2012, Gerd Christian Kunze
  6:  * All rights reserved.
  7:  *
  8:  * Redistribution and use in source and binary forms, with or without
  9:  * modification, are permitted provided that the following conditions are
 10:  * met:
 11:  *
 12:  *  * Redistributions of source code must retain the above copyright
 13:  *    notice, this list of conditions and the following disclaimer.
 14:  *
 15:  *  * Redistributions in binary form must reproduce the above copyright
 16:  *    notice, this list of conditions and the following disclaimer in the
 17:  *    documentation and/or other materials provided with the distribution.
 18:  *
 19:  *  * Neither the name of Gerd Christian Kunze nor the names of the
 20:  *    contributors may be used to endorse or promote products derived from
 21:  *    this software without specific prior written permission.
 22:  *
 23:  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
 24:  * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
 25:  * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
 26:  * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
 27:  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
 28:  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
 29:  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
 30:  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
 31:  * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
 32:  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
 33:  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 34:  *
 35:  * Template
 36:  * 28.12.2012 15:11
 37:  */
 38: namespace MOC\Core;
 39: use MOC\Api;
 40: use MOC\Generic\Device\Core;
 41: 
 42: /**
 43:  *
 44:  */
 45: class Template implements Core {
 46:     /**
 47:      * Get Changelog
 48:      *
 49:      * @static
 50:      * @return \MOC\Core\Changelog
 51:      */
 52:     public static function InterfaceChangelog() {
 53:         return Api::Core()->Changelog();
 54:     }
 55: 
 56:     /**
 57:      * Get Dependencies
 58:      *
 59:      * @static
 60:      * @return \MOC\Core\Depending
 61:      */
 62:     public static function InterfaceDepending() {
 63:         return Api::Core()->Depending();
 64:     }
 65: 
 66:     /**
 67:      * Get Singleton/Instance
 68:      *
 69:      * @static
 70:      * @return Template
 71:      */
 72:     public static function InterfaceInstance() {
 73:         return new Template();
 74:     }
 75: 
 76:     /** @var null|Template\Template $Template */
 77:     private $Template = null;
 78:     /** @var string $Content */
 79:     private $Content = '';
 80: 
 81:     /**
 82:      * @param Template\Template $Template
 83:      *
 84:      * @return Template
 85:      */
 86:     public function ApplyTemplate( Template\Template $Template ) {
 87:         $this->Template = $Template;
 88:         $this->Content = $this->Template->GetPayload();
 89:         return $this;
 90:     }
 91: 
 92:     /**
 93:      * @return Template\Template
 94:      */
 95:     public function CreateTemplate() {
 96:         return Template\Template::InterfaceInstance();
 97:     }
 98: 
 99:     /**
100:      * @param Template\Variable $Variable
101:      * @param $Limit
102:      *
103:      * @return Template
104:      */
105:     public function ApplyVariable( Template\Variable $Variable, $Limit = -1 ) {
106:         $this->Content = preg_replace(
107:             $Variable::REGEX_PATTERN_LEFT
108:                 .$Variable->GetIdentifier()
109:             .$Variable::REGEX_PATTERN_RIGHT,
110:             $Variable->GetPayload(),
111:             $this->Content,
112:             $Limit
113:         );
114:         return $this;
115:     }
116: 
117:     /**
118:      * @return Template\Variable
119:      */
120:     public function CreateVariable() {
121:         return Template\Variable::InterfaceInstance();
122:     }
123: 
124:     /**
125:      * @param Template\Import $Include
126:      * @param $Limit
127:      *
128:      * @return Template
129:      */
130:     public function ApplyImport( Template\Import $Include, $Limit = -1 ) {
131:         $this->Content = preg_replace(
132:             $Include::REGEX_PATTERN_LEFT
133:                 .$Include->GetIdentifier()
134:                 .$Include::REGEX_PATTERN_RIGHT,
135:             $Include->GetPayload(),
136:             $this->Content,
137:             $Limit
138:         );
139:         return $this;
140:     }
141: 
142:     /**
143:      * @return Template\Import
144:      */
145:     public function CreateImport() {
146:         return Template\Import::InterfaceInstance();
147:     }
148: 
149:     /**
150:      * @param Template\Complex $Complex
151:      * @param $Limit
152:      *
153:      * @return Template
154:      */
155:     public function ApplyComplex( Template\Complex $Complex, $Limit = -1 ) {
156:         $this->Content = preg_replace(
157:             $Complex::REGEX_PATTERN_LEFT
158:                 .$Complex->GetIdentifier()
159:                 .$Complex::REGEX_PATTERN_RIGHT,
160:             $Complex->GetPayload(),
161:             $this->Content,
162:             $Limit
163:         );
164:         return $this;
165:     }
166: 
167:     /**
168:      * @param bool $doCleanUp
169:      *
170:      * @return mixed|string
171:      */
172:     public function GetPayload( $doCleanUp = false ) {
173:         if( $doCleanUp ) {
174:             $this->Content = preg_replace(
175:                 Template\Complex::REGEX_PATTERN_LEFT.'.*?'
176:                     .Template\Complex::REGEX_PATTERN_RIGHT, '',
177:                 $this->Content
178:             );
179:             $this->Content = preg_replace(
180:                 Template\Variable::REGEX_PATTERN_LEFT.'.*?'
181:                     .Template\Variable::REGEX_PATTERN_RIGHT, '',
182:                 $this->Content
183:             );
184:             $this->Content = preg_replace(
185:                 Template\Import::REGEX_PATTERN_LEFT.'.*?'
186:                     .Template\Import::REGEX_PATTERN_RIGHT, '',
187:                 $this->Content
188:             );
189:         }
190:         return $this->Content;
191:     }
192: }
193: 
API documentation generated by ApiGen 2.8.0