Example #1
0
File: report.php Project: anqh/anqh
    /**
     * Render view.
     *
     * @return  string
     */
    public function content()
    {
        ob_start();
        $gallery = $this->image->gallery();
        echo Form::open(Route::url('gallery_image', array('gallery_id' => Route::model_id($gallery), 'id' => $this->image->id, 'action' => 'report')), array('class' => Request::current()->is_ajax() ? 'ajaxify' : ''));
        ?>

<fieldset>

	<?php 
        echo Form::control_group(Form::input('reason', null, array('class' => 'input-block-level')), array('name' => __('Reason')), null, __('You can enter an optional reason for reporting this image, e.g. why it should be removed'));
        ?>

</fieldset>

<fieldset class="form-actions">
	<?php 
        echo Form::button('save', __('Report'), array('type' => 'submit', 'class' => 'btn btn-danger btn-large'));
        ?>
	<?php 
        echo Request::current()->is_ajax() ? '' : HTML::anchor(Route::url('gallery_image', array('gallery_id' => Route::model_id($gallery), 'id' => $this->image->id, 'action' => '')), __('Cancel'), array('class' => 'cancel'));
        ?>

	<?php 
        echo Form::csrf();
        ?>
</fieldset>

<?php 
        return ob_get_clean();
    }
Example #2
0
 /**
  * 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;
 }
Example #3
0
File: top.php Project: anqh/anqh
    /**
     * Render view.
     *
     * @return  string
     */
    public function content()
    {
        ob_start();
        ?>

<div class="row">

	<?php 
        foreach ($this->images as $image) {
            $gallery = $image->gallery();
            ?>

	<div class="<?php 
            echo $this->wide ? 'col-xs-6 col-sm-4 col-md-3 col-lg-2' : 'col-xs-12 col-sm-6';
            ?>
">
		<div class="thumbnail">

			<?php 
            echo HTML::anchor(Route::url('gallery_image', array('gallery_id' => Route::model_id($gallery), 'id' => $image->id)), HTML::image($image->get_url('thumbnail', $gallery->dir)));
            ?>

			<div class="caption">
				<h4><?php 
            echo HTML::anchor(Route::model($gallery), HTML::chars($gallery->name));
            ?>
</h4>
			</div>

			<small class="stats label label-default">

	<?php 
            switch ($this->type) {
                case Model_Image::TOP_COMMENTED:
                    echo '<i class="fa fa-comment"></i> ', Num::format($image->comment_count, 0);
                    break;
                case Model_Image::TOP_RATED:
                    echo '<i class="fa fa-star"></i> ', round($image->rate_total / $image->rate_count, 2);
                    break;
                case Model_Image::TOP_VIEWED:
                    echo '<i class="fa fa-eye"></i> ', Num::format($image->view_count, 0);
                    break;
            }
            ?>

			</small>
		</div>
	</div>

<?php 
        }
        ?>

</div>

<?php 
        return ob_get_clean();
    }
Example #4
0
File: forum.php Project: anqh/anqh
 /**
  * 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) {
         case self::TYPE_REPLY:
             $topic = Model_Forum_Topic::factory($item->data['topic_id']);
             if ($topic->loaded()) {
                 $text = HTML::anchor(Route::get('forum_post')->uri(array('topic_id' => Route::model_id($topic), 'id' => $item->data['post_id'])) . '#post-' . $item->data['post_id'], '<i class="fa fa-comments"></i> ' . HTML::chars($topic->name), array('title' => $topic->name));
             }
             break;
         case self::TYPE_TOPIC:
             $topic = Model_Forum_Topic::factory($item->data['topic_id']);
             if ($topic->loaded()) {
                 $text = HTML::anchor(Route::model($topic), '<i class="fa fa-comments"></i> ' . HTML::chars($topic->name), array('title' => $topic->name));
             }
             break;
     }
     return $text;
 }
Example #5
0
File: forum.php Project: anqh/forum
 /**
  * Get newsfeed item as HTML
  *
  * @static
  * @param   Model_NewsfeedItem  $item
  * @return  string
  */
 public static function get(Model_NewsFeedItem $item)
 {
     $text = '';
     switch ($item->type) {
         case self::TYPE_REPLY:
             $topic = Model_Forum_Topic::factory($item->data['topic_id']);
             if ($topic->loaded()) {
                 $text = __('replied to topic<br />:topic', array(':topic' => HTML::anchor(Route::get('forum_post')->uri(array('topic_id' => Route::model_id($topic), 'id' => $item->data['post_id'])) . '#post-' . $item->data['post_id'], '<i class="icon-comment icon-white"></i> ' . HTML::chars($topic->name), array('title' => $topic->name))));
             }
             break;
         case self::TYPE_TOPIC:
             $topic = Model_Forum_Topic::factory($item->data['topic_id']);
             if ($topic->loaded()) {
                 $text = __('started a new topic<br />:topic', array(':topic' => HTML::anchor(Route::model($topic), '<i class="icon-comment icon-white"></i> ' . HTML::chars($topic->name), array('title' => $topic->name))));
             }
             break;
     }
     return $text;
 }
