Пример #1
0
 public function action_index()
 {
     header('Access-Control-Allow-Origin: *');
     $category = (int) $this->request->param('id', 0);
     //SEO. закрываем сортировку
     if ($category != 0) {
         $sort = 1;
         Kotwig_View::set_global('sort', $sort);
     }
     //end_SEO
     $categories = ORM::factory('Photosets_Category')->find_all();
     foreach ($categories as $c) {
         $this->data['categories'][] = array('id' => $c->id, 'name' => $c->name);
     }
     $this->data['category'] = $category;
     $photosets = ORM::factory('Photoset')->where('published', '=', 1)->where('show_' . $this->language, '=', 1)->order_by('order', 'asc');
     if ($category != 0) {
         $photosets = $photosets->where('category_id', '=', $category);
     }
     $photosets = $photosets->order_by('order', 'ASC');
     $paginate = Paginate::factory($photosets)->paginate(NULL, NULL, 12)->page_count();
     $photosets = $photosets->find_all();
     if (count($photosets) < 1) {
         $this->data['error'] = 'Error photo';
     }
     $this->data['pagecount'] = $paginate;
     foreach ($photosets as $p) {
         $img = $p->isCover() ? 'http://' . $_SERVER['HTTP_HOST'] . URL::media('images/w300-h225-ccc-si/' . $p->pathCover()) : 'http://' . $_SERVER['HTTP_HOST'] . URL::media('images/w300-h225-ccc-si/media/images/nocover.jpg');
         $this->data['photosets'][] = array('url' => 'http://' . $_SERVER['HTTP_HOST'] . '/' . $this->language . URL::site('api/smartphoto/view/' . $p->id), 'image' => $img, 'name' => $p->name(), 'category' => $p->category->name);
     }
     $this->response->body(json_encode($this->data));
 }
Пример #2
0
 public function action_index()
 {
     header('Access-Control-Allow-Origin: *');
     $id = $this->request->param('id', 0);
     //SEO. закрываем сортировку
     if ($id != 0) {
         $sort = 1;
         Kotwig_View::set_global('sort', $sort);
     }
     //end_SEO
     $category = ORM::factory('Category', $id);
     $video = ORM::factory('Video')->where('published', '=', 1)->and_where('language', '=', $this->language);
     if ($category->loaded()) {
         $video = $video->and_where_open()->and_where('category_id', '=', $id);
         if ($category->has_children()) {
             $video = $video->or_where('category_id', 'IN', $category->children->as_array('id'));
         }
         $video = $video->and_where_close();
     }
     $video = $video->order_by('date', 'DESC');
     $paginate = Paginate::factory($video)->paginate(NULL, NULL, 12)->page_count();
     $video = $video->find_all();
     $cat = ORM::factory('Category')->fulltree;
     foreach ($cat as $c) {
         $this->data['cat'][] = array('id' => $c->id, 'name' => $c->name, 'level' => $c->lvl, 'url' => 'http://' . $_SERVER['HTTP_HOST'] . '/' . $this->language . URL::site('api/smartvideo/' . $c->id));
     }
     foreach ($video as $v) {
         $this->data['video'][] = array('id' => $v->id, 'link' => $v->link, 'title' => $v->title, 'description' => $v->description, 'preview' => 'http://img.youtube.com/vi/' . $v->link . '/1.jpg', 'url' => 'http://' . $_SERVER['HTTP_HOST'] . '/' . $this->language . URL::site('api/smartvideo/view/' . $v->id), 'category' => $v->category->name);
     }
     $this->data['sel_id'] = $id;
     $this->data['page_count'] = $paginate;
     $this->response->body(json_encode($this->data));
 }
Пример #3
0
 public function get_response()
 {
     $response = Response::factory();
     $view = Kotwig_View::factory('errors/500');
     $response->status(500);
     $response->body($view->render());
     return $response;
 }
Пример #4
0
 public function page_count()
 {
     $count = ceil($this->count_all() / $this->count);
     if ($count <= 0) {
         $count = 1;
     }
     Kotwig_View::set_global('max_page', $count);
     return $count;
 }
