Example #1
0
 /**
  * Display a listing of the resource.
  *
  * @return Response
  */
 public function index()
 {
     parent::show();
     $menus = Page::where("slug", "!=", "")->orderBy("menu_sort_order")->get();
     $banner = $this->banner;
     return $this->respond($menus, 'menus.index', compact('menus', 'banner'));
 }
Example #2
0
 public function tim_viec_danh_muc($id, $phanloai, $title)
 {
     $data['post'] = Page::where('loai', $id)->where('phanloai', $phanloai)->orderBy('id', 'desc')->paginate(11);
     $data['loai'] = $id;
     $data['phan_loai'] = '.phan-loai-' . $phanloai;
     if ($id == 1) {
         $data['title'] = 'Việc làm Gia Sư Đà Nẵng - Tìm việc Gia Sư dành cho sinh viên';
     } elseif ($id == 2) {
         $data['title'] = 'Việc làm nhân viên bán hàng  - Tuyển dụng nhân viên bán hàng';
     } elseif ($id == 3) {
         $data['title'] = 'Tuyển dụng, tìm việc làm giữ xe, phát tờ rơi, nhân viên bảo vệ';
     } elseif ($id == 4) {
         $data['title'] = 'Việc Làm Nhân Viên Phục Vụ - Tìm việc làm phục vụ cafe ĐN';
     } elseif ($id == 5) {
         $data['title'] = 'Việc làm PG, Tiếp Thị | Tìm việc làm Tiếp Thị, PG tại Đà Nẵng';
     } elseif ($id == 6) {
         $data['title'] = 'Việc Làm Tạp Vụ, Giúp Việc - Tìm việc làm tạp vụ, giúp việc ĐN';
     } elseif ($id == 7) {
         $data['title'] = 'Việc Làm Thực Tập - Tìm việc làm thực tập sinh viên Đà Nẵng';
     } elseif ($id == 8) {
         $data['title'] = 'Việc Làm Cộng Tác Viên - Tuyển cộng tác viên - Tìm việc CTV';
     } elseif ($id == 9) {
         $data['title'] = 'Việc Làm Freelancer Đà Nẵng- Tìm việc freelancer - Freelancer ';
     } else {
         $data['title'] = 'Việc làm đa cấp | Website viec lam sinh vien so 1 tai Da Nang';
     }
     return View::make('template.content', $data);
 }
Example #3
0
 public function tim_viec_danh_muc($id, $phanloai, $title)
 {
     $data['post'] = Page::where('loai', $id)->where('phanloai', $phanloai)->orderBy('id', 'desc')->paginate(11);
     $data['loai'] = $id;
     $data['phan_loai'] = '.phan-loai-' . $phanloai;
     if ($id == 1) {
         $data['title'] = 'Gia sư sinh viên | Website viec lam sinh vien uy tin tai da nang';
     } elseif ($id == 2) {
         $data['title'] = 'Nhân viên bán hàng | Website viec lam sinh vien uy tin tai da nang';
     } elseif ($id == 3) {
         $data['title'] = 'Việc làm phát tờ rơi, giữ xe, bảo vệ dành cho sinh viên tại Đà Nẵng';
     } elseif ($id == 4) {
         $data['title'] = 'Việc làm nhà hàng, cafe, tiệc cưới dành cho sinh viên tại Đà Nẵng';
     } elseif ($id == 5) {
         $data['title'] = 'PG-PB, Tiếp thị, Khảo sát thị trường | Website viec lam uy tin so 1';
     } elseif ($id == 6) {
         $data['title'] = 'Giúp việc nhà, trông coi cửa hàng| Website viec lam sinh vien uy tin';
     } elseif ($id == 7) {
         $data['title'] = 'Việc làm sinh viên thực tập | Website viec lam uy tin tai Da Nang';
     } elseif ($id == 8) {
         $data['title'] = 'Việc làm cộng tác viên | Website viec lam sinh vien uy tin tai Da Nang';
     } elseif ($id == 9) {
         $data['title'] = 'Việc làm freelancer | Website viec lam sinh vien uy tin tai Da Nang';
     } else {
         $data['title'] = 'Việc làm đa cấp | Website viec lam sinh vien so 1 tai Da Nang';
     }
     return View::make('template.content', $data);
 }