Example #6
0
 /**
  * Get notification as HTML.
  *
  * @static
  * @param   Model_Notification
  * @return  string
  */
 public static function get(Model_Notification $notification)
 {
     $text = '';
     switch ($notification->type) {
         case self::TYPE_IMAGE_COMMENT:
             $user = Model_User::find_user($notification->user_id);
             $image = Model_Image::factory($notification->data_id);
             if ($user->loaded() && $image->loaded()) {
                 $gallery = $image->gallery();
                 $text = __(':user commented your :photo: <em>:comment</em>', array(':user' => HTML::user($user), ':photo' => HTML::anchor(Route::url('gallery_image', array('gallery_id' => Route::model_id($gallery), 'id' => $image->id, 'action' => '')), __('photo'), array('class' => 'hoverable')), ':comment' => Text::smileys(Text::auto_link_urls(HTML::chars($notification->text)))));
             } else {
                 $notification->delete();
             }
             break;
         case self::TYPE_IMAGE_NOTE:
             $user = Model_User::find_user($notification->user_id);
             $image = Model_Image::factory($notification->data_id);
             if ($user->loaded() && $image->loaded()) {
                 $gallery = $image->gallery();
                 $text = __(':user tagged you to a :photo', array(':user' => HTML::user($user), ':photo' => HTML::anchor(Route::url('gallery_image', array('gallery_id' => Route::model_id($gallery), 'id' => $image->id, 'action' => '')), __('photo'), array('class' => 'hoverable'))));
             } else {
                 $notification->delete();
             }
             break;
         case self::TYPE_IMAGE_REPORT:
             $user = Model_User::find_user($notification->user_id);
             $image = Model_Image::factory($notification->data_id);
             if ($user->loaded() && $image->loaded()) {
                 $gallery = $image->gallery();
                 $text = __(':user reported a :photo: <em>:reason</em>', array(':user' => HTML::user($user), ':photo' => HTML::anchor(Route::url('gallery_image', array('gallery_id' => Route::model_id($gallery), 'id' => $image->id, 'action' => '')), __('photo'), array('class' => 'hoverable')), ':reason' => $notification->text ? HTML::chars($notification->text) : __('No reason')));
             } else {
                 $notification->delete();
             }
             break;
     }
     return $text;
 }
Example #7
0
    /**
     * Render view.
     *
     * @return  string
     */
    public function content()
    {
        ob_start();
        ?>

<div class="image">
	<figure>

		<?php 
        if ($this->url) {
            echo HTML::anchor($this->url, HTML::image($this->image->get_url(null, $this->gallery->dir)), array('title' => __('Next image'), 'class' => 'image'));
        } else {
            echo HTML::anchor(Route::model($this->gallery, $this->show_pending ? 'approve' : ''), HTML::image($this->image->get_url(null, $this->gallery->dir)), array('title' => __('Back to gallery'), 'class' => 'image'));
        }
        ?>

		<?php 
        if ($this->can_note) {
            ?>

			<?php 
            echo Form::open(Route::url('gallery_image', array('gallery_id' => Route::model_id($this->gallery), 'id' => $this->image->id, 'action' => 'note')), array('id' => 'form-note'));
            ?>

			<fieldset>
				<?php 
            echo Form::control_group(Form::input('name'));
            ?>

				<?php 
            echo Form::submit('save', __('Save'), array('class' => 'btn btn-success'));
            ?>
				<a class="cancel" href="#cancel"><?php 
            echo __('Cancel');
            ?>
</a>

				<?php 
            echo Form::hidden('x');
            ?>
				<?php 
            echo Form::hidden('y');
            ?>
				<?php 
            echo Form::hidden('width');
            ?>
				<?php 
            echo Form::hidden('height');
            ?>
				<?php 
            echo Form::hidden('user_id');
            ?>
			</fieldset>

			<?php 
            echo Form::close();
            ?>

		<?php 
        }
        ?>

	</figure>

	<?php 
        echo $this->notes();
        ?>

</div>
<?php 
        return ob_get_clean();
    }