Пример #5
0
 public function render($file = NULL)
 {
     if ($file !== NULL) {
         $this->set_filename($file);
     }
     if (empty($this->_file)) {
         throw new Kohana_View_Exception('You must set the file to use within your view before rendering');
     }
     // Combine local and global data and capture the output
     return Kotwig_View::capture($this->_file, $this->_data);
 }
Пример #6
0
 public function before()
 {
     $this->default_template = $this->request->controller() . '/' . $this->request->action();
     if ($this->request->directory()) {
         // Preprend directory if needed
         $this->default_template = $this->request->directory() . '/' . $this->default_template;
     }
     $this->template = Kotwig_View::factory();
     Kotwig_View::set_global('_request', $this->request);
     Kotwig_View::set_global('_response', $this->response);
 }
Пример #7
0
 public function get_response()
 {
     $this->user = Auth::instance()->get_user();
     $this->detect_language();
     $response = Response::factory();
     $view = Kotwig_View::factory('errors/404');
     $response->status(404);
     if ($this->getMessage()) {
         $view->set('no_translation', $this->getMessage());
     }
     $response->body($view->render());
     return $response;
 }
Пример #8
0
 public function action_index()
 {
     $alphabet = array('ru' => array('А', 'Б', 'В', 'Г', 'Д', 'Е', 'Ё', 'Ж', 'З', 'И', 'Й', 'К', 'Л', 'М', 'Н', 'О', 'П', 'Р', 'С', 'Т', 'У', 'Ф', 'Х', 'Ц', 'Ч', 'Ш', 'Щ', 'Ъ', 'Ы', 'Ь', 'Э', 'Ю', 'Я'), 'kz' => array('А', 'Ә', 'Б', 'В', 'Г', 'Ғ', 'Д', 'Е', 'Ё', 'Ж', 'З', 'И', 'Й', 'К', 'Қ', 'Л', 'М', 'Н', 'Ң', 'О', 'Ө', 'П', 'Р', 'С', 'Т', 'У', 'Ү', 'Ұ', 'Ф', 'Х', 'Һ', 'Ц', 'Ч', 'Ш', 'Щ', 'Ъ', 'Ы', 'I', 'Ь', 'Э', 'Ю', 'Я'), 'en' => array('A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'));
     $lang = Security::xss_clean($this->request->param('language'));
     foreach ($alphabet[$lang] as $alpha) {
         $biog = ORM::factory('Biography')->where('published', '=', 1)->where_open()->where('name_' . $lang, 'like', $alpha . '%')->or_where('name_' . $lang, 'like', '% ' . $alpha . '%')->where_close()->find();
         if ($biog->loaded()) {
             $alphabet_new[] = $alpha;
         }
     }
     $this->set('alphabet', $alphabet_new);
     $categories1 = ORM::factory('Biography_Category')->where('era', '=', '1')->find_all();
     $halyk_kaharmany = ORM::factory('Biography_Category', 9);
     $this->set('halyk_kaharmany', $halyk_kaharmany);
     $categories2 = ORM::factory('Biography_Category')->where('era', '=', '2')->find_all();
     $this->set('categories1', $categories1)->set('categories2', $categories2);
     $category = (int) $this->request->param('category', 0);
     $alpha = Security::xss_clean($this->request->param('alpha', ""));
     //SEO. закрываем сортировку
     if ($alpha != '') {
         $sort = 1;
         Kotwig_View::set_global('sort', $sort);
     }
     //end_SEO
     $biography = ORM::factory('Biography')->where('published', '=', 1)->where('name_' . $this->language, '<>', '');
     if ($category != 0) {
         $biography = $biography->where('category_id', '=', $category);
         $this->add_cumb('Personalia', 'biography');
         $cat = ORM::factory('Biography_Category', $category);
         $this->add_cumb($cat->title, '/');
     } else {
         $biography = $biography->where('category_id', 'NOT IN', array(3, 4, 6, 7, 8, 15));
         $this->add_cumb('Personalia', '/');
     }
     if (!empty($alpha)) {
         $biography = $biography->where_open()->where('name_' . $lang, 'like', $alpha . '%')->or_where('name_' . $lang, 'like', '% ' . $alpha . '%')->where_close();
     }
     $biography = $biography->order_by('order');
     $paginate = Paginate::factory($biography)->paginate(NUll, NULL, 10)->render();
     $biography = $biography->find_all();
     if (count($biography) == 0) {
         $this->set('error', I18n::get('Sorry.'));
     }
     /* метатэг description */
     $biography_meta = ORM::factory('Page')->where('key', '=', 'biography_' . $category . '_1')->find();
     $this->metadata->description($biography_meta->description);
     $this->set('list', $biography)->set('paginate', $paginate)->set('category', $category)->set('alpha', $alpha);
 }