Example #4
0
 /**
  * Gets a list of languages that the page has not been translated to or originates from
  *
  * @param  integer $pageId
  * @param  array  $languages
  * @return array
  */
 public function getUnUsedLanguageList($pageId, $languages)
 {
     $existingLangages = $this->Page->where(function ($query) use($pageId) {
         $query->where('id', $pageId)->orWhere('translated_from_page_id', $pageId);
     })->lists('title', 'language_id');
     return array_diff_key($languages, $existingLangages->toArray());
 }
Example #5
0
 /**
  * Get total page count.
  *
  * @param bool $all
  *
  * @return mixed
  */
 protected function totalPages($all = false)
 {
     if (!$all) {
         return $this->page->where('is_published', 1)->where('lang', $this->getLang())->count();
     }
     return $this->page->where('lang', $this->getLang())->count();
 }
Example #6
0
 /**
  * Creates a compressed cache file for the chapter
  *
  * @author Woxxy
  * @return url to compressed file
  */
 function compress($comic, $language = 'en', $volume = null, $chapter = null, $subchapter = 0)
 {
     require_once FCPATH . 'assets/pclzip/pclzip.lib.php';
     $files = array();
     if (get_setting('fs_dl_volume_enabled') && $volume !== null && $chapter === null) {
         if ($volume == 0) {
             show_404();
         }
         $chapters = new Chapter();
         $chapters->where('comic_id', $comic->id)->where('volume', $volume)->order_by('volume', 'asc')->order_by('chapter', 'asc')->order_by('subchapter', 'asc')->get();
         if ($chapters->result_count() == 0) {
             show_404();
         }
         $volume_id = $volume;
         $chapter_id = $chapters->id;
         $filepath = $comic->directory();
         $filename = $this->filename_chapters_compressed($chapters);
         foreach ($chapters as $chaptere) {
             $pages = new Page();
             $pages->where('chapter_id', $chaptere->id)->get();
             foreach ($pages as $page) {
                 $files[] = array(PCLZIP_ATT_FILE_NAME => 'content/comics/' . $comic->directory() . '/' . $chaptere->directory() . '/' . $page->filename, PCLZIP_ATT_FILE_NEW_FULL_NAME => $this->filename_chapter_compressed($chaptere) . '/' . $page->filename);
             }
         }
     } else {
         $chaptere = new Chapter();
         $chaptere->where('comic_id', $comic->id)->where('language', $language)->where('volume', $volume)->where('chapter', $chapter)->where('subchapter', $subchapter);
         $chaptere->get();
         if ($chaptere->result_count() == 0) {
             show_404();
         }
         $volume_id = 0;
         $chapter_id = $chaptere->id;
         $filepath = $comic->directory() . '/' . $chaptere->directory();
         $filename = $this->filename_chapter_compressed($chaptere);
         $pages = new Page();
         $pages->where('chapter_id', $chaptere->id)->get();
         foreach ($pages as $page) {
             $files[] = 'content/comics/' . $comic->directory() . '/' . $chaptere->directory() . '/' . $page->filename;
         }
     }
     $this->where('comic_id', $comic->id)->where('volume_id', $volume_id)->where('chapter_id', $chapter_id)->get();
     if ($this->result_count() == 0 || !file_exists('content/comics/' . $filepath . '/' . $this->filename)) {
         $this->remove_old();
         $archive = new PclZip('content/comics/' . $filepath . '/' . $filename . '.zip');
         $archive->create($files, PCLZIP_OPT_REMOVE_ALL_PATH, PCLZIP_OPT_NO_COMPRESSION);
         $this->comic_id = $comic->id;
         $this->volume_id = $volume_id;
         $this->chapter_id = $chapter_id;
         $this->filename = $filename . '.zip';
         $this->size = filesize('content/comics/' . $filepath . '/' . $filename . '.zip');
         $this->lastdownload = date('Y-m-d H:i:s', time());
         $this->save();
     } else {
         $this->lastdownload = date('Y-m-d H:i:s', time());
         $this->save();
     }
     return array("url" => site_url() . 'content/comics/' . $filepath . '/' . urlencode($this->filename), "server_path" => FCPATH . 'content/comics/' . $filepath . '/' . $this->filename);
 }
