public function action_connect_post() { // Module::load('blog'); // // $posts = Blog\Model_Post::query()->limit(15)->get(); // // $i = 1; // foreach($posts as $post) // { // $gallery = \Model_Gallery::forge(array( // 'name' => $post->slug, // 'post_id' => $post->id, // 'asset_id' => $i // )); // // $gallery->save(); // // $i++; // } $gallery = Model_Gallery::query()->related('asset')->limit(15)->get(); foreach ($gallery as $asset) { $input_file = DOCROOT . $asset->uri . $asset->name; $image64Encoded = $this->_base64_encode_image($input_file, $asset->type); echo 'Name - ' . $asset->name; echo '<img src="' . $image64Encoded . '" alt="' . $asset->name . '" />'; echo $asset->post_id; echo $asset->asset_id; echo '<hr />'; } die; }
public static function getInstance() { if (null === self::$_instance) { self::$_instance = new self(); } return self::$_instance; }
/** * Get newsfeed item as HTML * * @param Model_NewsfeedItem $item * @return string */ public static function get(Model_NewsfeedItem $item) { $text = ''; switch ($item->type) { case self::TYPE_COMMENT: $gallery = Model_Gallery::factory($item->data['gallery_id']); $image = Model_Image::factory($item->data['image_id']); if ($gallery->loaded() && $image->loaded()) { $text = __('commented to an image<br />:gallery', array(':gallery' => HTML::anchor(Route::url('gallery_image', array('gallery_id' => Route::model_id($gallery), 'id' => $image->id, 'action' => '')), '<i class="icon-camera icon-white"></i> ' . HTML::chars($gallery->name), array('class' => 'hoverable')))); } break; case self::TYPE_COMMENT_FLYER: $flyer = Model_Flyer::factory($item->data['flyer_id']); if ($flyer->loaded()) { $text = __('commented to a flyer<br />:flyer', array(':flyer' => HTML::anchor(Route::url('flyer', array('id' => $flyer->id)), '<i class="icon-picture icon-white"></i> ' . ($flyer->name ? HTML::chars($flyer->name) : __('flyer')), array('class' => 'hoverable')))); } break; case self::TYPE_FLYER_EDIT: $flyer = Model_Flyer::factory($item->data['flyer_id']); if ($flyer->loaded()) { $text = __('updated flyer<br />:flyer', array(':flyer' => HTML::anchor(Route::url('flyer', array('id' => $flyer->id)), '<i class="icon-picture icon-white"></i> ' . ($flyer->name ? HTML::chars($flyer->name) : __('flyer')), array('class' => 'hoverable')))); } break; case self::TYPE_NOTE: $gallery = Model_Gallery::factory($item->data['gallery_id']); $image = Model_Image::factory($item->data['image_id']); $user = Model_User::find_user($item->data['user_id']); if ($gallery->loaded() && $image->loaded() && $user->loaded()) { $text = __('tagged :user to an image<br />:gallery', array(':user' => HTML::user($user), ':gallery' => HTML::anchor(Route::url('gallery_image', array('gallery_id' => Route::model_id($gallery), 'id' => $image->id, 'action' => '')), '<i class="icon-tag icon-white"></i> ' . HTML::chars($gallery->name), array('class' => 'hoverable')))); } break; } return $text; }
public function action_featured($id = false) { $gallery = \Model_Gallery::query()->where('post_id', $id)->get_one(); if (!$gallery) { return \Response::forge(\View::forge('frontend/post/show/image')); } $data['url'] = $gallery->asset->uri . '' . $gallery->asset->name; $data['extension'] = $gallery->asset->type; $this->data['image_url'] = \Request::forge('image/encoder/encodeBase64')->execute($data)->response()->body(); return \Response::forge(\View::forge('frontend/post/show/image')->set($this->data, null, false)); }
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 static function factory($path = NULL, array $values = array()) { if (!Model_Gallery::$_root) { Model_Gallery::$_root = DOCROOT . 'galleri'; } if (!is_null($path)) { $values['path'] = $path; } $obj = new Model_Gallery(); foreach ($values as $key => $value) { $obj->{$key} = $value; } return $obj; }
public function action_save() { $data = (object) filter_input_array(INPUT_POST, FILTER_SANITIZE_STRING); $dataRaw = (object) filter_input_array(INPUT_POST, FILTER_UNSAFE_RAW); $gallery = ORM::factory("gallery"); if (!empty($data->id)) { $gallery = ORM::factory("gallery", $data->id); } $gallery->name = $data->name; $gallery->slug = Model_Gallery::buildSlug($data->slug, $gallery); $gallery->status = $data->status; $gallery->content = $dataRaw->content; $gallery->save(); $this->request->redirect("admin/galleries"); }
public function get_navSubCategories() { /* * Initially get sub categories by post slug and default to world category * On subsequent requests get sub categories by category slug */ $slug = \Input::get('slug'); $slugType = \Input::get('slugType'); /* [ post | category ] */ $category = false; if ($slugType === 'post') { $post = Model_Post::query()->where('slug', $slug)->get_one(); if ($post) { $category = Model_Category::query()->where('id', $post->category_id)->get_one(); $category = Model_Category::query()->where('id', $category->parent_id)->get_one(); if (!$category) { $category = Model_Category::query()->where('id', $post->category_id)->get_one(); } } else { $cat_id = 1; $cat_name = 'world'; } } elseif ($slugType == 'category') { $category = Model_Category::query()->where('slug', $slug)->get_one(); } if (!$category) { $cat_id = 1; $cat_name = 'world'; } else { $cat_id = $category->id; $cat_name = $category->name; } $subCategories = Model_Category::query()->where('parent_id', $cat_id)->get(); $posts = array(); $subSections = array(); $gallery = array(); $data = array(); foreach ($subCategories as $key => $cat) { $subCategories[$key]['posts'] = Model_Post::query()->where('category_id', $cat->id)->related('galleries')->limit(3)->get(); foreach ($subCategories[$key]['posts'] as $k => $post) { $gallery[$key][$k] = \Model_Gallery::query()->where('post_id', $post->id)->related('asset')->get_one(); } } $subCategories['section'] = $cat_name; return $this->response = $subCategories; }
public function readAction() { $pageIDs = explode('_', $this->getRequest()->getRequest('page_id')); $pageID = end($pageIDs); // if($pageID == JO_Registry::get('page_contact')) { // $this->redirect(WM_Router::create($this->getRequest()->getBaseUrl() . '?controller=contacts')); // } if ($this->getRequest()->isXmlHttpRequest() || $this->getRequest()->issetQuery('popup')) { $this->forward('pages', 'ajaxRead'); } $this->view->page = Model_Pages::getPage($pageID); if (!$this->view->page) { $this->forward('error', 'error404'); } if ($this->view->page['parent_id']) { $this->getRequest()->setParams('active_page_id', $this->view->page['parent_id']); } else { $this->getRequest()->setParams('active_page_id', $pageID); } $model_images = new Helper_Images(); $this->view->page['description'] = html_entity_decode($this->view->page['description'], ENT_QUOTES, 'utf-8'); if (JO_Registry::get('config_fix_image_thumb_editor')) { $this->view->page['description'] = $model_images->fixEditorText($this->view->page['description']); } if (JO_Registry::get('config_fix_external_urls')) { $this->view->page['description'] = $this->fixUrl($this->view->page['description']); } $this->view->page['description'] = $this->replaceTags($this->view->page['description']); $this->getLayout()->meta_title = $this->view->page['meta_title'] ? $this->view->page['meta_title'] : $this->view->page['title']; $this->getLayout()->meta_description = $this->view->page['meta_description']; $this->getLayout()->meta_keywords = $this->view->page['meta_keywords']; $this->view->images = array(); $images = Model_Gallery::getGalleryImages($pageID, 'pages'); if ($images) { foreach ($images as $image) { $this->view->images[] = array('title' => $image['title'], 'thumb' => $model_images->resize($image['image'], 91, 47, true), 'popup' => $model_images->resizeWidth($image['image'], 582), 'image' => 'uploads' . $image['image']); } } $this->view->full_url = WM_Router::create($this->getRequest()->getBaseUrl() . '?controller=pages&action=read&page_id=' . $pageID); $this->view->children = array('header_part' => 'layout/header_part', 'footer_part' => 'layout/footer_part', 'left_part' => 'pages/left_part'); }
private function getPageForm() { $request = $this->getRequest(); $page_id = $request->getQuery('id'); $pages_module = new Model_Pages(); if ($page_id) { $page_info = $pages_module->getPage($page_id); } $parent_id = (int) $request->getQuery('parent_id'); $parent_info = Model_Pages::getPage($parent_id); if ($parent_info) { $this->view->parent_title = $parent_info['title']; } $this->view->page_id = $page_id; $this->view->cancel_url = $request->getModule() . '/pages/' . ($parent_id ? '?parent_id=' . $parent_id : ''); if ($request->getPost('in_footer')) { $this->view->in_footer = $request->getPost('in_footer'); } elseif (isset($page_info)) { $this->view->in_footer = $page_info['in_footer']; } else { $this->view->in_footer = 0; } if ($request->getPost('status')) { $this->view->status = $request->getPost('status'); } elseif (isset($page_info)) { $this->view->status = $page_info['status']; } else { $this->view->status = 1; } if ($request->getPost('title')) { $this->view->title = $request->getPost('title'); } elseif (isset($page_info)) { $this->view->title = $page_info['title']; } if ($request->getPost('description')) { $this->view->description = $request->getPost('description'); } elseif (isset($page_info)) { $this->view->description = $page_info['description']; } if ($request->getPost('meta_title')) { $this->view->meta_title = $request->getPost('meta_title'); } elseif (isset($page_info)) { $this->view->meta_title = $page_info['meta_title']; } if ($request->getPost('meta_description')) { $this->view->meta_description = $request->getPost('meta_description'); } elseif (isset($page_info)) { $this->view->meta_description = $page_info['meta_description']; } if ($request->getPost('meta_keywords')) { $this->view->meta_keywords = $request->getPost('meta_keywords'); } elseif (isset($page_info)) { $this->view->meta_keywords = $page_info['meta_keywords']; } if ($request->getRequest('keyword')) { $this->view->keyword = $request->getRequest('keyword'); } elseif (isset($page_info)) { $this->view->keyword = $page_info['keyword']; } if (isset($page_info)) { $images = Model_Gallery::getGalleryImages($page_id, 'pages'); if ($images) { $model_images = new Helper_Images(); $this->view->images = array(); foreach ($images as $image) { $this->view->images[] = array('image_id' => $image['image_id'], 'image' => 'uploads' . $image['image'], 'thumb' => $model_images->resize($image['image'], 100, 100), 'title' => $image['title']); } } } else { $temporary_images = JO_Session::get('temporary_images'); if ($temporary_images) { $model_images = new Helper_Images(); $this->view->images = array(); foreach ($temporary_images as $key => $image) { $this->view->images[] = array('image_id' => $key, 'image' => 'uploads' . $image['image'], 'thumb' => $model_images->resize($image['image'], 100, 100), 'title' => isset($image[JO_Registry::get('config_language_id')]['title']) ? $image[JO_Registry::get('config_language_id')]['title'] : ''); } } } }
/** * Set gallery specific title and actions. * * @param Model_Gallery $gallery */ protected function _set_gallery(Model_Gallery $gallery) { // Set title $images = count($gallery->images()); $this->view->tab = 'gallery'; $this->view->title = $gallery->name; $this->view->subtitle = __($images == 1 ? ':images image' : ':images images', array(':images' => $images)) . ' - ' . HTML::time(Date::format('DMYYYY', $gallery->date), $gallery->date, true); // Set actions $this->view->tabs['galleries']['link'] = Route::url('galleries', array('action' => 'browse', 'year' => date('Y', $gallery->date), 'month' => date('m', $gallery->date))); if ($this->view->actions['upload'] && Permission::has(new Model_Gallery(), Model_Gallery::PERMISSION_UPLOAD, self::$user)) { $this->view->actions['upload']['link'] = Route::model($gallery, 'upload'); } $this->view->tabs['gallery'] = array('link' => Route::model($gallery), 'text' => '<i class="icon-camera icon-white"></i> ' . __('Gallery')); if ($event = $gallery->event()) { $this->view->tabs[] = array('link' => Route::model($event), 'text' => '<i class="icon-calendar icon-white"></i> ' . __('Event') . ' »'); } }
/** * Get user's new comment counts * * @return array */ public function find_new_comments() { $new = array(); // Profile comments if ($this->new_comment_count) { $new['new-comments'] = HTML::anchor(URL::user($this), __(':comments', array(':comments' => '<div></div><var>' . $this->new_comment_count . '</var>')), array('title' => __('New comments'))); } // Blog comments $blog_comments = Model_Blog_Entry::find_new_comments($this); if (count($blog_comments)) { $new_comments = 0; foreach ($blog_comments as $blog_entry) { $new_comments += $blog_entry->new_comment_count; } $new['new-blog-comments'] = HTML::anchor(Route::model($blog_entry), __(':comments', array(':comments' => '<div></div><var>' . $new_comments . '</var>')), array('title' => __('New blog comments'))); } unset($blog_comments); // Forum quotes $forum_quotes = Model_Forum_Quote::find_by_user($this); if (count($forum_quotes)) { $new_quotes = count($forum_quotes); $quote = $forum_quotes->current(); $new['new-forum-quotes'] = HTML::anchor(Route::get('forum_post')->uri(array('topic_id' => Route::model_id($quote->topic), 'id' => $quote->post->id)) . '#post-' . $quote->post->id, __(':quotes', array(':quotes' => '<div></div><var>' . $new_quotes . '</var>')), array('title' => __('Forum quotes'))); } // Images waiting for approval if (Permission::has(new Model_Gallery(), Model_Gallery::PERMISSION_APPROVE_WAITING, $this)) { $gallery_approvals = Model_Gallery::find_pending(Permission::has(new Model_Gallery(), Model_Gallery::PERMISSION_APPROVE, $this) ? null : $this); if (count($gallery_approvals)) { $new_approvals = count($gallery_approvals); $new['new-gallery-approvals'] = HTML::anchor(Route::get('galleries')->uri(array('action' => 'approval')), __(':galleries', array(':galleries' => '<div></div><var>' . $new_approvals . '</var>')), array('title' => __('Galleries waiting for approval'))); } } // Image comments $image_comments = Model_Image::find_new_comments($this); if (count($image_comments)) { $new_comments = 0; foreach ($image_comments as $image) { $new_comments += $image->new_comment_count; } $new['new-image-comments'] = HTML::anchor(Route::get('gallery_image')->uri(array('gallery_id' => Route::model_id(Model_Gallery::find_by_image($image->id)), 'id' => $image->id, 'action' => '')), __(':comments', array(':comments' => '<div></div><var>' . $new_comments . '</var>')), array('title' => __('New image comments'))); } unset($image_comments); // Private messages return $new; }
public function action_view($galleri) { $this->template->title = 'Änglarna Stockholms galleri: ' . html::chars($galleri); $this->template->content = View::factory('galleri/view')->set('images', Model_Gallery::factory($galleri)->load()->images)->set('title', $galleri); }
public static function deletePage($page_id) { $db = JO_Db::getDefaultAdapter(); $pages = self::getPages(array('parent_id' => $page_id)); if ($pages) { foreach ($pages as $page) { self::deletePage($page['page_id']); } } $images = Model_Gallery::getGalleryImages($page_id, 'pages'); if ($images) { foreach ($images as $image) { Model_Gallery::deleteImage($image['image_id']); } } $db->delete('pages', array('page_id = ?' => (int) $page_id)); $db->query("DELETE FROM url_alias WHERE query = 'page_id=" . (int) $page_id . "'"); }
/** * Render view. * * @return string */ public function content() { ob_start(); $images = $this->gallery->images(); $copyright = $multiple = null; foreach ($images as $image) { // Add copyright if ($image->author_id != $copyright) { $copyright = $image->author_id; if ($multiple) { // Not first copyright ?> </div> <?php } else { // First copyright $multiple = true; } ?> <header><h3>© <?php echo HTML::user($copyright); ?> </h3></header> <div class="row"> <?php } // Copyright ?> <article class="col-xs-6 col-md-4 col-lg-3"> <div class="thumbnail"> <?php echo HTML::anchor(Route::url('gallery_image', array('gallery_id' => Route::model_id($this->gallery), 'id' => $image->id, 'action' => '')), HTML::image($image->get_url('thumbnail', $this->gallery->dir))); ?> <small class="stats label label-default"> <?php echo (int) $image->view_count; ?> <i class="fa fa-eye"></i> <?php if ($image->comment_count) { ?> <?php echo (int) $image->comment_count; ?> <i class="fa fa-comment"></i> <?php } ?> </small> </div> </article> <?php } ?> </div> <?php return ob_get_clean(); }
/** * Get anchor to newsfeed item target. * * @static * @param Model_NewsfeedItem $item * @return string */ public static function get_link(Model_NewsfeedItem $item) { $text = ''; switch ($item->type) { // Image case self::TYPE_COMMENT: case self::TYPE_NOTE: $gallery = Model_Gallery::factory($item->data['gallery_id']); $image = Model_Image::factory($item->data['image_id']); if ($gallery->loaded() && $image->loaded()) { $text = HTML::anchor(Route::url('gallery_image', array('gallery_id' => Route::model_id($gallery), 'id' => $image->id, 'action' => '')), '<i class="fa fa-camera-retro"></i> ' . HTML::chars($gallery->name), array('class' => 'hoverable')); } break; // Flyer // Flyer case self::TYPE_COMMENT_FLYER: case self::TYPE_FLYER_EDIT: $flyer = Model_Flyer::factory($item->data['flyer_id']); if ($flyer->loaded()) { $text = HTML::anchor(Route::url('flyer', array('id' => $flyer->id)), '<i class="fa fa-picture"></i> ' . ($flyer->name ? HTML::chars($flyer->name) : __('flyer')), array('class' => 'hoverable')); } break; // Gallery // Gallery case self::TYPE_UPLOAD: $gallery = Model_Gallery::factory($item->data['gallery_id']); if ($gallery->loaded()) { $text = HTML::anchor(Route::model($gallery), '<i class="fa fa-camera-retro"></i> ' . HTML::chars($gallery->name), array('class' => 'hoverable')); } break; } return $text; }
public function pageAction() { $this->view->menu_page = 'selected'; $this->view->item = $this->_getParam('item', 'new'); $this->view->lang = $this->_getParam('lang', 'ua'); $this->view->pages = Model_Page::getAll(); $this->view->galleries = Model_Gallery::getAll('image'); $this->view->videos = Model_Gallery::getAll('video'); $this->view->audios = Model_Gallery::getAll('audio'); $this->view->actionname = '/admin/savepage'; $this->view->idname = 'idpage'; //перевіряємо на видалення $delete = $this->_getParam('delete', false); if ($delete && Zend_Validate::is($this->view->item, 'Digits')) { Model_Page::deletepage($this->view->item); $this->_redirect('/admin/page'); } // якщо треба отримати дані за id сторінки if (Zend_Validate::is($this->view->item, 'Digits')) { $this->view->data = Model_Page::getById($this->view->item, $this->view->lang); } else { $this->view->data = Model_Page::getById(NULL); } }
/** * Get user's new comment counts. * * @param Model_User $user * @return array */ public static function notifications(Model_User $user) { $new = array(); // Profile comments if ($user->new_comment_count) { $new['new-comments'] = HTML::anchor(URL::user($user), '<i class="icon-comment icon-white"></i> ' . $user->new_comment_count, array('class' => 'badge badge-info', 'title' => __('New comments'))); } // Forum private messages $private_messages = Forum::find_new_private_messages($user); if (count($private_messages)) { $new_messages = 0; foreach ($private_messages as $private_message) { $new_messages += $private_message->unread; } $new['new-private-messages'] = HTML::anchor(Route::model($private_message->topic()) . '?page=last#last', '<i class="icon-comment icon-white"></i> ' . $new_messages, array('class' => 'badge badge-info', 'title' => __('New private messages'))); } unset($private_messages); // Blog comments $blog_comments = Model_Blog_Entry::factory()->find_new_comments($user); if (count($blog_comments)) { $new_comments = 0; foreach ($blog_comments as $blog_entry) { $new_comments += $blog_entry->new_comment_count; } $new['new-blog-comments'] = HTML::anchor(Route::model($blog_entry), '<i class="icon-comment icon-white"></i> ' . $new_comments, array('class' => 'badge badge-info', 'title' => __('New blog comments'))); } unset($blog_comments); // Forum quotes $forum_quotes = Model_Forum_Quote::factory()->find_by_user($user); if (count($forum_quotes)) { $new_quotes = count($forum_quotes); $quote = $forum_quotes->current(); $new['new-forum-quotes'] = HTML::anchor(Route::get('forum_post')->uri(array('topic_id' => $quote->forum_topic_id, 'id' => $quote->forum_post_id)) . '#post-' . $quote->forum_post_id, '<i class="icon-comment icon-white"></i> ' . $new_quotes, array('class' => 'badge badge-info', 'title' => __('Forum quotes'))); } // Images waiting for approval if (Permission::has(new Model_Gallery(), Model_Gallery::PERMISSION_APPROVE_WAITING, $user)) { $gallery_approvals = Model_Gallery::factory()->find_pending(Permission::has(new Model_Gallery(), Model_Gallery::PERMISSION_APPROVE, $user) ? null : $user); if (count($gallery_approvals)) { $new_approvals = count($gallery_approvals); $new['new-gallery-approvals'] = HTML::anchor(Route::get('galleries')->uri(array('action' => 'approval')), '<i class="icon-exclamation-sign icon-white"></i> ' . $new_approvals, array('class' => 'badge badge-warning', 'title' => __('Galleries waiting for approval'))); } } // Flyer comments $flyer_comments = Model_Flyer::factory()->find_new_comments($user); $flyers = array(); if (count($flyer_comments)) { $new_comments = 0; foreach ($flyer_comments as $flyer) { $flyers[$flyer->image_id] = true; $new_comments += $flyer->image()->new_comment_count; } $new['new-flyer-comments'] = HTML::anchor(Route::get('flyer')->uri(array('id' => $flyer->id, 'action' => '')), '<i class="icon-picture icon-white"></i> ' . $new_comments, array('class' => 'badge badge-info', 'title' => __('New flyer comments'))); } unset($flyer_comments); // Image comments $image_comments = Model_Image::factory()->find_new_comments($user); $note_comments = Model_Image_Note::factory()->find_new_comments($user); if (count($image_comments) || count($note_comments)) { $new_comments = 0; $new_image = null; foreach ($image_comments as $image) { // @TODO: Until flyer comments are fixed.. if (!isset($flyers[$image->id])) { $new_comments += $image->new_comment_count; $new_image_id = $image->id; } } foreach ($note_comments as $note) { $new_comments += $note->new_comment_count; $new_image_id = $note->image_id; } if ($new_comments) { $new['new-image-comments'] = HTML::anchor(Route::get('gallery_image')->uri(array('gallery_id' => Route::model_id(Model_Gallery::find_by_image($new_image_id)), 'id' => $new_image_id, 'action' => '')), '<i class="icon-camera icon-white"></i> ' . $new_comments, array('class' => 'badge badge-info', 'title' => __('New image comments'))); } } unset($image_comments, $note_comments, $new_image); // Image tags $notes = Model_Image_Note::factory()->find_new_notes($user); if (count($notes)) { $new_notes = 0; $new_note_image_id = null; /** @var Model_Image_Note $note */ foreach ($notes as $note) { $new_notes++; $new_note_image_id = $note->image_id; } if ($new_notes) { $new['new-image-notes'] = HTML::anchor(Route::get('gallery_image')->uri(array('gallery_id' => Route::model_id(Model_Gallery::find_by_image($new_note_image_id)), 'id' => $new_note_image_id, 'action' => '')), '<i class="icon-tag icon-white"></i> ' . $new_notes, array('class' => 'badge badge-info', 'title' => __('New image tags'))); } } unset($note_comments, $new_note_image_id); return $new; }
/** * Render view. * * @return string */ public function content() { ob_start(); // Get shown images if ($this->show_pending) { // Show pending images $images = $this->gallery->find_images_pending($this->can_approve ? null : self::$_user); $radios = array(); if ($this->can_approve) { $radios['approve'] = __('Approve'); } $radios['deny'] = $this->can_approve ? __('Deny') : __('Delete'); $radios['wait'] = __('Wait'); ?> <header class="well sticky"> <?php if ($this->can_approve) { echo __('Approve'), ': <var class="approve"">0</var>, '; echo __('Deny'), ': <var class="deny"">0</var>, '; } else { echo __('Delete'), ': <var class="deny"">0</var>, '; } echo __('Wait'), ': <var class="wait">', count($images), '</var><br />'; ?> </header> <?php } else { // Show approved images $images = $this->gallery->images(); } // Add pending images form? if ($this->show_pending) { echo Form::open(null, array('id' => 'form-image-approval', 'class' => 'form-horizontal')); } $copyright = $multiple = null; foreach ($images as $image) { // Add copyright if ($image->author_id != $copyright) { $copyright = $image->author_id; if ($multiple) { // Not first copyright ?> </ul> <?php } else { // First copyright $multiple = true; } ?> <header>© <?php echo HTML::user($copyright); ?> </header> <ul class="thumbnails"> <?php } // Copyright ?> <li class="span2"> <?php echo HTML::anchor(Route::url('gallery_image', array('gallery_id' => Route::model_id($this->gallery), 'id' => $image->id, 'action' => $this->show_pending ? 'approve' : '')), HTML::image($image->get_url('thumbnail', $this->gallery->dir)), $image->description ? array('class' => 'thumbnail', 'title' => HTML::chars($image->description)) : array('class' => 'thumbnail')); if (!$this->show_pending) { // Info echo '<i class="icon-comment icon-white"></i> ' . (int) $image->comment_count; echo '<i class="icon-eye-open icon-white"></i> ' . (int) $image->view_count; } else { // Pending image form echo Form::radios_wrap('image_id[' . $image->id . ']', $radios, 'wait'); } ?> </li> <?php } // Images ?> </ul> <?php // Form controls if ($this->show_pending) { ?> <fieldset class="form-actions"> <?php echo Form::radios_wrap('all', $radios, null, null, __('For all images'), null, null, 'inline'); echo Form::csrf(); echo Form::button('approve', __('Save'), array('type' => 'submit', 'class' => 'btn btn-success btn-large')), ' '; echo HTML::anchor(Route::url('galleries', array('action' => 'approval')), __('Cancel'), array('class' => 'cancel')); ?> </fieldset> <?php echo Form::close(); ?> <script> head.ready('jquery', function() { // Calculate totals function totals() { $.each([ 'approve', 'deny', 'wait' ], function totals() { $('var.' + this).text($('input[name!=all][value=' + this + ']:checked').length); }); } // Actions for all images $('form input[name=all]').change(function onChangeAll() { $('form input[value=' + $(this).val() + ']').attr('checked', 'checked'); totals(); }); // Single image actions $('form input[name^=image_id]').change(function onChangeOne() { $('input[name=all]').removeAttr('checked'); totals(); }); }); </script> <?php } return ob_get_clean(); }
public function action_show_featured_story($slug = false) { // Get post by slug $post = $this->data['post'] = Model_Post::query()->where('id', 25)->get_one(); $gallery = \Model_Gallery::query()->where('post_id', $post->id)->get_one(); $data['url'] = $gallery->asset->uri . '' . $gallery->asset->name; $data['extension'] = $gallery->asset->type; $this->data['featured_image'] = \Request::forge('image/encoder/encodeBase64')->execute($data)->response()->body(); if (!$post) { \Messages::error(__('frontend.post.not-found')); \Response::redirect_back(\Router::get('homepage')); } return \Response::forge(\View::forge('frontend/post/show/featured')->set($this->data, null, false)); }