Пример #9
0
 public function action_index()
 {
     $category_id = (int) Arr::get($_GET, 'category', 0);
     //SEO. закрываем сортировку
     if ($category_id != 0) {
         $sort = 1;
         Kotwig_View::set_global('sort', $sort);
     }
     //end_SEO
     $audio = ORM::factory('Audio')->where('published', '=', 1)->and_where('show_' . I18n::$lang, '=', 1)->and_where('storage_id', '>', 0);
     if ($category_id != 0) {
         $audio = $audio->and_where('category_id', '=', $category_id);
         $audio = $audio->order_by('numb');
     } else {
         $audio = $audio->order_by('title');
     }
     $paginate = Paginate::factory($audio)->paginate(NULL, NULL, 12)->render();
     $audio = $audio->find_all();
     if ($category_id != 0) {
         $this->add_cumb('Audio', 'audio');
         $category = ORM::factory('Audio_Category', $category_id);
         $this->add_cumb($category->name, '');
     } else {
         $this->add_cumb('Audio', '');
     }
     $this->set('name_category', $category_id != 0 ? $category->name : '');
     $this->set('selected_cat', $category_id);
     $this->set('audio', $audio);
     $this->set('paginate', $paginate);
     $for_category = ORM::factory('Audio')->where('published', '=', 1)->and_where('show_' . I18n::$lang, '=', 1)->and_where('storage_id', '>', 0)->find_all();
     $list_category = array();
     foreach ($for_category as $cat_id) {
         array_push($list_category, $cat_id->category_id);
         $category = ORM::factory('Audio_Category', $cat_id->category_id);
         $list_category = array_merge($list_category, $category->rev());
     }
     $list_category = array_unique($list_category);
     $cats = ORM::factory('Audio_Category')->fulltree;
     $filter_cat = array();
     foreach ($cats as $cat) {
         if (in_array($cat->id, $list_category)) {
             array_push($filter_cat, $cat);
         }
     }
     $this->set('cats', $filter_cat);
 }
Пример #10
0
 public function action_index()
 {
     $id = $this->request->param('id', 0);
     //SEO. закрываем сортировку
     if ($id != 0) {
         $sort = 1;
         Kotwig_View::set_global('sort', $sort);
     }
     //end_SEO
     $category = ORM::factory('Category', $id);
     $video = ORM::factory('Video')->where('published', '=', 1)->and_where('language', '=', $this->language);
     if ($category->loaded()) {
         $video = $video->and_where_open()->and_where('category_id', '=', $id);
         if ($category->has_children()) {
             $video = $video->or_where('category_id', 'IN', $category->children->as_array('id'));
         }
         $video = $video->and_where_close();
         $this->add_cumb('Video', 'video');
         $this->add_cumb($category->name, '');
     } else {
         $this->add_cumb('Video', '');
     }
     $video = $video->order_by('date', 'DESC');
     $paginate = Paginate::factory($video)->paginate(NULL, NULL, 12)->render();
     $video = $video->find_all();
     $categories = ORM::factory('Category')->find_all();
     $mas_categories = array();
     foreach ($categories as $item) {
         $video_count = ORM::factory('Video')->where('published', '=', 1)->and_where('language', '=', $this->language)->and_where_open()->and_where('category_id', '=', $item->id);
         /* if ($item->has_children())
            {
                $video_count = $video_count->or_where('category_id', 'IN', $item->children->as_array('id'));
            }
            $video_count = $video_count->and_where_close()->count_all(); */
         if ($video_count) {
             $mas_categories[] = $item;
         }
     }
     $cat = ORM::factory('Category')->fulltree;
     $count_comments = Comments::instance();
     $this->set('cat', $cat);
     $this->set('video', $video)->set('categories', $mas_categories)->set('select_id', $id);
     $this->set('paginate', $paginate)->set('count_comments', $count_comments);
 }
