Example #1
0
/**
 * Вывод поля типа "Текстовый блок" в альтернативных формах шаблона
 * @param string имя поля
 * @param string дополнительные свойства для <input ...>
 * @param int идентификатор компонента, его стоит указывать при вызове функции т.к. в функции s_list_class() его глобальное значение будет иное
 * @param bool выводить описание поля или нет
 * @param bool выводить панельку с BB-кодами (для панельки нужны IDшники формы и поля, а также стили CSS!)
 * @param string значение по умолчанию
 * @return string
 */
function nc_text_field($field_name, $style = "", $classID = "", $caption = false, $bbcode = false, $value = '')
{
    // для получения значения поля
    global $fldValue, $fldID, $systemTableID;
    global $SUB_FOLDER, $HTTP_ROOT_PATH, $ROOT_FOLDER;
    $nc_core = nc_Core::get_object();
    $system_env = $nc_core->get_settings();
    $allowTags = $nc_core->sub_class->get_current('AllowTags');
    // текущее значение компонента
    if (!$classID) {
        $classID = $nc_core->sub_class->get_current('Class_ID');
    }
    $show_field_errors = $classID == $nc_core->sub_class->get_current('Class_ID');
    $sysTable = $systemTableID ? $systemTableID : $nc_core->component->get_by_id($classID, 'System_Table_ID');
    $component = new nc_Component($classID, $sysTable);
    $fields = $component->get_fields(NC_FIELDTYPE_TEXT);
    // поиск поля
    $field = 0;
    foreach ($fields as $v) {
        if ($v['name'] == $field_name) {
            $field = $v;
        }
    }
    // поля не существует
    if (!$field) {
        if ($show_field_errors) {
            trigger_error("<b>nc_text_field()</b>: Incorrect field name (" . $field_name . ")", E_USER_WARNING);
        }
        return false;
    }
    // поле не доступно для редактирования
    if ($field['edit_type'] == 3 || $field['edit_type'] == 2 && !nc_field_check_admin_perm()) {
        return false;
    }
    // значение поля
    if (!$value && is_array($fldID)) {
        $t = array_flip($fldID);
        $value = $fldValue[$t[$field['id']]];
    }
    # формат поля
    $format = nc_field_parse_format($field['format'], 3);
    $rows = $format['rows'];
    $cols = $format['cols'];
    # проверим, есть ли в параметре "style", атрибуты
    $style_attr = nc_reg_search_html_attr($style);
    # прописываем параметры из формата поля "Текстовый блок", учитывая параметры из $style
    $style_opt = "";
    if (!in_array("rows", $style_attr)) {
        $style_opt .= "rows='" . ($rows ? $rows : "5") . "'";
    }
    if (!in_array("cols", $style_attr)) {
        $style_opt .= ($style_opt ? " " : "") . "cols='" . ($cols ? $cols : "60") . "'";
    }
    if ($style_opt) {
        $style_opt = " " . $style_opt;
    }
    // вывод функции
    $result = '';
    # вывод Caption, если нужно
    if ($caption) {
        $result .= nc_field_caption($field);
    }
    # учтем allowTags еще и от самого формата поля
    // $format['html']: 0- наследовать, 1 - разрешить, 2 - запретить
    if ($format['html']) {
        $allowTags = $format['html'] == 1;
    }
    #редактор встроен или нет?
    $EditorType = $nc_core->get_settings('EditorType');
    $EmbedEditor = false;
    if ($format['fck']) {
        $EmbedEditor = $format['fck'] == 1;
    } else {
        $CkeditorEmbedEditor = $nc_core->get_settings('CkeditorEmbedEditor');
        $FckeditorEmbedEditor = $nc_core->get_settings('FckeditorEmbedEditor');
        if ($EditorType == 2) {
            if ($FckeditorEmbedEditor !== false) {
                $EmbedEditor = $FckeditorEmbedEditor;
            } else {
                $EmbedEditor = $nc_core->get_settings('EmbedEditor');
            }
        } else {
            if ($EditorType == 3) {
                if ($CkeditorEmbedEditor !== false) {
                    $EmbedEditor = $CkeditorEmbedEditor;
                } else {
                    $EmbedEditor = $nc_core->get_settings('EmbedEditor');
                }
            }
        }
    }
    $no_cm = '';
    # если разрешены HTML-теги, вывести кнопку
    if ($nc_core->admin_mode && $allowTags && $system_env['EditorType'] > 1 && $EmbedEditor != 1) {
        $sess_id = $AUTHORIZATION_TYPE == "session" ? "&" . session_name() . "=" . session_id() : "";
        $windowWidth = 750;
        $windowHeight = 605;
        switch ($EditorType) {
            default:
            case 2:
                $editor_name = 'FCKeditor';
                break;
            case 3:
                $editor_name = 'ckeditor4';
                $windowWidth = 1100;
                $windowHeight = 420;
                break;
            case 4:
                $editor_name = 'tinymce';
                break;
        }
        $link = "editors/{$editor_name}/neditor.php";
        $result .= "<button type='button' onclick=\"window.open('" . $SUB_FOLDER . $HTTP_ROOT_PATH . $link . "?form=adminForm&control=f_" . $field_name . $sess_id . "', 'Editor', 'width={$windowWidth},height={$windowHeight},resizable=yes,scrollbars=no,toolbar=no,location=no,status=no,menubar=no');\">" . TOOLS_HTML_INFO . "</button><br />";
        $no_cm = " class='no_cm' ";
    } elseif ($allowTags && $system_env['EditorType'] > 1 && $EmbedEditor == 1) {
        include_once $ROOT_FOLDER . "editors/nc_editors.class.php";
        $editor = new nc_Editors($system_env['EditorType'], "f_" . $field_name, $value, $format['panel']);
        $result .= $editor->get_html();
        unset($editor);
    }
    if (!$nc_core->inside_admin && ($format['bbcode'] || $bbcode)) {
        $result .= nc_bbcode_bar('this', 'adminForm', 'f_' . $field_name, 1);
    }
    if (!$allowTags || $EmbedEditor != 1) {
        $result .= "<textarea {$no_cm} id='f_" . $field_name . "' name='f_" . $field_name . "'" . $style_opt . ($style ? " " . $style : "") . ">" . htmlspecialchars($value) . "</textarea>";
    }
    if ($format['typo']) {
        $result .= '<br><input type="button" onclick="nc_typo_field(\'f_' . $field_name . '\'); return false;" value="' . CONTROL_FIELD_TYPO_BUTTON . '">';
    }
    //$result .= nc_field_validation('textarea', 'f_'.$field_name, $field['id'], 'text', $field['not_null']);
    return $result;
}
Example #2
0
 /**
  * @param $header
  * @param $location
  * @param $active_toolbar
  */
 function ui_config_wysiwyg($header, $location, $active_tab, $active_toolbar)
 {
     $this->headerText = $header;
     $this->locationHash = $location;
     $this->treeMode = 'sitemap';
     $this->tabs = array(array('id' => 'ckeditor-tab', 'caption' => NETCAT_SETTINGS_EDITOR_CKEDITOR, 'location' => "wysiwyg.ckeditor.settings"));
     if (nc_Editors::fckeditor_exists()) {
         $this->tabs[] = array('id' => 'fckeditor-tab', 'caption' => NETCAT_SETTINGS_EDITOR_FCKEDITOR, 'location' => "wysiwyg.fckeditor.settings");
     } else {
         $this->tabs[] = array('id' => 'dummy-tab', 'caption' => '', 'location' => "");
     }
     if ($active_tab == 'fckeditor-tab') {
         $this->activeTab = 'fckeditor-tab';
         $this->toolbar = array(array('id' => 'fckeditor-settings', 'caption' => NETCAT_WYSIWYG_CKEDITOR_SETTINGS_TAB_SETTINGS, 'location' => "wysiwyg.fckeditor.settings", 'group' => 'grp1'));
     } else {
         $this->activeTab = 'ckeditor-tab';
         $this->toolbar = array(array('id' => 'ckeditor-settings', 'caption' => NETCAT_WYSIWYG_CKEDITOR_SETTINGS_TAB_SETTINGS, 'location' => "wysiwyg.ckeditor.settings", 'group' => 'grp1'), array('id' => 'ckeditor-panels', 'caption' => NETCAT_WYSIWYG_CKEDITOR_SETTINGS_TAB_PANELS, 'location' => "wysiwyg.ckeditor.panels", 'group' => 'grp1'));
     }
     $this->activeToolbarButtons = array($active_toolbar);
 }