Ejemplo n.º 1
0
 public function __construct($value = null)
 {
     $this->db = nc_core()->db;
     if ($value) {
         $this->set_value($value);
     }
 }
Ejemplo n.º 2
0
 /**
  * Возвращает путь к папке netcat_files (от корня сайта), без слэша на конце
  *
  * @return string
  */
 protected function get_files_folder()
 {
     // cannot do that in the constructor because $nc_core is not initialized there
     if (!isset($this->files_folder)) {
         $this->files_folder = rtrim(nc_core('SUB_FOLDER') . nc_core('HTTP_FILES_PATH'), '/\\');
     }
     return $this->files_folder;
 }
Ejemplo n.º 3
0
 /**
  * @param string $option
  * @return mixed
  */
 public function get($option)
 {
     $value = parent::get($option);
     if ($this->internal_encoding != $this->output_encoding) {
         $value = nc_core('utf8')->conv($this->internal_encoding, $this->output_encoding, $value);
     }
     return $value;
 }
Ejemplo n.º 4
0
/**
 * Путь (от корня сайта) к папке с модулями.
 * E.g. nc_module_path('auth') → '/netcat/modules/auth/'
 *
 * @return string
 */
function nc_module_path()
{
    $path = '';
    if (func_num_args()) {
        $args = func_get_args();
        $path = implode('/', $args) . '/';
    }
    return nc_core('SUB_FOLDER') . nc_core('HTTP_ROOT_PATH') . 'modules/' . $path;
}
Ejemplo n.º 5
0
 public function __construct(nc_template_view $template_view, $partial_file, array $data = array())
 {
     $this->template_view = $template_view;
     if (nc_check_file($partial_file)) {
         $this->partial_file = $partial_file;
     }
     $this->data = $data;
     $this->data['nc_core'] = nc_core();
     $this->data['db'] = nc_db();
 }
Ejemplo n.º 6
0
 /**
  * Инициализация модуля:
  * — Инициализация автоматической загрузки классов модуля
  * — Если модуль не разу не запускался, будут созданы стандартные
  *   маршруты для всех сайтов
  * — Привязка слушателей создания и удаления сайтов
  */
 public static function init()
 {
     nc_core()->register_class_autoload_path('nc_routing_', dirname(__FILE__) . "/classes");
     if (!nc_routing::get_setting('IsInstalled', 0)) {
         nc_routing_route_defaults::create_for_all_sites();
         self::set_setting('IsInstalled', 1, 0);
     }
     nc_routing_listener::init();
     self::$SUB_FOLDER = nc_core::get_object()->SUB_FOLDER;
 }
 public function render_field()
 {
     $view = nc_core()->ui->view(dirname(__FILE__) . '/views/field.view.php');
     $view->with('field', $this);
     $view->with('field_name', $this->get_name());
     $view->with('field_value_json', $this->get_value());
     $view->with('data_source_config', array('ajax_path' => nc_core('SUB_FOLDER') . nc_core('HTTP_ROOT_PATH') . 'action.php?ctrl=system.form.fields.data_source.data_source'));
     foreach ($this->default_settings as $key => $value) {
         $view->with($key, $this->get($key));
     }
     return $view;
 }
Ejemplo n.º 8
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();
 }
Ejemplo n.º 9
0
 function _edit_doc_link($row)
 {
     // global function inside a method... huh?
     if (!$row["Subdivision_ID"]) {
         return "";
     }
     // oops
     $resolved_url_data = nc_resolve_url($row["Referrer_URL"]);
     $url = parse_url($row["Referrer_URL"]);
     $edit_link_params = array("sub" => nc_array_value($resolved_url_data, "folder_id"), "cc" => nc_array_value($resolved_url_data, "infoblock_id"), "message" => nc_array_value($resolved_url_data, "object_id"));
     $edit_link = $url['scheme'] . "://" . $url['host'] . nc_core("SUB_FOLDER") . nc_core("HTTP_ROOT_PATH") . ($resolved_url_data["resource_type"] == "object" ? "message.php" : "") . "?" . (isset($url["query"]) ? $url["query"] . "&" : "") . http_build_query($edit_link_params);
     return "<a href='" . htmlspecialchars($edit_link) . "' target='_blank'>" . NETCAT_MODULE_SEARCH_ADMIN_BROKEN_LINK_EDIT . "</a>";
 }