Example #7
0
 public function getMappedPage()
 {
     $page = Page::where('uri', $this->uri)->first();
     if (!$page) {
         return false;
     }
     return $page;
 }
 /**
  * Setup the layout used by the controller.
  *
  * @return void
  */
 public function view($slug)
 {
     if ($page = Page::where('slug', $slug)->first()) {
         return View::make('pages.index')->with('page', $page)->with('custom', '0');
     } else {
         App::abort('404');
     }
 }
Example #9
0
 public static function boot()
 {
     parent::boot();
     //删除时先删除相关文档、单页
     self::deleting(function (User $user) {
         Article::where('uid', '=', $user->id)->delete();
         Page::where('uid', '=', $user->id)->delete();
     });
 }
Example #10
0
 function index()
 {
     $pages = new Page();
     if (@$_GET['search']) {
         $pages->where("title like '%" . $_GET['search'] . "%'");
     }
     $data['pages'] = $pages->order_by('id', 'desc')->get_page();
     $this->template->build('admin/page_index', $data);
 }
Example #11
0
 /**
  * Display the specified resource.
  *
  * @param  string  $slug
  * @return Response
  */
 public function show($slug)
 {
     // Check if the page exists
     if (is_null($page = Page::where('slug', $slug)->first())) {
         // Put a 404 in ur face, yo !
         return App::abort(404);
     }
     return View::make('modules.page.show')->with('page', Page::where('slug', $slug)->first());
 }
 /**
  * Display customer profile
  *
  * @param $profile
  * @return Response
  */
 public function show($profile)
 {
     $p = User::where('profile_url', '=', $profile)->where('approved', '=', '0')->first();
     $page = Page::where('title', '=', 'faq-customer')->first();
     $follow = Follow::where('user', $p->id)->where('hub', '=', 0)->get();
     $follow_hub = Follow::where('user', $p->id)->where('artist', '=', 0)->get();
     $wall = new \Illuminate\Database\Eloquent\Collection();
     $events = new \Illuminate\Database\Eloquent\Collection();
     $comments = Comment::where('user', '=', $p->id)->orderBy('created_at', 'desc')->get();
     $hidden = unserialize(Cookie::get('hide'));
     //dd( Cookie::get('hide') );
     if (count($follow) > 0) {
         foreach ($follow as $f) {
             $s = Song::where('artist', '=', $f->artist)->where('completed', '=', '1')->get();
             $e = ArtistEvent::where('artist', '=', $f->artist)->where('date', '>', \Carbon\Carbon::now())->get();
             $wall = $wall->merge($s);
             $events = $events->merge($e);
         }
     }
     if (count($follow_hub) > 0) {
         foreach ($follow_hub as $h) {
             $hub = Hub::where('id', '=', $h->hub)->first();
             if (!is_null($hub)) {
                 $artists = User::where('type', '=', 'artist')->where('hub', '=', $hub->id)->get();
                 $artists_list = [];
                 $songs = [];
                 $events = [];
                 foreach ($artists as $a) {
                     $artists_list[] = $a->id;
                 }
                 if (count($artists_list) > 0) {
                     $songs = Song::where('completed', '=', '1')->whereIn('artist', $artists_list)->orderBy('created_at', 'desc')->get();
                     $events = ArtistEvent::whereIn('artist', $artists_list)->get();
                 }
                 $news = News::where('hub', '=', $hub->id)->take(3)->get();
                 $wall = $wall->merge($songs);
                 $events = $events->merge($events);
             }
         }
     }
     $purchased = Purchase::where('customer', '=', $p->id)->get();
     foreach ($purchased as $pp) {
         $song_purchased = Song::withTrashed()->where('id', '=', $pp->song)->get();
         $download = Download::where('customer', '=', $p->id)->where('song', '=', $pp->song)->first();
         $song_purchased[0]->purchased = true;
         if (isset($download)) {
             $song_purchased[0]->link = $download->url;
         }
         $wall = $wall->merge($song_purchased);
     }
     $wall->sortByDesc('created_at');
     if (!isset($news)) {
         $news = null;
     }
     return View::make('customer.profile-new', ['profile' => $p, 'wall' => $wall, 'page' => $page, 'events' => $events, 'comments' => $comments, 'hidden' => $hidden, 'news' => $news]);
 }
