| 1 | <?php |
|---|
| 2 | // wcf imports |
|---|
| 3 | require_once(WCF_DIR.'lib/system/event/EventListener.class.php'); |
|---|
| 4 | |
|---|
| 5 | /** |
|---|
| 6 | * Displays the tab for tagging |
|---|
| 7 | * |
|---|
| 8 | * @author Torben Brodt |
|---|
| 9 | * @package de.easy-coding.wcf.taggingreloaded |
|---|
| 10 | * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-3.0.html> |
|---|
| 11 | */ |
|---|
| 12 | class TaggingReloadedMessageFormListener implements EventListener { |
|---|
| 13 | protected $eventObj; |
|---|
| 14 | protected $className; |
|---|
| 15 | protected $tags = array(); |
|---|
| 16 | |
|---|
| 17 | protected $systemTaggerUserID = 0; // unsigned int |
|---|
| 18 | |
|---|
| 19 | /** |
|---|
| 20 | * @see EventListener::execute() |
|---|
| 21 | */ |
|---|
| 22 | public function execute($eventObj, $className, $eventName) { |
|---|
| 23 | $this->eventObj = $eventObj; |
|---|
| 24 | $this->className = $className; |
|---|
| 25 | |
|---|
| 26 | // abort if the user does not have permissions to use tagging |
|---|
| 27 | if(!WCF::getUser()->getPermission('user.message.tagging')) { |
|---|
| 28 | return; |
|---|
| 29 | } |
|---|
| 30 | |
|---|
| 31 | switch ($eventName) { |
|---|
| 32 | case 'readData': |
|---|
| 33 | $this->readData(); |
|---|
| 34 | break; |
|---|
| 35 | case 'readFormParameters': |
|---|
| 36 | $this->readFormParameters(); |
|---|
| 37 | break; |
|---|
| 38 | case 'assignVariables': |
|---|
| 39 | $this->assignVariables(); |
|---|
| 40 | break; |
|---|
| 41 | case 'saved': |
|---|
| 42 | $this->saved(); |
|---|
| 43 | break; |
|---|
| 44 | } |
|---|
| 45 | } |
|---|
| 46 | |
|---|
| 47 | /** |
|---|
| 48 | * |
|---|
| 49 | */ |
|---|
| 50 | protected function styleClassic() { |
|---|
| 51 | WCF::getTPL()->assign('tags', implode(' ', array_keys($this->tags))); |
|---|
| 52 | WCF::getTPL()->append('additionalInformationFields', WCF::getTPL()->fetch('messageFormTaggingClassic')); |
|---|
| 53 | } |
|---|
| 54 | |
|---|
| 55 | /** |
|---|
| 56 | * |
|---|
| 57 | */ |
|---|
| 58 | protected function styleReloaded() { |
|---|
| 59 | // button |
|---|
| 60 | $tab = '<li id="taggingTab"><a onclick="tabbedPane.openTab(\'tagging\');">'.WCF::getLanguage()->get('wcf.taggingreloaded.tagging').'</a></li>'; |
|---|
| 61 | |
|---|
| 62 | WCF::getTPL()->append('specialStyles', '<script type="text/javascript" src="'.RELATIVE_WCF_DIR.'js/TaggingReloaded.class.js"></script>'); |
|---|
| 63 | WCF::getTPL()->append('additionalTabs', $tab); |
|---|
| 64 | WCF::getTPL()->append('additionalSubTabs', WCF::getTPL()->fetch('messageFormTaggingReloaded')); |
|---|
| 65 | |
|---|
| 66 | // add tags |
|---|
| 67 | $tags = '<script type="text/javascript">//<![CDATA['."\n"; |
|---|
| 68 | foreach($this->tags as $tag => $weight) { |
|---|
| 69 | $tags .= "tagging.add('{$tag}',{$weight});"; |
|---|
| 70 | } |
|---|
| 71 | $tags .= "\n//]]></script>"; |
|---|
| 72 | WCF::getTPL()->append('additionalSubTabs', $tags); |
|---|
| 73 | } |
|---|
| 74 | |
|---|
| 75 | /** |
|---|
| 76 | * @see Form::assignVariables() |
|---|
| 77 | */ |
|---|
| 78 | protected function assignVariables () { |
|---|
| 79 | switch(WCF::getUser()->getUserOption('tagging_style')) { |
|---|
| 80 | case 1: |
|---|
| 81 | $this->styleReloaded(); |
|---|
| 82 | break; |
|---|
| 83 | case 2: |
|---|
| 84 | $this->styleClassic(); |
|---|
| 85 | break; |
|---|
| 86 | } |
|---|
| 87 | } |
|---|
| 88 | } |
|---|
| 89 | ?> |
|---|