Example #8
0
 /**
  * Action: upload
  */
 public function action_upload()
 {
     // Load existing gallery if any
     $gallery_id = (int) $this->request->param('gallery_id');
     if (!$gallery_id) {
         $gallery_id = (int) $this->request->param('id');
     }
     if ($gallery_id) {
         // Existing gallery
         $gallery = Model_Gallery::factory($gallery_id);
         if (!$gallery->loaded()) {
             throw new Model_Exception($gallery, $gallery_id);
         }
     } else {
         // New gallery
         return $this->_edit_gallery(null, Arr::get($_REQUEST, 'event'));
     }
     Permission::required(new Model_Gallery(), Model_Gallery::PERMISSION_UPLOAD, self::$user);
     // Handle post
     $errors = array();
     if ($_FILES) {
         $file = Arr::get($_FILES, 'file');
         if ($file) {
             // We need to flatten our file one level as ajax uploaded files are set up funnily.
             // Support for ajax uploads one by one for now..
             foreach ($file as $key => $value) {
                 is_array($value) and $file[$key] = $value[0];
             }
             // Needed for IE response
             if ($multiple = Arr::get($_REQUEST, 'multiple', false)) {
                 $this->auto_render = false;
             }
             // Upload info for JSON
             $info = new stdClass();
             $info->name = HTML::chars($file['name']);
             $info->size = intval($file['size']);
             // Save image
             try {
                 // Make sure we don't timeout. An external queue would be better thuough.
                 set_time_limit(0);
                 ignore_user_abort(true);
                 // Duplicate filename check
                 $uploaded = Session::instance()->get('uploaded', array());
                 if (isset($uploaded[$gallery->id]) && in_array($file['name'], $uploaded[$gallery->id])) {
                     throw new Kohana_Exception(__('Already uploaded'));
                 }
                 $image = Model_Image::factory();
                 $image->normal = 'wide';
                 $image->set_fields(array('author_id' => self::$user->id, 'file' => $file, 'status' => Model_Image::NOT_ACCEPTED, 'created' => time()));
                 $image->save();
                 // Save exif
                 try {
                     $exif = Model_Image_Exif::factory();
                     $exif->image_id = $image->id;
                     $exif->save();
                 } catch (Kohana_Exception $e) {
                     throw $e;
                 }
                 // Set the image as gallery image
                 $gallery->relate('images', array($image->id));
                 $gallery->image_count++;
                 $gallery->save();
                 // Mark filename as uploaded for current gallery
                 $uploaded[$gallery->id][] = $file['name'];
                 Session::instance()->set('uploaded', $uploaded);
                 // Make sure the user has photo role to be able to see uploaded pictures
                 if (!self::$user->has_role('photo')) {
                     self::$user->add_role('photo');
                 }
                 // Show image if uploaded with ajax
                 if ($this->ajax || $multiple) {
                     $info->url = $image->get_url();
                     $info->thumbnail_url = $image->get_url(Model_Image::SIZE_THUMBNAIL);
                     $info->gallery_url = Route::url('gallery_image', array('gallery_id' => Route::model_id($gallery), 'id' => $image->id, 'action' => 'approve'));
                     $info->delete_url = Route::url('gallery_image', array('gallery_id' => Route::model_id($gallery), 'id' => $image->id, 'action' => 'delete')) . '?token=' . Security::csrf();
                     $info->delete_type = 'GET';
                     $this->response->body(json_encode(array($info)));
                     return;
                 }
                 $this->request->redirect(Route::model($gallery));
             } catch (Validation_Exception $e) {
                 $errors = $e->array->errors('validation');
             } catch (Kohana_Exception $e) {
                 $errors = array('file' => $e->getMessage());
             }
             // Show errors if uploading with ajax, skip form
             if (($this->ajax || $multiple) && !empty($errors)) {
                 $info->error = Arr::get($errors, 'file');
                 $this->response->body(json_encode(array($info)));
                 return;
             }
         }
     }
     // Build page
     $this->view = View_Page::factory($gallery->name);
     $images = count($gallery->images());
     $this->view->subtitle = __($images == 1 ? ':images image' : ':images images', array(':images' => $images)) . ' - ' . HTML::time(Date::format('DMYYYY', $gallery->date), $gallery->date, true);
     // Upload
     $this->view->add(View_Page::COLUMN_MAIN, $this->section_upload());
     // Help
     $this->view->add(View_Page::COLUMN_SIDE, $this->section_upload_help());
 }
