Exemplo n.º 1
0
 /**
  * Class constructor
  */
 public function __construct()
 {
     $request_uri = explode('?', rawurldecode($_SERVER['REQUEST_URI']));
     // query จาก URL ที่ส่งมา
     $modules = $_GET;
     unset($_GET);
     // แยก path
     Router::parseRoutes($request_uri[0], $modules);
     if (!empty($modules['return']) && is_file(APP_PATH . 'modules/controllers/' . strtolower($modules['return']) . 'controller.php')) {
         // เรียก controller ที่กำหนดเอง
         $Controller = Gcms::createClass(ucfirst($modules['return']) . '\\Controller');
     } else {
         // เรียก site controller
         $Controller = Gcms::createClass('Site\\Controller');
     }
     $Controller->inint($modules);
 }
Exemplo n.º 2
0
 /**
  * ฟังก์ชั่น แปลงเป็นรายการเมนู
  *
  * @param array $item แอเรย์ข้อมูลเมนู
  * @param boolean $arrow (optional) true=แสดงลูกศรสำหรับเมนูที่มีเมนูย่อย (default false)
  * @return string คืนค่า HTML ของเมนู
  */
 public function getItem($item, $arrow = false)
 {
     $c = array();
     if ($item['alias'] != '') {
         $c[] = $item['alias'];
     } elseif ($item['module'] != '') {
         $c[] = $item['module'];
     }
     if (isset($item['published'])) {
         if ($item['published'] != 1) {
             if (Gcms::isMember()) {
                 if ($item['published'] == '3') {
                     $c[] = 'hidden';
                 }
             } else {
                 if ($item['published'] == '2') {
                     $c[] = 'hidden';
                 }
             }
         }
     }
     $c = sizeof($c) == 0 ? '' : ' class="' . implode(' ', $c) . '"';
     if ($item['index_id'] > 0 || $item['menu_url'] != '') {
         $a = $item['menu_target'] == '' ? '' : ' target=' . $item['menu_target'];
         $a .= $item['accesskey'] == '' ? '' : ' accesskey=' . $item['accesskey'];
         if ($item['index_id'] > 0) {
             $a .= ' href="' . \Core\Url::createUrl($item['module']) . '"';
         } elseif ($item['menu_url'] != '') {
             $a .= ' href="' . $item['menu_url'] . '"';
         } else {
             $a .= ' tabindex=0';
         }
     } else {
         $a = ' tabindex=0';
     }
     $b = $item['menu_tooltip'] == '' ? $item['menu_text'] : $item['menu_tooltip'];
     if ($b != '') {
         $a .= ' title="' . $b . '"';
     }
     if ($arrow) {
         return '<li' . $c . '><a class=menu-arrow' . $a . '><span>' . ($item['menu_text'] == '' ? '&nbsp;' : htmlspecialchars_decode($item['menu_text'])) . '</span></a>';
     } else {
         return '<li' . $c . '><a' . $a . '><span>' . ($item['menu_text'] == '' ? '&nbsp;' : htmlspecialchars_decode($item['menu_text'])) . '</span></a>';
     }
 }
Exemplo n.º 3
0
 /**
  * แก้ไขข้อมูล.
  *
  * @param string $table ชื่อตาราง
  * @param array|string $idArr id ที่ต้องการแก้ไข หรือข้อความค้นหารูปแอเรย์ [filed=>value]
  * @param array $recArr ข้อมูลที่ต้องการบันทึก
  *
  * @return bool สำเร็จ คืนค่า true
  */
 public function edit($table, $idArr, $recArr)
 {
     try {
         $keys = array();
         $values = array();
         foreach ($recArr as $key => $value) {
             $keys[] = "`{$key}`=:{$key}";
             $values[":{$key}"] = $value;
         }
         if (is_array($idArr)) {
             $datas = array();
             foreach ($idArr as $key => $value) {
                 $datas[] = "`{$key}`=:{$key}";
                 $values[":{$key}"] = $value;
             }
             $where = sizeof($datas) == 0 ? '' : implode(' AND ', $datas);
         } else {
             $id = (int) $idArr;
             $where = $id == 0 ? '' : '`id`=:id';
             $values[':id'] = $id;
         }
         if ($where == '' || sizeof($keys) == 0) {
             return false;
         } else {
             $sql = "UPDATE `{$table}` SET " . implode(',', $keys) . " WHERE {$where} LIMIT 1";
             $query = $this->connection->prepare($sql);
             $query->execute($values);
             ++$this->time;
             return true;
         }
     } catch (PDOException $e) {
         Gcms::debug($e->getMessage());
         return false;
     }
 }
Exemplo n.º 4
0
 /**
  * แก้ไขข้อมูล.
  *
  * @param string $table ชื่อตาราง
  * @param array|string $idArr id ที่ต้องการแก้ไข หรือข้อความค้นหารูปแอเรย์ [filed=>value]
  * @param array $recArr ข้อมูลที่ต้องการบันทึก
  *
  * @return bool สำเร็จ คืนค่า true
  */
 public function edit($table, $idArr, $recArr)
 {
     if (is_array($idArr)) {
         $datas = array();
         foreach ($idArr as $key => $value) {
             $datas[] = "`{$key}`='{$value}'";
         }
         $id = implode(' AND ', $datas);
     } else {
         $id = (int) $idArr;
         $id = $id == 0 ? '' : "`id`='{$id}'";
     }
     if ($id == '') {
         return false;
     } else {
         $datas = array();
         foreach ($recArr as $key => $value) {
             $datas[] = "`{$key}`='{$value}'";
         }
         $sql = "UPDATE `{$table}` SET " . implode(',', $datas) . " WHERE {$id} LIMIT 1";
         $query = @mysql_query($sql, $this->connection);
         if ($query == false) {
             Gcms::debug(mysql_error($this->connection));
             return false;
         } else {
             ++$this->time;
             return true;
         }
     }
 }