Beispiel #1
0
 private function _getStylesPath($params, $path_root)
 {
     //Get parameter options for template CSS
     $content_css = $params->get('styles_css', 1);
     $content_css_custom = $params->get('styles_css_custom', '');
     $db = JFactory::getDBO();
     $query = $db->getQuery(true);
     $query->select('template')->from('#__template_styles')->where('client_id=0 AND home=1');
     $db->setQuery($query);
     $template = $db->loadResult();
     //For some reason the Beez template are using General.css instead
     //of template.css, and the template.css file is setup to fail?!
     //This code checks to see what template we are using and switch
     //to General.css to solve the issue.
     //
     //By Mark Smeed - For 1.6 ONLY
     if (in_array($template, array('beez_20', 'beez5', 'beez3')) && $content_css == 1) {
         $content_css = 0;
         $content_css_custom = 'templates/' . $template . '/css/general.css';
     }
     //end if
     if ($content_css) {
         if (is_file(JPATH_SITE . '/templates/' . $template . '/css/template.css')) {
             $content_css = 'templates/' . $template . '/css/template.css';
         } else {
             if (is_file(JPATH_SITE . '/templates/' . $template . '/css/template.css.php')) {
                 $content_css = 'templates/' . $template . '/css/JFCKeditor.css.php';
                 if (!is_file(JPATH_SITE . '/templates/' . $template . '/css/JFCKeditor.css.php') || filemtime(JPATH_SITE . '/templates/' . $template . '/css/template.css.php') > filemtime(JPATH_SITE . '/templates/' . $template . '/css/JFCKeditor.css.php')) {
                     $file_content = file_get_contents('../templates/' . $template . '/css/template.css.php');
                     $file_content = preg_replace_callback("/(.*?)(@?ob_start\\('?\"?ob_gzhandler\"?'?\\))(.*)/", create_function('$matches', 'return ($matches[1]) .\';\';'), $file_content);
                     $file_content = preg_replace("/(.*define\\().*DIRECTORY_SEPARATOR.*(;?)/", '', $file_content);
                     $file_content = '<' . '?' . 'php' . ' function getYooThemeCSS() { ' . '?' . '>' . $file_content . '<' . '?' . 'php' . ' } ' . '?' . '>';
                     $fout = fopen($this->_path_root . $content_css, "w");
                     fwrite($fout, $file_content);
                     fclose($fout);
                 }
                 include $this->_path_root . $content_css;
                 $content_css = 'templates/' . $template . '/css/JFCKeditor.css';
                 ob_start();
                 getYooThemeCSS();
                 $file_content = ob_get_contents();
                 ob_end_clean();
                 $fout = fopen($this->_path_root . $content_css, "w");
                 fwrite($fout, $file_content);
                 fclose($fout);
             } else {
                 $content_css = 'plugins/editors/jckeditor/contents.css';
             }
         }
         //end if
     } else {
         if ($content_css_custom) {
             $hasRoot = strpos(' ' . strtolower($content_css_custom), strtolower(JPATH_SITE));
             $file_path = ($hasRoot ? '' : JPATH_SITE) . ($hasRoot || substr($content_css_custom, 0, 1) == DS ? '' : DS) . $content_css_custom;
             if (is_file($file_path)) {
                 $content_css = $file_path;
                 $content_css = str_replace(strtolower(JPATH_SITE) . DS, '', strtolower($content_css_custom));
             }
         } else {
             $content_css = 'plugins/editors/jckeditor/contents.css';
         }
         //end if $content_css_custom
         /*write to xml file and read from css asnd store this file under editors*/
     }
     //end if $content_css || $editor_css
     $this->_content_css = $path_root . $content_css;
     $content_css = JURI::root() . $content_css;
     $content_css = str_replace(DS, '/', $content_css);
     return $content_css;
 }
