public function action_fupload() { if (!empty($_FILES['file'])) { $user_id = Auth::instance()->get_user()->id; $storage_id = Storage::instance()->add($_FILES['file'], $user_id); if ($storage_id) { $image = ORM::factory('Storage', $storage_id); $fname = URL::media($image->file_path); // displaying file $array = array('filelink' => $fname, 'filename' => $image->name); echo stripslashes(json_encode($array)); exit; } else { throw new HTTP_Exception_404('Ошибка при сохранении'); } } else { throw new HTTP_Exception_404('Не верный формат картинки'); } //////////////////// /* $dir = APPPATH . '../media/upload/'; $fname = substr(md5(time()), 0, 8) . '_' . $_FILES['file']['name']; move_uploaded_file($_FILES['file']['tmp_name'], $dir . $fname); $array = array( 'filelink' => Url::site('/media/upload/').'/'. $fname, 'filename' => $_FILES['file']['name'] ); echo stripslashes(json_encode($array)); exit; */ }
public function action_index() { header('Access-Control-Allow-Origin: *'); $photosets = ORM::factory('Photoset')->where('published', '=', 1)->where('is_important', '=', 1)->where('show_' . $this->language, '=', 1)->order_by('date', 'DESC')->limit(1)->find_all(); if (count($photosets) < 1) { $this->data['error'] = 'Publication not found'; } foreach ($photosets as $k => $v) { $this->data['lastphoto']['id'] = $v->id; $this->data['lastphoto']['name'] = $v->name; $this->data['lastphoto']['date'] = $v->date; $attach = $v->attach->where('main', '=', '1')->find(); $this->data['lastphoto']['file_path'] = 'http://' . $_SERVER['HTTP_HOST'] . URL::media('/images/w505-h680/' . $attach->photo->file_path); } $publications = ORM::factory('Publication')->where('title_' . I18n::$lang, '<>', '')->where('published', '=', 1)->and_where('is_slider', '=', 1)->order_by('order', 'desc')->limit(3)->find_all(); $pub = array(); foreach ($publications as $k => $v) { $coverUrl = ''; if (!empty($v->picture->file_path)) { $coverUrl = 'http://' . $_SERVER['HTTP_HOST'] . URL::media('/images/w333-h214/' . $v->picture->file_path); } $pub['id'] = $v->id; $pub['url'] = 'http://' . $_SERVER['HTTP_HOST'] . URL::site('api/smartpublications/view/' . $v->id); $pub['title'] = $v->title; $pub['desc'] = strip_tags($v->desc); $pub['coverUrl'] = $coverUrl; $this->data['publications'][] = $pub; } $this->response->body(json_encode($this->data)); }
public function action_feed() { $info = array('title' => __($this->metadata->title), 'pubDate' => date('r'), 'description' => $this->metadata->description, 'language' => I18n::lang(), 'ttl' => 60); $news = ORM::factory('Publication')->where('published', '=', 1)->order_by('date', 'desc')->limit(40)->find_all(); $items = array(); foreach ($news as $item) { $items[] = array('title' => $item->title, 'description' => strip_tags($item->desc), 'image' => isset($item->picture->file_path) && $item->picture->file_path ? URL::media($item->picture->file_path, TRUE) : '', 'content' => strip_tags($item->text), 'link' => Url::site('publications/view/' . $item->id, true), 'pubDate' => date('r', strtotime($item->date))); } header('Content-Type: text/xml; charset=utf-8'); $xml = Feed::create($info, $items, 'UTF-8'); echo $xml; die; }
function userdata($userid) { $user = ORM::factory('User', $userid); if ($user->profile->first_name != '' and $user->profile->last_name != '') { $username = $user->profile->first_name . ' ' . $user->profile->last_name; } else { $username = $user->username; } if (!empty($user->profile->img->file_path)) { $author = array('name' => $username, 'id' => $user->id, 'photoUrl' => URL::media($user->profile->img->file_path, true)); } else { $author = array('name' => $username, 'id' => $user->id, 'photoUrl' => ''); } return $author; }
public function action_view() { header('Access-Control-Allow-Origin: *'); $id = (int) $this->request->param('id', 0); $material = ORM::factory('Education', $id); if (!$material->loaded()) { $this->data['error'] = '404 Not found'; $this->response->body(json_encode($this->data)); return; } $materials = $material->materials->find_all(); $this->data = array('id' => $material->id, 'title' => $material->title); foreach ($materials as $k => $v) { $this->data['materials'][] = array('type' => $v->type, 'path' => URL::media('media/scorm/' . $material->id . '/' . $v->path, true), 'title' => $v->title); } $this->response->body(json_encode($this->data)); }
public function action_view() { header('Access-Control-Allow-Origin: *'); $id = (int) $this->request->param('id', 0); $photoset = ORM::factory('Photoset')->where('id', '=', $id)->where('show_' . $this->language, '=', 1)->find(); if (!$photoset->loaded()) { $this->data['error'] = '404 Not Found'; $this->response->body(json_encode($this->data)); return; } $attach = $photoset->attach->order_by('order', 'asc')->find_all(); $this->data['name'] = $photoset->name(); foreach ($attach as $a) { $this->data['photos'][] = array('name' => $a->name, 'thumb' => 'http://' . $_SERVER['HTTP_HOST'] . URL::media('images/w184-h184-ccc-si/' . $a->photo->file_path), 'full' => 'http://' . $_SERVER['HTTP_HOST'] . URL::media($a->photo->file_path)); } $this->response->body(json_encode($this->data)); }
public function action_view() { header('Access-Control-Allow-Origin: *'); $id = (int) $this->request->param('id', 0); $item = ORM::factory('Publication', $id); if (!$item->loaded()) { throw new HTTP_Exception_404(); } if (!$item->translation()) { throw new HTTP_Exception_404('no_translation'); } $this->data['id'] = $item->id; $this->data['title'] = $item->title; $this->data['text'] = $item->text; $this->data['image'] = 'http://' . $_SERVER['HTTP_HOST'] . URL::media($item->picture->file_path); $tags = $item->tags->where('type', '=', 'publication')->find_all()->as_array('id', 'name'); $tags = implode(', ', $tags); $this->data['tags'] = (array) $tags; $this->response->body(json_encode($this->data)); }
public function action_index() { $email = Security::xss_clean(Arr::get($this->post, 'email', '')); $user = ORM::factory('User')->where('email', '=', $email)->find(); if ($user->loaded() && $user->network_reg == 0 && empty($user->link_activate)) { $date = date("Y-m-d H:i:s"); $code = md5($date . $user->password); Email::connect(); Email::View('reminderapi'); Email::set(array('username' => $user->username, 'id' => $code, 'url' => URL::media($this->language . '/auth/recovery/', true))); Email::send($user->email, array('*****@*****.**', 'e-history.kz'), "E-history.kz, ссылка для смены пароля.", '', true); $save_code = ORM::factory('User', $user->id); $save_code->link_recovery = $code; $save_code->save(); $this->data = true; } else { $this->data['error'] = 'Email is not registered'; } $this->response->body(json_encode($this->data)); }
public function action_materials() { if (!Auth::instance()->logged_in()) { $this->redirect('/', 301); } $user_id = $this->user->id; $materials = ORM::factory('Material')->where('user_id', '=', $user_id); $paginate = Paginate::factory($materials)->paginate(NULL, NULL, 3)->render(); $materials = $materials->find_all(); $this->set('materials', $materials); $this->set('paginate', $paginate); $uploader = View::factory('storage/materials')->set('user_id', $user_id)->render(); $this->set('uploader', $uploader); if ($this->request->method() == Request::POST) { $journal = (int) Arr::get($_POST, 'material_type', 0); if ($journal !== 1) { $journal = 0; } try { $material = ORM::factory('Material'); $material->theme = substr(Arr::get($_POST, 'theme', ''), 0, 250); $material->message = substr(Arr::get($_POST, 'message', ''), 0, 500); $material->user_id = $user_id; $material->date = date('Y-m-d H:i:s'); $material->lang_notice = strtolower(Kohana_I18n::lang()); if ($journal) { $material->is_journal = 1; $material->is_moderator = 0; } $material->save(); $files = Arr::get($_POST, 'files', ''); if ($files) { foreach ($files as $key => $file) { if ($key > 7) { break; } if ($file) { $storage = ORM::factory('Storage', (int) $file); try { $upload = ORM::factory('Material_File'); $upload->user_id = $user_id; $upload->material_id = $material->id; $upload->date = date('Y-m-d H:i:s'); $upload->storage_id = (int) $file; $upload->filesize = filesize($storage->file_path); $upload->save(); } catch (ORM_Validation_Exception $e) { } } } } Message::success(i18n::get('The material sent to the moderator. Thank you!')); $user = ORM::factory('User', $user_id); $user_email = $user->email; Email::connect(); Email::View('review_now_' . i18N::lang()); Email::set(array('message' => I18n::get('Оставленный вами материал находится на рассмотрении редакционной коллегии портала'))); Email::send($user_email, array('*****@*****.**', 'e-history.kz'), I18n::get('Рассмотрение материала на портале "История Казахстана" e-history.kz'), '', true); if ($journal != 1) { $material_type = 'Интересные материалы'; $url = URL::media('/manage/materials', TRUE); } else { $material_type = 'Журнал e-history'; $url = URL::media('/manage/materials/ehistory', TRUE); } $user_profile = ORM::factory('User_Profile', $user_id); if ($user_profile->first_name != '') { $user_name = $user_profile->first_name . ' ' . $user_profile->last_name; } else { $user_name = $user->username; } $email = '*****@*****.**'; Email::connect(); Email::View('new_material'); Email::set(array('url' => $url, 'material_type' => $material_type, 'username' => $user_name)); Email::send($email, array('*****@*****.**', 'e-history.kz'), "Новый материал на e-history.kz", '', true); $this->redirect('profile/materials', 301); } catch (ORM_Validation_Exception $e) { $errors = $e->errors($e->alias()); $files = Arr::get($_POST, 'files', ''); $this->set('errors', $errors)->set('material', $_POST)->set('files', $files); } } $this->add_cumb('User profile', 'profile'); $this->add_cumb('Downloaded Content', '/'); }
public function action_index() { $start = Arr::get($_POST, 'start', date('Y-m-d 00:00:00')); $end = Arr::get($_POST, 'end', date('Y-m-d 23:59:59')); $logs = ORM::factory('Log')->where('date', '>=', $start)->and_where('date', '<=', $end)->find_all(); $data = array(); $models = array('Model_Publication' => __('Publications'), 'Model_News' => __('News'), 'Model_Pages_Content' => __('Pages'), 'Model_Expert_Opinion' => __('Expert opinions'), 'Model_Biography' => __('Biographies'), 'Model_Briefing' => __('Briefings'), 'Model_Calendar' => __('Calendar'), 'Model_Chronology_Line' => __('Chronology'), 'Model_Video' => __('Video'), 'Model_Audio' => __('Audio'), 'Model_Photoset' => __('Photosets'), 'Model_Point' => __('Point'), 'Model_Infograph' => __('Infographics'), 'Model_Slider' => __('Slider'), 'Model_Book' => __('Library'), 'Model_Debate' => __('Debate')); $all = array(); $today = array(); foreach ($models as $model => $garbage) { $e = explode('_', $model); array_shift($e); $count = ORM::factory(implode('_', $e))->count_all(); $all[$model] = $count; $today[$model] = 0; } $this->set('all', $all); foreach ($logs as $log) { $user = ORM::factory('User', $log->user_id); $model = $log->model; $u = $user->email . ', ' . $user->username; if (isset($data[$model][$u]['count'])) { $data[$model][$u]['count']++; } else { $data[$model][$u]['count'] = 1; } if (isset($data[$model][$u]['words'])) { $data[$model][$u]['words'] = $data[$model][$u]['words'] + $log->count; } else { $data[$model][$u]['words'] = $log->count; } $today[$model]++; if ($model == 'Model_Publication') { $publication = ORM::factory('Publication', $log->content_id); $data[$model][$u]['event'][] = $log->event; $data[$model][$u]['pubs'][] = '<a target="_blank" href="' . URL::media('manage/publications/publication/view/' . $publication->id) . '">' . $publication->title . '</a>'; $data[$model][$u]['title'][] = $log->title; $data[$model][$u]['has'][] = $publication->loaded() ? 1 : 0; } if ($model == 'Model_News') { $news = ORM::factory('News', $log->content_id); $data[$model][$u]['pubs'][] = '<a target="_blank" href="' . URL::media('manage/publications/news/view/' . $news->id) . '">' . $news->title . '</a>'; $data[$model][$u]['event'][] = $log->event; $data[$model][$u]['title'][] = $log->title; $data[$model][$u]['has'][] = $news->loaded() ? 1 : 0; } if ($model == 'Model_Pages_Content') { $content = ORM::factory('Pages_Content', $log->content_id); $data[$model][$u]['pubs'][] = '<a target="_blank" href="' . URL::media('manage/contents/show/' . $content->id) . '">' . $content->title . '</a>'; $data[$model][$u]['event'][] = $log->event; $data[$model][$u]['title'][] = $log->title; $data[$model][$u]['has'][] = $content->loaded() ? 1 : 0; } if ($model == 'Model_Expert_Opinion') { $opinion = ORM::factory('Expert_Opinion', $log->content_id); $data[$model][$u]['pubs'][] = '<a target="_blank" href="' . URL::media('manage/expertopinions/view/' . $opinion->id) . '">' . $opinion->title . '</a>'; $data[$model][$u]['event'][] = $log->event; $data[$model][$u]['title'][] = $log->title; $data[$model][$u]['has'][] = $opinion->loaded() ? 1 : 0; } if ($model == 'Model_Debate') { $debate = ORM::factory('Debate', $log->content_id); $data[$model][$u]['pubs'][] = '<a target="_blank" href="' . URL::media('manage/debate/edit/' . $debate->id) . '">' . $debate->title . '</a>'; $data[$model][$u]['event'][] = $log->event; $data[$model][$u]['title'][] = $log->title; $data[$model][$u]['has'][] = $debate->loaded() ? 1 : 0; } if ($model == 'Model_Biography') { $biography = ORM::factory('Biography', $log->content_id); $data[$model][$u]['pubs'][] = '<a target="_blank" href="' . URL::media('manage/biography/view/' . $biography->id) . '">' . $biography->name . '</a>'; $data[$model][$u]['event'][] = $log->event; $data[$model][$u]['title'][] = $log->title; $data[$model][$u]['has'][] = $biography->loaded() ? 1 : 0; } if ($model == 'Model_Briefing') { $briefing = ORM::factory('Briefing', $log->content_id); $data[$model][$u]['pubs'][] = '<a target="_blank" href="' . URL::media('manage/briefings/view/' . $briefing->id) . '">' . $briefing->title . '</a>'; $data[$model][$u]['event'][] = $log->event; $data[$model][$u]['title'][] = $log->title; $data[$model][$u]['has'][] = $briefing->loaded() ? 1 : 0; } if ($model == 'Model_Calendar') { $calendar = ORM::factory('Calendar', $log->content_id); $data[$model][$u]['pubs'][] = '<a target="_blank" href="' . URL::media('manage/calendar/view/' . $calendar->id) . '">' . $calendar->title . '</a>'; $data[$model][$u]['event'][] = $log->event; $data[$model][$u]['title'][] = $log->title; $data[$model][$u]['has'][] = $calendar->loaded() ? 1 : 0; } if ($model == 'Model_Chronology_Line') { $line = ORM::factory('Chronology_Line', $log->content_id); $data[$model][$u]['pubs'][] = '<a target="_blank" href="' . URL::media('manage/chronology/edit/' . $line->id) . '">' . $line->title . '</a>'; $data[$model][$u]['event'][] = $log->event; $data[$model][$u]['title'][] = $log->title; $data[$model][$u]['has'][] = $line->loaded() ? 1 : 0; } if ($model == 'Model_Video') { $video = ORM::factory('Video', $log->content_id); $data[$model][$u]['pubs'][] = '<a target="_blank" href="' . URL::media('manage/video/view/' . $video->id) . '">' . $video->title . '</a>'; $data[$model][$u]['event'][] = $log->event; $data[$model][$u]['title'][] = $log->title; $data[$model][$u]['has'][] = $video->loaded() ? 1 : 0; } if ($model == 'Model_Audio') { $audio = ORM::factory('Audio', $log->content_id); $data[$model][$u]['pubs'][] = '<a target="_blank" href="' . URL::media('manage/audio/edit/' . $audio->id) . '">' . $audio->title . '</a>'; $data[$model][$u]['event'][] = $log->event; $data[$model][$u]['title'][] = $log->title; $data[$model][$u]['has'][] = $audio->loaded() ? 1 : 0; } if ($model == 'Model_Photoset') { $photoset = ORM::factory('Photoset', $log->content_id); $data[$model][$u]['pubs'][] = '<a target="_blank" href="' . URL::media('manage/photosets/view/' . $photoset->id) . '">' . $photoset->name . '</a>'; $data[$model][$u]['event'][] = $log->event; $data[$model][$u]['title'][] = $log->title; $data[$model][$u]['has'][] = $photoset->loaded() ? 1 : 0; } if ($model == 'Model_Point') { $point = ORM::factory('Point', $log->content_id); $data[$model][$u]['pubs'][] = '<a target="_blank" href="' . URL::media('manage/point/edit/' . $point->id) . '">' . $point->name . '</a>'; $data[$model][$u]['event'][] = $log->event; $data[$model][$u]['title'][] = $log->title; $data[$model][$u]['has'][] = $point->loaded() ? 1 : 0; } if ($model == 'Model_Infograph') { $infograph = ORM::factory('Infograph', $log->content_id); $data[$model][$u]['pubs'][] = '<a target="_blank" href="' . URL::media('manage/infographs/view/' . $infograph->id) . '">' . $infograph->title . '</a>'; $data[$model][$u]['event'][] = $log->event; $data[$model][$u]['title'][] = $log->title; $data[$model][$u]['has'][] = $infograph->loaded() ? 1 : 0; } if ($model == 'Model_Slider') { $slider = ORM::factory('Slider', $log->content_id); $data[$model][$u]['pubs'][] = '<a target="_blank" href="' . URL::media('manage/sliders/edit/' . $slider->id . '?type=slider') . '">' . $slider->title . '</a>'; $data[$model][$u]['event'][] = $log->event; $data[$model][$u]['title'][] = $log->title; $data[$model][$u]['has'][] = $slider->loaded() ? 1 : 0; } if ($model == 'Model_Book') { $book = ORM::factory('Book', $log->content_id); $data[$model][$u]['pubs'][] = '<a target="_blank" href="' . URL::media('manage/library/show/' . $book->id) . '">' . $book->title . '</a>'; $data[$model][$u]['event'][] = $log->event; $data[$model][$u]['title'][] = $log->title; $data[$model][$u]['has'][] = $book->loaded() ? 1 : 0; } } $this->set('today', $today); $this->set('data', $data)->set('models', $models)->set('dates', array('start' => date('d.m.Y', strtotime($start)), 'end' => date('d.m.Y', strtotime($end)))); }
public function action_picturecut() { $x1 = (int) Arr::get($_POST, 'x1', 0); $h = (int) Arr::get($_POST, 'h', 0); $y1 = (int) Arr::get($_POST, 'y1', 0); $w = (int) Arr::get($_POST, 'w', 0); $path = Arr::get($_POST, 'path', 0); $user_id = Auth::instance()->get_user()->id; $storage_id = Storage::instance()->save_jcrop_photo(URL::media($path, true), $user_id); $storage = ORM::factory('Storage', $storage_id); $newpath = $storage->file_path; $targ_w = 280; $targ_h = 186; $ext = explode('.', $path); $ext = $ext[1]; if ($ext != 'png') { $img_r = imagecreatefromjpeg(URL::media($newpath, true)); } else { $img_r = imagecreatefrompng(URL::media($newpath, true)); } $dst_r = ImageCreateTrueColor($targ_w, $targ_h); imagecopyresampled($dst_r, $img_r, 0, 0, $x1, $y1, $targ_w, $targ_h, $w, $h); if ($ext != 'png') { imagejpeg($dst_r, $newpath, 90); } else { imagepng($dst_r, $newpath, 9); } $result['path'] = $newpath; $result['id'] = $storage_id; $this->response->body(json_encode($result)); }
</div> <?php endif; ?> */ ?> <div id="comments-block"> <?php foreach ($commentaries as $comment) { ?> <div class="one-comment"> <div class="c-user-avatar"> <?php if (isset($comment->user->profile->img->file_path)) { ?> <div> <img src="<?php echo URL::media('images/w65-h65-cct-si/' . $comment->user->profile->img->file_path); ?> " alt="" /> </div> <?php } ?> </div> <div class="c-user-comment"> <p class="comment-information"> <strong> <?php if (!$comment->status) { ?> <?php echo HTML::chars($comment->user->show_name());
public function action_delete_answer() { $id = (int) $this->request->param('id', 0); $question = ORM::factory('Question', $id); if (!$question->loaded()) { throw new HTTP_Exception_404(); } $token = Arr::get($_POST, 'token', false); if ($this->request->post() and Security::token() === $token) { $question->values(array('text_answer' => '', 'author' => '', 'date_answer' => NULL, 'status' => 1))->save(); Message::success('Ответ на вопрос удален'); $this->redirect('manage/questions/list/' . ($status = $question->status ? $question->status : '')); } $this->template->set_filename('manage/questions/delete'); $this->template->set('question', $question)->set('status', $question->status)->set('title', 'ответ на вопрос')->set('token', Security::token(true))->set('cancel_url', URL::media('manage/questions/list/' . ($status = $question->status ? $question->status : ''))); }
public function before() { parent::before(); // detecting language, setting it // $this->detect_language(); // $this->set('_language', $this->language); $this->set('device', $this->detect_device()); //var_dump($_COOKIE); // creating and attaching page metadata $this->metadata = new Model_Metadata(); $this->metadata->title(__(Application::instance()->get('title')), false); $this->set('_metadata', $this->metadata); $this->set('_token', Security::token()); // Handles return urls, cropping language out of it (will be appended by url.site at redirect time) // $rr = Request::initial()->uri(); // $rr = trim($rr, '/'); // $rr = explode('/', $rr); // if (in_array($rr[0], Application::instance()->get('language.list'))) { // array_shift($rr); // } // $rr = implode('/', $rr); // $this->set('_return', $rr . Url::query()); View::bind_global('_breadcumbs', $this->breadcumbs); // detecting if user is logged in if (method_exists(Auth::instance(), 'auto_login')) { Auth::instance()->auto_login(); } // if (Auth::instance()->logged_in()) { $id = Auth::instance()->get_user()->id; $user = ORM::factory('user', $id); $input = $user->has('roles', ORM::factory('role', array('name' => 'admin'))); $this->set("admin_mode", $input); } else { $this->set("admin_mode", false); } // $this->user = Auth::instance()->get_user(); $this->set('_user', $this->user); if (Auth::instance()->logged_in() && $this->user->profile->is_visited != 1 && strtolower($this->request->controller()) == 'profile') { $this->redirect('profile/information', 301); } $sliders = ORM::factory('Slider')->where('is_active', '=', 1)->and_where('type', '=', 'slider')->order_by('order', 'asc')->find_all(); $this->set('sliders', $sliders); $banner = ORM::factory('Slider')->where('is_active', '=', 1)->and_where('type', '=', 'banner')->find_all(); $this->set('menu_banner', $banner); $menu = ORM::factory('Page')->where('key', '=', 'menu')->find(); //Для SEO (сортировка) if ($this->request->controller() == 'Auth' or $this->request->controller() == 'Search' or $this->request->controller() == 'Profile') { $this->set('sort', 1); } //end SEO $page_roots = ORM::factory('Page', $menu->id)->children(); $page_main = array(); $children_pages = array(); $children_pages_last = array(); $children_pages_last_last = array(); foreach ($page_roots as $p) { $page_main[$p->key] = array('id' => $p->id, 'name' => $p->name, 'description' => $p->description); $children_pages[$p->key] = $p->children(); //ORM::factory('Page')->where('parent_id','=',$p->id)->find_all();//только первый уровень детей //второй уровень детей. foreach ($children_pages[$p->key] as $ch_p) { if ($ch_p->id == 232 or $ch_p->id == 159) { continue; } $children_pages_last[$ch_p->id] = $ch_p->children(); //третий уровень детей foreach ($children_pages_last[$ch_p->id] as $ch_p_l) { $children_pages_last_last[$ch_p_l->id] = $ch_p_l->children(); } } } $page_halyk_kaharmany = ORM::factory('Page', 319); $this->set('page_halyk_kaharmany', $page_halyk_kaharmany); $this->set('_pages', $page_main)->set('_children_pages', $children_pages)->set('_children_pages_last', $children_pages_last)->set('_children_pages_last_last', $children_pages_last_last)->set('_return_url', URL::media(Request::initial()->uri())); //для вывода сообщения о регистрации восстановления пароля и прочих действий //само сообщение выводится в модальном окне, находится в шаблоне footer if (Message::get()) { $this->set('basic_message', Message::display('/message/basic')); } $nofollowlink = url::media(Request::initial()->uri()); $controller = strtolower(Request::initial()->controller()); $action = strtolower(Request::initial()->action()); if ($controller == 'books' and $action == 'index') { $params = explode('books/', $_SERVER['REQUEST_URI']); if (isset($params[1]) and isset($params[0])) { $params = explode('?', $params[1]); $razdel = $params[0]; } else { $razdel = ''; } if (isset($params[1])) { $params = explode('=', $params[1]); $idbook = $params[1]; } else { $idbook = ''; } $wherestring = 'books_' . $razdel . '_' . $idbook; $page = ORM::factory('Page')->where('key', '=', $wherestring)->find(); $linkid = $page->id; $nofollowlink = URL::site('contents/list/' . $linkid); } if ($controller == 'biography' and $action == 'index') { $params = explode('biography/', $_SERVER['REQUEST_URI']); if (isset($params[1])) { $idbiography = $params[1]; } else { $idbiography = ''; } $wherestring = 'biography' . '_' . $idbiography; $page = ORM::factory('Page')->where('key', 'LIKE', $wherestring . '%')->find(); $linkid = $page->id; $nofollowlink = URL::site('contents/list/' . $linkid); } if ($controller == 'organization' and $action == 'show') { $params = explode('organization/show/', $_SERVER['REQUEST_URI']); if (isset($params[1])) { $idorganization = $params[1]; } else { $idorganization = ''; } $wherestring = 'organization' . '_' . $idorganization; $page = ORM::factory('Page')->where('key', 'LIKE', $wherestring . '%')->find(); $linkid = $page->id; $nofollowlink = URL::site('contents/list/' . $linkid); } if ($controller == 'expert' and $action == 'index') { $nofollowlink = URL::site('contents/list/301'); } //в базе дублируется запись 4 и 301 if ($controller == 'publications' and $action == 'index') { $nofollowlink = URL::site('contents/list/231'); } if ($controller == 'debate' and $action == 'index') { $nofollowlink = URL::site('contents/list/335'); } if ($controller == 'debate' and $action == 'index') { $nofollowlink = URL::site('contents/list/335'); } $this->set('nofollowlink', $nofollowlink); //потому-что SEO. }
public function action_view() { header('Access-Control-Allow-Origin: *'); $id = (int) $this->request->param('id', 0); $debate = ORM::factory('Debate', $id); if (!isset($has_access)) { $has_access = 0; } if (!isset($has_ma_access)) { $has_ma_access = 0; } if (!$debate->loaded() or !$has_ma_access and ($debate->is_public != 1 and !$has_access or $debate->is_closed)) { $this->data['error'] = 'Not access to this debate'; $this->response->body(json_encode($this->data)); return; } $nowdate = date('Y-m-d H:i:s'); if ($debate->author->profile->img->file_path) { $this->data['author_avatar'] = URL::media('/images/w140-h140-ccc-si/' . $debate->author->profile->img->file_path, true); } else { $this->data['author_avatar'] = URL::media('/images/w140-h140-ccc-si/media/images/no_user.jpg', true); } if ($debate->opponent->profile->img->file_path) { $this->data['opponent_avatar'] = URL::media('/images/w140-h140-ccc-si/' . $debate->opponent->profile->img->file_path, true); } else { $this->data['opponent_avatar'] = URL::media('/images/w140-h140-ccc-si/media/images/no_user.jpg', true); } //URL.media('/images/w140-h140-ccc-si/media/images/no_user.jpg') $this->data['id'] = $debate->id; $this->data['title'] = $debate->title; $this->data['preview'] = $debate->description; $this->data['createdDate'] = $debate->date; $this->data['authorId'] = $debate->author->id; $this->data['authorUsername'] = $debate->author->username; $this->data['opponentId'] = $debate->opponent->id; $this->data['opponentUsername'] = $debate->opponent->username; $this->data['endTime'] = $debate->end_time; $this->data['url'] = URL::site('/', true) . $this->language . '/api/smartdebates/view/' . $debate->id; $this->data['commentCount'] = $debate->comments_count; $this->data['nowdate'] = $nowdate; $opinions = ORM::factory('Debate_Opinion')->where('debate_id', '=', $id)->order_by('date', 'ASC')->find_all(); $comments = ORM::factory('Debate_Comment')->where('debate_id', '=', $id); if (!$has_ma_access) { $comments = $comments->and_where('hide', '=', 0); } $comments = $comments->order_by('date', 'ASC'); $comments_count = clone $comments; $comments_count = $comments_count->count_all(); $comments = $comments->find_all(); foreach ($opinions as $k => $v) { $op = array(); $op['moderator_text'] = $v->moderator_text; $op['date'] = $v->date; $op['minus'] = $v->minus; $op['plus'] = $v->plus; $this->data['opinions'][] = $op; } $this->response->body(json_encode($this->data)); }
<a name="comments"></a> <form method="POST"> <div class="mar-top-30"> <div class="border-gray mar-top-10"></div> <div class="block-comment"> <?php if (isset($user->profile->photo->file_path)) { ?> <div class="ava"><img src="<?php echo HTML::chars(URL::media($user->profile->photo->file_path)); ?> " alt=""></div><?php } ?> <div class="content"> <div class="part"></div> <div class="info"> </div> <textarea id="message" name="message" class="comment" placeholder="Оставить комментарий"></textarea> </div> <div class="clearfix"></div> </div> </div> <div class="marg-bot-30 mar-top-10"> <input id="send_message" name="send_message" class="locate-search-button" type="submit" value="<?php echo __('Отправить'); ?> "> </div> </form> <script type="text/javascript">
public function action_variantedit() { $id = $this->request->param('id', 0); $params = explode('-', $id); array_walk($params, 'intval'); $quest_id = $params[0]; if (isset($params[1])) { $variant_id = $params[1]; $variant = ORM::factory('aq', $variant_id); } else { $variant = ORM::factory('aq'); } $quest = ORM::factory('qv', $quest_id); $this->set('variant', $variant); if (!$quest->loaded()) { throw new HTTP_Exception_404(); } $this->set('quest', $quest); $this->set('cancel_url', URL::media('manage/tests/variants/' . $quest_id)); if ($this->request->method() == 'POST') { try { $numbers = ORM::factory('aq')->where('id_qv', '=', $quest_id)->order_by('number', 'DESC')->limit(1)->find(); $number = $numbers->number + 1; $variant->answer = Security::xss_clean(Arr::get($_POST, 'text', '')); $variant->id_qv = $quest_id; $variant->number = $number; $variant->right = (int) Arr::get($_POST, 'right', 0); $variant->published = 1; $variant->save(); $this->redirect('manage/tests/variants/' . $quest_id); } catch (ORM_Validation_Exception $e) { $errors = $e->errors($e->alias()); $this->set('errors', $errors); } } }
public function action_view() { header('Access-Control-Allow-Origin: *'); $id = (int) $this->request->param('id', 0); $id_pub = array('id' => $id, 'published' => 1); //$biography = ORM::factory('Biography', $id); $biography = ORM::factory('Biography', $id_pub); if (!$biography->loaded()) { throw new HTTP_Exception_404(); } if (!$biography->translation()) { throw new HTTP_Exception_404('no_translation'); } $read = $biography->attach->where('key', '=', 'read')->find_all(); if (count($read) > 0) { foreach ($read as $k => $v) { $this->data['read'][] = array('num' => $k, 'title' => $v->title, 'link' => $v->link); } } $references = $biography->attach->where('key', '=', 'references')->find_all(); if (count($references) > 0) { foreach ($references as $k => $v) { $this->data['references'][] = array('num' => $k, 'title' => $v->title, 'link' => $v->link); } } $this->data['item'] = array('id' => $biography->id, 'desc' => $biography->desc, 'text' => $biography->text, 'image' => URL::media('/images/w220-h294-cct-si/' . $biography->picture->file_path, TRUE), 'name' => $biography->name, 'category' => $biography->category->title, 'date_start' => $biography->date_start, 'date_finish' => $biography->date_finish, 'birthplace' => $biography->birthplace, 'deathplace' => $biography->deathplace); $this->response->body(json_encode($this->data)); }
protected function _execute(array $params) { $report_list = array(); $start = microtime(true); //получаем список юзеров имеющих подписки $user_list = ORM::factory('Subscription')->group_by('user_id')->find_all(); foreach ($user_list as $oneuser) { set_time_limit(30); $user_id = $oneuser->user_id; $lang = ORM::factory('Subscription_Setting')->where('user_id', '=', $user_id)->find()->lang; $lang_arr = array('ru', 'en', 'kz', 'RU', 'EN', 'KZ'); if (!in_array($lang, $lang_arr)) { $lang = 'ru'; } $period = ORM::factory('Subscription_Setting')->where('user_id', '=', $user_id)->find()->period; $user = ORM::factory('User', $user_id); $user_profile = ORM::factory('User_Profile', $user_id); $update_time = false; $period_arr = array('1', '2', '3'); if (!in_array($period, $period_arr)) { $update_time = true; } if ($period == '1') { $update_time = true; } if ($period == '2') { if (date('N') == 1) { $update_time = true; } } if ($period == '3') { if (date('j') == 1) { $update_time = true; } } //Как обращаться к пользователю if ($user_profile->first_name != '') { $user_name = $user_profile->first_name . ' ' . $user_profile->last_name; } else { $user_name = $user->username; } //На какое мыло слать $user_email = $user->email; //выставляем язык для рассылки I18n::lang($lang); //получаем список подписок текущего пользователя $sub_list = ORM::factory('Subscription')->where('user_id', '=', $user_id)->find_all(); $links = array(); //ищем самую старую дату из всех подписок $lastdate = '3000-01-01 00:00:00'; foreach ($sub_list as $sub) { if ($lastdate > $sub->date) { $lastdate = $sub->date; } } //если пришло время обновляться if ($update_time == true) { //перебираем список подписок текущего юзера foreach ($sub_list as $sub) { //Получаем запись из Pages, на которую подписан юзер $page = ORM::factory('Page', $sub->category_id); //Смотрим ключ записи, если ключ пустой то ищем имя ключа родителя $key = $page->key; if ($page->key == '' and $page->lvl == '3') { $page_lvl = ORM::factory('Page', $page->parent_id)->as_array(null, 'key'); $key = $page_lvl['key']; } //перебираем все варианты ключей //История казахстана и подразделы if ($key == 'history') { set_time_limit(30); if ($page->lvl == 2) { $allsubhistory = ORM::factory('Page')->where('parent_id', '=', $sub->category_id)->find_all()->as_array(null, 'id'); $allsubhistory = ORM::factory('Page')->where('parent_id', 'in', $allsubhistory)->find_all()->as_array(null, 'id'); $inlog = ORM::factory('Log')->where(DB::expr('lower(model)'), 'LIKE', strtolower('Model_Pages_Content'))->and_where('date', '>', $lastdate)->find_all()->as_array(null, 'content_id'); if (count($inlog) > 0) { if (count(Subtool::findincontents($inlog, $allsubhistory)) > 0) { $links[] = array('link' => URL::media($lang . '/contents/list/' . $sub->category_id), 'title' => $page->name); } } } if ($page->lvl == 3) { $allsubhistory = ORM::factory('Page')->where('parent_id', '=', $sub->category_id)->find_all()->as_array(null, 'id'); $inlog = ORM::factory('Log')->where(DB::expr('lower(model)'), 'LIKE', strtolower('Model_Pages_Content'))->and_where('date', '>', $lastdate)->find_all()->as_array(null, 'content_id'); if (count($inlog) > 0) { if (count(Subtool::findincontents($inlog, $allsubhistory)) > 0) { $links[] = array('link' => URL::media($lang . '/contents/list/' . $sub->category_id), 'title' => $page->name); } } } } //Первый президент и подразделы if ($key == 'president') { set_time_limit(30); if ($page->lvl == 3) { if ($page->key == '') { $find_child = ORM::factory('Page')->where('parent_id', '=', $sub->category_id)->find_all()->as_array(null, 'id'); $inlog = ORM::factory('Log')->where(DB::expr('lower(model)'), 'LIKE', strtolower('Model_Pages_Content'))->and_where('date', '>', $lastdate)->find_all()->as_array(null, 'content_id'); if (count($find_child) > 0) { if (count($inlog) > 0) { if (count(Subtool::findincontents($inlog, $find_child)) > 0) { $links[] = array('link' => URL::media($lang . '/contents/list/' . $sub->category_id), 'title' => $page->name); } } } else { if (count($inlog) > 0) { $find_child[] = $sub->category_id; if (count(Subtool::findincontents($inlog, $find_child)) > 0) { $links[] = array('link' => URL::media($lang . '/contents/list/' . $sub->category_id), 'title' => $page->name); } } } } } if ($page->lvl == 2) { $president = false; $find_child_lvl3 = ORM::factory('Page')->where('parent_id', '=', $sub->category_id)->find_all(); foreach ($find_child_lvl3 as $child_lvl3) { if ($president == false) { if ($child_lvl3->key == '') { $find_child = ORM::factory('Page')->where('parent_id', '=', $sub->category_id)->find_all()->as_array(null, 'id'); $inlog = ORM::factory('Log')->where(DB::expr('lower(model)'), 'LIKE', strtolower('Model_Pages_Content'))->and_where('date', '>', $lastdate)->find_all()->as_array(null, 'content_id'); if (count($find_child) > 0) { if (count($inlog) > 0) { if (count(Subtool::findincontents($inlog, $find_child)) > 0) { $president = true; } } } else { if (count($inlog) > 0) { $find_child[] = $sub->category_id; if (count(Subtool::findincontents($inlog, $find_child)) > 0) { $president = true; } } } } $e = explode('_', $page->key); if ($e[0] == 'books' and isset($e[2])) { $inlog = ORM::factory('Log')->where(DB::expr('lower(model)'), 'LIKE', strtolower('Model_Book'))->and_where('date', '>', $lastdate)->find_all()->as_array(null, 'content_id'); $cats[] = $e[2]; if (count($inlog) > 0) { if (count(Subtool::findinbooks($inlog, $cats)) > 0) { $president = true; } } } } } if ($president == true) { $links[] = array('link' => URL::media($lang . '/contents/list/' . $sub->category_id), 'title' => $page->name); } } } //Экспертный взгляд и подразделы if ($key == 'expert' and $page->key == 'expert' and $page->lvl == 3) { set_time_limit(30); $inlog = ORM::factory('Log')->where(DB::expr('lower(model)'), 'LIKE', strtolower('Model_Expert_Opinion'))->and_where('date', '>', $lastdate)->find_all()->as_array(null, 'content_id'); if (count($inlog) > 0) { $links[] = array('link' => URL::media($lang . '/contents/list/' . $sub->category_id), 'title' => $page->name); } } if ($key == 'expert' and $page->key == '' and $page->lvl == 3) { $inlog = ORM::factory('Log')->where(DB::expr('lower(model)'), 'LIKE', strtolower('Model_Pages_Content'))->and_where('date', '>', $lastdate)->find_all()->as_array(null, 'content_id'); if (count($inlog) > 0) { $allsub[] = $sub->category_id; if (count(Subtool::findincontents($inlog, $allsub)) > 0) { $links[] = array('link' => URL::media($lang . '/contents/list/' . $sub->category_id), 'title' => $page->name); } } } if ($key == 'expert' and $page->lvl == 2) { set_time_limit(30); $expert = false; $find_child_lvl3 = ORM::factory('Page')->where('parent_id', '=', $sub->category_id)->find_all(); foreach ($find_child_lvl3 as $child_lvl3) { if ($expert == false) { if ($child_lvl3->key == 'expert') { $inlog = ORM::factory('Log')->where(DB::expr('lower(model)'), 'LIKE', strtolower('Model_Expert_Opinion'))->and_where('date', '>', $lastdate)->find_all()->as_array(null, 'content_id'); if (count($inlog) > 0) { $expert = true; } } if ($child_lvl3->key == '') { $inlog = ORM::factory('Log')->where(DB::expr('lower(model)'), 'LIKE', strtolower('Model_Pages_Content'))->and_where('date', '>', $lastdate)->find_all()->as_array(null, 'content_id'); if (count($inlog) > 0) { $allsub[] = $child_lvl3->id; if (count(Subtool::findincontents($inlog, $allsub)) > 0) { $expert = true; } } } } } if ($expert == true) { $links[] = array('link' => URL::media($lang . '/contents/list/' . $sub->category_id), 'title' => $page->name); } } //Электронный архив и подразделы if ($key == 'archive' and $page->lvl == 3) { set_time_limit(30); $find_child_lvl3 = ORM::factory('Page')->where('parent_id', '=', $sub->category_id)->find_all(); if (count($find_child_lvl3) > 0) { $archive_lvl3 = false; foreach ($find_child_lvl3 as $child_lvl3) { if ($archive_lvl3 == false) { $allsub = array(); $inlog = ORM::factory('Log')->where(DB::expr('lower(model)'), 'LIKE', strtolower('Model_Pages_Content'))->and_where('date', '>', $lastdate)->find_all()->as_array(null, 'content_id'); if (count($inlog) > 0) { $allsub[] = $child_lvl3->id; if (count(Subtool::findincontents($inlog, $allsub)) > 0) { $archive_lvl3 = true; } } } } if ($archive_lvl3 == true) { $links[] = array('link' => URL::media($lang . '/contents/list/' . $sub->category_id), 'title' => $page->name); } } else { $inlog = ORM::factory('Log')->where(DB::expr('lower(model)'), 'LIKE', strtolower('Model_Pages_Content'))->and_where('date', '>', $lastdate)->find_all()->as_array(null, 'content_id'); if (count($inlog) > 0) { $allsub[] = $sub->category_id; if (count(Subtool::findincontents($inlog, $allsub)) > 0) { $links[] = array('link' => URL::media($lang . '/contents/list/' . $sub->category_id), 'title' => $page->name); } } } } if ($key == 'archive' and $page->lvl == 2) { $find_all_child = ORM::factory('Page')->where('parent_id', '=', $sub->category_id)->find_all(); $archive_lvl3 = false; foreach ($find_all_child as $finded_child) { if ($archive_lvl3 == false) { set_time_limit(30); $find_child_lvl3 = ORM::factory('Page')->where('parent_id', '=', $finded_child->id)->find_all(); $archive_lvl3 = false; if (count($find_child_lvl3) > 0) { foreach ($find_child_lvl3 as $child_lvl3) { $allsub = array(); $inlog = ORM::factory('Log')->where(DB::expr('lower(model)'), 'LIKE', strtolower('Model_Pages_Content'))->and_where('date', '>', $lastdate)->find_all()->as_array(null, 'content_id'); if (count($inlog) > 0) { $allsub[] = $child_lvl3->id; if (count(Subtool::findincontents($inlog, $allsub)) > 0) { $archive_lvl3 = true; } } } } else { $inlog = ORM::factory('Log')->where(DB::expr('lower(model)'), 'LIKE', strtolower('Model_Pages_Content'))->and_where('date', '>', $lastdate)->find_all()->as_array(null, 'content_id'); if (count($inlog) > 0) { $allsub[] = $finded_child->id; if (count(Subtool::findincontents($inlog, $allsub)) > 0) { $archive_lvl3 = true; } } } } } if ($archive_lvl3 == true) { $links[] = array('link' => URL::media($lang . '/contents/list/' . $sub->category_id), 'title' => $page->name); } } //Персоналии if ($key == 'biography' and $page->lvl == 3) { $all_biography_lvl4 = ORM::factory('Page')->where('parent_id', '=', $page->id)->find_all(); foreach ($all_biography_lvl4 as $biography_lvl4) { set_time_limit(30); $newbiography = false; $e = explode('_', $biography_lvl4->key); $inlog = ORM::factory('Log')->where(DB::expr('lower(model)'), 'LIKE', strtolower('Model_Biography'))->and_where('date', '>', $lastdate)->find_all()->as_array(null, 'content_id'); if (count($inlog) > 0) { $biography = ORM::factory('Biography')->where('id', 'in', $inlog)->and_where('category_id', '=', $e[1])->find_all()->as_array(null, 'id'); if (count($biography) > 0) { $newbiography = true; } } } if ($newbiography == true) { $links[] = array('link' => URL::media($lang . '/contents/list/' . $sub->category_id), 'title' => $page->name); } } if ($key == 'personal' and $page->lvl == 2) { $all_biography_lvl3 = ORM::factory('Page')->where('parent_id', '=', $page->id)->find_all()->as_array(null, 'id'); $all_biography_lvl4 = ORM::factory('Page')->where('parent_id', 'in', $all_biography_lvl3)->find_all(); $newbiography = false; foreach ($all_biography_lvl4 as $biography_lvl4) { set_time_limit(30); if ($newbiography == false) { $e = explode('_', $biography_lvl4->key); $inlog = ORM::factory('Log')->where(DB::expr('lower(model)'), 'LIKE', strtolower('Model_Biography'))->and_where('date', '>', $lastdate)->find_all()->as_array(null, 'content_id'); if (count($inlog) > 0) { $biography = ORM::factory('Biography')->where('id', 'in', $inlog)->and_where('category_id', '=', $e[1])->find_all()->as_array(null, 'id'); if (count($biography) > 0) { $newbiography = true; } } } } if ($newbiography == true) { $links[] = array('link' => URL::media($lang . '/contents/list/' . $sub->category_id), 'title' => $page->name); } } //Книги любые $e = explode('_', $page->key); if ($e[0] == 'books' and isset($e[2])) { $inlog = ORM::factory('Log')->where(DB::expr('lower(model)'), 'LIKE', strtolower('Model_Book'))->and_where('date', '>', $lastdate)->find_all()->as_array(null, 'content_id'); $cats[] = $e[2]; if (count($inlog) > 0) { if (count(Subtool::findinbooks($inlog, $cats)) > 0) { $links[] = array('link' => URL::media($lang . '/contents/list/' . $sub->category_id), 'title' => $page->name); } } } // Историческое образование if ($key == 'education' and $page->lvl == 3) { $find_child_lvl3 = ORM::factory('Page')->where('parent_id', '=', $sub->category_id)->find_all(); if (count($find_child_lvl3) > 0) { $education_lvl3 = false; foreach ($find_child_lvl3 as $child_lvl3) { if ($education_lvl3 == false) { $allsub = array(); $inlog = ORM::factory('Log')->where(DB::expr('lower(model)'), 'LIKE', strtolower('Model_Book'))->and_where('date', '>', $lastdate)->find_all()->as_array(null, 'content_id'); if (count($inlog) > 0) { $e = explode('_', $child_lvl3->key); $allsub[] = $e[1]; if (count(Subtool::findinbooks($inlog, $allsub)) > 0) { $education_lvl3 = true; } } } } if ($education_lvl3 == true) { $links[] = array('link' => URL::media($lang . '/contents/list/' . $sub->category_id), 'title' => $page->name); } } } if ($key == 'education' and $page->lvl == 2) { $find_child_lvl2 = ORM::factory('Page')->where('parent_id', '=', $sub->category_id)->find_all()->as_array(null, 'id'); $neweducation = false; foreach ($find_child_lvl2 as $child_lvl2) { set_time_limit(30); if ($neweducation == false) { $find_child_lvl3 = ORM::factory('Page')->where('parent_id', '=', $child_lvl2)->find_all(); if (count($find_child_lvl3) > 0) { foreach ($find_child_lvl3 as $child_lvl3) { $allsub = array(); $inlog = ORM::factory('Log')->where(DB::expr('lower(model)'), 'LIKE', strtolower('Model_Book'))->and_where('date', '>', $lastdate)->find_all()->as_array(null, 'content_id'); if (count($inlog) > 0) { $e = explode('_', $child_lvl3->key); $allsub[] = $e[1]; if (count(Subtool::findinbooks($inlog, $allsub)) > 0) { $neweducation = true; } } } } else { $booksfore = ORM::factory('Page', $child_lvl2); //опасный момент $e = explode('_', $booksfore->key); if ($e[0] == 'books' and isset($e[2])) { $inlog = ORM::factory('Log')->where(DB::expr('lower(model)'), 'LIKE', strtolower('Model_Book'))->and_where('date', '>', $lastdate)->find_all()->as_array(null, 'content_id'); $cats[] = $e[2]; if (count($inlog) > 0) { if (count(Subtool::findinbooks($inlog, $cats)) > 0) { $neweducation = true; } } } } } } if ($neweducation == true) { $links[] = array('link' => URL::media($lang . '/contents/list/' . $sub->category_id), 'title' => $page->name); } } //Организации образования и науки if ($key == 'institute' and $page->lvl == 3) { set_time_limit(30); $find_child_lvl4 = ORM::factory('Page')->where('parent_id', '=', $page->id)->find_all(); if (count($find_child_lvl4->as_array(null, 'id')) > 0) { foreach ($find_child_lvl4 as $child_lvl4) { $find_child_lvl5 = ORM::factory('Page')->where('parent_id', '=', $child_lvl4->id)->find_all()->as_array(null, 'id'); if (count($find_child_lvl5) > 0) { $child_lvl5[] = $find_child_lvl5[0]; } } if (count($child_lvl5) > 0) { $find_organization = ORM::factory('Organization')->where('page_id', 'in', $child_lvl5)->and_where('date', '>', $lastdate)->find_all()->as_array(null, 'id'); if (count($find_organization) > 0) { $links[] = array('link' => URL::media($lang . '/contents/list/' . $sub->category_id), 'title' => $page->name); } } else { $child_lvl4_ids = $find_child_lvl4->as_array(null, 'id'); $find_organization = ORM::factory('Organization')->where('page_id', 'in', $child_lvl4_ids)->and_where('date', '>', $lastdate)->find_all()->as_array(null, 'id'); if (count($find_organization) > 0) { $links[] = array('link' => URL::media($lang . '/contents/list/' . $sub->category_id), 'title' => $page->name); } } } else { $inlog = ORM::factory('Log')->where(DB::expr('lower(model)'), 'LIKE', strtolower('Model_Pages_Content'))->and_where('date', '>', $lastdate)->find_all()->as_array(null, 'content_id'); if (count($inlog) > 0) { $allsubs[] = $page->id; if (count(Subtool::findincontents($inlog, $allsubs)) > 0) { $links[] = array('link' => URL::media($lang . '/contents/list/' . $sub->category_id), 'title' => $page->name); } } } } if ($key == 'institute' and $page->lvl == 2) { $find_child_lvl3 = ORM::factory('Page')->where('parent_id', '=', $page->id)->find_all(); $newinstitute = false; foreach ($find_child_lvl3 as $child_lvl3) { set_time_limit(30); if ($newinstitute == false) { $find_child_lvl4 = ORM::factory('Page')->where('parent_id', '=', $child_lvl3->id)->find_all(); if (count($find_child_lvl4->as_array(null, 'id')) > 0) { foreach ($find_child_lvl4 as $child_lvl4) { set_time_limit(30); $find_child_lvl5 = ORM::factory('Page')->where('parent_id', '=', $child_lvl4->id)->find_all()->as_array(null, 'id'); if (count($find_child_lvl5) > 0) { $child_lvl5[] = $find_child_lvl5[0]; } } if (count($child_lvl5) > 0) { $find_organization = ORM::factory('Organization')->where('page_id', 'in', $child_lvl5)->and_where('date', '>', $lastdate)->find_all()->as_array(null, 'id'); if (count($find_organization) > 0) { $newinstitute = true; } } else { $child_lvl4_ids = $find_child_lvl4->as_array(null, 'id'); $find_organization = ORM::factory('Organization')->where('page_id', 'in', $child_lvl4_ids)->and_where('date', '>', $lastdate)->find_all()->as_array(null, 'id'); if (count($find_organization) > 0) { $newinstitute = true; } } } else { $inlog = ORM::factory('Log')->where(DB::expr('lower(model)'), 'LIKE', strtolower('Model_Pages_Content'))->and_where('date', '>', $lastdate)->find_all()->as_array(null, 'content_id'); if (count($inlog) > 0) { $allsubs[] = $page->id; if (count(Subtool::findincontents($inlog, $allsubs)) > 0) { $newinstitute = true; } } } } } if ($newinstitute == true) { $links[] = array('link' => URL::media($lang . '/contents/list/' . $sub->category_id), 'title' => $page->name); } } if ($key == 'people' and $page->lvl == 3) { $find_child_lvl4 = ORM::factory('Page')->where('parent_id', '=', $page->id)->find_all()->as_array(null, 'id'); if (count($find_child_lvl4) > 0) { $inlog = ORM::factory('Log')->where(DB::expr('lower(model)'), 'LIKE', strtolower('Model_Pages_Content'))->and_where('date', '>', $lastdate)->find_all()->as_array(null, 'content_id'); if (count($inlog) > 0) { $allsubs = $find_child_lvl4; if (count(Subtool::findincontents($inlog, $allsubs)) > 0) { $links[] = array('link' => URL::media($lang . '/contents/list/' . $sub->category_id), 'title' => $page->name); } } } else { $inlog = ORM::factory('Log')->where(DB::expr('lower(model)'), 'LIKE', strtolower('Model_Pages_Content'))->and_where('date', '>', $lastdate)->find_all()->as_array(null, 'content_id'); if (count($inlog) > 0) { $allsubs[] = $page->id; if (count(Subtool::findincontents($inlog, $allsubs)) > 0) { $links[] = array('link' => URL::media($lang . '/contents/list/' . $sub->category_id), 'title' => $page->name); } } } } if ($key == 'people' and $page->lvl == 2) { $find_child_lvl3 = ORM::factory('Page')->where('parent_id', '=', $page->id)->find_all(); $newpeople = false; foreach ($find_child_lvl3 as $child_lvl3) { set_time_limit(30); if ($newpeople == false) { $find_child_lvl4 = ORM::factory('Page')->where('parent_id', '=', $child_lvl3->id)->find_all()->as_array(null, 'id'); if (count($find_child_lvl4) > 0) { $inlog = ORM::factory('Log')->where(DB::expr('lower(model)'), 'LIKE', strtolower('Model_Pages_Content'))->and_where('date', '>', $lastdate)->find_all()->as_array(null, 'content_id'); if (count($inlog) > 0) { $allsubs = $find_child_lvl4; if (count(Subtool::findincontents($inlog, $allsubs)) > 0) { $newpeople = true; } } } else { $inlog = ORM::factory('Log')->where(DB::expr('lower(model)'), 'LIKE', strtolower('Model_Pages_Content'))->and_where('date', '>', $lastdate)->find_all()->as_array(null, 'content_id'); if (count($inlog) > 0) { $allsubs[] = $child_lvl3->id; if (count(Subtool::findincontents($inlog, $allsubs)) > 0) { $newpeople = true; } } } } } if ($newpeople == true) { $links[] = array('link' => URL::media($lang . '/contents/list/' . $sub->category_id), 'title' => $page->name); } } //публикации if ($key == 'publications' and $page->lvl == 2) { $inlog = ORM::factory('Log')->where(DB::expr('lower(model)'), 'LIKE', strtolower('Model_Publication'))->and_where('language', '=', $lang)->and_where('date', '>', $lastdate)->find_all()->as_array(null, 'id'); if (count($inlog) > 0) { $links[] = array('link' => URL::media($lang . '/contents/list/' . $sub->category_id), 'title' => $page->name); } } //Электронный журнал "e-history.kz" if ($key == 'metodology' or $key == 'crossstudy' or $key == 'metodicheskie') { $find_childs_lvl4 = ORM::factory('Page')->where('parent_id', '=', $page->id)->find_all(); $finded_lvl3 = false; foreach ($find_childs_lvl4 as $childs_lvl4) { set_time_limit(30); if ($finded_lvl3 == false) { set_time_limit(30); $find_childs_lvl5 = ORM::factory('Page')->where('parent_id', '=', $childs_lvl4->id)->find_all()->as_array(null, 'id'); if (count($find_childs_lvl5) > 0) { $inlog = ORM::factory('Log')->where(DB::expr('lower(model)'), 'LIKE', strtolower('Model_Pages_Content'))->and_where('date', '>', $lastdate)->find_all()->as_array(null, 'content_id'); if (count($inlog) > 0) { $allsubs = $find_childs_lvl5; if (count(Subtool::findincontents($inlog, $allsubs)) > 0) { $finded_lvl3 = true; } } } else { $inlog = ORM::factory('Log')->where(DB::expr('lower(model)'), 'LIKE', strtolower('Model_Pages_Content'))->and_where('date', '>', $lastdate)->find_all()->as_array(null, 'content_id'); if (count($inlog) > 0) { $allsubs[] = $childs_lvl4->id; if (count(Subtool::findincontents($inlog, $allsubs)) > 0) { $finded_lvl3 = true; } } } } } if ($finded_lvl3 == true) { $links[] = array('link' => URL::media($lang . '/contents/list/' . $sub->category_id), 'title' => $page->name); } } if ($key == 'journal_ehistory') { $find_childs_lvl3 = ORM::factory('Page')->where('parent_id', '=', $page->id)->find_all(); $newehistory = false; foreach ($find_childs_lvl3 as $childs_lvl3) { set_time_limit(30); if ($newehistory == false) { $find_childs_lvl4 = ORM::factory('Page')->where('parent_id', '=', $childs_lvl3->id)->find_all(); $finded_lvl3 = false; foreach ($find_childs_lvl4 as $childs_lvl4) { if ($finded_lvl3 == false) { set_time_limit(30); $find_childs_lvl5 = ORM::factory('Page')->where('parent_id', '=', $childs_lvl4->id)->find_all()->as_array(null, 'id'); if (count($find_childs_lvl5) > 0) { $inlog = ORM::factory('Log')->where(DB::expr('lower(model)'), 'LIKE', strtolower('Model_Pages_Content'))->and_where('date', '>', $lastdate)->find_all()->as_array(null, 'content_id'); if (count($inlog) > 0) { $allsubs = $find_childs_lvl5; if (count(Subtool::findincontents($inlog, $allsubs)) > 0) { $finded_lvl3 = true; $newehistory = true; } } } else { $inlog = ORM::factory('Log')->where(DB::expr('lower(model)'), 'LIKE', strtolower('Model_Pages_Content'))->and_where('date', '>', $lastdate)->find_all()->as_array(null, 'content_id'); if (count($inlog) > 0) { $allsubs[] = $childs_lvl4->id; if (count(Subtool::findincontents($inlog, $allsubs)) > 0) { $finded_lvl3 = true; $newehistory = true; } } } } } } } if ($newehistory == true) { $links[] = array('link' => URL::media($lang . '/contents/list/' . $sub->category_id), 'title' => $page->name); } } //блок интерактив if ($key == 'debate') { $debates = ORM::factory('Debate')->where('date', '>', $lastdate)->find_all()->as_array(null, 'id'); if (count($debates) > 0) { $links[] = array('link' => URL::media($lang . '/contents/list/' . $sub->category_id), 'title' => $page->name); } } if ($key == 'briefings') { $briefings = ORM::factory('Briefing')->where('date', '>', $lastdate)->find_all()->as_array(null, 'id'); if (count($briefings) > 0) { $links[] = array('link' => URL::media($lang . '/contents/list/' . $sub->category_id), 'title' => $page->name); } } if ($key == 'scorm') { $educations = ORM::factory('Education')->where('date', '>', $lastdate)->find_all()->as_array(null, 'id'); if (count($educations) > 0) { $links[] = array('link' => URL::media($lang . '/contents/list/' . $sub->category_id), 'title' => $page->name); } } if ($key == 'ent') { $ent = ORM::factory('Ent')->where('date', '>', $lastdate)->find_all()->as_array(null, 'id'); if (count($ent) > 0) { $links[] = array('link' => URL::media($lang . '/contents/list/' . $sub->category_id), 'title' => $page->name); } } if ($key == 'interactive') { $interactives = ORM::factory('Page')->where('parent_id', '=', $page->id)->find_all(); $newinteractive = false; foreach ($interactives as $child) { set_time_limit(30); if ($newinteractive == false) { $child_key = $child->key; if ($child_key == 'debate') { $debates = ORM::factory('Debate')->where('date', '>', $lastdate)->find_all()->as_array(null, 'id'); if (count($debates) > 0) { $newinteractive = true; } } if ($child_key == 'briefings') { $briefings = ORM::factory('Briefing')->where('date', '>', $lastdate)->find_all()->as_array(null, 'id'); if (count($briefings) > 0) { $newinteractive = true; } } if ($child_key == 'scorm') { $educations = ORM::factory('Education')->where('date', '>', $lastdate)->find_all()->as_array(null, 'id'); if (count($educations) > 0) { $newinteractive = true; } } if ($child_key == 'ent') { $ent = ORM::factory('Ent')->where('date', '>', $lastdate)->find_all()->as_array(null, 'id'); if (count($ent) > 0) { $newinteractive = true; } } } } if ($newinteractive == true) { $links[] = array('link' => URL::media($lang . '/contents/list/' . $sub->category_id), 'title' => $page->name); } } if ($key == 'photosets') { $photosets = ORM::factory('Photoset')->where('date', '>', $lastdate)->find_all()->as_array(null, 'id'); if (count($photosets) > 0) { $links[] = array('link' => URL::media($lang . '/contents/list/' . $sub->category_id), 'title' => $page->name); } } if ($key == 'video') { $videos = ORM::factory('Video')->where('date', '>', $lastdate)->find_all()->as_array(null, 'id'); if (count($videos) > 0) { $links[] = array('link' => URL::media($lang . '/contents/list/' . $sub->category_id), 'title' => $page->name); } } if ($key == 'audio') { $inlog = ORM::factory('Log')->where(DB::expr('lower(model)'), 'LIKE', strtolower('Model_Audio'))->and_where('date', '>', $lastdate)->find_all()->as_array(null, 'content_id'); if (count($inlog) > 0) { $audios = ORM::factory('Audio')->where('id', 'in', $inlog)->find_all()->as_array(null, 'id'); if (count($audios) > 0) { $links[] = array('link' => URL::media($lang . '/contents/list/' . $sub->category_id), 'title' => $page->name); } } } if ($key == 'infographs') { $infographs = ORM::factory('Infograph')->where('date', '>', $lastdate)->find_all()->as_array(null, 'id'); if (count($infographs) > 0) { $links[] = array('link' => URL::media($lang . '/contents/list/' . $sub->category_id), 'title' => $page->name); } } if ($key == 'library') { $inlog = ORM::factory('Log')->where(DB::expr('lower(model)'), 'LIKE', strtolower('Model_Book'))->and_where('date', '>', $lastdate)->find_all()->as_array(null, 'content_id'); if (count($inlog) > 0) { $books = ORM::factory('Book')->where('id', 'in', $inlog)->find_all()->as_array(null, 'id'); if (count($books) > 0) { $links[] = array('link' => URL::media($lang . '/contents/list/' . $sub->category_id), 'title' => $page->name); } } } if ($key == 'multimedia') { $find_child_lvl3 = ORM::factory('Page')->where('parent_id', '=', $page->id)->find_all(); $newmultimedia = false; foreach ($find_child_lvl3 as $child_lvl3) { set_time_limit(30); if ($newmultimedia == false) { $child_key = $child_lvl3->key; if ($child_key == 'photosets') { $photosets = ORM::factory('Photoset')->where('date', '>', $lastdate)->find_all()->as_array(null, 'id'); if (count($photosets) > 0) { $newmultimedia = true; } } if ($child_key == 'video') { $videos = ORM::factory('Video')->where('date', '>', $lastdate)->find_all()->as_array(null, 'id'); if (count($videos) > 0) { $newmultimedia = true; } } if ($child_key == 'audio') { $inlog = ORM::factory('Log')->where(DB::expr('lower(model)'), 'LIKE', strtolower('Model_Audio'))->and_where('date', '>', $lastdate)->find_all()->as_array(null, 'content_id'); if (count($inlog) > 0) { $audios = ORM::factory('Audio')->where('id', 'in', $inlog)->find_all()->as_array(null, 'id'); if (count($audios) > 0) { $newmultimedia = true; } } } if ($child_key == 'infographs') { $infographs = ORM::factory('Infograph')->where('date', '>', $lastdate)->find_all()->as_array(null, 'id'); if (count($infographs) > 0) { $newmultimedia = true; } } if ($child_key == 'library') { $inlog = ORM::factory('Log')->where(DB::expr('lower(model)'), 'LIKE', strtolower('Model_Book'))->and_where('date', '>', $lastdate)->find_all()->as_array(null, 'content_id'); if (count($inlog) > 0) { $books = ORM::factory('Book')->where('id', 'in', $inlog)->find_all()->as_array(null, 'id'); if (count($books) > 0) { $newmultimedia = true; } } } } } if ($newmultimedia == true) { $links[] = array('link' => URL::media($lang . '/contents/list/' . $sub->category_id), 'title' => $page->name); } } $subupdate = ORM::factory('Subscription', $sub->id); $subupdate->date = date("Y-m-d H:i:s"); $subupdate->save(); } $time = microtime(true) - $start; if (count($links) != 0) { $report_list[] = array('time' => $time, 'user_id' => $user_id); Email::connect(); if ($lang == 'ru' or $lang == 'RU') { Email::View('distribution_ru'); } if ($lang == 'kz' or $lang == 'KZ') { Email::View('distribution_kz'); } if ($lang == 'en' or $lang == 'EN') { Email::View('distribution_en'); } Email::set(array('user' => $user_name, 'period1' => $lastdate, 'period2' => date("Y-m-d H:i:s"), 'unsublink' => Subtool::media('/' . $lang . '/profile/subscription'), 'links' => $links)); set_time_limit(60); Email::send($user_email, array('*****@*****.**', 'e-history.kz'), I18n::get('Обновления на портале Истории Казахстана e-history.kz'), '', true); } } } set_time_limit(60); if (count($report_list) != 0) { Email::connect(); Email::View('successsub'); Email::set(array('message' => 'Все рассылки успешно разослались', 'list' => $report_list)); Email::send('*****@*****.**', array('*****@*****.**', 'e-history.kz'), "Рассылки на истории", '', true); } else { Email::connect(); Email::View('default'); Email::set(array('message' => 'Сегодня никому ничего не отправлено')); Email::send('*****@*****.**', array('*****@*****.**', 'e-history.kz'), "Рассылки на истории", '', true); } }
public function action_view() { header('Access-Control-Allow-Origin: *'); $id = (int) $this->request->param('id', 0); $content = ORM::factory('Pages_Content')->where('id', '=', $id)->and_where('published', '=', 1)->find(); if (!$content->loaded()) { $this->data['error'] = '404 Not Found'; $this->response->body(json_encode($this->data)); return; } if (!$content->translation()) { $this->data['error'] = '404 No translation'; $this->response->body(json_encode($this->data)); return; } $page = ORM::factory('Page', $content->page_id); $path = $page->parents(); $this->data['page'] = array('id' => $page->id, 'name' => $page->name, 'description' => $page->description); $c = $content; $cont = array('id' => $c->id, 'page_id' => $c->page_id, 'type' => $c->type, 'title' => $c->title, 'description' => $c->description, 'text' => $c->text); if ($c->picture->file_path) { $cont['image'] = URL::media('images/w300-h225-ccc-si/' . $c->picture->file_path); } else { $cont['image'] = URL::media('images/w300-h225-ccc-si/media/images/nocover.jpg'); } $this->data['contents'][] = $cont; $this->response->body(json_encode($this->data)); }
public function action_index() { $explode = explode('_', strtolower($this->entryType)); if ($explode[0] == 'list') { $this->entryType = $explode[0]; } switch ($this->entryType) { case 'publications': $publication = ORM::factory('Publication')->where('id', '=', $this->entryId)->and_where('title_' . $this->language, '<>', '')->and_where('published', '=', 1)->find(); if (!$publication->loaded()) { $this->data['error'] = 'Publication not found'; } else { $comments = ORM::factory('Comment')->where('object_id', '=', $this->entryId)->and_where('status', '=', '1')->and_where('table', '=', 'publications')->find_all(); $coverUrl = ''; if (!empty($publication->picture->file_path)) { $coverUrl = 'http://' . $_SERVER['SERVER_NAME'] . '/' . $publication->picture->file_path; } $this->data['id'] = $publication->id; $this->data['title'] = $publication->title; $this->data['createdDate'] = $publication->date; $this->data['coverUrl'] = $coverUrl; $this->data['text'] = str_replace('/media/upload', URL::media('/media/upload', true), $publication->text); $this->data['commentCount'] = $comments->count(); $this->data['url'] = URL::site('/', true) . $this->language . '/publications/view/' . $publication->id; } break; case 'expert_opinion': $opinion = ORM::factory('Expert_Opinion')->where('id', '=', $this->entryId)->and_where('title_' . $this->language, '<>', '')->find(); if (!$opinion->loaded()) { $this->data['error'] = 'Expert opinion not found'; } else { $comments = ORM::factory('Expert_Comment')->where('opinion_id', '=', $this->entryId)->and_where('moderator_decision', '=', '1')->find_all(); $this->data['id'] = $opinion->id; $this->data['title'] = $opinion->expert->name . ': ' . $opinion->title; $this->data['createdDate'] = $opinion->date; $this->data['text'] = str_replace('/media/upload', URL::media('/media/upload', true), $opinion->text); $this->data['commentCount'] = $comments->count(); $this->data['url'] = URL::site('/', true) . $this->language . '/expert/view/' . $opinion->id; } break; case 'list': $id = $this->entryId; $page_content = ORM::factory('Pages_Content')->where('id', '=', $id)->and_where('published', '=', 1)->and_where('title_' . $this->language, '<>', '')->find(); $comments = ORM::factory('Comment')->where('object_id', '=', $id)->and_where('status', '=', '1')->find_all(); if (!$page_content->loaded()) { $this->data['error'] = 'Content not found'; } else { $coverUrl = ''; if (!empty($page_content->picture->file_path)) { $coverUrl = 'http://' . $_SERVER['SERVER_NAME'] . '/' . $page_content->picture->file_path; } $this->data['id'] = $page_content->id; $this->data['title'] = $page_content->title; $this->data['createdDate'] = $page_content->date; $this->data['coverUrl'] = $coverUrl; $this->data['text'] = str_replace('/media/upload', URL::media('/media/upload', true), $page_content->text); $this->data['commentCount'] = $comments->count(); $this->data['url'] = URL::site('/', true) . $this->language . '/contents/view/' . $id; } break; case 'debate': $status = false; $nowdate = date('Y-m-d H:i:s'); $debate = ORM::factory('Debate', $this->entryId); if (!$debate->loaded() or $debate->is_closed) { $this->data['error'] = 'Unknown Exception'; } else { if ($debate->is_closed == 0) { if (Date::translate($debate->end_time, 'U') < Date::translate($nowdate, 'U') and Date::translate($debate->end_time, 'U') != 0) { $status = false; } else { $status = true; } } $this->data['id'] = $debate->id; $this->data['title'] = $debate->title; $this->data['preview'] = $debate->description; $this->data['createdDate'] = $debate->date; $this->data['authorId'] = $debate->author->id; $this->data['authorUsername'] = $debate->author->username; $this->data['opponentId'] = $debate->opponent->id; $this->data['opponentUsername'] = $debate->opponent->username; $this->data['isActive'] = $status; $this->data['endTime'] = $debate->end_time; $this->data['url'] = URL::site('/', true) . $this->language . '/debate/view/' . $debate->id; $this->data['commentCount'] = $debate->comments_count; //меняем флаг уведомлений(считаем просмотренными) if (!empty($this->auth_token) and $this->api->token_expires($this->auth_token)) { $user = ORM::factory('Api_Token')->where('token', '=', $this->auth_token)->find(); if ($user->loaded()) { $notices = ORM::factory('Api_Notice')->where('user_id', '=', $user->user_id)->and_where('object_id', '=', $this->entryId)->and_where('flag', '=', 0)->find_all(); if ($notices->count() > 0) { foreach ($notices as $notice) { $notice->flag = 1; $notice->update(); } } } } } break; case 'today': $coverUrl = ''; $list = ORM::factory('Calendar')->where('id', '=', $this->entryId)->and_where('title_' . $this->language, '<>', '')->and_where('text_' . $this->language, '<>', '')->find(); if ($list->loaded()) { $month = $list->month; $day = $list->day; if ($list->month < 10) { $month = '0' . $list->month; } if ($list->day < 10) { $day = '0' . $list->day; } if (!empty($list->picture->file_path)) { $coverUrl = 'http://' . $_SERVER['SERVER_NAME'] . '/' . $list->picture->file_path; } $this->data['id'] = $list->id; $this->data['dateHistory'] = trim($list->year) . '-' . trim($list->month) . '-' . trim($list->day); $this->data['title'] = $list->title; $this->data['preview'] = $list->desc; $this->data['text'] = str_replace('/media/upload', URL::media('/media/upload', true), $list->text); $this->data['coverUrl'] = $coverUrl; $this->data['url'] = URL::site('/', true) . $this->language . '/calendar/event/' . $month . '/' . $day; } break; } $this->response->body(json_encode($this->data)); }