Ejemplo n.º 10
0
 /**
  * Селектор сайта
  * @param int $current_site_id
  * @return string
  */
 public static function site_select($current_site_id)
 {
     // @todo remove that 'helper' when global site selector is introduced
     $sites = nc_core('catalogue')->get_all();
     $options = array();
     foreach ($sites as $id => $row) {
         $options[$id] = $id . '. ' . $row['Catalogue_Name'];
     }
     $site_selector_id = 'nc_admin_site_select';
     $site_selector = nc_core('ui')->html->select('site_id', $options, $current_site_id)->attr('id', $site_selector_id);
     $nc = '$nc';
     $site_selector .= "<script>\n            (function() {\n                {$nc}('#{$site_selector_id}').change(function() {\n                    var re = /site_id=\\d+/,\n                        loc = location.href,\n                        new_site_id = {$nc}(this).val(),\n                        new_site_loc = 'site_id=' + new_site_id;\n                    if (re.test(loc)) {\n                        location.href = loc.replace(/site_id=\\d+/, new_site_loc);\n                    }\n                    else {\n                        location.href += (loc.indexOf('?') ? '&' : '?' ) + new_site_loc;\n                    }\n                });\n            })();\n        </script>";
     return $site_selector;
 }
Ejemplo n.º 11
0
 /**
  * Убрать после отказа от поддержки MySQL 4.1.x
  */
 protected function check_hash_column_type()
 {
     static $hash_column_type_checked = false;
     if (!$hash_column_type_checked) {
         $hash_length = nc_search_util::can_use_binary_columns() ? "20" : "40";
         /** @var nc_db $db */
         $db = nc_core('db');
         $hash_column_definition = $db->get_row("SHOW COLUMNS FROM `Search_Link` LIKE 'Hash'", ARRAY_A);
         if (!strpos($hash_column_definition['Type'], $hash_length)) {
             $db->query("ALTER TABLE `Search_Link` CHANGE `Hash` `Hash` BINARY({$hash_length}) NOT NULL");
         }
         $hash_column_type_checked = true;
     }
 }
Ejemplo n.º 12
0
 protected function __construct()
 {
     if (!$this->module_keyword) {
         // cut prefix "nc_"
         $this->module_keyword = strtolower(substr(get_class($this), 3));
     }
     if (!$this->module_folder) {
         $this->module_folder = nc_core('MODULE_FOLDER') . $this->module_keyword . DIRECTORY_SEPARATOR;
     }
     // Загрузка подмодулей при старте
     foreach ($this->submodules as $key => $submodule) {
         if ($submodule === self::LOAD_ON_STARTUP) {
             $this->load_submodule($key);
         }
     }
     $this->init();
 }
Ejemplo n.º 13
0
 public function save_fields($only_isset_post = false, $template = null, $fld_content = null)
 {
     if (null == $template) {
         $template = $this->template;
     }
     if ($fld_content === null) {
         $fld_content = nc_core('input')->fetch_post();
     }
     foreach ($template->fields->standart as $field => $tmp) {
         if (!$only_isset_post || isset($fld_content[$field])) {
             if ($field == 'RecordTemplate') {
                 $fld_content['RecordTemplate'] = nc_get_string_service_prefix_for_RecordTemplate() . $fld_content['RecordTemplate'] . nc_get_string_service_suffix_for_RecordTemplate();
             }
             nc_save_file($template->fields->get_path($field), $fld_content[$field]);
         }
     }
     nc_tpl_parser::parts2main($template);
 }
Ejemplo n.º 14
0
 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;
 }
