예제 #1
0
 protected function __construct()
 {
     $this->nc_core = nc_core();
     $this->table = nc_db_table::make('Subdivision');
     $this->file_table = nc_db_table::make('Filetable', 'ID');
     $this->routing_module_enabled = nc_module_check_by_keyword('routing');
     $this->current_page_url = urldecode(strtok($_SERVER['REQUEST_URI'], '?'));
     $this->current_sub_url = substr($this->current_page_url, 0, strrpos($this->current_page_url, "/") + 1);
     if (!empty($GLOBALS['current_sub'])) {
         $this->set_current_sub($GLOBALS['current_sub']);
     }
     $this->reset();
 }
 protected function init()
 {
     $this->bind('add', array('catalogue', 'block', 'width', 'widgets'));
     $this->bind('settings', array('widget_class_id', 'block_widget_id'));
     $this->bind('edit', array('block_widget_id', 'width', 'widgets'));
     $this->bind('checked', array('block_widget_id', 'checked', 'back_link'));
     $this->bind('delete', array('block_widget_id', 'back_link'));
     $this->bind('delete_post', array('block_widget_id', 'back_link'));
     $this->field_table = nc_db_table::make('Field');
     $this->widget_table = nc_db_table::make('Widget');
     $this->widget_class_table = nc_db_table::make('Widget_Class');
     $this->widget_field_table = nc_db_table::make('Widget_Field', 'ID');
     $this->block_widget_table = $this->nc_core->widget->block_widget_table;
     $this->is_naked = (bool) $this->input->fetch_post_get('isNaked');
 }
예제 #3
0
 protected function get_data_from_source($source)
 {
     $data = array();
     if (!empty($source['class_id'])) {
         $table = nc_db_table::make('Message' . (int) $source['class_id'], 'Message_ID');
         if (!empty($source['subclass_id'])) {
             $table->where('Sub_Class_ID', $source['subclass_id']);
         }
         if ($source['order_by']) {
             $table->raw('order_by', $source['order_by']);
         }
         if ($source['where']) {
             $table->where($source['where']);
         }
         if ($source['limit']) {
             $table->limit($source['limit']);
         }
         $data = $table->get_result();
         if ($source['bindings']) {
             $this->bind_fields($data, $source['bindings']);
         }
         $message_ids = array();
         foreach ($data as $i => $row) {
             $message_ids[] = $row['Message_ID'];
         }
         $full_links = array();
         # основной запрос для построения пути
         $result = nc_db()->get_results("SELECT  m.`Message_ID`, CONCAT(sub.`Hidden_URL`, IF(m.`Keyword` <> '', m.`Keyword`, CONCAT(cc.`EnglishName`, '_', m.`Message_ID`)), '.html') AS fullLink\n                      FROM `Message" . $source['class_id'] . "` AS m\n                      LEFT JOIN `Subdivision` AS sub\n                      ON m.`Subdivision_ID` = sub.`Subdivision_ID`\n                      LEFT JOIN `Sub_Class` AS cc\n                      ON m.`Sub_Class_ID` = cc.`Sub_Class_ID`\n                      WHERE m.`Message_ID` IN (" . implode(',', $message_ids) . ")", ARRAY_A);
         foreach ($result as $row) {
             $full_links[$row['Message_ID']] = $row['fullLink'];
         }
         $result = array();
         foreach ($data as $i => $row) {
             foreach ($row as $k => $v) {
                 $result[$i]['f_' . $k] = $v;
             }
             $result[$i]['f_RowID'] = $row['Message_ID'];
             $result[$i]['fullLink'] = 'http://' . $_SERVER['HTTP_HOST'] . $full_links[$row['Message_ID']];
             // $result[$i]['fullLink'] = 'http://' . $_SERVER['HTTP_HOST'] . nc_message_link($row['Message_ID'], $source['class_id']);
         }
     }
     return (array) $result;
 }
 public function action_set_search_fields($cc)
 {
     $fields = nc_core()->input->fetch_post('fields');
     // print_r($fields);
     $sub_class_table = nc_db_table::make('Sub_Class');
     $field_table = nc_db_table::make('Field');
     $class_id = $sub_class_table->where_id($cc)->get_value('Class_ID');
     $field_table->where('Class_ID', $class_id)->update(array('DoSearch' => 0));
     foreach ($fields as $id) {
         $field_table->where_id($id)->update(array('DoSearch' => 1));
     }
     $back_url = $_SERVER['HTTP_REFERER'];
     if (!$back_url) {
         $back_url = nc_core()->SUB_FOLDER . nc_core()->HTTP_ROOT_PATH . '?inside_admin=1&cc=' . $cc;
     }
     $this->is_naked = true;
     ob_get_level() and ob_end_clean();
     header("Location: {$back_url}");
     exit;
 }
 protected function export_process()
 {
     $id = $this->id;
     $classificator = $this->classificator_table->where_id($id)->get_row();
     if (!$classificator) {
         return false;
     }
     // Export data: Classificator
     $data = array($id => $classificator);
     $this->dumper->export_data('Classificator', 'Classificator_ID', $data);
     // Export data: Classificator_{Table_Name}
     $table = 'Classificator_' . $classificator['Table_Name'];
     $pk = $classificator['Table_Name'] . '_ID';
     $classificator_data_table = nc_db_table::make($table, $pk);
     $data = $classificator_data_table->get_result();
     $this->dumper->export_data($table, $pk, $data);
     // Export table: Classificator_{Table_Name}
     $this->dumper->export_table($table);
     $this->dumper->set_dump_info('classificator_table', $classificator['Table_Name']);
 }
