register_hook('TOOLBAR_DEFINE', 'AFTER', $this, 'insert_button', array ()); $controller->register_hook('AJAX_CALL_UNKNOWN', 'BEFORE', $this, '_ajax_call'); } /** * Inserts the toolbar button */ function insert_button(Doku_Event $event, $param) { $event->data[] = array( 'type' => 'format', 'title' => 'Multiselect', 'icon' => '../../plugins/multiselect/images/toolicon.png', 'sample' => 'CHECK HELP', 'open' => ''>', 'insert'=>'', ); } function _ajax_call(Doku_Event $event, $param) { if ($event->data !== 'plugin_multiselect') { return; } //no other ajax call handlers needed $event->stopPropagation(); $event->preventDefault(); /* @var $INPUT \Input */ global $INPUT; #Variables $selectcount = $INPUT->int('index'); $smileycount = $INPUT->int('count'); $token = $INPUT->str('token'); $token= cleanText($token); /* @var $Hajax \helper_plugin_ajaxedit */ $Hajax = $this->loadHelper('ajaxedit'); $data=$Hajax->getWikiPage(); $range_delemiters = array(); //remove pagemod area - no changes here $ranges = preg_split('$$', $data); $count = preg_match_all('$$', $data, $range_delemiters); if($count) { $range_delemiters = $range_delemiters[0]; } else { $range_delemiters = array(); } //will be set in loop to detect if change has already happened $found_flag = false; //will count the &$range_part){ //find "our" multiselect $found=explode(""); if ($stop !== FALSE) { $oldsmileys=substr($found[$selectcount_range+1],0,$stop); //move selected smiley to front $ret = preg_match_all('/[\w\[\]\(\)\{\}\|\?\+\-\*\^\$\\\.:!\/;,+#~&%]+|"[\w\[\]\(\)\{\}\|\?\+\-\*\^\$\\\.:!\/;,+#~&%\s]+"/u',trim($oldsmileys),$matches); $newsmileys=str_replace('"','',$matches[0]); //$newsmileys=explode(" ",trim($oldsmileys)); if ($smileycount < count($newsmileys)) { $temp=$newsmileys[0]; $newsmileys[0]=$newsmileys[$smileycount]; $newsmileys[$smileycount]=$temp; } foreach($newsmileys as $key=>$sm){ if(strpos($sm,' ') !== false){ $newsmileys[$key] = '"'.$sm.'"'; } } $newsmileys=implode(' ',$newsmileys); //create new pagesource $found[$selectcount_range+1]=str_replace($oldsmileys," ".$newsmileys." ",$found[$selectcount_range+1]); $range_part=implode("getLang('changed_from_to'),'Multiselect',hsc($temp),hsc($token)); $Hajax->saveWikiPage($data,$summary,false,$param); } }