Overview

Namespaces

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

Classes

  • ArrayIterator
  • DateInterval
  • DOMNode
  • Kotchasan
  • Kotchasan\Accordion
  • Kotchasan\ApiController
  • Kotchasan\ArrayTool
  • Kotchasan\Cache\ApcCache
  • Kotchasan\Cache\Cache
  • Kotchasan\Cache\CacheItem
  • Kotchasan\Cache\FileCache
  • Kotchasan\CKEditor
  • Kotchasan\Collection
  • Kotchasan\Config
  • Kotchasan\Controller
  • Kotchasan\Country
  • Kotchasan\Csv
  • Kotchasan\Curl
  • Kotchasan\Currency
  • Kotchasan\Database
  • Kotchasan\Database\Db
  • Kotchasan\Database\DbCache
  • Kotchasan\Database\Driver
  • Kotchasan\Database\PdoMysqlDriver
  • Kotchasan\Database\Query
  • Kotchasan\Database\QueryBuilder
  • Kotchasan\Database\Schema
  • Kotchasan\Database\Sql
  • Kotchasan\DataTable
  • Kotchasan\Date
  • Kotchasan\DOMNode
  • Kotchasan\DOMParser
  • Kotchasan\Email
  • Kotchasan\File
  • Kotchasan\Files
  • Kotchasan\Form
  • Kotchasan\Grid
  • Kotchasan\Html
  • Kotchasan\Htmldoc
  • Kotchasan\HtmlTable
  • Kotchasan\Http\AbstractMessage
  • Kotchasan\Http\AbstractRequest
  • Kotchasan\Http\Message
  • Kotchasan\Http\NotFound
  • Kotchasan\Http\Request
  • Kotchasan\Http\Response
  • Kotchasan\Http\Stream
  • Kotchasan\Http\UploadedFile
  • Kotchasan\Http\Uri
  • Kotchasan\Image
  • Kotchasan\InputItem
  • Kotchasan\Inputs
  • Kotchasan\KBase
  • Kotchasan\Language
  • Kotchasan\ListItem
  • Kotchasan\Log\AbstractLogger
  • Kotchasan\Log\Logger
  • Kotchasan\Login
  • Kotchasan\Menu
  • Kotchasan\Mime
  • Kotchasan\Model
  • Kotchasan\Number
  • Kotchasan\ObjectTool
  • Kotchasan\Orm\Field
  • Kotchasan\Orm\Recordset
  • Kotchasan\Password
  • Kotchasan\Pdf
  • Kotchasan\Province
  • Kotchasan\Router
  • Kotchasan\Session
  • Kotchasan\Singleton
  • Kotchasan\Tab
  • Kotchasan\TableRow
  • Kotchasan\Template
  • Kotchasan\Text
  • Kotchasan\Validator
  • Kotchasan\View
  • PHPMailer
  • Psr\Log\AbstractLogger
  • Psr\Log\LogLevel
  • Psr\Log\NullLogger
  • SMTP

Interfaces

  • ArrayAccess
  • Countable
  • DateTimeInterface
  • Iterator
  • IteratorAggregate
  • Psr\Cache\CacheItemInterface
  • Psr\Cache\CacheItemPoolInterface
  • Psr\Http\Message\MessageInterface
  • Psr\Http\Message\RequestInterface
  • Psr\Http\Message\ResponseInterface
  • Psr\Http\Message\ServerRequestInterface
  • Psr\Http\Message\StreamInterface
  • Psr\Http\Message\UploadedFileInterface
  • Psr\Http\Message\UriInterface
  • Psr\Log\LoggerAwareInterface
  • Psr\Log\LoggerInterface
  • SeekableIterator
  • Serializable
  • Traversable

Traits

  • Psr\Log\LoggerTrait

Exceptions

  • Exception
  • InvalidArgumentException
  • Kotchasan\ApiException
  • Kotchasan\Cache\Exception
  • Kotchasan\Database\Exception
  • Kotchasan\InputItemException
  • LogicException
  • phpmailerException
  • RuntimeException

Functions

  • createClass
  • debug
  • getClassPath
  • Overview
  • Namespace
  • Class
  • Tree
 1: <?php
 2: /**
 3:  * @filesource Kotchasan/Menu.php
 4:  *
 5:  * @copyright 2016 Goragod.com
 6:  * @license http://www.kotchasan.com/license/
 7:  *
 8:  * @see http://www.kotchasan.com/
 9:  */
10: 
11: namespace Kotchasan;
12: 
13: /**
14:  * คลาสสำหรับแสดงผลเมนูมาตรฐานของ Kotchasan.
15:  *
16:  * @author Goragod Wiriya <admin@goragod.com>
17:  *
18:  * @since 1.0
19:  */
20: class Menu
21: {
22:     /**
23:      * แสดงผลเมนู.
24:      *
25:      * @param array $items รายการเมนู
26:      *
27:      * @return string
28:      */
29:     public static function render($items, $select)
30:     {
31:         $menus = array();
32:         foreach ($items as $alias => $values) {
33:             if (isset($values['url'])) {
34:                 $menus[] = self::getItem($alias, $values, false, $select).'</li>';
35:             } elseif (isset($values['submenus'])) {
36:                 $menus[] = self::getItem($alias, $values, true, $select).'<ul>';
37:                 $menus[] = self::render($values['submenus'], $select);
38:                 $menus[] = '</ul>';
39:             }
40:         }
41: 
42:         return implode('', $menus);
43:     }
44: 
45:     /**
46:      * ฟังก์ชั่น แปลงเป็นรายการเมนู
47:      * คืนค่า HTML ของเมนู
48:      *
49:      * @param string|int $name   ชื่อเมนู
50:      * @param array      $item   แอเรย์ข้อมูลเมนู
51:      * @param bool       $arrow  true แสดงลูกศรสำหรับเมนูที่มีเมนูย่อย
52:      * @param string     $select ชื่อเมนูที่ถูกเลือก
53:      *
54:      * @return string
55:      */
56:     protected static function getItem($name, $item, $arrow, $select)
57:     {
58:         if (empty($name) && !is_int($name)) {
59:             $c = '';
60:         } else {
61:             $c = array($name);
62:             if ($name == $select) {
63:                 $c[] = 'select';
64:             }
65:             $c = ' class="'.implode(' ', $c).'"';
66:         }
67:         if (!empty($item['url'])) {
68:             $a = array('href="'.$item['url'].'"');
69:             if (!empty($item['target'])) {
70:                 $a[] = 'target="'.$item['target'].'"';
71:             }
72:         }
73:         if (!empty($item['text'])) {
74:             $a[] = 'title="'.$item['text'].'"';
75:         }
76:         $a = isset($a) ? ' '.implode(' ', $a) : '';
77:         if ($arrow) {
78:             return '<li'.$c.'><span class=menu-arrow'.$a.'><span>'.(empty($item['text']) ? '&nbsp;' : strip_tags(htmlspecialchars_decode($item['text']))).'</span></span>';
79:         } else {
80:             return '<li'.$c.'><a'.$a.'><span>'.(empty($item['text']) ? '&nbsp;' : strip_tags(htmlspecialchars_decode($item['text']))).'</span></a>';
81:         }
82:     }
83: }
84: 
Kotchasan API documentation generated by ApiGen