示例#1
0
 /**
  * Get newsfeed item as HTML
  *
  * @param   Newsfeed_Model  $item
  * @return  string
  */
 public static function get(NewsFeedItem_Model $item)
 {
     $text = '';
     switch ($item->type) {
         case self::TYPE_COMMENT:
             $gallery = new Gallery_Model($item->data['gallery_id']);
             $image = new Image_Model($item->data['image_id']);
             if ($gallery->loaded() && $image->loaded()) {
                 $text = __('commented to an image in :gallery', array(':gallery' => html::anchor(url::model($gallery) . '/' . $image->id, text::title($gallery->name), array('title' => $gallery->name))));
             }
             break;
     }
     return $text;
 }
示例#2
0
 /**
  * Get newsfeed item as HTML
  *
  * @param   Newsfeed_Model  $item
  * @return  string
  */
 public static function get(NewsFeedItem_Model $item)
 {
     $text = '';
     switch ($item->type) {
         case self::TYPE_COMMENT:
             $entry = new Blog_Entry_Model($item->data['entry_id']);
             if ($entry->id) {
                 $text = __('commented to blog :blog', array(':blog' => html::anchor(url::model($entry), text::title($entry->name), array('title' => $entry->name))));
             }
             break;
         case self::TYPE_ENTRY:
             $entry = new Blog_Entry_Model($item->data['entry_id']);
             if ($entry->id) {
                 $text = __('wrote a new blog entry :blog', array(':blog' => html::anchor(url::model($entry), text::title($entry->name), array('title' => $entry->name))));
             }
             break;
     }
     return $text;
 }
示例#3
0
 /**
  * Get newsfeed item as HTML
  *
  * @param   Newsfeed_Model  $item
  * @return  string
  */
 public static function get(NewsFeedItem_Model $item)
 {
     $text = '';
     switch ($item->type) {
         case self::TYPE_EVENT:
             $event = new Event_Model($item->data['event_id']);
             if ($event->id) {
                 $text = __('added new event :event', array(':event' => html::anchor(url::model($event), text::title($event->name), array('title' => $event->name))));
             }
             break;
         case self::TYPE_FAVORITE:
             $event = new Event_Model($item->data['event_id']);
             if ($event->id) {
                 $text = __('added event :event to favorites', array(':event' => html::anchor(url::model($event), text::title($event->name), array('title' => $event->name))));
             }
             break;
     }
     return $text;
 }
示例#4
0
 /**
  * Get newsfeed item as HTML
  *
  * @param   Newsfeed_Model  $item
  * @return  string
  */
 public static function get(NewsFeedItem_Model $item)
 {
     $text = '';
     switch ($item->type) {
         case self::TYPE_REPLY:
             $topic = new Forum_Topic_Model($item->data['topic_id']);
             if ($topic->id) {
                 $text = __('replied to topic :topic', array(':topic' => html::anchor(url::model($topic) . '/page/last#last', text::title($topic->name), array('title' => $topic->name))));
             }
             break;
         case self::TYPE_TOPIC:
             $topic = new Forum_Topic_Model($item->data['topic_id']);
             if ($topic->id) {
                 $text = __('started a new topic :topic', array(':topic' => html::anchor(url::model($topic), text::title($topic->name), array('title' => $topic->name))));
             }
             break;
     }
     return $text;
 }
示例#5
0
文件: roles.php 项目: anqqa/Anqh
 /**
  * Single role view
  *
  * @param  string  $role_id
  * @param  string  $action
  */
 public function role($role_id, $action = null)
 {
     if ($action) {
         switch ($action) {
             // Delete role
             case 'delete':
                 $this->_role_delete($role_id);
                 return;
         }
     }
     $this->history = false;
     $role = new Role_Model((int) $role_id);
     $form_values = $role->as_array();
     $form_errors = $errors = array();
     // Check post
     if ($post = $this->input->post()) {
         $role->name = $post['name'];
         $role->description = $post['description'];
         try {
             $role->save();
             url::redirect('/roles');
         } catch (ORM_Validation_Exception $e) {
             $form_errors = $e->validation->errors();
         }
         $form_values = arr::overwrite($form_values, $post);
     }
     // show form
     if ($role->id) {
         $this->breadcrumb[] = html::anchor('role/' . url::title($role->id, $role->name), html::specialchars($role->name));
         $this->page_title = text::title($role->name);
         $this->page_actions[] = array('link' => 'role/' . url::title($role->id, $role->name) . '/delete', 'text' => __('Delete role'), 'class' => 'role-delete');
     } else {
         $this->page_title = __('Role');
     }
     if (empty($errors)) {
         widget::add('main', View_Mod::factory('roles/role_edit', array('values' => $form_values, 'errors' => $form_errors)));
     } else {
         $this->_error(Kohana::lang('generic.error'), $errors);
     }
 }