예제 #6
0
 public function import_data($table, $new_table = null)
 {
     $save_ids = $this->get_import_settings('save_ids');
     $data = $this->get_dump_info('data', $table);
     $dict_fields = $this->get_dump_info('dict_fields');
     $new_table = $new_table ? $new_table : $table;
     $pk = $data['pk'];
     $fields = $data['fields'];
     $xmls = $data['files'];
     if (!$xmls) {
         return false;
     }
     $db_table = nc_db_table::make($new_table, $pk);
     $message_table = substr($new_table, 0, 7) == 'Message' ? substr($new_table, 7) : false;
     $lower_table = $message_table ? 'message' : strtolower($new_table);
     $event_before_insert = 'before_insert_' . $lower_table;
     $event_after_insert = 'after_insert_' . $lower_table;
     foreach ($xmls as $xml) {
         $xml_file = $this->get_dump_path($xml);
         if (!file_exists($xml_file)) {
             throw new Exception("XML file not found: {$xml}", 1);
         }
         $data = $this->read_data($xml_file);
         foreach ($data as $row) {
             $row = array_combine($fields, unserialize(base64_decode($row)));
             foreach ($dict_fields as $alias => $field) {
                 if (isset($row[$alias])) {
                     if ($field === true) {
                         $field = $alias;
                     }
                     $row[$alias] = $this->get_dict($field, $row[$alias], $row[$alias]);
                 }
             }
             $event_args = $message_table ? array($message_table, $row) : array($row);
             $this->call_event($event_before_insert, $event_args, $row);
             if (!$save_ids) {
                 $id = $row[$pk];
                 unset($row[$pk]);
             }
             if ($new_id = $db_table->set($row)->insert()) {
                 $this->set_import_result('total_insert_rows', +1, true);
             } elseif ($error = $db_table->get_last_error()) {
                 $error = 'TABLE: ' . $db_table->get_table() . PHP_EOL . 'ERROR: ' . $error;
                 throw new Exception($error, 1);
             }
             $this->set_dict($pk, $id, $new_id);
             $event_args[] = $new_id;
             $this->call_event($event_after_insert, $event_args);
         }
     }
 }
예제 #7
0
 protected function init()
 {
     $this->template_table = nc_db_table::make('Template');
 }
예제 #8
0
 protected function make_message_table($class_id)
 {
     return nc_db_table::make('Message' . intval($class_id), 'Message_ID');
 }
