"update to fck 2.6"

This commit is contained in:
Ralf Becker 2008-04-15 12:23:32 +00:00
parent e4401d7f41
commit be2fa1c923

View File

@ -431,19 +431,10 @@ class html
*/ */
static function htmlarea_availible() static function htmlarea_availible()
{ {
switch(self::$user_agent) require_once(EGW_INCLUDE_ROOT.'/phpgwapi/js/fckeditor/fckeditor.php');
{
case 'msie': // use FCKeditor's own check
return self::$ua_version >= 5.5; return FCKeditor_IsCompatibleBrowser();
case 'mozilla':
return self::$ua_version >= 1.3;
case 'safari':
return self::$ua_version >= 523.12;
case 'opera':
return self::$ua_version >= 9.5;
default:
return False;
}
} }
/** /**
@ -464,7 +455,7 @@ class html
* this static function is a wrapper for fckEditor to create some reuseable layouts * this static 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'
@ -472,7 +463,7 @@ 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
*/ */
static function fckEditor($_name, $_content, $_mode, $_options=array('toolbar_expanded' =>'true'), $_height='400px', $_width='100%',$_base_href='') static function fckEditor($_name, $_content, $_mode, $_options=array('toolbar_expanded' =>'true'), $_height='400px', $_width='100%',$_base_href='')
{ {
if (!self::htmlarea_availible() || $_mode == 'ascii') if (!self::htmlarea_availible() || $_mode == 'ascii')
{ {
@ -486,16 +477,20 @@ class html
$oFCKeditor->Value = $_content; $oFCKeditor->Value = $_content;
$oFCKeditor->Width = str_replace('px','',$_width); // FCK adds px if width contains no % $oFCKeditor->Width = str_replace('px','',$_width); // FCK adds px if width contains no %
$oFCKeditor->Height = str_replace('px','',$_height); $oFCKeditor->Height = str_replace('px','',$_height);
// by default switch all browsers and uploads off // by default switch all browsers and uploads off
$oFCKeditor->Config['LinkBrowser'] = $oFCKeditor->Config['LinkUpload'] = false; $oFCKeditor->Config['LinkBrowser'] = $oFCKeditor->Config['LinkUpload'] = false;
$oFCKeditor->Config['FlashBrowser'] = $oFCKeditor->Config['FlashUpload'] = false; $oFCKeditor->Config['FlashBrowser'] = $oFCKeditor->Config['FlashUpload'] = false;
$oFCKeditor->Config['ImageBrowser'] = $oFCKeditor->Config['ImageUpload'] = false; $oFCKeditor->Config['ImageBrowser'] = $oFCKeditor->Config['ImageUpload'] = false;
// Activate the image browser+upload, if $_base_href exists and is browsable by the webserver // 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.'/.')) 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
if (substr($_base_href,-1) != '/') $_base_href .= '/' ;
// store the path and application in the session, to make sure it can't be called with arbitrary pathes
$GLOBALS['egw']->session->appsession($_base_href,'FCKeditor',$GLOBALS['egw_info']['flags']['currentapp']);
$oFCKeditor->Config['ImageBrowserURL'] = $oFCKeditor->BasePath.'editor/filemanager/browser/default/browser.html?ServerPath='.$_base_href.'&Type=Image&Connector='.$oFCKeditor->BasePath.'editor/filemanager/connectors/php/connector.php'; $oFCKeditor->Config['ImageBrowserURL'] = $oFCKeditor->BasePath.'editor/filemanager/browser/default/browser.html?ServerPath='.$_base_href.'&Type=Image&Connector='.$oFCKeditor->BasePath.'editor/filemanager/connectors/php/connector.php';
$oFCKeditor->Config['ImageBrowser'] = true; $oFCKeditor->Config['ImageBrowser'] = true;
$oFCKeditor->Config['ImageUpload'] = is_writable($_SERVER['DOCUMENT_ROOT'].$_base_href); $oFCKeditor->Config['ImageUpload'] = is_writable($_SERVER['DOCUMENT_ROOT'].$_base_href);
@ -525,9 +520,9 @@ class html
else else
{ {
$oFCKeditor->Config['SpellerPagesServerScript'] .= '&spellchecker_lang='.$GLOBALS['egw_info']['user']['preferences']['common']['lang']; $oFCKeditor->Config['SpellerPagesServerScript'] .= '&spellchecker_lang='.$GLOBALS['egw_info']['user']['preferences']['common']['lang'];
} }
$oFCKeditor->Config['FirefoxSpellChecker'] = false; $oFCKeditor->Config['FirefoxSpellChecker'] = false;
} }
// Now setting the user preferences // Now setting the user preferences
if (isset($GLOBALS['egw_info']['user']['preferences']['common']['rte_enter_mode'])) if (isset($GLOBALS['egw_info']['user']['preferences']['common']['rte_enter_mode']))
{ {
@ -536,7 +531,7 @@ class html
if (isset($GLOBALS['egw_info']['user']['preferences']['common']['rte_skin'])) if (isset($GLOBALS['egw_info']['user']['preferences']['common']['rte_skin']))
{ {
$oFCKeditor->Config['SkinPath'] = $oFCKeditor->BasePath.'editor/skins/'.$GLOBALS['egw_info']['user']['preferences']['common']['rte_skin'].'/'; $oFCKeditor->Config['SkinPath'] = $oFCKeditor->BasePath.'editor/skins/'.$GLOBALS['egw_info']['user']['preferences']['common']['rte_skin'].'/';
} }
switch($_mode) { switch($_mode) {
case 'simple': case 'simple':
@ -551,7 +546,7 @@ class html
case 'advanced': case 'advanced':
$oFCKeditor->ToolbarSet = 'egw_advanced'.$spell; $oFCKeditor->ToolbarSet = 'egw_advanced'.$spell;
break; break;
} }
return $oFCKeditor->CreateHTML(); return $oFCKeditor->CreateHTML();
} }
@ -568,18 +563,18 @@ 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
*/ */
static function fckEditorQuick($_name, $_mode, $_content='', $_height='400px', $_width='100%') static function fckEditorQuick($_name, $_mode, $_content='', $_height='400px', $_width='100%')
{ {
if (!self::htmlarea_availible() || $_mode == 'ascii') if (!self::htmlarea_availible() || $_mode == 'ascii')
{ {
return "<textarea name=\"$_name\" style=\"width:100%; height:400px; border:0px;\">$_content</textarea>"; return "<textarea name=\"$_name\" style=\"width:100%; height:400px; border:0px;\">$_content</textarea>";
} }
else else
{ {
return self::fckEditor($_name, $_content, $_mode, array(), $_height, $_width); return self::fckEditor($_name, $_content, $_mode, array(), $_height, $_width);
} }
} }
/** /**
* represents html's input tag * represents html's input tag
* *
@ -891,7 +886,7 @@ class html
{ {
$path = EGW_SERVER_ROOT.$url; $path = EGW_SERVER_ROOT.$url;
} }
if (is_null($path) || !@is_readable($path)) if (is_null($path) || !@is_readable($path))
{ {
// if the image-name is a percentage, use a progressbar // if the image-name is a percentage, use a progressbar
@ -940,10 +935,10 @@ class html
$vars = $url; $vars = $url;
$url = '/index.php'; $url = '/index.php';
} }
elseif (strpos($url,'/')===false && elseif (strpos($url,'/')===false &&
count(explode('.',$url)) >= 3 && count(explode('.',$url)) >= 3 &&
!(strpos($url,'mailto:')!==false || !(strpos($url,'mailto:')!==false ||
strpos($url,'://')!==false || strpos($url,'://')!==false ||
strpos($url,'javascript:')!==false)) strpos($url,'javascript:')!==false))
{ {
$url = "/index.php?menuaction=$url"; $url = "/index.php?menuaction=$url";
@ -1092,7 +1087,7 @@ class html
} }
return $html; return $html;
} }
/** /**
* tree widget using dhtmlXtree * tree widget using dhtmlXtree
* *
@ -1138,7 +1133,7 @@ class html
$html .= "$tree.enableCheckBoxes(1);\n"; $html .= "$tree.enableCheckBoxes(1);\n";
$html .= "$tree.setOnCheckHandler('$_onCheckHandler');\n"; $html .= "$tree.setOnCheckHandler('$_onCheckHandler');\n";
} }
$top = 0; $top = 0;
if ($_topFolder) if ($_topFolder)
{ {
@ -1155,7 +1150,7 @@ class html
else else
{ {
$label = $_topFolder; $label = $_topFolder;
} }
$html .= "\n$tree.insertNewItem(0,'$top','".addslashes($label)."',$_onNodeSelect,'$topImage','$topImage','$topImage','CHILD,TOP');\n"; $html .= "\n$tree.insertNewItem(0,'$top','".addslashes($label)."',$_onNodeSelect,'$topImage','$topImage','$topImage','CHILD,TOP');\n";
if (is_array($_topFolder) && isset($_topFolder['title'])) if (is_array($_topFolder) && isset($_topFolder['title']))
@ -1179,15 +1174,15 @@ class html
// evtl. remove leading delimiter // evtl. remove leading delimiter
if ($path{0} == $delimiter) $path = substr($path,1); if ($path{0} == $delimiter) $path = substr($path,1);
$folderParts = explode($delimiter,$path); $folderParts = explode($delimiter,$path);
//get rightmost folderpart //get rightmost folderpart
$label = array_pop($folderParts); $label = array_pop($folderParts);
if (isset($data['label'])) $label = $data['label']; if (isset($data['label'])) $label = $data['label'];
// the rest of the array is the name of the parent // the rest of the array is the name of the parent
$parentName = implode((array)$folderParts,$delimiter); $parentName = implode((array)$folderParts,$delimiter);
if(empty($parentName)) $parentName = $top; if(empty($parentName)) $parentName = $top;
$entryOptions = 'CHILD'; $entryOptions = 'CHILD';
if ($_onCheckHandler && $_selected) // check selected items on multi selection if ($_onCheckHandler && $_selected) // check selected items on multi selection
{ {
@ -1220,7 +1215,7 @@ class html
$html .= "$tree.openItem('$top');\n"; $html .= "$tree.openItem('$top');\n";
} }
$html .= "</script>\n"; $html .= "</script>\n";
return $html; return $html;
} }
} }