当前位置: 首页>>代码示例>>PHP>>正文


PHP Tpl::get_file方法代码示例

本文整理汇总了PHP中Tpl::get_file方法的典型用法代码示例。如果您正苦于以下问题:PHP Tpl::get_file方法的具体用法?PHP Tpl::get_file怎么用?PHP Tpl::get_file使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Tpl的用法示例。


在下文中一共展示了Tpl::get_file方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: action_tutorial

 /**
  * Action tutorial
  */
 public function action_tutorial()
 {
     $file = 'tutorial' . $this->request->param('key', 1);
     /**
      * View
      */
     // Get content file and Factory
     $content_file = Tpl::get_file($file, $this->settings->back_tpl_dir . '/home', $this->partials);
     $this->content = Tpl::factory($content_file);
 }
开发者ID:deraemons,项目名称:deraemon-cms,代码行数:13,代码来源:Home.php

示例2: get_response

 /**
  * Generate a Response for the 500 Exception.
  *
  * Internal
  * The user should be shown a nice 500 page.
  *
  * @return Response
  */
 public function get_response()
 {
     // Lets log the Exception, Just in case it's important!
     Kohana_Exception::log($this);
     if (Kohana::$environment >= Kohana::DEVELOPMENT) {
         // Show the normal Kohana error page.
         return parent::get_response();
     } else {
         // Get tpl directory
         $front_tpl_dir = Cms_Helper::settings('front_tpl_dir');
         // Get file
         $content_file = Tpl::get_file($this->code, $front_tpl_dir . '/error');
         // Set variable and render
         $content = Tpl::factory($content_file)->set('code', $this->getCode())->set('message', $this->getMessage())->set('request_url', URL::site(Request::current()->url(), "http"))->render();
         // Factory response
         $response = Response::factory();
         $response->body($content);
         return $response;
     }
 }
开发者ID:deraemons,项目名称:deraemon-cms,代码行数:28,代码来源:500.php

示例3: action_index


//.........这里部分代码省略.........
     // </editor-fold>
     /*
      * If delete
      */
     // <editor-fold defaultstate="collapsed" desc="If delete">
     if ($this->request->post('delete')) {
         // Database transaction start
         Database::instance()->begin();
         // Try
         try {
             // Get delete received comment ids
             $delete_received_comment_ids = Arr::get($this->request->post(), 'delete_received_comment_id', array());
             // Iterate and chack and delete
             foreach ($delete_received_comment_ids as $delete_received_comment_id) {
                 // Get received comment
                 $received_comment = Tbl::factory('received_comments')->get($delete_received_comment_id);
                 // Delete
                 $received_comment->delete();
             }
             // Database commit
             Database::instance()->commit();
             // Add success notice
             if ($delete_received_comment_ids) {
                 Notice::add(Notice::SUCCESS, Kohana::message('general', 'delete_success'));
             } else {
                 Notice::add(Notice::SUCCESS, Kohana::message('general', 'no_delete'), array(':text' => 'emil'));
             }
         } catch (HTTP_Exception_302 $e) {
             $this->redirect($e->location());
         } catch (Warning_Exception $e) {
             // Database rollback
             Database::instance()->rollback();
             // Add
             Notice::add(Notice::WARNING, $e->getMessage());
         } catch (Exception $e) {
             // Database rollback
             Database::instance()->rollback();
             // Add error notice
             Notice::add(Notice::ERROR, $e->getMessage() . $e->getFile() . $e->getLine());
         }
     }
     // </editor-fold>
     /*
      * Get received_comments
      */
     // <editor-fold defaultstate="collapsed" desc="Get received_comments">
     $all_received_comments = Tbl::factory('received_comments')->select('received_comments.*')->select(array('items.segment', 'item_segment'))->select(array('items.title', 'item_title'))->join('items')->on('received_comments.item_id', '=', 'items.id')->order_by($order_column, $order_direction)->read()->as_array();
     $pagenate = Pgn::factory(array('total_items' => count($all_received_comments), 'items_per_page' => $this->settings->pagenate_items_per_page_for_received_comments, 'follow' => $this->settings->pagenate_items_follow_for_received_comments));
     // Paginated items
     $received_comments = array_slice($all_received_comments, $pagenate->offset, $pagenate->items_per_page);
     foreach ($received_comments as $received_comment) {
         $received_comment->delete_url = URL::site("{$this->settings->backend_name}/received_comments/delete/{$received_comment->id}", 'http') . URL::query();
     }
     // </editor-fold>
     /*
      * If update
      */
     // <editor-fold defaultstate="collapsed" desc="If update">
     if ($this->request->post('update')) {
         $post = $this->request->post();
         // Set post to tag
         foreach ($received_comments as $received_comment) {
             $received_comment->is_accept = isset($post['is_accept'][$received_comment->id]) ? $post['is_accept'][$received_comment->id] : 0;
         }
         // Database transaction start
         Database::instance()->begin();
         // Try
         try {
             // Update
             foreach ($received_comments as $received_comment) {
                 Tbl::factory('received_comments')->get($received_comment->id)->update(array('is_accept' => isset($post['is_accept'][$received_comment->id]) ? $post['is_accept'][$received_comment->id] : 0));
             }
             // Database commit
             Database::instance()->commit();
             // Add success notice
             Notice::add(Notice::SUCCESS, Kohana::message('general', 'update_success'));
         } catch (HTTP_Exception_302 $e) {
             $this->redirect($e->location());
         } catch (Validation_Exception $e) {
             // Database rollback
             Database::instance()->rollback();
             // Add validation notice
             Notice::add(Notice::VALIDATION, Kohana::message('general', 'update_success'), NULL, $e->errors('validation'));
         } catch (Exception $e) {
             // Database rollback
             Database::instance()->rollback();
             // Add error notice
             Notice::add(Notice::ERROR, $e->getMessage());
         }
     }
     // </editor-fold>
     /**
      * View
      */
     // <editor-fold defaultstate="collapsed" desc="View">
     $this->partials['pagenate'] = Tpl::get_file('pagenate', $this->settings->back_tpl_dir);
     $content_file = Tpl::get_file('index', $this->settings->back_tpl_dir . '/received_comments', $this->partials);
     $this->content = Tpl::factory($content_file)->set('columns', $columns)->set('received_comments', $received_comments)->set('pagenate', $pagenate)->set('post', $this->request->post());
     // </editor-fold>
 }
