"get image upload in fck working again"

This commit is contained in:
Ralf Becker 2007-04-14 16:57:57 +00:00
parent 5aad1fc35a
commit c5c317d9df

View File

@ -577,7 +577,7 @@ class html
* this function is a wrapper for fckEditor to create some reuseable layouts * this function is a wrapper for fckEditor to create some reuseable layouts
* *
* @param string $_name name and id of the input-field * @param string $_name name and id of the input-field
* @param string $_content='' of the tinymce (will be run through htmlspecialchars !!!), default '' * @param string $_content of the tinymce (will be run through htmlspecialchars !!!), default ''
* @param string $_mode display mode of the tinymce editor can be: simple, extended or advanced * @param string $_mode display mode of the tinymce editor can be: simple, extended or advanced
* @param array $_options (toolbar_expanded true/false) * @param array $_options (toolbar_expanded true/false)
* @param string $_height='400px' * @param string $_height='400px'
@ -585,8 +585,9 @@ class html
* @param string $base_href='' if passed activates the browser for image at absolute path passed * @param string $base_href='' if passed activates the browser for image at absolute path passed
* @return string the necessary html for the textarea * @return string the necessary html for the textarea
*/ */
function fckEditor($_name, $_content='', $_mode, $_options=array('toolbar_expanded' =>'true'), $_height='400px', $_width='100%',$_base_href) { function fckEditor($_name, $_content, $_mode, $_options=array('toolbar_expanded' =>'true'), $_height='400px', $_width='100%',$_base_href)
if (!$this->htmlarea_availible()) {
if (!$this->htmlarea_availible() || $_mode == 'ascii')
{ {
return $this->textarea($_name,$_content,'style="width: '.$_width.'; height: '.$_height.';"'); return $this->textarea($_name,$_content,'style="width: '.$_width.'; height: '.$_height.';"');
} }
@ -597,19 +598,19 @@ class html
$oFCKeditor->Value = $_content; $oFCKeditor->Value = $_content;
$oFCKeditor->Width = $_width ; $oFCKeditor->Width = $_width ;
$oFCKeditor->Height = $_height ; $oFCKeditor->Height = $_height ;
$oFCKeditor->Config['LinkBrowser'] = 'false';
$oFCKeditor->Config['FlashBrowser'] = 'false';
$oFCKeditor->Config['LinkUpload'] = 'false';
// Activate the browser and config upload pathimage dir ($_base_href/images) if passed (absolute path) // by default switch all browsers and uploads off
if ($_base_href) $oFCKeditor->Config['LinkBrowser'] = $oFCKeditor->Config['LinkUpload'] = false;
$oFCKeditor->Config['FlashBrowser'] = $oFCKeditor->Config['FlashUpload'] = false;
$oFCKeditor->Config['ImageBrowser'] = $oFCKeditor->Config['ImageUpload'] = false;
// Activate the image browser+upload, if $_base_href exists and is browsable by the webserver
if ($_base_href && is_dir($_SERVER['DOCUMENT_ROOT'].$_base_href) && file_exists($_SERVER['DOCUMENT_ROOT'].$_base_href.'/.'))
{ {
// Only images for now // Only images for now
$oFCKeditor->Config['ImageBrowserURL'] = $oFCKeditor->BasePath.'editor/filemanager/browser/default/browser.html?ServerPath='.$_base_href.'&Type=images&Connector=connectors/php/connector.php'; $oFCKeditor->Config['ImageBrowserURL'] = $oFCKeditor->BasePath.'editor/filemanager/browser/default/browser.html?ServerPath='.$_base_href.'&Type=images&Connector=connectors/php/connector.php';
} $oFCKeditor->Config['ImageBrowser'] = true;
else $oFCKeditor->Config['ImageUpload'] = is_writable($_SERVER['DOCUMENT_ROOT'].$_base_href);
{
$oFCKeditor->Config['ImageBrowser'] = 'false';
} }
// By default the editor start expanded // By default the editor start expanded
if ($_options['toolbar_expanded'] == 'false') if ($_options['toolbar_expanded'] == 'false')
@ -618,23 +619,20 @@ class html
} }
switch($_mode) { switch($_mode) {
case 'ascii':
return "<textarea name=\"$_name\" style=\"width:".$_width."; height:".$_height."; border:0px;\">$_content</textarea>";
break;
case 'simple': case 'simple':
$oFCKeditor->ToolbarSet = 'egw_simple'; $oFCKeditor->ToolbarSet = 'egw_simple';
return $oFCKeditor->CreateHTML() ;
break; break;
default:
case 'extended': case 'extended':
$oFCKeditor->ToolbarSet = 'egw_extended'; $oFCKeditor->ToolbarSet = 'egw_extended';
return $oFCKeditor->CreateHTML() ;
break; break;
case 'advanced': case 'advanced':
$oFCKeditor->ToolbarSet = 'egw_advanced'; $oFCKeditor->ToolbarSet = 'egw_advanced';
return $oFCKeditor->CreateHTML() ;
break; break;
} }
return /*"toolbarset='$oFCKeditor->ToolbarSet'<pre>".print_r($oFCKeditor->Config,true)."</pre>\n".*/ $oFCKeditor->CreateHTML();
} }
/** /**
@ -649,7 +647,8 @@ class html
* @param string $base_href='' * @param string $base_href=''
* @return string the necessary html for the textarea * @return string the necessary html for the textarea
*/ */
function fckEditorQuick($_name, $_mode, $_content='', $_height='400px', $_width='100%') { function fckEditorQuick($_name, $_mode, $_content='', $_height='400px', $_width='100%')
{
include_once(EGW_INCLUDE_ROOT."/phpgwapi/js/fckeditor/fckeditor.php"); include_once(EGW_INCLUDE_ROOT."/phpgwapi/js/fckeditor/fckeditor.php");
$oFCKeditor = new FCKeditor($_name) ; $oFCKeditor = new FCKeditor($_name) ;
@ -1356,4 +1355,22 @@ class html
return $html; return $html;
} }
/**
* html-class singleton, return a referenze to the global instanciated html object in $GLOBALS['egw']->html
*
* Please use that static method in all new code, instead of instanciating an own html object:
* $my_html =& html::singleton();
*
* @static
* @return html
*/
function &singleton()
{
if (!is_object($GLOBALS['egw']->html))
{
$GLOBALS['egw']->html = new html;
}
return $GLOBALS['egw']->html;
}
} }