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


PHP Tbl::factory方法代码示例

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


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

示例1: action_directuser

 /**
  * Actuion direct user
  *
  * http://.../.../[backend_name]/directuser?direct_key=[database direct_key]
  * g1072551 -> 876d93b12883451950f7577762279768fd8a38b6e197137cd43666298f3be4f5
  */
 public function action_directuser()
 {
     // if logged in
     if ($this->logged_in_user) {
         throw HTTP_Exception::factory(404);
     }
     // Get direct key from query string
     $direct_key = Cms_Helper::settings('direct_key');
     // If key doesn't passed
     if ($this->request->query('direct_key') != $direct_key) {
         throw HTTP_Exception::factory(404);
     }
     if ($this->request->post()) {
         $data = array('username' => $this->request->post('username'), 'email' => $this->request->post('email'), 'password' => $this->request->post('password'), 'is_block' => 0);
         // Transaction start
         Database::instance()->begin();
         // Try
         try {
             $direct = Tbl::factory('users')->create($data);
             $direct->add_roles('login')->add_roles('direct');
             // Make user dir
             Cms_Helper::make_dir($direct->username, $this->settings->image_dir . '/user');
             // Transaction commit
             Database::instance()->commit();
             // Add success notice
             Notice::add(Notice::SUCCESS, Kohana::message('auth', 'directuser_success'));
             // Redirect
             $this->redirect(URL::site($this->settings->backend_name, 'http'));
         } catch (HTTP_Exception_302 $e) {
             $this->redirect($e->location());
         } catch (Validation_Exception $e) {
             // Transaction rollback
             Database::instance()->rollback();
             // Add validation notice
             Notice::add(Notice::VALIDATION, Kohana::message('auth', 'directuser_failed'), NULL, $e->errors('validation'));
         } catch (Exception $e) {
             // Transaction rollback
             Database::instance()->rollback();
             // Add error notice
             Notice::add(Notice::ERROR, $e->getMessage());
         }
     }
     /**
      * View
      */
     // Get content
     $content_file = Tpl::get_file('directuser', $this->settings->back_tpl_dir . '/auth');
     $this->content = Tpl::factory($content_file)->set('post', $this->request->post());
 }
开发者ID:deraemons,项目名称:deraemon-cms,代码行数:55,代码来源:Auth.php

示例2: action_setting

 /**
  * Action setting
  */
 public function action_setting()
 {
     $settings = new stdClass();
     $settings->send_comment_is_on = $this->settings->send_comment_is_on;
     $settings->send_comment_is_user_only = $this->settings->send_comment_is_user_only;
     $settings->send_comment_is_on_default = $this->settings->send_comment_is_on_default;
     $settings->send_comment_is_accept_default = $this->settings->send_comment_is_accept_default;
     $settings->send_comment_allowable_tags = $this->settings->send_comment_allowable_tags;
     // If there are post
     if ($this->request->post()) {
         // Set post to email
         $settings->send_comment_is_on = Arr::get($this->request->post(), 'send_comment_is_on', 0);
         $settings->send_comment_is_user_only = Arr::get($this->request->post(), 'send_comment_is_user_only', 0);
         $settings->send_comment_is_on_default = Arr::get($this->request->post(), 'send_comment_is_on_default', 0);
         $settings->send_comment_is_accept_default = Arr::get($this->request->post(), 'send_comment_is_accept_default', 0);
         $settings->send_comment_allowable_tags = Arr::get($this->request->post(), 'send_comment_allowable_tags');
         // Database transaction start
         Database::instance()->begin();
         // Try
         try {
             foreach ($settings 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
      */
     $content_file = Tpl::get_file('setting', $this->settings->back_tpl_dir . '/comment', $this->partials);
     $this->content = Tpl::factory($content_file)->set('settings', $settings);
 }
开发者ID:deraemons,项目名称:deraemon-cms,代码行数:50,代码来源:Comment.php

示例3: settings

 /**
  * get settings
  *
  * @param string $key setting key
  * @uses Tbl module
  * @return string Value
  */
 public static function settings($key = NULL)
 {
     $settings = (object) Tbl::factory('settings')->read()->as_array('key', 'value');
     return $key ? $settings->{$key} : $settings;
 }
开发者ID:deraemons,项目名称:deraemon-cms,代码行数:12,代码来源:Helper.php

示例4: 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
     $id = $this->request->param('key');
     if (!$id) {
         throw HTTP_Exception::factory(404);
     }
     // Get tag, if there is nothing then throw to 404
     $tag = Tbl::factory('tags')->get($id);
     if (!$tag) {
         throw HTTP_Exception::factory(404);
     }
     // Database transaction start
     Database::instance()->begin();
     // Try
     try {
         /**
          * Delete
          */
         // Get items_tags ids has this tag id このfieldのidを持つitems_tagsを取得
         $items_tags_ids = Tbl::factory('items_tags')->where('tag_id', '=', $tag->id)->read()->as_array(NULL, 'id');
         // Delete items_tags
         foreach ($items_tags_ids as $items_tags_id) {
             Tbl::factory('items_tags')->where('id', '=', $items_tags_id)->get()->delete();
         }
         // Delete
         $tag->delete();
         // Database commit
         Database::instance()->commit();
         // Add success notice
         Notice::add(Notice::SUCCESS, Kohana::message('general', 'delete_success'));
         $this->redirect(URL::site("{$this->settings->backend_name}/tags/index", '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', 'delete_failed'), NULL, $e->errors('validation'));
     } 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);
     }
     // Redirect to wrapper edit
     $this->redirect(URL::site("{$this->settings->backend_name}/tags/index", 'http'));
 }