예제 #9
0
 protected function export_process()
 {
     global $SUB_FOLDER, $HTTP_FILES_PATH, $DOCUMENT_ROOT;
     $id = $this->id;
     $site = $this->site_table->where_id($id)->get_row();
     if (!$site) {
         return false;
     }
     $this->dumper->register_dict_field('Catalogue_ID', 'Class_ID', 'Sub_Class_ID', 'Template_ID', 'Subdivision_ID');
     // Catalogue
     $data = array($id => $site);
     $this->dumper->export_data('Catalogue', 'Catalogue_ID', $data);
     // Settings
     $data = $this->settings_table->where('Catalogue_ID', $id)->index_by_id()->get_result();
     $this->dumper->export_data('Settings', 'Settings_ID', $data);
     // Subdivisions
     $data = $this->subdivision_table->where('Catalogue_ID', $id)->where('Parent_Sub_ID', 0)->index_by_id()->get_result();
     $parent_ids = array_keys($data);
     while ($parent_ids) {
         $result = $this->subdivision_table->where_in('Parent_Sub_ID', $parent_ids)->index_by_id()->get_result();
         $parent_ids = array_keys($result);
         $data += $result;
     }
     $this->dumper->export_data('Subdivision', 'Subdivision_ID', $data);
     // Sub_Class
     $sub_ids = $this->dumper->get_dict('Subdivision_ID');
     $sub_classes = $this->subclass_table->where_in('Subdivision_ID', $sub_ids)->index_by_id()->get_result();
     $this->dumper->export_data('Sub_Class', 'Sub_Class_ID', $sub_classes);
     ##### TEMPLATES #####
     $template_ids = $this->dumper->get_dict('Template_ID');
     unset($template_ids[0]);
     if ($template_ids) {
         do {
             $template_ids = array_unique($this->template_table->where_in_id($template_ids)->get_list('Parent_Template_ID'));
             $template_ids[0] = 0;
         } while (call_user_func_array('max', $template_ids));
         unset($template_ids[0]);
         $template_ids = array_keys($template_ids);
         // Template
         $templates = $this->template_table->where_in_id($template_ids)->index_by_id()->get_result();
         $data = $templates;
         while ($template_ids) {
             $result = $this->template_table->where_in('Parent_Template_ID', $template_ids)->index_by_id()->get_result();
             $template_ids = array_keys($result);
             $data += $result;
         }
         $this->dumper->export_data('Template', 'Template_ID', $data);
         // Export files
         foreach ($templates as $tpl) {
             if ($tpl['File_Mode']) {
                 $this->dumper->export_files(nc_core('HTTP_TEMPLATE_PATH') . 'template', $tpl['File_Path']);
             }
         }
     }
     ##### COMPONENTS #####
     // Class
     if ($class_ids = $this->dumper->get_dict('Class_ID')) {
         $components = $this->class_table->where_in_id($class_ids)->where('System_Table_ID', 0)->index_by_id()->get_result();
         // Class templates
         $data = $components + $this->class_table->where_in('ClassTemplate', $class_ids)->index_by_id()->get_result();
         $this->dumper->export_data('Class', 'Class_ID', $data);
         // Field
         $data = $this->field_table->where_in('Class_ID', $class_ids)->index_by_id()->get_result();
         $this->dumper->export_data('Field', 'Field_ID', $data);
         foreach ($components as $class_id => $com) {
             // Message*
             $this->dumper->export_table('Message' . $class_id);
             // Export component files
             if ($com['File_Mode']) {
                 $this->dumper->export_files(nc_core('HTTP_TEMPLATE_PATH') . 'class', $com['File_Path']);
             }
         }
     }
     ##### DATA #####
     if ($sub_classes) {
         foreach ($sub_classes as $sub_class_id => $sub_class) {
             $class_id = $sub_class['Class_ID'];
             $sub_id = $sub_class['Subdivision_ID'];
             $message_table = nc_db_table::make('Message' . $class_id, 'Message_ID');
             // Data
             $data = $message_table->where('Sub_Class_ID', $sub_class_id)->index_by_id()->get_result();
             $this->dumper->export_data($message_table->get_table(), 'Message_ID', $data);
             // Files
             $dir = $SUB_FOLDER . $HTTP_FILES_PATH . "{$sub_id}/{$sub_class_id}/";
             if (file_exists($DOCUMENT_ROOT . $dir)) {
                 $this->dumper->export_files($dir);
             }
         }
     }
 }
예제 #10
0
 protected function generate_aggregator($widget_id, $settings)
 {
     if (is_string($settings) && $settings[0] == 'a') {
         $settings = unserialize($settings);
     } else {
         $settings = (array) $settings;
     }
     $widget = nc_db_table::make('Widget')->where_id($widget_id)->get_row();
     $fields = array();
     $nc_core = nc_core();
     $db = nc_db();
     $widget_class_id = $widget['Widget_Class_ID'];
     $field_values = nc_db_table::make('Widget_Field')->where('Widget_ID', $widget_id)->get_list('Field_ID', 'Value');
     $result = $db->get_results("SELECT `Field_ID`, `Field_Name`, `DefaultState` FROM `Field` WHERE `Widget_Class_ID`='" . $widget_class_id . "'", ARRAY_A);
     foreach ($result as $row) {
         $field_id = $row['Field_ID'];
         $fields[$row['Field_Name']] = isset($field_values[$field_id]) ? $field_values[$field_id] : $row['DefaultState'];
     }
     extract($fields, EXTR_PREFIX_ALL, 'f');
     $widget_view = new nc_widget_view($this->core->WIDGET_TEMPLATE_FOLDER, nc_db());
     $widget_view->load($widget['Widget_Class_ID']);
     include $widget_view->get_field_path('Settings');
     ob_start();
     include $widget_view->get_field_path('Template');
     return ob_get_clean();
 }