示例#6
0
文件: blogs.php 项目: anqqa/Anqh
 /**
  * Edit entry
  *
  * @param  integer|string  $entry_id
  */
 public function _entry_edit($entry_id = false)
 {
     $this->history = false;
     $entry = new Blog_Entry_Model((int) $entry_id);
     // For authenticated users only
     if (!$this->user || !$entry->is_author() && !$this->visitor->logged_in('admin')) {
         url::redirect(empty($_SESSION['history']) ? '/blogs' : $_SESSION['history']);
     }
     $errors = $form_errors = array();
     $form_messages = '';
     $form_values = $entry->as_array();
     /***** CHECK POST *****/
     if (request::method() == 'post') {
         $post = $this->input->post();
         // update
         $editing = (bool) $entry->id;
         if ($editing) {
             $extra['modified'] = date::unix2sql(time());
             $extra['modifies'] = (int) $entry->modifies + 1;
         } else {
             $extra['author_id'] = $this->user->id;
         }
         if ($entry->validate($post, true, $extra)) {
             // News feed event
             if (!$editing) {
                 newsfeeditem_blog::entry($this->user, $entry);
             }
             url::redirect(url::model($entry));
         } else {
             $form_errors = $post->errors();
             $form_messages = $post->message();
         }
         $form_values = arr::overwrite($form_values, $post->as_array());
     }
     /***** /CHECK POST *****/
     /***** SHOW FORM *****/
     if ($entry->id) {
         $this->page_actions[] = array('link' => url::model($entry) . '/delete?token=' . csrf::token($this->user->id), 'text' => __('Delete entry'), 'class' => 'entry-delete');
         $this->page_title = text::title($entry->name);
         $this->page_subtitle = __('Edit entry');
     } else {
         $this->page_title = __('New entry');
     }
     $form = $entry->get_form();
     if (empty($errors)) {
         widget::add('head', html::script(array('js/jquery.markitup.pack.js', 'js/markitup.bbcode.js')));
         widget::add('main', View::factory('blog/entry_edit', array('form' => $form, 'values' => $form_values, 'errors' => $form_errors, 'messages' => $form_messages)));
     } else {
         $this->_error(Kohana::lang('generic.error'), $errors);
     }
     /***** /SHOW FORM *****/
 }
示例#7
0
文件: image_info.php 项目: anqqa/Anqh
    ?>
				<?php 
    if ($image->exif->focal) {
        ?>
				<dd><?php 
        echo __('Focal length: :focal mm', array(':focal' => '<var>' . text::title($image->exif->focal, true)));
        ?>
</dd>
				<?php 
    }
    ?>
				<?php 
    if ($image->exif->iso) {
        ?>
				<dd><?php 
        echo __('ISO speed: :iso', array(':iso' => '<var>' . text::title($image->exif->iso, true)));
        ?>
</dd>
				<?php 
    }
    ?>
				<?php 
    if ($image->exif->taken) {
        ?>
				<dd><?php 
        echo __('Taken: :taken', array(':taken' => '<var>' . date::format('DMYYYY_HM', $image->exif->taken)));
        ?>
</dd>
				<?php 
    }
    ?>
