コード例 #1
0
 public static function select_levels()
 {
     $role = array(0 => LL('cms::form.select', CMSLANG));
     $max = ROLE;
     for ($i = 2; $i < $max; $i++) {
         $role[$i] = $i;
     }
     return $role;
 }
コード例 #2
0
 public function get_index($lang_to = 'en')
 {
     //LOAD JS LIBS
     Asset::container('footer')->add('form', 'bundles/cms/js/jquery.form.js', 'jquery');
     Asset::container('footer')->add('translations', 'bundles/cms/js/sections/translations_list.js', 'cms');
     $this->layout->header_data = array('title' => LL('cms::title.translations', CMSLANG));
     $this->layout->top_data = array('search' => false);
     $langs = CmsPage::select_lang_translation();
     $my_lang = LANG;
     array_shift($langs);
     //GET DATA
     $data = CmsTranslation::where('lang_from', '=', $my_lang)->where('lang_to', '=', $lang_to)->order_by('word', 'asc')->get();
     $this->layout->content = View::make('cms::interface.pages.translation_list')->with('langs', $langs)->with('lang_from', $my_lang)->with('lang_to', $lang_to)->with('data', $data);
 }
コード例 #3
0
 public static function select_zone($page_id = '')
 {
     $zones = array(0 => LL('cms::form.select', CMSLANG));
     if (!empty($page_id)) {
         $rs = CmsPage::find($page_id);
         $layout = $rs->layout;
         if (!empty($layout)) {
             $zone_arr = Config::get('cms::theme.layout_' . $layout);
             foreach ($zone_arr as $key => $value) {
                 $zones[$key] = $value;
             }
         }
     }
     return $zones;
 }
コード例 #4
0
 public function post_index()
 {
     //POST LOGIN
     $credentials = array('cms' => true, 'username' => Input::get('username'), 'password' => Input::get('password'), 'remember' => false);
     //CHECK CREDENTIALS
     if (Auth::attempt($credentials)) {
         //SUCCESS NOTIFICATION
         return Redirect::to_action('cms::dashboard');
     } else {
         //ERROR NOTIFICATION
         Notification::error(LL('cms::alert.login_error', CMSLANG));
         //BACK TO LOGIN
         return Redirect::to_action('cms::login')->with_input('only', array('username'));
     }
 }
コード例 #5
0
 public function post_delete_translation()
 {
     $auth = Auth::check();
     if ($auth and is_numeric(AUTHORID)) {
         $id = Input::get('id');
         $trans = CmsTranslation::find($id);
         $trans->delete();
         $tid = $id;
         $response = 'success';
         $msg = LL('cms::ajax_resp.translation_delete_success', CMSLANG)->get();
     } else {
         $tid = null;
         $response = 'error';
         $msg = LL('cms::ajax_resp.translation_delete_error', CMSLANG)->get();
     }
     $data = array('auth' => $auth, 'id' => $tid, 'response' => $response, 'message' => $msg);
     return json_encode($data);
 }
コード例 #6
0
 public function post_delete()
 {
     if (Input::has('user_id')) {
         $uid = Input::get('user_id');
         $user = CmsUser::find($uid);
         //CHECK IF USER EXISTS
         if (empty($user)) {
             Notification::error(LL('cms::alert.delete_user_error', CMSLANG), 2500);
             return Redirect::to_action('cms::user');
         } else {
             $user->delete();
             Notification::success(LL('cms::alert.delete_user_success', CMSLANG, array('user' => $user->username)), 1500);
             return Redirect::to_action('cms::user');
         }
     } else {
         Notification::error(LL('cms::alert.delete_user_error', CMSLANG), 1500);
         return Redirect::to_action('cms::user');
     }
 }
コード例 #7
0
 public function post_delete()
 {
     if (Input::has('role_id')) {
         $rid = Input::get('role_id');
         $page = CmsPage::where_role_id($rid)->first();
         //CHECK IF ROLE STILL IN USE
         if (!empty($page)) {
             Notification::error(LL('cms::alert.delete_role_stillinuse_error', CMSLANG, array('page' => $page->name)), 2500);
             return Redirect::to_action('cms::role');
         } else {
             $role = CmsRole::find($rid);
             $role->delete();
             Notification::success(LL('cms::alert.delete_role_success', CMSLANG, array('role' => $role->name)), 1500);
             return Redirect::to_action('cms::role');
         }
     } else {
         Notification::error(LL('cms::alert.delete_role_error', CMSLANG), 1500);
         return Redirect::to_action('cms::page');
     }
 }
コード例 #8
0
 public function post_delete()
 {
     if (Input::has('gallery_id')) {
         $gid = Input::get('gallery_id');
         $gallery = CmsGallery::find($gid);
         //CHECK IF GALLERY EXISTS
         if (!empty($gallery)) {
             //DELETE FROM DB
             $gallery->files()->delete();
             $gallery->delete();
             Notification::success(LL('cms::alert.delete_gallery_success', CMSLANG, array('gallery' => $gallery->name)), 1500);
             return Redirect::to_action('cms::gallery');
         } else {
             Notification::error(LL('cms::alert.delete_gallery_error', CMSLANG), 2500);
             return Redirect::to_action('cms::gallery');
         }
     } else {
         Notification::error(LL('cms::alert.delete_gallery_error', CMSLANG), 1500);
         return Redirect::to_action('cms::gallery');
     }
 }
コード例 #9
0
 public function post_delete()
 {
     if (Input::has('download_id')) {
         $did = Input::get('download_id');
         $download = CmsDownload::find($did);
         //CHECK IF DOWNLOAD EXISTS
         if (!empty($download)) {
             //DELETE FROM DB
             $download->files()->delete();
             $download->delete();
             Notification::success(LL('cms::alert.delete_download_success', CMSLANG, array('download' => $download->name)), 1500);
             return Redirect::to_action('cms::download');
         } else {
             Notification::error(LL('cms::alert.delete_download_error', CMSLANG), 2500);
             return Redirect::to_action('cms::download');
         }
     } else {
         Notification::error(LL('cms::alert.delete_download_error', CMSLANG), 1500);
         return Redirect::to_action('cms::download');
     }
 }