开发者ID:deraemons,项目名称:deraemon-cms,代码行数:101,代码来源:Comments.php

示例4: action_login

 /**
  * Action login
  */
 public function action_login()
 {
     $post = $this->request->post();
     $username = Arr::get($post, 'username');
     $password = Arr::get($post, 'password');
     $remember = Arr::get($post, 'remember') ?: 0;
     // If there is post login
     if ($this->request->post('login')) {
         // ログインチェック
         if (Auth::instance()->login($username, $password, $remember)) {
             // ロールチェック
             if (Auth::instance()->logged_in('direct') or Auth::instance()->logged_in('admin') or Auth::instance()->logged_in('edit')) {
                 // Add success notice
                 Notice::add(Notice::SUCCESS, Kohana::message('auth', 'login_success'), array(':user' => $username));
                 // Redirect to home
                 $this->redirect(URL::site($this->settings->backend_name, 'http'));
             } else {
                 // Add error notice
                 Notice::add(Notice::ERROR, Kohana::message('auth', 'login_refusal'), NULL, Kohana::message('auth', 'login_refusal_messages'));
             }
         } else {
             // Add error notice
             Notice::add(Notice::ERROR, Kohana::message('auth', 'login_failed'), NULL, Kohana::message('auth', 'login_failed_messages'));
         }
     }
     /**
      * View
      */
     // Get content
     $content_file = Tpl::get_file('login', $this->settings->back_tpl_dir . '/auth');
     $this->content = Tpl::factory($content_file)->set('post', $post);
 }
开发者ID:deraemons,项目名称:deraemon-cms,代码行数:35,代码来源:Auth.php

示例5: action_edit

 /**
  * Action edit
  */
 public function action_edit()
 {
     // Get id from param, if there is nothing then throw to 404
     $id = $this->request->param('key');
     if (!$id) {
         throw HTTP_Exception::factory(404);
     }
     // Get wrapper, if there is nothing then throw to 404
     $wrapper = Tbl::factory('wrappers')->where('id', '=', $id)->read(1);
     if (!$wrapper) {
         throw HTTP_Exception::factory(404);
     }
     // Get content from file and direct set to wrppaer
     $wrapper->content = Tpl::get_file($wrapper->segment, $this->settings->front_tpl_dir . '/wrapper');
     $wrapper->delete_url = URL::site("{$this->settings->backend_name}/wrappers/delete/{$wrapper->id}", 'http');
     // Save present segment
     $oldfile = "wrapper/{$wrapper->segment}";
     // If there are post
     if ($this->request->post()) {
         // Set post to wrapper
         $wrapper->segment = $this->request->post('segment');
         $wrapper->name = $this->request->post('name');
         $wrapper->content_type = $this->request->post('content_type');
         $wrapper->content = $this->request->post('content');
         // Database transaction start
         Database::instance()->begin();
         // Try
         try {
             // Update
             Tbl::factory('wrappers')->get($wrapper->id)->update(array('segment' => $this->request->post('segment'), 'name' => $this->request->post('name'), 'content_type' => $this->request->post('content_type')));
             // New file
             $newfile = "wrapper/{$wrapper->segment}";
             // rename file
             Cms_Helper::rename_file($oldfile, $newfile, $this->settings->front_tpl_dir);
             // Update file
             Cms_Helper::set_file($newfile, $this->settings->front_tpl_dir, $this->request->post('content'));
             // Database commit
             Database::instance()->commit();
             // Add success notice
             Notice::add(Notice::SUCCESS, Kohana::message('general', 'update_success'));
         } catch (HTTP_Exception_302 $e) {
             $this->redirect($e->location());
         } catch (Validation_Exception $e) {
             // Database rollback
             Database::instance()->rollback();
             // Add validation notice
             Notice::add(Notice::VALIDATION, Kohana::message('general', 'update_failed'), NULL, $e->errors('validation'));
         } catch (Exception $e) {
             // Database rollback
             Database::instance()->rollback();
             // Add error notice
             Notice::add(Notice::ERROR, $e->getMessage());
         }
     }
     /**
      * View
      */
     $content_file = Tpl::get_file('edit', $this->settings->back_tpl_dir . '/wrappers', $this->partials);
     $this->content = Tpl::factory($content_file)->set('wrapper', $wrapper);
 }
开发者ID:deraemons,项目名称:deraemon-cms,代码行数:63,代码来源:Wrappers.php

