Example #1
0
 /**
  * Generated from @assert ('/{LNG_([\w\s\.\-\'\(\),%\/:&\#;]+)}/e', '\Kotchasan\Language::get(array(1=>"$1"))', '<b>{LNG_Language test}</b>') [==] '<b>Language test</b>'.
  *
  * @covers Kotchasan\Template::pregReplace
  */
 public function testPregReplace2()
 {
     $this->assertEquals('<b>Language test</b>', \Kotchasan\Template::pregReplace('/{LNG_([\\w\\s\\.\\-\'\\(\\),%\\/:&\\#;]+)}/e', '\\Kotchasan\\Language::get(array(1=>"$1"))', '<b>{LNG_Language test}</b>'));
 }
Example #2
0
 /**
  * ส่งออกเป็น HTML
  *
  * @param string|null $template HTML Template ถ้าไม่กำหนด (null) จะใช้ index.html
  */
 public function renderHTML($template = null)
 {
     // default for template
     if (!empty($this->metas)) {
         $this->contents['/(<head.*)(<\\/head>)/isu'] = '$1' . implode("\n", $this->metas) . "\n" . '$2';
     }
     $this->contents['/{LNG_([^}]+)}/e'] = '\\Kotchasan\\Language::get(array(1=>"$1"))';
     $this->contents['/{WEBTITLE}/'] = self::$cfg->web_title;
     $this->contents['/{WEBDESCRIPTION}/'] = self::$cfg->web_description;
     $this->contents['/{WEBURL}/'] = WEB_URL;
     $this->contents['/{SKIN}/'] = Template::$src;
     $this->contents['/{LANGUAGE}/'] = \Kotchasan\Language::name();
     $this->contents['/^[\\s\\t]+/m'] = '';
     foreach ($this->after_contents as $key => $value) {
         $this->contents[$key] = $value;
     }
     // แทนที่ลงใน Template
     if ($template === null) {
         // ถ้าไม่ได้กำหนดมาใช้ index.html
         $template = Template::load('', '', 'index');
     }
     return Template::pregReplace(array_keys($this->contents), array_values($this->contents), $template);
 }