Beispiel #2
0
 function getPath(&$errors = '', $type = "content")
 {
     //Get parameter options for template CSS
     $params = $this->_params;
     $content_css = $params->get($type . '_css', 1);
     $content_css_custom = $params->def($type . '_css_custom', '');
     $db = JFactory::getDBO();
     $query = $db->getQuery(true);
     $query->select('template');
     $query->from('#__template_styles');
     $query->where('client_id=0 AND home=1');
     $db->setQuery($query);
     $template = $db->loadResult();
     //For some reason the Beez template are using General.css instead
     //of template.css, and the template.css file is setup to fail?!
     //This code checks to see what template we are using and switch
     //to General.css to solve the issue.
     //
     //By Mark Smeed - For 1.6 ONLY
     if (in_array($template, array('beez_20', 'beez5', 'beez3')) && ($content_css == 1 && $content_css_custom == 0)) {
         $content_css = 0;
         $content_css_custom = 'templates/' . $template . '/css/general.css';
         $this->_default_beez_template = $template;
     }
     //end if
     if ($content_css) {
         if (is_file(JPATH_SITE . '/templates/' . $template . '/css/template.css')) {
             $content_css = 'templates/' . $template . '/css/template.css';
         } else {
             if (is_file(JPATH_SITE . '/templates/' . $template . '/css/template.css.php')) {
                 $content_css = 'templates/' . $template . '/css/JFCKeditor.css.php';
                 if (!is_file(JPATH_SITE . '/templates/' . $template . '/css/JFCKeditor.css.php') || filemtime(JPATH_SITE . '/templates/' . $template . '/css/template.css.php') > filemtime(JPATH_SITE . '/templates/' . $template . '/css/JFCKeditor.css.php')) {
                     $file_content = file_get_contents('../templates/' . $template . '/css/template.css.php');
                     $file_content = preg_replace_callback("/(.*?)(@?ob_start\\('?\"?ob_gzhandler\"?'?\\))(.*)/", create_function('$matches', 'return ($matches[1]) .\';\';'), $file_content);
                     $file_content = preg_replace("/(.*define\\().*DIRECTORY_SEPARATOR.*(;?)/", '', $file_content);
                     $file_content = '<' . '?' . 'php' . ' function getYooThemeCSS() { ' . '?' . '>' . $file_content . '<' . '?' . 'php' . ' } ' . '?' . '>';
                     $fout = fopen($this->_path_root . $content_css, "w");
                     fwrite($fout, $file_content);
                     fclose($fout);
                 }
                 include $this->_path_root . $content_css;
                 $content_css = 'templates/' . $template . '/css/JFCKeditor.css';
                 ob_start();
                 getYooThemeCSS();
                 $file_content = ob_get_contents();
                 ob_end_clean();
                 $fout = fopen($this->_path_root . $content_css, "w");
                 fwrite($fout, $file_content);
                 fclose($fout);
             } else {
                 $errors .= '<span style="color: red;">Warning: the JCK Editor cannot find a default template.css style-sheet to use. Please see: <a  href="http://www.joomlackeditor.com/downloads/jck-editor/installation-guide?start=8">Installation guide</a></span><br/>';
                 //$errors .= '<span style="color: red;">Warning: ' . JPATH_SITE . '/templates/'.$template.'/css/template.css' . ' or ' . JPATH_SITE . '/templates/'.$template.'/css/template.css.php does not appear to be a valid file. Reverting to JoomlaCK\'s default styles</span><br/>'; AW 15/07/11
             }
         }
         //end if valid file
         /* Is the content_css == 0 or 1 then use FCK's default */
         if ($errors !== "") {
             $content_css = 'plugins/editors/jckeditor/contents.css';
         }
         //end if
     } else {
         if ($content_css_custom) {
             $hasRoot = strpos(' ' . strtolower($content_css_custom), strtolower(JPATH_SITE));
             $file_path = ($hasRoot ? '' : JPATH_SITE) . ($hasRoot || substr($content_css_custom, 0, 1) == DS ? '' : DS) . $content_css_custom;
             if (is_file($file_path)) {
                 $content_css = $file_path;
                 $content_css = str_replace(strtolower(JPATH_SITE) . DS, '', strtolower($content_css_custom));
             } else {
                 //$errors .= '<span style="color: red;">Warning: ' .  $file_path . ' does not appear to be a valid file.</span><br/>'; AW 15/07/11
                 $errors .= '<span style="color: red;">Warning: the JCK Editor cannot find a default template.css style-sheet to use. Please see: <a  href="http://www.joomlackeditor.com/downloads/jck-editor/installation-guide?start=8">Installation guide</a></span><br/>';
                 $content_css = 'plugins/editors/jckeditor/contents.css';
             }
             //end if valid file
         } else {
             $content_css = 'plugins/editors/jckeditor/contents.css';
         }
         //end if $content_css_custom
         /*write to xml file and read from css asnd store this file under editors*/
     }
     //end if $content_css || $editor_css
     return $content_css;
 }