Пример #11
0
 public function action_index()
 {
     $list = ORM::factory('Debate')->where_open()->where('is_public', '=', 1);
     $id = (int) $this->request->param('id', 0);
     $status = Security::xss_clean(Arr::get($_GET, 'status', ''));
     //SEO. закрываем сортировку
     if ($id != 0 or $status != '') {
         $sort = 1;
         Kotwig_View::set_global('sort', $sort);
     }
     //end_SEO
     $nowdate = date('Y-m-d H:i:s');
     $user = ORM::factory('User', $id);
     if (!$user->loaded() and $id) {
         $this->redirect("debate", 301);
     }
     if (Auth::instance()->logged_in()) {
         $has_ma_access = Auth::instance()->get_user()->has_access('ma');
     } else {
         $has_ma_access = 0;
     }
     if (!$has_ma_access) {
         $list = $list->and_where('is_closed', '=', 0);
     } else {
         $list = $list->or_where('is_public', '=', 0);
     }
     if ($id) {
         $username = $user->username;
         $this->add_cumb('Debate', 'debate');
         $this->add_cumb($username, '/');
     } else {
         $this->add_cumb('Debate', '/');
     }
     switch ($status) {
         case "active":
             $list->and_where('end_time', '>', $nowdate);
             $this->set('status', 'active');
             break;
         case "ending":
             $list->and_where('end_time', '<', $nowdate);
             $this->set('status', 'ending');
             break;
         default:
             if ($id) {
                 $list->and_where('author_id', '=', $id);
                 $this->set('id', $id);
             } else {
                 if (Auth::instance()->logged_in()) {
                     $list->or_where('author_id', '=', Auth::instance()->get_user()->id)->or_where('opponent_email', '=', Auth::instance()->get_user()->email);
                 }
             }
             $this->set('status', 'all');
     }
     $list->where_close()->and_where('language', '=', $this->language)->order_by('date', 'DESC');
     $paginate = Paginate::factory($list)->paginate(NULL, NULL, 10)->render();
     $list = $list->find_all();
     $this->set('list', $list);
     $this->set('paginate', $paginate);
     $this->set('nowdate', $nowdate);
     $authors = new Massiv();
     $users = array();
     $debate = ORM::factory('Debate')->where('is_public', '=', 1)->and_where('is_closed', '=', 0)->find_all();
     foreach ($debate as $item) {
         if (!in_array($item->author_id, $users)) {
             $users[] = $item->author_id;
             $count = ORM::factory('Debate')->where('is_public', '=', 1)->and_where('author_id', '=', $item->author_id)->count_all();
             $username = $item->author->username;
             $authors[$item->author_id] = array('name' => $username, 'count' => $count);
         }
         if (sizeof($users) == 25) {
             break;
         }
     }
     $this->set('authors', $authors);
     /* метатэг description */
     $this->metadata->description(i18n::get('Дебаты на исторические темы'));
 }
