Skip to content
Permalink
Browse files

Usr styles (#475)

* additons for  creating user styles

* updates to admin.php

* Updates admin.php to accept input for alternate template

* Set up path to alternate template

* new message function; tied alternate template to css6

* Replace text input with drop-down menu list for selecting alternate templates

* removed non-writable directories from template drop-down list

* Adds option to copy of default _style.css to ckeditor/css

* Adding setting for using alternate style sheet.

* adds info to aadmin.php

* Includes function alt_style_sheet() in edit.php to check for alternate style sheet in ckeditor/css.

* Chagned function name tfunc to ckg_admininfo, proof against naming ocnflicts

* fix for  compressed files which remove comments, hence header with template name from _style.css

* Localization for Info button in admin.php, enabling exact comparison for toggle function ckg_admininfo
  • Loading branch information...
turnermm committed May 15, 2019
1 parent 3ff8f85 commit 5fd62690ddd49c0ed7a7ef0ed8ac761cad2dc21a
Showing with 729 additions and 5 deletions.
  1. +37 −3 action/edit.php
  2. +124 −0 admin.php
  3. +3 −0 conf/default.php
  4. +2 −1 conf/metadata.php
  5. +11 −1 lang/en/lang.php
  6. +3 −0 lang/en/settings.php
  7. +11 −0 lang/en/style.txt
  8. +5 −0 script.js
  9. +533 −0 scripts/css6.php
@@ -517,6 +517,30 @@ function dw_edit_displayed()
}
/**
Check for for alternate style sheet
*/
function alt_style_sheet() {
$stylesheet = DOKU_PLUGIN . 'ckgedit/ckeditor/css/_style.css';
if(file_exists($stylesheet)) {
global $conf;
$tpl_name = $conf['template'];
if($fh = fopen($stylesheet,"r")) {
$line_num = 0;
while (!feof($fh) && $line_num < 4) {
$line = fgets($fh,1024); //msg($line);
if(strpos($line,$tpl_name)!==false) {
return DOKU_BASE . '/lib/plugins/ckgedit/ckeditor/css/_style.css' ;
break;
}
$line_num ++;
}
}
}
return "";
}
/**
* function _print
* @author Myron Turner
@@ -586,7 +610,8 @@ function _print()
$fbOptions = "filebrowserImageBrowseUrl : \"$doku_url/lib/plugins/ckgedit/fckeditor/editor/filemanager/browser/default/browser.html?Type=Image&Connector=$doku_url/lib/plugins/ckgedit/fckeditor/editor/filemanager/connectors/php/connector.php\",
filebrowserBrowseUrl: \"$doku_url/lib/plugins/ckgedit/fckeditor/editor/filemanager/browser/default/browser.html?Type=File&Connector=$doku_url/lib/plugins/ckgedit/fckeditor/editor/filemanager/connectors/php/connector.php\"";
}
$contents_css = $this->alt_style_sheet();
//msg($contents_css);
$ckeditor_replace =<<<CKEDITOR_REPLACE
ckgeditCKInstance = CKEDITOR.replace('wiki__text',
@@ -616,7 +641,9 @@ function _print()
}
);
FCKeditor_OnComplete(ckgeditCKInstance);
if("$contents_css") {
CKEDITOR.config.contentsCss = "$contents_css";
}
CKEDITOR_REPLACE;
@@ -650,9 +677,16 @@ function _print()
}
?>
</div>
<?php
/*
$this->xhtml=<<<ERRTXT
[<a class="wikilink1 curid" data-curid="true" href="/dokuwiki/doku.php?id=*:*" title="*:*">go to top</a> | <a class="wikilink1" href="/dokuwiki/doku.php?id=*:start#system_configuration" title="*:start">back to Index</a> | <a class="wikilink1" href="/dokuwiki/doku.php?id=*:start" title="*:start">Wiki start page</a> ]
ERRTXT;*/
?>

<textarea name="wikitext" id="wiki__text" <?php echo $ro?> cols="80" rows="10" class="edit" tabindex="1"><?php echo "\n".$this->xhtml?></textarea>