Example #9
0
File: topic.php Project: anqh/forum
 /**
  * Edit forum post
  *
  * @param  integer  $topic_id  When replying to a topic
  * @param  integer  $post_id   When editing a post
  * @param  integer  $quote_id  When quoting a post
  *
  * @throws  Model_Exception  missing topic, missing post
  */
 protected function _edit_post($topic_id, $post_id = null, $quote_id = null)
 {
     $this->history = false;
     // Topic is always loaded, avoid haxing attempts to edit posts from wrong topics
     $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_POST, self::$user);
     if ($post_id) {
         // Editing a post
         $post = $this->private ? Model_Forum_Private_Post::factory($post_id) : Model_Forum_Post::factory($post_id);
         if (!$post->loaded() || $post->forum_topic_id != $topic->id) {
             throw new Model_Exception($post, $post_id);
         }
         Permission::required($post, Model_Forum_Post::PERMISSION_UPDATE, self::$user);
     } else {
         // New reply
         $post = $this->private ? Model_Forum_Private_Post::factory() : Model_Forum_Post::factory();
     }
     // Quoting a post
     if ($quote_id) {
         $quote = $this->private ? Model_Forum_Private_Post::factory() : Model_Forum_Post::factory($quote_id);
         if (!$quote->loaded() || $quote->forum_topic_id != $topic->id) {
             throw new Model_Exception($quote, $quote_id);
         }
         Permission::required($quote, Model_Forum_Post::PERMISSION_READ, self::$user);
         if (!$post->loaded()) {
             $post->post = '[quote author="' . $quote->author_name . '" post="' . $quote->id . '"]' . $quote->post . "[/quote]\n\n";
         }
         $post->parent_id = $quote_id;
     }
     // Handle post
     $errors = array();
     if ($_POST && Security::csrf_valid()) {
         $post->post = Arr::get($_POST, 'post');
         $post->author_ip = Request::$client_ip;
         $post->author_host = Request::host_name();
         if (!$post->loaded()) {
             // New post
             $post->forum_topic_id = $topic->id;
             $post->forum_area_id = $topic->forum_area_id;
             $post->author_id = self::$user->id;
             $post->author_name = self::$user->username;
             $post->created = time();
             $increase = true;
             // Notify recipients
             if ($this->private) {
                 $topic->notify_recipients(self::$user);
             }
         } else {
             // Old post
             $post->modify_count++;
             $post->modified = time();
             $increase = false;
         }
         try {
             $post->save();
             if ($increase) {
                 // Quote, only for public topics
                 if (!$this->private && $quote_id && $quote->author_id) {
                     $quoted = $quote->author_id;
                     $quote = new Model_Forum_Quote();
                     $quote->user_id = $quoted;
                     $quote->author_id = self::$user->id;
                     $quote->forum_topic_id = $topic->id;
                     $quote->forum_post_id = $post->id;
                     $quote->created = time();
                     $quote->save();
                 }
                 // Topic
                 $topic->post_count++;
                 $topic->last_post_id = $post->id;
                 $topic->last_poster = $post->author_name;
                 // If current topic is set to sink, don't update last posted date
                 if ($topic->status != Model_Forum_Topic::STATUS_SINK) {
                     $topic->last_posted = $post->created;
                 }
                 $topic->save();
                 // Area, only for public topics
                 if (!$this->private) {
                     $area = $topic->area();
                     $area->post_count++;
                     $area->last_topic_id = $topic->id;
                     $area->save();
                 }
                 // User
                 self::$user->post_count++;
                 self::$user->save();
                 // News feed
                 if (!$this->private) {
                     NewsfeedItem_Forum::reply(self::$user, $post);
                 }
             }
             if ($this->ajax) {
                 $post_route = Route::url($this->private ? 'forum_private_post' : 'forum_post', array('topic_id' => Route::model_id($topic), 'id' => $post->id));
                 $post_response = Request::factory($post_route)->execute();
                 $this->response->body($post_response->body());
                 return;
             }
             $this->request->redirect(Route::model($topic, '?page=last#last'));
         } catch (Validation_Exception $e) {
             $errors = $e->array->errors('validate');
         }
     }
     // Common attributes
     if ($quote_id) {
         $mode = View_Forum_PostEdit::QUOTE;
     } else {
         if ($post_id) {
             $mode = View_Forum_PostEdit::EDIT_POST;
         } else {
             $mode = View_Forum_PostEdit::REPLY;
         }
     }
     $section = $this->section_post_edit($mode, $post);
     $section->forum_topic = $topic;
     $section->errors = $errors;
     $section->cancel = $this->ajax ? Route::url($this->private ? 'forum_private_post' : 'forum_post', array('topic_id' => Route::model_id($topic), 'id' => $quote_id ? $quote_id : $post->id)) : Request::back(Route::model($topic), true);
     /*		$form = array(
     			'errors'  => $errors,
     			'ajax'    => $this->ajax ? true : null,
     			'topic'   => $topic,
     			'post'    => $post,
     			'user'    => self::$user,
     			'private' => $this->private,
     			'cancel'  => $this->ajax
     				? Route::get($this->private ? 'forum_private_post' : 'forum_post')
     						->uri(array(
     							'topic_id' => Route::model_id($topic),
     							'id'       => $quote_id ? $quote_id : $post->id,
     						))
     				: Request::back(Route::model($topic), true),
     		);*/
     if ($this->ajax) {
         $this->response->body($mode == View_Forum_PostEdit::EDIT_POST ? $section->content() : $section);
         return;
     }
     // Build page
     $this->view = new View_Page();
     $this->view->title_html = Forum::topic($topic);
     $this->view->add(View_Page::COLUMN_MAIN, $section);
     /*
     		Widget::add('main', View_Module::factory('forum/reply', array(
     			'mod_id'  => 'reply',
     		) + $form));*/
 }