Example #13
0
 /** @test **/
 public function it_returns_the_fresh_model_fetched_from_the_database()
 {
     $this->createComponent('pages');
     $this->insertOn('pages', ['title' => 'Psych!', 'content' => 'GUUUS!!!']);
     $page = Page::where('title', 'Psych!')->first();
     $page->title = 'House';
     $page = $page->fresh();
     $this->assertEquals('Psych!', $page->title);
     $this->assertEquals('GUUUS!!!', $page->content);
 }
Example #14
0
 public static function getPageid()
 {
     $route = AppHelper::curPageURL();
     $pageId = Page::where('route', '=', $route)->get();
     //return $user;
     foreach ($pageId as $value) {
         $id = $value['id'];
     }
     return $id;
 }
Example #15
0
 public function getPage($slug)
 {
     $page = Page::where('slug', $slug)->first();
     if (empty($page)) {
         $page = new Page();
         $page->slug = $slug;
         $page->content = "Empty Page -> Please Edit in Admin Section";
         $page->save();
     }
     return View::make('site.pages.index', compact('page'));
 }
 /**
  * Display the specified post.
  *
  * @param  int  $id
  * @return Response
  */
 public function index($slug)
 {
     $page = Page::where('slug', '=', $slug)->first();
     //Make sure page is active
     if (!Auth::guest() && Auth::user()->role == 'admin' || $page->active) {
         $author = User::find($page->user_id);
         $data = array('page' => $page, 'author' => $author, 'menu' => Menu::orderBy('order', 'ASC')->get(), 'video_categories' => VideoCategory::all(), 'post_categories' => PostCategory::all(), 'theme_settings' => ThemeHelper::getThemeSettings(), 'pages' => Page::all());
         return View::make('Theme::page', $data);
     } else {
         return Redirect::to('pages')->with(array('note' => 'Sorry, this page is no longer active.', 'note_type' => 'error'));
     }
 }