<!-- textarea name="wikitext" id="wiki__text" <?php echo $ro?> cols="80" rows="10"
class="edit" tabindex="1"><?php echo "<body style='background-color:#fff;background-image:none;'>\n" . $this->xhtml .'</body>' ?></textarea --!>
<?php
$temp=array();
124 admin.php
@@ -0,0 +1,124 @@
<?php
/**
* @author Myron Turner <turnermm02@shaw.ca>
* @license GPL 2 http://www.gnu.org/licenses/gpl-2.0.html
*/
require_once(DOKU_INC . 'lib/plugins/ckgedit/scripts/css6.php');
class admin_plugin_ckgedit extends DokuWiki_Admin_Plugin {
private $tpl_inc;
private $template;
private $alt;
function __construct() {
global $conf;
$this->template = $conf['template'];
$this->tpl_inc = tpl_incdir();
}
function handle() {
if (!isset($_REQUEST['cmd'])) return; // first time - nothing to do
$this->output = 'invalid';
if (!checkSecurityToken()) return;
if (!is_array($_REQUEST['cmd'])) return;
switch (key($_REQUEST['cmd'])) {
case 'stylesheet' : {
$this->alt = "";
$this->output = 'style_sheet_msg';
break;
}
case 'alt_stylesheet' : {
$this->alt = $_REQUEST['templates'];
$this->output = 'alt_style_sheet_msg';
break;
}
}
}
/**
* output appropriate html
*/
function html() {
ptln('<div id = "ckg_styl_sheet" style = "display:none">');
echo $this->locale_xhtml('style');
ptln('</div>');
ptln('<button type = "button" id = "Infobut" onclick="jQuery(\'#ckg_styl_sheet\').toggle(800,ckg_admininfo(this));">');
echo $this->getLang('stylesheet_oinfo');
ptln('</button>');
ptln('<form action="'.wl($ID).'" method="post">');
// output hidden values to ensure dokuwiki will return back to this plugin
ptln(' <input type="hidden" name="do" value="admin" />');
ptln(' <input type="hidden" name="page" value="'.$this->getPluginName().'" />');
formSecurityToken();
//Current style sheet
ptln('<p style = "line-height: 200%;">' . $this->getLang('default_stylesheet') . ': (' .$this->template . ')<br />');
ptln('<label for="ckg_save_ss">' .$this->getLang('checkbox').'</label>');
ptln('<input type="checkbox" name="ckg_save_ss">&nbsp;&nbsp;');
ptln('<input type="submit" name="cmd[stylesheet]" value="'.$this->getLang('style_sheet').'" /></p>');
// Other style sheet
$alt_val = isset($this->alt)?$this->alt: "" ;
ptln('<p style = "line-height: 200%;">' . $this->getLang('alt_stylesheet') .'<br />');
ptln('<select name="templates" style = "line-height:100%">');
echo $this->templates( $alt_val );
ptln('</select>');
ptln('<input type="submit" name="cmd[alt_stylesheet]" value="'.$this->getLang('style_sheet').'" />');
ptln('</form></p>');
if($this->output && $this->output == 'style_sheet_msg') {
$path = $this->tpl_inc;
ptln(htmlspecialchars($this->getLang($this->output)). " " .$this->template);
$retv = css_ckg_out($path);
$this->message($path, $retv);
}
else if($this->output && $this->output == 'alt_style_sheet_msg') {
ptln(htmlspecialchars($this->getLang($this->output)). " " .$this->alt);
$path = str_replace('tpl/'.$this->template, 'tpl/'.$this->alt,$this->tpl_inc);
$retv = css_ckg_out($path,$this->alt);
$this->message($path, $retv);
}
}
function message($path, $which) {
$messages = array(
"Stylesheet saved to $path" . 'Styles/_style.css',
"Failed to save stylesheet to $path" . 'Styles/_style.css'
);
$color = $which == 0? '#333': 'blue';
ptln('<br /><span style = "color:'.$color. ';">'.htmlspecialchars($messages[$which]).'</span>');
}
function templates($selected="") {
$dir = dirname($this->tpl_inc);
$files = scandir($dir);
$dir .= '/';
$list = "<option value='' >Select</option>";
foreach ($files AS $file) {
if($file == '.' || $file == '..' || $file == $this->template) continue;
$entry = $dir . $file;
if(!is_writable($entry)) continue;
if(is_dir ($entry ) ) {
if($file == $selected) {
$list .= "<option value='$file' selected>$file</option>";
}
else $list .= "<option value='$file' >$file</option>";
}
}
return $list;
}
}
@@ -40,5 +40,8 @@
$conf['preserve_enc'] = 0;
$conf['gui'] = 'moono';
$conf['rel_links'] = 0;
$conf['style_sheet'] = 0;
@@ -42,4 +42,5 @@
$meta['dblclk'] = array('multichoice','_choices' => array('on','off'));
$meta['preserve_enc'] = array('onoff');
$meta['gui'] = array('multichoice','_choices' => array('moono','moono-lisa'));
$meta['rel_links'] = array('onoff');
$meta['rel_links'] = array('onoff');
$meta['style_sheet']= array('onoff');
@@ -65,5 +65,15 @@
$lang['broken_image'] = "Use the imagePaste plugin with the Dokuwiki Mediamanager or try the MS Word Paste Tool. Raw data of Ctrl-v images over 2.5M can hang. This image is: " ;
$lang['js']['broken_image_1'] = "Use the imagePaste plugin with the Dokuwiki Mediamanager or try the MS Word Paste Tool.";
$lang['js']['broken_image_2'] = "Ctrl-v images with raw data over 2.5M can hang. This image is: " ;
$lang['menu'] = 'CKEditor editor CSS tool';
$lang['default_stylesheet'] = 'Create a style sheet for the current template';
$lang['alt_stylesheet'] = 'Create a stylesheet for another template';
$lang['style_sheet'] = 'Create Style sheet';
$lang['style_sheet_msg'] = 'Creating Style sheet for the current template:';
$lang['alt_style_sheet_msg'] = 'Creating Style sheet for:';
$lang['checkbox'] = 'Copy to ckeditor/css';
$lang['stylesheet_oinfo'] = 'Info';
$lang['stylesheet_cinfo'] = 'Close Info';
$lang['js']['stylesheet_oinfo'] = $lang['stylesheet_oinfo'];
$lang['js']['stylesheet_cinfo'] = $lang['stylesheet_cinfo'];
@@ -51,4 +51,7 @@
$lang['preserve_enc'] ="Preserve urlencoding in urls when the dokuwiki deaccent option is active.";
$lang['gui'] = "Select CKEditor GUI.";
$lang['rel_links'] = "Activate support for relative internal and image links";
$lang['style_sheet'] = 'Use an alternate style sheet for the Ckeditor editing window.' .
' For more information see the <b>CKEditor editor CSS tool</b>, under <em>Additional Plugins</em> on the <code>Admin</code> page. Or ' .
' see the ckgedit plugin page.';
@@ -0,0 +1,11 @@
**Current Template** \\
With this app you can create a style sheet for the CKEditor's editing window that is based on your template. It will place the style sheet in your template folder in the directory named **Styles**, which will be created when the style sheet is saved. The style sheet will be named **_styles.css**. To activate this style sheet two things must be done:

- it must be placed in **ckgedit/ckeditor/css**. This will automatically be done for you if you check off the checkbox labeled **Copy to ckeditor/css.**
- The **style_sheet** option in the ''Configuration Settings'' must be set to **true**.

**Other templates: installed but not activate** \\ You can also create additional style sheets for other templates which you might have stored in your **tpl** folder. These will be copied to the Styles folder of the respective templates but not to **ckeditor/css**.

----


@@ -487,3 +487,8 @@ function getCookie(name) {
var value = re.exec(document.cookie);
return (value != null) ? decodeURIComponent(value[1]) : null;
}
function ckg_admininfo(t){
if(t.innerHTML == LANG.plugins.ckgedit.stylesheet_cinfo)
t.innerHTML = LANG.plugins.ckgedit.stylesheet_oinfo;
else t.innerHTML = LANG.plugins.ckgedit.stylesheet_cinfo;
}

0 comments on commit 5fd6269

Please sign in to comment.
You can’t perform that action at this time.