Пример #1
0
function form_fckeditor($data = '', $value = '', $extra = '')
{
    $CI =& get_instance();
    $fckeditor_basepath = $CI->config->item('fckeditor_basepath');
    require_once $_SERVER["DOCUMENT_ROOT"] . '/' . $fckeditor_basepath . 'fckeditor.php';
    $instanceName = is_array($data) && isset($data['name']) ? $data['name'] : $data;
    $fckeditor = new FCKeditor($instanceName);
    if ($fckeditor->IsCompatible()) {
        $fckeditor->Value = html_entity_decode($value);
        $fckeditor->BasePath = $fckeditor_basepath;
        if ($fckeditor_toolbarset = $CI->config->item('fckeditor_toolbarset_default')) {
            $fckeditor->ToolbarSet = $fckeditor_toolbarset;
        }
        if (is_array($data)) {
            if (isset($data['value'])) {
                $fckeditor->Value = html_entity_decode($data['value']);
            }
            if (isset($data['basepath'])) {
                $fckeditor->BasePath = $data['basepath'];
            }
            if (isset($data['toolbarset'])) {
                $fckeditor->ToolbarSet = $data['toolbarset'];
            }
            if (isset($data['width'])) {
                $fckeditor->Width = $data['width'];
            }
            if (isset($data['height'])) {
                $fckeditor->Height = $data['height'];
            }
        }
        return $fckeditor->CreateHtml();
    } else {
        return form_textarea($data, $value, $extra);
    }
}
Пример #2
0
<?php

// 2004-1-7  This function really isn't quite ready for register globals.
require_once dirname(__FILE__) . '/accesscheck.php';
#initialisation###############
// Verify that FCKeditor is available
if (USEFCK && file_exists("./FCKeditor/fckeditor.php")) {
    include "./FCKeditor/fckeditor.php";
    // Create the editor object here so we can check to see if *it* wants us to use it (this
    // does a browser check, etc.
    $oFCKeditor = new FCKeditor('message');
    $usefck = $oFCKeditor->IsCompatible();
    unset($oFCKeditor);
    // This object is *very* short-lived.  Thankfully, it's also light-weight
} else {
    $usefck = 0;
}
// Verify that TinyMCE is available
$useTinyMCE = 0;
if (USETINYMCEMESG && file_exists(TINYMCEPATH)) {
    $useTinyMCE = 1;
}
include $GLOBALS["coderoot"] . "date.php";
$errormsg = '';
$rss_content = '';
$done = 0;
$messageid = 0;
$duplicate_atribute = 0;
# not actually used it seems @@@ check
$embargo = new date("embargo");
$embargo->useTime = true;
Пример #3
0
$wgAutoloadClasses['FCKeditorParserWrapper'] = $dir . 'FCKeditorParserWrapper.body.php';
$wgAutoloadClasses['FCKeditorSkin'] = $dir . 'FCKeditorSkin.body.php';
$wgAutoloadClasses['FCKeditorEditPage'] = $dir . 'FCKeditorEditPage.body.php';
$wgAutoloadClasses['FCKeditor_MediaWiki'] = $dir . 'FCKeditor.body.php';
// Path to internationalization file
$wgExtensionMessagesFiles['FCKeditor'] = $dir . 'FCKeditor.i18n.php';
$wgExtensionMessagesFiles['FCKeditorMagic'] = $dir . 'FCKeditor.i18n.magic.php';
// Initialize FCKeditor and the MediaWiki extension
// @fixme something like this should be delayed until it's actually time
// to work with the editor or something.
if (php_sapi_name() == 'cli') {
    // Command line
    $wgFCKEditorIsCompatible = false;
} else {
    $fckeditor = new FCKeditor('fake');
    $wgFCKEditorIsCompatible = $fckeditor->IsCompatible();
}
$oFCKeditorExtension = new FCKeditor_MediaWiki();
// Hooked functions
$wgHooks['ParserAfterTidy'][] = array($oFCKeditorExtension, 'onParserAfterTidy');
$wgHooks['EditPage::showEditForm:initial'][] = array($oFCKeditorExtension, 'onEditPageShowEditFormInitial');
$wgHooks['EditPage::showEditForm:fields'][] = array($oFCKeditorExtension, 'onEditPageShowEditFormFields');
$wgHooks['EditPageBeforePreviewText'][] = array($oFCKeditorExtension, 'onEditPageBeforePreviewText');
$wgHooks['EditPagePreviewTextEnd'][] = array($oFCKeditorExtension, 'onEditPagePreviewTextEnd');
$wgHooks['CustomEditor'][] = array($oFCKeditorExtension, 'onCustomEditor');
$wgHooks['ParserBeforeStrip'][] = 'FCKeditor_MediaWiki::onParserBeforeStrip';
$wgHooks['ParserBeforeInternalParse'][] = 'FCKeditor_MediaWiki::onParserBeforeInternalParse';
$wgHooks['EditPageBeforeConflictDiff'][] = 'FCKeditor_MediaWiki::onEditPageBeforeConflictDiff';
$wgHooks['SanitizerAfterFixTagAttributes'][] = 'FCKeditor_MediaWiki::onSanitizerAfterFixTagAttributes';
$wgHooks['MakeGlobalVariablesScript'][] = 'FCKeditor_MediaWiki::onMakeGlobalVariablesScript';
$wgHooks['GetPreferences'][] = 'FCKeditor_MediaWiki::onGetPreferences';
Пример #4
0
 /**
  * Build this element using FCKeditor
  */
 function build_FCKeditor()
 {
     if (!FCKeditor::IsCompatible()) {
         return parent::toHTML();
     }
     $this->fck_editor->Value = $this->getValue();
     $result = $this->fck_editor->CreateHtml();
     if (isset($this->fck_editor->Config['LoadAsciiMath'])) {
         if (isset($_SESSION['ascii_math_loaded']) && $_SESSION['ascii_math_loaded'] == false) {
             $result .= $this->fck_editor->Config['LoadAsciiMath'];
             $_SESSION['ascii_math_loaded'] = true;
         }
     }
     //Add a link to open the allowed html tags window
     //$result .= '<small><a href="#" onclick="MyWindow=window.open('."'".api_get_path(WEB_CODE_PATH)."help/allowed_html_tags.php?fullpage=". ($this->fullPage ? '1' : '0')."','MyWindow','toolbar=no,location=no,directories=no,status=yes,menubar=no,scrollbars=yes,resizable=yes,width=500,height=600,left=200,top=20'".'); return false;">'.get_lang('AllowedHTMLTags').'</a></small>';
     return $result;
 }