示例#8
0
文件: events.php 项目: anqqa/Anqh
			<?php 
        }
        ?>

			<?php 
        foreach ($events as $event) {
            ?>

			<article class="event event-<?php 
            echo $event->id;
            ?>
">

				<header>
					<h4><?php 
            echo html::anchor(url::model($event), text::title($event->name));
            ?>
</h4>
				</header>

				<?php 
            if ($event->price !== null && $event->price != -1) {
                ?>
				<span class="details price"><?php 
                echo $event->price == 0 ? __('Free entry') : '<var>' . format::money($event->price, $event->country->currencycode) . '</var>';
                ?>
</span>
				<?php 
            }
            ?>
示例#9
0
文件: galleries.php 项目: anqqa/Anqh
?>

<ul>

<?php 
foreach ($galleries as $gallery) {
    ?>
	<li class="unit size1of2">
		<div class="thumb unit size2of5">
			<?php 
    echo html::anchor(url::model($gallery), html::image('http://' . Kohana::config('site.image_server') . '/kuvat/' . $gallery->dir . '/thumb_' . $gallery->default_image->legacy_filename));
    ?>
		</div>
		<header>
			<h4><?php 
    echo html::anchor(url::model($gallery), text::title($gallery->name));
    ?>
</h4>
			<span class="details">
				<?php 
    echo html::time(date::format('DMYYYY', $gallery->event_date), $gallery->event_date, true);
    ?>
,
				<?php 
    echo __2(':images image', ':images images', $gallery->image_count, array(':images' => '<var>' . $gallery->image_count . '</var>'));
    ?>
			</span>
		</header>
	</li>
<?php 
}
示例#10
0
if (!empty($events)) {
    ?>
<ul class="events">

	<?php 
    foreach ($events as $event) {
        ?>
	<li class="event event-<?php 
        echo $event->id;
        ?>
">
		<?php 
        echo date::format('DDMM', $event->start_time);
        ?>
		<!--<?php 
        echo html::anchor(url::model($event), text::limit_chars(text::title($event->name), 20, '&hellip;', true), array('title' => $event->name));
        ?>
-->
		<?php 
        echo html::anchor(url::model($event), $event->name);
        ?>
	</li>
	<?php 
    }
    ?>

</ul>

<?php 
} else {
    ?>
示例#11
0
文件: groups.php 项目: anqqa/Anqh
				<?php 
        } elseif (!$area->is_type(Forum_Area_Model::TYPE_HIDDEN)) {
            ?>

				<article class="area area-<?php 
            echo $area->id;
            ?>
 disabled">
					<header>
						<h4>
							<span title="<?php 
            echo strip_tags($area->description);
            ?>
"><?php 
            echo text::title($area->name);
            ?>
						</h4>
						<?php 
            echo __('Members only');
            ?>
					</header>
				</article>

				<?php 
        }
        ?>

			<?php 
    }
    ?>
示例#12
0
文件: member.php 项目: anqqa/Anqh
 /**
  * Blog entries
  */
 public function _blog()
 {
     $this->tab_id = 'blog';
     // Basic information
     $this->page_title = text::title($this->member->username, false);
     $this->_side_views();
 }
示例#13
0
	<li class="group">
		<h5><?php 
    echo html::anchor(url::model($group), text::title($group->name));
    ?>
</h5>
		<ul class="areas">

		<?php 
    foreach ($group->forum_areas->find_all() as $area) {
        ?>
			<?php 
        if ($area->has_access(Forum_Area_Model::ACCESS_READ)) {
            ?>
			<li><?php 
            echo html::anchor(url::model($area), text::title($area->name), array('title' => strip_tags($area->description)));
            ?>
</li>
			<?php 
        }
        ?>
		<?php 
    }
    ?>

		</ul>
	</li>

<?php 
}
?>
示例#14
0
文件: events.php 项目: anqqa/Anqh
 /**
  * Week view
  *
  * @param  int  $year
  * @param  int  $week
  */
 public function week($year, $week)
 {
     $this->tab_id = 'browse';
     if (valid::year($year) && valid::week($week)) {
         $this->type = 'week';
         $this->date->setISODate($year, $week);
         // check for new years fix
         if ($week == 1) {
             $saturday = new DateTime();
             $saturday->setISODate($year, $week, 6);
             $this->date = $saturday;
         }
         $this->page_title = text::title(__('Week') . ' ' . $this->date->format('W/Y'));
         $this->breadcrumb[] = html::anchor(Router::$routed_uri, html::specialchars($this->page_title));
         $this->_build_calendar();
     }
 }
