Project

General

Profile

1
<?php
2

    
3
/**
4
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
5
 *
6
 * This program is free software: you can redistribute it and/or modify
7
 * it under the terms of the GNU General Public License as published by
8
 * the Free Software Foundation, either version 3 of the License, or
9
 * (at your option) any later version.
10
 *
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
18
 */
19

    
20
/**
21
 * WbLink.php
22
 *
23
 * @category     Addons
24
 * @package      Addons_News
25
 * @copyright    Manuela v.d.Decken <manuela@isteam.de>
26
 * @author       Manuela v.d.Decken <manuela@isteam.de>
27
 * @license      http://www.gnu.org/licenses/gpl.html   GPL License
28
 * @version      0.0.1
29
 * @revision     $Revision: $
30
 * @link         $HeadURL: $
31
 * @lastmodified $Date: $
32
 * @since        File available since 04.11.2013
33
 * @description  This class implements an interface for the wblink-outputfilter
34
 *
35
 * @inherited WbDatabase $oDb
36
 * @inherited WbAdaptor  $oReg
37
 *
38
 */
39

    
40
class m_news_WbLink extends WbLinkAbstract
41
{
42
/**
43
 * makeLinkFromTag
44
 * @param type $aReplacement
45
 * @return string
46
 * @description
47
 */
48
	public function makeLinkFromTag(array $aReplacement)
49
	{
50
	// set link on failure ('#' means, still stay on current page)
51
		$sRetval = '#';
52
	// search `link` from posts table and create absolute URL
53
		$sql = 'SELECT `link` '
54
			 . 'FROM `'.$this->oDb->TablePrefix.'mod_news_posts` '
55
			 . 'WHERE `post_id`='.$aReplacement['Args']['item'];
56
		if(($sLink = $this->oDb->get_one($sql)))
57
		{
58
			$sLink = trim(str_replace('\\', '/', $sLink), '/');
59
		// test if valid accessfile is available
60
			if(is_readable($this->oReg->AppPath.$this->oReg->PagesDir.$sLink.$this->oReg->PageExtension))
61
			{
62
				$sRetval = $this->oReg->AppUrl.$this->oReg->PagesDir.$sLink.$this->oReg->PageExtension;
63
			}
64
		}
65
		return $sRetval;
66
	}
67

    
68
//	public function generateLinkList(Template $oTpl)
69
//	{
70
//		;
71
//	}
72
} // end of class m_news_WbLink
(2-2/34)