Example #17
0
 /**
  * Returns the comic
  * 
  * Available filters: id (required)
  * 
  * @author Woxxy
  */
 function comic_get()
 {
     if ($this->get('id')) {
         //// check that the id is at least a valid number
         $this->_check_id();
         // get the comic
         $comic = new Comic();
         $comic->where('id', $this->get('id'))->limit(1)->get();
     } else {
         if ($this->get('stub')) {
             // mostly used for load balancer
             $comic = new Comic();
             $comic->where('stub', $this->get('stub'));
             // back compatibility with version 0.7.6, though stub is already an unique key
             if ($this->get('uniqid')) {
                 $comic->where('uniqid', $this->get('uniqid'));
             }
             $comic->limit(1)->get();
         } else {
             $this->response(array('error' => _('You didn\'t use the necessary parameters')), 404);
         }
     }
     if ($comic->result_count() == 1) {
         $chapters = new Chapter();
         $chapters->where('comic_id', $comic->id)->get();
         $chapters->get_teams();
         $result = array();
         $result["comic"] = $comic->to_array();
         // order in the beautiful [comic][chapter][teams][page]
         $result["chapters"] = array();
         foreach ($chapters->all as $key => $chapter) {
             $result['chapters'][$key]['comic'] = $result["comic"];
             $result['chapters'][$key]['chapter'] = $chapter->to_array();
             // if it's requested, throw in also the pages (for load balancer)
             if ($this->get('chapter_stub') == $chapter->stub && $this->get('chapter_uniqid') == $chapter->uniqid) {
                 $pages = new Page();
                 $pages->where('chapter_id', $chapter->id)->get();
                 $result["chapters"][$key]["chapter"]["pages"] = $pages->all_to_array();
             }
             // teams is a normal array, can't use $team->all_to_array()
             foreach ($chapter->teams as $team) {
                 $result['chapters'][$key]['teams'][] = $team->to_array();
             }
         }
         // all good
         $this->response($result, 200);
         // 200 being the HTTP response code
     } else {
         // there's no comic with that id
         $this->response(array('error' => _('Comic could not be found')), 404);
     }
 }
 public function viewPage($urlString)
 {
     try {
         $page = Page::where('urlString', $urlString)->first();
         if (!$page) {
             return Response::notFound();
         }
         $page = Page::decodePageJson($page);
         return View::make('pages/viewPage')->with(array('page' => $page, 'currentPage' => 'viewPage', 'ogImage' => $page['ogData']['ogImage'], 'ogTitle' => $page['ogData']['ogTitle'], 'title' => $page['title'] ? $page['title'] : '', 'ogDescription' => $page['ogData']['ogDescription'], 'description' => $page['description'] ? $page['description'] : ''));
     } catch (Illuminate\Database\Eloquent\ModelNotFoundException $e) {
         return Response::notFound('Quiz not found');
     }
 }
Example #19
0
 public static function register()
 {
     // register home page
     Registry::set('home_page', Page::home());
     // register posts page
     Registry::set('posts_page', Page::posts());
     if (!is_admin()) {
         // register menu items
         $pages = Page::where('show_in_menu', '=', '1')->sort('menu_order')->get();
         $pages = new Items($pages);
         Registry::set('menu', $pages);
         Registry::set('total_menu_items', $pages->length());
     }
 }
Example #20
0
 /**
  * This method checks to see if a view exists and if it does loads it along with any
  * associated data from the database. It then checks to see if a function exists for
  * the passed in page name (substituting dashes for underscores and runs that) if it exists.
  * @param  string  $page            The page name
  * @param  string  $variable        Allows us to pass a second variable to things
  * @return view                     Ideally a view of some kind
  */
 public function get_index($page = 'home', $variable = false)
 {
     $this->data['page'] = Page::where('slug', '=', $page)->first();
     $function = strtolower(Request::method() . '_' . str_replace('-', '_', $page));
     if (method_exists($this, $function)) {
         $this->{$function}($variable);
     } else {
         if (View::exists('site.' . $page)) {
             return View::make('site.' . $page, $this->data);
         } else {
             return Response::error('404');
         }
     }
 }
Example #21
0
 /**
  * Initializer.
  *
  * @return void
  */
 public function __construct()
 {
     // CSRF Protection
     $this->beforeFilter('csrf', array('on' => 'post'));
     // Initialization of the MessageBag
     $this->messageBag = new Illuminate\Support\MessageBag();
     if (Route::currentRouteName() != 'setLang') {
         if (Session::get('locale')) {
             App::setLocale(Session::get('locale'));
         } else {
             Session::put('locale', 'fr');
             App::setLocale('fr');
         }
     }
     View::share('locale', Session::get('locale') ? Session::get('locale') : App::getLocale());
     View::share('menu_pages', Schema::hasTable('pages') ? Page::where('draft', '0')->where('in_menu', '1')->where('lang', Session::get('locale'))->get(array('title', 'slug')) : null);
 }
