|
Автор |
Сообщение |
den
Старожил
Зарегистрирован: 31.01.2006 Сообщения: 13870 Откуда: Кировоград, Украина
|
|
|
|
В простейшем случае вызов редактора осуществляется так:
include("spaw2/spaw.inc.php");
$spaw = new SpawEditor("comment", $rows[post_content]);
$spaw->show();
Метод show() выводит редактор сразу в браузер. Иногда нужно получить HTML-код редактора, особенно, если сайт использует TPL-шаблоны. Получить HTML-код позволяет метод getHtml()
$editor = $spaw->getHtml();
...
// устанавливает TPL-переменную (шаблонизатор абстрактный)
tpl_set("editor_place", $editor);
Установить размер редактора можно так:
$spaw = new SpawEditor("comment");
SpawConfig::setStaticConfigValue('default_height','200px');
SpawConfig::setStaticConfigValue('default_width','440px');
$editor = $spaw->getHtml();
Можно размер сразу задавать при создании редактора:
$spaw = new SpawEditor('comment' /*name*/,'' /*value*/,
'en' /*language*/, 'mini' /*toolbar mode*/, '' /*theme*/,
'440px' /*width*/, '100px' /*height*/, '' /*stylesheet file*/);
Здесь comment - имя POST-переменной, '' - текст, который будет загружен в редактор, en - язык (для русского - ru), mini - минимальный набор кнопок, '' - тема, 440 (Ш) х 100 (В) - размеры браузера, последний параметр - CSS-файл
Набор кнопок редактируется еще в config.php (можно задать, что будет входить в набор mini):
SpawConfig::setStaticConfigItem('toolbarset_mini',
array(
"format" => "format_mini",
"edit" => "edit",
"tools" => "tools"
)
);
Здесь в набор mini будут входить кнопки форматирования, редактирования (undo/redo) и утилиты. Вот последние кнопки можно отключить:
SpawConfig::setStaticConfigItem('toolbarset_mini',
array(
"format" => "format_mini",
"edit" => "edit"
)
); |
|
Вернуться к началу |
dhsilabs@jabber.ru |
|
|
den
Старожил
Зарегистрирован: 31.01.2006 Сообщения: 13870 Откуда: Кировоград, Украина
|
|
|
|
Если нужно определить полностью свой набор кнопок, то идем в plugins/core/lib/toolbars/ создаем файл с именем:
название.toolbar.php
например
den.toolbar.php
В этом файле определяем кнопки, которые должны быть на нашей панели:
<?php
$items = array
(
new SpawTbButton("core", "bold", "isStandardFunctionEnabled", "isStandardFunctionPushed", "standardFunctionClick"),
new SpawTbButton("core", "italic", "isStandardFunctionEnabled", "isStandardFunctionPushed", "standardFunctionClick"),
new SpawTbButton("core", "underline", "isStandardFunctionEnabled", "isStandardFunctionPushed", "standardFunctionClick"),
new SpawTbImage("core", "separator"),
new SpawTbButton("core", "justifyleft", "isStandardFunctionEnabled", "isStandardFunctionPushed", "standardFunctionClick", SPAW_AGENT_ALL, true),
new SpawTbButton("core", "justifycenter", "isStandardFunctionEnabled", "isStandardFunctionPushed", "standardFunctionClick", SPAW_AGENT_ALL, true),
new SpawTbImage("core", "separator"),
new SpawTbButton("core", "undo", "isStandardFunctionEnabled", "", "standardFunctionClick"),
new SpawTbButton("core", "redo", "isStandardFunctionEnabled", "", "standardFunctionClick"),
new SpawTbImage("core", "separator"),
new SpawTbButton("core", "insertorderedlist", "isStandardFunctionEnabled", "isStandardFunctionPushed", "standardFunctionClick", SPAW_AGENT_ALL, true),
new SpawTbButton("core", "insertunorderedlist", "isStandardFunctionEnabled", "isStandardFunctionPushed", "standardFunctionClick", SPAW_AGENT_ALL, true),
new SpawTbButton("core", "hyperlink", "isInDesignMode", "", "hyperlinkClick", SPAW_AGENT_ALL, true),
new SpawTbButton("core", "unlink", "isStandardFunctionEnabled", "", "standardFunctionClick", SPAW_AGENT_ALL, true),
new SpawTbButton("core", "image", "isInDesignMode", "", "imageClick", SPAW_AGENT_ALL, true),
new SpawTbButton("core", "image_prop", "isInDesignMode", "", "imagePropClick", SPAW_AGENT_ALL, true)
);
?>
Если не знаешь,как прописать ту или иную кнопку, нужно просмотреть файлы *.toolbar.php - в них весь набор необходимых кнопок
Затем в config.php редактируем mini (или прописываем свой набор панелей):
SpawConfig::setStaticConfigItem('toolbarset_mini',
array(
"format" => "den"
)
); |
|
Вернуться к началу |
dhsilabs@jabber.ru |
|
|
den
Старожил
Зарегистрирован: 31.01.2006 Сообщения: 13870 Откуда: Кировоград, Украина
|
|
|
|
У редактора есть возможность изменения размера пользователем - нужно потянуть за нижний правый угол. Размер изменится. Не всегда это допустимо, так как страдает дизайн сайта. Поскольку штатными средствами я не нашел, как запретить ресайз, то отредактировал js/common/editor.js. Из него нужно удалить вот эти строки:
// resizing control
SpawEditor.prototype.isResizing = false;
SpawEditor.prototype.isVerticalResizingAllowed = function()
{
var res = this.getConfigValue("resizing_directions");
res = res?res.toLowerCase():res;
if (res == 'vertical' || res == 'both')
return true;
else
return false;
}
SpawEditor.prototype.isHorizontalResizingAllowed = function()
{
var res = this.getConfigValue("resizing_directions");
res = res?res.toLowerCase():res;
if (res == 'horizontal' || res == 'both')
return true;
else
return false;
}
SpawEditor.prototype.resizingGripMouseDown = function(event)
{
this.lastMousePosX = event.clientX;
this.lastMousePosY = event.clientY;
this.isResizing = true;
SpawEngine.resizingEditor = this;
//SpawEngine.resizingEditor.hidePage(SpawEngine.resizingEditor.getActivePage());
// prevent gecko from dragging image
if (event.preventDefault)
event.preventDefault();
}
SpawEditor.prototype.finalizeResizing = function()
{
var resobj = this.isInDesignMode()?this.getPageIframeObject(this.getActivePage().name):this.getPageInput(this.getActivePage().name);
for (var i=0; i<this.pages.length; i++)
{
var pif = this.getPageIframeObject(this.pages[i].name);
var pta = this.getPageInput(this.pages[i].name);
pif.style.height = resobj.offsetHeight + 'px';
pta.style.height = resobj.offsetHeight + 'px';
pta.style.width = resobj.offsetWidth + 'px';
}
} |
|
Вернуться к началу |
dhsilabs@jabber.ru |
|
|
|
|
 Главная страница сайта
|
Вы не можете начинать темы Вы не можете отвечать на сообщения Вы не можете редактировать свои сообщения Вы не можете удалять свои сообщения Вы не можете голосовать в опросах
|
|