<?php
/**
 * @license    GPL 2 (http://www.gnu.org/licenses/gpl.html)
 * @author Dan Kreiser <dan.kreiser@gmail.com>
 */

// must be run within Dokuwiki
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_googlechart extends DokuWiki_Action_Plugin {

    /**
     * return some info
     *
     * @author Dan Kreiser <dan.kreiser@gmail.com>
     */
    function getInfo(){
        return array_merge(confToHash(dirname(__FILE__).'/README'), array('name' => 'Toolbar Component'));
    }

    /**
     * register the eventhandlers
     *
     */
    function register(&$controller){
        $controller->register_hook('TOOLBAR_DEFINE', 'AFTER', $this, 'handle_toolbar', array ());
   
    }

 
	
	function handle_toolbar(&$event, $param) {
        $event->data[] =array (
            'type' => 'picker',
            'title' => $this->getLang('google chart api'),
            'icon' => '../../plugins/googlechart/images/toolbar/buttons/googlechart.png',
            'list' => array(
                array(
                    'type'   => 'insert',
                    'title'  => 'Pie 3D',
                    'icon'   => '../../plugins/googlechart/images/toolbar/googlechart/pie3d.png',
                    'insert'   => '<googlechart>\ncht=p3\nchs=280x100\nchd=t:10,20,30,40\nchds=0,100\nchl=May|June|July\n</googlechart>\n'
                ),
                 array(
                    'type'   => 'insert',
                    'title'  => 'Pie 2D',
                    'icon'   => '../../plugins/googlechart/images/toolbar/googlechart/pie2d.png',
                    'insert'   => '<googlechart>\ncht=p\nchs=280x100\nchd=t:10,20,30,40\nchds=0,100\nchl=May|June|July\n</googlechart>\n'
                ),
                array(
                    'type'   => 'insert',
                    'title'  => 'Vertical Bars',
                    'icon'   => '../../plugins/googlechart/images/toolbar/googlechart/vbar.png',
                    'insert'   => '<googlechart>\nchxt=x,x,y,y\ncht=bvs\nchd=s:c9ucD\nchls=2.0\nchs=250x125\nchxl=1:%7CMartinis%7C3:%7CScore\nchxp=1,50%7C3,50\n</googlechart>\n'
												
                ),
				  array(
                    'type'   => 'insert',
                    'title'  => 'Horizontal Bars',
                    'icon'   => '../../plugins/googlechart/images/toolbar/googlechart/hbar.png',
                    'insert'   =>'<googlechart>\nchxt=x,y,r,t\ncht=bhs\nchd=s:EUjVu\nchco=76A4FB\nchls=2.0\nchs=200x190\n</googlechart>\n'
                ),
				array(
                    'type'   => 'insert',
                    'title'  => 'Line Chart',
                    'icon'   => '../../plugins/googlechart/images/toolbar/googlechart/line-chart.png',
                    'insert'   => '<googlechart>\nchxt=x,x,y,y\ncht=lc\nchd=s:cEAELFJHHHKUju9uuXUc\nchco=76A4FB\nchls=2.0\nchs=200x125\nchxl=1:|Freezing|Hot|3:|Low|High\nchma=40,20,20,30\n</googlechart>\n'
                ),
				array(
                    'type'   => 'insert',
                    'title'  => 'Gauge',
                    'icon'   => '../../plugins/googlechart/images/toolbar/googlechart/gauge.png',
                    'insert'   => '<googlechart>\nchs=200x125\ncht=gom\nchd=t:70\nchco=FF0000,FF8040,FFFF00,00FF00,00FFFF,0000FF,800080\nchxt=x,y\nchxl=0:|Groovy|1:|slow|faster|crazy\n</googlechart>\n'
                ),
				array(
                    'type'   => 'insert',
                    'title'  => 'LATEX',
                    'icon'   => '../../plugins/googlechart/images/toolbar/googlechart/tex.png',
                    'insert'   => '<googlechart>\ncht=tx\nchl=NH_K(M)=\left[\sum_{i=1}^{n/2}\left(\left( m_{2i-1}+k_{2i-1}\right) mod 2^w\right)\cdot\left(\left(m_{2i}+k_{2i}\right) mod 2^{w}\right)\right]mod 2^{2w}\n</googlechart>\n'
                ),
				array(
                    'type'   => 'insert',
                    'title'  => 'Notice',
                    'icon'   => '../../plugins/googlechart/images/toolbar/googlechart/notice.png',
                    'insert'   => '<googlechart>\nchst=d_fnote_title\nchld=pinned_c|1|004400|l|Joe|Today+2-for-1+!|555-1234\n</googlechart>\n'
                ),
				array(
                    'type'   => 'insert',
                    'title'  => 'Venn chart',
                    'icon'   => '../../plugins/googlechart/images/toolbar/googlechart/venn.png',
                    'insert'   => '<googlechart>\ncht=v\nchs=200x100\nchd=t:100,80,60,30,30,30,10\nchco=FF6342,ADDE63,63C6DE\nchdl=A|B|C\n</googlechart>\n'
                ),
				array(
                    'type'   => 'insert',
                    'title'  => 'Graph',
                    'icon'   => '../../plugins/googlechart/images/toolbar/googlechart/graph.png',
                    'insert'   => '<googlechart>\ncht=gv:neato\nchl=digraph{A->B->C->A}\nchs=150x150\n</googlechart>\n'
                ),
				array(
                    'type'   => 'insert',
                    'title'  => 'QR',
                    'icon'   => '../../plugins/googlechart/images/toolbar/googlechart/qr.png',
                    'insert'   => '<googlechart>\ncht=qr\nchs=200x200\nchl=Dokuwiki+is+the+best+wiki\nchoe=UTF-8\n</googlechart>\n'
                ),
				array(
                    'type'   => 'insert',
                    'title'  => 'MAP',
                    'icon'   => '../../plugins/googlechart/images/toolbar/googlechart/map.png',
                    'insert'   => '<googlechart>\ncht=map:fixed=-60,0,80,-35\nchs=600x350\nchld=CA-BC|CN|IT|GR|US-UT\nchdl=Vancouver|Beijing|Torino|Athens|Salt+Lake+City\nchco=B3BCC0|5781AE|FF0000|FFC726|885E80|518274\nchtt=Last+Five+Olympic+Hosts\nchm=f2010+Winter,000000,0,0,10\nf2008+Summer,000000,0,1,10\nf2008+Winter,000000,0,2,10,1,:-5:10\nf2004+Summer,000000,0,3,10\nf2004+Summer,000000,0,4,10\nchma=0,110,0,0\n</googlechart>\n'
                )					
				
				)
				);
    }
}

