コード例 #1
0
ファイル: tbs_class_php4.php プロジェクト: reggi49/plansys
 function meth_Merge_AutoSpe(&$Txt, &$Loc)
 {
     // Merge Special Var Fields ([var..*])
     $ErrMsg = false;
     $SubStart = false;
     if (isset($Loc->SubLst[1])) {
         switch ($Loc->SubLst[1]) {
             case 'now':
                 $x = time();
                 break;
             case 'version':
                 $x = $this->Version;
                 break;
             case 'script_name':
                 $x = basename(isset($_SERVER) ? $_SERVER['PHP_SELF'] : $GLOBALS['HTTP_SERVER_VARS']['PHP_SELF']);
                 break;
             case 'template_name':
                 $x = $this->_LastFile;
                 break;
             case 'template_date':
                 $x = '';
                 if ($this->f_Misc_GetFile($x, $this->_LastFile, '', array(), false)) {
                     $x = $x['mtime'];
                 }
                 break;
             case 'template_path':
                 $x = dirname($this->_LastFile) . '/';
                 break;
             case 'name':
                 $x = 'TinyButStrong';
                 break;
             case 'logo':
                 $x = '**TinyButStrong**';
                 break;
             case 'charset':
                 $x = $this->Charset;
                 break;
             case 'error_msg':
                 $this->_ErrMsgName = $Loc->FullName;
                 return $Loc->PosEnd;
                 break;
             case '':
                 $ErrMsg = 'it doesn\'t have any keyword.';
                 break;
             case 'tplvars':
                 if ($Loc->SubNbr == 2) {
                     $SubStart = 2;
                     $x = implode(',', array_keys($this->TplVars));
                     // list of all template variables
                 } else {
                     if (isset($this->TplVars[$Loc->SubLst[2]])) {
                         $SubStart = 3;
                         $x =& $this->TplVars[$Loc->SubLst[2]];
                     } else {
                         $ErrMsg = 'property TplVars doesn\'t have any item named \'' . $Loc->SubLst[2] . '\'.';
                     }
                 }
                 break;
             case 'store':
                 if ($Loc->SubNbr == 2) {
                     $SubStart = 2;
                     $x = implode('', $this->TplStore);
                     // concatenation of all stores
                 } else {
                     if (isset($this->TplStore[$Loc->SubLst[2]])) {
                         $SubStart = 3;
                         $x =& $this->TplStore[$Loc->SubLst[2]];
                     } else {
                         $ErrMsg = 'Store named \'' . $Loc->SubLst[2] . '\' is not defined yet.';
                     }
                 }
                 if (!isset($Loc->PrmLst['strconv'])) {
                     $Loc->PrmLst['strconv'] = 'no';
                     $Loc->PrmLst['protect'] = 'no';
                 }
                 break;
             case 'cst':
                 $x = @constant($Loc->SubLst[2]);
                 break;
             case 'tbs_info':
                 $x = 'TinyButStrong version ' . $this->Version . ' for PHP 4';
                 $x .= "\r\nInstalled plug-ins: " . count($this->_PlugIns);
                 foreach (array_keys($this->_PlugIns) as $pi) {
                     $o =& $this->_PlugIns[$pi];
                     $x .= "\r\n- plug-in [" . (isset($o->Name) ? $o->Name : $pi) . '] version ' . (isset($o->Version) ? $o->Version : '?');
                 }
                 break;
             case 'php_info':
                 ob_start();
                 phpinfo();
                 $x = ob_get_contents();
                 ob_end_clean();
                 $x = clsTinyButStrong::f_Xml_GetPart($x, '(style)+body', false);
                 if (!isset($Loc->PrmLst['strconv'])) {
                     $Loc->PrmLst['strconv'] = 'no';
                     $Loc->PrmLst['protect'] = 'no';
                 }
                 break;
             default:
                 $IsSupported = false;
                 if (isset($this->_piOnSpecialVar)) {
                     $x = '';
                     $ArgLst = array(substr($Loc->SubName, 1), &$IsSupported, &$x, &$Loc->PrmLst, &$Txt, &$Loc->PosBeg, &$Loc->PosEnd, &$Loc);
                     $this->meth_PlugIn_RunAll($this->_piOnSpecialVar, $ArgLst);
                 }
                 if (!$IsSupported) {
                     $ErrMsg = '\'' . $Loc->SubLst[1] . '\' is an unsupported keyword.';
                 }
         }
     } else {
         $ErrMsg = 'it doesn\'t have any subname.';
     }
     if ($ErrMsg !== false) {
         $this->meth_Misc_Alert($Loc, $ErrMsg);
         $x = '';
     }
     if ($Loc->PosBeg === false) {
         return $Loc->PosEnd;
     } else {
         return $this->meth_Locator_Replace($Txt, $Loc, $x, $SubStart);
     }
 }