示例6: action_detail

 /**
  * Action details
  */
 public function action_detail()
 {
     // Get id from param, if there is nothing then throw to 404
     $id = $this->request->param('key');
     if (!$id) {
         throw HTTP_Exception::factory(404);
     }
     // Get user, if there is nothing then throw to 404
     $user = Tbl::factory('users')->get($id);
     if (!$user) {
         throw HTTP_Exception::factory(404);
     }
     /**
      * Get and build details
      */
     // <editor-fold defaultstate="collapsed" desc="Get and build details">
     $details = Tbl::factory('users_details')->select('users_details.*')->select(array('details.segment', 'segment'))->select(array('details.name', 'name'))->join('details')->on('users_details.detail_id', '=', 'details.id')->where('users_details.user_id', '=', $user->id)->order_by('order')->read()->as_array('segment');
     // </editor-fold>
     /**
      * If there are post
      */
     if ($this->request->post()) {
         // Database transaction start
         Database::instance()->begin();
         // Try
         try {
             // Get rules
             $rules = Tbl::factory('detail_rules')->join('details')->on('detail_rules.detail_id', '=', 'details.id')->read()->as_array();
             // Set post to details
             foreach ($this->request->post() as $key => $value) {
                 if ($key != 'update') {
                     $details[$key]->value = $value;
                 }
             }
             /*
              * validation
              */
             // <editor-fold defaultstate="collapsed" desc="validation">
             // convert to array for validation
             $posts = array();
             foreach ($details as $key => $detail) {
                 $posts[$key] = $detail->value;
             }
             // Validation factory
             $validation = Validation::factory($posts);
             // Iterate post set rule and label
             foreach ($rules as $rule) {
                 // if param is null or 0 or ''
                 if (!$rule->param) {
                     $rule->param = NULL;
                 } elseif (strpos($rule->param, ',') === FALSE) {
                     $rule->param = array(trim($rule->param));
                 } else {
                     $rule->param = array($param[] = trim(substr($rule->param, 0, strpos($rule->param, ','))), $param[] = trim(substr($rule->param, strpos($rule->param, ',') + 1)));
                 }
                 $validation->rule($rule->segment, $rule->callback, $rule->param)->label($rule->segment, __($rule->name));
             }
             // If validation check is false
             if (!$validation->check()) {
                 throw new Validation_Exception($validation);
             }
             // </editor-fold>
             foreach ($details as $detail) {
                 Tbl::factory('users_details')->get($detail->id)->update(array('value' => $detail->value));
             }
             /**
              * Get and build details
              */
             // <editor-fold defaultstate="collapsed" desc="Get and build details">
             $details = Tbl::factory('users_details')->select('users_details.*')->select(array('details.segment', 'segment'))->select(array('details.name', 'name'))->join('details')->on('users_details.detail_id', '=', 'details.id')->where('users_details.user_id', '=', $user->id)->order_by('order')->read()->as_array('segment');
             // </editor-fold>
             /**
              * Database commit
              */
             Database::instance()->commit();
             // Add success notice
             Notice::add(Notice::SUCCESS, Kohana::message('general', 'update_success'));
         } catch (HTTP_Exception_302 $e) {
             $this->redirect($e->location());
         } catch (Validation_Exception $e) {
             // Database rollback
             Database::instance()->rollback();
             // Add validation notice
             Notice::add(Notice::VALIDATION, Kohana::message('general', 'update_failed'), NULL, $e->errors('validation'));
         } catch (Exception $e) {
             // Database rollback
             Database::instance()->rollback();
             // Add error notice
             Notice::add(Notice::ERROR, $e->getMessage() . '/' . $e->getFile() . '/' . $e->getLine());
         }
     }
     /**
      * View
      */
     $content_file = Tpl::get_file('detail', $this->settings->back_tpl_dir . '/users', $this->partials);
     $this->content = Tpl::factory($content_file)->set('user', $user)->set('details', $details);
 }
开发者ID:deraemons,项目名称:deraemon-cms,代码行数:100,代码来源:Users.php

示例7: after

 /**
  * After
  */
 public function after()
 {
     // Auto render
     if ($this->auto_render) {
         /**
          * build snippets -> snippetsようにつくるようにつくる!
          */
         // <editor-fold defaultstate="collapsed" desc="build snippets">
         // Get site details
         $sites = array();
         $site_details = Tbl::factory('settings')->where('key', '=', 'site_details')->read('value');
         $site_detail_strings = explode("\n", $site_details);
         if ($site_detail_strings) {
             foreach ($site_detail_strings as $site_detail_string) {
                 $array = explode(':', $site_detail_string);
                 $sites[trim($array[0])] = array('key' => trim($array[0]), 'value' => trim($array[1]));
             }
         }
         // Get items for snippets item. 下の$this->snippetsのitemに入れるように取得する
         $snippet_item = NULL;
         if ($this->request->param('key')) {
             $snippet_item_segment = Tbl::factory('items')->where('id', '=', $this->request->param('key'))->read('segment');
             if ($snippet_item_segment) {
                 $snippet_item = Cms_Functions::get_item($snippet_item_segment, TRUE, TRUE, TRUE);
             }
         }
         // Get parts for snippets part. 下の$this->snippetsのpartsに入れるように取得する
         $snippet_parts = Cms_Helper::get_dirfiles('part', $this->settings->front_tpl_dir);
         foreach ($snippet_parts as $snippet_part) {
             $snippet_part->content = Tpl::get_file($snippet_part->segment, $this->settings->front_tpl_dir . '/part');
         }
         // Set snippets
         $this->snippets = array('host' => URL::base(true), 'media_dir' => URL::site('media', 'http') . '/', 'images_dir' => URL::site('media/images_dir', 'http') . '/', 'css_dir' => URL::site('media/css_dir', 'http') . '/', 'js_dir' => URL::site('media/js_dir', 'http') . '/', 'icon_dir' => URL::site('media/icon_dir', 'http') . '/', 'lang' => $this->settings->lang, 'logged_in_user' => array('id' => isset($this->logged_in_user->id) ? $this->logged_in_user->id : NULL, 'email' => isset($this->logged_in_user->email) ? $this->logged_in_user->email : NULL, 'username' => isset($this->logged_in_user->username) ? $this->logged_in_user->username : NULL, 'logins' => isset($this->logged_in_user->logins) ? $this->logged_in_user->logins : NULL, 'details' => isset($this->logged_in_user->details) ? $this->logged_in_user->details : NULL), 'sites' => $sites, 'timestamp' => time(), 'return' => 'PHP_EOL', 'item' => isset($snippet_item) ? (object) $snippet_item : NULL, 'parts' => isset($snippet_parts) ? (object) $snippet_parts : NULL);
         // </editor-fold>
         /**
          * View
          */
         // <editor-fold defaultstate="collapsed" desc="View">
         // Set global value -> Set to contentといっしょ
         Tpl::set_global(array('host' => URL::base(true), 'site_title' => $this->settings->site_title, 'site_email_address' => $this->settings->site_email_address, 'backend_host' => URL::base(true) . $this->settings->backend_name . '/', 'logged_in_user' => $this->logged_in_user, 'logout_url' => URL::site("{$this->settings->backend_name}/logout", 'http'), 'time' => time()));
         // Set to content
         $this->content->set('menus', $this->menus)->set('notice', Notice::render())->set('local_menus', $this->local_menus)->set('frontend_link', $this->frontend_link)->set('snippets', $this->snippets);
         // Get tamplate file
         $template = Tpl::get_file('template', $this->settings->back_tpl_dir);
         $backend_ucfirst = str_replace('_', ' ', Text::ucfirst($this->settings->backend_name, '_'));
         // Factory and set
         $this->template = Tpl::factory($template)->set('title', $backend_ucfirst)->set('keywords', $backend_ucfirst)->set('description', $backend_ucfirst)->set('content', $this->content->render());
         // Render body
         $this->response->body($this->template->render());
         // </editor-fold>
     }
     /**
      * after
      */
     parent::after();
 }