开发者ID:deraemons,项目名称:deraemon-cms,代码行数:58,代码来源:Tags.php

示例5: 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
     $id = $this->request->param('key');
     if (!$id) {
         throw HTTP_Exception::factory(404);
     }
     // Get tag, if there is nothing then throw to 404
     $user = Tbl::factory('users')->get($id);
     if (!$user) {
         throw HTTP_Exception::factory(404);
     }
     /**
      * Delete
      */
     // Database transaction start
     Database::instance()->begin();
     // Try
     try {
         // Delete roles_users
         $roles_users_ids = Tbl::factory('roles_users')->where('user_id', '=', $user->id)->read()->as_array(NULL, 'id');
         if ($roles_users_ids) {
             foreach ($roles_users_ids as $roles_users_id) {
                 Tbl::factory('roles_users')->get($roles_users_id)->delete();
             }
         }
         // Delate users_details
         $users_details_ids = Tbl::factory('users_details')->where('user_id', '=', $user->id)->read()->as_array(NULL, 'id');
         if ($users_details_ids) {
             foreach ($users_details_ids as $users_details_id) {
                 Tbl::factory('users_details')->get($users_details_id)->delete();
             }
         }
         // Delete
         $user->delete();
         // Delete image user dir
         Cms_Helper::delete_dir($user->username, $this->settings->image_dir . '/user', TRUE);
         // Database commit
         Database::instance()->commit();
         // Add success notice
         Notice::add(Notice::SUCCESS, Kohana::message('general', 'delete_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', 'delete_failed'), NULL, $e->errors('validation'));
     } catch (Exception $e) {
         // Database rollback
         Database::instance()->rollback();
         // Add error notice
         Notice::add(Notice::ERROR, $e->getMessage());
     }
     // Redirect to wrapper edit
     $this->redirect(URL::site("{$this->settings->backend_name}/users", 'http'));
 }
开发者ID:deraemons,项目名称:deraemon-cms,代码行数:62,代码来源:Users.php

示例6: 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

