| 1 | <?php |
|---|
| 2 | // WCF includes |
|---|
| 3 | require_once(WCF_DIR.'lib/system/event/EventListener.class.php'); |
|---|
| 4 | |
|---|
| 5 | /** |
|---|
| 6 | * Adds the bubble javascript from thumbshots |
|---|
| 7 | * |
|---|
| 8 | * @author Torben Brodt |
|---|
| 9 | * @package de.easy-coding.wcf.thumbshots |
|---|
| 10 | * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-3.0.html> |
|---|
| 11 | */ |
|---|
| 12 | class AbstractPageThumbshotsListener implements EventListener { |
|---|
| 13 | private static $called = false; |
|---|
| 14 | |
|---|
| 15 | /** |
|---|
| 16 | * @see EventListener::execute() |
|---|
| 17 | */ |
|---|
| 18 | public function execute($eventObj, $className, $eventName) { |
|---|
| 19 | if(!self::$called) { |
|---|
| 20 | self::$called = true; |
|---|
| 21 | |
|---|
| 22 | // place author backlink |
|---|
| 23 | if($this->isBranding($eventObj, $className)) { |
|---|
| 24 | WCF::getTPL()->append('additionalFooterOptions', |
|---|
| 25 | '<li><a class="externalURL" href="http://www.m-software.de/thumbshots"><span>Thumbshots</span></a></li>'); |
|---|
| 26 | } |
|---|
| 27 | |
|---|
| 28 | // place javascript widget |
|---|
| 29 | WCF::getTPL()->append('additionalFooterContents', '<script type="text/javascript" src="'.RELATIVE_WCF_DIR.'js/Bubble.js"></script><script type="text/javascript"> |
|---|
| 30 | Bubble.disallow("href", /'.THUMBSHOTS_DISALLOW.'/); |
|---|
| 31 | Bubble.init("externalURL", function (D) { |
|---|
| 32 | return \'<img alt="" style="width:150px;height:100px" src="http://www.m-software.de/screenshot/Screenshot.png?url=\'+ escape(D.href) +\'&commingsoonimg=http://fadeout.de/images/thumbshot.png" />\'; |
|---|
| 33 | }); |
|---|
| 34 | </script>'); |
|---|
| 35 | } |
|---|
| 36 | } |
|---|
| 37 | |
|---|
| 38 | /** |
|---|
| 39 | * @return boolean |
|---|
| 40 | */ |
|---|
| 41 | protected function isBranding($eventObj, $className) { |
|---|
| 42 | $doBranding = false; |
|---|
| 43 | if($className == 'ThreadPage') { |
|---|
| 44 | if($eventObj->thread->isSticky || $eventObj->thread->isAnnouncement) { |
|---|
| 45 | return true; |
|---|
| 46 | } |
|---|
| 47 | } |
|---|
| 48 | if(THUMBSHOTS_BACKLINK && isset($_SERVER['REQUEST_URI']) && @preg_match('/'.THUMBSHOTS_BACKLINK.'/', $_SERVER['REQUEST_URI'])) { |
|---|
| 49 | return true; |
|---|
| 50 | } |
|---|
| 51 | return false; |
|---|
| 52 | } |
|---|
| 53 | } |
|---|
| 54 | ?> |
|---|