Example #10
0
			<?php 
    if ($note) {
        ?>
			<li><a href="#" class="action small note-add"><?php 
        echo __('Tag people');
        ?>
</a></li>
			<?php 
    }
    ?>

		</ul>
	</figcaption>

	<?php 
    echo Form::open(Route::get('gallery_image')->uri(array('gallery_id' => Route::model_id($gallery), 'id' => $image->id, 'action' => 'note')), array('id' => 'form-note'));
    ?>
		<fieldset>
			<ul>
				<?php 
    echo Form::input_wrap('name');
    ?>
			</ul>
			<?php 
    echo Form::submit_wrap('save', __('Save'), null, '#cancel', null, array('x' => null, 'y' => null, 'width' => null, 'height' => null, 'user_id' => null));
    ?>
		</fieldset>
	<?php 
    echo Form::close();
    ?>
Example #11
0
 /**
  * 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;
 }
Example #12
0
File: search.php Project: anqh/anqh
    /**
     * Render view.
     *
     * @return  string
     */
    public function content()
    {
        ob_start();
        $current_year = 0;
        foreach ($this->images as $image) {
            $gallery = $image->gallery();
            // Subtitle
            $year = date('Y', $image->created);
            if ($year !== $current_year) {
                if ($current_year) {
                    ?>

</div>

				<?php 
                }
                ?>

<header><h3><?php 
                echo $year;
                ?>
</h3></header>
<div class="row">

<?php 
                $current_year = $year;
            }
            ?>

	<article class="col-xs-6 col-sm-4 col-md-3 col-lg-2">
		<div class="thumbnail">

			<?php 
            echo HTML::anchor(Route::url('gallery_image', array('gallery_id' => Route::model_id($gallery), 'id' => $image->id)), HTML::image($image->get_url('thumbnail', $gallery->dir)));
            ?>

			<div class="caption">
				<h4><?php 
            echo HTML::anchor(Route::model($gallery), HTML::chars($gallery->name));
            ?>
</h4>
			</div>

			<small class="stats label label-default">
				<?php 
            echo (int) $image->view_count;
            ?>
 <i class="fa fa-eye"></i>
				<?php 
            if ($image->comment_count) {
                ?>
					&nbsp; <?php 
                echo (int) $image->comment_count;
                ?>
 <i class="fa fa-comment"></i>
				<?php 
            }
            ?>
			</small>
		</div>
	</article>

<?php 
        }
        ?>

</div>

<?php 
        return ob_get_clean();
    }
Example #13
0
        echo '&copy; ' . HTML::user($copyright);
        ?>
</header>
<ul class="line">

		<?php 
    }
    ?>

	<li class="grid2<?php 
    echo Text::alternate(' first', '', '', '');
    ?>