Ejemplo n.º 15
0
 protected function export_process()
 {
     $id = $this->id;
     $widget_class = $this->widget_class_table->where_id($id)->get_row();
     if (!$widget_class) {
         return false;
     }
     // Export data: Class
     $data = array($id => $widget_class);
     $this->dumper->export_data('Widget_Class', 'Widget_Class_ID', $data);
     // Export data: Field
     $data = $this->field_table->where('Widget_Class_ID', $id)->get_result();
     $this->dumper->export_data('Field', 'Field_ID', $data);
     // Export files
     if ($widget_class['File_Mode']) {
         $this->dumper->export_files(nc_core('HTTP_TEMPLATE_PATH') . 'widget', $widget_class['File_Path']);
     }
     $this->dumper->set_dump_info('widget_class_keyword', $widget_class['Keyword']);
     $this->dumper->set_dump_info('file_mode', $template['File_Mode']);
 }
Ejemplo n.º 16
0
 protected function export_process()
 {
     $id = $this->id;
     $component = $this->class_table->where_id($id)->get_row();
     if (!$component) {
         return false;
     }
     // Export data: Class
     $data = array($id => $component);
     $data += $this->class_table->where('ClassTemplate', $id)->index_by_id()->get_result();
     $this->dumper->export_data('Class', 'Class_ID', $data);
     // Export data: Field
     $data = $this->field_table->where('Class_ID', $id)->get_result();
     $this->dumper->export_data('Field', 'Field_ID', $data);
     $this->dumper->export_table('Message' . $id);
     // Export files
     if ($component['File_Mode']) {
         $this->dumper->export_files(nc_core('HTTP_TEMPLATE_PATH') . 'class', $component['File_Path']);
     }
     $this->dumper->set_dump_info('file_mode_' . $id, $component['File_Mode']);
 }
Ejemplo n.º 17
0
 public function match(nc_routing_request $request, nc_routing_result $result)
 {
     if (preg_match('/^(html|xml|rss)\\b/', $result->get_remainder(), $matches)) {
         $format = $matches[1];
         if ($format == 'rss' || $format == 'xml') {
             $infoblock_id = $result->get_infoblock_id();
             if (!$infoblock_id) {
                 return false;
             }
             $infoblock_settings = nc_core('sub_class')->get_by_id($infoblock_id);
             $format_mismatch = $format == 'rss' && !$infoblock_settings['AllowRSS'] || $format == 'xml' && !$infoblock_settings['AllowXML'];
             if ($format_mismatch) {
                 return false;
             }
         }
         $result->set_resource_parameter('format', $format);
         $result->truncate_remainder(strlen($format));
         return true;
     } else {
         return false;
     }
 }
Ejemplo n.º 18
0
 protected function export_process()
 {
     $id = $this->id;
     $template = $this->template_table->where_id($id)->get_row();
     if (!$template) {
         return false;
     }
     // Export data: Template
     $data = array($id => $template);
     $parent_ids = array($id);
     while ($parent_ids) {
         $result = $this->template_table->where_in('Parent_Template_ID', $parent_ids)->index_by_id()->get_result();
         $parent_ids = array_keys($result);
         $data += $result;
     }
     $this->dumper->export_data('Template', 'Template_ID', $data);
     // Export files
     if ($template['File_Mode']) {
         $this->dumper->export_files(nc_core('HTTP_TEMPLATE_PATH') . 'template', $template['File_Path']);
     }
     $this->dumper->set_dump_info('file_mode', $template['File_Mode']);
 }
Ejemplo n.º 19
0
 protected function escape($val)
 {
     return nc_core('db')->escape($val);
 }