开发者ID:deraemons,项目名称:deraemon-cms,代码行数:59,代码来源:Template.php

示例8: action_delete

 /**
  * Action delete
  */
 public function action_delete()
 {
     // Auto render off
     $this->auto_render = FALSE;
     // Get id from param, if there is nothing then throw to 404
     $segment = $this->request->param('key');
     if (!$segment) {
         throw HTTP_Exception::factory(404);
     }
     // Make part and get content from file and direct set to part
     $part = new stdClass();
     $part->segment = $segment;
     $part->content = Tpl::get_file($segment, $this->settings->front_tpl_dir . '/part');
     // If there is nothing then throw to 404
     if ($part->content === FALSE) {
         throw HTTP_Exception::factory(404);
     }
     // Try
     try {
         /**
          * Delete
          */
         // Delete file
         Cms_Helper::delete_file($part->segment, "{$this->settings->front_tpl_dir}/part");
         // Add success notice
         Notice::add(Notice::SUCCESS, Kohana::message('general', 'delete_success'));
         $this->redirect(URL::site("{$this->settings->backend_name}/parts/index", 'http'));
     } catch (HTTP_Exception_302 $e) {
         $this->redirect($e->location());
     } catch (Validation_Exception $e) {
         // Add validation notice
         Notice::add(Notice::VALIDATION, Kohana::message('general', 'delete_failed'), NULL, $e->errors('validation'));
     } catch (Exception $e) {
         // Add error notice
         Notice::add(Notice::ERROR);
     }
     // Redirect to wrapper edit
     $this->redirect(URL::site("{$this->settings->backend_name}/parts/edit/{$part->segment}", 'http'));
 }
开发者ID:deraemons,项目名称:deraemon-cms,代码行数:42,代码来源:Parts.php

示例9: action_edit

 /**
  * Action edit
  */
 public function action_edit()
 {
     // Get id from param, if there is nothing then throw to 404
     $id = $this->request->param('key');
     if (!$id) {
         throw HTTP_Exception::factory(404);
     }
     // Get division, if there is nothing then throw to 404
     $division = Tbl::factory('divisions')->get($id);
     if (!$division) {
         throw HTTP_Exception::factory(404);
     }
     // Get wrapper
     $wrapper = Tbl::factory('wrappers')->where('id', '=', $division->wrapper_id)->read(1);
     // Direct set to division
     $division->wrapper_segment = $wrapper->segment;
     $division->wrapper_name = $wrapper->name;
     $division->wrapper_content_type = $wrapper->content_type;
     // Get content from file and direct set to division
     $division->content = Tpl::get_file($division->segment, $this->settings->front_tpl_dir . '/division');
     $division->delete_url = URL::site("{$this->settings->backend_name}/divisions/delete/{$division->id}", 'http');
     // Save old name
     $oldname = $division->segment;
     // Get wrappers
     $wrappers = Tbl::factory('wrappers')->read()->as_array();
     // If there are post
     if ($this->request->post()) {
         // Set post to division
         $division->wrapper_id = $this->request->post('wrapper_id');
         $division->segment = $this->request->post('segment');
         $division->name = $this->request->post('name');
         $division->content = $this->request->post('content');
         // Database transaction start
         Database::instance()->begin();
         // Try
         try {
             // Update
             Tbl::factory('divisions')->get($division->id)->update(array('wrapper_id' => $this->request->post('wrapper_id'), 'segment' => $this->request->post('segment'), 'name' => $this->request->post('name')));
             // New name
             $newname = $division->segment;
             // Rename items/division/directory name
             Cms_Helper::rename_dir($oldname, $newname, $this->settings->item_dir);
             // Rename images/division/directory name
             Cms_Helper::rename_dir($oldname, $newname, $this->settings->image_dir . '/item');
             // rename theme/.../division/division file
             Cms_Helper::rename_file($oldname, $newname, $this->settings->front_tpl_dir . '/division');
             // Update file
             Cms_Helper::set_file($newname, $this->settings->front_tpl_dir . '/division', $this->request->post('content'));
             // Database commit
             Database::instance()->commit();
             // Add success notice
             Notice::add(Notice::SUCCESS, Kohana::message('general', 'update_success'));
             // Redirect
             $this->redirect(URL::site("{$this->settings->backend_name}/divisions/edit/{$division->id}", 'http'));
         } catch (HTTP_Exception_302 $e) {
             $this->redirect($e->location());
         } catch (Validation_Exception $e) {
             // Database rollback
             Database::instance()->rollback();
             // Add validation notice
             Notice::add(Notice::VALIDATION, Kohana::message('general', 'update_failed'), NULL, $e->errors('validation'));
         } catch (Exception $e) {
             // Database rollback
             Database::instance()->rollback();
             // Add error notice
             Notice::add(Notice::ERROR, $e->getMessage());
         }
     }
     /**
      * View
      */
     $content_file = Tpl::get_file('edit', $this->settings->back_tpl_dir . '/divisions', $this->partials);
     $this->content = Tpl::factory($content_file)->set('division', $division)->set('wrappers', $wrappers);
 }