コード例 #10
0
 public function post_delete()
 {
     if (Input::has('tag_id')) {
         $tid = Input::get('tag_id');
         $tag = CmsTag::find($tid);
         //CHECK IF TAG EXISTS
         if (!empty($tag)) {
             $lang = $tag->lang;
             //DELETE FROM DB
             $tag->blogs()->delete();
             $tag->delete();
             Notification::success(LL('cms::alert.delete_tag_success', CMSLANG, array('tag' => $tag->name)), 1500);
             return Redirect::to_action('cms::tag', array($lang));
         } else {
             Notification::error(LL('cms::alert.delete_tag_error', CMSLANG), 2500);
             return Redirect::to_action('cms::tag', array($lang));
         }
     } else {
         Notification::error(LL('cms::alert.delete_gallery_error', CMSLANG), 1500);
         return Redirect::to_action('cms::tag', array($lang));
     }
 }
コード例 #11
0
 public function post_save_role()
 {
     $auth = Auth::check();
     if ($auth) {
         $input = Input::get();
         //GRAB DATA
         $role = new CmsRole();
         if (!empty($input['role_id'])) {
             $role = CmsRole::find($input['role_id']);
         }
         //VALIDATION CHECK
         $rules = array('role_name' => 'required|between:2,20|unique:roles,name,' . $input['role_id'], 'role_level' => 'not_in:0');
         $messages = array('required' => LL('cms::validation.required', CMSLANG)->get(), 'between' => LL('cms::validation.between.string', CMSLANG)->get(), 'unique' => LL('cms::validation.unique', CMSLANG)->get(), 'not_in' => LL('cms::validation.not_in', CMSLANG)->get());
         $validation = Validator::make($input, $rules, $messages);
         if ($validation->fails()) {
             return json_encode($validation->errors);
         }
         //VALIDATION OK
         $role->name = $input['role_name'];
         $role->level = $input['role_level'];
         $role->save();
         $rid = $role->id;
         //UPDATE ROLE LEVEL IN PAGE
         CmsPage::update_role_level($rid, $input['role_level']);
         $response = 'success';
         $msg = LL('cms::ajax_resp.role_save_success', CMSLANG)->get();
         $backurl = $input['back_url'];
     } else {
         $rid = null;
         $response = 'error';
         $msg = LL('cms::ajax_resp.role_save_error', CMSLANG)->get();
         $backurl = '#';
     }
     $data = array('auth' => $auth, 'cls' => 'role_id', 'id' => $rid, 'response' => $response, 'message' => $msg, 'backurl' => $backurl);
     return json_encode($data);
 }
コード例 #12
0
 public function post_save_tags()
 {
     $auth = Auth::check();
     if ($auth and is_numeric(AUTHORID)) {
         $input = Input::get();
         //GRAB DATA
         $blog = new CmsBlog();
         if (!empty($input['blog_id'])) {
             $blog = CmsBlog::find($input['blog_id']);
             //CHECK OWNERSHIP
             if (CmsRole::role_fail($input['page_id'])) {
                 $msg = array('noaccess' => LL('cms::ajax_resp.ownership_error', CMSLANG)->get());
                 return json_encode($msg);
             }
         }
         $bid = Input::get('blog_id');
         $pid = Input::get('page_id');
         if (Input::get('as_values_tags_id') !== '') {
             $tags = substr(Input::get('as_values_tags_id'), 0, -1);
             if (substr($tags, 0, 1) == ',') {
                 $tags = substr($tags, 1);
             }
             $rels = explode(',', $tags);
             if (is_array($rels)) {
                 $blog->tags()->sync($rels);
             }
             $response = 'success';
             $msg = LL('cms::ajax_resp.blog_tags_success', CMSLANG)->get();
             $backurl = $input['back_url'];
         } else {
             $response = 'success';
             $msg = LL('cms::ajax_resp.blog_tags_success', CMSLANG)->get();
             $backurl = $input['back_url'];
         }
     } else {
         $bid = null;
         $response = 'error';
         $msg = LL('cms::ajax_resp.blog_tags_error', CMSLANG)->get();
         $backurl = '#';
     }
     $data = array('auth' => $auth, 'cls' => 'blog_id', 'id' => $bid, 'pageid' => $pid, 'response' => $response, 'message' => $msg, 'backurl' => $backurl);
     return json_encode($data);
 }
