/**
  * แสดงผล
  *
  * @return string
  */
 public function render(Request $request)
 {
     // อ่านข้อมูลสมาชิก
     $model = new Model();
     $user = $model->db()->createQuery()->from('user')->where(array('id', (int) $_SESSION['login']['id']))->first();
     $template = Template::create('member', 'member', 'profile');
     $contents = array('/<NEWREGISTER>(.*)<\\/NEWREGISTER>/isu' => $request->request('action')->toString() === 'newregister' ? '\\1' : '', '/<IDCARD>(.*)<\\/IDCARD>/isu' => empty(self::$cfg->member_idcard) ? '' : '\\1', '/{ACCEPT}/' => Mime::getEccept(self::$cfg->user_icon_typies));
     // ข้อมูลฟอร์ม
     foreach ($user as $key => $value) {
         if ($key == 'sex') {
             $datas = array();
             foreach (Language::get('SEXES') as $k => $v) {
                 $sel = $k == $value ? ' selected' : '';
                 $datas[] = '<option value="' . $k . '"' . $sel . '>' . $v . '</option>';
             }
             $contents['/{SEX}/'] = implode('', $datas);
         } elseif ($key === 'subscrib') {
             $contents['/{SUBSCRIB}/'] = $value == 1 ? 'checked' : '';
         } elseif ($key === 'icon') {
             if (is_file(ROOT_PATH . self::$cfg->usericon_folder . $value)) {
                 $icon = WEB_URL . self::$cfg->usericon_folder . $value;
             } else {
                 $icon = WEB_URL . 'skin/img/noicon.jpg';
             }
             $contents['/{ICON}/'] = $icon;
         } else {
             $contents['/{' . strtoupper($key) . '}/'] = $value;
         }
     }
     $template->add($contents);
     // after render
     Gcms::$view->setContents(array('/:type/' => empty(self::$cfg->user_icon_typies) ? 'jpg' : implode(', ', self::$cfg->user_icon_typies)), false);
     return $template->render();
 }
 /**
  * แสดงผล
  */
 public function render()
 {
     // แอดมิน
     if (Login::isAdmin()) {
         // รายการที่ต้องการ
         $index = \Index\Mailwrite\Model::getIndex(self::$request->get('id')->toInt());
         // สร้างหรือแก้ไข
         $title = Language::get(empty($index->id) ? 'Create' : 'Edit');
         // แสดงผล
         $section = Html::create('section');
         // breadcrumbs
         $breadcrumbs = $section->add('div', array('class' => 'breadcrumbs'));
         $ul = $breadcrumbs->add('ul');
         $ul->appendChild('<li><span class="icon-settings">{LNG_Site settings}</span></li>');
         $ul->appendChild('<li><a href="{BACKURL?module=mailtemplate&id=0}">{LNG_Email template}</a></li>');
         $ul->appendChild('<li><span>' . $title . '</span></li>');
         $section->add('header', array('innerHTML' => '<h1 class="icon-write">' . $title . ' ' . $index->name . '</h1>'));
         if ($index) {
             // แสดงฟอร์ม
             $section->appendChild(createClass('Index\\Mailwrite\\View')->render($index));
             return $section->render();
         }
     }
     // 404.html
     return \Index\Error\Controller::page404();
 }
 /**
  * module=mailserver
  *
  * @param object $config
  * @return string
  */
 public function render($config)
 {
     // form
     $form = Html::create('form', array('id' => 'setup_frm', 'class' => 'setup_frm', 'autocomplete' => 'off', 'action' => 'index.php/index/model/mailserver/save', 'onsubmit' => 'doFormSubmit', 'ajax' => true));
     $fieldset = $form->add('fieldset', array('title' => '{LNG_General}'));
     // noreply_email
     $fieldset->add('text', array('id' => 'noreply_email', 'labelClass' => 'g-input icon-email', 'itemClass' => 'item', 'label' => '{LNG_noreply email}', 'comment' => '{LNG_Email addresses for sender and do not reply such as no-reply@domain.tld}', 'maxlength' => 255, 'value' => isset($config->noreply_email) ? $config->noreply_email : self::$cfg->noreply_email));
     // email_charset
     $fieldset->add('text', array('id' => 'email_charset', 'labelClass' => 'g-input icon-language', 'itemClass' => 'item', 'label' => '{LNG_Email encoding}', 'comment' => '{LNG_Specify the language code of the email, as utf-8}', 'value' => isset($config->email_charset) ? $config->email_charset : self::$cfg->email_charset));
     // email_use_phpMailer
     $fieldset->add('select', array('id' => 'email_use_phpMailer', 'labelClass' => 'g-input icon-clock', 'itemClass' => 'item', 'label' => '{LNG_Mail program}', 'comment' => '{LNG_Set the application for send an email}', 'options' => Language::get('MAIL_PROGRAMS'), 'value' => isset($config->email_use_phpMailer) ? $config->email_use_phpMailer : self::$cfg->email_use_phpMailer));
     // ตั้งค่า mail server
     $fieldset = $form->add('fieldset', array('title' => '{LNG_Mail Server Settings}'));
     // email_Host
     $fieldset->add('text', array('id' => 'email_Host', 'labelClass' => 'g-input icon-world', 'itemClass' => 'item', 'label' => '{LNG_Mail server}', 'comment' => '{LNG_The name of the mail server as localhost or smtp.gmail.com (To change the settings of your email is the default. To remove this box entirely.)}', 'value' => isset($config->email_Host) ? $config->email_Host : self::$cfg->email_Host));
     // email_Port
     $fieldset->add('number', array('id' => 'email_Port', 'labelClass' => 'g-input icon-config', 'itemClass' => 'item', 'label' => '{LNG_Port}', 'comment' => '{LNG_Mail server port number (default is 25, for GMail used 465, 587 for DirectAdmin).}', 'value' => isset($config->email_Port) ? $config->email_Port : self::$cfg->email_Port));
     // email_SMTPAuth
     $fieldset->add('select', array('id' => 'email_SMTPAuth', 'labelClass' => 'g-input icon-config', 'itemClass' => 'item', 'label' => '{LNG_Authentication require}', 'comment' => '{LNG_How to define user authentication for mail servers. If you enable it, you must configure below correctly.}', 'options' => Language::get('BOOLEANS'), 'value' => isset($config->email_SMTPAuth) ? $config->email_SMTPAuth : self::$cfg->email_SMTPAuth));
     // email_SMTPSecure
     $fieldset->add('select', array('id' => 'email_SMTPSecure', 'labelClass' => 'g-input icon-config', 'itemClass' => 'item', 'label' => '{LNG_SSL support}', 'comment' => '{LNG_Enable SSL encryption for sending email}', 'options' => Language::get('SMTPSECURIES'), 'value' => isset($config->email_SMTPSecure) ? $config->email_SMTPSecure : self::$cfg->email_SMTPSecure));
     // email_Username
     $fieldset->add('text', array('id' => 'email_Username', 'labelClass' => 'g-input icon-user', 'itemClass' => 'item', 'label' => '{LNG_Username}', 'comment' => '{LNG_Username for the mail server. (To change, enter a new value.)}', 'value' => isset($config->email_Username) ? $config->email_Username : self::$cfg->email_Username));
     // email_Password
     $fieldset->add('text', array('id' => 'email_Password', 'labelClass' => 'g-input icon-password', 'itemClass' => 'item', 'label' => '{LNG_Password}', 'comment' => '{LNG_Password of the mail server. (To change the fill.)}'));
     $fieldset = $form->add('fieldset', array('class' => 'submit'));
     // submit
     $fieldset->add('submit', array('class' => 'button ok large', 'value' => '{LNG_Save}'));
     $form->script('initMailserver();');
     return $form->render();
 }
 /**
  * action
  */
 public static function action()
 {
     $ret = array();
     // referer, session, admin
     if (self::$request->initSession() && self::$request->isReferer() && ($login = Login::isAdmin())) {
         if ($login['email'] == 'demo') {
             $ret['alert'] = Language::get('Unable to complete the transaction');
         } else {
             if (self::$request->post('action')->toString() === 'delete') {
                 $id = self::$request->post('action')->toInt();
                 $rs = Recordset::create(get_called_class());
                 $index = $rs->find($id);
                 if ($index) {
                     $index->delete();
                 }
                 // คืนค่า
                 $ret['delete_id'] = self::$request->post('src')->toString() . '_' . $id;
                 $ret['alert'] = Language::get('Deleted successfully');
             }
         }
     } else {
         $ret['alert'] = Language::get('Unable to complete the transaction');
     }
     // คืนค่าเป็น JSON
     echo json_encode($ret);
 }
 /**
  * แสดงผล
  *
  * @return string
  */
 public function render()
 {
     $template = Template::create('', '', '404');
     $message = Language::get('Sorry, cannot find a page called Please check the URL or try the call again.');
     $template->add(array('/{TOPIC}/' => $message, '/{DETAIL}/' => $message));
     return (object) array('topic' => $message, 'detail' => $template->render(), 'description' => $message, 'keywords' => $message, 'module' => '404', 'owner' => 'index');
 }
 /**
  * form submit
  */
 public function save()
 {
     $ret = array();
     // referer, session, member
     if (self::$request->initSession() && self::$request->isReferer() && ($login = Login::isAdmin())) {
         if ($login['email'] == 'demo') {
             $ret['alert'] = Language::get('Unable to complete the transaction');
         } else {
             // โหลด config
             $config = Config::load(ROOT_PATH . 'settings/config.php');
             $config->member_reserv = array();
             foreach (explode("\n", self::$request->post('member_reserv')->text()) as $item) {
                 $config->member_reserv[] = trim($item);
             }
             $config->wordrude = array();
             foreach (explode("\n", self::$request->post('wordrude')->text()) as $item) {
                 $config->wordrude[] = trim($item);
             }
             $config->wordrude_replace = self::$request->post('wordrude_replace', 'xxx')->toString();
             $config->counter_digit = max(4, self::$request->post('counter_digit')->toInt());
             // save config
             if (Config::save($config, ROOT_PATH . 'settings/config.php')) {
                 $ret['alert'] = Language::get('Saved successfully');
                 $ret['location'] = 'reload';
             } else {
                 $ret['alert'] = sprintf(Language::get('File %s cannot be created or is read-only.'), 'settings/config.php');
             }
         }
     } else {
         $ret['alert'] = Language::get('Unable to complete the transaction');
     }
     // คืนค่าเป็น JSON
     echo json_encode($ret);
 }
 /**
  * แสดงผล
  *
  * @return string
  */
 public function render()
 {
     // อ่านข้อมูลสมาชิก
     $rs = Recordset::create('Index\\User\\Model');
     $user = $rs->where((int) $_SESSION['login']['id'])->first('id');
     $template = Template::create('member', 'member', 'password');
     $contents = array('/{ACCEPT}/' => Mime::getEccept(self::$cfg->user_icon_typies), '/{USER_ICON_TYPIES}/' => sprintf(Language::get('Upload a picture of %s resize automatically'), empty(self::$cfg->user_icon_typies) ? 'jpg' : implode(', ', self::$cfg->user_icon_typies)));
     // ข้อมูลฟอร์ม
     foreach ($user as $key => $value) {
         if ($key == 'sex') {
             $source = Language::get('SEXES');
             $datas = array();
             foreach ($source as $k => $v) {
                 $sel = $k == $value ? ' selected' : '';
                 $datas[] = '<option value="' . $k . '"' . $sel . '>' . $v . '</option>';
             }
             $contents['/{' . strtoupper($key) . '}/'] = implode('', $datas);
         } elseif ($key === 'subscrib') {
             $contents['/{' . strtoupper($key) . '}/'] = $value == 1 ? 'checked' : '';
         } elseif ($key === 'icon') {
             if (is_file(ROOT_PATH . self::$cfg->usericon_folder . $value)) {
                 $icon = WEB_URL . self::$cfg->usericon_folder . $value;
             } else {
                 $icon = WEB_URL . 'skin/img/noicon.jpg';
             }
             $contents['/{ICON}/'] = $icon;
         } else {
             $contents['/{' . strtoupper($key) . '}/'] = $value;
         }
     }
     $template->add($contents);
     return $template->render();
 }
 /**
  * รับค่าจาก action
  */
 public function action()
 {
     $ret = array();
     // referer, session, admin
     if (self::$request->initSession() && self::$request->isReferer() && ($login = Login::isAdmin())) {
         if (empty($login['fb'])) {
             // ค่าที่ส่งมา
             $type = self::$request->post('type')->toString();
             $type = $type == 'js' ? 'js' : 'php';
             $id = self::$request->post('id')->toString();
             $action = self::$request->post('action')->toString();
             if ($action == 'delete') {
                 // โหลดภาษา
                 $datas = Language::installed($type);
                 // ลบรายการที่ส่งมา
                 $datas = ArrayTool::delete($datas, $id);
                 // save
                 $error = Language::save($datas, $type);
                 if (empty($error)) {
                     $ret['location'] = 'reload';
                 } else {
                     $ret['alert'] = $error;
                 }
             }
         }
     } else {
         $ret['alert'] = Language::get('Unable to complete the transaction');
     }
     echo json_encode($ret);
 }
 /**
  * module=menuwrite
  *
  * @param object $menu
  * @return string
  */
 public function render($menu)
 {
     // form
     $form = Html::create('form', array('id' => 'setup_frm', 'class' => 'setup_frm', 'autocomplete' => 'off', 'action' => 'index.php/index/model/menuwrite/save', 'onsubmit' => 'doFormSubmit', 'ajax' => true));
     $fieldset = $form->add('fieldset', array('title' => '{LNG_Menu details}'));
     $groups = $fieldset->add('groups-table', array('label' => '{LNG_Language}', 'id' => 'language', 'comment' => '{LNG_Select the language of this item (Select the first Is present in every language)}'));
     // language
     $groups->add('select', array('id' => 'language', 'labelClass' => 'g-input icon-language', 'itemClass' => 'width', 'options' => ArrayTool::replace(array('' => '{LNG_all languages}'), Language::installedLanguage()), 'value' => empty($menu->id) ? '' : $menu->language));
     $groups->add('a', array('id' => 'copy_menu', 'class' => 'button icon-copy copy', 'title' => '{LNG_Copy this item to the selected language}'));
     // menu_text
     $fieldset->add('text', array('id' => 'menu_text', 'labelClass' => 'g-input icon-menus', 'itemClass' => 'item', 'label' => '{LNG_Text}', 'comment' => '{LNG_Text displayed on the menu}', 'maxlength' => 100, 'value' => $menu->menu_text));
     // menu_tooltip
     $fieldset->add('text', array('id' => 'menu_tooltip', 'labelClass' => 'g-input icon-edit', 'itemClass' => 'item', 'label' => '{LNG_Tooltip}', 'comment' => '{LNG_Message when mouse over the menu}', 'maxlength' => 100, 'value' => $menu->menu_tooltip));
     // accesskey
     $fieldset->add('text', array('id' => 'accesskey', 'labelClass' => 'g-input icon-keyboard', 'itemClass' => 'item', 'label' => '{LNG_Accesskey}', 'comment' => '{LNG_Enter lowercase English letters or numbers to be used as a shortcut to this menu. (Sub-menus do not support the shortcut menu. Do not duplicate keys of the system shortcut)}', 'value' => $menu->accesskey));
     $fieldset = $form->add('fieldset', array('title' => '{LNG_Installation and position of the menu}'));
     // alias
     $fieldset->add('text', array('id' => 'alias', 'labelClass' => 'g-input icon-edit', 'itemClass' => 'item', 'label' => '{LNG_Alias}', 'comment' => '{LNG_The name of the menu (the default is the name of the module is installed)}', 'value' => $menu->alias));
     // parent
     $fieldset->add('select', array('id' => 'parent', 'labelClass' => 'g-input icon-config', 'itemClass' => 'item', 'label' => '{LNG_Menu position}', 'comment' => '{LNG_Select the menu position. The menu will be displayed on the website at the selected position. (Based on templates you are using)}', 'options' => Language::find('MENU_PARENTS', array('MAINMENU' => 'Main menu')), 'value' => $menu->parent));
     // type
     if ($menu->menu_order == 1) {
         $m = 0;
     } elseif ($menu->level == 0) {
         $m = 1;
     } elseif ($menu->level == 1) {
         $m = 2;
     } else {
         $m = 3;
     }
     $fieldset->add('select', array('id' => 'type', 'labelClass' => 'g-input icon-config', 'itemClass' => 'item', 'label' => '{LNG_Menu type}', 'comment' => '{LNG_Select the type of menu}', 'options' => Language::get('MENU_TYPES'), 'value' => $m));
     // menu_order
     $fieldset->add('select', array('id' => 'menu_order', 'labelClass' => 'g-input icon-config', 'itemClass' => 'item', 'label' => '{LNG_Menu order}', 'size' => 8, 'comment' => '{LNG_The sequence of the desired menu. The menu will be displayed next from the selected item}'));
     // published
     $fieldset->add('select', array('id' => 'published', 'labelClass' => 'g-input icon-published1', 'itemClass' => 'item', 'label' => '{LNG_Status}', 'comment' => '{LNG_Publish this item}', 'options' => Language::get('MENU_PUBLISHEDS'), 'value' => $menu->published));
     $fieldset = $form->add('fieldset', array('id' => 'menu_action', 'title' => '{LNG_Action when click on menu}'));
     // action
     if ($menu->menu_url != '') {
         $m = 2;
     } elseif ($menu->index_id == 0) {
         $m = 0;
     } else {
         $m = 1;
     }
     $fieldset->add('select', array('id' => 'action', 'labelClass' => 'g-input icon-config', 'itemClass' => 'item', 'label' => '{LNG_When choosing the menu}', 'comment' => '{LNG_Choose how to proceed. When you click on the menu}', 'options' => Language::get('MENU_ACTIONS'), 'value' => $m));
     // index_id
     $fieldset->add('select', array('id' => 'index_id', 'labelClass' => 'g-input icon-modules', 'itemClass' => 'item action 1', 'label' => '{LNG_installed module}', 'comment' => '{LNG_Choose the page you want to open when you click a menu item from a list of web pages or modules already installed}', 'optgroup' => \Index\Menuwrite\Model::getModules(), 'value' => $menu->owner . '_' . $menu->index_id));
     // menu_url
     $fieldset->add('text', array('id' => 'menu_url', 'labelClass' => 'g-input icon-world', 'itemClass' => 'item action 2', 'label' => '{LNG_URL}', 'comment' => '{LNG_Links for this item, which will open this page when click on it}', 'value' => str_replace(array('{', '}'), array('&#x007B;', '&#x007D;'), $menu->menu_url)));
     // menu_target
     $fieldset->add('select', array('id' => 'menu_target', 'labelClass' => 'g-input icon-forward', 'itemClass' => 'item action 1 2', 'label' => '{LNG_The opening page of links}', 'comment' => '{LNG_Determine how to turn the page when a link is clicked}', 'options' => Language::get('MENU_TARGET'), 'value' => $menu->menu_target));
     $fieldset = $form->add('fieldset', array('class' => 'submit'));
     // submit
     $fieldset->add('submit', array('class' => 'button ok large', 'value' => '{LNG_Save}'));
     // id
     $fieldset->add('hidden', array('id' => 'id', 'value' => $menu->id));
     $form->script('initMenuwrite();');
     return $form->render();
 }