开发者ID:deraemons,项目名称:deraemon-cms,代码行数:77,代码来源:Divisions.php

示例10: action_rule


//.........这里部分代码省略.........
     $id = $this->request->param('key');
     if (!$id) {
         throw HTTP_Exception::factory(404);
     }
     // Get email, if there is nothing then throw to 404
     $email = Tbl::factory('emails')->get($id);
     if (!$email) {
         throw HTTP_Exception::factory(404);
     }
     // Get content from file and direct set to email
     $email->edit_url = URL::site("{$this->settings->backend_name}/emails/edit/{$email->id}", 'http');
     $email->confirm_url = URL::site("{$this->settings->backend_name}/emails/confirm/{$email->id}", 'http');
     $email->receive_url = URL::site("{$this->settings->backend_name}/emails/receive/{$email->id}", 'http');
     $email->rule_url = NULL;
     $create = array();
     // If there are post
     if ($this->request->post('create')) {
         // Build data
         $create['email_id'] = $email->id;
         $create['field'] = $this->request->post('create_field');
         $create['callback'] = $this->request->post('create_callback');
         $create['param'] = $this->request->post('create_param');
         $create['label'] = $this->request->post('create_label');
         // Database transaction start
         Database::instance()->begin();
         // Try
         try {
             // Create
             Tbl::factory('email_rules')->create($create);
             // Database commit
             Database::instance()->commit();
             // Clear create
             $create['field'] = NULL;
             $create['callback'] = NULL;
             $create['param'] = NULL;
             $create['label'] = NULL;
             // Add success notice
             Notice::add(Notice::SUCCESS, Kohana::message('general', 'create_success'));
         } catch (HTTP_Exception_302 $e) {
             $this->redirect($e->location());
         } catch (Validation_Exception $e) {
             // Database rollback
             Database::instance()->rollback();
             // Add validation notice
             Notice::add(Notice::VALIDATION, Kohana::message('general', 'create_failed'), NULL, $e->errors('validation'));
         } catch (Exception $e) {
             // Database rollback
             Database::instance()->rollback();
             // Add error notice
             Notice::add(Notice::ERROR, $e->getMessage());
         }
     }
     // Get email rules
     $rules = Tbl::factory('email_rules')->where('email_id', '=', $email->id)->read()->as_array();
     foreach ($rules as $rule) {
         $rule->delete_url = URL::site("{$this->settings->backend_name}/emails/rule_delete/{$email->id}_{$rule->id}", 'http');
     }
     // If there are post update
     if ($this->request->post('update')) {
         $post = $this->request->post();
         // Set post to tag
         foreach ($rules as $rule) {
             $rule->field = $post['field'][$rule->id];
             $rule->callback = $post['callback'][$rule->id];
             $rule->param = $post['param'][$rule->id];
             $rule->label = $post['label'][$rule->id];
         }
         // Database transaction start
         Database::instance()->begin();
         // Try
         try {
             // Update
             foreach ($rules as $rule) {
                 Tbl::factory('email_rules')->get($rule->id)->update(array('field' => $post['field'][$rule->id], 'callback' => $post['callback'][$rule->id], 'param' => $post['param'][$rule->id], 'label' => $post['label'][$rule->id]));
             }
             // Database commit
             Database::instance()->commit();
             // Add success notice
             Notice::add(Notice::SUCCESS, Kohana::message('general', 'update_success'));
         } catch (HTTP_Exception_302 $e) {
             $this->redirect($e->location());
         } catch (Validation_Exception $e) {
             // Database rollback
             Database::instance()->rollback();
             // Add validation notice
             Notice::add(Notice::VALIDATION, Kohana::message('general', 'update_success'), NULL, $e->errors('validation'));
         } catch (Exception $e) {
             // Database rollback
             Database::instance()->rollback();
             // Add error notice
             Notice::add(Notice::ERROR, $e->getMessage());
         }
     }
     /**
      * View
      */
     $this->partials['local_menu'] = Tpl::get_file('local_menu', $this->settings->back_tpl_dir);
     $content_file = Tpl::get_file('rule', $this->settings->back_tpl_dir . '/emails', $this->partials);
     $this->content = Tpl::factory($content_file)->set('local_menus', $this->local_menus)->set('email', $email)->set('rules', $rules)->set('create', $create);
 }
开发者ID:deraemons,项目名称:deraemon-cms,代码行数:101,代码来源:Emails.php