/** construct an input field using the user's preferred editor
 *
 * this constructs an input for rich text like a page with HTML-code.
 * Most users will probably have selected the FCKeditor. However,
 * there is also the option to use the so-called 'plain' editor, which
 * is nothing more than a textarea in disguise.
 *
 * The properties recognised translate to the following HTML-code/attributes
 * <pre>
 * name      : name
 * value     : value
 * accesskey : accesskey
 * rows      : rows
 * columns   : cols
 * maxlength : maxlength
 * alt       : alt
 * class     : class (also depends on viewonly and errors)
 * tabindex  : tabindex
 * id        : id
 * title     : title
 * viewonly  : disabled AND addition of ATTR_CLASS_ERROR to class list (if viewonly == TRUE)
 * errors    : addition of ATTR_CLASS_ERROR to class list (if errors > 0)
 * </pre>
 *
 * @param array &$item the parameters that describe the dialog input element
 * @param string $name the name of the input element ('fieldname')
 * @param mixed $value the (current) value of the input element to show ('field value')
 * @return array|string 1 or more lines of ready-to-use HTML
 * @todo if we let the hotkey from the label prevail and add it to the input tag, why add a hotkey to the label too?
 */
function dialog_get_widget_richtextinput(&$item, $name, $value, $f_type)
{
    global $CFG, $USER, $LANGUAGE;
    $rows = max(isset($item['rows']) ? intval($item['rows']) : 4, 4);
    // at least 4 rows, always
    $preferred_editor = !empty($USER->editor) ? $USER->editor : $CFG->editor;
    if ($preferred_editor == 'ckeditor') {
        require_once $CFG->progdir . '/lib/ckeditor/ckeditor.php';
        $editor = new CKEditor();
        $editor->basePath = $CFG->progwww_short . '/lib/ckeditor/';
        $editor->returnOutput = TRUE;
        $editor->config['defaultLanguage'] = $LANGUAGE->get_current_language();
        $editor->config['height'] = sprintf("%dem", $rows);
        // assume 1em per line
        $editor->config['width'] = isset($item['columns']) ? 10 * intval($item['columns']) : '100%';
        $editor->config['filebrowserLinkBrowseUrl'] = sprintf('%s/admin.php?job=%s', $CFG->www_short, JOB_FILEBROWSER);
        $editor->config['filebrowserImageBrowseUrl'] = sprintf('%s/admin.php?job=%s', $CFG->www_short, JOB_IMAGEBROWSER);
        $editor->config['filebrowserFlashBrowseUrl'] = sprintf('%s/admin.php?job=%s', $CFG->www_short, JOB_FLASHBROWSER);
        $editor->config['skin'] = 'kama';
        /* Try to set sensible dimensions in case JavaScript is disabled and CKEditor
         * falls back on a plain textarea. We attempt to use the full available width
         * of the element containting this textarea/editor via a style attribute.
         * Note: the default dimensions in CKEditor are: rows=8, cols=60
         * (see /program/lib/ckeditor/ckeditor_phpX.php).
         */
        $editor->textareaAttributes['rows'] = $rows;
        if (isset($item['columns'])) {
            $editor->textareaAttributes['cols'] = $item['columns'];
        }
        $editor->textareaAttributes['style'] = 'width: 100%;';
        return $editor->editor($name, $value);
    } elseif ($preferred_editor == 'fckeditor' && !isset($_GET['fcksource'])) {
        require_once $CFG->progdir . '/lib/fckeditor/fckeditor.php';
        $editor = new FCKeditor($name);
        if ($editor->IsCompatible()) {
            $editor->Value = $value;
            $editor->BasePath = $CFG->progwww_short . '/lib/fckeditor/';
            $editor->Config['AutoDetectLanguage'] = FALSE;
            $editor->Config['DefaultLanguage'] = $LANGUAGE->get_current_language();
            $editor->Height = 20 * $rows;
            // heuristic: assume 20px per row
            $editor->Width = isset($item['columns']) ? 10 * intval($item['columns']) : '100%';
            $editor->Config['LinkBrowserURL'] = sprintf('%s/admin.php?job=%s', $CFG->www_short, JOB_FILEBROWSER);
            $editor->Config['LinkUpload'] = 'false';
            $editor->Config['ImageBrowserURL'] = sprintf('%s/admin.php?job=%s', $CFG->www_short, JOB_IMAGEBROWSER);
            $editor->Config['ImageUpload'] = 'false';
            $editor->Config['FlashBrowserURL'] = sprintf('%s/admin.php?job=%s', $CFG->www_short, JOB_FLASHBROWSER);
            $editor->Config['FlashUpload'] = 'false';
            $editor->Config['SkinPath'] = $editor->BasePath . 'editor/skins/silver/';
            return $editor->CreateHtml();
        }
        // else
        // fall through to plain text editor (the only other option re: preferred editor)
    }
    // Still here? You want the plain editor then (ie. a textarea)
    $attributes = array('name' => $name);
    $widget = 'textarea';
    $attributes['rows'] = $rows;
    if (isset($item['columns'])) {
        $attributes['cols'] = $item['columns'];
    }
    $hotkey = isset($item['label']) ? accesskey_from_string($item['label']) : '';
    if (!empty($hotkey)) {
        $attributes['accesskey'] = $hotkey;
    } elseif (isset($item['accesskey'])) {
        $attributes['accesskey'] = $item['accesskey'];
    }
    $class = dialog_get_class($item);
    if (!empty($class)) {
        $attributes['class'] = $class;
    }
    if (isset($item['tabindex'])) {
        $attributes['tabindex'] = $item['tabindex'];
    }
    if (isset($item['id'])) {
        $attributes['id'] = $item['id'];
    }
    if (isset($item['title'])) {
        // see todo #1 above
        $attributes['title'] = $item['title'];
    }
    if (isset($item['viewonly']) && $item['viewonly']) {
        $attributes['disabled'] = NULL;
    }
    $attributes['style'] = 'width: 100%;';
    return html_tag($widget, $attributes, htmlspecialchars($value));
}
Пример #6
0
    /**
     * Function fnGetWYSIWYGeditor gets the editor.We can toggle the editor type by changing $strType value.
     * @param string $strElementName
     * @param string $strElementValue
     * @param int $intHeight
     * @param int $intWidth
     * @param string $strType
     * @return string
     */
    function fnGetWYSIWYGeditor($strElementName, $strElementValue = "", $intHeight = '400', $intWidth = '300', $strType = 'tinymce', $strParentIFrameName = "")
    {
        $arrElements = explode(",", $strElementName);
        //$strEditor = "<h4><img src='images/word.jpg' align='absmiddle'> Please use the <img src='".SITE_NAME."/lib/pear/tinymce/remove_formatting.jpg' align='absmiddle' /> icon when posting from Microsoft Word.</h4>";
        if ($strType == "fckeditor") {
            $strElementName = $arrElements[0];
            include DOCUMENT_ROOT . "/lib/pear/fckeditor/fckeditor.php";
            $oFCKeditor = new FCKeditor($strElementName);
            $oFCKeditor->BasePath = "lib/pear/fckeditor/";
            $oFCKeditor->Value = stripslashes($strElementValue);
            $oFCKeditor->Width = $intHeight;
            $oFCKeditor->Height = $intWidth;
            if ($oFCKeditor->IsCompatible()) {
                $strEditor .= "<div id='showloadingfckeditor' name='showloadingfckeditor'><img src='images/loading.gif' /> Loading Editor...</div>";
            }
            $strEditor .= $oFCKeditor->Create();
        } else {
            //$arrElements = explode(",",$strElementName);
            $strCount = count($arrElements);
            if ($strCount > 1) {
                // IF SESSION IS NOT SET
                if (!isset($_SESSION['ELECNT'])) {
                    $_SESSION['ELECNT'] = $strCount;
                }
                if (isset($_SESSION['ELECNT'])) {
                    if ((int) $_SESSION['ELECNT'] < $strCount) {
                        $strElementName = $arrElements[0];
                        $strEditor .= '<textarea id="' . $strElementName . '" name="' . $strElementName . '">' . $strElementValue . '</textarea>';
                        //$_SESSION['ELECNT'] = $_SESSION['ELECNT'] - 1;
                        if ((int) $_SESSION['ELECNT'] <= 1) {
                            unset($_SESSION['ELECNT']);
                        } else {
                            $_SESSION['ELECNT'] = $_SESSION['ELECNT'] - 1;
                        }
                        return $strEditor;
                    }
                    $_SESSION['ELECNT'] = $_SESSION['ELECNT'] - 1;
                }
            } else {
                unset($_SESSION['ELECNT']);
            }
            $strEditor .= '<script type="text/javascript" src="' . SITE_NAME . '/lib/pear/tinymce/jscripts/tiny_mce/tiny_mce.js"></script>
						<script type="text/javascript">
					 
							function myCustomOnInit() {
					 			try 
					 			{	
					 				fnTinyMCECallBack();
					 			}
					 			catch(e)
					 			{
					 
					 			}
							}
					 
							tinyMCE.init({
								// General options
								mode : "exact",
								elements : "' . $strElementName . '",
								theme : "advanced",
								height : "' . $intHeight . '",
								width : "' . $intWidth . '",
								plugins : "safari,pagebreak,style,layer,table,save,advhr,advimage,advlink,iespell,inlinepopups,media,print,contextmenu,paste,directionality,noneditable,visualchars,nonbreaking,xhtmlxtras,template",

								theme_advanced_buttons1 : "bold,italic,underline,|,justifyleft,justifycenter,justifyright,|,fontsizeselect,forecolor,backcolor,|,bullist,numlist,|,pasteword",
								theme_advanced_buttons2 : "link,unlink,|,code,image,|,hr,charmap,iespell|,table,media",
								theme_advanced_buttons3 :"",

								theme_advanced_toolbar_location : "top",
								theme_advanced_toolbar_align : "left",

								// Replace values for the template plugin
								template_replace_values : {
									username : "******",
									staffid : "991234"
								},
					 			oninit : "myCustomOnInit"

							});
					 
					 
						</script>';
            $strElementName = $arrElements[0];
            $strEditor .= '<textarea id="' . $strElementName . '" name="' . $strElementName . '">' . $strElementValue . '</textarea>';
        }
        return $strEditor;
    }
