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 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/gallery_edit.js', 'cms');
     $this->layout->header_data = array('title' => LL('cms::title.gallery_edit', CMSLANG));
     $this->layout->top_data = array('search' => false);
     //GET GALLERY DATA
     $gallery = CmsGallery::with(array('files'))->find($id);
     $this->layout->content = View::make('cms::interface.pages.gallery_new_edit')->with('title', LL('cms::title.gallery_edit', CMSLANG))->with('gallery_id', $id)->with('gallery_name', $gallery->name)->with('gallery_thumb', $gallery->thumb)->with('gallery_thumbs', CmsGallery::select_thumb())->with('files', $gallery->files);
 }
 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);
 }
 /**
  * GALLERY Marker - Shows an image gallery saved in Service / Gallery
  *
  * [$GALLERY[{
  *	"name":"<gallery name>",
  *	"wm":"true | false",	=> OPTIONAL
  *	"class":"<class>",		=> OPTIONAL
  *	"tpl":"<tpl_name>"		=> OPTIONAL (in /partials/markers)
  * }]]
  *
  * @param  array
  * @return string
  */
 public static function GALLERY($vars = array())
 {
     //Get variables from array $vars
     if (!empty($vars)) {
         extract($vars);
     }
     //Bind variables
     $_name = '';
     if (isset($name) and !empty($name)) {
         $_name = $name;
     }
     $_wm = 'no';
     if (isset($wm) and !empty($wm) and $wm == 'true') {
         $_wm = 'wm';
     }
     $_class = 'gallery unstyled';
     if (isset($class) and !empty($class)) {
         $_class = $class;
     }
     $_tpl = 'gallery';
     if (isset($tpl) and !empty($tpl)) {
         $_tpl = $tpl;
     }
     //Get DB information
     if (!empty($_name)) {
         //CACHE DATA
         if (CACHE) {
             $gallery = Cache::remember('img_gallery_' . $_name, function () use($_name) {
                 return CmsGallery::with(array('files'))->where_name($_name)->first();
             }, 1440);
         } else {
             $gallery = CmsGallery::with(array('files'))->where_name($_name)->first();
         }
         //Load file lable and title
         if (!empty($gallery->files)) {
             $images = $gallery->files;
             $thumb = $gallery->thumb;
         } else {
             $images = array();
             $thumb = 'thumb';
         }
     } else {
         $images = array();
         $thumb = 'thumb';
     }
     $options = array('id' => $_name, 'class' => $_class);
     $view = LOAD_VIEW($_tpl);
     $view['images'] = $images;
     $view['thumb'] = $thumb;
     $view['wm'] = $_wm == 'wm' ? 'true' : 'no';
     $view['options'] = HTML::attributes($options);
     return $view;
 }