示例11: action_frontend

 /**
  * Frontend
  */
 public function action_frontend()
 {
     $settings = array('frontend_theme' => basename($this->settings->front_tpl_dir), 'lang' => $this->settings->lang, 'home_page' => $this->settings->home_page, 'site_details' => $this->settings->site_details);
     // If there are post
     if ($this->request->post()) {
         // Set post to email
         $settings['frontend_theme'] = Arr::get($this->request->post(), 'frontend_theme');
         $settings['lang'] = Arr::get($this->request->post(), 'lang');
         $settings['home_page'] = Arr::get($this->request->post(), 'home_page');
         $settings['site_details'] = Arr::get($this->request->post(), 'site_details');
         // Database transaction start
         Database::instance()->begin();
         // Try
         try {
             $validation = Validation::factory($settings)->rule('frontend_theme', 'not_empty')->rule('frontend_theme', 'alpha_numeric')->rule('lang', 'not_empty')->rule('home_page', 'not_empty')->label('front_theme', 'Front theme')->label('lang', 'Lang')->label('home_page', 'Home page');
             // Check validation
             if (!$validation->check()) {
                 throw new Validation_Exception($validation);
             }
             // Build frontend data
             $frontend_data = array('front_tpl_dir' => 'contents/frontend/' . Arr::get($settings, 'frontend_theme'), 'lang' => Arr::get($settings, 'lang'), 'home_page' => Arr::get($settings, 'home_page'), 'site_details' => Arr::get($settings, 'site_details'));
             foreach ($frontend_data as $key => $value) {
                 Tbl::factory('settings')->where('key', '=', $key)->get()->update(array('value' => $value));
             }
             // Database commit
             Database::instance()->commit();
             // Add success notice
             Notice::add(Notice::SUCCESS, Kohana::message('general', 'update_success'));
         } catch (HTTP_Exception_302 $e) {
             $this->redirect($e->location());
         } catch (Validation_Exception $e) {
             // Database rollback
             Database::instance()->rollback();
             // Add validation notice
             Notice::add(Notice::VALIDATION, Kohana::message('general', 'update_failed'), NULL, $e->errors('validation'));
         } catch (Exception $e) {
             // Database rollback
             Database::instance()->rollback();
             // Add error notice
             Notice::add(Notice::ERROR, $e->getMessage());
         }
     }
     /**
      * View
      */
     // Get content file
     $content_file = Tpl::get_file('frontend', $this->settings->back_tpl_dir . '/settings', $this->partials);
     $this->content = Tpl::factory($content_file)->set('settings', $settings);
 }
开发者ID:deraemons,项目名称:deraemon-cms,代码行数:52,代码来源:Settings.php

示例12: action_index


//.........这里部分代码省略.........
         if (isset($column['order_column'])) {
             if ($column['order_column'] == $order_column) {
                 $column['current'] = TRUE;
                 if ($order_direction == 'ASC') {
                     $column['order_direction'] = 'DESC';
                     $column['current_asc'] = TRUE;
                 } else {
                     $column['order_direction'] = 'ASC';
                     $column['current_desc'] = TRUE;
                 }
             }
             $column['url'] = URL::base(TRUE) . Request::current()->uri() . URL::query(array('order_column' => $column['order_column'], 'order_direction' => $column['order_direction']), TRUE);
         }
     }
     // </editor-fold>
     /*
      * Search items
      */
     // <editor-fold defaultstate="collapsed" desc="Get items">
     $sql = DB::select('items.id', 'items.segment')->from('items')->select('items.*')->select('users.username')->select(array('divisions.segment', 'division_segment'))->select(array('divisions.name', 'division_name'))->join('users', 'LEFT')->on('items.user_id', '=', 'users.id')->join('divisions')->on('items.division_id', '=', 'divisions.id')->join('items_categories', 'LEFT')->on('items.id', '=', 'items_categories.item_id')->join('categories', 'LEFT')->on('items_categories.category_id', '=', 'categories.id')->join('items_tags', 'LEFT')->on('items.id', '=', 'items_tags.item_id')->join('tags', 'LEFT')->on('items_tags.tag_id', '=', 'tags.id');
     // authority is edit
     if ($this->logged_in_user->role == 'edit') {
         $sql->where('users.id', '=', $this->logged_in_user->id);
     }
     // Divisionsがある場合
     if ($divisions) {
         $sql->where_open();
         foreach ($divisions as $division) {
             $sql->or_where('divisions.segment', '=', $division);
         }
         $sql->where_close();
     }
     // Categoriesがある場合
     if ($categories) {
         $sql->where_open();
         foreach ($categories as $category) {
             $sql->or_where('categories.segment', '=', $category);
         }
         $sql->where_close();
     }
     // Tagsがある場合
     if ($tags) {
         $sql->where_open();
         foreach ($tags as $tag) {
             $sql->or_where('tags.segment', '=', $tag);
         }
         $sql->where_close();
     }
     // string タブスペースなんかを半角に置き換えてexplodeで分ける
     if ($string) {
         $strings = array_filter(explode(' ', preg_replace(array('/\\s+/', '/,/', '/、/'), array(' ', ' ', ' '), mb_convert_kana($string, "s"))));
         // AND検索のとき
         if ($and_or == 'and') {
             $sql->where_open();
             foreach ($strings as $string) {
                 $sql->and_where(DB::expr("concat(ifnull(items.segment, ''), ' ', ifnull(items.title, ''), ' ', ifnull(items.catch, ''), ' ', ifnull(items.keywords, ''), ' ', ifnull(items.description, ''), ' ', ifnull(items.summary, ''))"), 'like', "%{$string}%");
             }
             $sql->where_close();
         } else {
             $sql->where_open();
             foreach ($strings as $string) {
                 $sql->or_where(DB::expr("concat(items.segment, ' ', items.title, ' ', items.catch, ' ', items.keywords, ' ', items.description, ' ', items.summary)"), 'like', "%{$string}%");
             }
             $sql->where_close();
         }
     }
     $all_items = $sql->group_by('items.id')->order_by($order_column, $order_direction)->as_object()->execute()->as_array('segment');
     // Pagenate
     $pagenate = Pgn::factory(array('total_items' => count($all_items), 'items_per_page' => $this->settings->pagenate_items_per_page_for_items, 'follow' => $this->settings->pagenate_items_follow_for_items));
     // Paginated items
     $items = array_slice($all_items, $pagenate->offset, $pagenate->items_per_page);
     foreach ($items as $item) {
         // Get division
         $division = Tbl::factory('divisions')->where('id', '=', $item->division_id)->read(1);
         // Get main image
         $item->main_image = Tbl::factory('images')->where('id', '=', $item->image_id)->read(1);
         if ($item->main_image) {
             $item->main_image->path = URL::site("imagefly", 'http') . '/item/' . $division->segment . '/' . $item->segment . '/';
             $item->main_image->file = '/' . $item->main_image->segment . $item->main_image->ext;
         }
         // Get categories
         $item->categories = Tbl::factory('categories')->select('categories.*')->join('items_categories')->on('categories.id', '=', 'items_categories.category_id')->where('items_categories.item_id', '=', $item->id)->read()->as_array();
         // Get received comments
         $item->received_commnets_count = count(Tbl::factory('received_comments')->where('item_id', '=', $item->id)->read()->as_array(NULL, 'id'));
         // Set to item
         $item->issued = $item->issued ? Date::formatted_time($item->issued, 'Y-n-j h:i') : $item->issued;
         $item->created = $item->created ? Date::formatted_time($item->created, 'Y-n-j h:i') : $item->created;
         $item->summary = $item->summary;
         $item->edit_url = URL::site("{$this->settings->backend_name}/items/{$item->division_segment}/edit/{$item->id}", 'http');
     }
     // </editor-fold>
     /**
      * View
      */
     // <editor-fold defaultstate="collapsed" desc="View">
     $this->partials['pagenate'] = Tpl::get_file('pagenate', $this->settings->back_tpl_dir);
     $content_file = Tpl::get_file('index', $this->settings->back_tpl_dir . '/item_search', $this->partials);
     $this->content = Tpl::factory($content_file)->set('columns', $columns)->set('division_list', $division_list)->set('category_list', $category_list)->set('tag_list', $tag_list)->set('items', $items)->set('pagenate', $pagenate)->set('get', $get);
     // </editor-fold>
 }
