本文整理汇总了PHP中Notice::add方法的典型用法代码示例。如果您正苦于以下问题:PHP Notice::add方法的具体用法?PHP Notice::add怎么用?PHP Notice::add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Notice
的用法示例。
在下文中一共展示了Notice::add方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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);
}
示例2: action_result
/**
* Action result
*/
public function action_result()
{
// Get result from file and direct set to search
$result = new stdClass();
$result->content = Tpl::get_file('result', $this->settings->front_tpl_dir . '/search');
// If there are post
if ($this->request->post()) {
// Set post to author
$result->content = $this->request->post('content');
// Database transaction start
Database::instance()->begin();
// Try
try {
// Update file
Cms_Helper::set_file("result", $this->settings->front_tpl_dir . '/search', $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('result', $this->settings->back_tpl_dir . '/search', $this->partials);
$this->content = Tpl::factory($content_file)->set('result', $result);
}
示例3: 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 comment, if there is nothing then throw to 404
$received_email = Tbl::factory('received_emails')->get($id);
if (!$received_email) {
throw HTTP_Exception::factory(404);
}
// Database transaction start
Database::instance()->begin();
// Try
try {
/**
* Delete
*/
$received_email->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}/received_emails/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 (Exception $e) {
// Database rollback
Database::instance()->rollback();
// Add error notice
Notice::add(Notice::ERROR);
}
// Redirect to received_emails index
$this->redirect(URL::site("{$this->settings->backend_name}/received_emails/index", 'http'));
}
示例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 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'));
}
示例5: importer
function importer($path, $node, $line)
{
global $blogid, $migrational, $items, $item;
switch ($path) {
case '/blog/setting':
setProgress($item++ / $items * 100, _t('블로그 설정을 복원하고 있습니다.'));
$setting = new BlogSetting();
if (isset($node['title'][0]['.value'])) {
$setting->title = $node['title'][0]['.value'];
}
if (isset($node['description'][0]['.value'])) {
$setting->description = $node['description'][0]['.value'];
}
if (isset($node['banner'][0]['name'][0]['.value'])) {
$setting->banner = $node['banner'][0]['name'][0]['.value'];
}
if (isset($node['useSloganOnPost'][0]['.value'])) {
$setting->useSloganOnPost = $node['useSloganOnPost'][0]['.value'];
}
if (isset($node['postsOnPage'][0]['.value'])) {
$setting->postsOnPage = $node['postsOnPage'][0]['.value'];
}
if (isset($node['postsOnList'][0]['.value'])) {
$setting->postsOnList = $node['postsOnList'][0]['.value'];
}
if (isset($node['postsOnFeed'][0]['.value'])) {
$setting->postsOnFeed = $node['postsOnFeed'][0]['.value'];
}
if (isset($node['publishWholeOnFeed'][0]['.value'])) {
$setting->publishWholeOnFeed = $node['publishWholeOnFeed'][0]['.value'];
}
if (isset($node['acceptGuestComment'][0]['.value'])) {
$setting->acceptGuestComment = $node['acceptGuestComment'][0]['.value'];
}
if (isset($node['acceptcommentOnGuestComment'][0]['.value'])) {
$setting->acceptcommentOnGuestComment = $node['acceptcommentOnGuestComment'][0]['.value'];
}
if (isset($node['language'][0]['.value'])) {
$setting->language = $node['language'][0]['.value'];
}
if (isset($node['timezone'][0]['.value'])) {
$setting->timezone = $node['timezone'][0]['.value'];
}
if (!$setting->save()) {
user_error(__LINE__ . $setting->error);
}
if (!empty($setting->banner) && !empty($node['banner'][0]['content'][0]['.stream'])) {
Attachment::confirmFolder();
Utils_Base64Stream::decode($node['banner'][0]['content'][0]['.stream'], Path::combine(ROOT, 'attach', $blogid, $setting->banner));
Attachment::adjustPermission(Path::combine(ROOT, 'attach', $blogid, $setting->banner));
fclose($node['banner'][0]['content'][0]['.stream']);
unset($node['banner'][0]['content'][0]['.stream']);
}
return true;
case '/blog/category':
setProgress($item++ / $items * 100, _t('분류를 복원하고 있습니다.'));
$category = new Category();
$category->name = $node['name'][0]['.value'];
$category->priority = $node['priority'][0]['.value'];
if (isset($node['root'][0]['.value'])) {
$category->id = 0;
}
if (!$category->add()) {
user_error(__LINE__ . $category->error);
}
if (isset($node['category'])) {
for ($i = 0; $i < count($node['category']); $i++) {
$childCategory = new Category();
$childCategory->parent = $category->id;
$cursor =& $node['category'][$i];
$childCategory->name = $cursor['name'][0]['.value'];
$childCategory->priority = $cursor['priority'][0]['.value'];
if (!$childCategory->add()) {
user_error(__LINE__ . $childCategory->error);
}
}
}
return true;
case '/blog/post':
setProgress($item++ / $items * 100, _t('글을 복원하고 있습니다.'));
$post = new Post();
$post->id = $node['id'][0]['.value'];
$post->slogan = @$node['.attributes']['slogan'];
$post->visibility = $node['visibility'][0]['.value'];
if (isset($node['starred'][0]['.value'])) {
$post->starred = $node['starred'][0]['.value'];
} else {
$post->starred = 0;
}
$post->title = $node['title'][0]['.value'];
$post->content = $node['content'][0]['.value'];
$post->contentformatter = isset($node['content'][0]['.attributes']['formatter']) ? $node['content'][0]['.attributes']['formatter'] : 'ttml';
$post->contenteditor = isset($node['content'][0]['.attributes']['editor']) ? $node['content'][0]['.attributes']['editor'] : 'modern';
$post->location = $node['location'][0]['.value'];
$post->password = isset($node['password'][0]['.value']) ? $node['password'][0]['.value'] : null;
$post->acceptcomment = $node['acceptComment'][0]['.value'];
$post->accepttrackback = $node['acceptTrackback'][0]['.value'];
$post->published = $node['published'][0]['.value'];
if (isset($node['longitude'][0]['.value'])) {
$post->longitude = $node['longitude'][0]['.value'];
//.........这里部分代码省略.........
示例6: 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'));
}
示例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 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'));
}
示例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'));
}
示例9: 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'));
}
示例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 email, if there is nothing then throw to 404
$email = Tbl::factory('emails')->get($id);
if (!$email) {
throw HTTP_Exception::factory(404);
}
// Database transaction start
Database::instance()->begin();
// Try
try {
/**
* Delete
*/
// used by email
$used_rule_ids = Tbl::factory('email_rules')->where('email_id', '=', $email->id)->read()->as_array(NULL, 'id');
if ($used_rule_ids) {
foreach ($used_rule_ids as $used_rule_id) {
Tbl::factory('email_rules')->get($used_rule_id)->delete();
}
}
// Delete file
Cms_Helper::delete_file($email->segment, "{$this->settings->front_tpl_dir}/email");
Cms_Helper::delete_file($email->segment, "{$this->settings->front_tpl_dir}/email/confirm");
Cms_Helper::delete_file($email->segment, "{$this->settings->front_tpl_dir}/email/receive");
// Delete
$email->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}/emails/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 (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}/emails/edit/{$email->id}", 'http'));
}
示例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);
}
示例12: 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'));
}
示例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);
}
示例14: action_received_comment_delete
/**
* Action received comment delete
*/
public function action_received_comment_delete()
{
// Auto render off
$this->auto_render = FALSE;
// Get ids, if When it is smaller than 2 then throw to 404
$ids = explode('_', $this->request->param('key'));
if (!(count($ids) == 2)) {
throw HTTP_Exception::factory(404);
}
// idsをitem_idとreceived_comment_idに分ける
list($item_id, $received_comment_id) = $ids;
// Get received_comment, if there is nothing then throw to 404
$received_comment = Tbl::factory('received_comments')->get($received_comment_id);
if (!$received_comment) {
throw HTTP_Exception::factory(404);
}
// Get item, if there is nothing then throw to 404
$this->item = Tbl::factory('items')->get($item_id);
if (!$this->item) {
throw HTTP_Exception::factory(404);
}
// Get division
$division = Tbl::factory('divisions')->where('id', '=', $this->item->division_id)->read(1);
// Database transaction start
Database::instance()->begin();
// Try
try {
// Delete
$received_comment->delete();
// Database commit
Database::instance()->commit();
// Add success notice
Notice::add(Notice::SUCCESS, Kohana::message('general', 'delete_success'));
// redirect
$this->redirect(URL::site("{$this->settings->backend_name}/items/{$division->segment}/received_comments/{$this->item->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', 'delete_failed'), NULL, $e->errors('validation'));
} catch (Exception $e) {
// Database rollback
Database::instance()->rollback();
// Add error notice
Notice::add(Notice::ERROR);
}
// Redirect to received_comments edit
$this->redirect(URL::site("{$this->settings->backend_name}/items/{$division->segment}/received_comments/{$this->item->id}", 'http') . URL::query());
}
示例15: 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'));
}