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 __construct($mid = 0)
 {
     if (ajax && !$mid) {
         $mid = $_REQUEST['_mid'];
     }
     $class_name = table::get_class_from_mid($mid);
     /** @var \classes\table $class */
     $class = new $class_name();
     $super_fields = $class->get_fields();
     $fields = [form::create('field_boolean', 'deleted')->set_attr('label', 'Show deleted?')->set_attr('options', [25 => 25, 50 => 50, 75 => 75, 100 => 100, 0 => 'All'])->set_attr('required', false), form::create('field_select', 'npp')->set_attr('label', 'Number per page')->set_attr('options', [25 => 25, 50 => 50, 75 => 75, 100 => 100, 0 => 'All'])->set_attr('required', false), form::create('field_int', '_mid')->set_attr('hidden', true)];
     /** @var \form\field $field */
     foreach ($super_fields as $field) {
         if ($field->filter) {
             $field->required = false;
             $fields[] = $field;
         }
     }
     parent::__construct($fields);
     /** @var \form\field $field */
     foreach ($fields as $field) {
         if (session::is_set('cms', 'filter', $mid, $field->field_name)) {
             $this->{$field->field_name} = session::get('cms', 'filter', $mid, $field->field_name);
         }
     }
     $this->id = 'filter_form';
     $this->submit = 'Filter';
     $this->_mid = $mid;
 }
Esempio n. 3
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. 4
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. 5
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. 6
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. 7
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());
     }
 }