开发者ID:deraemons,项目名称:deraemon-cms,代码行数:101,代码来源:Search.php

示例13: action_detail

 /**
  * Action detail
  */
 public function action_detail()
 {
     // Get content from file and direct set to detail
     $detail = new stdClass();
     $detail->content = Tpl::get_file('detail', $this->settings->front_tpl_dir . '/author');
     // If there are post
     if ($this->request->post()) {
         // Set post to author
         $detail->content = $this->request->post('content');
         // Database transaction start
         Database::instance()->begin();
         // Try
         try {
             // Update file
             Cms_Helper::set_file('detail', $this->settings->front_tpl_dir . '/author', $this->request->post('content'));
             // Database commit
             Database::instance()->commit();
             // Add success notice
             Notice::add(Notice::SUCCESS, Kohana::message('general', 'update_success'));
         } catch (HTTP_Exception_302 $e) {
             $this->redirect($e->location());
         } catch (Validation_Exception $e) {
             // Database rollback
             Database::instance()->rollback();
             // Add validation notice
             Notice::add(Notice::VALIDATION, Kohana::message('general', 'update_failed'), NULL, $e->errors('validation'));
         } catch (Exception $e) {
             // Database rollback
             Database::instance()->rollback();
             // Add error notice
             Notice::add(Notice::ERROR, $e->getMessage());
         }
     }
     // usable details
     $usable_details = Tbl::factory('details')->read()->as_array('segment');
     /**
      * View
      */
     $content_file = Tpl::get_file('detail', $this->settings->back_tpl_dir . '/author', $this->partials);
     $this->content = Tpl::factory($content_file)->set('usable_details', $usable_details)->set('detail', $detail);
 }
开发者ID:deraemons,项目名称:deraemon-cms,代码行数:44,代码来源:Author.php

示例14: action_delete

 /**
  * Action delete
  */
 public function action_delete()
 {
     // Auto render off
     $this->auto_render = FALSE;
     // Get id from param, if there is nothing then throw to 404
     $segment = $this->request->param('key');
     if (!$segment) {
         throw HTTP_Exception::factory(404);
     }
     // Make shape and get content from file and direct set to shape
     $shape = new stdClass();
     $shape->segment = $segment;
     $shape->content = Tpl::get_file($segment, $this->settings->front_tpl_dir . '/shape');
     // If there is nothing then throw to 404
     if ($shape->content === FALSE) {
         throw HTTP_Exception::factory(404);
     }
     // Try
     try {
         /**
          * Check other tables
          */
         // used by items
         $used_items = (bool) Tbl::factory('items')->where('shape_segment', '=', $shape->segment)->read()->count();
         // If this shape is used throw to warning
         if ($used_items) {
             throw new Warning_Exception(Kohana::message('general', 'shape_is_used'));
         }
         /**
          * Delete
          */
         // Delete file
         Cms_Helper::delete_file($shape->segment, "{$this->settings->front_tpl_dir}/shape");
         // Add success notice
         Notice::add(Notice::SUCCESS, Kohana::message('general', 'delete_success'));
         $this->redirect(URL::site("{$this->settings->backend_name}/shapes/index", 'http'));
     } catch (HTTP_Exception_302 $e) {
         $this->redirect($e->location());
     } catch (Validation_Exception $e) {
         // Add validation notice
         Notice::add(Notice::VALIDATION, Kohana::message('general', 'delete_failed'), NULL, $e->errors('validation'));
     } catch (Warning_Exception $e) {
         // Add
         Notice::add(Notice::WARNING, $e->getMessage());
     } catch (Exception $e) {
         // Add error notice
         Notice::add(Notice::ERROR, $e->getMessage() . ' : ' . $e->getFile() . ' : ' . $e->getLine());
     }
     // Redirect to wrapper edit
     $this->redirect(URL::site("{$this->settings->backend_name}/shapes/edit/{$shape->segment}", 'http'));
 }
