本文整理汇总了PHP中Widget::factory方法的典型用法代码示例。如果您正苦于以下问题:PHP Widget::factory方法的具体用法?PHP Widget::factory怎么用?PHP Widget::factory使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Widget
的用法示例。
在下文中一共展示了Widget::factory方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: action_confirm
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;
}
示例2: widget
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;
}
示例3: action_index
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());
}
示例4: action_index
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());
}
示例5: action_view
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());
}
示例6: action_index
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());
}
示例7: action_index
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());
}
示例8: render
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;
}
示例9: action_page
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?
}
}
示例10: action_view
/**
* 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());
}
示例11: action_index
/**
* 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());
}
示例12: action_award
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());
}
}
}
示例13: buildPage
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());
}
}
示例14: action_index
/**
* 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());
}
示例15: get
/**
* 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;
}