コード例 #1
0
ファイル: PostProperty.php プロジェクト: vcorobceanu/WebAPL
 public static function postWithProperty($property, $with_url = false)
 {
     $row = PostProperty::prepare()->where(PostLang::getField('enabled'), 1)->where(PostProperty::getField('key'), $property)->remember(SettingsModel::one('cachelife'))->first();
     if ($row && $with_url) {
         $row['url'] = Post::getFullURI($row->id);
     }
     return $row ? $row : false;
 }
コード例 #2
0
ファイル: jobrequest.php プロジェクト: vcorobceanu/WebAPL
 public function getlist()
 {
     \User::onlyHas('jobrequest-view');
     $jqgrid = new jQgrid(\JobRequestModel::getTableName());
     echo $jqgrid->populate(function ($start, $limit) {
         return \JobRequestModel::join(PostLang::getTableName(), \PostLang::getField('post_id'), '=', \JobRequestModel::getField('post_id'))->where(\PostLang::getField('lang_id'), \WebAPL\Language::getId())->select(\JobRequestModel::getField('id'), \PostLang::getField('title'), \JobRequestModel::getField('name'), \JobRequestModel::getField('cv_path'), \JobRequestModel::getField('date_created'))->skip($start)->take($limit)->orderBy(\JobRequestModel::getField('date_created'), 'desc')->get();
     });
 }
コード例 #3
0
ファイル: PostLang.php プロジェクト: vcorobceanu/WebAPL
 public static function uniqURI($id, $title = '')
 {
     $uri = urigen($title);
     $clear_count = PostLang::whereRaw("uri like ? AND id <> ?", array($uri, $id))->count();
     if ($clear_count == 0) {
         return $uri;
     }
     return ($uri ? $uri . '-' : '') . $id;
 }
コード例 #4
0
 public function soclist()
 {
     \User::onlyHas('socialc-view');
     $pages = \Post::join(\PostLang::getTableName(), \PostLang::getField('post_id'), '=', \Post::getField('id'))->where(\PostLang::getField('lang_id'), \WebAPL\Language::getId())->where(\Post::getField('taxonomy_id'), 1)->orderBy(\PostLang::getField('title'), 'desc')->get();
     $page_list = array();
     $page_json = array();
     foreach ($pages as $page) {
         $page_list[] = "{$page->post_id}:{$page->title}";
         $page_json[$page->post_id] = $page->title;
     }
     $data['pagesString'] = implode(';', $page_list);
     $data['pagesJson'] = json_encode($page_json);
     $this->layout->content = Template::moduleView($this->module_name, 'views.list', $data);
     return $this->layout;
 }
コード例 #5
0
 public function topost($id)
 {
     $post = Post::find($id);
     if ($post) {
         switch ($post->taxonomy_id) {
             case 1:
                 $uri = Post::getFullURI($post->id, true);
                 return Redirect::to($uri);
             case 2:
                 $feed = FeedPost::where('post_id', $post->id)->first();
                 if ($feed) {
                     $page = Post::where('feed_id', $feed->feed_id)->first();
                     if ($page) {
                         $viewmods = WebAPL\Template::getViewMethodList('page');
                         $uri = Post::getFullURI($page->id, true);
                         if (isset($viewmods[$page->view_mod]['support_item']) && $viewmods[$page->view_mod]['support_item']) {
                             $plang = PostLang::where('post_id', $post->id)->where('lang_id', \WebAPL\Language::getId())->first();
                             if ($plang) {
                                 $url = $uri . "?item=" . $plang->uri;
                             } else {
                                 $url = $uri;
                             }
                         } else {
                             $url = $uri;
                         }
                         return Redirect::to($url);
                     } else {
                         throw new Exception("Not found page, post #{$id}");
                     }
                 } else {
                     throw new Exception("Not found feed, post #{$id}");
                 }
                 break;
             default:
                 throw new Exception("Not found taxonomy, post #{$id}");
                 break;
         }
     } else {
         throw new Exception("Post not found #{$id}");
     }
 }
コード例 #6
0
ファイル: Post.php プロジェクト: vcorobceanu/WebAPL
 public static function removeLang($lang_id)
 {
     PostLang::where('lang_id', $lang_id)->delete();
 }
コード例 #7
0
ファイル: FeedController.php プロジェクト: vcorobceanu/WebAPL
 public function postDelete()
 {
     $id = Input::get('id');
     $post = Post::find($id);
     if ($post->is_trash == 1) {
         PostLang::where('post_id', $id)->delete();
         FeedFieldValue::where('post_id', $id)->delete();
         Files::dropMultiple('post_cover', $id);
         Files::dropMultiple('doc_post_lang', $id);
         Files::dropMultiple('doc_post', $id);
         $post->delete();
         Log::warning("Drop post #{$id}");
     }
     return Redirect::to('feed');
 }
