public function action_signup() { $this->template->menu_signup = TRUE; // Если залогинен, то перекидываем на дерево if (Auth::instance()->logged_in()) { $this->redirect(Route::url('user/id', array('user_id' => Auth::instance()->get_user()->id))); } $post = Arr::extract($this->request->post(), array('name', 'surname', 'email')); $data['errors'] = NULL; if ($this->request->method() == 'POST') { // Генерирую случайный пароль из цифр $post['password'] = Text::random('numeric', 5); try { $user = ORM::factory('User')->values($post)->save(); $user->add('roles', ORM::factory('Role', array('name' => 'login'))); $message = ' Для входа на сайт ' . $_SERVER['HTTP_HOST'] . ' используйте следующие данные:<br><br> Адрес электронной почты: ' . HTML::chars($user->email) . '<br> Пароль: ' . HTML::chars($post['password']) . '<br><br> <a href="' . URL::base(TRUE) . '">Перейти на сайт</a>'; Useful::mail($user->email, 'Регистрация LiveTex', $message, 'LiveTex'); // Авторизовываю Auth::instance()->login($user->email, $post['password'], TRUE); $this->redirect(Route::url('user/id', array('user_id' => $user->id))); } catch (ORM_Validation_Exception $e) { $data['errors'] = $e->errors('orm'); } } $data += $post; $this->template->content = View::factory('auth/signup', $data); }
/** * After action */ public function after() { $this->template->legend = HTML::chars(__($this->config_mod['b_menu']['heading'])) . SEPARATOR . HTML::chars($this->title); $this->template->v_nav_top = View::factory('backend/v_nav_top'); $this->template->v_nav_left = View::factory('backend/v_nav_left', ['panels' => Module::get_panels(), 'current' => $this->config_mod['cms_module']]); parent::after(); }
/** * @param bool $id * @return bool * @throws Kohana_Exception * * insert or update book */ public function insBook($id = false) { $_POST = Arr::map('trim', $_POST); $post = Validation::factory($_POST); $post->rule('name', 'not_empty')->rule('name', 'alpha_numeric', array(':value', false))->rule('name', 'min_length', array(':value', 2))->rule('name', 'max_length', array(':value', 20))->rule('email', 'email')->rule('body', 'not_empty')->rule('body', 'max_length', array(':value', 1024)); if ($post->check()) { if ($id) { $book = ORM::factory('Guestbook', $id); } else { $book = ORM::factory('Guestbook'); } $book->name = Security::encode_php_tags(HTML::chars($_POST['name'])); $book->email = Security::encode_php_tags(HTML::chars($_POST['email'])); $book->body = Security::encode_php_tags(HTML::chars($_POST['body'])); try { if ($id) { $book->update(); } else { $book->create(); } return true; } catch (ORM_Validation_Exception $e) { return false; } } else { //$errors = $post -> errors('validation'); return false; } }
/** * Render content. * * @return string */ public function content() { ob_start(); // Stamp echo HTML::time(Date('l ', $this->event->stamp_begin) . Date::format('DDMMYYYY', $this->event->stamp_begin), $this->event->stamp_begin, true); // Location if ($this->event->venue) { echo ' @ ', HTML::anchor(Route::model($this->event->venue), HTML::chars($this->event->venue->name)), ', ', HTML::chars($this->event->venue->city_name); } elseif ($this->event->venue_name) { echo ' @ ', $this->event->venue_url ? HTML::anchor($this->event->venue_url, $this->event->venue_name) : HTML::chars($this->event->venue_name), $this->event->city_name ? ', ' . HTML::chars($this->event->city_name) : ''; } elseif ($this->event->city_name) { echo ' @ ', HTML::chars($this->event->city_name); } // Flyer if ($this->event->flyer_front) { echo '<figure>', HTML::image($this->event->flyer_front->get_url(Model_Image::SIZE_THUMBNAIL)), '</figure>'; } elseif ($this->event->flyer_back) { echo '<figure>', HTML::image($this->event->flyer_back->get_url(Model_Image::SIZE_THUMBNAIL)), '</figure>'; } elseif (Valid::url($this->event->flyer_front_url)) { echo '<br /><figure>', HTML::image($this->event->flyer_front_url, array('width' => 160)), '</figure>'; } // Favorites if ($this->event->favorite_count) { echo '<span class="stats"><i class="icon-heart"></i> ' . $this->event->favorite_count . '</span>'; } return ob_get_clean(); }
/** * 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_EVENT: $event = Model_Event::factory($item->data['event_id']); if ($event->loaded()) { $text = __('added new event<br />:event', array(':event' => HTML::anchor(Route::model($event), '<i class="icon-calendar icon-white"></i> ' . HTML::chars($event->name), array('class' => 'hoverable')))); } break; case self::TYPE_EVENT_EDIT: $event = Model_Event::factory($item->data['event_id']); if ($event->loaded()) { $text = __('updated event<br />:event', array(':event' => HTML::anchor(Route::model($event), '<i class="icon-calendar icon-white"></i> ' . HTML::chars($event->name), array('class' => 'hoverable')))); } break; case self::TYPE_FAVORITE: $event = Model_Event::factory($item->data['event_id']); if ($event->loaded()) { $text = __('added event to favorites<br />:event', array(':event' => HTML::anchor(Route::model($event), '<i class="icon-heart icon-white"></i> ' . HTML::chars($event->name), array('class' => 'hoverable')))); } break; } return $text; }
/** * Render view. * * @return string */ public function content() { ob_start(); foreach ($this->_group_by_city() as $city => $venues) { ?> <header> <h4><?php echo HTML::chars($city); ?> </h4> </header> <ul class="list-unstyled row"> <?php foreach ($venues as $venue) { ?> <li class="col-xs-6 col-sm-4 col-md-3"><?php echo HTML::anchor(Route::model($venue), HTML::chars($venue->name)); ?> </li> <?php } ?> </ul> <?php } return ob_get_clean(); }
/** * Render content. * * @return string */ public function content() { // Venue if ($this->event->venue_hidden) { $venue = __('Underground'); } elseif ($venue = $this->event->venue()) { $venue = HTML::anchor(Route::model($venue), HTML::chars($venue->name)); } else { $venue = HTML::chars($this->event->venue_name); } ob_start(); ?> <span class="details"><?php echo $this->event->price() . ($venue ? ' @ ' : '') . $venue; ?> </span><br /> <span class="djs"><?php echo HTML::chars($this->event->dj); ?> </span> <?php return ob_get_clean(); }
/** * Render <head>. * * @return string */ protected function _head() { ob_start(); ?> <head> <meta charset="<?php echo Kohana::$charset; ?> " /> <meta http-equiv="Content-Type" content="text/html; charset=<?php echo Kohana::$charset; ?> " /> <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1" /> <title><?php echo ($this->title ? HTML::chars($this->title) . ' | ' : '') . Kohana::$config->load('site.site_name'); ?> </title> <link rel="icon" type="image/png" href="<?php echo $this->base; ?> ui/favicon.png" /> <?php echo $this->_styles(); ?> </head> <?php return ob_get_clean(); }
/** * Render view. * * @return string */ public function content() { if (!$this->blog_entries) { return ''; } ob_start(); ?> <ul class="unstyled"> <?php foreach ($this->blog_entries as $entry) { ?> <li><?php echo HTML::anchor(Route::model($entry), HTML::chars($entry->name)); ?> </li> <?php } ?> </ul> <?php return ob_get_clean(); }
/** * Render view. * * @return string */ public function content() { if (!$this->blog_entries) { return ''; } ob_start(); ?> <ul class="list-unstyled"> <?php foreach ($this->blog_entries as $entry) { ?> <li><?php echo __(':blog by :author', array(':blog' => HTML::anchor(Route::model($entry), HTML::chars($entry->name)), ':author' => HTML::user($entry->author()))); ?> </li> <?php } ?> </ul> <?php return ob_get_clean(); }
/** * Render content. * * @return string */ public function content() { ob_start(); // Stamp echo HTML::time(Date('l ', $this->event->stamp_begin) . Date::format('DDMMYYYY', $this->event->stamp_begin), $this->event->stamp_begin, true); // Location if ($this->event->venue) { echo ' @ ', HTML::anchor(Route::model($this->event->venue), HTML::chars($this->event->venue->name)), ', ', HTML::chars($this->event->venue->city_name); } elseif ($this->event->venue_name) { echo ' @ ', $this->event->venue_url ? HTML::anchor($this->event->venue_url, $this->event->venue_name) : HTML::chars($this->event->venue_name), $this->event->city_name ? ', ' . HTML::chars($this->event->city_name) : ''; } elseif ($this->event->city_name) { echo ' @ ', HTML::chars($this->event->city_name); } // Flyer if ($flyer = $this->event->flyer()) { echo '<figure>', HTML::image($flyer->image_url(Model_Image::SIZE_THUMBNAIL)), '</figure>'; } elseif ($this->event->flyer_front_url) { echo '<figure>', HTML::image($this->event->flyer_front_url, ['class' => 'img-responsive']), '</figure>'; } // Favorites if ($this->event->favorite_count) { echo '<span class="stats"><i class="fa fa-heart"></i> ' . $this->event->favorite_count . '</span>'; } return ob_get_clean(); }
/** * Render content. * * @return string */ public function content() { if (!$this->events) { return ''; } ob_start(); ?> <ul class="list-unstyled"> <?php foreach ($this->events as $event) { ?> <li> <span title="<?php echo Date::format(Date::DATETIME, $event->stamp_begin) . ($event->stamp_end ? ' - ' . Date::format(Date::TIME, $event->stamp_end) : ''); ?> "><?php echo Date::format(Date::DM_PADDED, $event->stamp_begin); ?> </span> <?php echo HTML::anchor(Route::model($event), HTML::chars($event->name), array('class' => 'hoverable', 'title' => HTML::chars($event->name))); ?> </li> <?php } ?> </ul> <?php return ob_get_clean(); }
/** * Render view. * * @return string */ public function content() { if (!$this->topics) { return ''; } ob_start(); ?> <ul class="unstyled"> <?php foreach ($this->topics as $topic) { ?> <li> <small class="ago"><?php echo HTML::time(Date::short_span($topic->last_posted, true), $topic->last_posted); ?> </small> <?php echo HTML::anchor(Route::model($topic), '<i class="muted iconic-upload"></i>', array('title' => __('First post'))); ?> <?php echo HTML::anchor(Route::model($topic, '?page=last#last'), HTML::chars($topic->name), array('title' => $topic->name)); ?> </li> <?php } ?> </ul> <?php return ob_get_clean(); }
/** * Render view. * * @return string */ public function content() { ob_start(); ?> <ul class="thumbnails"> <?php foreach ($this->flyers as $flyer) { $name = $flyer->event ? $flyer->event->name : $flyer->name; ?> <li class="span2"> <?php echo HTML::anchor(Route::get('flyer')->uri(array('id' => $flyer->id)), HTML::image($flyer->image->get_url('thumbnail')), array('class' => 'thumbnail')); ?> <h4><?php echo HTML::anchor(Route::get('flyer')->uri(array('id' => $flyer->id)), HTML::chars($name), array('title' => HTML::chars($name))); ?> </h4> </li> <?php } ?> </ul> <?php return ob_get_clean(); }
/** * Render view. * * @return string */ public function content() { ob_start(); $uri = Route::model($this->venue, 'combine'); ?> <ul class="unstyled"> <?php foreach ($this->venues as $venue) { ?> <li><?php echo floor($venue['similarity']); ?> % <?php echo HTML::anchor($uri . '/' . $venue['venue']->id, HTML::chars($venue['venue']->name) . ', ' . HTML::chars($venue['venue']->city_name)); ?> </li> <?php } ?> </ul> <?php return ob_get_clean(); }
/** * Render view. * * @return string */ public function content() { ob_start(); echo '<figure>', HTML::image($this->image->get_url(Model_Image::SIZE_THUMBNAIL)), '</figure>'; // Tagged people $notes = $this->image->notes(); if (count($notes)) { $names = array(); /** @var Model_Image_Note $note */ foreach ($notes as $note) { $user = $note->user(); $names[] = $user ? HTML::user($user['username']) : HTML::chars($note->name); } echo implode(', ', $names); } // Copyright if ($this->image->author_id) { echo '<br />© ', HTML::user($this->image->author_id); } // Comments if ($this->image->comment_count) { echo '<span class="stats"><i class="icon-comment"></i> ' . $this->image->comment_count . '</span>'; } return ob_get_clean(); }
/** * Render view. * * @return string */ public function content() { ob_start(); foreach ($this->_group_by_city() as $city => $venues) { ?> <article> <header> <h4><?php echo HTML::chars($city); ?> </h4> </header> <ul class="unstyled block-grid two-up"> <?php foreach ($venues as $venue) { ?> <li><?php echo HTML::anchor(Route::model($venue), HTML::chars($venue->name)); ?> </li> <?php } ?> </ul> </article> <?php } return ob_get_clean(); }
function lili($item, $key, $cats) { ?> <option value="<?php echo $cats[$key]['seoname']; ?> " <?php echo core::get('category') == $cats[$key]['seoname'] ? 'selected' : ''; ?> > <?php echo $cats[$key]['name']; ?> </option> <?php if (count($item) > 0) { ?> <optgroup label="<?php echo HTML::chars($cats[$key]['name']); ?> "> <?php if (is_array($item)) { array_walk($item, 'lili', $cats); } ?> <?php } ?> <?php }
/** * Render alert. * * @return string */ public function render() { ob_start(); // Section attributes $attributes = array('class' => 'alert alert-block ' . $this->class); ?> <div <?php echo HTML::attributes($attributes); ?> > <?php if ($this->header) { ?> <h4 class="alert-heading"><?php echo HTML::chars($this->header); ?> </h4><?php } ?> <?php echo $this->content; ?> </div> <?php return ob_get_clean(); }
/** * Render view. * * @return string */ public function content() { if (!$this->topics) { return ''; } ob_start(); ?> <ul class="list-unstyled"> <?php foreach ($this->topics as $topic) { ?> <li> <?php echo HTML::anchor(Route::model($topic, '?page=last#last'), Forum::topic($topic), array('title' => HTML::chars($topic->name))); ?> </li> <?php } ?> </ul> <?php return ob_get_clean(); }
/** * Render view. * * @return string */ public function content() { ob_start(); ?> <ul class="list-unstyled"> <?php foreach ($this->venues as $venue) { ?> <li><?php echo HTML::anchor(Route::model($venue), HTML::chars($venue->name)); ?> </li> <?php } ?> </ul> <?php return ob_get_clean(); }
public function paginate($page = null, $link = null, $count = null) { if ($page == null) { $page = Arr::get($_GET, 'page', 1); } if (!empty($_GET['item_count'])) { $this->count = (int) Arr::get($_GET, 'item_count'); $count = $this->count; } else { if ($count == null) { $count = $this->count; } else { $this->count = (int) $count; } } if ($link == null) { $link = Request::initial()->uri(); } $count = (int) $count; $page = (int) $page; $start = $page * $count - $count; $max_page = $this->page_count(); if ($page < 1) { $page = 1; } else { $page = min($page, $max_page); } $prev = $page == 1 ? false : true; $next = $page == $max_page ? false : true; $this->orm->limit($count)->offset($start); $this->view_vars = array('page' => $page, 'max_page' => $max_page, 'key' => $this->config->get('key', 'page'), 'count' => $count, 'link' => Security::xss_clean(HTML::chars($link)), 'next' => $next, 'prev' => $prev); return Security::xss_clean(HTML::chars($this)); }
/** * 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; }
/** * Render alert. * * @return string */ public function render() { ob_start(); // Section attributes $attributes = array('class' => 'alert alert-block ' . $this->class); if ($this->header === true) { $this->header = self::generate_header(); } ?> <div <?php echo HTML::attributes($attributes); ?> > <?php if ($this->header) { ?> <strong><?php echo HTML::chars($this->header); ?> </strong><?php } ?> <?php echo $this->content; ?> </div> <?php return ob_get_clean(); }
/** * Create new view. * * @param Model_Image $image * @param Model_Gallery $gallery */ public function __construct(Model_Image $image, Model_Gallery $gallery) { parent::__construct(); $this->image = $image; $this->gallery = $gallery; $this->title = HTML::chars($gallery->name); }
/** * Create new view. * * @param Model_Flyer $flyer */ public function __construct(Model_Flyer $flyer) { parent::__construct(); $this->flyer = $flyer; $this->image = $flyer->image(); $this->event = $flyer->event(); $this->title = HTML::chars($this->event ? $this->event->name : $flyer->name); }
/** * @throws Kohana_Exception * * delete news */ public function action_del() { $id = $this->request->param('id'); $id = Security::encode_php_tags(HTML::chars($id)); $news = new Model_New(); $news->delNew($id); HTTP::redirect($_SERVER['HTTP_REFERER']); }
public static function factory() { $m = new Mustache_Engine(array('loader' => new Mustache_Loader_Kohana(), 'partials_loader' => new Mustache_Loader_Kohana('templates/partials'), 'escape' => function ($value) { return HTML::chars($value); }, 'cache' => Kohana::$cache_dir . DIRECTORY_SEPARATOR . 'mustache')); $class = get_called_class(); return new $class($m); }
public static function factory($obj) { $m = new Mustache_Engine(array('partials_loader' => new Mustache_Loader_KoaceLoader(array('layout' => $obj->layout_name, 'page' => $obj->page_name, 'aceui_dir' => $obj->aceui_dir)), 'escape' => function ($value) { return HTML::chars($value); }, 'cache' => Kohana::$cache_dir . DIRECTORY_SEPARATOR . 'mustache')); $class = get_called_class(); return new $class($m, $obj); }
/** * 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(); }