/** * Action: index */ public function action_index() { // Go to post? $topic_id = (int) $this->request->param('topic_id'); if ($topic_id) { $post_id = (int) $this->request->param('id'); } else { $topic_id = (int) $this->request->param('id'); } // Load topic /** @var Model_Forum_Private_Topic|Model_Forum_Topic $topic */ $topic = $this->private ? Model_Forum_Private_Topic::factory($topic_id) : Model_Forum_Topic::factory($topic_id); if (!$topic->loaded()) { throw new Model_Exception($topic, $topic_id); } Permission::required($topic, Model_Forum_Topic::PERMISSION_READ, self::$user); // Did we request single post with ajax? if (($this->ajax || $this->internal) && isset($post_id)) { $this->history = false; $post = $this->private ? Model_Forum_Private_Post::factory($post_id) : Model_Forum_Post::factory($post_id); if (!$post->loaded()) { throw new Model_Exception($topic, $topic_id); } // Permission is already checked by the topic, no need to check for post $this->response->body($this->section_post($topic, $post)); return; } // Update counts if ($this->private) { $topic->mark_as_read(self::$user); } if (!self::$user || $topic->author_id != self::$user->id) { $topic->read_count++; $topic->save(); } // Build page $this->view = new View_Page(); $this->view->title_html = Forum::topic($topic); $this->view->subtitle = __($topic->post_count == 1 ? ':posts post' : ':posts posts', array(':posts' => Num::format($topic->post_count, 0))); $this->view->tab = 'topic'; $this->page_actions['topic'] = array('link' => Route::model($topic), 'text' => '<i class="icon-comment icon-white"></i> ' . __('Topic')); // Public topic extras if (!$this->private) { // Quotes are supported only in public forum as we get notifications anyway in private if (self::$user) { $quotes = Model_Forum_Quote::factory()->find_by_user(self::$user); if (count($quotes)) { foreach ($quotes as $quote) { if ($topic->id == $quote->forum_topic_id) { $quote->delete(); break; } } } } // Facebook if (Kohana::$config->load('site.facebook')) { Anqh::open_graph('title', $topic->name); Anqh::open_graph('url', URL::site(Route::url('forum_topic', array('id' => $topic->id, 'action' => '')), true)); } Anqh::share(true); // Model binding $area = $topic->area(); if ($area->type == Model_Forum_Area::TYPE_BIND && $topic->bind_id) { if ($bind = Model_Forum_Area::get_binds($area->bind)) { $model = AutoModeler::factory($bind['model'], $topic->bind_id); if ($model->loaded()) { // Set actions $this->page_actions[] = array('link' => Route::model($model), 'text' => $bind['link']); // Set views foreach ((array) $bind['view'] as $view) { $this->view->add(View_Page::COLUMN_SIDE, View_Module::factory($view, array($bind['model'] => $model)), Widget::TOP); } } } } } // Public topic extras // Set actions if (Permission::has($topic, Model_Forum_Topic::PERMISSION_POST, self::$user)) { $this->view->actions[] = array('link' => Request::current_uri() . '#reply', 'text' => '<i class="icon-comment icon-white"></i> ' . __('Reply to topic'), 'class' => 'btn btn-primary topic-post'); } if (Permission::has($topic, Model_Forum_Topic::PERMISSION_UPDATE, self::$user)) { $this->view->actions[] = array('link' => Route::model($topic, 'edit'), 'text' => '<i class="icon-edit icon-white"></i> ' . __('Edit topic')); } // Breadcrumbs $this->page_breadcrumbs[] = HTML::anchor(Route::url('forum_group'), __('Forum')); $this->page_breadcrumbs[] = HTML::anchor(Route::model($topic->area()), $topic->area()->name); // Pagination $this->view->add(View_Page::COLUMN_MAIN, $pagination = $this->section_pagination($topic)); $this->view->subtitle .= ', ' . __($pagination->total_pages == 1 ? ':pages page' : ':pages pages', array(':pages' => Num::format($pagination->total_pages, 0))); $this->view->subtitle .= ', ' . __($topic->read_count == 1 ? ':views view' : ':views views', array(':views' => Num::format($topic->read_count, 0))); // Go to post? if (isset($post_id)) { $pagination->item($topic->get_post_number($post_id) + 1); // We need to set pagination urls manually if jumped to a post $pagination->base_url = Route::model($topic); } // Recipients if ($this->private) { $this->view->add(View_Page::COLUMN_MAIN, $this->section_recipients($topic)); $this->view->add(View_Page::COLUMN_MAIN, '<hr />'); } // Posts $this->view->add(View_Page::COLUMN_MAIN, $this->section_topic($topic, $pagination)); // Reply if (Permission::has($topic, Model_Forum_Topic::PERMISSION_POST, self::$user)) { $section = $this->section_post_edit(View_Forum_PostEdit::REPLY, $this->private ? Model_Forum_Private_Post::factory() : Model_Forum_Post::factory()); $section->forum_topic = $topic; $this->view->add(View_Page::COLUMN_MAIN, $section); } // Pagination $this->view->add(View_Page::COLUMN_MAIN, $pagination); $this->_side_views(); }
/** * Action: image */ public function action_image() { $gallery_id = (int) $this->request->param('gallery_id'); $image_id = $this->request->param('id'); /** @var Model_Gallery $gallery */ $gallery = Model_Gallery::factory($gallery_id); if (!$gallery->loaded()) { throw new Model_Exception($gallery, $gallery_id); } // Are we approving pending images? if ($this->request->action() == 'approve') { // Can we see galleries with un-approved images? Permission::required($gallery, Model_Gallery::PERMISSION_APPROVE_WAITING, self::$user); // Can we see all of them and approve? $approve = Permission::has($gallery, Model_Gallery::PERMISSION_APPROVE, self::$user); $images = $gallery->find_images_pending($approve ? null : self::$user); } else { Permission::required($gallery, Model_Gallery::PERMISSION_READ, self::$user); $images = $gallery->images(); } // Find current, previous and next images $i = 0; /** @var Model_Image $next */ /** @var Model_Image $previous */ /** @var Model_Image $current */ $previous = $next = $current = null; foreach ($images as $image) { $i++; if (!is_null($current)) { // Current was found last round $next = $image; $i--; break; } else { if ($image->id == $image_id) { // Current found now $current = $image; // Fix state to loaded to perform update instead of insert when saving $current->state(AutoModeler::STATE_LOADED); } else { // No current found $previous = $image; } } } // Show image if (!is_null($current)) { // Comments section if (!isset($approve) && Permission::has($gallery, Model_Gallery::PERMISSION_COMMENTS, self::$user)) { $errors = array(); $values = array(); // Handle comment if (Permission::has($gallery, Model_Gallery::PERMISSION_COMMENT, self::$user) && $_POST) { try { $comment = Model_Image_Comment::factory()->add(self::$user->id, $current, Arr::get($_POST, 'comment'), Arr::get($_POST, 'private')); $current->comment_count++; if ($current->author_id != self::$user->id) { $current->new_comment_count++; } $current->save(); $gallery->comment_count++; $gallery->save(); if (!$comment->private) { // Noted users foreach ($current->notes() as $note) { $note->state(AutoModeler::STATE_LOADED); $note->new_comment_count++; $note->save(); } // Newsfeed NewsfeedItem_Galleries::comment(self::$user, $gallery, $current); } // Redirect back to image if not ajax if ($this->_request_type !== Controller::REQUEST_AJAX) { $this->request->redirect(Route::url('gallery_image', array('gallery_id' => Route::model_id($gallery), 'id' => $current->id, 'action' => ''))); return; } } catch (Validation_Exception $e) { $errors = $e->array->errors('validation'); $values = $comment; } } else { if (self::$user) { // Clear new comment count? if ($current->author_id == self::$user->id && $current->new_comment_count > 0) { $current->new_comment_count = 0; $current->save(); } foreach ($current->notes() as $note) { if ($note->user_id == self::$user->id) { $note->state(AutoModeler::STATE_LOADED); $save = false; if ($note->new_comment_count > 0) { $note->new_comment_count = 0; $save = true; } if ($note->new_note > 0) { $note->new_note = null; $save = true; } if ($save) { $note->save(); } } } } } // Get view $section_comments = $this->section_image_comments($current); $section_comments->errors = $errors; $section_comments->values = $values; } else { if (!self::$user) { // Guest user $section_comments = $this->section_image_comments_teaser($current->comment_count); } } if (isset($section_comments) && $this->_request_type === Controller::REQUEST_AJAX) { $this->response->body($section_comments); return; } // Build page $this->view = View_Page::factory(__('Gallery')); // Image actions if (Permission::has($gallery, Model_Gallery::PERMISSION_UPDATE, self::$user)) { $this->view->actions[] = array('link' => Route::url('gallery_image', array('gallery_id' => Route::model_id($gallery), 'id' => $current->id, 'action' => 'default')) . '?token=' . Security::csrf(), 'text' => '<i class="icon-home icon-white"></i> ' . __('Set default'), 'class' => 'btn-inverse image-default'); } if (Permission::has($current, Model_Image::PERMISSION_DELETE, self::$user)) { $this->view->actions[] = array('link' => Route::url('gallery_image', array('gallery_id' => Route::model_id($gallery), 'id' => $current->id, 'action' => 'delete')) . '?token=' . Security::csrf(), 'text' => '<i class="icon-trash icon-white"></i> ' . __('Delete'), 'class' => 'btn-inverse image-delete'); } // Gallery actions $this->_set_page_actions(Permission::has(new Model_Gallery(), Model_Gallery::PERMISSION_CREATE, self::$user)); $this->_set_gallery($gallery); array_unshift($this->view->tabs, array('link' => Route::model($gallery), 'text' => '« ' . __('Gallery'))); $this->view->tabs['gallery'] = array('link' => Route::url('gallery_image', array('gallery_id' => Route::model_id($gallery), 'id' => $current->id)), 'text' => '<i class="icon-camera icon-white"></i> ' . __('Photo')); // Pagination $previous_url = $previous ? Route::url('gallery_image', array('gallery_id' => Route::model_id($gallery), 'id' => $previous->id, 'action' => $approve ? 'approve' : '')) . '#title' : null; $next_url = $next ? Route::url('gallery_image', array('gallery_id' => Route::model_id($gallery), 'id' => $next->id, 'action' => $approve ? 'approve' : '')) . '#title' : null; $this->view->add(View_Page::COLUMN_TOP, $this->section_image_pagination($previous_url, $next_url, $i, count($images))); // Image if (!isset($approve)) { $current->view_count++; $current->save(); } $this->view->add(View_Page::COLUMN_TOP, $this->section_image($current, $gallery, $next_url, (bool) $approve)); // Comments if (isset($section_comments)) { $this->view->add(View_Page::COLUMN_MAIN, $section_comments); } // Share if (Kohana::$config->load('site.facebook')) { Anqh::open_graph('title', __('Image') . ': ' . $gallery->name); Anqh::open_graph('url', URL::site(Route::url('gallery_image', array('id' => $current->id, 'gallery_id' => $gallery->id, 'action' => '')), true)); if ($current->description) { Anqh::open_graph('description', $current->description); } Anqh::open_graph('image', URL::site($current->get_url('thumbnail'), true)); } Anqh::share(true); $this->view->add(View_Page::COLUMN_SIDE, $this->section_share()); // Image info $this->view->add(View_Page::COLUMN_SIDE, $this->section_image_info($current)); } }
/** * Destroy controller */ public function after() { if ($this->ajax || $this->internal) { // AJAX and HMVC requests $this->response->body($this->response->body() . ''); } else { if ($this->auto_render) { // Normal requests $session = Session::instance(); // Save current URI /* Moved to Controller if ($this->history && $this->response->status() < 400) { $uri = $this->request->current_uri(); unset($this->breadcrumb[$uri]); $this->breadcrumb = array_slice($this->breadcrumb, -9, 9, true); $this->breadcrumb[$uri] = $this->page_title; $session ->set('history', $uri . ($_GET ? URL::query($_GET) : '')) ->set('breadcrumb', $this->breadcrumb); } */ // Controller name as the default page id if none set empty($this->page_id) and $this->page_id = $this->request->controller(); // Stylesheets $styles = array('ui/boot.css' => null, 'ui/typo.css' => null, 'ui/base.css' => null, 'ui/jquery-ui.css' => null, 'http://fonts.googleapis.com/css?family=Nobile:regular,bold' => null); // Generic views Widget::add('breadcrumb', View::factory('generic/breadcrumb', array('breadcrumb' => $this->breadcrumb, 'last' => !$this->history))); Widget::add('actions', View::factory('generic/actions', array('actions' => $this->page_actions))); Widget::add('navigation', View::factory('generic/navigation', array('items' => Kohana::$config->load('site.menu'), 'selected' => $this->page_id))); if (!empty($this->tabs)) { Widget::add('subnavigation', View::factory('generic/navigation', array('items' => $this->tabs, 'selected' => $this->tab_id))); } /* Widget::add('tabs', View::factory('generic/tabs_top', array( 'tabs' => $this->tabs, 'selected' => $this->tab_id ))); */ // Footer Widget::add('footer', View_Module::factory('events/event_list', array('mod_id' => 'footer-events-new', 'mod_class' => 'article grid4 first cut events', 'mod_title' => __('New events'), 'events' => Model_Event::factory()->find_new(10)))); Widget::add('footer', View_Module::factory('forum/topiclist', array('mod_id' => 'footer-topics-active', 'mod_class' => 'article grid4 cut topics', 'mod_title' => __('New posts'), 'topics' => Model_Forum_Topic::factory()->find_by_latest_post(10)))); Widget::add('footer', View_Module::factory('blog/entry_list', array('mod_id' => 'footer-blog-entries', 'mod_class' => 'article grid4 cut blogentries', 'mod_title' => __('New blogs'), 'entries' => Model_Blog_Entry::factory()->find_new(10)))); // Skin $skins = Kohana::$config->load('site.skins'); $skin = 'dark'; //$session->get('skin', 'dark'); $skin_imports = array('ui/mixin.less', 'ui/grid.less', 'ui/layout.less', 'ui/widget.less', 'ui/custom.less'); // Dock $classes = array(); foreach ($skins as $skin_name => &$skin_config) { $skin_config['path'] = 'ui/' . $skin_name . '/skin.less'; $classes[] = HTML::anchor(Route::get('setting')->uri(array('action' => 'skin', 'value' => $skin_name)), $skin_config['name'], array('class' => 'theme', 'rel' => $skin_name)); } //Widget::add('dock', __('Theme') . ': ' . implode(', ', $classes)); // Language selection $available_languages = Kohana::$config->load('locale.languages'); if (count($available_languages)) { $languages = array(); foreach ($available_languages as $lang => $locale) { $languages[] = HTML::anchor('set/lang/' . $lang, HTML::chars($locale[2])); } // Widget::add('dock', ' | ' . __('Language: ') . implode(', ', $languages)); } // Search /* Widget::add('search', View_Module::factory('generic/search', array( 'mod_id' => 'search' ))); */ // Visitor card Widget::add('visitor', View::factory('generic/visitor', array('user' => self::$user))); // Time & weather Widget::add('dock', ' | ' . View::factory('generic/clock', array('user' => self::$user))); // Pin Widget::add('dock', ' | ' . HTML::anchor('#pin', '▲', array('title' => __('Lock menu'), 'class' => 'icon unlock', 'onclick' => '$("#header").toggleClass("pinned"); return false;'))); // End Widget::add('end', View::factory('generic/end')); // Analytics if ($google_analytics = Kohana::$config->load('site.google_analytics')) { Widget::add('head', HTML::script_source("\nvar tracker;\nhead.js(\n\t{ 'google-analytics': 'http://www.google-analytics.com/ga.js' },\n\tfunction() {\n\t\ttracker = _gat._getTracker('" . $google_analytics . "');\n\t\ttracker._trackPageview();\n\t}\n);\n")); } // Open Graph $og = array(); foreach ((array) Anqh::open_graph() as $key => $value) { $og[] = '<meta property="' . $key . '" content="' . HTML::chars($value) . '" />'; } if (!empty($og)) { Widget::add('head', implode("\n", $og)); } // Share if (Anqh::share()) { if ($share = Kohana::$config->load('site.share')) { // 3rd party share Widget::add('share', View_Module::factory('share/share', array('mod_class' => 'like', 'id' => $share))); Widget::add('foot', View::factory('share/foot', array('id' => $share))); } else { if ($facebook = Kohana::$config->load('site.facebook')) { // Facebook Like Widget::add('share', View_Module::factory('facebook/like')); Widget::add('ad_top', View::factory('facebook/connect', array('id' => $facebook))); } } } // Ads $ads = Kohana::$config->load('site.ads'); if ($ads && $ads['enabled']) { foreach ($ads['slots'] as $ad => $slot) { Widget::add($slot, View::factory('ads/' . $ad), Widget::MIDDLE); } } // And finally the profiler stats if (self::$user && self::$user->has_role('admin')) { //in_array(Kohana::$environment, array(Kohana::DEVELOPMENT, Kohana::TESTING))) { Widget::add('foot', View::factory('generic/debug')); Widget::add('foot', View::factory('profiler/stats')); } // Do some CSS magic to page class $page_class = explode(' ', $this->language . ' ' . $session->get('page_width', 'fixed') . ' ' . $session->get('page_main', 'left') . ' ' . $this->request->action() . ' ' . $this->page_class); // Controller set classes $page_class = implode(' ', array_unique(array_map('trim', $page_class))); // Bind the generic page variables $this->template->set('styles', $styles)->set('skin', $skin)->set('skins', $skins)->set('skin_imports', $skin_imports)->set('language', $this->language)->set('page_id', $this->page_id)->set('page_class', $page_class)->set('page_title', $this->page_title)->set('page_subtitle', $this->page_subtitle); // Add statistics $queries = 0; if (Kohana::$profiling) { foreach (Profiler::groups() as $group => $benchmarks) { if (strpos($group, 'database') === 0) { $queries += count($benchmarks); } } } $total = array('{memory_usage}' => number_format((memory_get_peak_usage() - KOHANA_START_MEMORY) / 1024, 2) . 'KB', '{execution_time}' => number_format(microtime(true) - KOHANA_START_TIME, 5), '{database_queries}' => $queries, '{included_files}' => count(get_included_files())); $this->template = strtr($this->template, $total); // Render page if ($this->auto_render === true) { $this->response->body($this->template); } } } return parent::after(); }
<?php defined('SYSPATH') or die('No direct access allowed.'); /** * AddThis * * @package Anqh * @author Antti Qvickström * @copyright (c) 2011 Antti Qvickström * @license http://www.opensource.org/licenses/mit-license.php MIT license */ $attributes = array(); // Custom URL if ($url = Anqh::open_graph('url')) { $attributes['addthis:url'] = $url; } // Custom title if ($title = Anqh::open_graph('title')) { $attributes['addthis:title'] = $title; } ?> <div class="addthis_toolbox addthis_pill_combo"<?php echo HTML::attributes($attributes); ?> > <a class="addthis_button_facebook_like"></a> <a class="addthis_button_tweet" tw:count="horizontal"></a> <a class="addthis_counter addthis_pill_style"></a> </div>
/** * Action: event */ public function action_event() { $event_id = (int) $this->request->param('id'); // Load event /** @var Model_Event $event */ $event = Model_Event::factory($event_id); if (!$event->loaded()) { throw new Model_Exception($event, $event_id); } Permission::required($event, Model_Event::PERMISSION_READ, self::$user); // Build page $this->view = View_Page::factory($event->name); $this->view->subtitle = $this->_event_subtitle($event); // Set actions if (Permission::has($event, Model_Event::PERMISSION_FAVORITE, self::$user)) { if ($event->is_favorite(self::$user)) { $this->view->actions[] = array('link' => Route::model($event, 'unfavorite') . '?token=' . Security::csrf(), 'text' => '<i class="icon-heart icon-white"></i> ' . __('Remove favorite'), 'class' => 'btn-inverse favorite-delete'); } else { $this->view->actions[] = array('link' => Route::model($event, 'favorite') . '?token=' . Security::csrf(), 'text' => '<i class="icon-heart icon-white"></i> ' . __('Add to favorites'), 'class' => 'btn-lovely favorite-add'); } } $this->view->tab = 'event'; $this->view->tabs['event'] = array('link' => Route::model($event), 'text' => '<i class="icon-calendar icon-white"></i> ' . __('Event')); $this->view->tabs[] = array('link' => Route::get('gallery_event')->uri(array('id' => $event->id)), 'text' => '<i class="icon-camera icon-white"></i> ' . __('Gallery') . ' »'); $this->view->tabs[] = array('link' => Route::get('forum_event')->uri(array('id' => $event->id)), 'text' => '<i class="icon-comment icon-white"></i> ' . __('Forum') . ' »'); if (Permission::has($event, Model_Event::PERMISSION_UPDATE, self::$user)) { $this->view->actions[] = array('link' => Route::model($event, 'edit'), 'text' => '<i class="icon-edit icon-white"></i> ' . __('Edit event')); $this->view->actions[] = array('link' => Route::model($event, 'image'), 'text' => '<i class="icon-picture icon-white"></i> ' . __('Add flyer'), 'class' => !count($event->flyers()) ? 'btn btn-primary' : null); } // Share if (Kohana::$config->load('site.facebook')) { Anqh::open_graph('type', 'activity'); Anqh::open_graph('title', $event->name); Anqh::open_graph('url', URL::site(Route::get('event')->uri(array('id' => $event->id, 'action' => '')), true)); Anqh::open_graph('description', date('l ', $event->stamp_begin) . Date::format(Date::DMY_SHORT, $event->stamp_begin) . ' @ ' . $event->venue_name); if ($event->flyer_front()) { Anqh::open_graph('image', $event->flyer_front()->get_url('thumbnail')); } } Anqh::share(true); // Event main info $this->view->add(View_Page::COLUMN_MAIN, $this->section_event_main($event)); $this->view->add(View_Page::COLUMN_SIDE, $this->section_share()); // Flyers $this->view->add(View_Page::COLUMN_SIDE, $this->section_carousel($event)); // Event side info $this->view->add(View_Page::COLUMN_SIDE, $this->section_event_info($event)); // Favorites if ($event->favorite_count) { $this->view->add(View_Page::COLUMN_SIDE, $this->section_event_favorites($event)); } }
/** * Destroy controller. */ public function after() { if ($this->_request_type !== Controller::REQUEST_INITIAL) { // AJAX and HMVC requests $this->response->body((string) $this->response->body()); } else { if ($this->auto_render) { // Normal requests // Stylesheets $styles = array('ui/jquery-ui.css', 'http://fonts.googleapis.com/css?family=Terminal+Dosis'); // Skins $selected_skin = $this->session->get('skin', 'blue'); // Less files needed to build a skin $less_imports = array('ui/mixin.less', 'ui/anqh.less'); $skins = array(HTML::style('static/css/bootstrap.css'), HTML::style('static/css/bootstrap-responsive.css')); foreach (array('blue') as $skin) { $skinsi[] = Less::style('ui/' . $skin . '.less', array('title' => $skin, 'rel' => $skin == $selected_skin ? 'stylesheet' : 'alternate stylesheet'), false, $less_imports); } // Footer $section = new View_Events_List(); $section->class .= ' span4'; $section->title = __('New events'); $section->events = Model_Event::factory()->find_new(10); Widget::add('footer', $section); $section = new View_Topics_List(); $section->class .= ' span4'; $section->title = __('New posts'); $section->topics = Model_Forum_Topic::factory()->find_by_latest_post(10); Widget::add('footer', $section); $section = new View_Blogs_List(); $section->class .= ' span4'; $section->title = __('New blogs'); $section->blog_entries = Model_Blog_Entry::factory()->find_new(10); Widget::add('footer', $section); // Open Graph $og = array(); foreach ((array) Anqh::open_graph() as $key => $value) { $og[] = '<meta property="' . $key . '" content="' . HTML::chars($value) . '" />'; } if (!empty($og)) { Widget::add('head', implode("\n", $og)); } // Analytics if ($google_analytics = Kohana::$config->load('site.google_analytics')) { Widget::add('head', HTML::script_source("\nvar tracker;\nhead.js(\n\t{ 'google-analytics': 'http://www.google-analytics.com/ga.js' },\n\tfunction() {\n\t\ttracker = _gat._getTracker('" . $google_analytics . "');\n\t\ttracker._trackPageview();\n\t}\n);\n")); } // Ads /* $ads = Kohana::$config->load('site.ads'); if ($ads && $ads['enabled']) { foreach ($ads['slots'] as $ad => $slot) { if ($slot == 'side') { $this->view->add(View_Page::COLUMN_SIDE, View::factory('ads/' . $ad)); } else { Widget::add($slot, View::factory('ads/' . $ad), Widget::MIDDLE); } } }*/ // Do some CSS magic to page class $page_class = array_merge(array($this->language, $this->request->action(), self::$user ? 'authenticated' : 'unauthenticated'), explode(' ', $this->page_class)); $page_class = implode(' ', array_unique($page_class)); // Set the generic page variables $this->view->styles = $styles; $this->view->skins = $skins; $this->view->language = $this->language; $this->view->id = $this->page_id; $this->view->class = $page_class; if ($this->page_actions) { $this->view->tabs = $this->page_actions; } if ($this->page_breadcrumbs) { $this->view->breadcrumbs = $this->page_breadcrumbs; } // And finally the profiler stats if (self::$user && self::$user->has_role('admin')) { //in_array(Kohana::$environment, array(Kohana::DEVELOPMENT, Kohana::TESTING))) { Widget::add('foot', View::factory('generic/debug')); Widget::add('foot', View::factory('profiler/stats')); } } } parent::after(); }
/** * Render content. * * @return string */ public function content() { static $script = true; $attributes = array(); // Custom URL $url = $this->url ? $this->url : Anqh::open_graph('url'); if ($url) { $attributes['addthis:url'] = $url; } // Custom title $title = $this->title ? $this->title : Anqh::open_graph('title'); if ($title) { $attributes['addthis:title'] = $title; } ob_start(); ?> <div class="addthis_toolbox addthis_default_style addthis_32x32_style"<?php echo HTML::attributes($attributes); ?> > <a class="addthis_button_facebook"></a> <a class="addthis_button_twitter"></a> <a class="addthis_button_google"><?php echo HTML::image('static/img/google-plus.png', array('alt' => 'Google +1', 'width' => 32, 'height' => 32)); ?> </a> <a class="addthis_button_email"></a> <a class="addthis_button_compact"></a> <a class="addthis_counter addthis_bubble_style"></a> </div> <?php if ($script) { ?> <?php if (Kohana::$config->load('site.google_analytics')) { ?> <script> var addthis_config, addthis_share; head.ready('google-analytics', function() { addthis_config = { data_ga_tracker: tracker, data_track_clickback: true, pubid: '<?php echo Kohana::$config->load('site.share'); ?> ' }; addthis_share = { templates: { twitter: '{{title}}: {{url}} (via @<?php echo Kohana::$config->load('site.share'); ?> )' } }; var at = document.createElement('script'); at.type = 'text/javascript'; at.async = true; at.src = 'http://s7.addthis.com/js/250/addthis_widget.js'; (document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(at); }); </script> <?php } else { ?> <script src="http://s7.addthis.com/js/250/addthis_widget.js#pubid=<?php echo Kohana::$config->load('site.share'); ?> "></script> <?php } } // Add JavaScript only once $script = false; return ob_get_clean(); }