Javascript.RU

 
 
Опции темы Искать в теме
  #1 (permalink)  
Старый 03.06.2009, 11:37
Новичок на форуме
Отправить личное сообщение для Vo.One Посмотреть профиль Найти все сообщения от Vo.One
 
Регистрация: 18.05.2009
Сообщений: 5

Медиа-менеджер TinyBrowser - автономная инсталляция
Задача состоит в интерграции TinyBrowser с моим php-приложением, не вызывая (в конкретном случае) TinyMCE. В readme описан следующий способ:
=================================
TinyBrowser Installation Method 2
=================================

This installation allows TinyBrowser to be used in 'stand-alone' mode, for
integration with any web application.
1) Copy the tinybrowser folder and contents to your server.
2) Place the following javascript link within the <head> tag on the page you
require TinyBrowser:

<script language="javascript" type="text/javascript"
src="/tinybrowser/tb_standalone.js.php"></script>

***NOTE:*** The above link assumes TinyBrowser is installed in your website
root directory, you will need to amend the link to your specific setup!
3) Edit the TinyBrowser configuration file (config_tinybrowser.php). The most
important settings are the file paths (these will be automatically created on
your server by TinyBrowser if they do not exist) and also the 'obfuscate'
property, which should be set to a random value.

***NOTE:*** If your server is Unix-based. you may wish to modify the
$tinybrowser['unixpermissions'] config value, which decides permissions.

4) To launch TinyBrowser use the following javascript function:

tinyBrowserPopUp('type','elementid');

'type' can contain 'image', 'media' or 'file' - corresponding to the type of
file you want TinyBrowser to manage.

'elementid' is the id of the page element you want populate with the file url
TinyBrowser returns - this is generally a form text input. If you want to
immediately display the image then create an <img> tag with the same element
id, only suffixed with img - e.g. elementidimg.

Вот фрагмент моего HTML:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
   <script language="javascript" type="text/javascript"  src="/tiny_mce/plugins/tinybrowser/tb_standalone.js.php"></script>
</head>
<body>
<form name="banner-editor" method="POST" action="/admin/index.php"> 
<TABLE><TR><TD>ID</TD><TD>Заголовок</TD><TD>Описание</TD><TD>Ссылка</TD><TD>Ссылка на изображение</TD><TD>Скрыть?</TD>
					<tr style="background-color: #E3E3E3"><td>&nbsp;</td><td><img width="220" height="90" alt="banner" src="../img/banners/1.jpg" /></td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td></tr>
					<TR style="background-color: #E3E3E3">
					<TD><font color="red">A</font></TD>

					<TD><input type="text" name="b_title_0" value="Banner A" /></TD>
					<TD><input type="text" name="b_dscr_0" value="Описание баннера А" /></TD>
					<TD><input type="text" name="b_link_0" value="http://link.bannerA/" /></TD>
					<TD><input type="text" name="b_img_0" value="img/banners/1.jpg" />
<a href="javascript:tinyBrowserPopUp('image','b_img_0');">[выбрать]</a></TD>
					<TD><input type="checkbox" name="b_visible_0" value="0" /></TD>
					
					</TR></table>
		<input type="hidden" name="banner_edit" value="1" />

		<input type="submit" value="Внести изменения" style="width:100%" />
		</form>
</body>
</html>


Путь на файл tb_standalone.js.php - корректен,
ссылка на вызов TinyBrowser'a выглядит так:
<a href="javascript:tinyBrowserPopUp('image','b_img_0');">[выбрать]</a>

, где b_img_0 это id текстового поля формы, куда ф-ция должна вернуть url.
--
FireBug говорит, что tinyBrowserPopUp is not defined.
Не понимая, как ф-ция может быть не определена при нормально подключенном файле, полез собственно в /tiny_mce/plugins/tinybrowser/tb_standalone.js.php, где обнаружил

<?php
require_once("config_tinybrowser.php");

$tbpath = pathinfo($_SERVER['SCRIPT_NAME']);
$tbmain = $tbpath['dirname'].'/tinybrowser.php';
?>

function tinyBrowserPopUp(type,formelementid,folder) {
   tburl = "<?php echo $tbmain; ?>" + "?type=" + type + "&feid=" + formelementid;
   if (folder !== undefined) tburl += "&folder="+folder+"%2F";
   newwindow=window.open(tburl,'tinybrowser','height=<?php echo $tinybrowser['window']['height']+15; ?>,width=<?php echo $tinybrowser['window']['width']+15; ?>,scrollbars=yes,resizable=yes');
   if (window.focus) {newwindow.focus()}
   return false;
}

Функция в файле описана. В чем может быть проблема?
--
Простите за невнимательность, путь к файлу должен был быть от корня сайта. Все заработало.

Последний раз редактировалось Vo.One, 03.06.2009 в 11:49. Причина: Моя невнимательность. Удалите тему :)
 


Опции темы Искать в теме
Искать в теме:

Расширенный поиск