Ejemplo n.º 1
0
 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);
         }
     }
 }
 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);
 }
Ejemplo n.º 3
0
 public function get_edit_element($page_id, $element_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('slug', 'bundles/cms/js/jquery.stringtoslug.js', 'jquery');
     //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');
     //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('elements', 'bundles/cms/js/sections/elements_edit.js', 'cms');
     $this->layout->header_data = array('title' => LL('cms::title.element_edit', CMSLANG));
     $this->layout->top_data = array('search' => false);
     if (!empty($element_id)) {
         //GET ELEMENT DATA
         $element = CmsElement::find($element_id);
         if (!empty($element)) {
             //GET PAGE DATA
             $page = CmsPage::find($page_id);
             //GET ELEMENTS DATA
             $elements = $page->elements;
             //GET FILE DATA
             $files = $page->files;
             // LOAD LAYOUT PREVIEW
             $preview_layout = CmsPage::preview_layout_create($page->layout);
             $this->layout->content = View::make('cms::interface.pages.element_new_edit')->with('role_fail', CmsRole::role_fail($page_id))->with('title', LL('cms::title.element_edit', CMSLANG))->with('page_id', $page_id)->with('element_id', $element_id)->with('element_name', $element->name)->with('element_label', $element->label)->with('element_text', $element->text)->with('element_zones', CmsElement::select_zone($page_id))->with('element_zone_selected', $element->zone)->with('element_is_valid', (bool) $element->is_valid)->with('elements', $elements)->with('media', $files)->with('page_header_selected', $page->header)->with('page_footer_selected', $page->footer)->with('page_layout_preview', $preview_layout);
         } else {
             $this->layout->content = View::make('cms::interface.pages.not_found')->with('message', LL('cms::alert.not_found', CMSLANG));
         }
     } else {
         $this->layout->content = View::make('cms::interface.pages.not_found')->with('message', LL('cms::alert.not_found', CMSLANG));
     }
 }
Ejemplo n.º 4
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);
 }