Skip to content

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
lisps committed Oct 25, 2013
1 parent 948c958 commit e435eb8
Show file tree
Hide file tree
Showing 8 changed files with 206 additions and 3 deletions.
11 changes: 8 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
textrotate
==========
====== Textrotate Plugin for DokuWiki ======

textrotate
All documentation for the Tagfilter Plugin is available online at:

* http://dokuwiki.org/plugin:textrotate

(c) 2013 by lisps

See LICENSE for license info.
35 changes: 35 additions & 0 deletions action.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<?php
/**
* DokuWiki Plugin textrotate (Action Component)
*
* @license GPL 2 (http://www.gnu.org/licenses/gpl.html)
* @author lisps
*/

if (!defined('DOKU_INC')) die();
if (!defined('DOKU_PLUGIN')) define('DOKU_PLUGIN', DOKU_INC . 'lib/plugins/');
require_once (DOKU_PLUGIN . 'action.php');

class action_plugin_textrotate extends DokuWiki_Action_Plugin {
/**
* Register the eventhandlers
*/
function register(&$controller) {
$controller->register_hook('TOOLBAR_DEFINE', 'AFTER', $this, 'insert_button', array ());
}

/**
* Inserts the toolbar button
*/
function insert_button(&$event, $param) {
$event->data[] = array(
'type' => 'format',
'title' => 'Vertikaler Text generieren',
'icon' => '../../plugins/textrotate/textrotate.png',
'sample'=> 'Vertikaler Text',
'open' => '!!',
'close' =>'!!',
'insert'=>'',
);
}
}
Binary file added example/example.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 7 additions & 0 deletions plugin.info.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
base textrotate
author lisps
email
date 2013-10-25
name TextRotate Plugin
desc converts a string into an image and rotates it
url http://dokuwiki.org/plugin:textrotate
14 changes: 14 additions & 0 deletions script.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
/**
* DokuWiki Plugin textrotate (JavaScript Component)
*
* @license GPL 2 (http://www.gnu.org/licenses/gpl.html)
* @author lisps
*/
jQuery(document).ready(function(){
jQuery('.textrotate').parent('td,th').css('vertical-align','bottom');
jQuery('.textrotate').parent('td,th').css('padding','0px');
jQuery('.textrotate').each(function(e){
count = jQuery(jQuery(this).parent().children()).size();
jQuery(this).parent().css('width',count*18 +'px');
})
});
10 changes: 10 additions & 0 deletions style.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
/**
* DokuWiki Plugin textrotate (CSS Component)
*
* @license GPL 2 (http://www.gnu.org/licenses/gpl.html)
* @author lisps
*/
table.inline {
/*table-layout:fixed !important;*/

}
132 changes: 132 additions & 0 deletions syntax.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
<?php
/**
* DokuWiki Plugin textrotate (Syntax Component)
*
* @license GPL 2 (http://www.gnu.org/licenses/gpl.html)
* @author lisps
*/

if(!defined('DOKU_INC')) define('DOKU_INC',realpath(dirname(__FILE__).'/../../').'/');
if(!defined('DOKU_PLUGIN')) define('DOKU_PLUGIN',DOKU_INC.'lib/plugins/');
require_once(DOKU_PLUGIN.'syntax.php');
if (!defined('DOKU_LF')) define('DOKU_LF', "\n");
if (!defined('DOKU_TAB')) define('DOKU_TAB', "\t");
if (!defined('DOKU_PLUGIN')) define('DOKU_PLUGIN',DOKU_INC.'lib/plugins/');

/*
* All DokuWiki plugins to extend the parser/rendering mechanism
* need to inherit from this class
*/
class syntax_plugin_textrotate extends DokuWiki_Syntax_Plugin {
/*
* What kind of syntax are we?
*/
function getType() {return 'protected'; }

/*
* Where to sort in?
*/
function getSort(){return 155;}

/*
* Paragraph Type
*/
function getPType() {return 'normal';}

/*
* Connect pattern to lexer
*/
function connectTo($mode) {
//$this->Lexer->addSpecialPattern("<rotate[^>]*>",$mode,'plugin_rotate');
$this->Lexer->addEntryPattern(
'!!(?=.*!!)',
$mode,
'plugin_textrotate'
);
}

function postConnect() {
$this->Lexer->addExitPattern(
'!!',
'plugin_textrotate'
);
}

/*
* Handle the matches
*/
function handle($match, $state, $pos, &$handler){

switch ($state) {
case DOKU_LEXER_ENTER :
//$match=trim(substr($match,7,strlen($match)-7-1));
//$opts["text"]=$match;
return array($state, array(''));

case DOKU_LEXER_UNMATCHED :
return array($state, $match);
case DOKU_LEXER_EXIT :
return array($state, '');
}
return $array();
}


/*
* Create output
*/
function render($mode, &$renderer, $data)
{
global $INFO;

list($state,$opt) = $data;
if($state != DOKU_LEXER_UNMATCHED) return true;

if($mode == 'metadata') return false;
if($mode == 'xhtml') {
//disable caching
$basedir ='lib/images/tmp';
$opt_r = explode('\\',$opt);
//$renderer->doc .= '<span style="vertical-align:bottom;width:'.count($opt_r)*16 .'px;" >';
foreach($opt_r as $opt){
$text = trim(utf8_decode($opt));

$img_name = sha1($text);
$file = $basedir.'/'. $img_name .'.png';

if(!file_exists($file)||true) {
@mkdir($basedir,777,true);

$width = 15;
$height = strlen($text)*10;
$img = ImageCreate($width, $height);

$black = ImageColorAllocate($img, 0, 0, 0);
$white = ImageColorAllocate($img, 255, 255, 255);
$blau = ImageColorAllocate($img, 0, 64, 128);

ImageColorTransparent($img,$white);
ImageFill($img, 0, 0, $white);


$image_height = ImageSY($img);
imagestringup($img, 5, 0, $height-5, $text, $black);
ImagePNG($img,$file);

}
//".$renderer->_xmlEntities($opt)."

$renderer->doc .="<img class='textrotate' src='$file' alt='adsf' >";
}
//$renderer->doc .="</span>";
//$renderer->doc .="<div style='clear:both'></div>";

}
else {
$renderer->doc .=str_replace('//',' ',$text);
}
return true;
}
}

//Setup VIM: ex: et ts=4 enc=utf-8 :
Binary file added textrotate.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit e435eb8

Please sign in to comment.