Ejemplo n.º 20
0
Archivo: ui.php Proyecto: Blu2z/implsk
 /**
  *
  * @param string $query_string
  * @param string|array $area
  * @param string $params Параметры, через амперсанд
  *   - field - поле поиска. Допустимые значения: 'title'
  *   - interval - непустое значение, если включена фильтрация по дате
  *   - intervalvalue - значение интервала
  *   - intervalunit - тип интервала (hour, day, week, month)
  *   - sortby - сортировка. Если пустое значение - сортировка по релевантности.
  *     Допустимые значения: last_updated или имя поля, по которому разрешена сортировка
  *   - sortdirection - desc (по умолчанию), asc
  *   - language - язык результатов, по умолчанию определяется автоматически
  *   - curPos - текущая позиция (номер первого результата)
  *   - recNum - количество результатов на странице, по умолчанию 10 (берется из
  *     настроек компонента в разделе)
  *   - correct - пытаться исправить запросы, не давшие результатов (по умолчанию
  *     равно соответствующей настройки модуля)
  *   - nologging - не записывать запрос в журнал запросов (при просмотре
  *     результатов из админки, чтобы не искажать картину запросов)
  * @return nc_search_data_persistent_collection
  */
 public function get_results($query_string, $area = "", $params = "")
 {
     if (!nc_search::should('EnableSearch')) {
         return new nc_search_result();
     }
     // return empty collection
     $start_time = microtime(true);
     $query_string = (string) $query_string;
     global $nc_core;
     parse_str($params, $params);
     if (isset($params["field"]) && $params["field"] && nc_search::should('AllowFieldSearch')) {
         $query_string = "{$params['field']}:({$query_string})";
     }
     $query = new nc_search_query($query_string);
     $has_interval = isset($params["interval"]) && isset($params["intervalvalue"]) && isset($params["intervalunit"]) && $params["interval"] && $params["intervalvalue"] && $params["intervalunit"];
     if ($has_interval) {
         $timestamp = strtotime("-{$params['intervalvalue']} {$params['intervalunit']}");
         $query->set('modified_after', strftime("%Y%m%d%H%M%S", $timestamp));
     }
     $allow_sort = isset($params["sortby"]) && $params["sortby"] && nc_search::should('AllowFieldSearch');
     if ($allow_sort) {
         $query->set('sort_by', $params["sortby"]);
         if (isset($params["sortdirection"]) && strtoupper($params["sortdirection"]) == 'ASC') {
             $query->set('sort_direction', SORT_ASC);
         }
     }
     if (isset($params["curPos"]) && $params["curPos"]) {
         $query->set('offset', (int) $params["curPos"]);
     }
     if (isset($params["recNum"]) && $params["recNum"]) {
         $query->set('limit', (int) $params["recNum"]);
     }
     if ($area) {
         if (is_array($area)) {
             $area = join(" ", $area);
         }
         $query->set('area', $area);
     }
     $language = isset($params["language"]) && $params["language"] ? $params["language"] : $nc_core->lang->detect_lang(1);
     $query->set('language', $language);
     $shutdown_page_path = nc_folder_path($nc_core->subdivision->get_current('Subdivision_ID'));
     register_shutdown_function('nc_search_shutdown', $shutdown_page_path, $query_string);
     $query_error = false;
     try {
         $results = nc_search::find($query);
     } catch (Exception $e) {
         $query_error = true;
         $results = new nc_search_result();
         $results->set_query($query)->set_error_message($e->getMessage());
     }
     $results->set_output_encoding(nc_core('NC_CHARSET'));
     // попробуем исправить, если не было результатов?
     $try_to_correct = $results->get_total_count() == 0 && !$query_error && (isset($params["correct"]) && $params["correct"] || nc_search::should('TryToCorrectQueries')) && preg_match_all('/[\\pL\\pN\\?\\*]+/u', $query_string, $tmp) <= nc_search::get_setting('MaxQueryLengthForCorrection');
     if ($try_to_correct) {
         $context = new nc_search_context(array("language" => $language, "action" => "searching"));
         $correctors = nc_search_extension_manager::get('nc_search_language_corrector', $context)->get_all();
         if (sizeof($correctors)) {
             $phrase = new nc_search_language_corrector_phrase($query_string);
             $rewritten_query = clone $query;
             foreach ($correctors as $corrector) {
                 if ($corrector->correct($phrase)) {
                     // что-то подправили
                     // попробуем поискать!
                     $rewritten_query->set('query_string', $phrase->to_string());
                     try {
                         $corrected_results = nc_search::find($rewritten_query);
                         if (sizeof($corrected_results)) {
                             $results = $corrected_results;
                             $results->set_correction_suggestion($phrase->get_suggestion());
                             $results->set_output_encoding(nc_core('NC_CHARSET'));
                             break;
                             // exit "foreach corrector"
                         }
                     } catch (Exception $e) {
                         // может упасть, например, если у изменённого слова есть несколько базовых форм...
                     }
                 }
                 // of "something changed"
             }
             // of "foreach corrector"
         }
         // end of "has correctors"
     }
     // end of "if ($try_to_correct)"
     $will_log = true;
     if (isset($params['nologging']) && $params['nologging'] && strlen($query_string)) {
         // только очень крутым чувакам разрешается не оставлять следов
         if (isset($GLOBALS['AUTH_USER_ID']) && isset($GLOBALS['perm']) && $GLOBALS["perm"]->isAccess(NC_PERM_MODULE)) {
             $will_log = false;
         }
     }
     if ($will_log && nc_search::should('SaveQueryHistory') && $query->get('offset') == 0) {
         $ip = ip2long($_SERVER['REMOTE_ADDR']);
         // achtung! не будет работать с IPv6!
         if ($ip > 0x7fffffff) {
             $ip -= 0x100000000;
         }
         // produce a signed 4-byte integer on 64-bit systems
         $query->set('results_count', $results->get_total_count())->set('user_ip', $ip)->set('user_id', $GLOBALS['AUTH_USER_ID'])->set('site_id', $GLOBALS['catalogue'])->save();
     }
     $results->set_search_time(microtime(true) - $start_time);
     return $results;
 }