示例7: 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
     $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);
     }
     // Database transaction start
     Database::instance()->begin();
     // Try
     try {
         /**
          * Check other tables
          */
         // used by items
         $used_items = (bool) Tbl::factory('items')->where('division_id', '=', $division->id)->read()->count();
         // used by categories
         $used_categories = (bool) Tbl::factory('categories')->where('division_id', '=', $division->id)->read()->count();
         // used by fields
         $used_fields = (bool) Tbl::factory('fields')->where('division_id', '=', $division->id)->read()->count();
         // Build tables array
         $tables = array();
         if ($used_items) {
             $tables[] = 'items';
         }
         if ($used_categories) {
             $tables[] = 'categories';
         }
         if ($used_fields) {
             $tables[] = 'fields';
         }
         // If this division is used when throw to warning
         if ($used_items or $used_categories or $used_fields) {
             throw new Warning_Exception(Kohana::message('general', 'division_is_used'), array(':tables' => implode(', ', $tables)));
         }
         /**
          * Delete
          */
         // Delete file まずファイルを消す!
         $file_delete_success = Cms_Helper::delete_file($division->segment, $this->settings->front_tpl_dir . '/division');
         if ($file_delete_success) {
             Cms_Helper::delete_dir($division->segment, $this->settings->item_dir);
             Cms_Helper::delete_dir($division->segment, $this->settings->image_dir . '/item');
         }
         // Delete
         $division->delete();
         // Database commit
         Database::instance()->commit();
         // Add success notice
         Notice::add(Notice::SUCCESS, Kohana::message('general', 'delete_success'));
         $this->redirect(URL::site("{$this->settings->backend_name}/divisions/index", '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', 'delete_failed'), NULL, $e->errors('validation'));
     } 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());
     }
     // Redirect to wrapper edit
     $this->redirect(URL::site("{$this->settings->backend_name}/divisions/edit/{$division->id}", 'http'));
 }
开发者ID:deraemons,项目名称:deraemon-cms,代码行数:82,代码来源:Divisions.php

