Esempio n. 1
0
 /**
  * @param array $path
  */
 public function __controller(array $path)
 {
     \classes\compiler::disable();
     error_reporting(-1);
     \core::$css = ['/.core/module/cms/css/styles.css'];
     \core::$js = ['/.core/js/jquery.js', '/.core/js/_ajax.js', '/.core/js/content_collapse.js', '/.core/module/cms/js/cms.js', '/.core/js/colorbox.js', '/.core/plugins/ckeditor/ckeditor.js'];
     if (\core::is_admin() && !isset($path[1])) {
         $path[1] = 'dashboard';
     }
     $this->view = 'login';
     if (isset($path[1]) && !empty($path[1]) && \core::is_admin()) {
         $this->view = $path[1];
         if (isset($path[2])) {
             $this->set_from_mid($path[2]);
             $this->npp = session::is_set('cms', $this->module->get_class_name(), 'npp') ? session::get('cms', $this->module->get_class_name(), 'npp') : 25;
             $this->page = isset($path[4]) ? $path[4] : 1;
             $this->current_class = $this->module->get_class();
         }
     }
     if (isset($path[3]) && !empty($path[3]) && core::is_admin()) {
         /** @var table $class */
         $class = $this->current_class;
         $class::$retrieve_unlive = true;
         $class::$retrieve_deleted = true;
         $this->current->do_retrieve_from_id([], $path[3]);
     }
     parent::__controller($path);
 }
Esempio n. 2
0
 public function set_search()
 {
     if (!isset($this->sort_method)) {
         $this->search_form = new search_form(get_class($this));
         $this->search_form->set_from_request();
         $this->search_form->attributes['data-ajax-change'] = get_class($this) . ':do_search_submit';
         if (session::is_set(get_class($this), $this->search_form->identifier, 'search')) {
             $this->search_form->keywords = session::get(get_class($this), $this->search_form->identifier, 'search');
         }
     }
 }
Esempio n. 3
0
 public function set_sort()
 {
     if (!isset($this->sort_method)) {
         $this->sort_form = new sort_form($this->get_sortable_fields(), get_class($this));
         $this->sort_form->set_from_request();
         $this->sort_form->attributes['data-ajax-change'] = get_class($this) . ':do_sort_submit';
         if (session::is_set(get_class($this), $this->sort_form->identifier, 'sort')) {
             $this->sort_form->sort = session::get(get_class($this), $this->sort_form->identifier, 'sort');
         }
     }
 }
Esempio n. 4
0
 public function set_filters()
 {
     if (!isset($this->filters)) {
         $this->filters = new filter_form($this->get_filterable_fields(), $this);
         $this->filters->set_from_request();
         $this->filters->attributes['data-ajax-change'] = get_class($this) . ':do_filter_submit';
         if (session::is_set(get_class($this), $this->filters->identifier, 'filter')) {
             foreach (session::get(get_class($this), $this->filters->identifier, 'filter') as $filter => $value) {
                 $this->filters->{$filter} = $value;
             }
         }
     }
 }
Esempio n. 5
0
 public function do_submit($no_session = false)
 {
     if (!$no_session) {
         foreach ($this->fields as $field) {
             if ($field instanceof field_boolean && !$this->{$field->field_name}) {
                 session::un_set('cms', 'filter', $this->_mid, $field->field_name);
             } else {
                 session::set($this->{$field->field_name}, 'cms', 'filter', $this->_mid, $field->field_name);
             }
         }
     }
     $module = new _cms_module();
     $module->do_retrieve([], ['where_equals' => ['mid' => $this->_mid]]);
     $list = new _cms_table_list($module, 1);
     ajax::update($list->get_table());
 }
Esempio n. 6
0
 public function set_from_request()
 {
     parent::set_from_request();
     if (!$this->identifier) {
         $this->identifier = clean_uri;
     }
     if (ajax && $_REQUEST['act'] == 'do_filter_submit') {
         if (isset($this->identifier)) {
             session::set([], get_class($this->source_data), $this->identifier, 'filter');
             foreach ($this->fields as $field) {
                 if (isset($this->{$field->field_name})) {
                     session::set($this->{$field->field_name}, get_class($this->source_data), $this->identifier, 'filter', $field->field_name);
                 }
             }
         }
     }
 }
Esempio n. 7
0
 public function __construct(__cms_module $module, $page)
 {
     $this->module = $module;
     $this->page = $page;
     $this->npp = session::is_set('cms', 'filter', $module->mid, 'npp') ? session::get('cms', 'filter', $module->mid, 'npp') : 25;
     $this->deleted = session::is_set('cms', 'filter', $module->mid, 'deleted') ? session::get('cms', 'filter', $module->mid, 'deleted') : false;
     $this->allowed_keys = ['' => 0] + (session::is_set('cms', 'expand', $module->mid) ? session::get('cms', 'expand', $module->mid) : []);
     $this->where = [];
     if ($module->order && preg_match('/[a-zA-Z0-9,\\s]+/', $module->order)) {
         $this->order = $module->order;
     }
     $class = $this->module->get_class_name();
     $this->class_name = $class;
     $this->class = new $class();
     foreach ($module->get_class()->get_fields() as $field) {
         if (session::is_set('cms', 'filter', $module->mid, $field->field_name) && session::get('cms', 'filter', $module->mid, $field->field_name)) {
             $this->where[$field->field_name] = session::get('cms', 'filter', $module->mid, $field->field_name);
         }
     }
 }
Esempio n. 8
0
 public function do_submit()
 {
     session::set(true, 'admin');
     _ajax::current()->redirect = '/cms/dashboard';
 }
Esempio n. 9
0
 public static function is_admin()
 {
     compiler::allow();
     return session::is_set('admin');
 }
Esempio n. 10
0
 public function do_toggle_expand()
 {
     if (isset($_REQUEST['id'])) {
         $module = new _cms_module();
         $module->do_retrieve([], ['where_equals' => ['mid' => $_REQUEST['mid']]]);
         if (_session::is_set('cms', 'expand', $module->mid)) {
             $value = _session::get('cms', 'expand', $module->mid);
             if (($key = array_search($_REQUEST['id'], $value)) !== false) {
                 unset($value[$key]);
             } else {
                 $value[] = $_REQUEST['id'];
             }
             _session::set($value, 'cms', 'expand', $module->mid);
         } else {
             _session::set([$_REQUEST['id']], 'cms', 'expand', $module->mid);
         }
         $list = new _cms_table_list($module, 1);
         _ajax::update($list->get_table());
     }
 }