コード例 #13
0
 public function post_save_download()
 {
     $auth = Auth::check();
     if ($auth) {
         $input = Input::get();
         //GRAB DATA
         $download = new CmsDownload();
         if (!empty($input['download_id'])) {
             $download = CmsDownload::find($input['download_id']);
         }
         //VALIDATION CHECK
         $rules = array('download_name' => 'required|alpha_dash|between:2,20|unique:downloads,name,' . $input['download_id']);
         $messages = array('required' => LL('cms::validation.required', CMSLANG)->get(), 'between' => LL('cms::validation.between.string', CMSLANG)->get(), 'unique' => LL('cms::validation.unique', CMSLANG)->get(), 'alpha_dash' => LL('cms::validation.alpha_dash', CMSLANG)->get());
         $validation = Validator::make($input, $rules, $messages);
         if ($validation->fails()) {
             return json_encode($validation->errors);
         }
         $download->name = strtolower($input['download_name']);
         $download->save();
         //DELETE CACHE
         if (CACHE) {
             Cache::forget('file_list_' . strtolower($input['download_name']));
         }
         $did = $download->id;
         if (Input::has('file_id')) {
             $files = Input::get('file_id');
             if (is_array($files)) {
                 // Empty template
                 $template = '';
                 foreach ($files as $fid) {
                     $check = DB::table('files_downloads')->where_cmsfile_id($fid)->where_cmsdownload_id($did)->first();
                     if (empty($check)) {
                         $download->files()->attach($fid, array('order_id' => 1000000));
                     }
                     $img = CmsFile::find($fid);
                     // Template returned
                     $template .= '<li id="' . $did . '_' . $fid . '" class="span1">';
                     $template .= '<a class="thumbnail" rel="tooltip" data-original-title="' . $img->name . '" href="' . BASE . $img->path . '">';
                     $template .= '<img src="' . BASE . $img->thumb . '" />';
                     $template .= '</a>';
                     $template .= '</li>';
                 }
                 //DELETE NOT IN
                 DB::table('files_downloads')->where_cmsdownload_id($did)->where_not_in('cmsfile_id', $files)->delete();
             }
             $response = 'success';
             $msg = LL('cms::ajax_resp.download_save_success', CMSLANG)->get();
             $backurl = $input['back_url'];
             // Inject container
             $inject = 'ul.sortable';
             $detach = true;
         } else {
             //DELETE ALL DOWNLOAD_ID
             DB::table('files_downloads')->where_cmsdownload_id($did)->delete();
             $response = 'success';
             $msg = LL('cms::ajax_resp.download_save_success', CMSLANG)->get();
             $backurl = $input['back_url'];
             $template = '';
             $inject = '';
             $detach = true;
         }
     } else {
         $response = 'error';
         $msg = LL('cms::ajax_resp.download_save_error', CMSLANG)->get();
         $backurl = '#';
         $template = '';
         $inject = '';
         $detach = true;
     }
     $data = array('auth' => $auth, 'cls' => 'download_id', 'id' => $did, 'response' => $response, 'message' => $msg, 'backurl' => $backurl, 'detach' => $detach, 'inject' => $inject, 'template' => $template);
     return json_encode($data);
 }
コード例 #14
0
 public function post_save_menu()
 {
     $auth = Auth::check();
     if ($auth) {
         $input = Input::get();
         //GRAB DATA
         $menu = new CmsMenu();
         if (!empty($input['menu_id'])) {
             $menu = CmsMenu::find($input['menu_id']);
         }
         //VALIDATION CHECK
         $rules = array('menu_name' => 'required|alpha_dash|between:2,20|unique_lang:' . $input['menu_id'] . ',' . $input['menu_lang'] . ',menus,name');
         $messages = array('required' => LL('cms::validation.required', CMSLANG)->get(), 'between' => LL('cms::validation.between.string', CMSLANG)->get(), 'unique_lang' => LL('cms::validation.unique', CMSLANG)->get(), 'alpha_dash' => LL('cms::validation.alpha_dash', CMSLANG)->get());
         $validation = Validator::make($input, $rules, $messages);
         if ($validation->fails()) {
             return json_encode($validation->errors);
         }
         $menu->name = strtolower($input['menu_name']);
         $menu->lang = strtolower($input['menu_lang']);
         $menu->parent_start = $input['parent_start'];
         $menu->is_nested = Input::has('is_nested') ? 1 : 0;
         //DELETE CACHE
         if (CACHE) {
             Cache::forget('menu_' . strtolower($input['menu_name']) . '_' . LANG);
         }
         if (CACHE) {
             Cache::forget('menu_pages_' . strtolower($input['menu_name']) . '_' . LANG);
         }
         $menu->save();
         $mid = $menu->id;
         // Empty template
         $template = '';
         if (Input::get('page_id') !== '') {
             $pages = Input::get('page_id');
             if (is_array($pages)) {
                 foreach ($pages as $pid) {
                     $check = DB::table('menus_pages')->where_cmspage_id($pid)->where_cmsmenu_id($mid)->first();
                     if (empty($check)) {
                         $menu->pages()->attach($pid, array('order_id' => Config::get('cms::settings.order')));
                     }
                     // Template returned
                     $template .= '<li id="' . $mid . '_' . $pid . '">';
                     $template .= '<a class="btn" href="#">';
                     $template .= '<i class="icon-resize-vertical"></i>';
                     $template .= CmsPage::find($pid)->name;
                     $template .= '</a>';
                     $template .= '</li>';
                 }
                 //DELETE NOT IN
                 DB::table('menus_pages')->where_cmsmenu_id($mid)->where_not_in('cmspage_id', $pages)->delete();
             }
             $response = 'success';
             $msg = LL('cms::ajax_resp.menu_save_success', CMSLANG)->get();
             $backurl = $input['back_url'];
             // Inject container
             $inject = 'ul.sortable';
             $detach = true;
         } else {
             //DELETE ALL MENU_ID
             DB::table('menus_pages')->where_cmsmenu_id($mid)->delete();
             $response = 'success';
             $msg = LL('cms::ajax_resp.menu_save_success', CMSLANG)->get();
             $backurl = $input['back_url'];
             $template = '';
             $inject = '';
             $detach = true;
         }
     } else {
         $response = 'error';
         $msg = LL('cms::ajax_resp.menu_save_error', CMSLANG)->get();
         $backurl = '#';
         $template = '';
         $inject = '';
         $detach = true;
     }
     $data = array('auth' => $auth, 'cls' => 'menu_id', 'id' => $mid, 'response' => $response, 'message' => $msg, 'backurl' => $backurl, 'detach' => $detach, 'inject' => $inject, 'template' => $template);
     return json_encode($data);
 }