Example #22
0
 /**
  * [isValidInputForNewPage description]
  * @param  [type]  $input
  * @return boolean
  */
 protected function isValidInputForNewPage($input)
 {
     // validate the input given before we create the page
     $this->validator = $this->Validator->make($input, $this->Page->createRules, $this->Page->messages);
     $fails = $this->validator->fails();
     if ($fails) {
         $this->errors = $this->validator->errors()->all();
         $this->message = "There were validation errors.";
     }
     // check to make sure that there is no duplicate slug/method out there
     $duplicatePage = $this->Page->where('http_verb', $input['http_verb'])->where('slug', $input['slug'])->first();
     if ($duplicatePage) {
         $this->errors = $this->validator->errors()->all();
         $this->errors['slug'] = 'There is already a page with this slug/verb pair';
         $this->message = "There were validation errors.";
     }
     return count($this->errors) == 0;
 }
Example #23
0
 public static function register()
 {
     // register home page
     Registry::set('home_page', Page::home());
     // register posts page
     Registry::set('posts_page', Page::posts());
     if (!is_admin()) {
         // register categories
         foreach (Category::get() as $itm) {
             $categories[$itm->id] = $itm;
         }
         Registry::set('all_categories', $categories);
         // register menu items
         $pages = Page::where('status', '=', 'published')->where('show_in_menu', '=', '1')->sort('menu_order')->get();
         $pages = new Items($pages);
         Registry::set('menu', $pages);
         Registry::set('total_menu_items', $pages->length());
     }
 }
 /**
  * Show charity profile
  *
  * @param int $charity
  *
  * @return Response
  *
  */
 public function show($charity)
 {
     $profile = User::where('profile_url', '=', $charity)->where('approved', '=', '0')->first();
     if ($profile->charity) {
         $page = Page::where('title', '=', 'faq-charity')->first();
         $songs = Song::where('charity', $profile->charity->id)->where('charity_approved', '=', 1)->orderBy('created_at', 'desc')->get();
         $songs_in = [];
         $approval = Song::where('charity', $profile->charity->id)->where('charity_approved', '=', 0)->get();
         foreach ($songs as $s) {
             $songs_in[] = $s->id;
         }
         if (count($songs_in) > 0) {
             $comments = Comment::whereIn('song', $songs_in)->orderBy('id', 'desc')->take(3)->get();
         } else {
             $comments = "";
         }
         return View::make('charity.profile-new', ['profile' => $profile, 'wall' => $songs, 'page' => $page, 'comments' => $comments, 'approval' => $approval]);
     } else {
         return Redirect::to('charity/settings');
     }
 }
Example #25
0
 function __construct()
 {
     if (SECOND_PARAMETER === 'new') {
         $this->newPage();
     }
     if (!SECOND_PARAMETER || !Validate::slug(SECOND_PARAMETER)) {
         Base::redirect('/oops');
     }
     $this->page = Page::where('slug', SECOND_PARAMETER)->findOne();
     if (!$this->page) {
         Base::redirect('/oops');
     }
     // Page title
     View::set('page_title', $this->page->title);
     if (ctype_lower(THIRD_PARAMETER) && method_exists($this, THIRD_PARAMETER)) {
         $func = THIRD_PARAMETER;
         $this->{$func}();
     } else {
         $this->page();
     }
 }