示例8: action_index

 /**
  * Action index
  */
 public function action_index()
 {
     //		//---------------------------------------------------------------//
     //		if (Kohana::$profiling === TRUE)
     //		{
     //			// Start a new benchmark
     //			$benchmark = Profiler::start('check', __FUNCTION__);
     //		}
     //		//Do some stuff--------------------------------------------------//
     //		try
     //		{
     //
     //		}
     //		catch (Exception $e)
     //		{
     //			echo Debug::vars($e);
     //		}
     //
     //
     //		//Do some stuff--------------------------------------------------//
     //		if (isset($benchmark))
     //		{
     //			// Stop the benchmark
     //			Profiler::stop($benchmark);
     //		}
     //		echo View::factory('profiler/stats');
     //		//---------------------------------------------------------------//
     /**
      * Get settings
      */
     // <editor-fold defaultstate="collapsed" desc="Get settings">
     $settings = Cms_Helper::settings();
     // </editor-fold>
     /**
      * Lang
      */
     // <editor-fold defaultstate="collapsed" desc="Lang">
     I18n::lang($settings->lang);
     // </editor-fold>
     /**
      * Get item:セグメントからURLを取得 間はなんでもOK でもセグメントはユニーク
      */
     // <editor-fold defaultstate="collapsed" desc="Get segment and item">
     // Get item
     $item = Cms_Functions::get_item($this->request->param('segment'), TRUE, TRUE, FALSE);
     // Check issued
     if (Date::formatted_time($item->issued, 'U') > time()) {
         $item = FALSE;
     }
     // itemがないとき(false)は404へ飛ばす
     if (!$item) {
         throw HTTP_Exception::factory(404);
     }
     // </editor-fold>
     /**
      * If login
      */
     // <editor-fold defaultstate="collapsed" desc="If login">
     // If switch and post ログイン機能ONのときポストがあったら
     if ($settings->author_login_is_on and $this->request->post('login')) {
         $this->login_result = Cms_Item::login($this->request->post());
     }
     // </editor-fold>
     /**
      * login check:ログインのチェック
      */
     // <editor-fold defaultstate="collapsed" desc="login check">
     // ログインのチェック
     if (Auth::instance()->logged_in()) {
         // Get user from auth
         $get_user = Auth::instance()->get_user();
         // Build logged_in_user
         $this->logged_in_user = (object) array('id' => $get_user->id, 'email' => $get_user->email, 'username' => $get_user->username, 'logins' => $get_user->logins, 'last_login' => $get_user->last_login, 'ext' => $get_user->ext, 'avatar' => FALSE, 'detail' => FALSE, 'role' => FALSE);
         // Set logged in user avatar
         if (is_file('application/' . Cms_Helper::settings('image_dir') . '/user/' . $get_user->username . '/avatar' . $get_user->ext)) {
             $this->logged_in_user->avatar = (object) array('path' => URL::site("imagefly", 'http') . '/user/' . $get_user->username . '/', 'file' => '/' . 'avatar' . $get_user->ext);
         }
         // Set logged in user detail
         $this->logged_in_user->detail = Tbl::factory('users_details')->join('details')->on('users_details.detail_id', '=', 'details.id')->select('users_details.*')->select('details.name')->select('details.segment')->where('users_details.user_id', '=', $get_user->id)->read()->as_array('segment');
         // Set logged in user role
         $this->logged_in_user->role = Tbl::factory('roles_users')->select('roles.*')->join('roles')->on('roles_users.role_id', '=', 'roles.id')->where('roles_users.user_id', '=', $get_user->id)->where('roles.name', '!=', 'login')->read('name');
     }
     // </editor-fold>
     /**
      * Set global value
      */
     // <editor-fold defaultstate="collapsed" desc="Set global value">
     // Get site details
     $site = array();
     $site_detail_string = explode("\n", $settings->site_details);
     if ($site_detail_string) {
         foreach ($site_detail_string as $value) {
             $array = explode(':', $value);
             $site[trim($array[0])] = trim($array[1]);
         }
     }
     // Build logged_in_user
//.........这里部分代码省略.........
开发者ID:deraemons,项目名称:deraemon-cms,代码行数:101,代码来源:Item.php

示例9: Log_File

Kohana::init(array('base_url' => '/', 'caching' => TRUE, 'profile' => FALSE, 'index_file' => FALSE));
/**
 * Attach the file write to logging. Multiple writers are supported.
 */
Kohana::$log->attach(new Log_File(APPPATH . 'logs'));
/**
 * Attach a file reader to config. Multiple readers are supported.
 */
Kohana::$config->attach(new Config_File());
/**
 * Enable modules. Modules are referenced by a relative or absolute path.
 */
Kohana::modules(array('auth' => MODPATH . 'auth', 'cache' => MODPATH . 'cache', 'codebench' => MODPATH . 'codebench', 'database' => MODPATH . 'database', 'image' => MODPATH . 'image', 'minion' => MODPATH . 'minion', 'unittest' => MODPATH . 'unittest', 'userguide' => MODPATH . 'userguide', 'cms' => MODPATH . 'cms', 'tbl' => MODPATH . 'tbl', 'tpl' => MODPATH . 'tpl', 'pgn' => MODPATH . 'pgn', 'notice' => MODPATH . 'notice', 'email' => MODPATH . 'email', 'mysqli' => MODPATH . 'mysqli'));
/**
 * Get settings
 */
// Kohx
$settings = (object) Tbl::factory('settings')->read()->as_array('key', 'value');
// Set timezoon
date_default_timezone_set($settings->timezoon);
Cookie::$salt = $settings->cooki_salt;
Cookie::$expiration = Cms_Helper::sec($settings->cooki_expiration);
Session::$default = 'database';
/**
 * Set the routes. Each route must have a minimum of a name, a URI and a set of
 * defaults for the URI.
 */
// Kohx
Cms_Route::write();
// Default
Route::set('default', '(<controller>(/<action>(/<id>)))')->defaults(array('controller' => 'home', 'action' => 'index'));
开发者ID:deraemons,项目名称:deraemon-cms,代码行数:31,代码来源:bootstrap.php

示例10: 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
     $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')->get($id);
     if (!$wrapper) {
         throw HTTP_Exception::factory(404);
     }
     // Database transaction start
     Database::instance()->begin();
     // Try
     try {
         /**
          * Check other tables
          */
         // used by divisions
         $used_divisions = (bool) Tbl::factory('divisions')->where('wrapper_id', '=', $wrapper->id)->read()->count();
         // If this warpper is used by division
         if ($used_divisions) {
             throw new Warning_Exception(Kohana::message('general', 'wrapper_is_used'));
         }
         /**
          * Delete
          */
         // Delete file
         $file = "wrapper/{$wrapper->segment}";
         Cms_Helper::delete_file($file, $this->settings->front_tpl_dir);
         // Delete
         $wrapper->delete();
         // Database commit
         Database::instance()->commit();
         // Add success notice
         Notice::add(Notice::SUCCESS, Kohana::message('general', 'delete_success'));
         // Redirect to wrapper index
         $this->redirect(URL::site("{$this->settings->backend_name}/wrappers/index", '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', 'delete_failed'), NULL, $e->errors('validation'));
     } 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);
     }
     // Redirect to wrapper edit
     $this->redirect(URL::site("{$this->settings->backend_name}/wrappers/edit/{$wrapper->id}", 'http'));
 }