Ejemplo n.º 21
0
        <pre class='nc-code'>cd <?php 
    echo $DOCUMENT_ROOT;
    ?>

find ./ -type f -exec chmod 0644 {} \;
find ./ -type d -exec chmod 0755 {} \;
chmod -R 0777 .<?php 
    echo nc_core('HTTP_ROOT_PATH');
    ?>
tmp/ .<?php 
    echo nc_core('HTTP_DUMP_PATH');
    ?>
 .<?php 
    echo nc_core('HTTP_FILES_PATH');
    ?>
 .<?php 
    echo nc_core('HTTP_TRASH_PATH');
    ?>
 .<?php 
    echo nc_core('HTTP_TEMPLATE_PATH');
    ?>
chmod 0755 .<?php 
    echo nc_core('HTTP_ROOT_PATH');
    ?>
admin/crontab.php</pre>
        <hr>
    <?php 
}
?>

</div>
Ejemplo n.º 22
0
<?php

if (!class_exists("nc_system")) {
    die;
}
$ui = $this->get_ui();
$ui->add_lists_toolbar();
$stopwords = nc_search::load('nc_search_language_stopword', "SELECT * FROM `%t%` ORDER BY `Language`, `Word`")->set_output_encoding(nc_core('NC_CHARSET'));
if (count($stopwords)) {
    // фильтр
    $language_options = array("<option value=''>" . NETCAT_MODULE_SEARCH_ADMIN_LANGUAGE_ANY_LANGUAGE . "</option>");
    foreach ($this->get_language_list() as $code => $lang) {
        if ($stopwords->first('language', $code)) {
            $language_options[] = "<option value='{$code}'>{$lang}</option>";
        }
    }
    echo "<div class='live_filter' id='stopword_filter'>", "<span class='icon'>", nc_admin_img("i_field_search_off.gif", NETCAT_MODULE_SEARCH_ADMIN_FILTER), "</span>", "<select id='filter_language'>", join("\n", $language_options), "</select>", "<input type='text' id='filter_word'>", "<span class='reset'>", "<div class='icons icon_delete' title='" . NETCAT_MODULE_SEARCH_ADMIN_FILTER_RESET . "' style='margin-top:5px'></div>", "</span>", "</div>";
    ?>

    <form method="POST" action="?view=stopwords" onsubmit="return ($nc('input:checked').size() > 0)">
        <input type="hidden" name="action" value="delete" />
        <input type="hidden" name="data_class" value="nc_search_language_stopword" />
        <table id="stopword_table" class="nc-table nc--striped nc--hovered nc--small" width="100%">
            <tr align="left">
                <th><?php 
    echo NETCAT_MODULE_SEARCH_ADMIN_LANGUAGE;
    ?>
</th>
                <th width="75%"><?php 
    echo NETCAT_MODULE_SEARCH_ADMIN_STOPWORD;
    ?>
Ejemplo n.º 23
0
 public function partial($name, $data = array())
 {
     $partial_file = nc_core()->template->get_partials_path($this->root_template_id, $name);
     return new nc_template_partial($this, $partial_file, $data);
 }
Ejemplo n.º 24
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);
             }
         }
     }
 }
 public function action_edit($template_id, $partial_name)
 {
     $this->partial = $partial_name;
     $this->template_id = (int) $template_id;
     $data = array('action' => 'edit');
     $this->ui_config('edit', CONTROL_TEMPLATE_PARTIALS . ' <small>' . $partial_name . '</small>');
     $this->ui_config->locationHash = "template.partials_edit({$this->template_id}, {$partial_name})";
     if (nc_core()->input->fetch_get('addNode')) {
         $node_id = $template_id;
         $partial = $partial_name;
         $fs_suffix = '_fs';
         $this->ui_config->treeChanges['addNode'][] = array("parentNodeId" => "template_partials-{$node_id}", "nodeId" => "template_partial-{$node_id}-{$partial}", "name" => $partial, "href" => "#template.partials_edit({$node_id}, {$partial})", "sprite" => 'dev-com-templates', "buttons" => array(nc_get_array_2json_button(CONTROL_TEMPLATE_PARTIALS_REMOVE, "template{$fs_suffix}.partials_remove({$node_id}, {$partial})", "nc-icon nc--remove nc--hovered")));
     }
     $partial_file = $this->nc_core->template->get_partials_path($this->template_id, $partial_name);
     if (file_exists($partial_file)) {
         if (isset($_POST['partial_source'])) {
             $partial_source = $this->nc_core->input->fetch_post('partial_source');
             file_put_contents($partial_file, $partial_source);
         }
         $partial_source = file_get_contents($partial_file);
         $data['partial_name'] = $partial_name;
         $data['partial_source'] = $partial_source;
     } else {
         nc_print_status('Template not found', 'error');
         return;
     }
     $this->ui_config->actionButtons[] = array('caption' => NETCAT_CUSTOM_ONCE_SAVE, 'action' => "nc.view.main('form').submit(); return false");
     return $this->view('template_partials/edit', $data);
 }