Example #26
0
	/**
	 * Function to create a new page from a $filedata array. It deals with
	 * processing the image data, checks if it's an image, puts values like
	 * height in the variables, sends to database function and file function.
	 * 
	 * This function fails silently for the user. For now.
	 *
	 * @author	Woxxy
	 * @param	array|$filedata It's an array of data produced by CodeIgniter 
	 * 			upload function
	 * @param	int|$chapter_id The ID of the chapter
	 * @param	int|$hidden NOT USED
	 * @param	string|$description NOT USED
	 * @return	boolean true on success, false on failure.
	 */
	public function add_page($filedata, $chapter_id, $hidden = 0, $description = "") {

		// Check if that file is actually an image
		if (!$imagedata = @getimagesize($filedata["server_path"])) {
			log_message('error', 'add_page: uploaded file doesn\'t seem to be an image');
			return false;
		}

		// Let's set some variables
		$this->chapter_id = $chapter_id;

		// Load the chapter and comic as soon as possible.
		if (!$this->get_chapter()) {
			log_message('error', 'add_page: couldn\'t find related chapter');
			return false;
		}

		if ($hidden == 1)
			$this->hidden = 1; else
			$this->hidden = 0;
		$this->description = $description;

		// Decide if it should overwrite. Normally files get overwritten.
		$overwrite = $filedata["overwrite"];

		// Throw the image to the folder with this function
		// While we aren't looking, this also creates the thumbnails
		if (!$this->add_page_file($filedata)) {
			log_message('error', 'add_page: failed creating file');
			return false;
		}

		// We need the dir to the chapter
		$dir = "content/comics/" . $this->chapter->comic->directory() . "/" . $this->chapter->directory() . "/";


		// $imagedata = @getimagesize($filedata["server_path"]);
		// We had set $imagedata before
		// We already have the thumbnail! Get data for that too.
		$thumbdata = @getimagesize($dir . "thumb_" . $filedata["name"]);

		// If a page in this chapter with the same filename exists, pick its ID and start updating it
		// This makes so everything gets overwritten with no error
		$page = new Page();
		$page->where('chapter_id', $this->chapter_id)->where('filename', $filedata["name"])->get();
		if ($page->result_count() > 0) {
			$this->id = $page->id;
		}

		// Prepare the variables
		$this->filename = $filedata["name"];
		$this->thumbnail = "thumb_";
		$this->width = $imagedata["0"];
		$this->height = $imagedata["1"];
		$this->size = filesize($dir . $filedata["name"]);
		$this->mime = image_type_to_mime_type($imagedata["2"]);
		$this->thumbwidth = $thumbdata["0"];
		$this->thumbheight = $thumbdata["1"];
		$this->thumbsize = filesize($dir . "thumb_" . $filedata["name"]);

		// Check from the thumbnail if the image is in colors or not
		$is_bw = $this->is_bw();
		if ($is_bw == "bw")
			$this->grayscale = 1;
		else if ($is_bw == "rgb")
			$this->grayscale = 0;
		else {
			log_message('error', 'add_page: error while determining if black and white or RGB');
			return false;
		}

		// Finally, save everything to database, and, in case of failure, remove the image files
		if (!$this->update_page_db()) {
			log_message('error', 'add_page: failed writing to database');
			$this->remove_page_file();
			return false;
		}

		// All good
		return true;
	}
Example #27
0
 private function createTree($pages)
 {
     foreach ($pages as $page) {
         $slug = $page->slug;
         if ($page->has_child) {
             if ($page->level == 0) {
                 $final[] = $page->page_name;
             }
             $children = Page::where('parent', '=', $slug)->get();
             foreach ($children as $sub) {
                 $slug2 = $sub->slug;
                 if ($sub->level == 1) {
                     $g = "-";
                     $g .= $sub->page_name;
                     $final[] = $g;
                 }
                 if ($sub->has_child) {
                     $children2 = Page::where('parent', '=', $slug2)->get();
                     foreach ($children2 as $sub2) {
                         if ($sub2->level == 2) {
                             $g = "--";
                         }
                         $g .= $sub2->page_name;
                         $final[] = $g;
                     }
                 }
             }
         } else {
             if ($page->level == 0) {
                 $final[] = $page->page_name;
             }
         }
     }
     return $final;
 }
Example #28
0
 public function post_delete_user()
 {
     $user = User::find(Input::get('id'));
     $user->delete();
     $post = Post::where('user_id', Input::get('id'));
     $post->delete();
     $page = Page::where('user_id', Input::get('id'));
     $page->delete();
     return Redirect::to(Input::get('url_full'))->with('delete_user', 'Xóa tài khoản thành công');
 }
