Overview

Namespaces

  • Kotchasan
    • Cache
    • Database
    • Http
    • Log
    • Orm
  • None
  • PHP
  • Psr
    • Cache
    • Http
      • Message
    • Log

Classes

  • Accordion
  • ApiController
  • ArrayTool
  • CKEditor
  • Collection
  • Config
  • Controller
  • Country
  • Csv
  • Curl
  • Currency
  • Database
  • DataTable
  • Date
  • DOMNode
  • DOMParser
  • Email
  • File
  • Files
  • Form
  • Grid
  • Html
  • Htmldoc
  • HtmlTable
  • Image
  • InputItem
  • Inputs
  • KBase
  • Language
  • ListItem
  • Login
  • Menu
  • Mime
  • Model
  • Number
  • ObjectTool
  • Password
  • Pdf
  • Province
  • Router
  • Session
  • Singleton
  • Tab
  • TableRow
  • Template
  • Text
  • Validator
  • View

Exceptions

  • ApiException
  • InputItemException
  • Overview
  • Namespace
  • Class
  • Tree

Class Template

Template engine.

Direct known subclasses

Kotchasan\Grid
Namespace: Kotchasan
Author: Goragod Wiriya admin@goragod.com
Since: 1.0
Located at Kotchasan/Template.php
Methods summary
public static
# add( array $array )

ฟังก์ชั่นกำหนดค่าตัวแปรของ template ฟังก์ชั่นนี้จะแทนที่ตัวแปรที่ส่งทั้งหมดลงใน template ทันที.

ฟังก์ชั่นกำหนดค่าตัวแปรของ template ฟังก์ชั่นนี้จะแทนที่ตัวแปรที่ส่งทั้งหมดลงใน template ทันที.

Parameters

$array
ชื่อที่ปรากฏใน template รูปแบบ array(key1=>val1,key2=>val2)

Returns

static
public static static
# create( string $owner, string $module, string $name )

โหลด template ครั้งแรกจะตรวจสอบไฟล์จาก module ถ้าไม่พบ จะใช้ไฟล์จาก owner.

โหลด template ครั้งแรกจะตรวจสอบไฟล์จาก module ถ้าไม่พบ จะใช้ไฟล์จาก owner.

Parameters

$owner
ชื่อโมดูลที่ติดตั้ง
$module
ชื่อโมดูล
$name
ชื่อ template ไม่ต้องระบุนามสกุลของไฟล์

Returns

static

Assert

('', '', 'FileNotFound')->isEmpty() [==] true
public static static
# createFromFile( string $filename )

โหลด template จากไฟล์.

โหลด template จากไฟล์.

Parameters

$filename

Returns

static

Throws

InvalidArgumentException
ถ้าไม่พบไฟล์

Assert

('FileNotFound') [throws] InvalidArgumentException
public static static
# createFromHTML( string $html )

สร้าง template จาก HTML.

สร้าง template จาก HTML.

Parameters

$html

Returns

static
public static string
# get( )

คืนค่าไดเร็คทอรี่ของ template ตั้งแต่ DOCUMENT_ROOT เช่น skin/default/.

คืนค่าไดเร็คทอรี่ของ template ตั้งแต่ DOCUMENT_ROOT เช่น skin/default/.

Returns

string
public boolean
# hasItem( )

ฟังก์ชั่นตรวจสอบว่ามีการ add ข้อมูลมาหรือเปล่า คืนค่า true ถ้ามีการเรียกใช้คำสั่ง add มาก่อนหน้า, หรือ false ถ้าไม่ใช่.

ฟังก์ชั่นตรวจสอบว่ามีการ add ข้อมูลมาหรือเปล่า คืนค่า true ถ้ามีการเรียกใช้คำสั่ง add มาก่อนหน้า, หรือ false ถ้าไม่ใช่.

Returns

boolean
public static
# init( string $skin )

กำหนด template ที่ต้องการ.

กำหนด template ที่ต้องการ.

Parameters

$skin
ไดเร็คทอรี่ของ template ตั้งแต่ DOCUMENT_ROOT ไม่ต้องมี / ปิดท้าย เช่น skin/default
public static
# insertHTML( string $html )

ฟังก์ชั่นใส่ HTML ลงใน template ตรงๆ ใช้สำหรับแทรก HTML ลงระหว่างแต่ละรายการ.

ฟังก์ชั่นใส่ HTML ลงใน template ตรงๆ ใช้สำหรับแทรก HTML ลงระหว่างแต่ละรายการ.

Parameters

$html
โค้ด HTML

Returns

static
public boolean
# isEmpty( )

ตรวจสอบว่ามีไฟล์ Template ถูกเลือกหรือไม่ คืนค่า true ถ้าไม่พบไฟล์ Template หรือ Template ว่างเปล่า, อื่นๆคืนค่า False.

ตรวจสอบว่ามีไฟล์ Template ถูกเลือกหรือไม่ คืนค่า true ถ้าไม่พบไฟล์ Template หรือ Template ว่างเปล่า, อื่นๆคืนค่า False.

Returns

boolean
public static string
# load( string $owner, string $module, string $name )

โหลด template ครั้งแรกจะตรวจสอบไฟล์จาก $module ถ้าไม่พบ จะใช้ไฟล์จาก $owner ถ้าไม่พบคืนค่าว่าง.

โหลด template ครั้งแรกจะตรวจสอบไฟล์จาก $module ถ้าไม่พบ จะใช้ไฟล์จาก $owner ถ้าไม่พบคืนค่าว่าง.

Parameters

$owner
ชื่อโมดูลที่ติดตั้ง
$module
ชื่อโมดูลที่ลงทะเบียน
$name
ชื่อ template ไม่ต้องระบุนามสกุลของไฟล์

Returns

string
public static string
# pregReplace( array $patt, array $replace, string $skin )

ฟังก์ชั่น preg_replace รองรับถึง PHP7.

ฟังก์ชั่น preg_replace รองรับถึง PHP7.

Parameters

$patt
คีย์ใน template
$replace
ข้อความที่จะถูกแทนที่ลงในคีย์
$skin
template

Returns

string

Assert

('/{TITLE}/', 'Title', '{TITLE}') [==] 'Title'
('/{LNG_([\w\s.-\'(),%\/:&#;]+)}/e', '\Kotchasan\Language::parse(array(1=>"$1"))', '{LNG_Language test}') [==] 'Language test'
public string
# render( )

คืนค่า HTML ถ้าไม่พบ template คืนค่าว่าง.

คืนค่า HTML ถ้าไม่พบ template คืนค่าว่าง.

Returns

string
Properties summary
protected integer $cols

จำนวนคอลัมน์ สำหรับการแสดงผลด้วย Grid.

จำนวนคอลัมน์ สำหรับการแสดงผลด้วย Grid.

# 0
protected array $items

แอเรย์ของข้อมูล.

แอเรย์ของข้อมูล.

#
protected integer $num

ตัวแปรสำหรับการขึ้นแถวใหม่ (Grid).

ตัวแปรสำหรับการขึ้นแถวใหม่ (Grid).

#
protected static string $src

ชื่อ template ที่กำลังใช้งานอยู่ รวมโฟลเดอร์ที่เก็บ template ด้วย นับแต่ DOCUMENT_ROOT เช่น skin/default/.

ชื่อ template ที่กำลังใช้งานอยู่ รวมโฟลเดอร์ที่เก็บ template ด้วย นับแต่ DOCUMENT_ROOT เช่น skin/default/.

#
Kotchasan API documentation generated by ApiGen