Example #10
0
 /**
  * จัดรูปแบบการแสดงผลในแต่ละแถว
  *
  * @param array $item
  * @return array
  */
 public function onRow($item)
 {
     $publisheds = Language::get('PUBLISHEDS');
     $item['published'] = '<a id=published_' . $item['id'] . ' class="icon-published' . $item['published'] . '" title="' . $publisheds[$item['published']] . '"></a>';
     $item['last_update'] = Date::format($item['last_update'], 'd M Y H:i');
     $item['language'] = empty($item['language']) ? '' : '<img src="' . WEB_URL . 'language/' . $item['language'] . '.gif" alt="' . $item['language'] . '">';
     return $item;
 }
Example #11
0
 /**
  * module=pages
  *
  * @return string
  */
 public function render()
 {
     $this->publisheds = Language::get('PUBLISHEDS');
     // Uri
     $uri = self::$request->getUri();
     // ตาราง
     $table = new DataTable(array('model' => 'Index\\Pages\\Model', 'perPage' => self::$request->cookie('pages_perPage', 30)->toInt(), 'defaultFilters' => array(array('M.owner', 'index')), 'onRow' => array($this, 'onRow'), 'hideColumns' => array('module_id', 'id', 'owner'), 'action' => 'index.php/index/model/pages/action', 'actionCallback' => 'indexActionCallback', 'actionConfirm' => 'confirmAction', 'searchColumns' => array('topic', 'module', 'detail'), 'headers' => array('topic' => array('text' => '{LNG_Topic}'), 'published' => array('text' => '{LNG_Status}', 'class' => 'center'), 'language' => array('text' => '{LNG_Language}', 'class' => 'center'), 'module' => array('text' => '{LNG_module name}', 'class' => 'center'), 'last_update' => array('text' => '{LNG_Last updated}', 'class' => 'center'), 'visited' => array('text' => '{LNG_Preview}', 'class' => 'center')), 'cols' => array('published' => array('class' => 'center'), 'language' => array('class' => 'center'), 'module' => array('class' => 'center'), 'last_update' => array('class' => 'center'), 'visited' => array('class' => 'visited')), 'buttons' => array('edit' => array('class' => 'icon-edit button green', 'href' => $uri->createBackUri(array('module' => 'pagewrite', 'id' => ':id')), 'text' => '{LNG_Edit}'), 'delete' => array('class' => 'icon-delete button red', 'id' => ':id', 'text' => '{LNG_Delete}')), 'addNew' => array('class' => 'button green icon-plus', 'href' => $uri->createBackUri(array('module' => 'pagewrite', 'id' => '0')), 'text' => '{LNG_Add New} {LNG_Page}')));
     // save cookie
     setcookie('pages_perPage', $table->perPage, time() + 3600 * 24 * 365, '/');
     return $table->render();
 }
 /**
  * หน้า login
  *
  * @param Request $request
  * @return object
  */
 public function render(Request $request)
 {
     $index = (object) array('canonical' => WEB_URL . 'index.php?module=dologin', 'topic' => Language::get('Visitors please login'), 'description' => self::$cfg->web_description, 'menu' => 'dologin');
     $template = Template::create('member', 'member', 'loginfrm');
     $template->add(array('/{TOKEN}/' => $request->createToken(), '/{EMAIL}/' => Login::$text_username, '/{PASSWORD}/' => Login::$text_password, '/{REMEMBER}/' => self::$request->cookie('login_remember')->toInt() == 1 ? 'checked' : '', '/{FACEBOOK}/' => empty(self::$cfg->facebook_appId) ? 'hidden' : 'facebook', '/{TOPIC}/' => $index->topic, '/{SUBTITLE}/' => $index->description));
     $index->detail = $template->render();
     $index->keywords = $index->topic;
     if (isset(Gcms::$view)) {
         Gcms::$view->addBreadcrumb($index->canonical, Language::get('Sign In'));
     }
     return $index;
 }
 /**
  * ส่งอีเมล์ ตาม ID
  *
  * @param Request $request
  */
 public function save(Request $request)
 {
     if ($request->initSession() && $request->isReferer() && ($login = Login::isMember())) {
         // ค่าที่ส่งมา
         $subject = $request->post('mail_subject')->topic();
         $detail = nl2br($request->post('mail_detail')->textarea());
         // ตรวจสอบ ค่าที่ส่งมา
         $ret = array();
         $antispam = new Antispam($request->post('mail_antispamid')->toString());
         if (!$antispam->valid($request->post('mail_antispam')->toString())) {
             // Antispam ไม่ถูกต้อง
             $ret['ret_mail_antispam'] = 'this';
             $ret['input'] = 'mail_antispam';
         } else {
             // ตรวจสอบผู้รับ
             $reciever = array();
             foreach (self::getUser($request->post('mail_reciever')->filter('0-9a-z')) as $item) {
                 $reciever[] = $item['email'] . (empty($item['name']) ? '' : '<' . $item['name'] . '>');
             }
             $reciever = implode(',', $reciever);
             // ตรวจสอบค่าที่ส่งมา
             if ($reciever == '') {
                 $ret['alert'] = Language::get('Unable to send e-mail, Because you can not send e-mail to yourself or can not find the email address of the recipient.');
                 $ret['location'] = WEB_URL . 'index.php';
             } elseif ($subject == '') {
                 $ret['ret_mail_subject'] = 'this';
                 $ret['input'] = 'mail_subject';
             } elseif ($detail == '') {
                 $ret['ret_mail_detail'] = 'this';
                 $ret['input'] = 'mail_detail';
             } else {
                 // ส่งอีเมล์
                 $err = Email::send($reciever, $login['email'] . (empty($login['displayname']) ? '' : '<' . $login['displayname'] . '>'), $subject, $detail);
                 if (empty($err)) {
                     // เคลียร์ Antispam
                     $antispam->delete();
                     // ส่งอีเมล์สำเร็จ
                     $ret['alert'] = Language::get('Your message was sent successfully');
                     $ret['location'] = WEB_URL . 'index.php';
                 } else {
                     // ข้อผิดพลาดการส่งอีเมล์
                     echo $err;
                 }
             }
         }
         if (!empty($ret)) {
             // คืนค่าเป็น JSON
             echo json_encode($ret);
         }
     }
 }