コード例 #15
0
 public function post_save_filename()
 {
     $auth = Auth::check();
     if ($auth) {
         $input = Input::get();
         //GRAB DATA
         if (!empty($input['file_id'])) {
             //GRAB DATA
             $file = CmsFile::find($input['file_id']);
             $fid = $file->id;
             $path = MEDIA_PATH($file->path);
             $name = $file->name;
             $ext = '.' . $file->ext;
             $filename = str_replace($ext, '', $name);
             $newname = $input['file_name'];
             //VALIDATION CHECK
             $rules = array('file_name' => 'required|alpha_dash|unique_filename:' . $file->ext . ',name');
             $messages = array('required' => LL('cms::validation.required', CMSLANG)->get(), 'unique_filename' => LL('cms::validation.unique_filename', CMSLANG)->get(), 'alpha_dash' => LL('cms::validation.alpha_dash', CMSLANG)->get());
             $validation = Validator::make($input, $rules, $messages);
             if ($validation->fails()) {
                 return json_encode($validation->errors);
             }
             //VALIDATION OK
             //RENAME DB
             //RENAME NAME
             $file->name = str_replace($filename, $newname, $name);
             //RENAME PATH
             $file->path = str_replace($filename, $newname, $file->path);
             //RENAME THUMB
             $file->thumb = str_replace($filename, $newname, $file->thumb);
             $file->save();
             //RENAME DISK
             //RENAME FILE
             if (file_exists($path)) {
                 rename($path, str_replace($filename, $newname, $path));
             }
             //LOOP ALL THUMBS AND RENAME
             foreach (Config::get('cms::theme.thumb') as $option) {
                 $thumb = MEDIA_NAME($path, $option['suffix']);
                 if (file_exists($thumb)) {
                     rename($thumb, str_replace($filename, $newname, $thumb));
                 }
             }
             $response = 'success';
             $msg = LL('cms::ajax_resp.filename_filename_success', CMSLANG)->get();
             $backurl = $input['back_url'];
         } else {
             $fid = null;
             $response = 'error';
             $msg = LL('cms::ajax_resp.filename_filename_error', CMSLANG)->get();
             $backurl = '#';
         }
     } else {
         $fid = null;
         $response = 'error';
         $msg = LL('cms::ajax_resp.filename_filename_error', CMSLANG)->get();
         $backurl = '#';
     }
     $data = array('auth' => $auth, 'cls' => 'file_id', 'id' => $fid, 'response' => $response, 'message' => $msg, 'backurl' => $backurl);
     return json_encode($data);
 }
コード例 #16
0
 public function post_search()
 {
     if (Input::has('q') and Input::has('source')) {
         //GET q
         $q = Input::get('q');
         //GET page
         $p = Input::get('page', 1);
         // GET FROM WHERE
         if (Input::has('url')) {
             Session::put('URL', Input::get('url', SLUG_FULL));
         }
         $url = Session::get('URL', '/');
         //ITEMS PER PAGE
         $npp = Config::get('cms::theme.site_pag');
         //GET SOURCE WHERE TO SEARCH
         $source = Input::get('source');
         $sources = explode('-', $source);
         $results = array();
         //PAGES
         $tot = 0;
         if (is_numeric(array_search('pages', $sources))) {
             $elements = CmsElement::with(array('pages'))->where('text', 'LIKE', '%' . $q . '%')->where_lang(SITE_LANG)->where_is_valid(1)->get();
             foreach ($elements as $key => $element) {
                 foreach ($element->pages as $page) {
                     $title = strlen($page->title) > 0 ? $page->title : $page->name;
                     $results[$key + 1]['source'] = LL('cms::label.pages', SITE_LANG)->get();
                     $results[$key + 1]['title'] = $title;
                     $results[$key + 1]['slug'] = $page->slug;
                     $results[$key + 1]['descr'] = $page->descr;
                 }
                 $tot++;
             }
         }
         if (is_numeric(array_search('blogs', $sources))) {
             $blogs = CmsBlog::with(array('pages'))->where('name', 'LIKE', '%' . $q . '%')->or_where('preview', 'LIKE', '%' . $q . '%')->or_where('text', 'LIKE', '%' . $q . '%')->where_lang(SITE_LANG)->where_is_valid(1)->get();
             foreach ($blogs as $key => $blog) {
                 foreach ($blog->pages as $page) {
                     $title = $blog->name;
                     $results[$tot + $key + 1]['source'] = LL('cms::label.blogs', SITE_LANG)->get();
                     $results[$tot + $key + 1]['title'] = $title;
                     $results[$tot + $key + 1]['slug'] = $page->slug . $blog->slug;
                     $results[$tot + $key + 1]['descr'] = $page->descr;
                 }
                 $tot++;
             }
         }
         $unique_results = array_unique($results, SORT_REGULAR);
         $count_results = count($unique_results);
         $output = array_slice($unique_results, $npp * $p - $npp, $npp);
         $paginate = Paginator::make($output, $count_results, $npp);
         //GET SEARCH RESULTS VIEW
         $search_results = Config::get('cms::theme.search_results');
         //LOAD VIEW
         $view = View::make('cms::theme.' . THEME . '.partials.' . $search_results);
         $view['results'] = $paginate;
         $view['q'] = $q;
         $view['source'] = $source;
         //LOAD ZONE TO INJECT IN
         $search_zone = Config::get('cms::theme.search_zone');
         //SEARCH PAGE DETAILS
         $search_template = Config::get('cms::theme.search_template');
         $search_header = Config::get('cms::theme.search_header');
         $search_footer = Config::get('cms::theme.search_footer');
         $search_layout = Config::get('cms::theme.search_layout');
         // RENDER THE PAGE
         CmsRender::page($url, array('template' => $search_template, 'header' => $search_header, 'footer' => $search_footer, 'layout' => $search_layout, 'zone' => $search_zone, 'view' => $view));
     } else {
         return Redirect::home();
     }
 }
コード例 #17
0
 public function get_login()
 {
     $html = View::make('cms::theme.' . THEME . '.templates.' . TEMPLATE)->with('title', LL('user.user_title', SITE_LANG))->with('keyw', 'login')->with('descr', 'login')->nest('header', 'cms::theme.' . THEME . '.partials.header_default')->nest('layout', 'cms::theme.' . THEME . '.user.login')->nest('footer', 'cms::theme.' . THEME . '.partials.footer_default');
     CmsRender::clean_code($html);
 }
