public function get_edit($id) { //SORTING Asset::container('footer')->add('sortable', 'bundles/cms/js/jquery.sortable.js', 'jquery'); Asset::container('footer')->add('serialize', 'bundles/cms/js/jquery.serializetree.js', 'sortable'); //LOAD JS LIBS Asset::container('footer')->add('form', 'bundles/cms/js/jquery.form.js', 'jquery'); Asset::container('footer')->add('files', 'bundles/cms/js/sections/menus_edit.js', 'cms'); $this->layout->header_data = array('title' => LL('cms::title.menu_edit', CMSLANG)); $this->layout->top_data = array('search' => false); //GET MENU DATA $menu = CmsMenu::find($id); //GET PAGE DATA $data = CmsPage::with(array('menus'))->where_lang($menu->lang)->where_parent_id(0)->order_by('lang', 'asc')->order_by('is_home', 'desc')->order_by('order_id', 'asc')->get(); $new_data = array(); foreach ($data as $obj) { $new_data[$obj->id] = $obj; $recursive = call_user_func_array('CmsPage::recursive_menuspages', array($obj->id)); $new_data = $new_data + $recursive; } if (empty($new_data)) { $new_data = array(); } //GET PAGES IN MENU $pages = CmsMenu::find($id)->pages; $this->layout->content = View::make('cms::interface.pages.menu_new_edit')->with('title', LL('cms::title.menu_edit', CMSLANG))->with('menu_id', $id)->with('menu_name', $menu->name)->with('menu_lang', $menu->lang)->with('menu_is_nested', (bool) $menu->is_nested)->with('menu_parent_start', CmsPage::select_top_slug($menu->lang, 0, true))->with('menu_parent_start_selected', $menu->parent_start)->with('pages', $pages)->with('menu_pages', $new_data); }
private function contact() { $isSent = Request::get(0, VAR_URI) == 'send'; $options = array('name' => array(Validator::MESSAGE => 'Der Name muss mindestens 5 und darf maximal 150 Zeichen lang sein.', Validator::MIN_LENGTH => 5, Validator::MAX_LENGTH => 150), 'email' => array(Validator::MESSAGE => 'Die E-Mail-Adresse ist nicht korrekt.', Validator::CALLBACK => Validator::CB_MAIL), 'message' => array(Validator::MESSAGE => 'Die Nachricht entspricht nicht den Vorgaben (mindestens 10 Zeichen, maximal 1000 Zeichen).', Validator::MIN_LENGTH => 10, Validator::MAX_LENGTH => 1000), 'title' => array(Validator::MESSAGE => 'Der Titel entspricht nicht den Vorgaben (mindestens 5 Zeichen, maximal 100 Zeichen).', Validator::MIN_LENGTH => 5, Validator::MAX_LENGTH => 100)); $this->enableClientFormValidation($options); // Don't validate the captcha via ajax as the session would end if (Config::get('captcha.enable')) { Core::loadClass('Core.Security.ReCaptcha'); $options['recaptcha_response_field'] = array(Validator::MESSAGE => 'Der Sicherheitscode wurde nicht korrekt eingegeben.', Validator::CALLBACK => 'cb_captcha_check'); } $data = array_fill_keys(array_keys($options), ''); $data['name'] = iif(Me::get()->loggedIn(), Me::get()->getName()); $data['email'] = iif(Me::get()->loggedIn(), Me::get()->getEmail()); $this->breadcrumb->add('Kontakt'); $this->header(); if ($isSent) { extract(Validator::checkRequest($options)); if (count($error) > 0) { CmsPage::error($error); } else { CmsTools::sendMail(Config::get('general.email'), $data['title'], $data['message'], $data['email'], $data['name']); CmsPage::ok('Die Anfrage wurde erfolgreich verschickt. Vielen Dank!'); $data['title'] = ''; $data['message'] = ''; } } $tpl = Response::getObject()->appendTemplate('Cms/contact/contact'); $tpl->assign('data', $data); if (Config::get('captcha.enable')) { $tpl->assign('captcha', recaptcha_get_html(Config::get('captcha.public_key')), false); } $tpl->output(); $this->footer(); }
/** * Lists all models. */ public function actionIndex() { $dataProvider = new CActiveDataProvider('CmsPage'); $this->render('index', array('dataProvider' => $dataProvider)); } /**
public static function menu($position) { $model = self::model()->findAllByAttributes(array('position' => $position)); $array = array(); foreach ($model as $one) { $array[] = array('label' => $one->title, 'url' => array('/page/index/id/' . $one->id), 'icon' => 'fa fa-arrow-right fa-border fa-2x', 'data' => CmsPage::model()->countByAttributes(array('category_id' => $one->id, 'status' => 2))); } return $array; }
/** * This is the default 'index' action that is invoked * when an action is not explicitly requested by users. */ public function actionIndex() { $criteria = new CDbCriteria(); $criteria->order = 'created DESC'; $criteria->compare('status', 2); $criteria->limit = 4; $model = CmsPage::model()->findAll($criteria); $this->render('index', array('model' => $model)); }
public function route() { if (Me::get()->isAllowed('admin')) { parent::route(); } else { parent::header(); CmsPage::error("Sie sind nicht berechtigt den Administrationsbereich zu betreten."); parent::footer(); } }
public static function role_fail($page_id) { $role = CmsPage::find($page_id)->role_level; if (!is_null($role)) { if ($role > ROLE) { return true; } } return false; }
public function loadModel($id) { $criteria = new CDbCriteria(); $criteria = "id=:id"; $criteria->params = array(':id' => $id); $model = CmsPage::model()->find($criteria); if ($model === null) { throw new CHttpException(404, 'The requested page does not exist.'); } return $model; }
public function parseUrl($request) { $searchPaths = array($request->pathInfo); // Also search for paths that end with the wildcard "*" (e.g. with news details) if ($lastPathSeparatorPos = strrpos($request->pathInfo, '/')) { $searchPaths[] = substr($request->pathInfo, 0, $lastPathSeparatorPos + 1) . '*'; } $page = CmsPage::model()->findByAttributes(array('path' => $searchPaths)); if ($page !== null) { return 'cms/page/default/id/' . $page->id; } return parent::parseUrl($request); }
function get_child_pages ($slug) { $this->load_model('CmsPage'); $page = CmsPage::meta()->one(array('slug' => $slug)); if (!$page) { return array(); } return CmsPage::meta()->filter(array('visible' => true))->all(array('parent' => $page->id)); }
public static function ar_kol($id_user) { $model = CmsPage::model()->findAllByAttributes(array('user_id' => array($id_user))); $ar = array(); $rr = date_parse(date("j.m.Y.H:i", time())); for ($i = 0; $i < $rr['month']; $i++) { $ar[$i] = 0; } foreach ($model as $one) { $rr = date_parse(date("j.m.Y.H:i", $one->created)); $ar[$rr['month'] - 1]++; } return $ar; }
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); }
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; }
public function actionDefault($id) { $this->page = CmsPage::model()->findByPk($id); $this->layout = $this->page->layout; $this->contents = $this->page->getContents(); if ($this->adminMode) { Yii::app()->clientScript->registerCoreScript('jquery'); $assetsUrl = Yii::app()->assetManager->publish(Yii::getPathOfAlias('cms.assets.admin'), false, -1, true); Yii::app()->clientScript->registerCssFile($assetsUrl . '/lib/jquery-ui/css/smoothness/jquery-ui.css'); Yii::app()->clientScript->registerScriptFile($assetsUrl . '/lib/jquery-ui/js/jquery-ui.min.js'); Yii::app()->clientScript->registerCssFile($assetsUrl . '/css/admin.css'); Yii::app()->clientScript->registerScriptFile($assetsUrl . '/js/admin.js'); } $this->render('/blank'); }
function getContent() { $xml = ''; $xml .= '<?xml version="1.0" encoding="UTF-8"?>'; $xml .= '<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">'; //root $xml .= $this->buildUrlTag('/'); //cms pages $pages = CmsPage::GetAll(array('partnerCode' => Application::PARTNER_CODE, 'statusCode' => CmsPageStatus::PUBLISHED)); foreach ($pages as $page) { $xml .= $this->buildUrlTag($page->getPath(), $page->getUpdated()); } //done $xml .= '</urlset>'; return $xml; }
public function get_sitemap($lang = LANG) { //GET PAGE DATA $data = CmsPage::with(array('files' => function ($query) { $query->where_is_image(1)->where_is_valid(1); }))->where_parent_id(0)->where_lang($lang)->order_by('is_home', 'desc')->order_by('slug', 'asc')->get(); $new_data = array(); foreach ($data as $value) { $new_data[$value->id] = $value; } foreach ($new_data as $page) { $recursive = call_user_func_array('CmsPage::recursive_site_sitemap', array($page->id)); $new_data = array_insert($new_data, $page->id, $recursive); } $view = View::make('cms::theme.' . THEME . '.templates.sitemap')->with('encoding', '<?xml version="1.0" encoding="UTF-8" ?>')->with('base', Config::get('application.url'))->with('data', $new_data); $headers = array('Content-Type' => 'text/xml'); return Response::make($view, 200, $headers); }
public function get_edit($id) { //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('form', 'bundles/cms/js/jquery.form.js', 'jquery'); Asset::container('footer')->add('files', 'bundles/cms/js/sections/files_edit.js', 'cms'); $this->layout->header_data = array('title' => LL('cms::title.file_edit', CMSLANG)); $this->layout->top_data = array('search' => false); //GET FILE DATA $file = CmsFile::with(array('pages', 'filetexts' => function ($query) { $query->where('lang', '=', LANG); }))->where_id($id)->first(); if (!empty($file->filetexts)) { foreach ($file->filetexts as $text) { $filetext_alt = !empty($text) ? $text->alt : ''; $filetext_title = !empty($text) ? $text->title : ''; $filetext_caption = !empty($text) ? $text->caption : ''; $filetext_label = !empty($text) ? $text->label : ''; } } else { $filetext_alt = ''; $filetext_title = ''; $filetext_caption = ''; $filetext_label = ''; } //GET PAGE DATA $data = CmsPage::with(array('files'))->where_parent_id(0)->order_by('lang', 'asc')->order_by('is_home', 'desc')->order_by('order_id', 'asc')->get(); $banners = CmsBanner::with(array('files'))->order_by('lang', 'asc')->get(); $galleries = CmsGallery::with(array('files'))->get(); $downloads = CmsDownload::with(array('files'))->get(); //GET SITEMAP ORDER $new_data = array(); foreach ($data as $obj) { $new_data[$obj->id] = $obj; $recursive = call_user_func_array('CmsPage::recursive_filespages', array($obj->id)); $new_data = $new_data + $recursive; } if (empty($new_data)) { $new_data = array(); } $this->layout->content = View::make('cms::interface.pages.file_edit')->with('title', LL('cms::title.file_edit', CMSLANG))->with('file_id', $id)->with('is_image', (bool) $file->is_image)->with('file_path', $file->path)->with('file_name', $file->name)->with('file_thumb', $file->thumb)->with('file_ext', $file->ext)->with('file_pages', $new_data)->with('langs', Config::get('cms::settings.langs'))->with('filetext_title', $filetext_title)->with('filetext_alt', $filetext_alt)->with('filetext_caption', $filetext_caption)->with('filetext_label', $filetext_label)->with('banners', $banners)->with('galleries', $galleries)->with('downloads', $downloads); }
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'); } }
public function write() { $db = Database::getObject(); $id = Request::get(1, VAR_INT); $action = Request::get(2, VAR_URI); $options = array('title' => array(Validator::MESSAGE => 'Der Name muss mindestens 2 und darf maximal 255 Zeichen lang sein.', Validator::MIN_LENGTH => 2, Validator::MAX_LENGTH => 255), 'uri' => array(Validator::MULTIPLE => array(array(Validator::MESSAGE => 'Die URI enthält Zeichen die nicht erlaubt sind. Erlaubt sind: a-z, 0-9, _, -', Validator::REGEXP => '/^[\\w\\d\\-]*$/i'), array(Validator::MESSAGE => 'Die angegebene URI existiert bereits für eine andere Seite.', Validator::CLOSURE => function ($uri) use($db, $id) { $db->query("SELECT uri FROM <p>page WHERE id != <id:int> AND uri = <uri>", compact("id", "uri")); return $db->numRows() == 0; }))), 'content' => array(Validator::OPTIONAL => true)); $this->breadcrumb->add(iif($id > 0, "Bearbeiten", "Hinzufügen")); $this->scriptFiles[URI::build('client/scripts/wymeditor/jquery.wymeditor.js')] = 'text/javascript'; $this->header(); $data = array('id' => $id, 'title' => '', 'uri' => '', 'content' => ''); if ($action == 'send') { extract(Validator::checkRequest($options)); $data['id'] = $id; if (count($error) > 0) { CmsPage::error($error); } else { if ($id > 0) { $db->query("UPDATE <p>page SET title = <title>, uri = <uri>, content = <content> WHERE id = <id:int>", $data); } else { $db->query("INSERT INTO <p>page SET title = <title>, uri = <uri>, content = <content>", $data); $data['id'] = $db->insertId(); } CmsPage::ok("Die Seite wurde erfolgreich gespeichert."); } } else { if ($id > 0) { $db->query("SELECT id, title, uri, content FROM <p>page WHERE id = <id:int>", compact("id")); if ($db->numRows() == 1) { $data = $db->fetchAssoc(); } } } $tpl = Response::getObject()->appendTemplate('Cms/admin/docs_write'); $tpl->assign('data', $data); $tpl->output(); $this->footer(); }
public function edit() { $id = Request::get(1, VAR_INT, 0); $action = Request::get(2, VAR_URI); $this->breadcrumb->add(iif($id > 0, "Bearbeiten", "Hinzufügen")); $this->header(); $db = Database::getObject(); $data = array('id' => $id, 'flughafen' => '', 'code' => '', 'land' => '', 'stadt' => ''); if ($action == 'send') { $options = array('flughafen' => array(Validator::MESSAGE => 'Der Name muss mindestens 2 und darf maximal 128 Zeichen lang sein.', Validator::MIN_LENGTH => 2, Validator::MAX_LENGTH => 128), 'code' => array(Validator::MESSAGE => 'Der Code muss genau 3 Zeichen lang sein.', Validator::LENGTH => 3), 'land' => array(Validator::MESSAGE => 'Der Name muss mindestens 2 und darf maximal 64 Zeichen lang sein.', Validator::MIN_LENGTH => 2, Validator::MAX_LENGTH => 64), 'stadt' => array(Validator::MESSAGE => 'Der Name muss mindestens 2 und darf maximal 96 Zeichen lang sein.', Validator::MIN_LENGTH => 2, Validator::MAX_LENGTH => 96)); extract(Validator::checkRequest($options)); $data['id'] = $id; if (count($error) > 0) { CmsPage::error($error); } else { if ($id > 0) { $db->query("UPDATE <p>airports SET flughafen = <flughafen>, land = <land>, stadt = <stadt>, code = <code> WHERE id = <id:int>", $data); } else { $db->query("INSERT INTO <p>airports SET flughafen = <flughafen>, land = <land>, stadt = <stadt>, code = <code>", $data); $data['id'] = $db->insertId(); } CmsPage::ok("Der Airport wurde erfolgreich gespeichert."); } } else { if ($id > 0) { $db->query("SELECT * FROM <p>airports WHERE id = <id:int>", compact("id")); if ($db->numRows() == 1) { $data = $db->fetchAssoc(); } } } $tpl = Response::getObject()->appendTemplate('Airlines/admin/airports_edit'); $tpl->assign('data', $data); $tpl->output(); $this->footer(); }
public function actionView($id) { $model = CmsPage::model()->findByPk($id); $model1 = new CmsComment(); $ar = $model1->getCommentsTree($id); if (isset($_POST['CmsComment'])) { $model1->page_id = $id; if (!Yii::app()->user->isGuest) { $model1->user_id = Yii::app()->user->id; } // esli polzovatel ne gost tokda soxranaem ego id $model1->attributes = $_POST['CmsComment']; if ($model1->save()) { if ($model1->parent_id != null && !Yii::app()->user->isGuest) { CmsComment::sendOtvet($model1->parent_id); } $this->refresh(); } } if (Yii::app()->user->isGuest) { $model1->scenario = 'ComSet'; } $this->render('view', array('model1' => $model1, 'model' => $model, 'comments' => $ar)); }
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); }
public function get_edit($id) { //LOAD JS LIBS Asset::container('footer')->add('form', 'bundles/cms/js/jquery.form.js', 'jquery'); Asset::container('footer')->add('count', 'bundles/cms/js/jquery.charcount.js', 'jquery'); Asset::container('footer')->add('elastic', 'bundles/cms/js/jquery.elastic.js', 'jquery'); Asset::container('footer')->add('slug', 'bundles/cms/js/jquery.stringtoslug.js', 'jquery'); Asset::container('footer')->add('ckcms', 'bundles/cms/js/ck.cms.js', 'jqadapter'); //CKEDITOR if (IS('cms::settings.wysiwyg', 'ckeditor')) { Asset::container('footer')->add('ckeditor', 'bundles/cms/ckeditor/ckeditor.js', 'form'); Asset::container('footer')->add('jqadapter', 'bundles/cms/ckeditor/adapters/jquery.js', 'form'); Asset::container('footer')->add('ckcms', 'bundles/cms/js/ck.cms.js', 'jqadapter'); } //MARKITUP if (IS('cms::settings.wysiwyg', 'markitup')) { Asset::container('footer')->add('markitup', 'bundles/cms/markitup/jquery.markitup.js', 'form'); Asset::container('footer')->add('sethtml', 'bundles/cms/markitup/sets/html/set.js', 'markitup'); Asset::container('footer')->add('ckcms', 'bundles/cms/js/ck.cms.js', 'jqadapter'); Asset::container('header')->add('csshtml', 'bundles/cms/markitup/sets/html/style.css'); Asset::container('header')->add('cssmarkitup', 'bundles/cms/markitup/skins/markitup/style.css'); } //PLUPLOAD Asset::container('footer')->add('plupload', 'bundles/cms/js/plupload.js', 'jquery'); Asset::container('footer')->add('plupload_html4', 'bundles/cms/js/plupload.html4.js', 'plupload'); Asset::container('footer')->add('plupload_html5', 'bundles/cms/js/plupload.html5.js', 'plupload'); //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 AUTOSUGGEST LIBS Asset::container('header')->add('autosuggestcss', 'bundles/cms/css/autosuggest.css', 'main'); Asset::container('footer')->add('autosuggest', 'bundles/cms/js/jquery.autosuggest.js', 'jquery'); //DATETIME PICKER Asset::container('header')->add('jqueryuicss', 'bundles/cms/css/jquery.ui.css', 'main'); if (LANG !== 'en') { Asset::container('footer')->add('local', 'bundles/cms/js/i18n/jquery.ui.datepicker-' . LANG . '.js', 'jquery'); } Asset::container('footer')->add('datepicker', 'bundles/cms/js/jquery.datepicker.js', 'local'); Asset::container('footer')->add('timepicker', 'bundles/cms/js/jquery.timepicker.js', 'datepicker'); //SORTING Asset::container('footer')->add('sortable', 'bundles/cms/js/jquery.sortable.js', 'jquery'); Asset::container('footer')->add('serialize', 'bundles/cms/js/jquery.serializetree.js', 'sortable'); Asset::container('footer')->add('pages', 'bundles/cms/js/sections/blogs_edit.js', 'cms'); $this->layout->header_data = array('title' => LL('cms::title.blog_edit', CMSLANG)); $this->layout->top_data = array('search' => false); if (!empty($id)) { //GET BLOG DATA $blog = CmsBlog::with(array('pages', 'blogrels'))->find($id); $pivot = DB::table('blogs_pages')->where_cmsblog_id($id)->where_is_default(1)->first(); //FILES OF PAGE $files = CmsPage::find($pivot->cmspage_id)->files; if (!empty($blog)) { //GET EXTRA ID $extra_ids = Config::get('cms::settings.extra_id'); //GET PAGE DATA $pagedata = CmsPage::where_lang($blog->lang)->where_parent_id(0)->where_extra_id(array_search('blogs', $extra_ids))->order_by('lang', 'asc')->order_by('is_home', 'desc')->order_by('order_id', 'asc')->get(); $new_data = array(); foreach ($pagedata as $obj) { $new_data[$obj->id] = $obj; $recursive = call_user_func_array('CmsPage::recursive_pages', array($obj->id)); $new_data = $new_data + $recursive; } //GET BLOG DATA $blogdata = CmsBlog::where_lang($blog->lang)->where('id', '<>', $id)->where_is_valid(1)->order_by('datetime_on', 'desc')->order_by('name', 'desc')->paginate(Config::get('cms::settings.pag')); if (empty($new_data)) { $new_data = array(); } $this->layout->content = View::make('cms::interface.pages.blog_new_edit')->with('role_fail', CmsRole::role_fail($pivot->cmspage_id))->with('title', LL('cms::title.blog_edit', CMSLANG))->with('blog_id', $id)->with('page_id', $pivot->cmspage_id)->with('blog_lang', $blog->lang)->with('blog_name', $blog->name)->with('blog_parent', CmsPage::select_page_slug($blog->lang, array_search('blogs', $extra_ids)))->with('blog_parent_selected', $pivot->cmspage_id)->with('blog_slug', substr($blog->slug, 1))->with('blog_parent_slug', CmsPage::get_page_slug($pivot->cmspage_id) . '/')->with('blog_zones', CmsElement::select_zone($pivot->cmspage_id))->with('blog_zone_selected', $blog->zone)->with('blog_is_valid', (bool) $blog->is_valid)->with('blog_date_on', $blog->get_datetime_on())->with('blog_date_off', $blog->get_datetime_off())->with('blog_title', $blog->title)->with('blog_preview', $blog->preview)->with('blog_text', $blog->text)->with('blog_keyw', $blog->keyw)->with('blog_descr', $blog->descr)->with('blog_tags', '')->with('files', $files)->with('pagedata', $new_data)->with('pagerels', $blog->pages)->with('blogdata', $blogdata)->with('blogrels', $blog->blogrels); } } }
$page_lang = $parameters[1]; $table = $parameters[2]; if (isset($parameters[3])) { $attribute = $parameters[3]; } $query = DB::table($table)->where($attribute, '=', $value)->where('lang', '=', $page_lang)->where('id', '<>', $page_id); return $query->count() == 0; }); Validator::register('unique_element_page', function ($attribute, $value, $parameters) { //CHECK UNIQUENESS OF ELEMENT NAME IN A PAGE $page_id = $parameters[0]; $element_id = $parameters[1]; if (isset($parameters[2])) { $attribute = $parameters[2]; } $elements = CmsPage::find($page_id)->elements()->where('cmselement_id', '<>', $element_id)->where($attribute, '=', $value)->count(); return $elements == 0; }); Validator::register('unique_file', function ($attribute, $value, $parameters) { //CHECK UNIQUENESS OF FILE NAME ON DISK $file_name = $parameters[0]; $path = $parameters[1]; // CHECK DB NAME $query = CmsFile::where_name($file_name); return !file_exists(path('public') . $path . $file_name) and $query->count() == 0; }); Validator::register('unique_filename', function ($attribute, $value, $parameters) { //CHECK UNIQUENESS OF FILE NAME $ext = $parameters[0]; if (isset($parameters[1])) { $attribute = $parameters[1];
/** * @return \yii\db\ActiveQuery */ public function getCmsPages() { return $this->hasMany(CmsPage::className(), ['cms_layout_id' => 'id']); }
public function post_popover_details() { $auth = Auth::check(); if ($auth) { if (Input::has('id')) { $pid = Input::get('id'); //CACHE DATA if (CACHE) { $page = Cache::remember('page_' . $pid . '_details', function () use($pid) { return CmsPage::with(array('user', 'pagerels', 'elements'))->find($pid); }, 60); } else { $page = CmsPage::with(array('user', 'pagerels', 'elements'))->find($pid); } return View::make('cms::interface.partials.page_details')->with('author', $page->user->username)->with('created_at', $page->created_date)->with('updated_at', $page->updated_date)->with('header', $page->header)->with('layout', $page->layout)->with('footer', $page->footer)->with('is_valid', (bool) $page->is_valid)->with('lang', $page->lang)->with('elements', $page->elements)->with('pagerels', $page->pagerels); } } }
public function actionIndex($key) { $page = CmsPage::model()->findByAttributes(array('Key' => $key)); $this->render('index', array('page' => $page)); }
function page ($path, $context = array()) { $cms_page = self::get_page($path); $slug = $cms_page->slug; $pk_lookup = array('parent' => $cms_page->get_pk()); Frix::model('cms', 'CmsFile'); Frix::model('cms', 'CmsImage'); Frix::model('cms', 'CmsVideo'); $context += array( 'cms_page' => $cms_page, 'cms_files' => CmsFile::meta()->all($pk_lookup), 'cms_images' => CmsImage::meta()->all($pk_lookup), 'cms_videos' => CmsVideo::meta()->all($pk_lookup), 'cms_pages' => CmsPage::meta()->filter(array('visible' => True))->all($pk_lookup), 'body_attrs' => array('id' => $slug), ); $t = new Template('cms/custom/' . $slug, 'cms/page'); echo $t->render($context); }
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); }
public function post_save_post() { $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); } } //VALIDATION CHECK $rules = array('blog_name' => 'required|between:2,90|unique_lang:' . $input['blog_id'] . ',' . $input['blog_lang'] . ',blogs,name', 'blog_parent' => 'not_in:0', 'blog_slug' => 'required|alpha_slug|unique_slug:blogs,' . $input['blog_lang'] . ',,' . $input['blog_id'], 'blog_date_on' => 'required|valid_datetime', 'blog_date_off' => 'valid_datetime', 'blog_zone' => 'not_in:0'); $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(), 'unique_slug' => LL('cms::validation.unique_slug', CMSLANG)->get(), 'alpha_slug' => LL('cms::validation.alpha_slug', CMSLANG)->get(), 'valid_datetime' => LL('cms::validation.valid_datetime', 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 $blog->author_id = AUTHORID; $blog->lang = $input['blog_lang']; $blog->name = $input['blog_name']; $slug = '/' . $input['blog_slug']; $parent_slug = empty($input['blog_parent_slug']) ? '/' : str_replace('//', '/', $input['blog_parent_slug']); $blog->slug = $slug; //SET PERMISSION LIKE PARENT PAGE $page = CmsPage::find($input['blog_parent']); $blog->role_id = $page->role_id; $blog->role_level = $page->role_level; $blog->text = PRETEXT($input['blog_text']); $blog->datetime_on = dateTime2Db($input['blog_date_on']); if (Input::has('blog_date_off')) { $blog->datetime_off = dateTime2Db($input['blog_date_off']); } else { $blog->datetime_off = dateTimeFuture(dateTime2Db($input['blog_date_on']), 'P2Y'); } $blog->zone = $input['blog_zone']; $blog->is_valid = Input::has('is_valid') ? 1 : 0; $blog->save(); $bid = $blog->id; $response = 'success'; $msg = LL('cms::ajax_resp.blog_post_success', CMSLANG)->get(); $backurl = $input['back_url']; $full_slug = str_replace('//', '/', $parent_slug . $slug); $pid = $input['blog_parent']; $now = date('Y-m-d H:i:s'); //SYNC PIVOT TABLE //NEW BLOG if (!Input::has('blog_id')) { //INSERT TO PIVOT $blog->pages()->attach($pid, array('is_default' => 1)); //UPDATE BLOG } else { //SET PAGE_ID WHERE IS_DEFAULT = 1 DB::table('blogs_pages')->where_cmsblog_id($bid)->where_is_default(1)->update(array('cmspage_id' => $pid)); } } else { $bid = null; $pid = null; $response = 'error'; $msg = LL('cms::ajax_resp.blog_post_error', CMSLANG)->get(); $backurl = '#'; $full_slug = ''; } $data = array('auth' => $auth, 'cls' => 'blog_id', 'id' => $bid, 'pageid' => $pid, 'full_slug' => $full_slug, 'response' => $response, 'message' => $msg, 'backurl' => $backurl); return json_encode($data); }