Project

General

Profile

« Previous | Next » 

Revision 2026

Added by darkviper almost 11 years ago

! [wblink] outputfilter now can handle ancors too
! WbLink Interface is much more easier to use now.

View differences:

WbLink.php
30 30
 * @link         $HeadURL: $
31 31
 * @lastmodified $Date: $
32 32
 * @since        File available since 04.11.2013
33
 * @description  This class implements an interface for the wblink-outputfilter
33
 * @description  This class implements an interface for i.e. the wblink-outputfilter
34 34
 *
35 35
 * @inherited WbDatabase $oDb
36 36
 * @inherited WbAdaptor  $oReg
......
39 39

  
40 40
class m_news_WbLink extends WbLinkAbstract
41 41
{
42
/* *** BEGIN define the environment of your addon! ************************************ */
43
/* (this section is a MUST and it MUST have all 8 consts defined!!)                     */
42 44
/**
45
 * name of the needed table
46
 * @description do NOT use the TablePrefix in this name!
47
 */
48
	const TABLE_NAME           = 'mod_news_posts';
49

  
50
/**
51
 * name of the field with the PageId
52
 */
53
	const FIELDNAME_PAGE_ID    = 'page_id';
54

  
55
/**
56
 * name of the field with the SectionId
57
 */
58
	const FIELDNAME_SECTION_ID = 'section_id';
59

  
60
/**
61
 * name of the field with the ItemId
62
 */
63
	const FIELDNAME_ITEM_ID    = 'post_id';
64

  
65
/**
66
 * name of the field with the needed link
67
 */
68
	const FIELDNAME_LINK       = 'link';
69

  
70
/**
71
 * name of the field with the needed title
72
 */
73
	const FIELDNAME_TITLE      = 'title';
74

  
75
/**
76
 * name of the field with the timestamp
77
 * @description define an empty string if no 'timestamp'-field is available or it's not needed!
78
 */
79
	const FIELDNAME_TIMESTAMP  = 'created_when';
80

  
81
/** name of the field with the active-flag
82
 * @description define an empty string if no 'active'-field is available or it's not needed!
83
 */
84
	const FIELDNAME_ACTIVE     = 'active';
85
/* *** END define the environment of your addon! ************************************** */
86

  
87
/**
43 88
 * makeLinkFromTag
44 89
 * @param type $aReplacement
45 90
 * @return string
46
 * @description
91
 * @description this method is used by the output filter
47 92
 */
48 93
	public function makeLinkFromTag(array $aReplacement)
49 94
	{
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['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;
95
/* *** Define here the full path where your links are based on! *********************** */
96

  
97
		$sBaseDir = $this->oReg->AppPath.$this->oReg->PagesDir;
98

  
99
/* *** Do NOT change the following request! ******************************************* */
100
		$sBaseDir = rtrim(str_replace('\\', '/', $sBaseDir), '/').'/';
101
		return $this->_makeLinkFromTag($sBaseDir, $aReplacement);
66 102
	}
67 103
/**
68 104
 * generateOptionsList
69
 * @param  string $sObjectName name of the array to create (default: 'AddonItemsSelectBox')
70
 * @return &array complete definition of a SelectBox
71
 * @description Bild a mulitdimensional Array with complete Option definitions for use in a Select Box
105
 * @return &array definition of a SelectBox
106
 * @description build a mulitdimensional Array with complete Option definitions for use in a Select Box
72 107
 */
73 108
	public function &generateOptionsList()
74 109
	{
75
		$aAddonItems =& $this->_executeListGeneration(
76
	                                           'news',
77
	                                           'mod_news_posts',
78
	                                           'page_id',
79
	                                           'section_id',
80
	                                           'post_id',
81
	                                           'created_when',
82
	                                           'title',
83
	                                           'active'
84
	                                          );
110
		$aAddonItems =& $this->_executeListGeneration();
85 111
		return $aAddonItems;
86 112
	}
87 113
} // end of class m_news_WbLink

Also available in: Unified diff