コード例 #18
0
 public function get_filter($page_id = 0, $ext = null)
 {
     //LOAD FANCYBOX LIBS
     Asset::container('header')->add('fancyboxcss', 'bundles/cms/css/fancybox.css', 'main');
     Asset::container('footer')->add('fancybox', 'bundles/cms/js/jquery.fancybox.js', 'jquery');
     //LOAD JS LIBS
     Asset::container('footer')->add('ias', 'bundles/cms/js/jquery.ias.js', 'jquery');
     Asset::container('footer')->add('files', 'bundles/cms/js/sections/files_list.js', 'cms');
     $this->layout->header_data = array('title' => LL('cms::title.files', CMSLANG));
     $this->layout->top_data = array('search' => '/cms/file/search', 'q' => '');
     //ALLOWED EXTENSIONS
     $ext_str = str_replace(' ', '', Config::get('cms::settings.mimes'));
     $extensions = explode(',', $ext_str);
     $extensions_selected = !is_null($ext) ? explode('-', $ext) : array();
     //GET DATA
     $sign = $page_id == 0 ? '<>' : '=';
     $files = DB::table('files');
     $files->join('files_pages', 'files.id', '=', 'files_pages.cmsfile_id');
     // FILTER PAGE_ID
     $files->where('files_pages.cmspage_id', $sign, $page_id);
     // FILTER FILE EXTENSION
     foreach ($extensions_selected as $key => $exte) {
         if ($key === 0) {
             $files->where('ext', '=', $exte);
         } else {
             $files->or_where('ext', '=', $exte);
         }
     }
     // COUNT TOTAL RESULTS
     $count = $files->count();
     $files->group_by('name');
     $files->order_by('name', 'asc');
     $files->order_by('ext', 'asc');
     $files->order_by('size', 'desc');
     $data = $files->paginate(Config::get('cms::settings.pag'));
     $data->total = $count;
     $this->layout->content = View::make('cms::interface.pages.file_list')->with('data', $data)->with('page', $page_id)->with('ext', $ext)->with('extensions_selected', $extensions_selected)->with('extensions', $extensions);
 }
コード例 #19
0
 public function post_add_download()
 {
     $auth = Auth::check();
     if ($auth and is_numeric(AUTHORID)) {
         if (Input::get('download_id') !== '') {
             $fid = Input::get('file_id');
             $downloads = Input::get('download_id');
             if (is_array($downloads)) {
                 foreach ($downloads as $key => $gid) {
                     $check = DB::table('files_downloads')->where_cmsfile_id($fid)->where_cmsdownload_id($gid)->count();
                     if ($check == 0) {
                         $download = CmsDownload::find($gid);
                         $add_array = array('order_id' => Config::get('cms::settings.order'));
                         $download->files()->attach($fid, $add_array);
                     }
                 }
                 //DELETE NOT IN
                 DB::table('files_downloads')->where_cmsfile_id($fid)->where_not_in('cmsdownload_id', $downloads)->delete();
                 $response = 'success';
                 $msg = LL('cms::ajax_resp.download_save_success', CMSLANG)->get();
                 $backurl = Input::get('back_url');
             } else {
                 //DELETE ALL
                 DB::table('files_downloads')->where_cmsfile_id($fid)->delete();
                 $response = 'success';
                 $msg = LL('cms::ajax_resp.download_save_success', CMSLANG)->get();
                 $backurl = '#';
             }
         } else {
             $response = 'error';
             $msg = LL('cms::ajax_resp.download_save_error', CMSLANG)->get();
             $backurl = '#';
         }
     } else {
         $response = 'error';
         $msg = LL('cms::ajax_resp.download_save_error', CMSLANG)->get();
         $backurl = '#';
     }
     $data = array('auth' => $auth, 'cls' => 'file_id', 'id' => $fid, 'response' => $response, 'message' => $msg, 'backurl' => $backurl);
     return json_encode($data);
 }
コード例 #20
0
 public static function select_lang_translation()
 {
     $langs = Config::get('cms::settings.langs');
     $select = array('', LL('cms::form.page_select', CMSLANG));
     foreach ($langs as $key => $value) {
         if ($key != LANG) {
             $select[$key] = $value;
         }
     }
     return $select;
 }
コード例 #21
0
 public function post_save_password()
 {
     $auth = Auth::check();
     if ($auth) {
         $input = Input::get();
         //GRAB DATA
         if (!empty($input['user_id'])) {
             $user = CmsUser::find($input['user_id']);
             //VALIDATION CHECK
             $rules = array('user_password' => 'required|min:8|confirmed');
             $messages = array('required' => LL('cms::validation.required', CMSLANG)->get(), 'min' => LL('cms::validation.min.string', CMSLANG)->get(), 'confirmed' => LL('cms::validation.confirmed', CMSLANG)->get());
             $validation = Validator::make($input, $rules, $messages);
             if ($validation->fails()) {
                 return json_encode($validation->errors);
             }
             //VALIDATION OK
             $user->password = Hash::make($input['user_password']);
             $user->save();
             $uid = $user->id;
             $response = 'success';
             $msg = LL('cms::ajax_resp.user_password_success', CMSLANG)->get();
             $backurl = $input['back_url'];
         } else {
             $uid = null;
             $response = 'error';
             $msg = LL('cms::ajax_resp.user_nouser_error', CMSLANG)->get();
             $backurl = '#';
         }
     } else {
         $uid = null;
         $response = 'error';
         $msg = LL('cms::ajax_resp.user_password_error', CMSLANG)->get();
         $backurl = '#';
     }
     $data = array('auth' => $auth, 'cls' => 'user_id', 'id' => $uid, 'response' => $response, 'message' => $msg, 'backurl' => $backurl);
     return json_encode($data);
 }
コード例 #22
0
/**
 * Load label or value if label not present.
 *
 * @param  string  $where
 * @param  string  $what
 * @return string
 */
