| 1: | <?php
|
| 2: | |
| 3: | |
| 4: | |
| 5: | |
| 6: | |
| 7: | |
| 8: | |
| 9: | |
| 10: | |
| 11: | |
| 12: | |
| 13: | |
| 14: | |
| 15: | |
| 16: | |
| 17: | |
| 18: | |
| 19: | |
| 20: | |
| 21: | |
| 22: | |
| 23: | |
| 24: | |
| 25: | |
| 26: | |
| 27: | |
| 28: | |
| 29: | |
| 30: |
|
| 31: | |
| 32: | |
| 33: | |
| 34: |
|
| 35: | if (!defined('SMARTY_DIR')) {
|
| 36: | |
| 37: | |
| 38: |
|
| 39: | define('SMARTY_DIR', dirname(__FILE__) . DIRECTORY_SEPARATOR);
|
| 40: | }
|
| 41: | |
| 42: | |
| 43: | |
| 44: |
|
| 45: | if (!defined('SMARTY_SYSPLUGINS_DIR')) {
|
| 46: | |
| 47: | |
| 48: |
|
| 49: | define('SMARTY_SYSPLUGINS_DIR', SMARTY_DIR . 'sysplugins' . DIRECTORY_SEPARATOR);
|
| 50: | }
|
| 51: | if (!defined('SMARTY_PLUGINS_DIR')) {
|
| 52: | |
| 53: | |
| 54: |
|
| 55: | define('SMARTY_PLUGINS_DIR', SMARTY_DIR . 'plugins' . DIRECTORY_SEPARATOR);
|
| 56: | }
|
| 57: | if (!defined('SMARTY_MBSTRING')) {
|
| 58: | |
| 59: | |
| 60: |
|
| 61: | define('SMARTY_MBSTRING', function_exists('mb_get_info'));
|
| 62: | }
|
| 63: | if (!defined('SMARTY_RESOURCE_CHAR_SET')) {
|
| 64: |
|
| 65: | |
| 66: | |
| 67: |
|
| 68: | define('SMARTY_RESOURCE_CHAR_SET', SMARTY_MBSTRING ? 'UTF-8' : 'ISO-8859-1');
|
| 69: | }
|
| 70: | if (!defined('SMARTY_RESOURCE_DATE_FORMAT')) {
|
| 71: | |
| 72: | |
| 73: |
|
| 74: | define('SMARTY_RESOURCE_DATE_FORMAT', '%b %e, %Y');
|
| 75: | }
|
| 76: | |
| 77: | |
| 78: |
|
| 79: | if (!class_exists('Smarty_Autoloader')) {
|
| 80: | include dirname(__FILE__) . '/bootstrap.php';
|
| 81: | }
|
| 82: | |
| 83: | |
| 84: |
|
| 85: | require_once SMARTY_SYSPLUGINS_DIR . 'smarty_internal_data.php';
|
| 86: | require_once SMARTY_SYSPLUGINS_DIR . 'smarty_internal_extension_handler.php';
|
| 87: | require_once SMARTY_SYSPLUGINS_DIR . 'smarty_internal_templatebase.php';
|
| 88: | require_once SMARTY_SYSPLUGINS_DIR . 'smarty_internal_template.php';
|
| 89: | require_once SMARTY_SYSPLUGINS_DIR . 'smarty_resource.php';
|
| 90: | require_once SMARTY_SYSPLUGINS_DIR . 'smarty_variable.php';
|
| 91: | require_once SMARTY_SYSPLUGINS_DIR . 'smarty_template_source.php';
|
| 92: | require_once SMARTY_SYSPLUGINS_DIR . 'smarty_template_resource_base.php';
|
| 93: | require_once SMARTY_SYSPLUGINS_DIR . 'smarty_internal_resource_file.php';
|
| 94: |
|
| 95: | |
| 96: | |
| 97: | |
| 98: | |
| 99: | |
| 100: | |
| 101: | |
| 102: | |
| 103: | |
| 104: | |
| 105: | |
| 106: | |
| 107: | |
| 108: |
|
| 109: | class Smarty extends Smarty_Internal_TemplateBase
|
| 110: | {
|
| 111: | |
| 112: | |
| 113: |
|
| 114: | const SMARTY_VERSION = '3.1.48';
|
| 115: | |
| 116: | |
| 117: |
|
| 118: | const SCOPE_LOCAL = 1;
|
| 119: | const SCOPE_PARENT = 2;
|
| 120: | const SCOPE_TPL_ROOT = 4;
|
| 121: | const SCOPE_ROOT = 8;
|
| 122: | const SCOPE_SMARTY = 16;
|
| 123: | const SCOPE_GLOBAL = 32;
|
| 124: | |
| 125: | |
| 126: |
|
| 127: | const CACHING_OFF = 0;
|
| 128: | const CACHING_LIFETIME_CURRENT = 1;
|
| 129: | const CACHING_LIFETIME_SAVED = 2;
|
| 130: | |
| 131: | |
| 132: |
|
| 133: | const CLEAR_EXPIRED = -1;
|
| 134: | |
| 135: | |
| 136: |
|
| 137: | const COMPILECHECK_OFF = 0;
|
| 138: | const COMPILECHECK_ON = 1;
|
| 139: | const COMPILECHECK_CACHEMISS = 2;
|
| 140: | |
| 141: | |
| 142: |
|
| 143: | const DEBUG_OFF = 0;
|
| 144: | const DEBUG_ON = 1;
|
| 145: | const DEBUG_INDIVIDUAL = 2;
|
| 146: | |
| 147: | |
| 148: |
|
| 149: | const PHP_PASSTHRU = 0;
|
| 150: | const PHP_QUOTE = 1;
|
| 151: | const PHP_REMOVE = 2;
|
| 152: | const PHP_ALLOW = 3;
|
| 153: | |
| 154: | |
| 155: |
|
| 156: | const FILTER_POST = 'post';
|
| 157: | const FILTER_PRE = 'pre';
|
| 158: | const FILTER_OUTPUT = 'output';
|
| 159: | const FILTER_VARIABLE = 'variable';
|
| 160: | |
| 161: | |
| 162: |
|
| 163: | const PLUGIN_FUNCTION = 'function';
|
| 164: | const PLUGIN_BLOCK = 'block';
|
| 165: | const PLUGIN_COMPILER = 'compiler';
|
| 166: | const PLUGIN_MODIFIER = 'modifier';
|
| 167: | const PLUGIN_MODIFIERCOMPILER = 'modifiercompiler';
|
| 168: |
|
| 169: | |
| 170: | |
| 171: |
|
| 172: | public static $global_tpl_vars = array();
|
| 173: |
|
| 174: | |
| 175: | |
| 176: |
|
| 177: | public static $_MBSTRING = SMARTY_MBSTRING;
|
| 178: |
|
| 179: | |
| 180: | |
| 181: |
|
| 182: | public static $_CHARSET = SMARTY_RESOURCE_CHAR_SET;
|
| 183: |
|
| 184: | |
| 185: | |
| 186: | |
| 187: |
|
| 188: | public static $_DATE_FORMAT = SMARTY_RESOURCE_DATE_FORMAT;
|
| 189: |
|
| 190: | |
| 191: | |
| 192: |
|
| 193: | public static $_UTF8_MODIFIER = 'u';
|
| 194: |
|
| 195: | |
| 196: | |
| 197: |
|
| 198: | public static $_IS_WINDOWS = false;
|
| 199: |
|
| 200: | |
| 201: | |
| 202: | |
| 203: | |
| 204: |
|
| 205: | public $auto_literal = true;
|
| 206: |
|
| 207: | |
| 208: | |
| 209: | |
| 210: | |
| 211: |
|
| 212: | public $error_unassigned = false;
|
| 213: |
|
| 214: | |
| 215: | |
| 216: | |
| 217: | |
| 218: |
|
| 219: | public $use_include_path = false;
|
| 220: |
|
| 221: | |
| 222: | |
| 223: | |
| 224: | |
| 225: |
|
| 226: | public $_templateDirNormalized = false;
|
| 227: |
|
| 228: | |
| 229: | |
| 230: | |
| 231: | |
| 232: |
|
| 233: | public $_joined_template_dir = null;
|
| 234: |
|
| 235: | |
| 236: | |
| 237: | |
| 238: | |
| 239: |
|
| 240: | public $_configDirNormalized = false;
|
| 241: |
|
| 242: | |
| 243: | |
| 244: | |
| 245: | |
| 246: |
|
| 247: | public $_joined_config_dir = null;
|
| 248: |
|
| 249: | |
| 250: | |
| 251: | |
| 252: | |
| 253: |
|
| 254: | public $default_template_handler_func = null;
|
| 255: |
|
| 256: | |
| 257: | |
| 258: | |
| 259: | |
| 260: |
|
| 261: | public $default_config_handler_func = null;
|
| 262: |
|
| 263: | |
| 264: | |
| 265: | |
| 266: | |
| 267: |
|
| 268: | public $default_plugin_handler_func = null;
|
| 269: |
|
| 270: | |
| 271: | |
| 272: | |
| 273: | |
| 274: |
|
| 275: | public $_compileDirNormalized = false;
|
| 276: |
|
| 277: | |
| 278: | |
| 279: | |
| 280: | |
| 281: |
|
| 282: | public $_pluginsDirNormalized = false;
|
| 283: |
|
| 284: | |
| 285: | |
| 286: | |
| 287: | |
| 288: |
|
| 289: | public $_cacheDirNormalized = false;
|
| 290: |
|
| 291: | |
| 292: | |
| 293: | |
| 294: | |
| 295: |
|
| 296: | public $force_compile = false;
|
| 297: |
|
| 298: | |
| 299: | |
| 300: | |
| 301: | |
| 302: |
|
| 303: | public $use_sub_dirs = false;
|
| 304: |
|
| 305: | |
| 306: | |
| 307: | |
| 308: | |
| 309: |
|
| 310: | public $allow_ambiguous_resources = false;
|
| 311: |
|
| 312: | |
| 313: | |
| 314: | |
| 315: | |
| 316: |
|
| 317: | public $merge_compiled_includes = false;
|
| 318: |
|
| 319: | |
| 320: | |
| 321: | |
| 322: | |
| 323: | |
| 324: | |
| 325: |
|
| 326: | public $extends_recursion = true;
|
| 327: |
|
| 328: | |
| 329: | |
| 330: | |
| 331: | |
| 332: |
|
| 333: | public $force_cache = false;
|
| 334: |
|
| 335: | |
| 336: | |
| 337: | |
| 338: | |
| 339: |
|
| 340: | public $left_delimiter = "{";
|
| 341: |
|
| 342: | |
| 343: | |
| 344: | |
| 345: | |
| 346: |
|
| 347: | public $right_delimiter = "}";
|
| 348: |
|
| 349: | |
| 350: | |
| 351: | |
| 352: | |
| 353: |
|
| 354: | public $literals = array();
|
| 355: |
|
| 356: | |
| 357: | |
| 358: | |
| 359: | |
| 360: | |
| 361: | |
| 362: |
|
| 363: | public $security_class = 'Smarty_Security';
|
| 364: |
|
| 365: | |
| 366: | |
| 367: | |
| 368: | |
| 369: |
|
| 370: | public $security_policy = null;
|
| 371: |
|
| 372: | |
| 373: | |
| 374: | |
| 375: | |
| 376: |
|
| 377: | public $php_handling = self::PHP_PASSTHRU;
|
| 378: |
|
| 379: | |
| 380: | |
| 381: | |
| 382: | |
| 383: |
|
| 384: | public $allow_php_templates = false;
|
| 385: |
|
| 386: | |
| 387: | |
| 388: | |
| 389: | |
| 390: | |
| 391: |
|
| 392: | public $debugging = false;
|
| 393: |
|
| 394: | |
| 395: | |
| 396: | |
| 397: | |
| 398: | |
| 399: | |
| 400: | |
| 401: | |
| 402: |
|
| 403: | public $debugging_ctrl = 'NONE';
|
| 404: |
|
| 405: | |
| 406: | |
| 407: | |
| 408: | |
| 409: | |
| 410: | |
| 411: |
|
| 412: | public $smarty_debug_id = 'SMARTY_DEBUG';
|
| 413: |
|
| 414: | |
| 415: | |
| 416: | |
| 417: | |
| 418: |
|
| 419: | public $debug_tpl = null;
|
| 420: |
|
| 421: | |
| 422: | |
| 423: | |
| 424: | |
| 425: |
|
| 426: | public $error_reporting = null;
|
| 427: |
|
| 428: | |
| 429: | |
| 430: | |
| 431: | |
| 432: |
|
| 433: | public $config_overwrite = true;
|
| 434: |
|
| 435: | |
| 436: | |
| 437: | |
| 438: | |
| 439: |
|
| 440: | public $config_booleanize = true;
|
| 441: |
|
| 442: | |
| 443: | |
| 444: | |
| 445: | |
| 446: |
|
| 447: | public $config_read_hidden = false;
|
| 448: |
|
| 449: | |
| 450: | |
| 451: | |
| 452: | |
| 453: |
|
| 454: | public $compile_locking = true;
|
| 455: |
|
| 456: | |
| 457: | |
| 458: | |
| 459: | |
| 460: |
|
| 461: | public $cache_locking = false;
|
| 462: |
|
| 463: | |
| 464: | |
| 465: | |
| 466: | |
| 467: |
|
| 468: | public $locking_timeout = 10;
|
| 469: |
|
| 470: | |
| 471: | |
| 472: | |
| 473: | |
| 474: | |
| 475: |
|
| 476: | public $default_resource_type = 'file';
|
| 477: |
|
| 478: | |
| 479: | |
| 480: | |
| 481: | |
| 482: | |
| 483: |
|
| 484: | public $caching_type = 'file';
|
| 485: |
|
| 486: | |
| 487: | |
| 488: | |
| 489: | |
| 490: |
|
| 491: | public $default_config_type = 'file';
|
| 492: |
|
| 493: | |
| 494: | |
| 495: | |
| 496: | |
| 497: |
|
| 498: | public $cache_modified_check = false;
|
| 499: |
|
| 500: | |
| 501: | |
| 502: | |
| 503: | |
| 504: |
|
| 505: | public $registered_plugins = array();
|
| 506: |
|
| 507: | |
| 508: | |
| 509: | |
| 510: | |
| 511: |
|
| 512: | public $registered_objects = array();
|
| 513: |
|
| 514: | |
| 515: | |
| 516: | |
| 517: | |
| 518: |
|
| 519: | public $registered_classes = array();
|
| 520: |
|
| 521: | |
| 522: | |
| 523: | |
| 524: | |
| 525: |
|
| 526: | public $registered_filters = array();
|
| 527: |
|
| 528: | |
| 529: | |
| 530: | |
| 531: | |
| 532: |
|
| 533: | public $registered_resources = array();
|
| 534: |
|
| 535: | |
| 536: | |
| 537: | |
| 538: | |
| 539: |
|
| 540: | public $registered_cache_resources = array();
|
| 541: |
|
| 542: | |
| 543: | |
| 544: | |
| 545: | |
| 546: |
|
| 547: | public $autoload_filters = array();
|
| 548: |
|
| 549: | |
| 550: | |
| 551: | |
| 552: | |
| 553: |
|
| 554: | public $default_modifiers = array();
|
| 555: |
|
| 556: | |
| 557: | |
| 558: | |
| 559: | |
| 560: |
|
| 561: | public $escape_html = false;
|
| 562: |
|
| 563: | |
| 564: | |
| 565: | |
| 566: | |
| 567: |
|
| 568: | public $start_time = 0;
|
| 569: |
|
| 570: | |
| 571: | |
| 572: | |
| 573: | |
| 574: |
|
| 575: | public $_current_file = null;
|
| 576: |
|
| 577: | |
| 578: | |
| 579: | |
| 580: | |
| 581: |
|
| 582: | public $_parserdebug = false;
|
| 583: |
|
| 584: | |
| 585: | |
| 586: | |
| 587: | |
| 588: |
|
| 589: | public $_objType = 1;
|
| 590: |
|
| 591: | |
| 592: | |
| 593: | |
| 594: | |
| 595: |
|
| 596: | public $_debug = null;
|
| 597: |
|
| 598: | |
| 599: | |
| 600: | |
| 601: | |
| 602: |
|
| 603: | protected $template_dir = array('./templates/');
|
| 604: |
|
| 605: | |
| 606: | |
| 607: | |
| 608: | |
| 609: |
|
| 610: | protected $_processedTemplateDir = array();
|
| 611: |
|
| 612: | |
| 613: | |
| 614: | |
| 615: | |
| 616: |
|
| 617: | protected $config_dir = array('./configs/');
|
| 618: |
|
| 619: | |
| 620: | |
| 621: | |
| 622: | |
| 623: |
|
| 624: | protected $_processedConfigDir = array();
|
| 625: |
|
| 626: | |
| 627: | |
| 628: | |
| 629: | |
| 630: |
|
| 631: | protected $compile_dir = './templates_c/';
|
| 632: |
|
| 633: | |
| 634: | |
| 635: | |
| 636: | |
| 637: |
|
| 638: | protected $plugins_dir = array();
|
| 639: |
|
| 640: | |
| 641: | |
| 642: | |
| 643: | |
| 644: |
|
| 645: | protected $cache_dir = './cache/';
|
| 646: |
|
| 647: | |
| 648: | |
| 649: | |
| 650: | |
| 651: |
|
| 652: | protected $obsoleteProperties = array(
|
| 653: | 'resource_caching', 'template_resource_caching', 'direct_access_security',
|
| 654: | '_dir_perms', '_file_perms', 'plugin_search_order',
|
| 655: | 'inheritance_merge_compiled_includes', 'resource_cache_mode',
|
| 656: | );
|
| 657: |
|
| 658: | |
| 659: | |
| 660: | |
| 661: | |
| 662: |
|
| 663: | protected $accessMap = array(
|
| 664: | 'template_dir' => 'TemplateDir', 'config_dir' => 'ConfigDir',
|
| 665: | 'plugins_dir' => 'PluginsDir', 'compile_dir' => 'CompileDir',
|
| 666: | 'cache_dir' => 'CacheDir',
|
| 667: | );
|
| 668: |
|
| 669: | |
| 670: | |
| 671: |
|
| 672: | public function __construct()
|
| 673: | {
|
| 674: | $this->_clearTemplateCache();
|
| 675: | parent::__construct();
|
| 676: | if (is_callable('mb_internal_encoding')) {
|
| 677: | mb_internal_encoding(Smarty::$_CHARSET);
|
| 678: | }
|
| 679: | $this->start_time = microtime(true);
|
| 680: | if (isset($_SERVER[ 'SCRIPT_NAME' ])) {
|
| 681: | Smarty::$global_tpl_vars[ 'SCRIPT_NAME' ] = new Smarty_Variable($_SERVER[ 'SCRIPT_NAME' ]);
|
| 682: | }
|
| 683: |
|
| 684: | Smarty::$_IS_WINDOWS = strtoupper(substr(PHP_OS, 0, 3)) === 'WIN';
|
| 685: |
|
| 686: | if (Smarty::$_CHARSET !== 'UTF-8') {
|
| 687: | Smarty::$_UTF8_MODIFIER = '';
|
| 688: | }
|
| 689: | }
|
| 690: |
|
| 691: | |
| 692: | |
| 693: | |
| 694: | |
| 695: | |
| 696: |
|
| 697: | public static function muteExpectedErrors()
|
| 698: | {
|
| 699: | return Smarty_Internal_ErrorHandler::muteExpectedErrors();
|
| 700: | }
|
| 701: |
|
| 702: | |
| 703: | |
| 704: | |
| 705: | |
| 706: |
|
| 707: | public static function unmuteExpectedErrors()
|
| 708: | {
|
| 709: | restore_error_handler();
|
| 710: | }
|
| 711: |
|
| 712: | |
| 713: | |
| 714: | |
| 715: | |
| 716: | |
| 717: | |
| 718: | |
| 719: |
|
| 720: | public function templateExists($resource_name)
|
| 721: | {
|
| 722: |
|
| 723: | $source = Smarty_Template_Source::load(null, $this, $resource_name);
|
| 724: | return $source->exists;
|
| 725: | }
|
| 726: |
|
| 727: | |
| 728: | |
| 729: | |
| 730: | |
| 731: | |
| 732: | |
| 733: | |
| 734: |
|
| 735: | public function enableSecurity($security_class = null)
|
| 736: | {
|
| 737: | Smarty_Security::enableSecurity($this, $security_class);
|
| 738: | return $this;
|
| 739: | }
|
| 740: |
|
| 741: | |
| 742: | |
| 743: | |
| 744: | |
| 745: |
|
| 746: | public function disableSecurity()
|
| 747: | {
|
| 748: | $this->security_policy = null;
|
| 749: | return $this;
|
| 750: | }
|
| 751: |
|
| 752: | |
| 753: | |
| 754: | |
| 755: | |
| 756: | |
| 757: | |
| 758: | |
| 759: | |
| 760: |
|
| 761: | public function addTemplateDir($template_dir, $key = null, $isConfig = false)
|
| 762: | {
|
| 763: | if ($isConfig) {
|
| 764: | $processed = &$this->_processedConfigDir;
|
| 765: | $dir = &$this->config_dir;
|
| 766: | $this->_configDirNormalized = false;
|
| 767: | } else {
|
| 768: | $processed = &$this->_processedTemplateDir;
|
| 769: | $dir = &$this->template_dir;
|
| 770: | $this->_templateDirNormalized = false;
|
| 771: | }
|
| 772: | if (is_array($template_dir)) {
|
| 773: | foreach ($template_dir as $k => $v) {
|
| 774: | if (is_int($k)) {
|
| 775: |
|
| 776: | $dir[] = $v;
|
| 777: | } else {
|
| 778: |
|
| 779: | $dir[ $k ] = $v;
|
| 780: | unset($processed[ $key ]);
|
| 781: | }
|
| 782: | }
|
| 783: | } else {
|
| 784: | if ($key !== null) {
|
| 785: |
|
| 786: | $dir[ $key ] = $template_dir;
|
| 787: | unset($processed[ $key ]);
|
| 788: | } else {
|
| 789: |
|
| 790: | $dir[] = $template_dir;
|
| 791: | }
|
| 792: | }
|
| 793: | return $this;
|
| 794: | }
|
| 795: |
|
| 796: | |
| 797: | |
| 798: | |
| 799: | |
| 800: | |
| 801: | |
| 802: | |
| 803: |
|
| 804: | public function getTemplateDir($index = null, $isConfig = false)
|
| 805: | {
|
| 806: | if ($isConfig) {
|
| 807: | $dir = &$this->config_dir;
|
| 808: | } else {
|
| 809: | $dir = &$this->template_dir;
|
| 810: | }
|
| 811: | if ($isConfig ? !$this->_configDirNormalized : !$this->_templateDirNormalized) {
|
| 812: | $this->_normalizeTemplateConfig($isConfig);
|
| 813: | }
|
| 814: | if ($index !== null) {
|
| 815: | return isset($dir[ $index ]) ? $dir[ $index ] : null;
|
| 816: | }
|
| 817: | return $dir;
|
| 818: | }
|
| 819: |
|
| 820: | |
| 821: | |
| 822: | |
| 823: | |
| 824: | |
| 825: | |
| 826: | |
| 827: |
|
| 828: | public function setTemplateDir($template_dir, $isConfig = false)
|
| 829: | {
|
| 830: | if ($isConfig) {
|
| 831: | $this->config_dir = array();
|
| 832: | $this->_processedConfigDir = array();
|
| 833: | } else {
|
| 834: | $this->template_dir = array();
|
| 835: | $this->_processedTemplateDir = array();
|
| 836: | }
|
| 837: | $this->addTemplateDir($template_dir, null, $isConfig);
|
| 838: | return $this;
|
| 839: | }
|
| 840: |
|
| 841: | |
| 842: | |
| 843: | |
| 844: | |
| 845: | |
| 846: | |
| 847: | |
| 848: |
|
| 849: | public function addConfigDir($config_dir, $key = null)
|
| 850: | {
|
| 851: | return $this->addTemplateDir($config_dir, $key, true);
|
| 852: | }
|
| 853: |
|
| 854: | |
| 855: | |
| 856: | |
| 857: | |
| 858: | |
| 859: | |
| 860: |
|
| 861: | public function getConfigDir($index = null)
|
| 862: | {
|
| 863: | return $this->getTemplateDir($index, true);
|
| 864: | }
|
| 865: |
|
| 866: | |
| 867: | |
| 868: | |
| 869: | |
| 870: | |
| 871: | |
| 872: |
|
| 873: | public function setConfigDir($config_dir)
|
| 874: | {
|
| 875: | return $this->setTemplateDir($config_dir, true);
|
| 876: | }
|
| 877: |
|
| 878: | |
| 879: | |
| 880: | |
| 881: | |
| 882: | |
| 883: | |
| 884: |
|
| 885: | public function addPluginsDir($plugins_dir)
|
| 886: | {
|
| 887: | if (empty($this->plugins_dir)) {
|
| 888: | $this->plugins_dir[] = SMARTY_PLUGINS_DIR;
|
| 889: | }
|
| 890: | $this->plugins_dir = array_merge($this->plugins_dir, (array)$plugins_dir);
|
| 891: | $this->_pluginsDirNormalized = false;
|
| 892: | return $this;
|
| 893: | }
|
| 894: |
|
| 895: | |
| 896: | |
| 897: | |
| 898: | |
| 899: |
|
| 900: | public function getPluginsDir()
|
| 901: | {
|
| 902: | if (empty($this->plugins_dir)) {
|
| 903: | $this->plugins_dir[] = SMARTY_PLUGINS_DIR;
|
| 904: | $this->_pluginsDirNormalized = false;
|
| 905: | }
|
| 906: | if (!$this->_pluginsDirNormalized) {
|
| 907: | if (!is_array($this->plugins_dir)) {
|
| 908: | $this->plugins_dir = (array)$this->plugins_dir;
|
| 909: | }
|
| 910: | foreach ($this->plugins_dir as $k => $v) {
|
| 911: | $this->plugins_dir[ $k ] = $this->_realpath(rtrim($v, '/\\') . DIRECTORY_SEPARATOR, true);
|
| 912: | }
|
| 913: | $this->_cache[ 'plugin_files' ] = array();
|
| 914: | $this->_pluginsDirNormalized = true;
|
| 915: | }
|
| 916: | return $this->plugins_dir;
|
| 917: | }
|
| 918: |
|
| 919: | |
| 920: | |
| 921: | |
| 922: | |
| 923: | |
| 924: | |
| 925: |
|
| 926: | public function setPluginsDir($plugins_dir)
|
| 927: | {
|
| 928: | $this->plugins_dir = (array)$plugins_dir;
|
| 929: | $this->_pluginsDirNormalized = false;
|
| 930: | return $this;
|
| 931: | }
|
| 932: |
|
| 933: | |
| 934: | |
| 935: | |
| 936: | |
| 937: |
|
| 938: | public function getCompileDir()
|
| 939: | {
|
| 940: | if (!$this->_compileDirNormalized) {
|
| 941: | $this->_normalizeDir('compile_dir', $this->compile_dir);
|
| 942: | $this->_compileDirNormalized = true;
|
| 943: | }
|
| 944: | return $this->compile_dir;
|
| 945: | }
|
| 946: |
|
| 947: | |
| 948: | |
| 949: | |
| 950: | |
| 951: | |
| 952: |
|
| 953: | public function setCompileDir($compile_dir)
|
| 954: | {
|
| 955: | $this->_normalizeDir('compile_dir', $compile_dir);
|
| 956: | $this->_compileDirNormalized = true;
|
| 957: | return $this;
|
| 958: | }
|
| 959: |
|
| 960: | |
| 961: | |
| 962: | |
| 963: | |
| 964: |
|
| 965: | public function getCacheDir()
|
| 966: | {
|
| 967: | if (!$this->_cacheDirNormalized) {
|
| 968: | $this->_normalizeDir('cache_dir', $this->cache_dir);
|
| 969: | $this->_cacheDirNormalized = true;
|
| 970: | }
|
| 971: | return $this->cache_dir;
|
| 972: | }
|
| 973: |
|
| 974: | |
| 975: | |
| 976: | |
| 977: | |
| 978: | |
| 979: | |
| 980: |
|
| 981: | public function setCacheDir($cache_dir)
|
| 982: | {
|
| 983: | $this->_normalizeDir('cache_dir', $cache_dir);
|
| 984: | $this->_cacheDirNormalized = true;
|
| 985: | return $this;
|
| 986: | }
|
| 987: |
|
| 988: | |
| 989: | |
| 990: | |
| 991: | |
| 992: | |
| 993: | |
| 994: | |
| 995: | |
| 996: | |
| 997: | |
| 998: | |
| 999: |
|
| 1000: | public function createTemplate($template, $cache_id = null, $compile_id = null, $parent = null, $do_clone = true)
|
| 1001: | {
|
| 1002: | if ($cache_id !== null && (is_object($cache_id) || is_array($cache_id))) {
|
| 1003: | $parent = $cache_id;
|
| 1004: | $cache_id = null;
|
| 1005: | }
|
| 1006: | if ($parent !== null && is_array($parent)) {
|
| 1007: | $data = $parent;
|
| 1008: | $parent = null;
|
| 1009: | } else {
|
| 1010: | $data = null;
|
| 1011: | }
|
| 1012: | if (!$this->_templateDirNormalized) {
|
| 1013: | $this->_normalizeTemplateConfig(false);
|
| 1014: | }
|
| 1015: | $_templateId = $this->_getTemplateId($template, $cache_id, $compile_id);
|
| 1016: | $tpl = null;
|
| 1017: | if ($this->caching && isset(Smarty_Internal_Template::$isCacheTplObj[ $_templateId ])) {
|
| 1018: | $tpl = $do_clone ? clone Smarty_Internal_Template::$isCacheTplObj[ $_templateId ] :
|
| 1019: | Smarty_Internal_Template::$isCacheTplObj[ $_templateId ];
|
| 1020: | $tpl->inheritance = null;
|
| 1021: | $tpl->tpl_vars = $tpl->config_vars = array();
|
| 1022: | } elseif (!$do_clone && isset(Smarty_Internal_Template::$tplObjCache[ $_templateId ])) {
|
| 1023: | $tpl = clone Smarty_Internal_Template::$tplObjCache[ $_templateId ];
|
| 1024: | $tpl->inheritance = null;
|
| 1025: | $tpl->tpl_vars = $tpl->config_vars = array();
|
| 1026: | } else {
|
| 1027: |
|
| 1028: | $tpl = new $this->template_class($template, $this, null, $cache_id, $compile_id, null, null);
|
| 1029: | $tpl->templateId = $_templateId;
|
| 1030: | }
|
| 1031: | if ($do_clone) {
|
| 1032: | $tpl->smarty = clone $tpl->smarty;
|
| 1033: | }
|
| 1034: | $tpl->parent = $parent ? $parent : $this;
|
| 1035: |
|
| 1036: | if (!empty($data) && is_array($data)) {
|
| 1037: |
|
| 1038: | foreach ($data as $_key => $_val) {
|
| 1039: | $tpl->tpl_vars[ $_key ] = new Smarty_Variable($_val);
|
| 1040: | }
|
| 1041: | }
|
| 1042: | if ($this->debugging || $this->debugging_ctrl === 'URL') {
|
| 1043: | $tpl->smarty->_debug = new Smarty_Internal_Debug();
|
| 1044: |
|
| 1045: | if (!$this->debugging && $this->debugging_ctrl === 'URL') {
|
| 1046: | $tpl->smarty->_debug->debugUrl($tpl->smarty);
|
| 1047: | }
|
| 1048: | }
|
| 1049: | return $tpl;
|
| 1050: | }
|
| 1051: |
|
| 1052: | |
| 1053: | |
| 1054: | |
| 1055: | |
| 1056: | |
| 1057: | |
| 1058: | |
| 1059: | |
| 1060: | |
| 1061: | |
| 1062: |
|
| 1063: | public function loadPlugin($plugin_name, $check = true)
|
| 1064: | {
|
| 1065: | return $this->ext->loadPlugin->loadPlugin($this, $plugin_name, $check);
|
| 1066: | }
|
| 1067: |
|
| 1068: | |
| 1069: | |
| 1070: | |
| 1071: | |
| 1072: | |
| 1073: | |
| 1074: | |
| 1075: | |
| 1076: | |
| 1077: | |
| 1078: | |
| 1079: |
|
| 1080: | public function _getTemplateId(
|
| 1081: | $template_name,
|
| 1082: | $cache_id = null,
|
| 1083: | $compile_id = null,
|
| 1084: | $caching = null,
|
| 1085: | Smarty_Internal_Template $template = null
|
| 1086: | ) {
|
| 1087: | $template_name = (strpos($template_name, ':') === false) ? "{$this->default_resource_type}:{$template_name}" :
|
| 1088: | $template_name;
|
| 1089: | $cache_id = $cache_id === null ? $this->cache_id : $cache_id;
|
| 1090: | $compile_id = $compile_id === null ? $this->compile_id : $compile_id;
|
| 1091: | $caching = (int)($caching === null ? $this->caching : $caching);
|
| 1092: | if ((isset($template) && strpos($template_name, ':.') !== false) || $this->allow_ambiguous_resources) {
|
| 1093: | $_templateId =
|
| 1094: | Smarty_Resource::getUniqueTemplateName((isset($template) ? $template : $this), $template_name) .
|
| 1095: | "#{$cache_id}#{$compile_id}#{$caching}";
|
| 1096: | } else {
|
| 1097: | $_templateId = $this->_joined_template_dir . "#{$template_name}#{$cache_id}#{$compile_id}#{$caching}";
|
| 1098: | }
|
| 1099: | if (isset($_templateId[ 150 ])) {
|
| 1100: | $_templateId = sha1($_templateId);
|
| 1101: | }
|
| 1102: | return $_templateId;
|
| 1103: | }
|
| 1104: |
|
| 1105: | |
| 1106: | |
| 1107: | |
| 1108: | |
| 1109: | |
| 1110: | |
| 1111: | |
| 1112: | |
| 1113: | |
| 1114: | |
| 1115: | |
| 1116: | |
| 1117: |
|
| 1118: | public function _realpath($path, $realpath = null)
|
| 1119: | {
|
| 1120: | $nds = array('/' => '\\', '\\' => '/');
|
| 1121: | preg_match(
|
| 1122: | '%^(?<root>(?:[[:alpha:]]:[\\\\/]|/|[\\\\]{2}[[:alpha:]]+|[[:print:]]{2,}:[/]{2}|[\\\\])?)(?<path>(.*))$%u',
|
| 1123: | $path,
|
| 1124: | $parts
|
| 1125: | );
|
| 1126: | $path = $parts[ 'path' ];
|
| 1127: | if ($parts[ 'root' ] === '\\') {
|
| 1128: | $parts[ 'root' ] = substr(getcwd(), 0, 2) . $parts[ 'root' ];
|
| 1129: | } else {
|
| 1130: | if ($realpath !== null && !$parts[ 'root' ]) {
|
| 1131: | $path = getcwd() . DIRECTORY_SEPARATOR . $path;
|
| 1132: | }
|
| 1133: | }
|
| 1134: |
|
| 1135: | $path = str_replace($nds[ DIRECTORY_SEPARATOR ], DIRECTORY_SEPARATOR, $path);
|
| 1136: | $parts[ 'root' ] = str_replace($nds[ DIRECTORY_SEPARATOR ], DIRECTORY_SEPARATOR, $parts[ 'root' ]);
|
| 1137: | do {
|
| 1138: | $path = preg_replace(
|
| 1139: | array('#[\\\\/]{2}#', '#[\\\\/][.][\\\\/]#', '#[\\\\/]([^\\\\/.]+)[\\\\/][.][.][\\\\/]#'),
|
| 1140: | DIRECTORY_SEPARATOR,
|
| 1141: | $path,
|
| 1142: | -1,
|
| 1143: | $count
|
| 1144: | );
|
| 1145: | } while ($count > 0);
|
| 1146: | return $realpath !== false ? $parts[ 'root' ] . $path : str_ireplace(getcwd(), '.', $parts[ 'root' ] . $path);
|
| 1147: | }
|
| 1148: |
|
| 1149: | |
| 1150: | |
| 1151: |
|
| 1152: | public function _clearTemplateCache()
|
| 1153: | {
|
| 1154: | Smarty_Internal_Template::$isCacheTplObj = array();
|
| 1155: | Smarty_Internal_Template::$tplObjCache = array();
|
| 1156: | }
|
| 1157: |
|
| 1158: | |
| 1159: | |
| 1160: |
|
| 1161: | public function setUseSubDirs($use_sub_dirs)
|
| 1162: | {
|
| 1163: | $this->use_sub_dirs = $use_sub_dirs;
|
| 1164: | }
|
| 1165: |
|
| 1166: | |
| 1167: | |
| 1168: |
|
| 1169: | public function setErrorReporting($error_reporting)
|
| 1170: | {
|
| 1171: | $this->error_reporting = $error_reporting;
|
| 1172: | }
|
| 1173: |
|
| 1174: | |
| 1175: | |
| 1176: |
|
| 1177: | public function setEscapeHtml($escape_html)
|
| 1178: | {
|
| 1179: | $this->escape_html = $escape_html;
|
| 1180: | }
|
| 1181: |
|
| 1182: | |
| 1183: | |
| 1184: | |
| 1185: | |
| 1186: |
|
| 1187: | public function getAutoLiteral()
|
| 1188: | {
|
| 1189: | return $this->auto_literal;
|
| 1190: | }
|
| 1191: |
|
| 1192: | |
| 1193: | |
| 1194: | |
| 1195: | |
| 1196: |
|
| 1197: | public function setAutoLiteral($auto_literal = true)
|
| 1198: | {
|
| 1199: | $this->auto_literal = $auto_literal;
|
| 1200: | }
|
| 1201: |
|
| 1202: | |
| 1203: | |
| 1204: |
|
| 1205: | public function setForceCompile($force_compile)
|
| 1206: | {
|
| 1207: | $this->force_compile = $force_compile;
|
| 1208: | }
|
| 1209: |
|
| 1210: | |
| 1211: | |
| 1212: |
|
| 1213: | public function setMergeCompiledIncludes($merge_compiled_includes)
|
| 1214: | {
|
| 1215: | $this->merge_compiled_includes = $merge_compiled_includes;
|
| 1216: | }
|
| 1217: |
|
| 1218: | |
| 1219: | |
| 1220: | |
| 1221: | |
| 1222: |
|
| 1223: | public function getLeftDelimiter()
|
| 1224: | {
|
| 1225: | return $this->left_delimiter;
|
| 1226: | }
|
| 1227: |
|
| 1228: | |
| 1229: | |
| 1230: | |
| 1231: | |
| 1232: |
|
| 1233: | public function setLeftDelimiter($left_delimiter)
|
| 1234: | {
|
| 1235: | $this->left_delimiter = $left_delimiter;
|
| 1236: | }
|
| 1237: |
|
| 1238: | |
| 1239: | |
| 1240: | |
| 1241: | |
| 1242: |
|
| 1243: | public function getRightDelimiter()
|
| 1244: | {
|
| 1245: | return $this->right_delimiter;
|
| 1246: | }
|
| 1247: |
|
| 1248: | |
| 1249: | |
| 1250: | |
| 1251: | |
| 1252: |
|
| 1253: | public function setRightDelimiter($right_delimiter)
|
| 1254: | {
|
| 1255: | $this->right_delimiter = $right_delimiter;
|
| 1256: | }
|
| 1257: |
|
| 1258: | |
| 1259: | |
| 1260: |
|
| 1261: | public function setDebugging($debugging)
|
| 1262: | {
|
| 1263: | $this->debugging = $debugging;
|
| 1264: | }
|
| 1265: |
|
| 1266: | |
| 1267: | |
| 1268: |
|
| 1269: | public function setConfigOverwrite($config_overwrite)
|
| 1270: | {
|
| 1271: | $this->config_overwrite = $config_overwrite;
|
| 1272: | }
|
| 1273: |
|
| 1274: | |
| 1275: | |
| 1276: |
|
| 1277: | public function setConfigBooleanize($config_booleanize)
|
| 1278: | {
|
| 1279: | $this->config_booleanize = $config_booleanize;
|
| 1280: | }
|
| 1281: |
|
| 1282: | |
| 1283: | |
| 1284: |
|
| 1285: | public function setConfigReadHidden($config_read_hidden)
|
| 1286: | {
|
| 1287: | $this->config_read_hidden = $config_read_hidden;
|
| 1288: | }
|
| 1289: |
|
| 1290: | |
| 1291: | |
| 1292: |
|
| 1293: | public function setCompileLocking($compile_locking)
|
| 1294: | {
|
| 1295: | $this->compile_locking = $compile_locking;
|
| 1296: | }
|
| 1297: |
|
| 1298: | |
| 1299: | |
| 1300: |
|
| 1301: | public function setDefaultResourceType($default_resource_type)
|
| 1302: | {
|
| 1303: | $this->default_resource_type = $default_resource_type;
|
| 1304: | }
|
| 1305: |
|
| 1306: | |
| 1307: | |
| 1308: |
|
| 1309: | public function setCachingType($caching_type)
|
| 1310: | {
|
| 1311: | $this->caching_type = $caching_type;
|
| 1312: | }
|
| 1313: |
|
| 1314: | |
| 1315: | |
| 1316: | |
| 1317: | |
| 1318: |
|
| 1319: | public function testInstall(&$errors = null)
|
| 1320: | {
|
| 1321: | Smarty_Internal_TestInstall::testInstall($this, $errors);
|
| 1322: | }
|
| 1323: |
|
| 1324: | |
| 1325: | |
| 1326: | |
| 1327: | |
| 1328: |
|
| 1329: | public function _getSmartyObj()
|
| 1330: | {
|
| 1331: | return $this;
|
| 1332: | }
|
| 1333: |
|
| 1334: | |
| 1335: | |
| 1336: | |
| 1337: | |
| 1338: | |
| 1339: | |
| 1340: | |
| 1341: | |
| 1342: |
|
| 1343: | public function __get($name)
|
| 1344: | {
|
| 1345: | if (isset($this->accessMap[ $name ])) {
|
| 1346: | $method = 'get' . $this->accessMap[ $name ];
|
| 1347: | return $this->{$method}();
|
| 1348: | } elseif (isset($this->_cache[ $name ])) {
|
| 1349: | return $this->_cache[ $name ];
|
| 1350: | } elseif (in_array($name, $this->obsoleteProperties)) {
|
| 1351: | return null;
|
| 1352: | } else {
|
| 1353: | trigger_error('Undefined property: ' . get_class($this) . '::$' . $name, E_USER_NOTICE);
|
| 1354: | }
|
| 1355: | return null;
|
| 1356: | }
|
| 1357: |
|
| 1358: | |
| 1359: | |
| 1360: | |
| 1361: | |
| 1362: | |
| 1363: | |
| 1364: | |
| 1365: | |
| 1366: |
|
| 1367: | public function __set($name, $value)
|
| 1368: | {
|
| 1369: | if (isset($this->accessMap[ $name ])) {
|
| 1370: | $method = 'set' . $this->accessMap[ $name ];
|
| 1371: | $this->{$method}($value);
|
| 1372: | } elseif (in_array($name, $this->obsoleteProperties)) {
|
| 1373: | return;
|
| 1374: | } elseif (is_object($value) && method_exists($value, $name)) {
|
| 1375: | $this->$name = $value;
|
| 1376: | } else {
|
| 1377: | trigger_error('Undefined property: ' . get_class($this) . '::$' . $name, E_USER_NOTICE);
|
| 1378: | }
|
| 1379: | }
|
| 1380: |
|
| 1381: | |
| 1382: | |
| 1383: | |
| 1384: | |
| 1385: | |
| 1386: |
|
| 1387: | private function _normalizeDir($dirName, $dir)
|
| 1388: | {
|
| 1389: | $this->{$dirName} = $this->_realpath(rtrim($dir, "/\\") . DIRECTORY_SEPARATOR, true);
|
| 1390: | if (class_exists('Smarty_Internal_ErrorHandler', false)) {
|
| 1391: | if (!isset(Smarty_Internal_ErrorHandler::$mutedDirectories[ $this->{$dirName} ])) {
|
| 1392: | Smarty_Internal_ErrorHandler::$mutedDirectories[ $this->{$dirName} ] = null;
|
| 1393: | }
|
| 1394: | }
|
| 1395: | }
|
| 1396: |
|
| 1397: | |
| 1398: | |
| 1399: | |
| 1400: | |
| 1401: |
|
| 1402: | private function _normalizeTemplateConfig($isConfig)
|
| 1403: | {
|
| 1404: | if ($isConfig) {
|
| 1405: | $processed = &$this->_processedConfigDir;
|
| 1406: | $dir = &$this->config_dir;
|
| 1407: | } else {
|
| 1408: | $processed = &$this->_processedTemplateDir;
|
| 1409: | $dir = &$this->template_dir;
|
| 1410: | }
|
| 1411: | if (!is_array($dir)) {
|
| 1412: | $dir = (array)$dir;
|
| 1413: | }
|
| 1414: | foreach ($dir as $k => $v) {
|
| 1415: | if (!isset($processed[ $k ])) {
|
| 1416: | $dir[ $k ] = $v = $this->_realpath(rtrim($v, "/\\") . DIRECTORY_SEPARATOR, true);
|
| 1417: | $processed[ $k ] = true;
|
| 1418: | }
|
| 1419: | }
|
| 1420: | $isConfig ? $this->_configDirNormalized = true : $this->_templateDirNormalized = true;
|
| 1421: | $isConfig ? $this->_joined_config_dir = join('#', $this->config_dir) :
|
| 1422: | $this->_joined_template_dir = join('#', $this->template_dir);
|
| 1423: | }
|
| 1424: | }
|
| 1425: | |