开发者ID:deraemons,项目名称:deraemon-cms,代码行数:65,代码来源:Wrappers.php

示例11: get_comments

 /**
  * Get Comments
  *
  * @param array $params
  * 	array(
  * 		'item_segment' => 'item_segment',
  * 		'order_column' => 'order_column',
  * 		'order_direction' => 'order_direction',
  * 		'offset' => '2',
  * 		'limit' => '5',
  * 	);
  */
 public static function get_comments(array $params)
 {
     /**
      * Build results
      */
     $return = new stdClass();
     $return->total = NULL;
     $return->comments = NULL;
     // Get param
     $item_segment = Arr::get($params, 'item_segment');
     $order_column = Arr::get($params, 'order_column');
     $order_direction = Arr::get($params, 'order_direction');
     $offset = Arr::get($params, 'offset');
     $limit = Arr::get($params, 'limit');
     // parent_segmentからparent_idを取得
     $item_id = Tbl::factory('items')->where('segment', '=', $item_segment)->read('id');
     $sql = Tbl::factory('received_comments')->where('item_id', '=', $item_id)->where('is_accept', '=', 1);
     // if there is order_column
     if ($order_column) {
         $sql->order_by($order_column, $order_direction);
     }
     // if there is offset
     if ($offset) {
         $sql->offset($offset);
     }
     // if there is limit
     if ($limit) {
         $sql->limit($limit);
     }
     // Items sqlを実行
     $return->comments = $sql->read()->as_array();
     // count
     $return->total = count($return->comments);
     return $return;
 }
开发者ID:deraemons,项目名称:deraemon-cms,代码行数:47,代码来源:Functions.php

示例12: login

 /**
  * Attempt to log in a user by using an Database object and plain-text password.
  *
  * @param   string   $username  Username to log in
  * @param   string   $password  Password to check against
  * @param   boolean  $remember  Enable autologin
  * @return  boolean
  */
 public function login($username, $password, $remember = FALSE)
 {
     if (empty($password)) {
         return FALSE;
     }
     // Todo:: kohx::1
     // もしブロックが1ならreturn FALSE
     $block_check = Tbl::factory('users')->where('username', '=', $username)->read('is_block');
     if ($block_check) {
         return FALSE;
     }
     return $this->_login($username, $password, $remember);
 }
开发者ID:deraemons,项目名称:deraemon-cms,代码行数:21,代码来源:Database.php

示例13: defined

<?php

defined('SYSPATH') or die('No direct access allowed.');
$settings = (object) Tbl::factory('settings')->or_where('key', '=', 'auth_hash_method')->or_where('key', '=', 'auth_hash_key')->or_where('key', '=', 'auth_lifetime')->or_where('key', '=', 'auth_session_key')->read()->as_array('key', 'value');
return array('driver' => 'Database', 'hash_method' => $settings->auth_hash_method, 'hash_key' => $settings->auth_hash_key, 'lifetime' => Cms_Helper::sec($settings->auth_lifetime), 'session_type' => Session::$default, 'session_key' => $settings->auth_session_key);
开发者ID:deraemons,项目名称:deraemon-cms,代码行数:5,代码来源:auth.php

示例14: action_rule_delete

 /**
  * Action rule_delete
  */
 public function action_rule_delete()
 {
     // Auto render off
     $this->auto_render = FALSE;
     // 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 detail, if there is nothing then throw to 404
     $detail_rule = Tbl::factory('detail_rules')->get($id);
     if (!$detail_rule) {
         throw HTTP_Exception::factory(404);
     }
     // Database transaction start
     Database::instance()->begin();
     // Try
     try {
         // Delete detail
         $detail_rule->delete();
         // Database commit
         Database::instance()->commit();
         // Add success notice
         Notice::add(Notice::SUCCESS, Kohana::message('general', 'delete_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', 'delete_failed'), NULL, $e->errors('validation'));
     } 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);
     }
     // Redirect to wrapper edit
     $this->redirect(URL::site("{$this->settings->backend_name}/details/rule/{$detail_rule->detail_id}", 'http'));
 }
开发者ID:deraemons,项目名称:deraemon-cms,代码行数:48,代码来源:Details.php

示例15: 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


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