function LABEL($where, $what)
{
    return (strlen(LL($where . $what, CMSLANG)->get()) > 0 and strpos(LL($where . $what, CMSLANG)->get(), '::') == 0) ? LL($where . $what, CMSLANG) : $what;
}
コード例 #23
0
 /**
  * Render page template with all variables
  *
  * @return string
  */
 public static function page($slug = null, $inject = array())
 {
     // CHECK $slug IS NOT NULL
     $SLUG_FULL = is_null($slug) ? SLUG_FULL : $slug;
     // Page with lang = SITE_LANG and is_homepage = 1
     if ($SLUG_FULL === '/') {
         // HOMEPAGE
         $page = CmsPage::with(array('elements' => function ($query) {
             $query->where_is_valid(1);
         }))->where_lang(SITE_LANG)->where_is_valid(VALID())->first();
         if (empty($page)) {
             return Response::error('404');
         }
         // More pages with lang = SITE_LANG and slug = SLUG_FULL
     } else {
         // MORE PAGES
         // Check slug is not lang
         if (array_key_exists(str_replace('/', '', $SLUG_FULL), Config::get('cms::settings.langs'))) {
             //Redirect al cambio lingua
             return Redirect::to_action('site@lang', array(str_replace('/', '', $SLUG_FULL)));
         }
         // Get page
         $page = self::page_base($SLUG_FULL);
         // Check page exists
         if (empty($page)) {
             // If not exists, look at SLUG_FIRST and save SLUG_LAST
             $page = self::page_base(SLUG_FIRST);
             // Check page exists
             // Not exists
             if (empty($page)) {
                 return Response::error('404');
                 // It exists and it is a ZOOM of EXTRA
             } else {
                 // Get Model to load
                 switch (getExtra($page->extra_id)) {
                     case 'blogs':
                         $model = CmsBlog::with(array('blogrels'));
                         break;
                         //case 'products':
                         //	$model = 'CmsProduct';
                         //	break;
                 }
                 // Load ZOOM if $extra exists
                 if (isset($model)) {
                     $extra = $model->where_lang(SITE_LANG)->where_slug(SLUG_LAST)->where_is_valid(VALID())->first();
                 }
             }
         }
     }
     //Bind $elements / $extra to ZONE
     if (!empty($page)) {
         // Check if SITE_ROLE < access_level -> to_login
         if (SITE_ROLE < $page->access_level) {
             return Redirect::to_action('site@login')->with('back_url', $SLUG_FULL);
         }
         // Set page_layout from DB or default if not set
         $page_layout = $page->layout;
         if (empty($page->layout)) {
             $page_layout = 'default';
         }
         //INJECT PAGE LAYOUT
         if (!empty($inject)) {
             $page_layout = !empty($inject['layout']) ? $inject['layout'] : $page_layout;
         }
         // Get layouts from config.design
         $arr_layout = Config::get('cms::theme.layout_' . $page_layout);
         // Load template
         $layout = View::make('cms::theme.' . THEME . '.layouts.' . $page_layout);
         // Bind page name
         $layout['NAME'] = $page->name;
         $layout['CLASSNAME'] = Str::slug($page->name);
         // Check layout exists
         if (!empty($arr_layout)) {
             // Bind zones as empty to avoid errors
             foreach ($arr_layout as $key => $value) {
                 $layout[strtoupper($key)] = '';
             }
         }
         // Bind contents to layout variables
         if (!empty($page)) {
             // Bind elements to $ZONE in page layout
             if (!empty($page->elements)) {
                 // Create zone array
                 $zone = array();
                 foreach ($page->elements as $item) {
                     $tmp_text = '<div id="' . $item->name . '" class="' . Config::get('cms::theme.ele_class') . '">';
                     $tmp_text .= Marker::decode($item->text);
                     $tmp_text .= '</div>';
                     $zone[$item->zone][] = $tmp_text;
                 }
                 // INJECT EXTERNAL ELEMENT INTO ZONE
                 if (!empty($inject)) {
                     // Clean content
                     // unset($zone);
                     // Append results
                     $zone[$inject['zone']][0] = $inject['view'];
                 }
                 // Bind pageitem text to ZONE which become layout variable
                 foreach ($page->elements as $item) {
                     $layout[strtoupper($item->zone)] = trim(implode("\n", $zone[$item->zone]));
                 }
             } else {
                 $new_page = CmsPage::where_lang(SITE_LANG)->where_parent_id($page->id)->where_is_valid(1)->order_by('order_id', 'asc')->first();
                 if (!empty($new_page)) {
                     return Redirect::to($new_page->slug);
                 }
             }
             // Bind $extra to layout ZONE if present
             if (!empty($extra)) {
                 //EXTRA VIEW ZOOM
                 $extra_what = CONF('cms::settings.extra_id', $page->extra_id);
                 $tmp_text = View::make('cms::theme.' . THEME . '.partials.details.' . $extra_what);
                 $tmp_text['text'] = $extra;
                 // Bind extra name
                 $layout['NAME'] = $extra->name;
                 $layout['CLASSNAME'] = Str::slug($page->name);
                 // Bind pageitem text to ZONE which become layout variable
                 $layout[strtoupper($extra->zone)] = trim(implode("\n", array($tmp_text)));
             }
         }
     } else {
         // Page not found, empty layout
         $layout = '';
     }
     //Set default title
     $title = !empty($page->title) ? $page->title : $page->name;
     //Set $extra title
     $title = isset($extra) ? $extra->name : $title;
     $title = !empty($extra->title) ? $extra->title : $title;
     $title = CmsUtility::string_style($title, Config::get('cms::theme.title_style'));
     // Add preview string to title
     if (SLUG_PREVIEW) {
         $title = LL('cms::title.preview_title', CMSLANG) . $title;
     }
     //Set default keyw
     $keyw = !empty($page->keyw) ? $page->keyw : Config::get('cms::theme.keyw');
     //Set $extra keyw
     $keyw = isset($extra) ? $extra->keyw : $keyw;
     $keyw = !empty($extra->keyw) ? $extra->keyw : $keyw;
     //Set default descr
     $descr = !empty($page->descr) ? $page->descr : Config::get('cms::theme.descr');
     //Set $extra descr
     $descr = isset($extra) ? $extra->descr : $descr;
     $descr = !empty($extra->descr) ? $extra->descr : $descr;
     //Set default template, header, footer, layout se non settati
     $template = !empty($page->template) ? $page->template : 'default';
     $header = !empty($page->header) ? $page->header : 'default';
     $footer = !empty($page->footer) ? $page->footer : 'default';
     // INJECT PAGE PARTIALS
     if (!empty($inject)) {
         $template = !empty($inject['template']) ? $inject['template'] : $template;
         $header = !empty($inject['header']) ? $inject['header'] : $header;
         $footer = !empty($inject['footer']) ? $inject['footer'] : $footer;
     }
     //APPLICATION COMPOSER
     View::composer('cms::theme.' . THEME . '.templates.' . $template, function ($view) {
         CmsRender::asset();
         //BASE JS
         Asset::container('header')->add('base_js', Config::get('application.url') . '/site/js');
         if (!isset($view->title)) {
             $view->title = Config::get('cms::theme.title');
         }
         if (!isset($view->descr)) {
             $view->descr = Config::get('cms::theme.descr');
         }
         if (!isset($view->keyw)) {
             $view->keyw = Config::get('cms::theme.keyw');
         }
         if (!isset($view->header)) {
             $view->header = '';
         }
         if (!isset($view->layout)) {
             $view->layout = '';
         }
         if (!isset($view->footer)) {
             $view->footer = '';
         }
     });
     //Prepare html buffer
     $html = View::make('cms::theme.' . THEME . '.templates.' . $template)->with('title', $title)->with('keyw', $keyw)->with('descr', $descr)->nest('header', 'cms::theme.' . THEME . '.partials.header_' . $header)->with('layout', $layout)->nest('footer', 'cms::theme.' . THEME . '.partials.footer_' . $footer);
     //Output buffer
     self::clean_code($html);
 }