Пример #12
0
 public function action_index()
 {
     header('Access-Control-Allow-Origin: *');
     $list = ORM::factory('Debate')->where_open()->where('is_public', '=', 1);
     $id = (int) $this->request->param('id', 0);
     $status = Security::xss_clean(Arr::get($_GET, 'status', ''));
     //SEO. закрываем сортировку
     if ($id != 0 or $status != '') {
         $sort = 1;
         Kotwig_View::set_global('sort', $sort);
     }
     //end_SEO
     $nowdate = date('Y-m-d H:i:s');
     $user = ORM::factory('User', $id);
     if (Auth::instance()->logged_in()) {
         $has_ma_access = Auth::instance()->get_user()->has_access('ma');
     } else {
         $has_ma_access = 0;
     }
     if (!$has_ma_access) {
         $list = $list->and_where('is_closed', '=', 0);
     } else {
         $list = $list->or_where('is_public', '=', 0);
     }
     switch ($status) {
         case "active":
             $list->and_where('end_time', '>', $nowdate);
             $this->set('status', 'active');
             break;
         case "ending":
             $list->and_where('end_time', '<', $nowdate);
             $this->set('status', 'ending');
             break;
         default:
             if ($id) {
                 $list->and_where('author_id', '=', $id);
                 $this->set('id', $id);
             } else {
                 if (Auth::instance()->logged_in()) {
                     $list->or_where('author_id', '=', Auth::instance()->get_user()->id)->or_where('opponent_email', '=', Auth::instance()->get_user()->email);
                 }
             }
             $this->data['status'] = 'all';
     }
     $list->where_close()->and_where('language', '=', $this->language)->order_by('date', 'DESC');
     $paginate = Paginate::factory($list)->paginate(NULL, NULL, 10)->page_count();
     $list = $list->find_all();
     $this->data['pagecount'] = $paginate;
     $this->data['nowdate'] = $nowdate;
     $status = false;
     foreach ($list as $item) {
         if ($item->is_closed == 0) {
             if (Date::translate($item->end_time, 'U') < Date::translate($nowdate, 'U') and Date::translate($item->end_time, 'U') != 0) {
                 $status = false;
             } else {
                 $status = true;
             }
         }
         $deb = array();
         $deb['id'] = $item->id;
         $deb['title'] = $item->title;
         $deb['preview'] = $item->description;
         $deb['createdDate'] = $item->date;
         $deb['authorId'] = $item->author->id;
         $deb['authorUsername'] = $item->author->username;
         $deb['opponentId'] = $item->opponent->id;
         $deb['opponentUsername'] = $item->opponent->username;
         $deb['isActive'] = $status;
         $deb['endTime'] = $item->end_time;
         $deb['url'] = URL::site('/', true) . $this->language . '/api/smartdebates/view/' . $item->id;
         $this->data['list'][] = $deb;
     }
     $this->response->body(json_encode($this->data));
 }
Пример #13
0
 public function action_index()
 {
     header('Access-Control-Allow-Origin: *');
     $alphabet = array('ru' => array('А', 'Б', 'В', 'Г', 'Д', 'Е', 'Ё', 'Ж', 'З', 'И', 'Й', 'К', 'Л', 'М', 'Н', 'О', 'П', 'Р', 'С', 'Т', 'У', 'Ф', 'Х', 'Ц', 'Ч', 'Ш', 'Щ', 'Ъ', 'Ы', 'Ь', 'Э', 'Ю', 'Я'), 'kz' => array('А', 'Ә', 'Б', 'В', 'Г', 'Ғ', 'Д', 'Е', 'Ё', 'Ж', 'З', 'И', 'Й', 'К', 'Қ', 'Л', 'М', 'Н', 'Ң', 'О', 'Ө', 'П', 'Р', 'С', 'Т', 'У', 'Ү', 'Ұ', 'Ф', 'Х', 'Һ', 'Ц', 'Ч', 'Ш', 'Щ', 'Ъ', 'Ы', 'I', 'Ь', 'Э', 'Ю', 'Я'), 'en' => array('A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'));
     $lang = Security::xss_clean($this->request->param('language'));
     foreach ($alphabet[$lang] as $alpha) {
         $biog = ORM::factory('Biography')->where('published', '=', 1)->where_open()->where('name_' . $lang, 'like', $alpha . '%')->or_where('name_' . $lang, 'like', '% ' . $alpha . '%')->where_close()->find();
         if ($biog->loaded()) {
             $alphabet_new[] = $alpha;
         }
     }
     $this->data['alphabet'] = $alphabet_new;
     $categories1 = ORM::factory('Biography_Category')->where('era', '=', '1')->find_all();
     $halyk_kaharmany = ORM::factory('Biography_Category', 9);
     foreach ($categories1 as $k => $v) {
         $cat = array();
         $cat['id'] = $v->id;
         $cat['title'] = $v->title;
         $this->data['categories1'][] = $cat;
     }
     $this->data['halyk_kaharmany'] = array('id' => $halyk_kaharmany->id, 'title' => $halyk_kaharmany->title);
     $category = (int) $this->request->param('id', 0);
     $biography = ORM::factory('Biography')->where('published', '=', 1)->where('name_' . $this->language, '<>', '');
     if ($category != 0) {
         $biography = $biography->where('category_id', '=', $category);
         $cat = ORM::factory('Biography_Category', $category);
     } else {
         $biography = $biography->where('category_id', 'NOT IN', array(3, 4, 6, 7, 8, 15));
     }
     $alpha = Security::xss_clean($this->request->param('category', ""));
     //SEO. закрываем сортировку
     if ($alpha != '') {
         $sort = 1;
         Kotwig_View::set_global('sort', $sort);
     }
     //end_SEO
     if (!empty($alpha)) {
         $biography = $biography->where_open()->where('name_' . $lang, 'like', $alpha . '%')->or_where('name_' . $lang, 'like', '% ' . $alpha . '%')->where_close();
     }
     $biography = $biography->order_by('order');
     $paginate = Paginate::factory($biography)->paginate(NUll, NULL, 10)->page_count();
     $biography = $biography->find_all();
     if (count($biography) == 0) {
         $this->data['error'] = I18n::get('Sorry.');
     } else {
         foreach ($biography as $k => $v) {
             $bio = array();
             $bio['id'] = $v->id;
             $bio['name'] = $v->name;
             $bio['image'] = URL::media('/images/w140-h187-cct-si/' . $v->picture->file_path, true);
             $bio['date_start'] = $v->getYear('date_start');
             $bio['date_finish'] = $v->getYear('date_finish');
             $bio['desc'] = $v->desc;
             $bio['url'] = 'http://' . $_SERVER['HTTP_HOST'] . '/' . $this->language . URL::site('api/smartpersonalii/view/' . $v->id);
             $this->data['list'][] = $bio;
         }
     }
     $this->data['pagecount'] = $paginate;
     $this->data['alpha'] = $alpha;
     $this->data['category'] = $category;
     $this->response->body(json_encode($this->data));
 }
