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');
     //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');
     //LOAD JS LIBS
     Asset::container('footer')->add('form', 'bundles/cms/js/jquery.form.js', 'jquery');
     Asset::container('footer')->add('banner', 'bundles/cms/js/sections/banner_edit.js', 'cms');
     $this->layout->header_data = array('title' => LL('cms::title.banner_edit', CMSLANG));
     $this->layout->top_data = array('search' => false);
     //GET BANNER DATA
     $banner = CmsBanner::with(array('files'))->find($id);
     //GET FILE DATA
     $files = CmsFile::where_is_image(1)->where_is_valid(1)->order_by('name', 'asc')->order_by('id', 'asc')->paginate(Config::get('cms::settings.pag'));
     $this->layout->content = View::make('cms::interface.pages.banner_new_edit')->with('title', LL('cms::title.banner_edit', CMSLANG))->with('banner_id', $id)->with('banner_lang', $banner->lang)->with('banner_name', $banner->name)->with('files', $files)->with('files_select', $banner->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);
 }
 /**
  * BANNER Marker - Shows a banner rotator as saved in Services / Banner
  *
  * [$BANNER[{
  *	"name":"<banner name>",
  *	"thumb":"<thumb type>"	=> (default: none)
  *	"type":"<slider name>"	=> (default: none | available: nivo)
  *	"theme":"<theme>"		=> (default: default)
  *	"caption":"false"		=> (default: false)
  *	"w":"",
  *	"h":"",
  *	"class":"<class>",		=> OPTIONAL
  *	"tpl":"<tpl_name>"		=> OPTIONAL (in /partials/markers)
  * }]]
  *
  * @param  array
  * @return string
  */
 public static function BANNER($vars = array())
 {
     //Get variables from array $vars
     if (!empty($vars)) {
         extract($vars);
     }
     //Bind variables
     $_name = '';
     if (isset($name) and !empty($name)) {
         $_name = $name;
     }
     $_type = '';
     if (isset($type) and !empty($type)) {
         $_type = $type;
     }
     $_thumb = '';
     if (isset($thumb) and !empty($thumb)) {
         $_thumb = $thumb;
     }
     $_theme = 'default';
     if (isset($theme) and !empty($theme)) {
         $_theme = $theme;
     }
     $_caption = false;
     if (isset($caption) and !empty($caption) and $caption == 'true') {
         $_caption = true;
     }
     $_w = null;
     if (isset($w) and !empty($w)) {
         $_w = $w;
     }
     $_h = null;
     if (isset($h) and !empty($h)) {
         $_h = $h;
     }
     $_class = 'banner';
     if (isset($class) and !empty($class)) {
         $_class = $class;
     }
     $_tpl = 'banner';
     if (isset($tpl) and !empty($tpl)) {
         $_tpl = $tpl;
     }
     //FORCE NIVO TPL
     if (isset($type) and $type == 'nivo') {
         $_tpl = 'nivo';
     }
     if (!empty($_name)) {
         if ($_type == 'nivo') {
             //LOAD NIVOSLIDER LIBS
             Asset::container('header')->add('nivoslidercss', 'bundles/cms/css/nivoslider.css', 'site_css');
             Asset::container('header')->add('nivo' . $_theme, 'bundles/cms/nivoslider/themes/' . $_theme . '/' . $_theme . '.css', 'nivoslidercss');
             Asset::container('footer')->add('nivosliderjs', 'bundles/cms/js/jquery.nivoslider.js', 'jquery_lib');
             Asset::container('footer')->add('banner', 'js/markers/banner.js', 'site_js');
         }
         //CACHE DATA
         if (CACHE) {
             $list = Cache::remember('img_banner_' . $_name . '_' . SITE_LANG, function () use($_name) {
                 return CmsBanner::with(array('files' => function ($query) {
                     $query->where('files_banners.date_off', '>=', date('Y-m-d H:i:s'));
                 }, 'files.filetexts' => function ($query) {
                     $query->where('lang', '=', SITE_LANG);
                 }))->where_name($_name)->first();
             }, 1440);
         } else {
             $list = CmsBanner::with(array('files' => function ($query) {
                 $query->where('files_banners.date_off', '>=', date('Y-m-d H:i:s'));
             }, 'files.filetexts' => function ($query) {
                 $query->where('lang', '=', SITE_LANG);
             }))->where_name($_name)->first();
         }
         //Load file lable and title
         if (!empty($list->files)) {
             $images = $list->files;
             $attr = $list->files;
         } else {
             $images = array();
             $attr = '';
         }
     } else {
         $images = array();
         $attr = '';
     }
     $options = array('id' => $_name, 'class' => $_class);
     $thumbs = CONF('cms::theme.thumb', $_thumb);
     $view = LOAD_VIEW($_tpl);
     $view['images'] = $images;
     $view['thumb'] = (strlen($_thumb) > 0 and array_key_exists('suffix', $thumbs)) ? $thumbs['suffix'] : '';
     $view['theme'] = $_theme;
     $view['attr'] = $attr;
     $view['caption'] = $_caption;
     $view['w'] = $_w;
     $view['h'] = $_h;
     $view['options'] = HTML::attributes($options);
     return $view;
 }