示例#15
0
文件: tags.php 项目: anqqa/Anqh
 /**
  * Show tag
  *
  * @param  intege|string  $tag_id
  * @param  string  $action
  */
 public function tag($tag_id, $action = null)
 {
     if ($action) {
         switch ($action) {
             // Delete tag
             case 'delete':
                 $this->_tag_delete($tag_id);
                 return;
                 // Edit tag
             // Edit tag
             case 'edit':
                 $this->_tag_edit($tag_id);
                 return;
         }
     }
     $tag = new Tag_Model((int) $tag_id);
     $errors = $tag->id ? array() : array('tags.error_tag_not_found');
     if (empty($errors)) {
         $tag_group = $tag->tag_group;
         $this->breadcrumb[] = html::anchor(url::model($tag_group), $tag_group->name);
         $this->breadcrumb[] = html::anchor(url::model($tag), $tag->name);
         $this->page_title = text::title($tag->name);
         $this->page_subtitle = html::specialchars($tag->description) . '&nbsp;';
         if ($this->visitor->logged_in('admin')) {
             $this->page_actions[] = array('link' => url::model($tag) . '/edit', 'text' => __('Edit tag'), 'class' => 'tag-edit');
         }
         foreach ($tag->get_defaults() as $key => $field) {
             if (!empty($field)) {
                 widget::add('main', $key . ' = ' . html::specialchars($field) . "<br />\n");
             }
         }
     } else {
         $this->_error(Kohana::lang('generic.error'), $errors);
     }
     $this->_side_views();
 }
示例#16
0
文件: peepbox.php 项目: anqqa/Anqh
<section class="mod peepbox">
	<header>
		<h4><?php 
echo text::title($member->username);
?>
</h4>
	</header>

	<?php 
if (valid::url($member->picture)) {
    ?>
	<?php 
    echo html::image($member->picture, array('width' => 160));
    ?>
	<?php 
}
?>

	<?php 
if ($member->default_image_id) {
    ?>
	<?php 
    echo html::img($member->default_image, 'normal', array('width' => 160));
    ?>
	<?php 
}
?>

</section>
示例#17
0
文件: topics.php 项目: anqqa/Anqh
    ?>
</h4>
		<ul class="details unit size1of6">
			<!-- <li class="unit size1of2"><?php 
    echo html::icon_value(array(':views' => $topic->reads), ':views view', ':views views', 'views');
    ?>
</li> -->
			<li class="unit size1of1"><?php 
    echo html::icon_value(array(':replies' => $topic->posts - 1), ':replies reply', ':replies replies', 'posts');
    ?>
</li>
		</ul>
	</header>
	<footer>
		<?php 
    if (isset($area)) {
        ?>
		<?php 
        echo __('In :area.', array(':area' => html::anchor(url::model($topic->forum_area), text::title($topic->forum_area->name), array('title' => strip_tags($topic->forum_area->description)))));
        ?>
		<?php 
    }
    ?>
		<?php 
    echo __('Last post by :user :ago ago', array(':user' => html::nick(false, $topic->last_poster), ':ago' => html::time(date::timespan_short($topic->last_posted), $topic->last_posted)));
    ?>
	</footer>
</article>

<?php 
}
示例#18
0
文件: favorites.php 项目: anqqa/Anqh
<ul class="contentlist favorites events">
	<?php 
foreach ($favorites as $favorite) {
    ?>
	<li class="event-<?php 
    echo $favorite->id;
    ?>
">
		<?php 
    echo date::format('DDMMYYYY', $favorite->start_time);
    ?>
		<?php 
    echo html::anchor(url::model($favorite), text::title($favorite->name), array('title' => html::specialchars($favorite->name)));
    ?>
	</li>
	<?php 
}
?>
</ul>
示例#19
0
文件: post.php 项目: anqqa/Anqh
if ($post->modifies > 0) {
    ?>
			<br />
			<?php 
    echo __('Edited :ago ago', array(':ago' => html::time(date::timespan_short($post->modified), $post->modified)));
    ?>
			<?php 
}
?>
			<?php 
if ($post->parent_id) {
    $parent_topic = $post->parent->forum_topic;
    ?>
			<br />
			<?php 
    echo __('Replying to :parent', array(':parent' => html::anchor(url::model($parent_topic) . '/' . $post->parent_id . '#post-' . $post->parent_id, text::title($parent_topic->name))));
    ?>
			<?php 
}
?>
			</span>

		</header>

		<section class="post-content">

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

		</section>
