示例#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');
     //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('pages', 'bundles/cms/js/sections/pages_edit.js', 'cms');
     $this->layout->header_data = array('title' => LL('cms::title.page_edit', CMSLANG));
     $this->layout->top_data = array('search' => false);
     if (!empty($id)) {
         //GET SUBPAGES DATA
         $subpages = CmsPage::where_parent_id($id)->order_by('order_id', 'asc')->get();
         //GET PAGE DATA
         $page = CmsPage::with(array('files', 'pagerels'))->find($id);
         if (!empty($page)) {
             $arr_slugs = explode('/', $page->slug);
             $slug = '/' . end($arr_slugs);
             //GET PAGE DATA
             $pagedata = CmsPage::where_lang($page->lang)->where('id', '<>', $id)->where_parent_id(0)->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;
             }
             if (empty($new_data)) {
                 $new_data = array();
             }
             // LOAD LAYOUT PREVIEW
             $preview_layout = CmsPage::preview_layout_create($page->layout);
             $this->layout->content = View::make('cms::interface.pages.page_new_edit')->with('role_fail', CmsRole::role_fail($id))->with('title', LL('cms::title.page_edit', CMSLANG))->with('page_id', $id)->with('page_lang', $page->lang)->with('page_name', $page->name)->with('page_parent', CmsPage::select_top_slug($page->lang, $id))->with('page_parent_selected', $page->parent_id)->with('page_slug', str_replace('/', '', $slug))->with('page_parent_slug', str_replace($slug, '', $page->slug))->with('page_owner', CmsRole::select_edit_owners())->with('page_owner_selected', $page->role_id)->with('page_access', CmsRole::select_edit_access())->with('page_access_selected', $page->access_level)->with('page_extra', CmsPage::select_extra_id())->with('page_extra_selected', $page->extra_id)->with('page_is_home', (bool) $page->is_home)->with('page_is_valid', (bool) $page->is_valid)->with('page_template', Config::get('cms::theme.template'))->with('page_template_selected', $page->template)->with('page_header', Config::get('cms::theme.header'))->with('page_header_selected', $page->header)->with('page_layout', Config::get('cms::theme.layout'))->with('page_layout_selected', $page->layout)->with('page_footer', Config::get('cms::theme.footer'))->with('page_footer_selected', $page->footer)->with('page_layout_preview', $preview_layout)->with('page_title', $page->title)->with('page_preview', $page->preview)->with('page_keyw', $page->keyw)->with('page_descr', $page->descr)->with('subpages', $subpages)->with('files', $page->files)->with('pagedata', $new_data)->with('pagerels', $page->pagerels);
         } 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));
     }
 }