예제 #11
0
 protected function init()
 {
     $this->widget_class_table = nc_db_table::make('Widget_Class');
     $this->field_table = nc_db_table::make('Field');
 }
예제 #12
0
파일: dev_json.php 프로젝트: Blu2z/implsk
    $hasTemplates = 0;
    if ($node_id == 3 && $nc_core->modules->get_by_keyword('auth')) {
        $hasTemplates = $db->get_var("SELECT COUNT(`Class_ID`) FROM `Class` WHERE `ClassTemplate` > 0 AND `System_Table_ID` = 3 AND File_Mode = " . +$_REQUEST['fs']);
        $user_class_id = $db->get_var("SELECT `Class_ID` FROM `Class` WHERE `ClassTemplate` = 0 AND `System_Table_ID` = 3 AND File_Mode = " . +$_REQUEST['fs']);
    }
    if ($hasTemplates) {
        $class_template_buttons = array();
        $class_template_buttons[] = nc_get_array_2json_button(CONTROL_CLASS_CLASS_TEMPLATE_ADD, "classtemplate{$fs_suffix}.add(" . $user_class_id . ")", "nc-icon nc--file-add nc--hovered");
        $ret_class_templates[] = array("nodeId" => "classtemplates-" . $user_class_id, "name" => CONTROL_CLASS_CLASS_TEMPLATES, "href" => "#classtemplates.edit(" . $user_class_id . ")", "sprite" => 'dev-templates' . ($File_Mode ? '' : '-v4'), "acceptDropFn" => "treeClassAcceptDrop", "onDropFn" => "treeClassOnDrop", "hasChildren" => $hasTemplates, "dragEnabled" => false, "buttons" => $class_template_buttons);
    }
} elseif ($node_type == 'template' && $node_id || $node_type == 'templates') {
    // Получение дерева макетов
    if (!$node_id) {
        $node_id = 0;
    }
    $tamplate_table = nc_db_table::make('Template');
    $templates = $tamplate_table->select('`Template_ID`, `Description`')->where('Parent_Template_ID', $node_id)->where('File_Mode', $File_Mode)->order_by('Priority')->order_by('Template_ID')->index_by_id()->get_result();
    $childrens_count = $tamplate_table->select('COUNT(*) as total, Parent_Template_ID')->where_in('Parent_Template_ID', array_keys($templates))->group_by('Parent_Template_ID')->get_list('Parent_Template_ID', 'total');
    // Представления макета дизайна
    if ($File_Mode && $node_id) {
        $is_root_template = !$tamplate_table->where_id($node_id)->get_value('Parent_Template_ID');
        if ($is_root_template) {
            $ret_templates[] = array("nodeId" => "template_partials-{$node_id}", "name" => CONTROL_TEMPLATE_PARTIALS, "href" => "#template.partials_list({$node_id})", "sprite" => 'dev-com-templates', "hasChildren" => (bool) $nc_core->template->has_partial($node_id), "buttons" => array(nc_get_array_2json_button(CONTROL_TEMPLATE_PARTIALS_ADD, "template{$fs_suffix}.partials_add({$node_id})", "nc-icon nc--dev-templates-add nc--hovered")));
        }
    }
    foreach ((array) $templates as $id => $template) {
        $template_buttons = array();
        $template_buttons[] = nc_get_array_2json_button(CONTROL_TEMPLATE_TEPL_CREATE, "template{$fs_suffix}.add({$id})", "nc-icon nc--dev-templates-add nc--hovered");
        $template_buttons[] = nc_get_array_2json_button(CONTROL_TEMPLATE_DELETE, "template{$fs_suffix}.delete({$id})", "nc-icon nc--remove nc--hovered");
        // Для корневых макетов v5 всегда показывать "+", т.к. они имеют partials
        if ($node_id == 0 && $File_Mode) {
 public function action_bindings($field_value)
 {
     $class_id = (int) $field_value['class_id'];
     $fields = nc_db_table::make('Field')->where('Class_ID', $class_id)->get_list('Field_Name', 'Description');
     return array('bindings_fields' => $fields);
 }
예제 #14
0
 protected function init()
 {
     $this->subdivision_table = nc_db_table::make('Subdivision');
     $this->subclass_table = nc_db_table::make('Sub_Class');
 }
예제 #15
0
 /**
  * Constructor function
  */
 public function __construct()
 {
     parent::__construct();
     $this->db = $this->core->db;
     $this->table = nc_db_table::make('Template');
 }