示例#20
0
文件: venues.php 项目: anqqa/Anqh
 /**
  * venue
  *
  * @param  integer|string  $venue_id
  * @param  string          $action
  */
 public function venue($venue_id, $action = null)
 {
     if ($action) {
         switch ($action) {
             // Delete venue
             case 'delete':
                 $this->_venue_delete($venue_id);
                 return;
                 // Add venue
             // Add venue
             case 'edit':
                 $this->_venue_edit($venue_id);
                 return;
         }
     }
     $venue = new Venue_Model((int) $venue_id);
     $errors = $venue->id ? array() : array(__('Venue not found'));
     if (empty($errors)) {
         $venue_category = $venue->venue_category;
         $this->breadcrumb[] = html::anchor('/venues/' . url::title($venue_category->id, $venue_category->name), $venue_category->name);
         $this->breadcrumb[] = html::anchor('/venue/' . url::title($venue->id, $venue->name), $venue->name);
         $this->page_class = 'venue-' . (int) $venue->id;
         $this->page_title = text::title($venue->name);
         $this->page_subtitle = __('Category :category', array(':category' => html::anchor(url::model($venue->venue_category), $venue->venue_category->name, array('title' => $venue->venue_category->description))));
         if ($venue->has_access(Venue_Model::ACCESS_EDIT)) {
             $this->page_actions[] = array('link' => 'venue/' . url::title($venue->id, $venue->name) . '/edit', 'text' => __('Edit venue'), 'class' => 'venue-edit');
         }
         $events = ORM::factory('event')->find_upcoming(10, array('venue_id', '=', $venue->id));
         if ($events->count()) {
             widget::add('main', View_Mod::factory('events/events_list', array('mod_id' => 'venue-upcoming-events', 'mod_title' => __('Upcoming events'), 'events' => $events)));
         }
         $events = ORM::factory('event')->find_past(10, array('venue_id', '=', $venue->id));
         if ($events->count()) {
             widget::add('main', View_Mod::factory('events/events_list', array('mod_id' => 'venue-past-events', 'mod_title' => __('Past events'), 'events' => $events)));
         }
         widget::add('side', View::factory('venues/venue_info', array('venue' => $venue)));
     } else {
         $this->_error(__('Uh oh!'), $errors);
     }
     $this->_side_views();
 }
