Быстрый лёгкий надёжный форумный движок
Вы не вошли.
Как придать имя при создании спойлера. Т.е что бы вместо надписи Скрытый текст указывалось то что ты вписал
Примерно такого вида [spoiler=Имя]Текст[/spoiler]
Редактировался FeSs (2010-12-10 05:55:52)
Offline
Примерно так надо сделать.
Этот блок в парсере
if (strpos($text, '[spoiler]') !== false)
{
$text = str_replace('[spoiler]', "<div> <div style=\"margin-bottom:2px\"><strong>".$lang_common['Hidden text']."</strong>: <input type=\"button\" value=\"".$lang_common['Show']."\" style=\"width:60px;font-size:10px;margin:0px;padding:0px;\" onClick=\"if (this.parentNode.parentNode.getElementsByTagName('div')[1].getElementsByTagName('div')[0].style.display != '') { this.parentNode.parentNode.getElementsByTagName('div')[1].getElementsByTagName('div')[0].style.display = ''; this.innerText = ''; this.value = '".$lang_common['Hide']."'; } else { this.parentNode.parentNode.getElementsByTagName('div')[1].getElementsByTagName('div')[0].style.display = 'none'; this.innerText = ''; this.value = '".$lang_common['Show']."'; }\"> </div> <div style=\"margin: 0px; padding: 6px; border: 1px inset;\"> <div style=\"display: none;\">", $text);
$text = str_replace('[/spoiler]', '</div> </div> </div>', $text);
}
заменить на этот
if (strpos($text, '[spoiler') !== false)
{
$text = str_replace('[spoiler]', "<div> <div style=\"margin-bottom:2px\"><strong>".$lang_common['Hidden text']."</strong>: <input type=\"button\" value=\"".$lang_common['Show']."\" style=\"width:60px;font-size:10px;margin:0px;padding:0px;\" onClick=\"if (this.parentNode.parentNode.getElementsByTagName('div')[1].getElementsByTagName('div')[0].style.display != '') { this.parentNode.parentNode.getElementsByTagName('div')[1].getElementsByTagName('div')[0].style.display = ''; this.innerText = ''; this.value = '".$lang_common['Hide']."'; } else { this.parentNode.parentNode.getElementsByTagName('div')[1].getElementsByTagName('div')[0].style.display = 'none'; this.innerText = ''; this.value = '".$lang_common['Show']."'; }\"> </div> <div style=\"margin: 0px; padding: 6px; border: 1px inset;\"> <div style=\"display: none;\">", $text);
$text = preg_replace('#\[spoiler=(.*?)\]#se', '"<div> <div style=\"margin-bottom:2px\"><strong>$1</strong>: <input type=\"button\" value=\"".$lang_common['Show']."\" style=\"width:60px;font-size:10px;margin:0px;padding:0px;\" onClick=\"if (this.parentNode.parentNode.getElementsByTagName(\'div\')[1].getElementsByTagName(\'div\')[0].style.display != \'\') { this.parentNode.parentNode.getElementsByTagName(\'div\')[1].getElementsByTagName(\'div\')[0].style.display = \'\'; this.innerText = \'\'; this.value = \'".$lang_common[\'Hide\']."\'; } else { this.parentNode.parentNode.getElementsByTagName(\'div\')[1].getElementsByTagName(\'div\')[0].style.display = \'none\'; this.innerText = \'\'; this.value = \'".$lang_common[\'Show\']."\'; }\"> </div> <div style=\"margin: 0px; padding: 6px; border: 1px inset;\"> <div style=\"display: none;\">"', $text);
$text = str_replace('[/spoiler]', '</div> </div> </div>', $text);
}
З.Ы. Работоспособность не проверял. Писал по типу бб-кода quote.
Редактировался Visman (2010-12-10 12:24:48)
Моя сборка FluxBB 1.5, ForkBB · сообщество
Offline
Visman, Где-то ошибка, а верхний код работает. Кстати, откуда он, самопал? В оригинале нету спойлера.
Offline
scalemaster, это из моей сборки.
А по ошибке в логи посмотри на что там PHP ругается.
Моя сборка FluxBB 1.5, ForkBB · сообщество
Offline
Parse error: syntax error, unexpected T_STRING in /include/parser.php on line 859
Кстати, как сделать, чтобы в скрытом виде пустое окошко строчку не занимало? Бордер 0 ставлю, но тогда в распахнутом виде нету границы.
Редактировался scalemaster (2010-12-10 11:12:03)
Offline
Первое свое сообщение изменил.
scalemaster, в первом приближении полное скрытие спойлера выглядит так:
$text = str_replace('[spoiler]', "<div> <div style=\"margin-bottom:2px\"><strong>".$lang_common['Hidden text']."</strong>: <input type=\"button\" value=\"".$lang_common['Show']."\" style=\"width:60px;font-size:10px;margin:0px;padding:0px;\" onClick=\"if (this.parentNode.parentNode.getElementsByTagName('div')[1].style.display != '') { this.parentNode.parentNode.getElementsByTagName('div')[1].style.display = ''; this.innerText = ''; this.value = '".$lang_common['Hide']."'; } else { this.parentNode.parentNode.getElementsByTagName('div')[1].style.display = 'none'; this.innerText = ''; this.value = '".$lang_common['Show']."'; }\"> </div> <div style=\"margin: 0px; padding: 6px; border: 1px inset; display: none;\"> <div style=\"\">", $text);
Моя сборка FluxBB 1.5, ForkBB · сообщество
Offline
Visman
Parse error: syntax error, unexpected T_STRING in /var/www/industri/data/www/die-krupps.ru/forum/include/parser.php on line 796
Ругается на эту строку
$text = preg_replace('#\[spoiler=(.*?)\]#se', '"<div> <div style=\"margin-bottom:2px\"><strong>$1</strong>: <input type=\"button\" value=\"".$lang_common['Show']."\" style=\"width:60px;font-size:10px;margin:0px;padding:0px;\" onClick=\"if (this.parentNode.parentNode.getElementsByTagName(\'div\')[1].getElementsByTagName(\'div\')[0].style.display != \'\') { this.parentNode.parentNode.getElementsByTagName(\'div\')[1].getElementsByTagName(\'div\')[0].style.display = \'\'; this.innerText = \'\'; this.value = \'".$lang_common[\'Hide\']."\'; } else { this.parentNode.parentNode.getElementsByTagName(\'div\')[1].getElementsByTagName(\'div\')[0].style.display = \'none\'; this.innerText = \'\'; this.value = \'".$lang_common[\'Show\']."\'; }\"> </div> <div style=\"margin: 0px; padding: 6px; border: 1px inset;\"> <div style=\"display: none;\">"', $text);
Ошибка появляется когда заходишь в тему
Offline
Еще в этом
$lang_common['Show']
так
$lang_common[\'Show\']
Моя сборка FluxBB 1.5, ForkBB · сообщество
Offline
Поменял в 3 местах все равно не пашет
Offline
Ленивые вы все
Вот проверенный код из моей сборки
if (strpos($text, '[spoiler') !== false)
{
// $text = str_replace('[spoiler]', "<div> <div style=\"margin-bottom:2px\"><strong>".$lang_common['Hidden text']."</strong>: <input type=\"button\" value=\"".$lang_common['Show']."\" style=\"width:60px;font-size:10px;margin:0px;padding:0px;\" onClick=\"if (this.parentNode.parentNode.getElementsByTagName('div')[1].getElementsByTagName('div')[0].style.display != '') { this.parentNode.parentNode.getElementsByTagName('div')[1].getElementsByTagName('div')[0].style.display = ''; this.innerText = ''; this.value = '".$lang_common['Hide']."'; } else { this.parentNode.parentNode.getElementsByTagName('div')[1].getElementsByTagName('div')[0].style.display = 'none'; this.innerText = ''; this.value = '".$lang_common['Show']."'; }\"> </div> <div style=\"margin: 0px; padding: 6px; border: 1px inset;\"> <div style=\"display: none;\">", $text);
// $text = str_replace('[/spoiler]', '</div> </div> </div>', $text);
$text = str_replace('[spoiler]', "<div><div style=\"margin-bottom:2px\"><strong>".$lang_common['Hidden text']."</strong>: <input type=\"button\" value=\"".$lang_common['Show']."\" style=\"width:60px;font-size:10px;margin:0px;padding:0px;\" onClick=\"if (this.parentNode.parentNode.getElementsByTagName('div')[1].style.display != '') { this.parentNode.parentNode.getElementsByTagName('div')[1].style.display = ''; this.innerText = ''; this.value = '".$lang_common['Hide']."'; } else { this.parentNode.parentNode.getElementsByTagName('div')[1].style.display = 'none'; this.innerText = ''; this.value = '".$lang_common['Show']."'; }\"></div><div style=\"margin: 0px; padding: 6px; border: 1px inset; display: none;\">", $text);
$text = preg_replace('#\[spoiler=(.*?)\]#se', '"<div><div style=\"margin-bottom:2px\"><strong>".\'$1\'."</strong>: <input type=\"button\" value=\"".$lang_common[\'Show\']."\" style=\"width:60px;font-size:10px;margin:0px;padding:0px;\" onClick=\"if (this.parentNode.parentNode.getElementsByTagName(\'div\')[1].style.display != \'\') { this.parentNode.parentNode.getElementsByTagName(\'div\')[1].style.display = \'\'; this.innerText = \'\'; this.value = \'".$lang_common[\'Hide\']."\'; } else { this.parentNode.parentNode.getElementsByTagName(\'div\')[1].style.display = \'none\'; this.innerText = \'\'; this.value = \'".$lang_common[\'Show\']."\'; }\"></div><div style=\"margin: 0px; padding: 6px; border: 1px inset; display: none;\">"', $text);
$text = str_replace('[/spoiler]', '</div></div>', $text);
}
Подходит только к ней.
Если хотите ставить на стандартном форуме, смотрите где в парсере добавлен spoiler и какие языковый переменные заведены дополнительно.
Моя сборка FluxBB 1.5, ForkBB · сообщество
Offline
Visman спасибо, заработало.
Только я мало того что ленивый, так еще и не знаю ничего)
Offline
Еще вопрос как кнопку Показать поменять на 2 графических (gif) элемента вида + при разворачивании и минуса при сворачивании. И Сделать не в конце названия эту кнопку а впереди
Offline
FeSs, кнопка тут рисуется кодом
<input type=\"button\" value=\"".$lang_common['Show']."\" style=\"width:60px;font-size:10px;margin:0px;padding:0px;\" onClick=\"if (this.parentNode.parentNode.getElementsByTagName('div')[1].style.display != '') { this.parentNode.parentNode.getElementsByTagName('div')[1].style.display = ''; this.innerText = ''; this.value = '".$lang_common['Hide']."'; } else { this.parentNode.parentNode.getElementsByTagName('div')[1].style.display = 'none'; this.innerText = ''; this.value = '".$lang_common['Show']."'; }\">
Чтобы она была спереди текста, этот код перетаскиваем и ставим перед <strong>.
Чтобы это была картинка меняй
input type=\"button\" value=\"".$lang_common['Show']."\" style=\"width:60px;font-size:10px;margin:0px;padding:0px;\"
на что-то такое
img src=\"АДРЕС КАРТИНКИ\"
а для смены картинок нужно эти куски
this.innerText = ''; this.value = '".$lang_common['Hide']."';
this.innerText = ''; this.value = '".$lang_common['Show']."';
сменить на что-то такое
this.src.replace('up','down');
this.src.replace('down','up');
т.е. имя файлов картинок должны различаться только на up и down по аналоги с коллапсом категорий.
Моя сборка FluxBB 1.5, ForkBB · сообщество
Offline
Чудесным образом наверное, потому что я хз, но после всех этих поправок все осталось как было xD
картинки обозвал spoiler_up и spoiler_down соответственно
всунул их в /forum/img/
Указал img src=\"/img/spoiler_.gif\"
Незнаю, вижу что много странностей для меня не понятных....и море сомнений
Offline
Указал img src=\"/img/spoiler_.gif\"
img src=\"img/spoiler_down.gif\"
Моя сборка FluxBB 1.5, ForkBB · сообщество
Offline
Все как было так и осталось....вообще никаких измененией
if (strpos($text, '[spoiler') !== false)
{
// $text = str_replace('[spoiler]', "<div> <div style=\"margin-bottom:2px\"><img src=\"http://die-krupps.ru/forum/img/spoiler_down.gif\" onClick=\"if (this.parentNode.parentNode.getElementsByTagName('div')[1].getElementsByTagName('div')[0].style.display != '') { this.parentNode.parentNode.getElementsByTagName('div')[1].getElementsByTagName('div')[0].style.display = ''; this.src.replace('up','down'); } else { this.parentNode.parentNode.getElementsByTagName('div')[1].getElementsByTagName('div')[0].style.display = 'none'; this.src.replace('down','up'); }\"><strong>".$lang_common['Hidden text']."</strong> </div> <div style=\"margin: 0px; padding: 6px; border: 1px inset;\"> <div style=\"display: none;\">", $text);
// $text = str_replace('[/spoiler]', '</div> </div> </div>', $text);
$text = str_replace('[spoiler]', "<div><div style=\"margin-bottom:2px\"><img src=\"img/spoiler_down.gif\" onClick=\"if (this.parentNode.parentNode.getElementsByTagName('div')[1].style.display != '') { this.parentNode.parentNode.getElementsByTagName('div')[1].style.display = ''; this.src.replace('up','down'); } else { this.parentNode.parentNode.getElementsByTagName('div')[1].style.display = 'none'; this.src.replace('down','up'); }\"><strong>".$lang_common['Hidden text']."</strong> </div><div style=\"margin: 0px; padding: 6px; border: 1px inset; display: none;\">", $text);
$text = preg_replace('#\[spoiler=(.*?)\]#se', '"<div><div style=\"margin-bottom:2px\"><strong>".\'$1\'."</strong>: <input type=\"button\" value=\"".$lang_common[\'Show\']."\" style=\"width:60px;font-size:10px;margin:0px;padding:0px;\" onClick=\"if (this.parentNode.parentNode.getElementsByTagName(\'div\')[1].style.display != \'\') { this.parentNode.parentNode.getElementsByTagName(\'div\')[1].style.display = \'\'; this.innerText = \'\'; this.value = \'".$lang_common[\'Hide\']."\'; } else { this.parentNode.parentNode.getElementsByTagName(\'div\')[1].style.display = \'none\'; this.innerText = \'\'; this.value = \'".$lang_common[\'Show\']."\'; }\"></div><div style=\"margin: 0px; padding: 6px; border: 1px inset; display: none;\">"', $text);
$text = str_replace('[/spoiler]', '</div></div>', $text);
}
Offline
FeSs, так изменен вариант только для [ spoiler ]. А для [ spoiler= кто будет менять?
По аналогии с первым нужно делать.
Моя сборка FluxBB 1.5, ForkBB · сообщество
Offline
Получилось, но + на - не меняется
Offline
FeSs, я же сказал по аналогии с первым.
Почему это
а для смены картинок нужно эти куски
this.innerText = ''; this.value = '".$lang_common['Hide']."';
this.innerText = ''; this.value = '".$lang_common['Show']."';
сменить на что-то такое
this.src.replace('up','down');
this.src.replace('down','up');
не сделано?
Моя сборка FluxBB 1.5, ForkBB · сообщество
Offline
Изменено же...
if (strpos($text, '[spoiler') !== false)
{
// $text = str_replace('[spoiler]', "<div> <div style=\"margin-bottom:2px\"><img src=\"http://die-krupps.ru/forum/img/spoiler_down.gif\" onClick=\"if (this.parentNode.parentNode.getElementsByTagName('div')[1].getElementsByTagName('div')[0].style.display != '') { this.parentNode.parentNode.getElementsByTagName('div')[1].getElementsByTagName('div')[0].style.display = ''; this.src.replace('up','down'); } else { this.parentNode.parentNode.getElementsByTagName('div')[1].getElementsByTagName('div')[0].style.display = 'none'; this.src.replace('down','up'); }\"> <strong>".$lang_common['Hidden text']."</strong> </div> <div style=\"margin: 0px; padding: 6px; border: 1px inset;\"> <div style=\"display: none;\">", $text);
// $text = str_replace('[/spoiler]', '</div> </div> </div>', $text);
$text = str_replace('[spoiler]', "<div><div style=\"margin-bottom:2px\"><img src=\"http://die-krupps.ru/forum/img/spoiler_down.gif\" onClick=\"if (this.parentNode.parentNode.getElementsByTagName('div')[1].style.display != '') { this.parentNode.parentNode.getElementsByTagName('div')[1].style.display = ''; this.src.replace('up','down'); } else { this.parentNode.parentNode.getElementsByTagName('div')[1].style.display = 'none'; this.src.replace('down','up'); }\"> <strong>".$lang_common['Hidden text']."</strong> </div><div style=\"margin: 0px; padding: 6px; border: 1px inset; display: none;\">", $text);
$text = preg_replace('#\[spoiler=(.*?)\]#se', '"<div><div style=\"margin-bottom:2px\"><img src=\"http://die-krupps.ru/forum/img/spoiler_up.gif\" onClick=\"if (this.parentNode.parentNode.getElementsByTagName(\'div\')[1].style.display != \'\') { this.parentNode.parentNode.getElementsByTagName(\'div\')[1].style.display = \'\'; this.innerText = \'\'; this.value = \'".$lang_common[\'Hide\']."\'; } else { this.parentNode.parentNode.getElementsByTagName(\'div\')[1].style.display = \'none\'; this.innerText = \'\'; this.value = \'".$lang_common[\'Show\']."\'; }\"> <strong>".\'$1\'."</strong> </div><div style=\"margin: 0px; padding: 6px; border: 1px inset; display: none;\">"', $text);
$text = str_replace('[/spoiler]', '</div></div>', $text);
}
Offline
FeSs, в строке с preg_replace, которая отвечает за спойлер с подписью, как были команды на переименование кнопки ( this.innerText = \'\'; this.value = \'".$lang_common[\'Hide\']."\'; this.innerText = \'\'; this.value = \'".$lang_common[\'Show\']."\'; ), так и остались.
З.Ы. Строки начинающиеся с // есть комментарий и их код не работает.
Моя сборка FluxBB 1.5, ForkBB · сообщество
Offline
Заменил, теперь он просто на строку preg_replace ругается
$text = str_replace('[spoiler]', "<div><div style=\"margin-bottom:2px\"><img src=\"http://die-krupps.ru/forum/img/spoiler_down.gif\" onClick=\"if (this.parentNode.parentNode.getElementsByTagName('div')[1].style.display != '') { this.parentNode.parentNode.getElementsByTagName('div')[1].style.display = ''; this.src.replace('up','down'); } else { this.parentNode.parentNode.getElementsByTagName('div')[1].style.display = 'none'; this.src.replace('down','up'); }\"> <strong>".$lang_common['Hidden text']."</strong> </div><div style=\"margin: 0px; padding: 6px; border: 1px inset; display: none;\">", $text);
$text = preg_replace('#\[spoiler=(.*?)\]#se', '"<div><div style=\"margin-bottom:2px\"><img src=\"http://die-krupps.ru/forum/img/spoiler_up.gif\" onClick=\"if (this.parentNode.parentNode.getElementsByTagName(\'div\')[1].style.display != \'\') { this.parentNode.parentNode.getElementsByTagName(\'div\')[1].style.display = \'\'; this.src.replace('up','down'); } else { this.parentNode.parentNode.getElementsByTagName(\'div\')[1].style.display = \'none\'; this.src.replace('down','up'); }\"> <strong>".\'$1\'."</strong> </div><div style=\"margin: 0px; padding: 6px; border: 1px inset; display: none;\">"', $text);
$text = str_replace('[/spoiler]', '</div></div>', $text);
Offline
Пробуй так
$text = preg_replace('#\[spoiler=(.*?)\]#se', '"<div><div style=\"margin-bottom:2px\"><img src=\"http://die-krupps.ru/forum/img/spoiler_up.gif\" onClick=\"if (this.parentNode.parentNode.getElementsByTagName(\'div\')[1].style.display != \'\') { this.parentNode.parentNode.getElementsByTagName(\'div\')[1].style.display = \'\'; this.src.replace(\'up\',\'down\'); } else { this.parentNode.parentNode.getElementsByTagName(\'div\')[1].style.display = \'none\'; this.src.replace(\'down\',\'up\'); }\"> <strong>".\'$1\'."</strong> </div><div style=\"margin: 0px; padding: 6px; border: 1px inset; display: none;\">"', $text);
И разберись где up должен быть, где down, а то с первой строкой не совпадает.
Моя сборка FluxBB 1.5, ForkBB · сообщество
Offline
пробовал, все равно, хотя подсвечивает именно эти слова up и down и именно в этой строке
Offline
$text = preg_replace('#\[spoiler=(.*?)\]#se', '"<div><div style=\"margin-bottom:2px\"><img src=\"img/spoiler_up.gif\" onClick=\"if (this.parentNode.parentNode.getElementsByTagName(\'div\')[1].style.display != \'\') { this.parentNode.parentNode.getElementsByTagName(\'div\')[1].style.display = \'\'; this.src.replace(\'up\',\'down\'); } else { this.parentNode.parentNode.getElementsByTagName(\'div\')[1].style.display = \'none\'; this.src.replace(\'down\',\'up\'); }\"> <strong>".\'$1\'."</strong> </div><div style=\"margin: 0px; padding: 6px; border: 1px inset; display: none;\">"', $text);
Моя сборка FluxBB 1.5, ForkBB · сообщество
Offline