Ejemplo n.º 26
0
    die;
}
$ui = $this->get_ui();
$ui->add_lists_toolbar();
$nc_core = nc_Core::get_object();
// предупредить, если мы сохранили не то, что ввёл пользователь
$crud_record = $this->get_action_record();
if ($crud_record && !$crud_record->get('dont_filter')) {
    $input = $this->get_input('data');
    $saved_value = !$nc_core->NC_UNICODE ? $nc_core->utf8->array_utf2win($crud_record->get('words')) : $crud_record->get('words');
    if ($input['words'] != $saved_value) {
        nc_print_status(NETCAT_MODULE_SEARCH_ADMIN_SYNONYM_SAVE_RESULT, 'info', array(join(' ', $saved_value), $this->hash_href("#module.search.synonyms_edit({$crud_record->get_id()})")));
    }
}
// end of "show a notice"
$synonyms = nc_search::load('nc_search_language_synonyms', "SELECT * FROM `%t%` ORDER BY `Language`")->set_output_encoding(nc_core('NC_CHARSET'));
if (count($synonyms)) {
    // фильтр
    $language_options = array("<option value=''>" . NETCAT_MODULE_SEARCH_ADMIN_LANGUAGE_ANY_LANGUAGE . "</option>");
    foreach ($this->get_language_list() as $code => $lang) {
        if ($synonyms->first('language', $code)) {
            $language_options[] = "<option value='{$code}'>{$lang}</option>";
        }
    }
    echo "<div class='live_filter' id='synonym_filter'>", "<span class='icon'>", nc_admin_img("i_field_search_off.gif", NETCAT_MODULE_SEARCH_ADMIN_FILTER), "</span>", "<select id='filter_language'>", join("\n", $language_options), "</select>", "<input type='text' id='filter_words'>", "<span class='reset'>", "<div class='icons icon_delete' title='" . NETCAT_MODULE_SEARCH_ADMIN_FILTER_RESET . "' style='margin-top:5px'></div>", "</span>", "</div>";
    ?>

    <form method="POST" action="?view=synonyms" onsubmit="return ($nc('input:checked').size() > 0)">
        <input type="hidden" name="action" value="delete" />
        <input type="hidden" name="data_class" value="nc_search_language_synonyms" />
        <table id="synonym_table" class="nc-table nc--striped nc--hovered nc--small" width="100%">
Ejemplo n.º 27
0
 /**
  * Полный путь к папке (файлу) экспорта
  * @param  string $file Имя файл
  * @return string
  */
 public function get_export_path($file = null)
 {
     return nc_core()->FILES_FOLDER . self::EXPORT_FOLDER . DIRECTORY_SEPARATOR . $file;
 }
Ejemplo n.º 28
0
<?php

/**
 * Script that can be included to initialize NetCat scripts and check user rights
 * (e.g. in scripts that should output JSON data)
 */
$NETCAT_FOLDER = realpath(dirname(__FILE__) . "/../../../../") . "/";
include_once $NETCAT_FOLDER . "vars.inc.php";
require_once $ADMIN_FOLDER . "function.inc.php";
/** @var Permission $perm */
$perm->ExitIfNotAccess(NC_PERM_MODULE, 0, 0, 0, 1);
if (nc_core('gzip')->check()) {
    ob_start('ob_gzhandler');
}
Ejemplo n.º 29
0
 public function import_files()
 {
     $save_ids = $this->get_import_settings('save_ids');
     $import_files = $this->get_dump_info('files');
     $doc_root = nc_core('DOCUMENT_ROOT');
     foreach ($import_files as $path => $files) {
         foreach ($files as $file => $src) {
             $path = rtrim($path, '/') . '/';
             $file = trim($file, '/');
             $file_path = $path . $file;
             $this->call_event('before_copy_file', array($path, $file), $file_path);
             $dest = $doc_root . $file_path;
             $src = $this->get_dump_path($src);
             // $replace = false;
             // if ($this->copy_files($src, $dest, $replace, $result)) {
             //     $this->set_import_result('total_copied_files',   $result['copied'], true);
             //     $this->set_import_result('total_skipped_files',  $result['skipped'], true);
             //     $this->set_import_result('total_replaced_files', $result['replaced'], true);
             // }
             if (file_exists($dest) && is_dir($dest)) {
                 remove_dir($dest);
             }
             $parent_dir = dirname($dest);
             if (!file_exists($parent_dir)) {
                 mkdir($parent_dir);
             }
             if (@rename($src, $dest)) {
                 $this->set_import_result('total_copied_files', +1, true);
             } else {
                 $this->set_import_result('total_skipped_files', +1, true);
             }
             $this->call_event('after_copy_file', array($dest));
         }
     }
 }
Ejemplo n.º 30
0
 /**
  * 'собственно функция для получения нужной информации'
  * @access private
  */
 function fetch_by_query($qry)
 {
     global $db;
     $this->subclasses = $db->get_results($qry, ARRAY_A);
     if ($this->subclasses[0]) {
         $this->catalogue_id = $this->subclasses[0]['Catalogue_ID'];
         $this->subdivision_id = $this->subclasses[0]['Subdivision_ID'];
         $this->subdivision_name = $this->subclasses[0]['Subdivision_Name'];
         $this->subdivision_checked = $this->subclasses[0]['Checked'];
         $this->label_color = $this->subclasses[0]['LabelColor'];
         if (nc_module_check_by_keyword('routing')) {
             $this->subdivision_url = nc_routing::get_folder_path($this->subclasses[0]['Subdivision_ID']);
         } else {
             $this->subdivision_url = nc_core('SUB_FOLDER') . $this->subclasses[0]['Hidden_URL'];
         }
         $this->check_rights();
     }
 }