示例#21
0
文件: forum.php 项目: anqqa/Anqh
 /**
  * Edit topic
  *
  * @param  mixed  $topic_id
  * @param  mixed  $area_id
  */
 public function _topic_edit($topic_id, $area_id = false)
 {
     $this->history = false;
     $errors = array();
     $forum_topic = new Forum_Topic_Model((int) $topic_id);
     $forum_area = $forum_topic->loaded() ? $forum_topic->forum_area : new Forum_Area_Model((int) $area_id);
     if ($forum_topic->loaded()) {
         // Editing topic
         $editing = true;
         if (!$forum_topic->has_access(Forum_Topic_Model::ACCESS_EDIT)) {
             url::back('forum');
         }
     } else {
         if ($forum_area->loaded()) {
             // New topic
             $editing = false;
             if (!$forum_area->has_access(Forum_Area_Model::ACCESS_WRITE)) {
                 url::back('forum');
             }
         } else {
             // New topic in unknown area
             $errors[] = __('Area :area or topic :topic not found', array(':area' => (int) $area_id, ':topic' => (int) $topic_id));
         }
     }
     if (empty($errors)) {
         $forum_post = new Forum_Post_Model((int) $forum_topic->first_post_id);
         $form_errors = array();
         $form_values_topic = $forum_topic->as_array();
         $form_values_post = $forum_post->as_array();
         $form_topics = false;
         // Bound area?
         if ($forum_area->is_type(Forum_Area_Model::TYPE_BIND)) {
             // Get bind config and load topics
             $bind = Forum_Area_Model::binds($forum_area->bind);
             if ($editing) {
                 // Can't edit bound topic
                 $form_topics = array($forum_topic->bind_id => $forum_topic->name);
             } else {
                 // Try to load options from configured model
                 try {
                     $bind_topics = ORM::factory($bind['model'])->find_bind_topics($forum_area->bind);
                     $form_topics = array(0 => __('Choose..')) + $bind_topics;
                 } catch (Kohana_Exception $e) {
                     $form_topics = array();
                 }
             }
         }
         // Admin actions
         if ($editing && $forum_topic->has_access(Forum_Topic_Model::ACCESS_DELETE)) {
             $this->page_actions[] = array('link' => url::model($forum_topic) . '/delete/?token=' . csrf::token(), 'text' => __('Delete topic'), 'class' => 'topic-delete');
         }
         // Check post
         if ($post = $this->input->post()) {
             $post['forum_area_id'] = $forum_area->id;
             $topic = $post;
             if (isset($bind_topics)) {
                 $topic['name'] = arr::get($bind_topics, (int) $topic['bind_id'], '');
             }
             $post_extra = $topic_extra = array('author_id' => $this->user->id, 'author_name' => $this->user->username);
             if ($editing) {
                 $post_extra['modifies'] = (int) $forum_post->modifies + 1;
                 $post_extra['modified'] = date::unix2sql(time());
             }
             $post_extra['author_ip'] = $this->input->ip_address();
             $post_extra['author_host'] = $this->input->host_name();
             // validate post first and save topic if ok
             if (csrf::valid() && $forum_post->validate($post, false, $post_extra) && $forum_topic->validate($topic, true, $topic_extra)) {
                 // post
                 $forum_post->forum_topic_id = $forum_topic->id;
                 $forum_post->save();
                 if (!$editing) {
                     // topic
                     $forum_topic->first_post_id = $forum_post->id;
                     $forum_topic->last_post_id = $forum_post->id;
                     $forum_topic->last_poster = $this->user->username;
                     $forum_topic->last_posted = date::unix2sql(time());
                     $forum_topic->posts = 1;
                     $forum_topic->save();
                     // area
                     $forum_area->last_topic_id = $forum_topic->id;
                     $forum_area->posts += 1;
                     $forum_area->topics += 1;
                     $forum_area->save();
                     // user
                     $this->user->posts += 1;
                     $this->user->save();
                     // News feed
                     newsfeeditem_forum::topic($this->user, $forum_topic);
                 }
                 // redirect back to topic
                 URL::redirect(url::model($forum_topic));
             } else {
                 $form_errors = array_merge($post->errors(), is_object($topic) ? $topic->errors() : array());
             }
             $form_values_topic = arr::overwrite($form_values_topic, is_object($topic) ? $topic->as_array() : $topic);
             $form_values_post = arr::overwrite($form_values_post, $post->as_array());
         }
     }
     // Show form
     if (empty($errors)) {
         $this->breadcrumb[] = html::anchor(url::model($forum_area), text::title($forum_area->name));
         $this->page_title = $editing ? text::title($forum_topic->name) : __('New topic');
         $this->page_subtitle = __('Area :area', array(':area' => html::anchor(url::model($forum_area), text::title($forum_area->name), array('title' => strip_tags($forum_area->description)))));
         widget::add('head', html::script(array('js/jquery.markitup.pack', 'js/markitup.bbcode')));
         widget::add('main', View_Mod::factory('forum/topic_edit', array('topic' => $form_values_topic, 'topics' => $form_topics, 'post' => $form_values_post, 'errors' => $form_errors)));
     } else {
         $this->_error(__('Error'), $errors);
     }
     $this->_side_views();
 }
示例#22
0
文件: entries.php 项目: anqqa/Anqh
 *
 * @package    Blog
 * @author     Antti Qvickström
 * @copyright  (c) 2010 Antti Qvickström
 * @license    http://www.opensource.org/licenses/mit-license.php MIT license
 */
?>

<?php 
foreach ($entries as $entry) {
    ?>

<article>
	<header>
		<?php 
    echo html::avatar($entry->author->avatar, $entry->author->username);
    ?>
		<h4><?php 
    echo html::anchor(url::model($entry), text::title($entry->name), array('title' => $entry->name));
    ?>
</h4>
		<span class="details">
		<?php 
    echo __('By :user :ago ago', array(':user' => html::user($entry->author), ':ago' => html::time(date::timespan_short($entry->created), $entry->created)));
    ?>
		</span>
	</header>
</article>

<?php 
}