コード例 #8
0
ファイル: HomeController.php プロジェクト: vcorobceanu/WebAPL
 public function getEmpty()
 {
     return ['no no no'];
     // BAD EMPTY FUNCTION
     // delete posts
     $posts = Post::where('taxonomy_id', 2)->get();
     foreach ($posts as $post) {
         PostLang::where('post_id', $post->id)->delete();
         Files::dropMultiple('post_cover', $post->id);
         Files::dropMultiple('doc_post', $post->id);
         Files::dropMultiple('doc_post_lang', $post->id);
         $post->delete();
     }
     DB::table('apl_feed_field_value')->truncate();
     DB::table('apl_feed_post')->truncate();
     DB::table(PostLang::getTableName())->update(array('text' => ''));
     // delete acte
     $actes = DB::table('apl_acte')->get();
     foreach ($actes as $act) {
         Files::dropMultiple('actelocale', $act->id);
     }
     DB::table('apl_acte')->truncate();
     // calendar
     DB::table('apl_calendar_group')->truncate();
     DB::table('apl_calendar_item')->truncate();
     DB::table('apl_calendar_item_lang')->truncate();
     DB::table('apl_calendar_post')->truncate();
     // complaint
     DB::table('apl_complaint')->truncate();
     // firechat
     DB::table('apl_firechat')->truncate();
     // gallery
     $galls = DB::table('apl_gallery')->get();
     foreach ($galls as $gal) {
         Files::dropMultiple('gallery', $gal->id);
     }
     DB::table('apl_gallery')->truncate();
     DB::table('apl_gallery_post')->truncate();
     // reqs
     $reqs = DB::table('apl_job_requests')->get();
     foreach ($reqs as $req) {
         if ($req->cv_path && file_exists($_SERVER['DOCUMENT_ROOT'] . '/' . $req->cv_path)) {
             @unlink($_SERVER['DOCUMENT_ROOT'] . '/' . $req->cv_path);
         }
     }
     DB::table('apl_job_requests')->truncate();
     // logs
     DB::table('apl_logs')->truncate();
     // newsletter
     DB::table('apl_newsletter')->truncate();
     // persons
     $persons = DB::table('apl_person')->get();
     foreach ($persons as $person) {
         Files::dropMultiple('person', $person->id);
         Files::dropMultiple('person_chat', $person->id);
     }
     DB::table('apl_person_audience')->truncate();
     DB::table('apl_person')->truncate();
     DB::table('apl_person_lang')->truncate();
     DB::table('apl_person_rel')->truncate();
     // polls
     DB::table('apl_poll')->truncate();
     DB::table('apl_poll_answer')->truncate();
     DB::table('apl_poll_answer_lang')->truncate();
     DB::table('apl_poll_question')->truncate();
     DB::table('apl_poll_votes')->truncate();
     // pagefiles
     $pagefiles = DB::table('apl_file')->where('module_name', 'article_cover')->get();
     foreach ($pagefiles as $pf) {
         Files::drop($pf->id);
     }
     DB::table('apl_file')->where('module_name', 'page')->delete();
     // othfiles
     $files = DB::table('apl_file')->where('module_name', 'article_cover')->get();
     foreach ($files as $file) {
         Files::drop($file->id);
     }
     DB::table('apl_file')->where('module_name', 'article_cover')->delete();
     $files = DB::table('apl_file')->where('module_name', 'doc_post_lang')->get();
     foreach ($files as $file) {
         Files::drop($file->id);
     }
     DB::table('apl_file')->where('module_name', 'doc_post_lang')->delete();
     $files = DB::table('apl_file')->where('module_name', 'test')->get();
     foreach ($files as $file) {
         Files::drop($file->id);
     }
     DB::table('apl_file')->where('module_name', 'test')->delete();
     $files = DB::table('apl_file')->where('module_name', 'person')->get();
     foreach ($files as $file) {
         Files::drop($file->id);
     }
     DB::table('apl_file')->where('module_name', 'person')->delete();
     $files = DB::table('apl_file')->where('module_name', 'rewwe')->get();
     foreach ($files as $file) {
         Files::drop($file->id);
     }
     DB::table('apl_file')->where('module_name', 'rewwe')->delete();
     return ['executed'];
 }
