public function action_confirm($category_id) { $category = ORM::factory('category')->where('id', '=', $category_id)->find(); $this->template->content = View::factory('admin/categories/confirm'); $this->template->sidebar = Widget::factory()->add(Helper_Default::admin_sidebar()); $this->template->content->category = $category; }
public function widget($type = NULL) { if ($type === NULL) { return Widget::factory($this->_widget, array("value" => $this->value(), "name" => $this->name(), "css_classes" => $this->css_class(), "formset_index" => $this->formset_index(), "theme" => $this->theme(), "choices" => $this->choices())); } $this->_widget = $type; return $this; }
public function action_index() { $results = ORM::factory('caption')->where('moderation_status_id', '!=', '2')->find_all(); $this->template->content = View::factory('admin/captions/index'); $this->template->content->set(array('captions' => $results)); $this->template->scripts = array('public/js/admin/moderation.js'); $this->template->sidebar = Widget::factory()->add(Helper_Default::admin_sidebar()); }
public function action_index($photo_id = NULL) { /* * load all of the Caption This photos that haven't expired */ $caption_photos = ORM::factory('captionthisphoto')->where('to', '>=', date('Y-m-d'))->find_all(); if ($photo_id != NULL) { $photo = ORM::factory('photo')->where('id', '=', $photo_id)->find(); /* * try to load the photo provided via the url */ if ($photo->loaded()) { /* * check to see if from date is before to date */ if (strtotime($_POST['to']) < strtotime($_POST['from'])) { Message::set(Message::ERROR, "From date must be before to date."); Request::instance()->redirect(Helper_Photos::get_photo_url($photo)); return; } /* * check to see if form was posted and has both of the dates */ if (!empty($_POST['from']) && !empty($_POST['to'])) { $from_date = date('Y-m-d', strtotime($_POST['from'])); $to_date = date('Y-m-d', strtotime($_POST['to'])); $check_dates = DB::select('*')->from('caption_this_photos')->where('from', 'BETWEEN', array($from_date, $to_date))->or_where('to', 'BETWEEN', array($from_date, $to_date))->order_by('from', 'ASC')->execute(); if ($check_dates->count() > 0) { Message::set(Message::ERROR, "There is already a Caption This photo in the period you selected."); } else { $caption_this_photo = ORM::factory('captionthisphoto'); $caption_this_photo->from = date("Y-m-d", strtotime($_POST['from'])); $caption_this_photo->to = date("Y-m-d", strtotime($_POST['to'])); $caption_this_photo->photo_id = $photo_id; $caption_this_photo->save(); /* * if the photo was saved, show a success message */ if ($caption_this_photo->saved()) { Message::set(Message::SUCCESS, "Photo successfully set as Caption This photo from " . $_POST['from'] . " to " . $_POST['to'] . "."); Request::instance()->redirect('admin/backtalk'); } else { Message::set(Message::ERROR, "A problem occured while trying to set photo as Caption This photo."); } } } else { Message::set(Message::ERROR, "You must select the date range for Caption This photo."); } } else { Message::set(Message::ERROR, "This photo doesn't exist."); } } $this->template->content = View::factory('admin/photos/caption'); $this->template->content->set(array('caption_photos' => $caption_photos)); $this->template->styles = array('public/js/vendor/datepicker/jquery-ui-1.8.5.custom.css' => 'screen'); $this->template->scripts = array('public/js/vendor/jquery-ui-1.8.5.custom.min.js'); $this->template->sidebar = Widget::factory()->add(Helper_Default::admin_sidebar()); }
public function action_view($avatar_id) { $avatar = ORM::factory('avatar')->where('id', '=', $avatar_id)->find(); $avatar->lock(); $this->template->content = View::factory('admin/avatars/view'); $this->template->content->set(array('avatar' => $avatar)); $this->template->scripts = array('public/js/admin/moderation.js'); $this->template->sidebar = Widget::factory()->add(Helper_Default::admin_sidebar()); }
public function action_index($id) { $page = Model_Page::getBySlug($id, false); if (!$page || !$page->isPublished() && !Helper_Account::is_admin(Auth::instance()->get_user())) { $this->template->content = View::factory("errors/index"); return; } $this->template->content = View::factory("page/index")->set("page", $page); $this->template->sidebar = Widget::factory()->add(Helper_Default::sidebar()); }
public function action_index($id) { $gallery = Model_Gallery::getBySlug($id, false); if (!$gallery || !$gallery->isPublished() && !Helper_Account::is_admin(Auth::instance()->get_user())) { $this->template->content = View::factory("errors/index"); return; } $this->template->content = View::factory("gallery/index")->set("gallery", $gallery); $this->template->content->reel = Reel::factory($gallery->photos); $this->template->sidebar = Widget::factory()->add(Helper_Default::sidebar()); }
public function render() { $output = ''; foreach ($this->widgets as $widget) { if (is_string($widget['name'])) { $output .= Widget::factory($widget['name'], $widget['config'])->render(); } elseif (is_object($widget['name'])) { $output .= $widget['name']->render(); } } return $output; }
public function action_page($slug) { $page = Model_Page::getBySlug($slug, false); if ($page) { $this->template->content = View::factory("myshot/index"); $this->template->content->page = $page; $this->template->sidebar = Widget::factory()->add(Helper_Default::sidebar()); } else { $this->template->content = "No page available"; //redirect instead? } }
/** * View the tag page. * * @return void * @author Merrick Christensen */ public function action_view($id = NULL) { $tag = ORM::factory('tag')->where('id', '=', $id)->find(); $this->template->title = 'View Photos Tagged ' . $tag->name . ' - National Geographic Kids My Shot'; $this->template->content = View::factory('tags/index'); if ($tag->loaded()) { $this->template->content->set(array('tag' => $tag, 'reel' => Reel::factory($tag->photos->order_by("photos.created", "desc")))); } else { Message::set(Message::NOTICE, "This tag does not exist."); Request::instance()->redirect('/'); } $this->template->sidebar = Widget::factory()->add(Helper_Default::sidebar()); }
/** * View the homepage. * * @return void * @author Merrick Christensen */ public function action_index() { $this->template->title = 'Share Your Photos - National Geographic Kids My Shot Community'; $this->template->scripts = array('public/js/vendor/jquery.jcarousel.js', 'public/js/categories/slideshow.js', 'public/js/home/home.js'); $awards = array(); $badges = array(); $events = ORM::factory('game_EventLog')->where('event_id', '=', Helper_Game::getSite()->getEvent(Model_Game_Site::HONOR_GIVEN))->order_by('time_stamp', 'DESC')->limit($this->sampleSize)->find_all(); foreach ($events as $event) { $eventUser = ORM::factory('user', $event->user->user_id); if ($eventUser->id) { if ($event->data->type == "game_Badge") { $obj = new stdClass(); $obj->data = $event->data; $obj->honor = ORM::factory($event->data->type, $event->data->honor_id); $obj->user = ORM::factory('user', $event->user->user_id); $badges[] = $obj; } } if (count($badges) >= $this->maxBadges) { break; } } if (count($awards) < $this->maxAwards) { $aevents = ORM::factory('game_EventLog')->where('event_id', '=', Helper_Game::getSite()->getEvent(Helper_Game::AWARD_GIVEN)->id)->order_by('time_stamp', 'DESC')->limit($this->sampleSize)->find_all(); foreach ($aevents as $event) { $obj = new stdClass(); $obj->data = $event->data; $obj->honor = ORM::factory($event->data->type, $event->data->honor_id); $obj->user = ORM::factory('user', $event->user->user_id); $obj->photo = ORM::factory('photo', $event->item->item_id); $awards[] = $obj; if (count($awards) >= $this->maxAwards) { break; } } } $honors = array_merge($awards, $badges); if (count($honors) == 0) { $honors = false; } $slider = Model_DLSliderGroup::getCurrentSlider(); if ($slider) { $this->template->top = View::factory("home/slider"); $this->template->top->slider = $slider; } $this->template->content = View::factory('home/index'); $this->template->content->set(array('user' => $this->user, 'recently_added' => Reel_More::factory(ORM::factory('photo')->order_by('created', 'desc')), 'top_rated' => Reel_More::factory(Helper_Photos::get_top_rated()), 'honors' => $honors, 'potd' => Model_DailyPhoto::todaysPhoto(), 'homeSpot' => Model_Homespot::getCurrent())); $this->template->sidebar = Widget::factory()->add(Helper_Default::sidebar()); }
public function action_award($id = null) { if ($id == null) { Request::instance()->redirect('/trophies/'); } else { $award = ORM::factory("game_Award", $id); if ($award->deleted) { Request::instance()->redirect('/trophies/'); } else { $this->template->content = View::factory("trophy/award"); $this->template->content->award = $award; $this->template->content->aItems = $aItems = $award->_items->order_by("id", "desc")->offset($this->numPerPage * (!empty($_GET['page']) ? filter_input(INPUT_GET, "page", FILTER_SANITIZE_NUMBER_INT) : 0))->limit($this->numPerPage)->find_all(); $pagination = Pagination::factory(array("items_per_page" => $this->numPerPage, "total_items" => $award->_items->count_all())); $this->template->content->pagination = $pagination; $this->totalItems = $award->_items->count_all(); $this->template->sidebar = Widget::factory()->add(Helper_Default::sidebar()); } } }
private function buildPage(Model_CaptionThisPhoto $caption_this_photo, View $view) { $photo_id = $caption_this_photo->photo_id; $photo = ORM::factory('photo')->where('id', '=', $photo_id)->find(); if ($photo->loaded()) { $photo->increment_view(); /* * load all captions associated with photo and sort them by rating */ $captions = DB::select('captions.*', array('AVG("caption_ratings.rating")', 'avg_rating'))->from('captions')->join('caption_ratings', 'LEFT')->on('captions.id', '=', 'caption_ratings.caption_id')->where('captions.photo_id', '=', $photo_id)->where('moderation_status_id', '=', 2)->group_by('captions.id')->order_by('avg_rating', 'DESC')->as_object('Model_Caption')->execute(); $past_caption_this_photos = ORM::factory('captionthisphoto')->where('from', '<=', date('Y-m-d'))->order_by("to", "DESC")->find_all(); $this->template->title = 'Back Talk - National Geographic Kids My Shot'; $this->template->content = $view; $this->template->content->set(array('user' => $photo->user, 'photo' => $photo, 'caption_this_photo' => $caption_this_photo, 'captions' => $captions, 'past_caption_this_photos' => $past_caption_this_photos, 'awaiting_captions' => ORM::factory('caption')->where('photo_id', '=', $photo_id)->where('moderation_status_id', '!=', '2')->where('user_id', '=', $this->user->id)->find_all())); $this->template->styles = array('public/js/vendor/rating/jquery.rating.css' => 'screen'); $this->template->scripts = array('public/js/vendor/rating/jquery.MetaData.js', 'public/js/vendor/rating/jquery.rating.pack.js', 'public/js/vendor/jquery.jcarousel.js', 'public/js/photos/caption.js', 'public/js/vendor/word-count.js'); $this->template->sidebar = Widget::factory()->add(Helper_Default::sidebar()); } }
/** * View the category page. * * @return void * @author Merrick Christensen */ public function action_index($id = NULL) { $category = ORM::factory('category')->where('id', '=', $id)->find(); $this->template->title = 'View ' . $category->name . ' Photos - National Geographic Kids My Shot'; $this->template->scripts = array('public/js/categories/slideshow.js'); $this->template->content = View::factory('categories/index'); // Take a deep breath! $featured = DB::query(Database::SELECT, 'SELECT * FROM (SELECT `photos`.`id` AS `id`, `ratings`.`id` AS `rating_id`, `photos`.`moderation_status_id`, `photos`.`category_id`, `photos`.`user_id`, `photos`.`name`, `photos`.`caption`, `photos`.`thumbnail`, `photos`.`small`, `photos`.`medium`, `photos`.`large`, `photos`.`original`, `photos`.`file_type`, `photos`.`order`, `photos`.`created`, Avg(`rating`) AS `rating` FROM `ratings` JOIN `photos` ON ( `photos`.`id` = `ratings`.`photo_id` ) WHERE `category_id` = ' . $id . ' GROUP BY `photo_id` ORDER BY `rating` DESC LIMIT 20) AS top_rated ORDER BY Rand() LIMIT 5')->as_object('Model_Photo'); // Did you make it? if ($category->loaded()) { $this->template->content->set(array('category' => $category, 'reel' => Reel::factory(ORM::factory('photo')->where('category_id', '=', $id)->order_by('created', 'desc')), 'featured_photos' => $featured->execute())); } else { Message::set(Message::NOTICE, "This category does not exist."); Request::instance()->redirect('/'); } $this->template->sidebar = Widget::factory()->add(Helper_Default::sidebar()); }
/** * Gets from conf DB json object of active widgets * @param string $name_placeholder name of placeholder * @param bool $only_names, returns only an array with the widgets names * @return array widgets */ public static function get($name_placeholder, $only_names = FALSE) { $widgets = array(); $active_widgets = core::config('placeholder.' . $name_placeholder); if ($active_widgets !== NULL and !empty($active_widgets) and $active_widgets !== '[]' and $active_widgets !== '[""]' and $active_widgets !== '""') { $active_widgets = json_decode($active_widgets, TRUE); // array of widget path, to include to view foreach ($active_widgets as $widget_name) { if ($only_names) { $widgets[] = $widget_name; } else { if (($w = Widget::factory($widget_name)) !== NULL) { $widgets[] = $w; } } } //end for } //end if widgets return $widgets; }
public function action_confirm($photo_id) { if (Helper_Account::is_admin()) { $photo = ORM::factory('photo')->where('id', '=', $photo_id)->find(); } else { $photo = ORM::factory('photo')->where('id', '=', $photo_id)->where('user_id', '=', $this->user->id)->find(); } if ($photo->loaded()) { $this->template->content = View::factory('photos/confirm'); $this->template->sidebar = Widget::factory()->add(Helper_Default::sidebar()); $this->template->content->set(array('photo' => $photo)); $this->template->scripts = array("public/js/photos/confirm.js"); } else { Message::set(MESSAGE::NOTICE, 'We couldn\'t find this photo!'); Request::instance()->redirect('/'); } }
static function default_dispatcher() { if (Input::$AJAX && Input::$AJAX['widget']) { $widget = Widget::factory(Input::$AJAX['widget']); $method = 'on_' . (Input::$AJAX['object'] ?: 'unknown') . '_' . (Input::$AJAX['event'] ?: 'unknown'); if (method_exists($widget, $method)) { Event::bind('system.output', 'Output::AJAX'); $widget->{$method}(); } return; } $args = Input::args(); $default_page = Config::get('system.default_page'); if (!$default_page) { $default_page = 'index'; } //从末端开始尝试 /* home/page/edit.1 home/page/index.php Index_Controller::edit(1) home/page/index.php Index_Controller::index('edit', 1) home/page.php Page_Controller::edit(1) home/page.php Page_Controller::index('edit', 1) */ $file = end($args); if (!preg_match('/[^\\\\]\\./', $file)) { //有非法字符的只能是参数 $path = implode('/', $args); // home/page/edit/index => index, NULL $candidates[($path ? $path . '/' : '') . $default_page] = array($default_page, NULL); $candidates[$path] = array($file, NULL); // home/page/edit => edit, NULL } if ($args) { $params = array_pop($args); $file = $args ? end($args) : $default_page; $path = $args ? implode('/', $args) : $default_page; $candidates[$path] = array($file, $params); // home/page.php => page, edit|1 } else { $candidates[$default_page] = array($default_page, NULL); } $class = NULL; foreach ($candidates as $path => $candidate) { if (Core::load(CONTROLLER_BASE, $path)) { $class = str_replace('/', '_', $path); $params = array(); if (preg_match_all('/(.*?[^\\\\])\\./', $candidate[1] . '.', $parts)) { foreach ($parts[1] as $part) { $params[] = strtr($part, array('\\.' => '.')); } } Config::set('system.controller_path', $path); Config::set('system.controller_class', $class); break; } } if (!$class) { URI::redirect('error/404'); } if (Input::$AJAX) { $class .= AJAX_SUFFIX; if (!class_exists($class, false)) { Core::load(CONTROLLER_BASE, 'ajax'); $class = 'AJAX' . CONTROLLER_SUFFIX; } $controller = new $class(); $object = Input::$AJAX['object']; $event = Input::$AJAX['event']; $method = $params[0]; if (!$method || $method[0] == '_') { $method = 'index_'; } $method .= '_' . ($object ? $object . '_' : '') . $event; if (method_exists($controller, $method)) { array_shift($params); } else { $method = 'index_' . ($object ? $object . '_' : '') . $event; if (!method_exists($controller, $method)) { $method = NULL; } } if ($method) { Controller::$CURRENT = $controller; Config::set('system.controller_method', $method); Config::set('system.controller_params', $params); $controller->_before_call($method, $params); call_user_func_array(array($controller, $method), $params); $controller->_after_call($method, $params); } } else { $class .= CONTROLLER_SUFFIX; $controller = new $class(); $method = $params[0]; if ($method && $method[0] != '_' && method_exists($controller, $method)) { array_shift($params); } elseif ($method && $method[0] != '_' && method_exists($controller, 'do_' . $method)) { $method = 'do_' . $method; array_shift($params); } else { $method = 'index'; } Controller::$CURRENT = $controller; Config::set('system.controller_method', $method); Config::set('system.controller_params', $params); $controller->_before_call($method, $params); call_user_func_array(array($controller, $method), $params); $controller->_after_call($method, $params); } }
<?php echo Menu::instance(); ?> </div> </div> <div id="content"> <div id="article"> <div class="entry"> <?php echo $content; ?> </div> </div> <div id="sidebar"> <?php echo Widget::factory('Submenu'); ?> <?php echo Sidebar::instance(); ?> </div> <div class="clear"></div> </div> <div id="bottom"> </div> <div id="footer"> <div class="widthfix"> © 2008 Your Name, powered by <a href="http://www.s7n.de/">S7Ncms</a>, theme by <a href="http://hellowiki.com/about/">Fen</a> </div> </div> <div class="none"></div>
public function action_saveplaceholders() { //deleting the fragment cache...a bit ugly but works. View::delete_fragment('sidebar_front'); View::delete_fragment('footer_front'); $this->auto_render = FALSE; $this->template = View::factory('js'); DB::delete('config')->where('group_name', '=', 'placeholder')->execute(); //for each placeholder foreach ($_GET as $placeholder => $widgets) { if (!is_array($widgets)) { $widgets = array($widgets); } // save palceholder to DB $confp = new Model_Config(); $confp->where('group_name', '=', 'placeholder')->where('config_key', '=', $placeholder)->limit(1)->find(); if (!$confp->loaded()) { $confp->group_name = 'placeholder'; $confp->config_key = $placeholder; } $confp->config_value = json_encode($widgets); $confp->save(); //edit each widget change placeholder foreach ($widgets as $wname) { $w = Widget::factory($wname); if ($w !== NULL) { if ($w->loaded and $w->placeholder != $placeholder) { $w->placeholder = $placeholder; $w->save(); } } } } $this->template->content = __('Saved'); }
public function action_flag($user_id = null) { $user = ORM::factory('user')->where('id', '=', $user_id)->find(); $content = $this->template->content = View::factory('admin/users/flag'); $this->template->sidebar = Widget::factory()->add(Helper_Default::admin_sidebar()); if ($user->loaded()) { $this->template->content->set(array('user' => $user)); } else { Message::set(Message::NOTICE, "This user does not exist."); Request::instance()->redirect('admin/users'); } if ($_POST) { /* How long do they want to suspend this user for? */ $flag_timeout = Arr::get($_POST, 'flag'); $user->flag = time() + $flag_timeout; /* Create the account. */ $user->save(); Request::instance()->redirect('admin/users'); /* Load the validation rules, filters etc.*/ //$post = $user->validate_update($_POST); /* If the post data validates using the rules setup in the user model. */ //if ($post->check()) //{ //$user->flag = time() + $flag_timeout; /* Create the account. */ //$user->save(); /* Redirect to users edit page. */ //Request::instance()->redirect('admin/users'); //} //else //{ /* Get errors for display in view. */ //Message::set(Message::ERROR, $post->errors("user")); //} } }
public function action_preview($id) { $id = filter_var($id, FILTER_SANITIZE_NUMBER_INT); $homeSpot = ORM::factory("homespot", $id); if (!$homeSpot->loaded()) { Message::set(Message::ERROR, "Sorry, that could not be found."); $this->request->redirect("admin/home/create"); return; } $this->template->title = 'Share Your Photos - National Geographic Kids My Shot Community'; $this->template->scripts = array('public/js/vendor/jquery.jcarousel.js', 'public/js/categories/slideshow.js', 'public/js/home/home.js'); $awards = array(); $badges = array(); $events = ORM::factory('game_EventLog')->where('event_id', '=', Helper_Game::getSite()->getEvent(Model_Game_Site::HONOR_GIVEN))->order_by('time_stamp', 'DESC')->limit($this->sampleSize)->find_all(); foreach ($events as $event) { $eventUser = ORM::factory('user', $event->user->user_id); if ($eventUser->id) { if ($event->data->type == "game_Badge") { $obj = new stdClass(); $obj->data = $event->data; $obj->honor = ORM::factory($event->data->type, $event->data->honor_id); $obj->user = ORM::factory('user', $event->user->user_id); $badges[] = $obj; } } if (count($badges) >= $this->maxBadges) { break; } } if (count($awards) < $this->maxAwards) { $aevents = ORM::factory('game_EventLog')->where('event_id', '=', Helper_Game::getSite()->getEvent(Helper_Game::AWARD_GIVEN)->id)->order_by('time_stamp', 'DESC')->limit($this->sampleSize)->find_all(); foreach ($aevents as $event) { $obj = new stdClass(); $obj->data = $event->data; $obj->honor = ORM::factory($event->data->type, $event->data->honor_id); $obj->user = ORM::factory('user', $event->user->user_id); $obj->photo = ORM::factory('photo', $event->item->item_id); $awards[] = $obj; if (count($awards) >= $this->maxAwards) { break; } } } $honors = array_merge($awards, $badges); if (count($honors) == 0) { $honors = false; } $slider = Model_DLSliderGroup::getCurrentSlider(); if ($slider) { $this->template->top = View::factory("home/slider"); $this->template->top->slider = $slider; } $this->template->content = View::factory('home/index'); $this->template->content->set(array('user' => $this->user, 'recently_added' => Reel_More::factory(ORM::factory('photo')->order_by('created', 'desc')), 'top_rated' => Reel_More::factory(Helper_Photos::get_top_rated()), 'honors' => $honors, 'potd' => Model_DailyPhoto::todaysPhoto(), 'homeSpot' => $homeSpot, 'homeSpotEditLink' => HTML::anchor("admin/home/edit/{$homeSpot->id}", "Edit"))); $this->template->sidebar = Widget::factory()->add(Helper_Default::sidebar()); }
public function action_view($id) { $slideshow = ORM::factory("slideshow", filter_var($id, FILTER_SANITIZE_NUMBER_INT)); if (!$slideshow->loaded() || !$slideshow->complete) { Message::set(Message::ERROR, "Slideshow could not be found!"); $this->request->redirect("/"); return; } $this->template->content = View::factory("slideshow/view"); $this->template->content->slideshow = $slideshow; $this->template->content->user = $slideshow->user; $this->template->sidebar = Widget::factory()->add(array('accountstatus', 'ad')); $this->template->scripts = array("public/js/vendor/jquery-ui-1.8.5.custom.min.js", 'public/js/vendor/jquery.jcarousel.js', "public/js/slideshow/viewer.js"); }
public function action_confirm($id) { $this->template->content = View::factory('admin/awards/confirm'); $this->template->sidebar = Widget::factory()->add(Helper_Default::admin_sidebar()); $this->template->content->award = ORM::factory("game_Award", $id); }
/** * View the 404 page * * @return void * @author Merrick Christensen */ public function action_404() { $this->template->content = View::factory('errors/index'); $this->template->content->set(array('user' => $this->user)); $this->template->sidebar = Widget::factory()->add(Helper_Default::sidebar()); }
public function before() { parent::before(); $this->template->sidebar = Widget::factory()->add(Helper_Default::admin_sidebar()); }
/** * Successful avatar upload. * * @return void * @author Merrick Christensen */ public function action_success() { $avatar = $this->user->avatar; if ($avatar->loaded()) { $this->template->content = View::factory('account/success'); $this->template->content->set(array('user' => $this->user, 'avatar' => $avatar)); $this->template->sidebar = Widget::factory()->add(Helper_Default::sidebar()); } else { Message::set(Message::NOTICE, 'The avatar you requested doesn\'t exist!'); Request::instance()->redirect('/'); } }
/** * Deleting Widgets */ public function action_delete() { $id = (int) $this->request->param('id', 0); $widget = ORM::factory('widget', $id); if (!$widget->loaded()) { Log::error('Attempt to access non-existent widget.'); Message::error(__('Widget doesn\'t exists!')); $this->request->redirect(Route::get('admin/widget')->uri()); } $split_name = explode('/', $widget->name); $static = ($split_name and $split_name[0] == 'static') ? TRUE : FALSE; // we can only delete if its a custom widget if (!$static) { $this->request->redirect(Route::get('admin/widget')->uri()); } $handler = Widget::factory($widget->name, $widget); $this->title = __('Delete :title', array(':title' => $widget->title)); $destination = $this->request->query('destination') !== NULL ? array('destination' => $this->request->query('destination')) : array(); $view = View::factory('form/confirm')->set('action', Route::get('admin/widget')->uri(array('action' => 'delete', 'id' => $widget->id)) . URL::query($destination))->set('title', $widget->title); // If deletion is not desired, redirect to post if (isset($_POST['no']) and $this->valid_post()) { $this->request->redirect(Route::get('admin/widget')->uri(array('id' => $widget->id))); } // If deletion is confirmed if (isset($_POST['yes']) and $this->valid_post()) { try { $title = $widget->title; $widget->delete(); $handler->delete($_POST); Message::success(__('Widget :title deleted successful!', array(':title' => $title))); Cache::instance('widgets')->delete_all(); } catch (Exception $e) { Log::error('Error occurred deleting widget id: :id, :msg', array(':id' => $widget->id, ':msg' => $e->getMessage())); Message::error(__('An error occurred deleting widget %title', array(':title' => $widget->title))); } $redirect = empty($destination) ? Route::get('admin/widget')->uri() : $this->request->query('destination'); $this->request->redirect($redirect); } $this->response->body($view); }
public function before() { parent::before(); $this->template->content = View::factory('archive/view'); $this->template->sidebar = Widget::factory()->add(Helper_Default::sidebar()); }
/** * Returns the named widget * * @param string $name Name of the widget * @param boolean $visible Visibility permission from widget or FALSE to skip * @param boolean $region The name of the region ex:left, right or FALSE for all regions * @param boolean $format The format of the output ex:xhtml, html or FALSE for object * * @return object Widget widget * @return string HTML widget */ public function get_widget($name, $visible = FALSE, $region = FALSE, $format = FALSE) { $response = FALSE; if (!($widget = $this->get($name))) { return $response; } $visible == TRUE ? $this->is_visible($widget) : $widget->visible == TRUE; // Enable developers to override widget Module::event('Widget', $widget); Module::event('Widget_' . ucfirst($name), $widget); if ($widget->status and $widget->visible) { try { $widget->content = Widget::factory($name, $widget, $widget->config)->render(); $response = $format === FALSE ? $widget : trim($this->_html($widget, $this->_region, $this->_format)); } catch (Exception $e) { Log::error('Error processing widget ":name": :msg', array(':name' => $name, ':msg' => $e->getMessage())); } } return $response; }
public function after() { $this->template->sidebar = Widget::factory()->add(array('accountstatus', 'ad', 'minute', 'search', 'following', 'followers', 'favphotos', 'categories', 'help', 'tags', 'editorial')); parent::after(); }