| 1: | <?php
|
| 2: | |
| 3: | |
| 4: | |
| 5: | |
| 6: | |
| 7: | |
| 8: | |
| 9: |
|
| 10: |
|
| 11: | |
| 12: | |
| 13: | |
| 14: | |
| 15: | |
| 16: | |
| 17: |
|
| 18: | class Smarty_Internal_Resource_Extends extends Smarty_Resource
|
| 19: | {
|
| 20: | |
| 21: | |
| 22: | |
| 23: | |
| 24: |
|
| 25: | public $mbstring_overload = 0;
|
| 26: |
|
| 27: | |
| 28: | |
| 29: | |
| 30: | |
| 31: | |
| 32: | |
| 33: | |
| 34: |
|
| 35: | public function populate(Smarty_Template_Source $source, Smarty_Internal_Template $_template = null)
|
| 36: | {
|
| 37: | $uid = '';
|
| 38: | $sources = array();
|
| 39: | $components = explode('|', $source->name);
|
| 40: | $smarty = &$source->smarty;
|
| 41: | $exists = true;
|
| 42: | foreach ($components as $component) {
|
| 43: |
|
| 44: | $_s = Smarty_Template_Source::load(null, $smarty, $component);
|
| 45: | if ($_s->type === 'php') {
|
| 46: | throw new SmartyException("Resource type {$_s->type} cannot be used with the extends resource type");
|
| 47: | }
|
| 48: | $sources[ $_s->uid ] = $_s;
|
| 49: | $uid .= $_s->filepath;
|
| 50: | if ($_template) {
|
| 51: | $exists = $exists && $_s->exists;
|
| 52: | }
|
| 53: | }
|
| 54: | $source->components = $sources;
|
| 55: | $source->filepath = $_s->filepath;
|
| 56: | $source->uid = sha1($uid . $source->smarty->_joined_template_dir);
|
| 57: | $source->exists = $exists;
|
| 58: | if ($_template) {
|
| 59: | $source->timestamp = $_s->timestamp;
|
| 60: | }
|
| 61: | }
|
| 62: |
|
| 63: | |
| 64: | |
| 65: | |
| 66: | |
| 67: |
|
| 68: | public function populateTimestamp(Smarty_Template_Source $source)
|
| 69: | {
|
| 70: | $source->exists = true;
|
| 71: |
|
| 72: | foreach ($source->components as $_s) {
|
| 73: | $source->exists = $source->exists && $_s->exists;
|
| 74: | }
|
| 75: | $source->timestamp = $source->exists ? $_s->getTimeStamp() : false;
|
| 76: | }
|
| 77: |
|
| 78: | |
| 79: | |
| 80: | |
| 81: | |
| 82: | |
| 83: | |
| 84: | |
| 85: |
|
| 86: | public function getContent(Smarty_Template_Source $source)
|
| 87: | {
|
| 88: | if (!$source->exists) {
|
| 89: | throw new SmartyException("Unable to load template '{$source->type}:{$source->name}'");
|
| 90: | }
|
| 91: | $_components = array_reverse($source->components);
|
| 92: | $_content = '';
|
| 93: |
|
| 94: | foreach ($_components as $_s) {
|
| 95: |
|
| 96: | $_content .= $_s->getContent();
|
| 97: | }
|
| 98: | return $_content;
|
| 99: | }
|
| 100: |
|
| 101: | |
| 102: | |
| 103: | |
| 104: | |
| 105: | |
| 106: | |
| 107: |
|
| 108: | public function getBasename(Smarty_Template_Source $source)
|
| 109: | {
|
| 110: | return str_replace(':', '.', basename($source->filepath));
|
| 111: | }
|
| 112: |
|
| 113: | |
| 114: | |
| 115: | |
| 116: | |
| 117: | |
| 118: |
|
| 119: | |
| 120: | |
| 121: |
|
| 122: | public function checkTimestamps()
|
| 123: | {
|
| 124: | return false;
|
| 125: | }
|
| 126: | }
|
| 127: | |