| 1: | <?php
|
| 2: |
|
| 3: | |
| 4: | |
| 5: | |
| 6: | |
| 7: | |
| 8: | |
| 9: | |
| 10: |
|
| 11: | class Smarty_Template_Source
|
| 12: | {
|
| 13: | |
| 14: | |
| 15: | |
| 16: | |
| 17: |
|
| 18: | public $uid = null;
|
| 19: |
|
| 20: | |
| 21: | |
| 22: | |
| 23: | |
| 24: |
|
| 25: | public $resource = null;
|
| 26: |
|
| 27: | |
| 28: | |
| 29: | |
| 30: | |
| 31: |
|
| 32: | public $type = null;
|
| 33: |
|
| 34: | |
| 35: | |
| 36: | |
| 37: | |
| 38: |
|
| 39: | public $name = null;
|
| 40: |
|
| 41: | |
| 42: | |
| 43: | |
| 44: | |
| 45: |
|
| 46: | public $filepath = null;
|
| 47: |
|
| 48: | |
| 49: | |
| 50: | |
| 51: | |
| 52: |
|
| 53: | public $timestamp = null;
|
| 54: |
|
| 55: | |
| 56: | |
| 57: | |
| 58: | |
| 59: |
|
| 60: | public $exists = false;
|
| 61: |
|
| 62: | |
| 63: | |
| 64: | |
| 65: | |
| 66: |
|
| 67: | public $basename = null;
|
| 68: |
|
| 69: | |
| 70: | |
| 71: | |
| 72: | |
| 73: |
|
| 74: | public $components = null;
|
| 75: |
|
| 76: | |
| 77: | |
| 78: | |
| 79: | |
| 80: |
|
| 81: | public $handler = null;
|
| 82: |
|
| 83: | |
| 84: | |
| 85: | |
| 86: | |
| 87: |
|
| 88: | public $smarty = null;
|
| 89: |
|
| 90: | |
| 91: | |
| 92: | |
| 93: | |
| 94: |
|
| 95: | public $isConfig = false;
|
| 96: |
|
| 97: | |
| 98: | |
| 99: | |
| 100: | |
| 101: |
|
| 102: | public $content = null;
|
| 103: |
|
| 104: | |
| 105: | |
| 106: | |
| 107: | |
| 108: |
|
| 109: | public $compiler_class = 'Smarty_Internal_SmartyTemplateCompiler';
|
| 110: |
|
| 111: | |
| 112: | |
| 113: | |
| 114: | |
| 115: |
|
| 116: | public $template_lexer_class = 'Smarty_Internal_Templatelexer';
|
| 117: |
|
| 118: | |
| 119: | |
| 120: | |
| 121: | |
| 122: |
|
| 123: | public $template_parser_class = 'Smarty_Internal_Templateparser';
|
| 124: |
|
| 125: | |
| 126: | |
| 127: | |
| 128: | |
| 129: | |
| 130: | |
| 131: | |
| 132: | |
| 133: | |
| 134: | |
| 135: |
|
| 136: | public function __construct(Smarty $smarty, $resource, $type, $name)
|
| 137: | {
|
| 138: | $this->handler =
|
| 139: | isset($smarty->_cache[ 'resource_handlers' ][ $type ]) ? $smarty->_cache[ 'resource_handlers' ][ $type ] :
|
| 140: | Smarty_Resource::load($smarty, $type);
|
| 141: | $this->smarty = $smarty;
|
| 142: | $this->resource = $resource;
|
| 143: | $this->type = $type;
|
| 144: | $this->name = $name;
|
| 145: | }
|
| 146: |
|
| 147: | |
| 148: | |
| 149: | |
| 150: | |
| 151: | |
| 152: | |
| 153: | |
| 154: | |
| 155: | |
| 156: | |
| 157: |
|
| 158: | public static function load(
|
| 159: | Smarty_Internal_Template $_template = null,
|
| 160: | Smarty $smarty = null,
|
| 161: | $template_resource = null
|
| 162: | ) {
|
| 163: | if ($_template) {
|
| 164: | $smarty = $_template->smarty;
|
| 165: | $template_resource = $_template->template_resource;
|
| 166: | }
|
| 167: | if (empty($template_resource)) {
|
| 168: | throw new SmartyException('Source: Missing name');
|
| 169: | }
|
| 170: |
|
| 171: | if (preg_match('/^([A-Za-z0-9_\-]{2,})[:]([\s\S]*)$/', $template_resource, $match)) {
|
| 172: | $type = $match[ 1 ];
|
| 173: | $name = $match[ 2 ];
|
| 174: | } else {
|
| 175: |
|
| 176: |
|
| 177: | $type = $smarty->default_resource_type;
|
| 178: | $name = $template_resource;
|
| 179: | }
|
| 180: |
|
| 181: | $source = new Smarty_Template_Source($smarty, $template_resource, $type, $name);
|
| 182: | $source->handler->populate($source, $_template);
|
| 183: | if (!$source->exists && isset($_template->smarty->default_template_handler_func)) {
|
| 184: | Smarty_Internal_Method_RegisterDefaultTemplateHandler::_getDefaultTemplate($source);
|
| 185: | $source->handler->populate($source, $_template);
|
| 186: | }
|
| 187: | return $source;
|
| 188: | }
|
| 189: |
|
| 190: | |
| 191: | |
| 192: | |
| 193: | |
| 194: |
|
| 195: | public function getTimeStamp()
|
| 196: | {
|
| 197: | if (!isset($this->timestamp)) {
|
| 198: | $this->handler->populateTimestamp($this);
|
| 199: | }
|
| 200: | return $this->timestamp;
|
| 201: | }
|
| 202: |
|
| 203: | |
| 204: | |
| 205: | |
| 206: | |
| 207: | |
| 208: |
|
| 209: | public function getContent()
|
| 210: | {
|
| 211: | return isset($this->content) ? $this->content : $this->handler->getContent($this);
|
| 212: | }
|
| 213: | }
|
| 214: | |