Пример #14
0
 public function action_index()
 {
     /*$year = (int)$this->request->param('year', 0);
             $list = Security::xss_clean($this->request->param('list', '0'));
     
             $attach = ORM::factory('Photosets_Attachment')->find_all();
             $count = count($attach);
     
             $rand = array();
             $ar = array();
             while (count($rand) < 15) {
                 $r=rand(0, $count);
                 if (!in_array($r, $ar))
                 {
                     $rand[] = ORM::factory('Photosets_Attachment')->limit(1)->offset($r)->find();
                     $ar[] = $r;
                 }
             }
             $photosets = ORM::factory('Photoset')->where('published','=', 1);
             if ($year > 0)
             {
                 $photosets = $photosets->where(DB::expr('YEAR(date)'), '=', $year);
             }
             $photosets->order_by('date', 'DESC');
             $paginate = Paginate::factory($photosets)->paginate(NULL, NULL, 15)->render();
             $photosets = $photosets->find_all();
     
             $this->set('photosets', $photosets)->set('rand', $rand);
             $this->set('paginate', $paginate);
             if ($list == 'list')
             {
                 $this->set('list', $list);
             }
             if ($year > 0)
             {
                 $this->set('year', $year);
             }
             $this->add_cumb('Photosets','/');*/
     $category = (int) $this->request->param('category', 0);
     //SEO. закрываем сортировку
     if ($category != 0) {
         $sort = 1;
         Kotwig_View::set_global('sort', $sort);
     }
     //end_SEO
     $categories = ORM::factory('Photosets_Category')->find_all();
     $this->set('categories', $categories)->set('category', $category);
     $photosets = ORM::factory('Photoset')->where('published', '=', 1)->where('show_' . $this->language, '=', 1)->order_by('order', 'asc');
     if ($category != 0) {
         $photosets = $photosets->where('category_id', '=', $category);
         $this->add_cumb('Photosets', 'photosets');
         $cat = ORM::factory('Photosets_Category', $category);
         $this->add_cumb($cat->name, '/');
     } else {
         $this->add_cumb('Photosets', '/');
     }
     $photosets = $photosets->order_by('order', 'ASC');
     $paginate = Paginate::factory($photosets)->paginate(NULL, NULL, 12)->render();
     $photosets = $photosets->find_all();
     if (count($photosets) < 1) {
         $this->set('error', I18n::get('Error photo'));
     }
     $this->set('photosets', $photosets)->set('paginate', $paginate);
 }