Пример #7
0
 /**
  * Check if compatible
  *
  * @return
  */
 function isCompatible()
 {
     if (!is_readable(ICMS_ROOT_PATH . $this->rootpath . "/fckeditor.php")) {
         return false;
     }
     include_once ICMS_ROOT_PATH . $this->rootpath . "/fckeditor.php";
     return FCKeditor::IsCompatible();
 }
Пример #8
0
 /**
  * Check if compatible
  *
  * @return
  */
 function isActive()
 {
     if (!@(include_once XOOPS_ROOT_PATH . $this->rootPath . "/fckeditor/fckeditor.php")) {
         $this->isEnabled = false;
     } else {
         $this->isEnabled = FCKeditor::IsCompatible();
     }
     return $this->isEnabled;
 }
Пример #9
0
 /**
  * Return the HTML code required to run FCKeditor.
  *
  * @return string
  */
 public function CreateHtml()
 {
     // Adaptation for the Chamilo LMS
     //@todo why the BasePath is relative ? we should use this constant WEB_PATH
     $this->BasePath = api_get_path(REL_PATH) . 'main/inc/lib/fckeditor/';
     $config = $this->get_custom_configuration();
     $this->read_configuration($config);
     $config = $this->get_default_configuration();
     $this->read_configuration($config);
     if ((api_is_allowed_to_edit() || api_is_platform_admin()) && isset($this->Config['BlockCopyPaste'])) {
         $this->Config['BlockCopyPaste'] = false;
     }
     $HtmlValue = htmlspecialchars($this->Value);
     $Html = '';
     if (FCKeditor::IsCompatible()) {
         if (api_get_setting('server_type') == 'test') {
             $File = 'fckeditor.original.html';
         } else {
             $File = 'fckeditor.html';
         }
         $Link = "{$this->BasePath}editor/{$File}?InstanceName={$this->InstanceName}";
         if ($this->ToolbarSet != '') {
             $Link .= "&amp;Toolbar={$this->ToolbarSet}";
         }
         // Render the linked hidden field.
         $Html .= "<input type=\"hidden\" id=\"{$this->InstanceName}\" name=\"{$this->InstanceName}\" value=\"{$HtmlValue}\" style=\"display:none\" />";
         // Render the configurations hidden field.
         $Html .= "<input type=\"hidden\" id=\"{$this->InstanceName}___Config\" value=\"" . $this->GetConfigFieldString() . "\" style=\"display:none\" />";
         // Render the editor IFRAME.
         $Html .= "<iframe id=\"{$this->InstanceName}___Frame\" src=\"{$Link}\" width=\"{$this->Width}\" height=\"{$this->Height}\" frameborder=\"0\" scrolling=\"no\"></iframe>";
     } else {
         if (strpos($this->Width, '%') === false) {
             $WidthCSS = $this->Width . 'px';
         } else {
             $WidthCSS = $this->Width;
         }
         if (strpos($this->Height, '%') === false) {
             $HeightCSS = $this->Height . 'px';
         } else {
             $HeightCSS = $this->Height;
         }
         $Html .= "<textarea name=\"{$this->InstanceName}\" rows=\"4\" cols=\"40\" style=\"width: {$WidthCSS}; height: {$HeightCSS}\">{$HtmlValue}</textarea>";
     }
     return $Html;
 }