Example #14
0
 /**
  * รับค่าจาก action ของ table
  */
 public function action()
 {
     $ret = array();
     // referer, session, admin
     if (self::$request->initSession() && self::$request->isReferer() && ($login = Login::isAdmin())) {
         if ($login['email'] == 'demo') {
             $ret['alert'] = Language::get('Unable to complete the transaction');
         } else {
             // ค่าที่ส่งมา
             $action = self::$request->post('action')->toString();
             $id = self::$request->post('id')->toInt();
             // Model
             $model = new \Kotchasan\Model();
             if ($action === 'published') {
                 // เผยแพร่
                 $index = $model->db()->first($model->getFullTableName('index'), $id);
                 if ($index) {
                     $published = $index->published == 1 ? 0 : 1;
                     $model->db()->update($model->getFullTableName('index'), $index->id, array('published' => $published));
                     // คืนค่า
                     $ret['elem'] = 'published_' . $index->id;
                     $lng = Language::get('PUBLISHEDS');
                     $ret['title'] = $lng[$published];
                     $ret['class'] = 'icon-published' . $published;
                 }
             } elseif ($action === 'delete') {
                 // ลบโมดูลและหน้าเพจ ไม่ลบข้อมูลของโมดูล
                 $query = $model->db()->createQuery()->select('id', 'module_id')->from('index')->where(array(array('index', 1), array('module_id', $model->db()->createQuery()->select('module_id')->from('index')->where(array('id', $id)))));
                 $count = 0;
                 foreach ($query->execute() as $field) {
                     $count++;
                     if ($field->id == $id) {
                         $model->db()->delete($model->getFullTableName('index'), $id);
                         $model->db()->delete($model->getFullTableName('index_detail'), $id);
                     }
                 }
                 // ลบโมดูล ถ้าไม่มีรายการในภาษาอื่น
                 if ($count < 2) {
                     $model->db()->delete($model->getFullTableName('modules'), $field->module_id);
                 }
                 // คืนค่า
                 $ret['delete_id'] = self::$request->post('src')->toString() . '_' . $id;
                 $ret['alert'] = Language::get('Deleted successfully');
             }
         }
     } else {
         $ret['alert'] = Language::get('Unable to complete the transaction');
     }
     // คืนค่าเป็น JSON
     echo json_encode($ret);
 }
 /**
  * หน้าขอรหัสผ่านใหม่
  *
  * @param Request $request
  * @param boolean $modal true แสดงแบบ modal, false (default) แสดงหน้าเว็บปกติ
  * @return object
  */
 public function render(Request $request, $modal = false)
 {
     $index = (object) array('canonical' => WEB_URL . 'index.php?module=forgot', 'topic' => Language::get('Request new password'), 'description' => self::$cfg->web_description);
     $template = Template::create('member', 'member', 'forgotfrm');
     $template->add(array('/{LNG_([^}]+)}/e' => '\\Kotchasan\\Language::get(array(1=>"$1"))', '/{TOPIC}/' => $index->topic, '/{EMAIL}/' => Login::$text_username, '/{WEBURL}/' => WEB_URL, '/{MODAL}/' => $modal ? 'true' : WEB_URL . 'index.php'));
     $index->detail = $template->render();
     $index->keywords = $index->topic;
     if (isset(Gcms::$view)) {
         Gcms::$view->addBreadcrumb($index->canonical, Language::get('Forgot'));
     }
     // เมนู
     $index->menu = 'forgot';
     return $index;
 }
 /**
  * แสดงผล
  *
  * @param object $index ข้อมูลโมดูล
  */
 public function render($index)
 {
     // รายการ
     $listitem = Grid::create('search', 'search', 'searchitem');
     foreach ($index->items as $item) {
         if ($item->index == 0 && $item->owner == 'document') {
             // document
             $uri1 = \Document\Index\Controller::url($item->module, $item->alias, $item->id);
             $uri2 = \Document\Index\Controller::url($item->module, $item->alias, $item->id, false);
         } elseif ($item->index == 0 && $item->owner == 'board') {
             // board
             $uri1 = \Board\Index\Controller::url($item->module, 0, $item->id);
             $uri2 = $uri1;
         } else {
             // other
             if (self::$cfg->module_url == 1) {
                 $uri1 = Gcms::createUrl($item->module, $item->alias);
                 $uri2 = Gcms::createUrl($item->module, $item->alias, 0, 0, '', false);
             } else {
                 $uri1 = Gcms::createUrl($item->module, '', 0, $item->id, '');
                 $uri2 = $uri1;
             }
         }
         $listitem->add(array('/{URL}/' => $uri1, '/{TOPIC}/' => $item->topic, '/{LINK}/' => $uri2, '/{DETAIL}/' => $item->description));
     }
     // template search/search.html
     $template = Template::create('search', 'search', 'search');
     // canonical
     $index->canonical = Gcms::createUrl($index->module);
     // current URL
     $uri = \Kotchasan\Http\Uri::createFromUri($index->canonical);
     if ($index->total > 0) {
         $list = Gcms::highlightSearch($listitem->render(), $index->q);
     } else {
         $list = $index->q == '' ? '' : '<div>' . Language::get('No results were found for') . ' <strong>' . $index->q . '</strong></div>';
         $list .= '<div><strong>' . Language::get('Search tips') . ' :</strong>' . Language::get('<ul><li>make sure that the spelling correct</li><li>try changing or new phrases. synonyms</li><li>try to identify a non-specific too</li><li>specific keywords to search the most concise</li></ul>') . '</div>';
     }
     // add template
     $template->add(array('/{LIST}/' => $list, '/{SPLITPAGE}/' => $uri->pagination($index->totalpage, $index->page), '/{SEARCH}/' => $index->q, '/{MODULE}/' => 'search', '/{RESULT}/' => $index->total == 0 ? '' : sprintf(Language::get('Search results <strong>%d - %d</strong> of about <strong>%d</strong> for <strong>%s</strong> (%s sec)'), $index->start + 1, $index->end, $index->total, $index->q, number_format(microtime(true) - REQUEST_TIME, 4))));
     $search = Language::get('Search');
     $index->detail = $template->render();
     $index->topic = ($index->q == '' ? '' : $index->q . ' - ') . $search;
     $index->description = $index->topic;
     $index->keywords = $index->topic;
     $index->menu = 'search';
     // breadcrumb ของหน้า
     Gcms::$view->addBreadcrumb($index->canonical, $search, $search);
     return $index;
 }
 /**
  * module=install
  *
  * @param string $type module หรือ widget
  * @param string $module โมดูลที่ติดตั้ง
  * @return object
  */
 public function render($type, $module)
 {
     $div = Html::create('div', array('class' => 'setup_frm', 'id' => 'install'));
     if ($type === 'module' && empty(Gcms::$install_modules[$module]) || $type === 'widget') {
         $div->add('aside', array('class' => 'tip', 'innerHTML' => Language::get('Module or an extension has not been installed correctly the first time. Please click on the button "Install" below to complete installation before.')));
         $div2 = $div->add('div', array('class' => 'padding-right-bottom-left'));
         $div2->add('a', array('class' => 'button ok large', 'id' => 'install_btn', 'innerHTML' => '<span class=icon-valid>' . Language::get('Install') . '</span>'));
         if ($type === 'module') {
             $div->script("callInstall('" . rawurlencode(ucfirst($module) . '\\Admin\\Install\\Model') . "')");
         } elseif ($type === 'widget') {
             $div->script("callInstall('" . rawurlencode('Widgets\\' . ucfirst($module) . '\\Models\\Install') . "')");
         }
     } else {
         $div->add('aside', array('class' => 'error', 'innerHTML' => Language::get('Can not install this module. Because this module is already installed. If you want to install this module, you will need to rename installed module to a different name. (This module is to use this name only).')));
     }
     return $div->render();
 }
 public function view(Request $request)
 {
     $topic = Language::get('Personal information') . ' ' . self::$cfg->web_title;
     $user = \Index\Member\Model::getUserById($request->get('id')->toInt());
     if ($user) {
         $template = Template::create('member', 'member', 'view');
         $template->add(array('/{ID}/' => $user->id, '/{EMAIL}/' => $user->email, '/{FNAME}/' => $user->fname, '/{LNAME}/' => $user->lname, '/{SEX}/' => $user->sex === 'f' || $user->sex === 'm' ? $user->sex : 'u', '/{DATE}/' => Date::format($user->create_date), '/{WEBSITE}/' => $user->website, '/{VISITED}/' => $user->visited, '/{LASTVISITED}/' => Date::format($user->lastvisited), '/{POST}/' => number_format($user->post), '/{REPLY}/' => number_format($user->reply), '/{STATUS}/' => isset(self::$cfg->member_status[$user->status]) ? self::$cfg->member_status[$user->status] : 'Unknow', '/{COLOR}/' => $user->status, '/{SOCIAL}/' => $user->fb == 1 ? 'icon-facebook' : '', '/{TOPIC}/' => $topic));
         // breadcrumbs
         $canonical = WEB_URL . 'index.php?module=member&amp;id=' . $user->id;
         Gcms::$view->addBreadcrumb($canonical, $topic);
         // คืนค่า
         return (object) array('detail' => $template->render(), 'keywords' => self::$cfg->web_title, 'description' => self::$cfg->web_description, 'topic' => $topic, 'canonical' => $canonical);
     } else {
         // ไม่พบสมาชิก
         return createClass('Index\\PageNotFound\\Controller')->init($request, 'index');
     }
 }
 /**
  * หน้าแก้ไขข้อมูลส่วนตัว
  *
  * @param Request $request
  * @return object
  */
 public function render(Request $request)
 {
     if ($login = Login::isMember()) {
         // tab ที่เลือก
         $tab = $request->request('tab')->toString();
         $member_tabs = array_keys(Gcms::$member_tabs);
         $tab = in_array($tab, $member_tabs) ? $tab : reset($member_tabs);
         $index = (object) array('description' => self::$cfg->web_description);
         // รายการ tabs
         $tabs = array();
         if (!empty($login['fb'])) {
             unset(Gcms::$member_tabs['password']);
         }
         foreach (Gcms::$member_tabs as $key => $values) {
             if ($values[0] != '') {
                 if ($key == $tab) {
                     $class = "tab select {$key}";
                     $index->topic = Language::get($values[0]);
                     $className = $values[1];
                 } else {
                     $class = "tab {$key}";
                 }
                 if (preg_match('/^http:\\/\\/.*/', $values[1])) {
                     $tabs[] = '<li class="' . $class . '"><a href="' . $values[1] . '">' . Language::get($values[0]) . '</a></li>';
                 } else {
                     $tabs[] = '<li class="' . $class . '"><a href="{WEBURL}index.php?module=editprofile&amp;tab=' . $key . '">' . Language::get($values[0]) . '</a></li>';
                 }
             }
         }
         if (empty($className)) {
             // FB และแก้ไขรหัสผ่าน
             return createClass('Index\\PageNotFound\\Controller')->init($request, 'index');
         } else {
             $template = Template::create('member', 'member', 'main');
             $template->add(array('/{TAB}/' => implode('', $tabs), '/{DETAIL}/' => createClass($className)->render($request)));
             $index->detail = $template->render();
             $index->keywords = $index->topic;
             // menu
             $index->menu = 'member';
             return $index;
         }
     } else {
         // ไม่ได้ login
         return createClass('Index\\PageNotFound\\Controller')->init($request, 'index');
     }
 }
 /**
  * ตารางรายชื่อสมาชิก
  *
  * @return string
  */
 public function render()
 {
     $this->sexes = Language::get('SEXES');
     // สถานะสมาชิก
     $change_member_status = array();
     $member_status = array(-1 => '{LNG_all items}');
     foreach (self::$cfg->member_status as $key => $value) {
         $member_status[$key] = $value;
         $change_member_status[$key] = '{LNG_Change member status to} ' . $value;
     }
     // ตารางสมาชิก
     $table = new DataTable(array('model' => 'Index\\Member\\Model', 'perPage' => self::$request->cookie('member_perPage', 30)->toInt(), 'sort' => self::$request->cookie('member_sort', 'id desc')->toString(), 'onRow' => array($this, 'onRow'), 'hideColumns' => array('visited', 'status', 'admin_access', 'activatecode', 'website', 'fb'), 'searchColumns' => array('fname', 'lname', 'displayname', 'email'), 'action' => 'index.php/index/model/member/action', 'actions' => array(array('id' => 'action', 'class' => 'ok', 'text' => '{LNG_With selected}', 'options' => array('accept' => '{LNG_Accept membership}', 'activate' => '{LNG_Send confirmation email}', 'sendpassword' => '{LNG_Get new password}', 'ban' => '{LNG_Suspended}', 'unban' => '{LNG_Cancel suspension}', 'delete' => '{LNG_Delete}')), array('id' => 'status', 'class' => 'ok', 'text' => '{LNG_With selected}', 'options' => $change_member_status)), 'filters' => array('status' => array('name' => 'status', 'default' => -1, 'text' => '{LNG_Member status}', 'options' => $member_status, 'value' => self::$request->get('status', -1)->toInt())), 'fields' => array('id', 'ban', 'email', 'displayname', 'CONCAT_WS(" ", `pname`,`fname`,`lname`) name', 'phone1', 'sex', 'website', 'create_date', 'lastvisited', 'visited', 'status', 'admin_access', 'activatecode', 'fb'), 'headers' => array('id' => array('text' => '{LNG_ID}', 'sort' => 'id'), 'ban' => array('text' => ''), 'email' => array('text' => '{LNG_Email}', 'sort' => 'email'), 'displayname' => array('text' => '{LNG_Displayname}', 'sort' => 'displayname'), 'name' => array('text' => '{LNG_Name} {LNG_Surname}', 'sort' => 'name'), 'phone1' => array('text' => '{LNG_Phone}'), 'sex' => array('text' => '{LNG_Sex}', 'class' => 'center'), 'website' => array('text' => '{LNG_Website}'), 'create_date' => array('text' => '{LNG_Created}', 'class' => 'center'), 'lastvisited' => array('text' => '{LNG_Last login} ({LNG_times})', 'class' => 'center')), 'cols' => array('sex' => array('class' => 'center'), 'ban' => array('class' => 'center'), 'create_date' => array('class' => 'center'), 'lastvisited' => array('class' => 'center')), 'buttons' => array(array('class' => 'icon-edit button green', 'href' => self::$request->getUri()->createBackUri(array('module' => 'editprofile', 'id' => ':id')), 'text' => '{LNG_Edit}'))));
     // save cookie
     setcookie('member_perPage', $table->perPage, time() + 3600 * 24 * 365, '/');
     setcookie('member_sort', $table->sort, time() + 3600 * 24 * 365, '/');
     return $table->render();
 }
 /**
  * module=maintenance
  *
  * @param string $language
  * @param string $template
  * @return string
  */
 public function render($language, $template)
 {
     // form
     $form = Html::create('form', array('id' => 'setup_frm', 'class' => 'setup_frm', 'autocomplete' => 'off', 'action' => 'index.php/index/model/maintenance/save', 'onsubmit' => 'doFormSubmit', 'ajax' => true));
     $fieldset = $form->add('fieldset', array('title' => '{LNG_The page will appear on your site is in maintenance mode}'));
     // maintenance_mode
     $fieldset->add('select', array('id' => 'maintenance_mode', 'labelClass' => 'g-input icon-config', 'itemClass' => 'item', 'label' => '{LNG_Settings}', 'options' => Language::get('BOOLEANS'), 'value' => isset(self::$cfg->maintenance_mode) ? self::$cfg->maintenance_mode : 0));
     $div = $fieldset->add('groups-table', array('label' => '{LNG_Language}'));
     // language
     $div->add('select', array('id' => 'language', 'labelClass' => 'g-input icon-language', 'itemClass' => 'width', 'options' => Language::installedLanguage(), 'value' => $language));
     $div->add('button', array('id' => 'btn_go', 'itemClass' => 'width', 'class' => 'button go', 'value' => '{LNG_Go}'));
     // detail
     $fieldset->add('ckeditor', array('id' => 'detail', 'itemClass' => 'item', 'height' => 300, 'language' => Language::name(), 'toolbar' => 'Document', 'label' => '{LNG_Detail}', 'value' => $template, 'upload' => true));
     $fieldset = $form->add('fieldset', array('class' => 'submit'));
     // submit
     $fieldset->add('submit', array('class' => 'button ok large', 'value' => '{LNG_Save}'));
     $form->script('doChangeLanguage("btn_go", "index.php?module=maintenance");');
     return $form->render();
 }
 /**
  * แสดงข้อมูลสมาชิก
  *
  * @param Request $request
  * @return object
  */
 public function render(Request $request)
 {
     // ตรวจสอบข้อมูล
     $user = \Index\Member\Model::getUserByActivateCode($request->get('id')->topic());
     if ($user) {
         // activate
         \Index\Member\Model::activateUser($user);
         // ข้อมูลแสดงผล (สำเร็จ)
         $details = array('/{DETAIL}/' => Language::get('<b>Congratulations!</b> your members have already confirmed. You can use your email address and password sent with the email address used to login.'), '/{CLASS}/' => 'message');
     } else {
         // ข้อมูลแสดงผล (ไม่สำเร็จ)
         $details = array('/{DETAIL}/' => Language::get('<b>Sorry!</b> can not find it registered. Information of registration may have expired or your registration may be confirmed.'), '/{CLASS}/' => 'error');
     }
     // template
     $template = Template::create('member', 'member', 'activate');
     $template->add($details);
     // คืนค่า
     return (object) array('detail' => $template->render(), 'keywords' => self::$cfg->web_title, 'description' => self::$cfg->web_description, 'topic' => Language::get('Activate') . ' ' . self::$cfg->web_title, 'menu' => 'member');
 }
 /**
  * บันทึก
  */
 public function save(Request $request)
 {
     // referer, session
     if ($request->initSession() && $request->isReferer()) {
         $ret = array();
         // ค่าที่ส่งมา
         $email = $request->post('forgot_email')->url();
         if ($email === '') {
             $ret['ret_forgot_email'] = Language::get('Please fill out this form');
         } else {
             $search = $this->db()->createQuery()->from('user')->where(array(array('email', $email), array('fb', '0')))->toArray()->first('id', 'email');
             if ($search === false) {
                 $ret['ret_forgot_email'] = Language::get('not a registered user');
             }
         }
         if (empty($ret)) {
             // รหัสผ่านใหม่
             $password = Text::rndname(6);
             // ข้อมูลอีเมล์
             $replace = array('/%PASSWORD%/' => $password, '/%EMAIL%/' => $search['email']);
             // send mail
             $err = Email::send(3, 'member', $replace, $search['email']);
             if (empty($err)) {
                 // อัปเดทรหัสผ่านใหม่
                 $save = array('password' => md5($password . $search['email']));
                 $this->db()->createQuery()->update('user')->set($save)->where($search['id'])->execute();
                 // คืนค่า
                 $ret['alert'] = Language::get('Your message was sent successfully');
                 $ret['ret_forgot_email'] = '';
                 $location = $request->post('modal')->url();
                 $ret['location'] = $location === 'true' ? 'close' : $location;
             } else {
                 $ret['ret_forgot_email'] = $err;
             }
         } else {
             $ret['input'] = 'forgot_email';
         }
         // คืนค่าเป็น JSON
         echo json_encode($ret);
     }
 }