function botEditorArea($name, $content, $hiddenField, $width, $height, $col, $row)
{
    global $my, $mosConfig_live_site, $database, $option, $_MAMBOTS, $mosConfig_absolute_path, $isInline, $bodyStyles, $template, $path_root;
    $gid = 20;
    $isInline = 0;
    $bodyStyles = "";
    $template = "";
    $content = str_replace("&lt;", "<", $content);
    $content = str_replace("&gt;", ">", $content);
    $content = str_replace("&amp;", "&", $content);
    $content = str_replace("&nbsp;", " ", $content);
    $content = str_replace("&quot;", "\"", $content);
    $mainframe = new mosMainFrame($database, $option, '.');
    $query = "SELECT id FROM #__mambots WHERE element = 'legacy.fckeditor' AND folder = 'editors'";
    $database->setQuery($query);
    $id = $database->loadResult();
    $mambot = new mosMambot($database);
    $mambot->load($id);
    $params =& new mosParameters($mambot->params);
    $toolbar = $params->get('toolbar', 'Advanced');
    $toolbar_ft = $params->get('toolbar_ft', 'Advanced');
    $content_css = $params->get('content_css', '1');
    $editor_css = $params->get('editor_css', '0');
    $content_css_custom = $params->get('content_css_custom', '');
    $text_direction = $params->get('text_direction', 'ltr');
    $newlines = $params->get('newlines', 'false');
    $skin = $params->get('skin', 'office2007');
    $image_path = $params->get('imagePath', '/images/stories/');
    $wwidth = $params->get('wwidth', '100%');
    $hheight = $params->get('hheight', '480');
    $formatSource = $params->get('FormatSource', 1);
    $add_stylesheet_path = $params->get('add_stylesheet_path', '');
    $add_stylesheet = $params->get('add_stylesheet', '');
    $bgcolor = $params->get('bgcolor', '#FFFFFF');
    $fontcolor = $params->def('fontcolor', '');
    $entermode = $params->def('entermode', 0);
    $shiftentermode = $params->def('shiftentermode', 1);
    $htmlentities = $params->def('htmlentities', 0);
    $crtlshiftentermode = $params->def('ctrlshiftentermode', 2);
    $includelatinentities = $params->def('includelatinentities', 0);
    $includegreekentities = $params->def('includegreekentities', 0);
    $numericentities = $params->def('numericentities', 0);
    $useRelativeURLPath = $params->def('UserRelativeFilePath', 1);
    $textAlign = $params->def('TextAlign', '');
    $showerrors = $params->def('showerrors', 1);
    $ForceSpellCheck = $params->def('ForceSpellCheck', 0);
    //set default view for toolabar
    $toolbar = $toolbar == 'Default' ? 'Advanced' : $toolbar;
    $toolbar_ft = $toolbar_ft == 'Default' ? 'Advanced' : $toolbar_ft;
    //set flag to see if Pspell should be enabled
    $enablePspell = function_exists("pspell_check") ? 1 : 0;
    //define path_root for relative path
    $path_root = '../';
    if (strpos($_SERVER['REQUEST_URI'], 'administrator')) {
        $logintime = mosGetParam($_SESSION, 'session_logintime', '');
        $session_id = md5($my->id . $my->username . $my->usertype . $logintime);
    } else {
        $query = 'select s.session_id from #__session s' . ' join #__users u on u.id = s.userid ' . ' where u.id =' . $my->id . ' and s.guest = 0 and u.gid > 18 ';
        $database->setQuery($query);
        $session_id = $database->loadResult();
        //set toolbar to compact mode
        $toolbar = $toolbar_ft;
        $path_root = '';
    }
    //check to see if we have to change the install chmod settings
    changeFCKChmod($path_root);
    /* Need to check to see  session recorded already created */
    $ip = md5($_SERVER['REMOTE_ADDR']);
    $query = 'select session_id from #__session where session_id =\'' . $ip . '\'';
    $database->setQuery($query);
    $ip_recorded = $database->loadResult();
    if (!isset($ip_recorded)) {
        $query = 'insert into #__session(username,time,session_id,gid) values(\'' . $session_id . '\',\'' . (time() + 7200) . '\',\'' . $ip . '\',0)';
    } else {
        $query = 'update #__session set time = \'' . (time() + 7200) . '\',username = \'' . $session_id . '\' ' . 'where session_id =\'' . $ip . '\'';
    }
    $database->setQuery($query);
    $database->query();
    $errors = '';
    //Sanitize image path
    $image_path = preg_replace('/(^\\s*\\/|\\/\\s*$)/', '', $image_path);
    $xml_path = "{$mosConfig_absolute_path}/mambots/editors/fckeditor/fckstyles_template.xml";
    $template = $mainframe->getTemplate();
    if ($content_css || $editor_css) {
        if ($editor_css !== 0 & $content_css == 0) {
            if (is_file($mosConfig_absolute_path . '/templates/' . $template . '/css/editor_css.css')) {
                $content_css = 'templates/' . $template . '/css/editor_css.css';
            } else {
                if ($my->gid > $gid) {
                    $errors .= '<span style="color: red;">Warning: ' . $mosConfig_absolute_path . 'templates/' . $template . '/css/editor_css.css' . ' does not appear to be a valid file. Reverting to JoomlaFCK\'s default styles</span><br/>';
                }
                //end if gid > 29
            }
            //end if valid file
        } else {
            if (is_file($mosConfig_absolute_path . '/templates/' . $template . '/css/template_css.css')) {
                $content_css = 'templates/' . $template . '/css/template_css.css';
            } else {
                if (is_file($mosConfig_absolute_path . '/templates/' . $template . '/css/template.css.php')) {
                    $content_css = 'templates/' . $template . '/css/JFCKeditor.css.php';
                    if (!is_file($mosConfig_absolute_path . '/templates/' . $template . '/css/JFCKeditor.css.php') || filemtime($mosConfig_absolute_path . '/templates/' . $template . '/css/template.css.php') > filemtime($mosConfig_absolute_path . '/templates/' . $template . '/css/JFCKeditor.css.php')) {
                        $file_content = file_get_contents('../templates/' . $template . '/css/template.css.php');
                        $file_content = preg_replace_callback("/(.*?)(@?ob_start\\('?\"?ob_gzhandler\"?'?\\))(.*)/", create_function('$matches', 'return ($matches[1]) .\';\';'), $file_content);
                        $file_content = preg_replace("/(.*define\\().*DIRECTORY_SEPARATOR.*(;?)/", '', $file_content);
                        $file_content = '<' . '?' . 'php' . ' function getYooThemeCSS() { ' . '?' . '>' . $file_content . '<' . '?' . 'php' . ' } ' . '?' . '>';
                        $fout = fopen($path_root . $content_css, "w");
                        fwrite($fout, $file_content);
                        fclose($fout);
                    }
                    include $path_root . $content_css;
                    $content_css = 'templates/' . $template . '/css/JFCKeditor.css';
                    ob_start();
                    getYooThemeCSS();
                    $file_content = ob_get_contents();
                    ob_end_clean();
                    $fout = fopen($path_root . $content_css, "w");
                    fwrite($fout, $file_content);
                    fclose($fout);
                } else {
                    if ($my->gid > $gid) {
                        $errors .= '<span style="color: red;">Warning: ' . $mosConfig_absolute_path . 'templates/' . $template . '/css/template_css.css' . ' does not appear to be a valid file. Reverting to JoomlaFCK\'s default styles</span><br/>';
                    }
                    //end if gid > 29
                }
            }
            //end if valid file
        }
        //end if  $editor_css !== 0 & $content_css == 0
        /* Is the content_css == 0 or 1 then use FCK's default */
        if ($errors != "") {
            $content_css = 'mambots/editors/fckeditor/editor/css/fck_editorarea.css';
            $style_css = "fckstyles.xml";
        }
        //end if
        /*write to xml file and read from css asnd store this file under editors*/
        xml_writer($path_root . $content_css, $xml_path);
        $style_css = "fckstyles_template.xml";
    } else {
        if ($content_css_custom) {
            $hasRoot = strpos(' ' . strtolower($content_css_custom), strtolower($mosConfig_absolute_path));
            $file_path = ($hasRoot ? '' : $mosConfig_absolute_path) . ($hasRoot || substr($content_css_custom, 0, 1) == DIRECTORY_SEPARATOR ? '' : DIRECTORY_SEPARATOR) . $content_css_custom;
            if (is_file($file_path)) {
                $content_css = $file_path;
                $content_css = str_replace(strtolower($mosConfig_absolute_path) . DS, '', strtolower($content_css_custom));
                xml_writer($path_root . $content_css, $xml_path);
                $style_css = "fckstyles_template.xml";
            } else {
                if ($my->gid > $gid) {
                    $errors .= '<span style="color: red;">Warning: ' . $mosConfig_absolute_path . '/' . $content_css_custom . ' does not appear to be a valid file.</span><br/>';
                }
                //end if gid > $gid
                $content_css = 'mambots/editors/fckeditor/editor/css/fck_editorarea.css';
                $style_css = "fckstyles.xml";
            }
            //end if valid file
        } else {
            $content_css = 'mambots/editors/fckeditor/editor/css/fck_editorarea.css';
            $style_css = "fckstyles.xml";
        }
        //end if $content_css_custom
    }
    //end if $content_css || $editor_css
    if (strpos($width, '%') === false) {
        $WidthCSS = $width . 'px';
    } else {
        $WidthCSS = $width;
    }
    if (strpos($height, '%') === false) {
        $HeightCSS = $height . 'px';
    } else {
        $HeightCSS = $height;
    }
    //if additional stylesheets specified
    $stylesheet_name = '';
    if ($add_stylesheet_path) {
        $hasRoot = strpos(' ' . strtolower($add_stylesheet_path), strtolower($mosConfig_absolute_path));
        $add_stylesheet_path = str_replace(strtolower($mosConfig_absolute_path) . DIRECTORY_SEPARATOR, '', strtolower($add_stylesheet_path));
    } else {
        $add_stylesheet_path = '/templates/' . $template . '/css/';
    }
    $BaseAddCSSPath = (preg_match('/(^\\/|^\\\\)/', $add_stylesheet_path) ? '' : '/') . $add_stylesheet_path . (preg_match('/.(\\/$|\\\\$)/', $add_stylesheet_path) ? '' : '/');
    $BaseAddCSSPath = str_replace('\\', '/', $BaseAddCSSPath);
    //echo $add_stylesheet_path;
    if ($add_stylesheet_path && $add_stylesheet) {
        if (strpos($add_stylesheet, ';')) {
            $stylesheets = explode(';', $add_stylesheet);
        } else {
            $stylesheets[] = $add_stylesheet;
        }
        $count = 0;
        foreach ($stylesheets as $stylesheet) {
            if (!preg_match('/\\.\\w{3}$/', $stylesheet)) {
                $stylesheet .= '.css';
            }
            $fin = $path_root . substr($BaseAddCSSPath, 1, strlen($BaseAddCSSPath)) . $stylesheet;
            $file = $mosConfig_absolute_path . (preg_match('/(^\\/|^\\\\)/', $add_stylesheet_path) ? '' : DIRECTORY_SEPARATOR) . $add_stylesheet_path . (preg_match('/.(\\/$|\\\\$)/', $add_stylesheet_path) ? '' : DIRECTORY_SEPARATOR) . $stylesheet;
            $fout = $path_root . 'mambots/editors/fckeditor/' . str_replace('.css', '.xml', $stylesheet);
            if (is_file($file)) {
                xml_writer($fin, $fout);
            } else {
                if ($my->gid > $gid) {
                    $errors .= '<span style="color: red;">Warning: ' . $file . ' does not appear to be a valid file.</span><br/>';
                }
                //end if gid > $gid
                array_splice($stylesheets, $count, 1);
            }
            //end if valid file
            $count++;
        }
        $stylesheet_name = str_replace('.css', '', implode(';', $stylesheets));
    }
    $results = $_MAMBOTS->trigger('onCustomEditorButton');
    $buttons = array();
    foreach ($results as $result) {
        if ($result[0]) {
            $buttons[] = '<img src="' . $mosConfig_live_site . '/mambots/editors-xtd/' . $result[0] . '" onclick="InsertHTML(\'' . $hiddenField . '\',\'' . $result[1] . '\')" />';
        }
    }
    $buttons = implode("", $buttons);
    /* Lets sort out the directory issue */
    $urlDetails = parse_url($mosConfig_live_site);
    $directory = str_replace(array($urlDetails['scheme'], $urlDetails['host'], '://'), '', $mosConfig_live_site);
    if ($showerrors && $my->gid > $gid) {
        //Version Checker
        if (function_exists("curl_init")) {
            $ch = curl_init();
            curl_setopt($ch, CURLOPT_URL, 'http://www.joomlafckeditor.com/version.txt');
            curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
            $version = curl_exec($ch);
            curl_close($ch);
            if ($version != '2.6.4.1' && $version) {
                $errors .= 'Please be aware there is a newer version of the JoomlaFCK Editor which can be downloaded from <a href="http://www.joomlafckeditor.com" target="_blank">http://www.joomlafckeditor.com</a>.<br/>';
            }
            //end if
        }
        //end if
        /* Check to see if the path exists. */
        if (!is_dir($mosConfig_absolute_path . '/' . $image_path)) {
            $errors .= '<span style="color: red;">Warning: ' . $mosConfig_absolute_path . $imagePath . ' does not appear to be a valid directory!</span><br/>';
        }
        //end if
        if ($errors !== "") {
            echo $errors . '<span style="color:blue">Please note the above message will only displayed to Managers and above.</span>';
        }
        //end if
    }
    $content_css = $mosConfig_live_site . '/' . $content_css;
    $content_css = str_replace('\\', '/', $content_css);
    // Define Enter & Shift Enter Mode
    $enterbehavior = array();
    $enterbehavior[0] = 'br';
    $enterbehavior[1] = 'p';
    $enterbehavior[2] = 'div';
    // Define Entities
    $htmlentities = $htmlentities ? 'true' : 'false';
    $includelatinentities = $includelatinentities ? 'true' : 'false';
    $includegreekentities = $includegreekentities ? 'true' : 'false';
    $numericentities = $numericentities ? 'true' : 'false';
    return <<<EOD
<textarea name="{$hiddenField}" id="{$hiddenField}" cols="{$col}" rows="{$row}" style="width:{$WidthCSS}; height:{$HeightCSS};">{$content}</textarea>
<script type="text/javascript">

\tvar oFCKeditor{$hiddenField} = new FCKeditor('{$hiddenField}');
\toFCKeditor{$hiddenField}.BasePath = "{$directory}/mambots/editors/fckeditor/" ;
\toFCKeditor{$hiddenField}.Config["SitePath"] =  "{$mosConfig_live_site}";
\toFCKeditor{$hiddenField}.Config["ImagePath"] =  "{$image_path}"; 
\toFCKeditor{$hiddenField}.Config["UseRelativeURLPath"] =  {$useRelativeURLPath}; 
\toFCKeditor{$hiddenField}.Config["CustomConfigurationsPath"] = "{$mosConfig_live_site}/mambots/editors/fckconfigjoomla.js";
\toFCKeditor{$hiddenField}.ToolbarSet = "{$toolbar}" ;
\toFCKeditor{$hiddenField}.Config['BaseAddCSSPath'] = "{$BaseAddCSSPath}";
\toFCKeditor{$hiddenField}.Config['EditorAreaCSS'] = "{$content_css}";
\toFCKeditor{$hiddenField}.Config['ContentLangDirection'] = "{$text_direction}" ;
\toFCKeditor{$hiddenField}.Config['SkinPath'] = oFCKeditor{$hiddenField}.BasePath + 'editor/skins/' + '{$skin}' + '/' ;
\toFCKeditor{$hiddenField}.Config['StylesXmlPath']= oFCKeditor{$hiddenField}.BasePath +'{$style_css}';
\toFCKeditor{$hiddenField}.Config['FormatSource'] = {$formatSource};\t
\toFCKeditor{$hiddenField}.Config['AddStylesheets'] = "{$stylesheet_name}";
\toFCKeditor{$hiddenField}.Config['BackgroundColor'] = "{$bgcolor}";
\toFCKeditor{$hiddenField}.Config['FontColor'] = "'.{$fontcolor}.'";\t
\toFCKeditor{$hiddenField}.Config['EnterMode'] = "{$enterbehavior[$entermode]}";
\toFCKeditor{$hiddenField}.Config['ShiftEnterMode'] = "{$enterbehavior[$shiftentermode]}";
\toFCKeditor{$hiddenField}.Config['CrtlShiftEnterMode'] = "{$enterbehavior[$crtlshiftentermode]}";
\toFCKeditor{$hiddenField}.Config['ProcessHTMLEntities'] = {$htmlentities} ;
\toFCKeditor{$hiddenField}.Config['IncludeLatinEntities'] = {$includelatinentities} ;
\toFCKeditor{$hiddenField}.Config['IncludeGreekEntities'] = {$includegreekentities} ;
\toFCKeditor{$hiddenField}.Config['ProcessNumericEntities'] = {$numericentities} ;
\toFCKeditor{$hiddenField}.Config['Pspell'] = "{$enablePspell}";
\toFCKeditor{$hiddenField}.Config['ForceInlineStyles'] = {$isInline};
\toFCKeditor{$hiddenField}.Config['JTemplate'] = "{$template}";
\toFCKeditor{$hiddenField}.Config['BodyStyles'] = "{$bodyStyles}";
\toFCKeditor{$hiddenField}.Config['TextAlign'] = "{$textAlign}";
\toFCKeditor{$hiddenField}.Config['UseAspell'] = "{$enablePspell}";
\toFCKeditor{$hiddenField}.Width = "{$wwidth}" ;
\toFCKeditor{$hiddenField}.Style_css = "{$style_css}" ;
\toFCKeditor{$hiddenField}.Height = "{$hheight}" ;
\t//oFCKeditor{$hiddenField}.ReplaceTextarea() ;
\t
\t
\t
\tvar forceSpellonSave = {$ForceSpellCheck}; 
\t
\tif(forceSpellonSave) {
\t
\t
\t\tif (!window.addEventListener) {
  \t\t\t  window.addEventListener = function (type, listener, useCapture) {
        \t\t\twindow.attachEvent('on' + type, function() { listener(event) });
    \t\t}
\t\t}
\t
\t\twindow.addEventListener("load", function() {
\t\t
\t\tif(typeof FCKIndexOf != "function")
\t\t{\t\t
\t\t\t\tvar FCKIndexOf = ( Array.prototype.indexOf ) ?
\t\t\t\t\t\tfunction( array, entry )
\t\t\t\t\t\t\t{
\t\t\t\t\t\t\t\treturn array.indexOf( entry );
\t\t\t\t\t\t\t}
\t\t\t\t\t:
\t\t\t\t\t\tfunction( array, entry )
\t\t\t\t\t\t{
\t\t\t\t\t\t\tfor ( var i = 0, len = array.length ; i < len ; i++ )
\t\t\t\t\t\t\t{
\t\t\t\t\t\t\t\tif ( array[ i ] === entry )
\t\t\t\t\t\t\t\t\treturn i;
\t\t\t\t\t\t\t}
\t\t\t\t\t\t\treturn -1;
\t\t\t\t\t\t};\t
\t\t\t
\t\t\t\t\t\t
\t\t\t\tfunction getElementByTitle( titles, obj ) {
\t\t\t\t
\t\t\t\t\tif (obj.title && FCKIndexOf(titles,obj.title) != -1 ) {
\t\t\t\t\t\t return obj;
\t\t\t\t\t}
\t\t\t\t\tfor ( var i = 0; i < obj.childNodes.length; i++ )
\t\t\t\t\t\t{
\t\t\t\t\t\t\tvar child = getElementByTitle( titles, obj.childNodes[i] );
\t\t\t\t\t\t\tif(child)
\t\t\t\t\t\t\t\treturn child;
\t\t\t\t\t\t}
\t\t\t\t\t
\t\t\t\t}\t
\t\t
\t\t\t\tvar submitbuttonOrig = submitbutton; // save fuction defintion defined by component
\t\t\t\t\t
\t\t\t\tif(typeof submitbutton == "function")
\t\t\t\t{
\t\t\t\t\t\t
\t\t\t\t\tfunction submitbuttonNew(pressbutton) //overide function defintion to call spellcheck on save
\t\t\t\t\t{
\t\t\t\t\t\t\t
\t\t\t\t\t\tif(pressbutton == "cancel" || pressbutton == "close" || pressbutton =="cpanel" )
\t\t\t\t\t\t{
\t\t\t\t\t\t\tsubmitbuttonOrig(pressbutton);
\t\t\t\t\t\t\treturn;
\t\t\t\t\t\t}
\t\t\t\t\t\t
\t\t\t\t\t\t\t\t
\t\t\t\t\t\tvar titles = ["Close","Cancel"];
\t\t\t\t\t\t
\t\t\t\t\t\tvar obj = getElementByTitle(titles,document); 
\t\t\t\t\t\t
\t\t\t\t\t\tvar exp = RegExp(pressbutton,"i");
\t\t\t\t\t\t
\t\t\t\t\t\tif(obj && obj.parentNode && exp.test(obj.parentNode.getAttribute("href")) )
\t\t\t\t\t\t{
\t\t\t\t\t\t\tsubmitbuttonOrig(pressbutton);
\t\t\t\t\t\t\treturn;
\t\t\t\t\t\t}
\t\t\t\t\t\t
\t\t\t\t\t\tvar FCK = FCKeditorAPI.GetInstance("{$hiddenField}");
\t\t\t\t\t\tFCK.submitform = submitbuttonOrig;
\t\t\t\t\t\tFCK.Config["saveAction"] = pressbutton;
\t\t\t\t\t\tFCK.ToolbarSet.CurrentInstance.Commands.GetCommand( "SpellCheck" ).Execute() ;
\t\t\t\t\t}
\t\t\t\t\t
\t\t\t\t\tsubmitbutton = submitbuttonNew; ' : "") . ' \t\t
\t\t\t\t}
\t\t\t}\t
\t\t},false);\t
\t}
\t
\t
\tfunction ReplaceText{$hiddenField}()
\t{
   \t\toFCKeditor{$hiddenField}.ReplaceTextarea();
   \t}
   
   \tif(window.addEvent)
\t{
\t\twindow.addEvent("domready",ReplaceText{$hiddenField})
\t}
\telse if(window.addEventListener)
\t{
\t\twindow.addEventListener("DOMContentLoaded", ReplaceText{$hiddenField}, null);
\t}
\telse
\t{
\t\twindow.attachEvent("onload",ReplaceText{$hiddenField})
\t
\t}\t
   
   
\tfunction InsertHTML(field, value) {
\t\t// Get the editor instance that we want to interact with.
\t\tvar oEditor = FCKeditorAPI.GetInstance(field) ;
\t
\t\t// Check the active editing mode.
\t\tif ( oEditor.EditMode == FCK_EDITMODE_WYSIWYG )\t{
\t\t\t// Insert the desired HTML.
\t\t\toEditor.InsertHtml( value ) ;
\t\t} else {
\t\t\talert( 'Please switch to WYSIWYG mode.' ) ;
\t\t}//end if
\t}//end function

</script>
<br />
<p>{$buttons}</p>
EOD;
}
Beispiel #4
0
 function getPath(&$params, &$errors = '')
 {
     //Get parameter options for template CSS
     $content_css = $params->get('content_css', 1);
     $editor_css = $params->def('editor_css', 0);
     $content_css_custom = $params->def('content_css_custom', '');
     $add_stylesheet_path = $params->def('add_stylesheet_path', '');
     $add_stylesheet = $params->def('add_stylesheet', '');
     $db = JFactory::getDBO();
     $query = 'SELECT template' . ' FROM #__templates_menu' . ' WHERE client_id = 0' . ' AND menuid = 0';
     $db->setQuery($query);
     $template = $db->loadResult();
     if ($content_css || $editor_css) {
         if ($editor_css !== 0 & $content_css == 0) {
             if (is_file(JPATH_SITE . '/templates/' . $template . '/css/editor.css')) {
                 $content_css = 'templates/' . $template . '/css/editor.css';
             } else {
                 $errors .= '<span style="color: red;">Warning: ' . JPATH_SITE . '/templates/' . $template . '/css/editor.css' . ' does not appear to be a valid file. Reverting to JoomlaFCK\'s default styles</span><br/>';
             }
             //end if valid file
         } else {
             if (is_file(JPATH_SITE . '/templates/' . $template . '/css/template.css')) {
                 $content_css = 'templates/' . $template . '/css/template.css';
             } else {
                 if (is_file(JPATH_SITE . '/templates/' . $template . '/css/template.css.php')) {
                     $content_css = 'templates/' . $template . '/css/JFCKeditor.css.php';
                     if (!is_file(JPATH_SITE . '/templates/' . $template . '/css/JFCKeditor.css.php') || filemtime(JPATH_SITE . '/templates/' . $template . '/css/template.css.php') > filemtime(JPATH_SITE . '/templates/' . $template . '/css/JFCKeditor.css.php')) {
                         $file_content = file_get_contents('../templates/' . $template . '/css/template.css.php');
                         $file_content = preg_replace_callback("/(.*?)(@?ob_start\\('?\"?ob_gzhandler\"?'?\\))(.*)/", create_function('$matches', 'return ($matches[1]) .\';\';'), $file_content);
                         $file_content = preg_replace("/(.*define\\().*DIRECTORY_SEPARATOR.*(;?)/", '', $file_content);
                         $file_content = '<' . '?' . 'php' . ' function getYooThemeCSS() { ' . '?' . '>' . $file_content . '<' . '?' . 'php' . ' } ' . '?' . '>';
                         $fout = fopen($this->_path_root . $content_css, "w");
                         fwrite($fout, $file_content);
                         fclose($fout);
                     }
                     include $this->_path_root . $content_css;
                     $content_css = 'templates/' . $template . '/css/JFCKeditor.css';
                     ob_start();
                     getYooThemeCSS();
                     $file_content = ob_get_contents();
                     ob_end_clean();
                     $fout = fopen($this->_path_root . $content_css, "w");
                     fwrite($fout, $file_content);
                     fclose($fout);
                 } else {
                     $errors .= '<span style="color: red;">Warning: ' . JPATH_SITE . '/templates/' . $template . '/css/template.css' . ' or ' . JPATH_SITE . '/templates/' . $template . '/css/template.css.php does not appear to be a valid file. Reverting to JoomlaFCK\'s default styles</span><br/>';
                 }
             }
             //end if valid file
         }
         //end if  $editor_css !== 0 & $content_css == 0
         /* Is the content_css == 0 or 1 then use FCK's default */
         if ($errors !== "") {
             $content_css = 'plugins/editors/jckeditor/contents.css';
         }
         //end if
     } else {
         if ($content_css_custom) {
             $hasRoot = strpos(' ' . strtolower($content_css_custom), strtolower(JPATH_SITE));
             $file_path = ($hasRoot ? '' : JPATH_SITE) . ($hasRoot || substr($content_css_custom, 0, 1) == DS ? '' : DS) . $content_css_custom;
             if (is_file($file_path)) {
                 $content_css = $file_path;
                 $content_css = str_replace(strtolower(JPATH_SITE) . DS, '', strtolower($content_css_custom));
             } else {
                 $errors .= '<span style="color: red;">Warning: ' . $file_path . ' does not appear to be a valid file.</span><br/>';
                 $content_css = 'plugins/editors/jckeditor/contents.css';
             }
             //end if valid file
         } else {
             $content_css = 'plugins/editors/jckeditor/contents.css';
         }
         //end if $content_css_custom
         /*write to xml file and read from css asnd store this file under editors*/
     }
     //end if $content_css || $editor_css
     $this->_content_css = $this->_path_root . $content_css;
     $content_css = JURI::root() . $content_css;
     $content_css = str_replace(DS, '/', $content_css);
     return $content_css;
 }