Example #29
0
 /**
  * Function to create a new page from a $filedata array. It deals with
  * processing the image data, checks if it's an image, puts values like
  * height in the variables, sends to database function and file function.
  *
  * This function fails silently for the user. For now.
  *
  * @author	Woxxy
  * @param	array|$filedata It's an array of data produced by CodeIgniter
  * 			upload function
  * @param	int|$chapter_id The ID of the chapter
  * @param	int|$hidden NOT USED
  * @param	string|$description NOT USED
  * @return	boolean true on success, false on failure.
  */
 public function add_page($path, $filename, $chapter)
 {
     // Check if that file is actually an image
     if (!($imagedata = @getimagesize($path))) {
         log_message('error', 'add_page: uploaded file doesn\'t seem to be an image');
         return false;
     }
     // Let's set some variables
     $this->chapter_id = $chapter->id;
     // Load the chapter and comic as soon as possible.
     if (!$this->get_chapter()) {
         log_message('error', 'add_page: couldn\'t find related chapter');
         return false;
     }
     // Throw the image to the folder with this function
     // While we aren't looking, this also creates the thumbnails
     if (!$this->add_page_file($path, $filename)) {
         log_message('error', 'add_page: failed creating file');
         return false;
     }
     // We need the dir to the chapter
     $dir = "content/comics/" . $this->chapter->comic->directory() . "/" . $this->chapter->directory() . "/";
     // If a page in this chapter with the same filename exists, pick its ID and start updating it
     // This makes so everything gets overwritten with no error
     $page = new Page();
     $page->where('chapter_id', $this->chapter_id)->where('filename', $filename)->get();
     if ($page->result_count() > 0) {
         $this->id = $page->id;
     }
     // Prepare the variables
     $this->filename = $filename;
     $this->width = $imagedata["0"];
     $this->height = $imagedata["1"];
     $this->size = filesize($dir . $filename);
     $this->mime = image_type_to_mime_type($imagedata["2"]);
     // Finally, save everything to database, and, in case of failure, remove the image files
     if (!$this->update_page_db()) {
         log_message('error', 'add_page: failed writing to database');
         $this->remove_page_file();
         return false;
     }
     $this->on_change($chapter);
     // All good
     return true;
 }
Example #30
0
 public function searchable($searchterm)
 {
     $searchresults = array();
     // Search posts table
     $posts = Post::where('title', 'LIKE', '%' . $searchterm . '%')->orWhere('content', 'LIKE', '%' . $searchterm . '%')->published()->get();
     if ($posts->count()) {
         foreach ($posts as $post) {
             $searchresults[] = array('type' => 'artikel', 'type_category' => $post->category->title, 'title' => $post->title, 'link' => 'posts/' . $post->slug, 'content' => $post->excerpt != NULL ? $post->excerpt : str_limit(strip_tags($post->content), 300), 'image' => $post->image, 'original_updated_at' => $post->updated_at, 'updated_at' => $post->translateDate($post->updated_at));
         }
     }
     // Search pages table
     $pages = Page::where('title', 'LIKE', '%' . $searchterm . '%')->orWhere('content', 'LIKE', '%' . $searchterm . '%')->published()->get();
     if ($pages->count()) {
         foreach ($pages as $page) {
             $searchresults[] = array('type' => 'halaman', 'type_category' => NULL, 'title' => $page->title, 'link' => 'pages/' . $page->slug, 'content' => $page->excerpt != NULL ? $page->excerpt : str_limit(strip_tags($page->content), 300), 'image' => NULL, 'original_updated_at' => $page->updated_at, 'updated_at' => $page->translateDate($page->updated_at));
         }
     }
     // print_r($searchresults);
     // array_sort($searchresults,'updated_at',SORT_DESC); // sort by latest updated
     return $searchresults;
 }