Example #24
0
 /**
  * จัดรูปแบบการแสดงผลในแต่ละแถว
  *
  * @param array $item
  * @return array
  */
 public function onRow($item)
 {
     $url = empty($item['menu_url']) ? WEB_URL . 'index.php?module=' . $item['module'] : $item['menu_url'];
     $text = '';
     for ($i = 0; $i < $item['level']; $i++) {
         $text .= '&nbsp;&nbsp;&nbsp;';
     }
     $item['menu_text'] = (empty($text) ? '' : $text . '↳&nbsp;') . $item['menu_text'];
     $item['move_left'] = '<a id=move_left_' . $item['move_left'] . ' title="{LNG_Move submenu to the top}" class=' . ($item['level'] == 0 ? 'hidden' : 'icon-move_left') . '></a>';
     $item['move_right'] = '<a id=move_right_' . $item['move_right'] . ' title="{LNG_Move menu to submenu of the top}" class=' . ($item['level'] > $this->toplvl ? 'hidden' : 'icon-move_right') . '></a>';
     $menu_publisheds = Language::get('MENU_PUBLISHEDS');
     $item['published'] = $menu_publisheds[$item['published']];
     $item['language'] = empty($item['language']) ? '' : '<img src="' . WEB_URL . 'language/' . $item['language'] . '.gif" alt="' . $item['language'] . '">';
     if (empty($item['index_id'])) {
         $item['module'] = str_replace(array('{', '}'), array('&#x007B;', '&#x007D;'), $item['menu_url']);
     } else {
         $item['module'] .= empty($item['ilanguage']) ? '' : '&nbsp;<img src="' . WEB_URL . 'language/' . $item['ilanguage'] . '.gif" alt="' . $item['ilanguage'] . '">';
     }
     $this->toplvl = $item['level'];
     return $item;
 }