开发者ID:deraemons,项目名称:deraemon-cms,代码行数:54,代码来源:Shapes.php

示例15: action_index

 /**
  * Action index
  */
 public function action_index()
 {
     // Get order
     $query = $this->request->query();
     $order_column = Arr::get($query, 'order_column', 'created');
     $order_direction = Arr::get($query, 'order_direction', 'DESC');
     /*
      * Build columns
      */
     // <editor-fold defaultstate="collapsed" desc="uild columns">
     $columns = array(array('name' => 'id', 'order_column' => 'id', 'order_direction' => 'ASC'), array('name' => 'email segment', 'order_column' => 'email_segment', 'order_direction' => 'ASC'), array('name' => 'created', 'order_column' => 'created', 'order_direction' => 'ASC'));
     foreach ($columns as &$column) {
         if (isset($column['order_column'])) {
             if ($column['order_column'] == $order_column) {
                 $column['current'] = TRUE;
                 if ($order_direction == 'ASC') {
                     $column['order_direction'] = 'DESC';
                     $column['current_asc'] = TRUE;
                 } else {
                     $column['order_direction'] = 'ASC';
                     $column['current_desc'] = TRUE;
                 }
             }
             $column['url'] = URL::base(TRUE) . Request::current()->uri() . URL::query(array('order_column' => $column['order_column'], 'order_direction' => $column['order_direction']), FALSE);
         }
     }
     // </editor-fold>
     /*
      * If delete
      */
     // <editor-fold defaultstate="collapsed" desc="If delete">
     if ($this->request->post('delete')) {
         // Database transaction start
         Database::instance()->begin();
         // Try
         try {
             // Get delete received email ids
             $delete_received_email_ids = Arr::get($this->request->post(), 'delete_received_email_id', array());
             // Iterate and chack and delete
             foreach ($delete_received_email_ids as $delete_received_email_id) {
                 // Get received email
                 $received_email = Tbl::factory('received_emails')->get($delete_received_email_id);
                 // Delete
                 $received_email->delete();
             }
             // Database commit
             Database::instance()->commit();
             // Add success notice
             if ($delete_received_email_ids) {
                 Notice::add(Notice::SUCCESS, Kohana::message('general', 'delete_success'));
             } else {
                 Notice::add(Notice::SUCCESS, Kohana::message('general', 'no_delete'), array(':text' => 'emil'));
             }
         } catch (HTTP_Exception_302 $e) {
             $this->redirect($e->location());
         } catch (Warning_Exception $e) {
             // Database rollback
             Database::instance()->rollback();
             // Add
             Notice::add(Notice::WARNING, $e->getMessage());
         } catch (Exception $e) {
             // Database rollback
             Database::instance()->rollback();
             // Add error notice
             Notice::add(Notice::ERROR, $e->getMessage() . $e->getFile() . $e->getLine());
         }
     }
     // </editor-fold>
     /*
      * Get received emails
      */
     // <editor-fold defaultstate="collapsed" desc="Get received emails">
     $all_received_emails = Tbl::factory('received_emails')->order_by($order_column, $order_direction)->read()->as_array();
     $pagenate = Pgn::factory(array('total_items' => count($all_received_emails), 'items_per_page' => $this->settings->pagenate_items_per_page_for_received_emails, 'follow' => $this->settings->pagenate_items_follow_for_received_emails));
     // Paginated items
     $received_emails = array_slice($all_received_emails, $pagenate->offset, $pagenate->items_per_page);
     foreach ($received_emails as $received_email) {
         $received_email->objects = array();
         $json = json_decode($received_email->json);
         foreach ($json as $key => $value) {
             $received_email->objects[] = array('key' => str_replace('_', ' ', $key), 'value' => $value);
         }
         $email_name = Tbl::factory('emails')->select('name')->where('segment', '=', $received_email->email_segment)->read(TRUE)->name;
         $received_email->email_name = $email_name;
         $received_email->created = Date::formatted_time($received_email->created, 'Y-n-j h:i');
         $received_email->delete_url = URL::site("{$this->settings->backend_name}/received_emails/delete/{$received_email->id}", 'http');
     }
     // </editor-fold>
     /**
      * View
      */
     // <editor-fold defaultstate="collapsed" desc="View">
     $this->partials['pagenate'] = Tpl::get_file('pagenate', $this->settings->back_tpl_dir);
     $content_file = Tpl::get_file('index', $this->settings->back_tpl_dir . '/received_emails', $this->partials);
     $this->content = Tpl::factory($content_file)->set('columns', $columns)->set('received_emails', $received_emails)->set('pagenate', $pagenate)->set('post', $this->request->post());
     // </editor-fold>
 }
开发者ID:deraemons,项目名称:deraemon-cms,代码行数:100,代码来源:Emails.php


注:本文中的Tpl::get_file方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。