コード例 #24
0
 public function post_add_tags()
 {
     $auth = Auth::check();
     if ($auth and is_numeric(AUTHORID)) {
         $input = Input::get();
         //GRAB DATA
         $tag = new CmsTag();
         //VALIDATION CHECK
         $rules = array('tag_name' => 'required|between:2,20|unique_lang:,' . $input['tag_lang'] . ',tags,name');
         $messages = array('required' => LL('cms::validation.required', CMSLANG)->get(), 'between' => LL('cms::validation.between.string', CMSLANG)->get(), 'unique_lang' => LL('cms::validation.unique_lang', CMSLANG)->get());
         $validation = Validator::make($input, $rules, $messages);
         if ($validation->fails()) {
             return json_encode($validation->errors);
         }
         //VALIDATION OK
         $tag->name = $input['tag_name'];
         $tag->lang = $input['tag_lang'];
         $tag->save();
         $tid = $tag->id;
         $response = 'success';
         $msg = LL('cms::ajax_resp.tag_save_success', CMSLANG)->get();
         $backurl = '#';
     } else {
         $rid = null;
         $response = 'error';
         $msg = LL('cms::ajax_resp.tag_save_error', CMSLANG)->get();
         $backurl = '#';
     }
     $data = array('auth' => $auth, 'cls' => 'tag_id', 'id' => $tid, 'response' => $response, 'message' => $msg, 'backurl' => $backurl);
     return json_encode($data);
 }
コード例 #25
0
 public function get_delete_cache($pattern = '*')
 {
     if ($pattern != '*') {
         $pattern = $pattern . '*';
     }
     $files = glob(path('storage') . 'cache/' . $pattern);
     foreach ($files as $file) {
         //D($file);
         if ($file != '.gitignore') {
             unlink($file);
         }
     }
     Notification::success(LL('cms::alert.delete_cache_success', CMSLANG, array('cache' => $pattern)), 2500);
     return Redirect::to_action('cms::dashboard');
 }
コード例 #26
0
 public function post_save_element_text()
 {
     $auth = Auth::check();
     if ($auth) {
         $input = Input::get();
         //OWNERSHIP
         if (!empty($input['page_id'])) {
             //CHECK OWNERSHIP
             if (CmsRole::role_fail($input['page_id'])) {
                 $msg = array('noaccess' => LL('cms::ajax_resp.ownership_error', CMSLANG)->get());
                 return json_encode($msg);
             }
         }
         $element = new CmsElement();
         if (!empty($input['element_id'])) {
             $element = CmsElement::find($input['element_id']);
         }
         $element->author_id = AUTHORID;
         $element->text = $input['element_text'];
         $element->lang = LANG;
         $element->save();
         $eid = $element->id;
         $page_id = $input['page_id'];
         $page = CmsPage::find($page_id);
         //IF NEW ADD TO PIVOT TABLE
         if (empty($input['element_id'])) {
             $page->elements()->attach($eid);
         }
         $response = 'success';
         $msg = LL('cms::ajax_resp.element_success', CMSLANG)->get();
         $backurl = $input['back_url'];
     } else {
         $eid = null;
         $page_id = null;
         $response = 'error';
         $msg = LL('cms::ajax_resp.element_error', CMSLANG)->get();
         $backurl = '#';
     }
     $data = array('auth' => $auth, 'cls' => 'element_id', 'id' => $eid, 'pageid' => $page_id, 'response' => $response, 'message' => $msg, 'backurl' => $backurl);
     return json_encode($data);
 }
コード例 #27
0
 public function post_clone_element()
 {
     if (Input::has('page_id') and Input::has('element_id') and Input::has('newpage_id')) {
         $pid = Input::get('page_id');
         $nid = Input::get('newpage_id');
         $eid = Input::get('element_id');
         $now = date('Y-m-d H:i:s');
         if (Input::has('to_clone')) {
             //CREATE NEW ELEMENT
             //GET ELEMENT MODEL
             $element = CmsElement::find($eid);
             $new_element_attr = array('author_id' => AUTHORID, 'name' => $element->name, 'label' => $element->label, 'text' => $element->text, 'zone' => $element->zone, 'lang' => LANG, 'is_valid' => 0);
             $new_element = new CmsElement($new_element_attr);
             $page = CmsPage::find($nid);
             $page->elements()->insert($new_element);
         } else {
             //GET ELEMENT MODEL
             $element = CmsElement::find($eid);
             $clone_array = array('cmselement_id' => $eid, 'cmspage_id' => $nid, 'created_at' => $now, 'updated_at' => $now);
             DB::table('elements_pages')->insert($clone_array);
         }
         Notification::success(LL('cms::alert.clone_element_success', CMSLANG, array('element' => $element->name)), 1500);
         return Redirect::to_action('cms::page', array(LANG));
     } else {
         Notification::error(LL('cms::alert.clone_element_error', CMSLANG), 1500);
         return Redirect::to_action('cms::page', array(LANG));
     }
 }