Example #25
0
 /**
  * ฟังก์ชั่นตรวจสอบการ Login
  */
 public function chklogin()
 {
     if (self::$request->initSession() && self::$request->isSafe()) {
         // กำหนด skin ให้กับ template
         Template::init(self::$cfg->skin);
         // ตรวจสอบการ login
         Login::create();
         // ตรวจสอบสมาชิก
         $login = Login::isMember();
         if ($login) {
             $name = trim($login['fname'] . ' ' . $login['lname']);
             $ret = array('alert' => str_replace('%s', empty($name) ? $login['email'] : $name, Language::get('Welcome %s, login complete')), 'content' => rawurlencode(\Index\Login\Controller::init($login)), 'action' => self::$request->post('login_action', self::$cfg->login_action)->toString());
             // clear
             self::$request->removeToken();
         } else {
             $ret = array('alert' => Login::$login_message, 'input' => Login::$login_input);
         }
         // คืนค่า JSON
         echo json_encode($ret);
     }
 }
Example #26
0
 /**
  * บันทึก
  */
 public function save()
 {
     $ret = array();
     // referer, session, member
     if (self::$request->initSession() && self::$request->isReferer() && ($login = Login::isAdmin())) {
         if ($login['email'] == 'demo') {
             $ret['alert'] = Language::get('Unable to complete the transaction');
         } else {
             // รับค่าจากการ POST
             $save = array('show_intro' => self::$request->post('show_intro')->toBoolean(), 'language' => self::$request->post('language')->toString(), 'detail' => self::$request->post('detail')->detail());
             if (!empty($save['language']) && preg_match('/^[a-z]{2,2}$/', $save['language'])) {
                 // save
                 $template = ROOT_PATH . DATA_FOLDER . 'intro.' . $save['language'] . '.php';
                 $f = @fopen($template, 'wb');
                 if ($f) {
                     fwrite($f, "<?php exit;?>\n" . $save['detail']);
                     fclose($f);
                     // โหลด config
                     $config = Config::load(ROOT_PATH . 'settings/config.php');
                     $config->show_intro = $save['show_intro'];
                     // save config
                     if (Config::save($config, ROOT_PATH . 'settings/config.php')) {
                         $ret['alert'] = Language::get('Saved successfully');
                         $ret['location'] = 'reload';
                     } else {
                         $ret['alert'] = sprintf(Language::get('File %s cannot be created or is read-only.'), 'settings/config.php');
                     }
                 } else {
                     $ret['alert'] = sprintf(Language::get('File %s cannot be created or is read-only.'), DATA_FOLDER . 'intro.' . $save['language'] . '.php');
                 }
             } else {
                 $ret['alert'] = Language::get('Unable to complete the transaction');
             }
         }
     } else {
         $ret['alert'] = Language::get('Unable to complete the transaction');
     }
     // คืนค่าเป็น JSON
     echo json_encode($ret);
 }