Beispiel #5
0
 function _getTemplateCss($template, &$BaseAddCSSPath, &$style_css, &$stylesheet_name, &$errors)
 {
     //Get parameter options for template CSS
     $content_css = $this->params->def('content_css', 1);
     $editor_css = $this->params->def('editor_css', 0);
     $content_css_custom = $this->params->def('content_css_custom', '');
     $add_stylesheet_path = $this->params->def('add_stylesheet_path', '');
     $add_stylesheet = $this->params->def('add_stylesheet', '');
     /* Start setting up the XML files */
     $xml_path = $this->_path_root . "plugins/editors/fckeditor/fckstyles_template.xml";
     $style_css = "fckstyles_template.xml";
     // initialise $error varable
     $errors = '';
     if ($content_css || $editor_css) {
         if ($editor_css !== 0 & $content_css == 0) {
             if (is_file(JPATH_SITE . '/templates/' . $template . '/css/editor.css')) {
                 $content_css = 'templates/' . $template . '/css/editor.css';
             } else {
                 $errors .= '<span style="color: red;">Warning: ' . JPATH_SITE . '/templates/' . $template . '/css/editor.css' . ' does not appear to be a valid file. Reverting to JoomlaFCK\'s default styles</span><br/>';
             }
             //end if valid file
         } else {
             if (is_file(JPATH_SITE . '/templates/' . $template . '/css/template.css')) {
                 $content_css = 'templates/' . $template . '/css/template.css';
             } else {
                 if (is_file(JPATH_SITE . '/templates/' . $template . '/css/template.css.php')) {
                     $content_css = 'templates/' . $template . '/css/JFCKeditor.css.php';
                     if (!is_file(JPATH_SITE . '/templates/' . $template . '/css/JFCKeditor.css.php') || filemtime(JPATH_SITE . '/templates/' . $template . '/css/template.css.php') > filemtime(JPATH_SITE . '/templates/' . $template . '/css/JFCKeditor.css.php')) {
                         $file_content = file_get_contents('../templates/' . $template . '/css/template.css.php');
                         $file_content = preg_replace_callback("/(.*?)(@?ob_start\\('?\"?ob_gzhandler\"?'?\\))(.*)/", create_function('$matches', 'return ($matches[1]) .\';\';'), $file_content);
                         $file_content = preg_replace("/(.*define\\().*DIRECTORY_SEPARATOR.*(;?)/", '', $file_content);
                         $file_content = '<' . '?' . 'php' . ' function getYooThemeCSS() { ' . '?' . '>' . $file_content . '<' . '?' . 'php' . ' } ' . '?' . '>';
                         $fout = fopen($this->_path_root . $content_css, "w");
                         fwrite($fout, $file_content);
                         fclose($fout);
                     }
                     include $this->_path_root . $content_css;
                     $content_css = 'templates/' . $template . '/css/JFCKeditor.css';
                     ob_start();
                     getYooThemeCSS();
                     $file_content = ob_get_contents();
                     ob_end_clean();
                     $fout = fopen($this->_path_root . $content_css, "w");
                     fwrite($fout, $file_content);
                     fclose($fout);
                 } else {
                     $errors .= '<span style="color: red;">Warning: ' . JPATH_SITE . '/templates/' . $template . '/css/template.css' . ' or ' . JPATH_SITE . '/templates/' . $template . '/css/template.css.php does not appear to be a valid file. Reverting to JoomlaFCK\'s default styles</span><br/>';
                 }
             }
             //end if valid file
         }
         //end if  $editor_css !== 0 & $content_css == 0
         /* Is the content_css == 0 or 1 then use FCK's default */
         if ($errors !== "") {
             $content_css = 'plugins/editors/fckeditor/editor/css/fck_editorarea.css';
         }
         //end if
         /*write to xml file and read from css asnd store this file under editors*/
         $this->xml_writer($this->_path_root . $content_css, $xml_path);
     } else {
         if ($content_css_custom) {
             $hasRoot = strpos(' ' . strtolower($content_css_custom), strtolower(JPATH_SITE));
             $file_path = ($hasRoot ? '' : JPATH_SITE) . ($hasRoot || substr($content_css_custom, 0, 1) == DS ? '' : DS) . $content_css_custom;
             if (is_file($file_path)) {
                 $content_css = $file_path;
                 $content_css = str_replace(strtolower(JPATH_SITE) . DS, '', strtolower($content_css_custom));
             } else {
                 $errors .= '<span style="color: red;">Warning: ' . $file_path . ' does not appear to be a valid file.</span><br/>';
                 $content_css = 'plugins/editors/fckeditor/editor/css/fck_editorarea.css';
             }
             //end if valid file
         } else {
             $content_css = 'plugins/editors/fckeditor/editor/css/fck_editorarea.css';
         }
         //end if $content_css_custom
         /*write to xml file and read from css asnd store this file under editors*/
         $this->xml_writer($this->_path_root . $content_css, $xml_path);
     }
     //end if $content_css || $editor_css
     //if additional stylesheets specified
     $stylesheet_name = '';
     if ($add_stylesheet_path) {
         $hasRoot = strpos(' ' . strtolower($add_stylesheet_path), strtolower(JPATH_SITE));
         $add_stylesheet_path = str_replace(strtolower(JPATH_SITE) . DS, '', strtolower($add_stylesheet_path));
     } else {
         $add_stylesheet_path = '/templates/' . $template . '/css/';
     }
     $BaseAddCSSPath = (preg_match('/(^\\/|^\\\\)/', $add_stylesheet_path) ? '' : '/') . $add_stylesheet_path . (preg_match('/.(\\/$|\\\\$)/', $add_stylesheet_path) ? '' : '/');
     $BaseAddCSSPath = str_replace('\\', '/', $BaseAddCSSPath);
     //echo $add_stylesheet_path;
     if ($add_stylesheet_path && $add_stylesheet) {
         if (strpos($add_stylesheet, ';')) {
             $stylesheets = explode(';', $add_stylesheet);
         } else {
             $stylesheets[] = $add_stylesheet;
         }
         $count = 0;
         foreach ($stylesheets as $stylesheet) {
             if (!preg_match('/\\.\\w{3}$/', $stylesheet)) {
                 $stylesheet .= '.css';
             }
             $fin = $this->_path_root . substr($BaseAddCSSPath, 1, strlen($BaseAddCSSPath)) . $stylesheet;
             $file = JPATH_SITE . (preg_match('/(^\\/|^\\\\)/', $add_stylesheet_path) ? '' : DS) . $add_stylesheet_path . (preg_match('/.(\\/$|\\\\$)/', $add_stylesheet_path) ? '' : DS) . $stylesheet;
             $fout = $this->_path_root . 'plugins/editors/fckeditor/' . str_replace('.css', '.xml', $stylesheet);
             if (!is_file($file)) {
                 $errors .= '<span style="color: red;">Warning: ' . $file . ' does not appear to be a valid file. So additional styles will not be added</span><br/>';
                 array_splice($stylesheets, $count, 1);
             } else {
                 $this->xml_writer($fin, $fout);
             }
             $count++;
         }
         $stylesheet_name = str_replace('.css', '', implode(';', $stylesheets));
     }
     $content_css = JURI::root() . $content_css;
     $content_css = str_replace(DS, '/', $content_css);
     return $content_css;
 }