コード例 #9
0
ファイル: PageController.php プロジェクト: vcorobceanu/WebAPL
 public function getImport()
 {
     $xsdstring = $_SERVER['DOCUMENT_ROOT'] . "/import.xml";
     $excel = new XML2003Parser($xsdstring);
     $table = $excel->getTableData();
     function mb_ucfirst($str, $enc = 'utf-8')
     {
         return mb_strtoupper(mb_substr($str, 0, 1, $enc), $enc) . mb_substr($str, 1, mb_strlen($str, $enc), $enc);
     }
     foreach ($table["table_contents"] as $row) {
         if (isset($row["row_contents"][2]) && isset($row["row_contents"][0])) {
             $id = $row["row_contents"][0]['value'];
             $value = trim(mb_ucfirst(mb_strtolower($row["row_contents"][2]['value'])));
             $postlang = PostLang::find($id);
             if ($postlang) {
                 $postlang->title = $value;
                 $postlang->uri = PostLang::uniqURI($id, $value);
                 $postlang->save();
             } else {
                 echo "undefined {$id} <br>";
             }
             //echo  "$id  $value<br><br><br>";
         }
     }
     return [];
 }
コード例 #10
0
ファイル: calendar.php プロジェクト: vcorobceanu/WebAPL
 public function save_post_cal_attach()
 {
     $id = Input::get('post_id');
     $count = \CalendarModel::where('post_id', $id)->count();
     if ($count == 0) {
         $post = Post::find($id);
         $calendar = new \CalendarModel();
         $calendar->post_id = $id;
         $calendar->event_date = $post->created_at;
         $field = \FeedFieldValue::join(\FeedField::getTableName(), \FeedField::getField('id'), '=', \FeedFieldValue::getField('feed_field_id'))->where(['post_id' => $id, \FeedField::getField('fkey') => 'hours'])->first();
         if ($field) {
             $calendar->period = $field->value;
         }
         $calendar->save();
         $postLangs = \PostLang::where('post_id', $id)->get();
         foreach ($postLangs as $postLang) {
             $calendarLang = new CalendarLangModel();
             $calendarLang->calendar_item_id = $calendar->id;
             $calendarLang->title = $postLang->title;
             $calendarLang->lang_id = $postLang->lang_id;
             $calendarLang->save();
         }
     } else {
         $calendar = CalendarModel::where('post_id', $id)->get();
         foreach ($calendar as $item) {
             CalendarLangModel::where('calendar_item_id', $item->id)->delete();
         }
         CalendarModel::where('post_id', $id)->delete();
     }
 }
コード例 #11
0
ファイル: newsletter.php プロジェクト: vcorobceanu/WebAPL
 public function sendarticle()
 {
     $post_id = Input::get('id');
     $post = \PostLang::where('post_id', $post_id)->first();
     if ($post) {
         $data['post'] = $post;
         $data['post_url'] = url("/../" . \WebAPL\Language::ext() . "/topost/" . $post_id);
         Template::viewModule($this->module_name, function () use($data, $post) {
             $newsletterUsers = \NewsletterModel::where('enabled', 1)->get();
             foreach ($newsletterUsers as $user) {
                 if (filter_var($user->email, FILTER_VALIDATE_EMAIL)) {
                     $data['user'] = $user;
                     $data['unsubscribe_link'] = url("/../newsletter/unsubscribe/{$user->hash}");
                     Mail::send('views.emails.post', $data, function ($message) use($post, $user) {
                         $message->from("noreply@{$_SERVER['SERVER_NAME']}", 'WebLPA');
                         $message->subject($post->title . " :: NEWSLETTER");
                         $message->to($user->email);
                     });
                 }
             }
         });
     }
 }
コード例 #12
0
ファイル: Post.php プロジェクト: vcorobceanu/WebAPL
 public static function findExistsDates($feed_id)
 {
     $posts = Post::prepareQuery(2)->join(FeedPost::getTableName(), Post::getField("id"), '=', FeedPost::getField("post_id"))->where(FeedPost::getField("feed_id"), $feed_id)->where(PostLang::getField('enabled'), 1)->where(Post::getField('is_trash'), 0)->orderBy(DB::raw("DATE(" . Post::getField('created_at') . ")"), 'asc')->select(DB::raw("DATE(" . Post::getField('created_at') . ") as data"))->remember(SettingsModel::one('cachelife'))->get();
     $dates = ['years' => [], 'months' => []];
     foreach ($posts as $post) {
         $tmst = strtotime($post->data);
         $y = (int) date("Y", $tmst);
         $m = (int) date("m", $tmst);
         $d = (int) date("d", $tmst);
         $dates['years'][$y] = $y;
         if (isset($dates['months'][$y])) {
             if (isset($dates['months'][$y][$m])) {
                 $dates['months'][$y][$m]++;
             } else {
                 $dates['months'][$y][$m] = 1;
             }
         } else {
             $dates['months'][$y] = [$m => 1];
         }
     }
     return $dates;
 }