Example #27
0
 /**
  * ฟังก์ชั่นส่งเมล์จากแม่แบบจดหมาย
  *
  * @param int $id ID ของจดหมายที่ต้องการส่ง
  * @param string $module ชื่อโมดูลของจดหมายที่ต้องการส่ง
  * @param array $datas ข้อมูลที่จะถูกแทนที่ลงในจดหมาย ในรูป 'ตัวแปร'=>'ข้อความ'
  * @param string $to ที่อยู่อีเมล์ผู้รับ  คั่นแต่ละรายชื่อด้วย ,
  * @return string สำเร็จคืนค่าว่าง ไม่สำเร็จ คืนค่าข้อความผิดพลาด
  */
 public static function send($id, $module, $datas, $to)
 {
     $model = new static();
     $email = $model->db()->createQuery()->from('emailtemplate')->where(array(array('module', $module), array('email_id', (int) $id), array('language', array(Language::name(), ''))))->cacheOn()->toArray()->first('from_email', 'copy_to', 'subject', 'detail');
     if ($email === false) {
         return Language::get('email template not found');
     } else {
         // ผู้ส่ง
         $from = empty($email['from_email']) ? self::$cfg->noreply_email : $email['from_email'];
         // ข้อความในอีเมล์
         $replace = ArrayTool::replace(array('/%WEBTITLE%/' => strip_tags(self::$cfg->web_title), '/%WEBURL%/' => WEB_URL, '/%ADMINEMAIL%/' => $from, '/%TIME%/' => Date::format()), $datas);
         ArrayTool::extract($replace, $keys, $values);
         $msg = preg_replace($keys, $values, $email['detail']);
         $subject = preg_replace($keys, $values, $email['subject']);
         $to = explode(',', $to);
         if (!empty($email['copy_to'])) {
             $to[] = $email['copy_to'];
         }
         // ส่งอีเมล์
         return parent::send(implode(',', $to), $from, $subject, $msg);
     }
 }
 /**
  * module=database
  * ฟอร์ม export
  *
  * @return string
  */
 public function export()
 {
     // Model
     $model = \Kotchasan\Model::create();
     // Form
     $form = Html::create('form', array('id' => 'export_frm', 'class' => 'paper', 'autocomplete' => 'off', 'action' => 'index.php/index/model/database/export', 'target' => '_export'));
     $fieldset = $form->add('fieldset', array('titleClass' => 'icon-export', 'title' => '{LNG_Backup database}'));
     $fieldset->add('div', array('class' => 'subtitle', 'innerHTML' => '{LNG_When you press the button below. GCMS will create <em>:dbname.sql</em> file for save on your computer. This file contains all the information in the database. You can use it to restore your system, or used to move data to another site.}'));
     $structure = Language::get('Structure');
     $datas = Language::get('Datas');
     $content = array();
     $content[] = '<div class=item>';
     $content[] = '<table class="responsive database fullwidth"><tbody id=language_tbl>';
     $content[] = '<tr><td class=tablet></td><td colspan=3 class=left><a href="javascript:setSelect(\'language_tbl\',true)">{LNG_Select all}</a>&nbsp;|&nbsp;<a href="javascript:setSelect(\'language_tbl\',false)">{LNG_Clear selectd}</a></td></tr>';
     $prefix = $model->getSetting('prefix');
     if ($prefix != '') {
         $prefix .= '_';
     }
     foreach ($model->db()->customQuery('SHOW TABLE STATUS', true) as $table) {
         if (preg_match('/^' . $prefix . '(.*?)$/', $table['Name'], $match)) {
             $tr = '<tr>';
             $tr .= '<th>' . $table['Name'] . '</th>';
             $tr .= '<td><label class=nowrap><input type=checkbox name=' . $table['Name'] . '[] value=sturcture checked>&nbsp;' . $structure . '</label></td>';
             $tr .= '<td><label class=nowrap><input type=checkbox name=' . $table['Name'] . '[] value=datas checked>&nbsp;' . $datas . '</label></td>';
             $tr .= '</tr>';
             $content[] = $tr;
         }
     }
     $content[] = '<tr><td class=tablet></td><td colspan=3 class=left><a href="javascript:setSelect(\'language_tbl\',true)">{LNG_Select all}</a>&nbsp;|&nbsp;<a href="javascript:setSelect(\'language_tbl\',false)">{LNG_Clear selectd}</a></td></tr>';
     $content[] = '</tbody></table>';
     $content[] = '</div>';
     $fieldset->appendChild(implode("\n", $content));
     $fieldset = $form->add('fieldset', array('class' => 'submit'));
     // submit
     $fieldset->add('submit', array('class' => 'button ok large', 'value' => '{LNG_Export}'));
     Gcms::$view->setContents(array('/:dbname/' => $model->getSetting('dbname'), '/:size/' => ini_get('upload_max_filesize')), false);
     return $form->render();
 }
 /**
  * module=pagewrite
  *
  * @param string $id
  * @return string
  */
 public function render($index)
 {
     // form
     $form = Html::create('form', array('id' => 'setup_frm', 'class' => 'setup_frm', 'autocomplete' => 'off', 'action' => 'index.php/index/model/pagewrite/save', 'onsubmit' => 'doFormSubmit', 'ajax' => true, 'upload' => true));
     $fieldset = $form->add('fieldset', array('title' => '{LNG_Details of} ' . Language::get($index->owner === 'index' ? 'Page' : 'Module')));
     $groups = $fieldset->add('groups-table', array('label' => '{LNG_Language}', 'id' => 'language', 'comment' => '{LNG_Select the language of this item (Select the first Is present in every language)}'));
     // language
     $groups->add('select', array('id' => 'language', 'labelClass' => 'g-input icon-language', 'itemClass' => 'width', 'options' => ArrayTool::replace(array('' => '{LNG_all languages}'), Language::installedLanguage()), 'value' => $index->language));
     $groups->add('a', array('id' => 'btn_copy', 'class' => 'button icon-copy copy', 'title' => '{LNG_Copy this item to the selected language}'));
     // module
     $fieldset->add('text', array('id' => 'module', 'labelClass' => 'g-input icon-modules', 'itemClass' => 'item', 'label' => '{LNG_Module}', 'comment' => '{LNG_Name of this module. English lowercase and number only, short. (Can not use a reserve or a duplicate)}', 'maxlength' => 64, 'value' => $index->module));
     // topic
     $fieldset->add('text', array('id' => 'topic', 'labelClass' => 'g-input icon-edit', 'itemClass' => 'item', 'label' => '{LNG_Topic}', 'comment' => '{LNG_Text displayed on the Title Bar of the browser (3 - 255 characters)}', 'maxlength' => 255, 'value' => $index->topic));
     // keywords
     $fieldset->add('textarea', array('id' => 'keywords', 'labelClass' => 'g-input icon-tags', 'itemClass' => 'item', 'label' => '{LNG_Keywords}', 'comment' => '{LNG_Text keywords for SEO or Search Engine to search}', 'value' => $index->keywords));
     // description
     $fieldset->add('textarea', array('id' => 'description', 'labelClass' => 'g-input icon-file', 'itemClass' => 'item', 'label' => '{LNG_Description}', 'comment' => '{LNG_Text short summary of your story. Which can be used to show in your theme. (If not the program will fill in the contents of the first paragraph)}', 'value' => $index->description));
     // detail
     $fieldset->add('ckeditor', array('id' => 'detail', 'itemClass' => 'item', 'height' => 300, 'language' => Language::name(), 'toolbar' => 'Document', 'upload' => true, 'label' => '{LNG_Detail}', 'value' => $index->detail));
     // published_date
     $fieldset->add('date', array('id' => 'published_date', 'labelClass' => 'g-input icon-calendar', 'itemClass' => 'item', 'label' => '{LNG_Published date}', 'comment' => '{LNG_The date of publication of this information. The publisher will start automatically when you log on due date}', 'value' => $index->published_date));
     // published
     $fieldset->add('select', array('id' => 'published', 'labelClass' => 'g-input icon-published1', 'itemClass' => 'item', 'label' => '{LNG_Published}', 'comment' => '{LNG_Publish this item}', 'options' => Language::get('PUBLISHEDS'), 'value' => $index->published));
     $fieldset = $form->add('fieldset', array('class' => 'submit'));
     // submit
     $fieldset->add('submit', array('class' => 'button ok large', 'value' => '{LNG_Save}'));
     // preview button
     if ($index->owner == 'index') {
         $fieldset->add('button', array('id' => 'btn_preview', 'class' => 'button preview large', 'value' => '{LNG_Preview}'));
     }
     // owner
     $fieldset->add('hidden', array('id' => 'owner', 'value' => $index->owner));
     // id
     $fieldset->add('hidden', array('id' => 'id', 'value' => $index->id));
     $form->script('initIndexWrite();');
     return $form->render();
 }
 /**
  * แสดงผล
  */
 public function render()
 {
     // แอดมิน
     if (Login::isAdmin()) {
         // รายการที่ต้องการ
         $id = self::$request->get('id')->toString();
         $title = Language::get(empty($id) ? 'Create' : 'Edit');
         // แสดงผล
         $section = Html::create('section');
         // breadcrumbs
         $breadcrumbs = $section->add('div', array('class' => 'breadcrumbs'));
         $ul = $breadcrumbs->add('ul');
         $ul->appendChild('<li><span class="icon-settings">{LNG_Site settings}</span></li>');
         $ul->appendChild('<li><a href="{BACKURL?module=languages&id=0}">{LNG_Language}</a></li>');
         $ul->appendChild('<li><span>' . $title . '</span></li>');
         $section->add('header', array('innerHTML' => '<h1 class="icon-language">' . $title . ' {LNG_Language} ' . $id . '</h1>'));
         // แสดงฟอร์ม
         $section->appendChild(createClass('Index\\Languageadd\\View')->render($id));
         return $section->render();
     } else {
         // 404.html
         return \Index\Error\Controller::page404();
     }
 }