コード例 #28
0
 /**
  * CRUMB Marker - Shows a BREADCRUMB style navigation menu
  *
  * [$CRUMB[{
  *	"home":"true",			=> OPTIONAL (default: true)	
  *	"separator":"<char>", 	=> OPTIONAL	
  *	"first":"false",		=> OPTIONAL (separator at start)
  *	"last":"false",			=> OPTIONAL (separator at the end)
  *	"label":""				=> OPTIONAL (default: cms::marker.crumb_here)
  *	"id":"<id>",			=> OPTIONAL (id of <ul>)
  *	"class":"<class>",		=> OPTIONAL (class of <ul>)
  *	"tpl":"<tpl_name>"		=> OPTIONAL (in /partials/markers)
  * }]]
  *
  * @param  array
  * @return string
  */
 public static function CRUMB($vars = array())
 {
     //Get variables from array $vars
     if (!empty($vars)) {
         extract($vars);
     }
     //Bind variables
     $_home = true;
     if (isset($home) and !empty($home) and $home == 'false') {
         $_home = false;
     }
     $_separator = '';
     if (isset($separator) and !empty($separator)) {
         $_separator = $separator;
     }
     $_first = false;
     if (isset($first) and !empty($first) and $first == 'true') {
         $_first = true;
     }
     $_last = false;
     if (isset($last) and !empty($last) and $last == 'true') {
         $_last = true;
     }
     $_label = LL('cms::marker.crumb_here', SITE_LANG)->get();
     if (isset($label) and !empty($label)) {
         $_label = $label;
     }
     $_id = null;
     if (isset($id) and !empty($id)) {
         $_id = $id;
     }
     $_class = 'crumb';
     if (isset($class) and !empty($class)) {
         $_class = $class;
     }
     $_tpl = 'crumb';
     if (isset($tpl) and !empty($tpl)) {
         $_tpl = $tpl;
     }
     if (!empty($_tpl)) {
         //CACHE DATA
         if (CACHE) {
             $menu = Cache::remember('menu_crumb_' . SITE_LANG, function () {
                 return $menu = CmsPage::where_lang(SITE_LANG)->get();
             }, 1440);
         } else {
             $menu = CmsPage::where_lang(SITE_LANG)->get();
         }
         //EXPLODE SLUG
         $slugs = explode('/', SLUG_FULL);
         $crumbs = array();
         $tmp_slug = '';
         if ($_home) {
             foreach ($menu as $item) {
                 if ($item->is_home == 1) {
                     $crumbs['/'] = $item->name;
                 }
             }
         }
         foreach ($slugs as $slug) {
             $tmp_slug = str_replace('//', '/', $tmp_slug . '/' . $slug);
             foreach ($menu as $item) {
                 if ($tmp_slug == $item->slug) {
                     $crumbs[$tmp_slug] = $item->name;
                 }
             }
         }
         if (count($slugs) > count($crumbs)) {
             $last_slug = SLUG_FULL;
             $crumbs[$last_slug] = $_label;
         }
     } else {
         $crumbs = array();
     }
     $options = array('id' => $_id, 'class' => $_class);
     $view = LOAD_VIEW($_tpl);
     $view['crumbs'] = $crumbs;
     $view['separator'] = $_separator;
     $view['first'] = $_first;
     $view['last'] = $_last;
     $view['options'] = HTML::attributes($options);
     return $view;
 }
コード例 #29
0
 public function post_delete()
 {
     if (Input::has('blog_id')) {
         $bid = Input::get('blog_id');
         $blog = CmsBlog::find($bid);
         //CHECK IF BLOG EXISTS
         if (!empty($blog)) {
             //OK, DELETE
             $blog->pages()->delete();
             $blog->delete();
             Notification::success(LL('cms::alert.delete_blog_success', CMSLANG, array('blog' => $blog->name)), 2500);
             return Redirect::to_action('cms::blog', array($blog->lang));
         } else {
             Notification::error(LL('cms::alert.delete_blog_error', CMSLANG), 2500);
             return Redirect::to_action('cms::blog', array(LANG));
         }
     } else {
         Notification::error(LL('cms::alert.delete_blog_error', CMSLANG), 2500);
         return Redirect::to_action('cms::blog', array(LANG));
     }
 }
コード例 #30
0
 public function action_search_tag()
 {
     $auth = Auth::check();
     if ($auth and is_numeric(AUTHORID)) {
         //LOAD JS LIBS
         Asset::container('footer')->add('ias', 'bundles/cms/js/jquery.ias.js', 'jquery');
         Asset::container('footer')->add('tags', 'bundles/cms/js/sections/tag_list.js', 'cms');
         if (Input::has('q')) {
             $q = Input::get('q');
             $this->layout->header_data = array('title' => $q);
             $this->layout->top_data = array('search' => '/cms/tag/search', 'q' => $q);
             //GET PAGE DATA
             $data = CmsTag::where('name', 'LIKE', '%' . $q . '%')->order_by('name', 'asc')->paginate(Config::get('cms::settings.pag'));
             $this->layout->content = View::make('cms::interface.pages.tag_list')->with('lang', '')->with('data', $data);
         } else {
             $this->layout->header_data = array('title' => LL('cms::title.users', CMSLANG));
             $this->layout->top_data = array('search' => '/cms/tag/search', 'q' => '');
             //GET ALL TAG DATA
             $data = CmsTag::where_lang(LANG)->order_by('name', 'asc')->paginate(Config::get('cms::settings.pag'));
             $this->layout->content = View::make('cms::interface.pages.tag_list')->with('data', $data)->with('lang', LANG);
         }
     }
 }