">
		<figure class="thumb">
			<?php 
    echo HTML::anchor(Route::get('gallery_image')->uri(array('gallery_id' => Route::model_id($gallery), 'id' => $image->id, 'action' => $pending ? 'approve' : '')), HTML::image($image->get_url('thumbnail', $gallery->dir)), $image->description ? array('title' => HTML::chars($image->description)) : null);
    ?>
			<?php 
    if (!$pending) {
        ?>

			<figcaption>
				<?php 
        echo HTML::icon_value(array(':comments' => (int) $image->comment_count), ':comments comment', ':comments comments', 'posts');
        ?>
				<?php 
        echo HTML::icon_value(array(':views' => (int) $image->view_count), ':views view', ':views views', 'views');
        ?>
<br />
			</figcaption>
Example #14
0
File: post.php Project: anqh/forum
    /**
     * Render view.
     *
     * @return  string
     */
    public function content()
    {
        ob_start();
        ?>

<div class="pull-left">

	<?php 
        if ($this->author) {
            ?>
		<?php 
            echo HTML::avatar($this->author->avatar, $this->author->username);
            ?>

		<p>
			<small><?php 
            echo __('Posts: :posts', array(':posts' => '<var>' . Num::format($this->author->post_count, 0) . '</var>'));
            ?>
</small>
		</p>
	<?php 
        } else {
            ?>
		<?php 
            echo HTML::avatar(false);
            ?>

	<?php 
        }
        ?>

</div>

<div class="arrow"></div>

<div class="media-body">
	<header<?php 
        echo $this->forum_post->id == $this->forum_topic->last_post_id ? ' id="last"' : '';
        ?>
>
		<small class="ago">
			<?php 
        echo HTML::anchor(Route::url($this->private ? 'forum_private_post' : 'forum_post', array('id' => Route::model_id($this->forum_post), 'topic_id' => Route::model_id($this->forum_topic))) . '#post-' . $this->forum_post->id, '#' . $this->nth, array('title' => __('Permalink')));
        ?>

			&bull;

			<?php 
        if (Permission::has($this->forum_post, Model_Forum_Post::PERMISSION_UPDATE, self::$_user)) {
            echo HTML::anchor(Route::url($this->private ? 'forum_private_post' : 'forum_post', array('id' => Route::model_id($this->forum_post), 'topic_id' => Route::model_id($this->forum_topic), 'action' => 'edit')), __('Edit'), array('class' => 'post-edit')) . ' &bull; ';
        }
        ?>

			<?php 
        if (Permission::has($this->forum_post, Model_Forum_Post::PERMISSION_DELETE, self::$_user)) {
            echo HTML::anchor(Route::url($this->private ? 'forum_private_post' : 'forum_post', array('id' => Route::model_id($this->forum_post), 'topic_id' => Route::model_id($this->forum_topic), 'action' => 'delete')) . '?token=' . Security::csrf(), __('Delete'), array('class' => 'post-delete')) . ' &bull; ';
        }
        ?>

			<?php 
        if (Permission::has($this->forum_topic, Model_Forum_Topic::PERMISSION_POST, self::$_user)) {
            echo HTML::anchor(Route::url($this->private ? 'forum_private_post' : 'forum_post', array('id' => Route::model_id($this->forum_post), 'topic_id' => Route::model_id($this->forum_topic), 'action' => 'quote')), __('Reply'), array('class' => 'post-quote')) . ' &bull; ';
        }
        ?>

			<?php 
        echo HTML::time(Date::short_span($this->forum_post->created, true, true), $this->forum_post->created);
        ?>
		</small>

		<?php 
        if ($this->author) {
            echo HTML::user($this->author->light_array());
            if ($this->author->title) {
                echo ' <small>&ldquo;' . HTML::chars($this->author->title) . '&rdquo;</small>';
            }
        } else {
            echo $this->forum_post->author_name;
            echo ' <small>&ldquo;' . __('Guest') . '&rdquo;</small>';
        }
        ?>
	</header>

	<?php 
        if ($this->forum_post->parent_id) {
            echo __('Replying to :parent', array(':parent' => HTML::anchor(Route::url($this->private ? 'forum_private_post' : 'forum_post', array('topic_id' => Route::model_id($this->forum_topic), 'id' => $this->forum_post->parent_id)) . '#post-' . $this->forum_post->parent_id, HTML::chars($this->forum_post->parent()->topic()->name))));
        }
        ?>

	<?php 
        echo BB::factory($this->forum_post->post)->render();
        ?>

	<footer>
		<?php 
        echo $this->author && $this->author->signature ? BB::factory("\n--\n" . $this->author->signature)->render() : '';
        ?>

		<?php 
        if ($this->forum_post->modify_count > 0) {
            echo '<br /><br />' . __('Edited :ago', array(':ago' => HTML::time(Date::fuzzy_span($this->forum_post->modified), $this->forum_post->modified)));
        }
        ?>
	</footer>
</div>

<?php 
        return ob_get_clean();
    }
Example #15
0
File: post.php Project: anqh/anqh
    /**
     * Render view.
     *
     * @return  string
     */
    public function content()
    {
        $bbcode = BB::factory();
        ob_start();
        if ($this->my) {
            $panel_class = 'panel-success';
        } elseif ($this->owner) {
            $panel_class = 'panel-info';
        } else {
            $panel_class = 'panel-default';
        }
        ?>

<div class="pull-left">

	<?php 
        if ($this->author) {
            ?>
		<?php 
            echo HTML::avatar($this->author->avatar_url, $this->author->username);
            ?>

		<p>
			<small><?php 
            echo __('Posts: :posts', array(':posts' => '<var>' . Num::format($this->author->post_count, 0) . '</var>'));
            ?>
</small>
		</p>
	<?php 
        } else {
            ?>
		<?php 
            echo HTML::avatar(false);
            ?>

	<?php 
        }
        ?>

</div>

<div class="media-body panel <?php 
        echo $panel_class;
        ?>
">
	<header class="panel-heading"<?php 
        echo $this->forum_post->id == $this->forum_topic->last_post_id ? ' id="last"' : '';
        ?>
>
		<small class="pull-right">
			<?php 
        echo HTML::anchor(Route::url($this->private ? 'forum_private_post' : 'forum_post', array('id' => Route::model_id($this->forum_post), 'topic_id' => Route::model_id($this->forum_topic))) . '#post-' . $this->forum_post->id, '#' . $this->nth, array('title' => __('Permalink')));
        ?>

			&bull;

			<?php 
        if (Permission::has($this->forum_post, Model_Forum_Post::PERMISSION_UPDATE)) {
            echo HTML::anchor(Route::url($this->private ? 'forum_private_post' : 'forum_post', array('id' => Route::model_id($this->forum_post), 'topic_id' => Route::model_id($this->forum_topic), 'action' => 'edit')), __('Edit'), array('class' => 'post-edit'));
        }
        ?>

			<?php 
        if (Permission::has($this->forum_post, Model_Forum_Post::PERMISSION_DELETE)) {
            echo HTML::anchor(Route::url($this->private ? 'forum_private_post' : 'forum_post', array('id' => Route::model_id($this->forum_post), 'topic_id' => Route::model_id($this->forum_topic), 'action' => 'delete')) . '?token=' . Security::csrf(), __('Delete'), array('class' => 'post-delete'));
        }
        ?>

			<?php 
        if (Permission::has($this->forum_topic, Model_Forum_Topic::PERMISSION_POST)) {
            echo HTML::anchor(Route::url($this->private ? 'forum_private_post' : 'forum_post', array('id' => Route::model_id($this->forum_post), 'topic_id' => Route::model_id($this->forum_topic), 'action' => 'quote')), __('Reply'), array('class' => 'post-quote'));
        }
        ?>

			&bull;

			<?php 
        echo HTML::time(Date::short_span($this->forum_post->created, true, true), $this->forum_post->created);
        ?>

			<?php 
        if ($this->forum_post->modify_count > 0) {
            ?>
			&bull;
			<span title="<?php 
            echo __($this->forum_post->modify_count == 1 ? ':edits edit, :ago' : ':edits edits, last :ago', array(':edits' => $this->forum_post->modify_count, ':ago' => Date::fuzzy_span($this->forum_post->modified)));
            ?>
"><?php 
            echo __('Edited');
            ?>
</span>
			<?php 
        }
        ?>

		</small>

		<?php 
        if ($this->author) {
            echo HTML::user($this->author->light_array());
            if ($this->author->title) {
                echo ' <small>' . HTML::chars($this->author->title) . '</small>';
            }
        } else {
            echo $this->forum_post->author_name;
            echo ' <small>' . __('Guest') . '</small>';
        }
        ?>
	</header>

	<div class="panel-body">

		<?php 
        if ($this->forum_post->parent_id) {
            echo '<p class="text-muted">' . __('Replying to :parent', array(':parent' => HTML::anchor(Route::url($this->private ? 'forum_private_post' : 'forum_post', array('topic_id' => Route::model_id($this->forum_topic), 'id' => $this->forum_post->parent_id)) . '#post-' . $this->forum_post->parent_id, HTML::chars($this->forum_post->parent()->topic()->name)))) . ':</p>';
        }
        ?>

		<?php 
        echo $bbcode->render($this->forum_post->post);
        ?>

		<?php 
        if ($this->forum_post->attachment) {
            $attachment = 'images/liitteet/' . $this->forum_post->attachment;
            if (file_exists($attachment)) {
                echo HTML::image($attachment);
            }
        }
        ?>

	</div>

	<?php 
        if ($this->author && $this->author->signature) {
            ?>
	<footer class="panel-body">
		<?php 
            echo $this->author && $this->author->signature ? $bbcode->render("\n--\n" . $this->author->signature, true) : '';
            ?>
	</footer>
	<?php 
        }
        ?>
</div>

<?php 
        return ob_get_clean();
    }
Example #16
0
File: post.php Project: anqh/forum
if (Permission::has($post, Model_Forum_Post::PERMISSION_DELETE, $user)) {
    echo HTML::anchor(Route::get($private ? 'forum_private_post' : 'forum_post')->uri(array('id' => Route::model_id($post), 'topic_id' => Route::model_id($topic), 'action' => 'delete')) . '?token=' . Security::csrf(), __('Delete'), array('class' => 'action post-delete small'));
}
?>

				<?php 
if (Permission::has($topic, Model_Forum_Topic::PERMISSION_POST, $user)) {
    echo HTML::anchor(Route::get($private ? 'forum_private_post' : 'forum_post')->uri(array('id' => Route::model_id($post), 'topic_id' => Route::model_id($topic), 'action' => 'quote')), __('Quote'), array('class' => 'action post-quote small'));
}
?>
				</nav>
			</header>

			<?php 
if ($post->parent_id) {
    echo __('Replying to :parent', array(':parent' => HTML::anchor(Route::get($private ? 'forum_private_post' : 'forum_post')->uri(array('topic_id' => Route::model_id($topic), 'id' => $post->parent_id)) . '#post-' . $post->parent_id, HTML::chars($post->parent()->topic()->name))));
}
?>

<?php 
echo BB::factory($post->post)->render();
?>

			<footer>
				<?php 
if ($post->modify_count > 0) {
    echo __('Edited :ago', array(':ago' => HTML::time(Date::fuzzy_span($post->modified), $post->modified)));
}
?>

				<?php 
Example #17
0
    /**
     * 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>&copy; <?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();
    }
Example #18
0
File: full.php Project: anqh/anqh
    /**
     * Render view.
     *
     * @return  string
     */
    public function content()
    {
        ob_start();
        ?>

<div class="image">
	<figure>

		<?php 
        if ($this->url) {
            echo HTML::anchor($this->url, HTML::image($this->image->get_url(null, $this->gallery->dir)), array('title' => __('Next image'), 'class' => 'image'));
        } else {
            echo HTML::anchor(Route::model($this->gallery), HTML::image($this->image->get_url(null, $this->gallery->dir)), array('title' => __('Back to gallery'), 'class' => 'image'));
        }
        ?>

		<?php 
        if ($exif = $this->exif()) {
            ?>

			<div class="exif">
				<i class="fa fa-camera-retro toggle"></i>
				<dl class="dl-horizontal">
					<?php 
            foreach ($exif as $term => $definition) {
                if (!is_null($definition)) {
                    ?>
					<dt><?php 
                    echo $term;
                    ?>
</dt><dd><?php 
                    echo $definition;
                    ?>
</dd>
					<?php 
                }
            }
            ?>
				</dl>
			</div>

		<?php 
        }
        ?>

		<?php 
        if ($this->can_note) {
            ?>

			<?php 
            echo Form::open(Route::url('gallery_image', array('gallery_id' => Route::model_id($this->gallery), 'id' => $this->image->id, 'action' => 'note')), array('id' => 'form-note', 'class' => 'panel panel-default'));
            ?>

			<fieldset class="panel-body">
				<?php 
            echo Form::input_wrap('name');
            ?>

				<?php 
            echo Form::submit('save', __('Save'), array('class' => 'btn btn-success'));
            ?>
				<a class="cancel" href="#cancel"><?php 
            echo __('Cancel');
            ?>
</a>

				<?php 
            echo Form::hidden('x');
            ?>
				<?php 
            echo Form::hidden('y');
            ?>
				<?php 
            echo Form::hidden('width');
            ?>
				<?php 
            echo Form::hidden('height');
            ?>
				<?php 
            echo Form::hidden('user_id');
            ?>
			</fieldset>

			<?php 
            echo Form::close();
            ?>

		<?php 
        }
        ?>

	</figure>

	<?php 
        echo $this->notes();
        ?>

</div>
<?php 
        return ob_get_clean();
    }
Example #19
0
 /**
  * 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;
 }
Example #20
0
File: thumbs.php Project: anqh/anqh
    /**
     * 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>&copy; <?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) {
                ?>
						&nbsp; <?php 
                echo (int) $image->comment_count;
                ?>
 <i class="fa fa-comment"></i>
					<?php 
            }
            ?>
				</small>

			</div>
		</article>

<?php 
        }
        ?>

	</div>

<?php 
        return ob_get_clean();
    }
Example #21
0
    /**
     * Get edit form.
     *
     * @return  string
     */
    public function form()
    {
        ob_start();
        // Map options
        $options = array('marker' => HTML::chars($this->venue->name), 'infowindow' => HTML::chars($this->venue->address) . '<br />' . HTML::chars($this->venue->city_name), 'lat' => $this->venue->latitude, 'long' => $this->venue->longitude);
        // Form
        echo Form::open(Route::url('venue', array('id' => Route::model_id($this->venue), 'action' => 'foursquare')), array('id' => 'form-foursquare-link', 'style' => 'display: none'));
        ?>

		<fieldset>
			<?php 
        echo Form::control_group(Form::input('city_name', $this->venue->city_name, array('class' => 'input-large')), array('city_name' => __('City')));
        ?>
			<?php 
        echo Form::control_group(Form::input('name', $this->venue->name, array('class' => 'input-large', 'placeholder' => __('Fill city first'))), array('name' => __('Name')));
        ?>
			<?php 
        echo Form::control_group(Form::input('address', $this->venue->address, array('class' => 'input-large', 'placeholder' => __('Fill venue first'))), array('address' => __('Address')));
        ?>
			<?php 
        echo Form::control_group(Form::input('foursquare_id', $this->venue->foursquare_id, array('class' => 'input', 'readonly' => 'readonly')), array('foursquare_id' => __('Foursquare ID')));
        ?>
			<?php 
        echo Form::control_group(Form::input('foursquare_category_id', $this->venue->foursquare_category_id, array('class' => 'input', 'readonly' => 'readonly')), array('foursquare_category_id' => __('Foursquare Category ID')));
        ?>
		</fieldset>
		<fieldset>
			<?php 
        echo Form::hidden('latitude', Arr::pick($this->venue->latitude, $this->venue->city ? $this->venue->city->latitude : 0));
        ?>
			<?php 
        echo Form::hidden('longitude', Arr::pick($this->venue->longitude, $this->venue->city ? $this->venue->city->longitude : 0));
        ?>

			<?php 
        echo Form::csrf();
        ?>
			<?php 
        echo Form::button('save', __('Link'), array('type' => 'submit', 'class' => 'btn btn-success'));
        ?>
		</fieldset>

		<?php 
        echo Form::close();
        ?>

<script>
head.ready('anqh', function hookFoursquare() {
	$("#link-foursquare").on('click', function linkFoursquare(event) {
		event.preventDefault();

		$(this).hide();
		$('#foursquare .alert').hide();

		$('#form-foursquare-link').show('fast');
		$('#map').show('fast', function toggleMap() {
			$('#map').googleMap(<?php 
        echo json_encode($options);
        ?>
);
		});
	});

	$('[name=city_name]:input').autocompleteGeo();

	$('[name=name]:input').foursquareVenue({
		venueId:         'foursquare_id',
		categoryId:      'foursquare_category_id',
		latitudeSearch:  'latitude',
		longitudeSearch: 'longitude'
	});
});
</script>

<?php 
        return ob_get_clean();
    }
Example #22
0
File: core.php Project: anqh/core
 /**
  * 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;
 }