Revision 2026
Added by darkviper about 12 years ago
| branches/2.8.x/CHANGELOG | ||
|---|---|---|
| 11 | 11 |
! = Update/Change |
| 12 | 12 |
=============================================================================== |
| 13 | 13 |
|
| 14 |
08 Dec-2013 Build 2026 Manuela v.d.Decken(DarkViper) |
|
| 15 |
! [wblink] outputfilter now can handle ancors too |
|
| 16 |
! WbLink Interface is much more easier to use now. |
|
| 14 | 17 |
07 Dec-2013 Build 2025 Manuela v.d.Decken(DarkViper) |
| 15 | 18 |
# mod-MultiLingual forgotten fix in Lib.php :( |
| 16 | 19 |
07 Dec-2013 Build 2024 Manuela v.d.Decken(DarkViper) |
| branches/2.8.x/wb/admin/interface/version.php | ||
|---|---|---|
| 51 | 51 |
|
| 52 | 52 |
// check if defined to avoid errors during installation (redirect to admin panel fails if PHP error/warnings are enabled) |
| 53 | 53 |
if(!defined('VERSION')) define('VERSION', '2.8.3');
|
| 54 |
if(!defined('REVISION')) define('REVISION', '2025');
|
|
| 54 |
if(!defined('REVISION')) define('REVISION', '2026');
|
|
| 55 | 55 |
if(!defined('SP')) define('SP', '');
|
| branches/2.8.x/wb/framework/WbLinkAbstract.php | ||
|---|---|---|
| 35 | 35 |
*/ |
| 36 | 36 |
abstract class WbLinkAbstract {
|
| 37 | 37 |
|
| 38 |
protected $oDb = null; |
|
| 39 |
protected $oReg = null; |
|
| 40 |
|
|
| 38 |
/** |
|
| 39 |
* @var object $oDb the active instance of WbDatabase |
|
| 40 |
*/ |
|
| 41 |
protected $oDb = null; |
|
| 42 |
/** |
|
| 43 |
* @var object $oReg the active instance of WbAdaptor |
|
| 44 |
*/ |
|
| 45 |
protected $oReg = null; |
|
| 46 |
/** |
|
| 47 |
* @var string $sAddon the name of the addon, which extends this class |
|
| 48 |
*/ |
|
| 49 |
protected $sAddon = ''; |
|
| 50 |
/** |
|
| 51 |
* protected constructor |
|
| 52 |
*/ |
|
| 41 | 53 |
final public function __construct() |
| 42 | 54 |
{
|
| 43 |
$this->oDb = WbDatabase::getInstance(); |
|
| 44 |
$this->oReg = WbAdaptor::getInstance(); |
|
| 55 |
$this->oDb = WbDatabase::getInstance(); |
|
| 56 |
$this->oReg = WbAdaptor::getInstance(); |
|
| 57 |
$this->sAddon = preg_replace('/^.*?_([^_]+)_[^_]*?$/', '\1', get_class($this));
|
|
| 45 | 58 |
} |
| 46 | 59 |
|
| 60 |
|
|
| 47 | 61 |
abstract public function makeLinkFromTag(array $aReplacement); |
| 48 | 62 |
abstract public function &generateOptionsList(); |
| 49 | 63 |
|
| 50 | 64 |
/** |
| 51 |
* |
|
| 52 |
* @param string $sAddonName |
|
| 53 |
* @param string $sAddonTableName |
|
| 54 |
* @param string $sPageIdName |
|
| 55 |
* @param string $sSectionIdName |
|
| 56 |
* @param string $sItemIdName |
|
| 57 |
* @param string $sDateTimeName |
|
| 58 |
* @param string $sTitleName |
|
| 59 |
* @param string $sActivatedName |
|
| 65 |
* executeListGeneration |
|
| 60 | 66 |
* @return array by reference |
| 61 | 67 |
*/ |
| 62 |
final protected function &_executeListGeneration( |
|
| 63 |
$sAddonName = 'news', |
|
| 64 |
$sAddonTableName = 'mod_news_posts', |
|
| 65 |
$sPageIdName = 'page_id', |
|
| 66 |
$sSectionIdName = 'section_id', |
|
| 67 |
$sItemIdName = 'post_id', |
|
| 68 |
$sDateTimeName = 'created_when', |
|
| 69 |
$sTitleName = 'title', |
|
| 70 |
$sActivatedName = 'active' |
|
| 71 |
) |
|
| 68 |
final protected function &_executeListGeneration() |
|
| 72 | 69 |
{
|
| 73 | 70 |
$aAddonItems = array(); |
| 74 | 71 |
//generate news lists |
| 75 |
$sql = 'SELECT `p`.`'.$sItemIdName.'` `ItemId`, `p`.`'.$sPageIdName.'` `PageId`, '
|
|
| 76 |
. '`s`.`section_id` `SectionId`, `p`.`'.$sTitleName.'` `Title` '
|
|
| 72 |
$sql = 'SELECT `p`.`'.$this::FIELDNAME_ITEM_ID.'` `ItemId`, `p`.`'.$this::FIELDNAME_PAGE_ID.'` `PageId`, '
|
|
| 73 |
. '`s`.`section_id` `SectionId`, `p`.`'.$this::FIELDNAME_TITLE.'` `Title` '
|
|
| 77 | 74 |
. 'FROM `'.$this->oDb->TablePrefix.'sections` `s` ' |
| 78 |
. 'LEFT JOIN `'.$this->oDb->TablePrefix.$sAddonTableName.'` `p` ON `s`.`section_id`= `p`.`'.$sSectionIdName.'` ' |
|
| 79 |
. 'WHERE `p`.`'.$sActivatedName.'`>0 AND `s`.`module`=\''.$sAddonName.'\' ' |
|
| 80 |
. 'ORDER BY `s`.`page_id`, `s`.`section_id`, `p`.`'.$sDateTimeName.'` DESC'; |
|
| 75 |
. 'LEFT JOIN `'.$this->oDb->TablePrefix.$this::TABLE_NAME.'` `p` ON `s`.`section_id`= `p`.`'.$this::FIELDNAME_SECTION_ID.'` ' |
|
| 76 |
. 'WHERE `s`.`module`=\''.$this->sAddon.'\' ' |
|
| 77 |
. ($this->FIELDNAME_ACTIVE != '' ? 'AND `p`.`'.$this::FIELDNAME_ACTIVE.'`>0 ' : '') |
|
| 78 |
. 'ORDER BY `s`.`page_id`, `s`.`section_id`'.($this::FIELDNAME_TIMESTAMP != '' ? ', `p`.`'.$this::FIELDNAME_TIMESTAMP.'` DESC' : ''); |
|
| 81 | 79 |
if (( $oRes = $this->oDb->doQuery($sql))) {
|
| 80 |
// preset group changer flags |
|
| 82 | 81 |
$iCurrentPage = 0; |
| 83 | 82 |
$iCurrentSection = 0; |
| 84 | 83 |
$iSectionCounter = 0; |
| 85 | 84 |
while ($aItem = $oRes->fetchRow(MYSQL_ASSOC)) {
|
| 85 |
// iterate all matches |
|
| 86 | 86 |
if ($iCurrentPage != $aItem['PageId']) {
|
| 87 |
// change group by PageId |
|
| 87 | 88 |
$iCurrentPage = $aItem['PageId']; |
| 88 | 89 |
$aAddonItems[$iCurrentPage.'P'] = array(); |
| 89 | 90 |
} |
| 90 | 91 |
if ($iCurrentSection != $aItem['SectionId']) {
|
| 92 |
// change group by SectionId |
|
| 91 | 93 |
$iCurrentSection = $aItem['SectionId']; |
| 92 | 94 |
$aAddonItems[$iCurrentPage.'P'][] = array(); |
| 93 | 95 |
$iSectionCounter = sizeof($aAddonItems[$iCurrentPage.'P'])-1; |
| 94 | 96 |
} |
| 97 |
// save current record |
|
| 95 | 98 |
$aAddonItems[$iCurrentPage.'P'][$iSectionCounter][] = array( |
| 96 |
'wblink' => '[wblink'.$aItem['PageId'].'?addon='.$sAddonName.'&item='.$aItem['ItemId'].']',
|
|
| 99 |
'wblink' => '[wblink'.$aItem['PageId'].'?addon='.$sAddon.'&item='.$aItem['ItemId'].']', |
|
| 97 | 100 |
'title' => preg_replace("/\r?\n/", "\\n", $this->oDb->escapeString($aItem['Title']))
|
| 98 | 101 |
); |
| 99 | 102 |
} |
| 100 | 103 |
} |
| 101 | 104 |
return $aAddonItems; |
| 102 | 105 |
} |
| 103 |
|
|
| 104 |
|
|
| 106 |
/** |
|
| 107 |
* makeLinkFromTag |
|
| 108 |
* @param string $sBasePath |
|
| 109 |
* @param array $aReplacement |
|
| 110 |
* @return string a valid URL or '#' on error |
|
| 111 |
*/ |
|
| 112 |
protected function _makeLinkFromTag($sBasePath, array $aReplacement) |
|
| 113 |
{
|
|
| 114 |
// set link on failure ('#' means, still stay on current page)
|
|
| 115 |
$sRetval = '#'; |
|
| 116 |
// search `link` from posts table and create absolute URL |
|
| 117 |
$sql = 'SELECT `'.$this::FIELDNAME_LINK.'` ' |
|
| 118 |
. 'FROM `'.$this->oDb->TablePrefix.$this::TABLE_NAME.'` ' |
|
| 119 |
. 'WHERE `'.$this::FIELDNAME_ITEM_ID.'`='.$aReplacement['item']; |
|
| 120 |
if (($sLink = $this->oDb->get_one($sql))) {
|
|
| 121 |
$sLink = trim(str_replace('\\', '/', $sLink), '/');
|
|
| 122 |
$sBasePath = trim(str_replace('\\', '/', $sBasePath), '/').'/';
|
|
| 123 |
// test if valid accessfile is available |
|
| 124 |
$sFilePath = $sBasePath.$sLink.$this->oReg->PageExtension; |
|
| 125 |
if (is_readable($sFilePath)) {
|
|
| 126 |
$sRelPath = preg_replace('/^'.preg_quote($this->oReg->AppPath, '/').'/', '', $sFilePath);
|
|
| 127 |
$sRetval = $this->oReg->AppUrl.$sRelPath.$aReplacement['ancor']; |
|
| 128 |
} |
|
| 129 |
} |
|
| 130 |
return $sRetval; |
|
| 131 |
} |
|
| 105 | 132 |
} // end of class WbLinkAbstract |
| branches/2.8.x/wb/modules/output_filter/filters/filterWbLink.php | ||
|---|---|---|
| 1 | 1 |
<?php |
| 2 |
|
|
| 3 |
|
|
| 4 |
/** |
|
| 5 |
* ParseWbLink |
|
| 6 |
* @param string $sContent |
|
| 7 |
* @return array details of all found Wblink-Tags |
|
| 8 |
* @description parse |
|
| 9 |
*/ |
|
| 10 |
function _parseWbLink(&$sContent) |
|
| 11 |
{
|
|
| 12 |
$aResults = array(); |
|
| 13 |
$aMatches = array(); |
|
| 14 |
$sPattern = '/\[wblink([0-9]+)(\#([^\?]+))?(\?([^\]]+))?\]/is'; |
|
| 15 |
if (preg_match_all($sPattern, $sContent, $aMatches, PREG_SET_ORDER)) {
|
|
| 16 |
foreach ($aMatches as $aTag) {
|
|
| 17 |
$aResults[$aTag[0]] = array(); |
|
| 18 |
$aResults[$aTag[0]]['pageid'] = $aTag[1]; |
|
| 19 |
$aResults[$aTag[0]]['ancor'] = (isset($aTag[3]) ? $aTag[3] : ''); |
|
| 20 |
$aResults[$aTag[0]]['params'] = array(); |
|
| 21 |
$aTag[5] = (isset($aTag[5]) ? $aTag[5] : ''); |
|
| 22 |
$aTmpArgs = preg_split('/&|&/i', $aTag[5], -1, PREG_SPLIT_NO_EMPTY);
|
|
| 23 |
foreach ($aTmpArgs as $sArgument) {
|
|
| 24 |
$aArgs = explode('=', $sArgument);
|
|
| 25 |
$aResults[$aTag[0]]['params'][$aArgs[0]] = $aArgs[1]; |
|
| 26 |
} |
|
| 27 |
} |
|
| 28 |
} |
|
| 29 |
return $aResults; |
|
| 30 |
} |
|
| 2 | 31 |
/* |
| 3 | 32 |
* @param string $content : contains the full content of the current page |
| 4 | 33 |
* @return string |
| ... | ... | |
| 10 | 39 |
$oDb = WbDatabase::getInstance(); |
| 11 | 40 |
$oReg = WbAdaptor::getInstance(); |
| 12 | 41 |
$aReplaceList = array(); |
| 13 |
$sPattern = '/\[wblink([0-9]+)\??([^\]]*)\]/is';
|
|
| 14 |
if(preg_match_all($sPattern,$sContent,$aMatches))
|
|
| 15 |
{
|
|
| 16 |
// iterate through all found matches
|
|
| 17 |
foreach($aMatches[0] as $iKey => $sKeyString )
|
|
| 18 |
{
|
|
| 19 |
$aReplaceList[$sKeyString] = array();
|
|
| 20 |
// use original Tag to save PageId
|
|
| 21 |
$aReplaceList[$sKeyString]['PageId'] = $aMatches[1][$iKey];
|
|
| 22 |
// if there are additional arguments given
|
|
| 23 |
if($aMatches[2][$iKey])
|
|
| 42 |
$aTagList = _parseWblink($sContent);
|
|
| 43 |
// iterate list if replacements are available
|
|
| 44 |
foreach ($aTagList as $sKey=>$aTag) {
|
|
| 45 |
// set link on failure ('#' means, still stay on current page)
|
|
| 46 |
$aReplaceList[$sKey] = '#';
|
|
| 47 |
// sanitize possible ancor
|
|
| 48 |
$aTag['ancor'] = ($aTag['ancor'] == '' ? '' : '#'.$aTag['ancor']);
|
|
| 49 |
// handle normal pages links
|
|
| 50 |
if (sizeof($aTag['params']) == 0) {
|
|
| 51 |
$sql = 'SELECT `link` FROM `'.$oDb->TablePrefix.'pages` WHERE `page_id` = '.(int)$aTag['pageid'];
|
|
| 52 |
if(($sLink = $oDb->get_one($sql)))
|
|
| 24 | 53 |
{
|
| 25 |
$aReplaceList[$sKeyString]['Args'] = array();
|
|
| 26 |
$aArgs = preg_split('/&|&/i', $aMatches[2][$iKey], -1, PREG_SPLIT_NO_EMPTY);
|
|
| 27 |
foreach($aArgs as $sArgument)
|
|
| 54 |
$sLink = trim(str_replace('\\', '/', $sLink), '/');
|
|
| 55 |
// test if valid accessfile is available
|
|
| 56 |
if(is_readable($oReg->AppPath.$oReg->PagesDir.$sLink.$oReg->PageExtension))
|
|
| 28 | 57 |
{
|
| 29 |
$aTmp = explode('=', $sArgument);
|
|
| 30 |
$aReplaceList[$sKeyString]['Args'][$aTmp[0]] = $aTmp[1];
|
|
| 58 |
// create absolute URL
|
|
| 59 |
$aReplaceList[$sKey] = $oReg->AppUrl.$oReg->PagesDir.$sLink.$oReg->PageExtension.$aTag['ancor'];
|
|
| 31 | 60 |
} |
| 32 | 61 |
} |
| 33 |
} |
|
| 34 |
if(sizeof($aReplaceList) > 0) |
|
| 35 |
{ // iterate list if replacements are available
|
|
| 36 |
foreach($aReplaceList as $sKey => $aReplacement) |
|
| 62 |
// handle links of modules |
|
| 63 |
} else {
|
|
| 64 |
// build name of the needed class |
|
| 65 |
$sClass = 'm_'.$aTag['params']['addon'].'_WbLink'; |
|
| 66 |
// remove addon name from replacement array |
|
| 67 |
// unset($aReplacement['Args']['addon']); |
|
| 68 |
if(class_exists($sClass)) |
|
| 37 | 69 |
{
|
| 38 |
// set link on failure ('#' means, still stay on current page)
|
|
| 39 |
$aReplaceList[$sKey] = '#';
|
|
| 40 |
// handle normal pages links
|
|
| 41 |
if(!isset($aReplacement['Args']))
|
|
| 70 |
// instantiate class
|
|
| 71 |
$oWbLink = new $sClass();
|
|
| 72 |
// the class must implement the interface
|
|
| 73 |
if($oWbLink instanceof WbLinkAbstract)
|
|
| 42 | 74 |
{
|
| 43 |
// read corresponding link from table 'pages' |
|
| 44 |
$sql = 'SELECT `link` FROM `'.$oDb->TablePrefix.'pages` WHERE `page_id` = '.(int)$aReplacement['PageId']; |
|
| 45 |
if(($sLink = $oDb->get_one($sql))) |
|
| 46 |
{
|
|
| 47 |
$sLink = trim(str_replace('\\', '/', $sLink), '/');
|
|
| 48 |
// test if valid accessfile is available |
|
| 49 |
if(is_readable($oReg->AppPath.$oReg->PagesDir.$sLink.$oReg->PageExtension)) |
|
| 50 |
{
|
|
| 51 |
// create absolute URL |
|
| 52 |
$aReplaceList[$sKey] = $oReg->AppUrl.$oReg->PagesDir.$sLink.$oReg->PageExtension; |
|
| 53 |
} |
|
| 54 |
} |
|
| 55 |
// handle links of modules |
|
| 56 |
}else |
|
| 57 |
{
|
|
| 58 |
// build name of the needed class |
|
| 59 |
$sClass = 'm_'.$aReplacement['Args']['addon'].'_WbLink'; |
|
| 60 |
// remove addon name from replacement array |
|
| 61 |
unset($aReplacement['Args']['addon']); |
|
| 62 |
if(class_exists($sClass)) |
|
| 63 |
{
|
|
| 64 |
// instantiate class |
|
| 65 |
$oWbLink = new $sClass(); |
|
| 66 |
// the class must implement the interface |
|
| 67 |
if($oWbLink instanceof WbLinkAbstract) |
|
| 68 |
{
|
|
| 69 |
// create real link from replacement data |
|
| 70 |
$aReplaceList[$sKey] = $oWbLink->makeLinkFromTag($aReplacement['Args']); |
|
| 71 |
} |
|
| 72 |
} |
|
| 75 |
$aTag['params']['pageid'] = $aTag['pageid']; |
|
| 76 |
$aTag['params']['ancor'] = $aTag['ancor']; |
|
| 77 |
// create real link from replacement data |
|
| 78 |
$aReplaceList[$sKey] = $oWbLink->makeLinkFromTag($aTag['params']); |
|
| 73 | 79 |
} |
| 74 | 80 |
} |
| 75 |
// extract indexes into a new array |
|
| 76 |
$aSearchList = array_keys($aReplaceList); |
|
| 77 |
// replace all identified wblink-tags in content |
|
| 78 |
$sContent = str_replace($aSearchList, $aReplaceList, $sContent); |
|
| 79 | 81 |
} |
| 82 |
// extract indexes into a new array |
|
| 83 |
$aSearchList = array_keys($aReplaceList); |
|
| 84 |
// replace all identified wblink-tags in content |
|
| 85 |
$sContent = str_replace($aSearchList, $aReplaceList, $sContent); |
|
| 80 | 86 |
} |
| 81 | 87 |
return $sContent; |
| 82 | 88 |
} |
| 89 |
|
|
| 90 |
|
|
| 91 |
// $oDb = WbDatabase::getInstance(); |
|
| 92 |
// $oReg = WbAdaptor::getInstance(); |
|
| 93 |
// $aReplaceList = array(); |
|
| 94 |
// $sPattern = '/\[wblink([0-9]+)\??([^\]]*)\]/is'; |
|
| 95 |
// if(preg_match_all($sPattern,$sContent,$aMatches)) |
|
| 96 |
// {
|
|
| 97 |
// // iterate through all found matches |
|
| 98 |
// foreach($aMatches[0] as $iKey => $sKeyString ) |
|
| 99 |
// {
|
|
| 100 |
// $aReplaceList[$sKeyString] = array(); |
|
| 101 |
// // use original Tag to save PageId |
|
| 102 |
// $aReplaceList[$sKeyString]['PageId'] = $aMatches[1][$iKey]; |
|
| 103 |
// // if there are additional arguments given |
|
| 104 |
// if($aMatches[2][$iKey]) |
|
| 105 |
// {
|
|
| 106 |
// $aReplaceList[$sKeyString]['Args'] = array(); |
|
| 107 |
// $aArgs = preg_split('/&|&/i', $aMatches[2][$iKey], -1, PREG_SPLIT_NO_EMPTY);
|
|
| 108 |
// foreach($aArgs as $sArgument) |
|
| 109 |
// {
|
|
| 110 |
// $aTmp = explode('=', $sArgument);
|
|
| 111 |
// $aReplaceList[$sKeyString]['Args'][$aTmp[0]] = $aTmp[1]; |
|
| 112 |
// } |
|
| 113 |
// } |
|
| 114 |
// } |
|
| 115 |
// if(sizeof($aReplaceList) > 0) |
|
| 116 |
// { // iterate list if replacements are available
|
|
| 117 |
// foreach($aReplaceList as $sKey => $aReplacement) |
|
| 118 |
// {
|
|
| 119 |
// // set link on failure ('#' means, still stay on current page)
|
|
| 120 |
// $aReplaceList[$sKey] = '#'; |
|
| 121 |
// // handle normal pages links |
|
| 122 |
// if(!isset($aReplacement['Args'])) |
|
| 123 |
// {
|
|
| 124 |
// // read corresponding link from table 'pages' |
|
| 125 |
// $sql = 'SELECT `link` FROM `'.$oDb->TablePrefix.'pages` WHERE `page_id` = '.(int)$aReplacement['PageId']; |
|
| 126 |
// if(($sLink = $oDb->get_one($sql))) |
|
| 127 |
// {
|
|
| 128 |
// $sLink = trim(str_replace('\\', '/', $sLink), '/');
|
|
| 129 |
// // test if valid accessfile is available |
|
| 130 |
// if(is_readable($oReg->AppPath.$oReg->PagesDir.$sLink.$oReg->PageExtension)) |
|
| 131 |
// {
|
|
| 132 |
// // create absolute URL |
|
| 133 |
// $aReplaceList[$sKey] = $oReg->AppUrl.$oReg->PagesDir.$sLink.$oReg->PageExtension; |
|
| 134 |
// } |
|
| 135 |
// } |
|
| 136 |
// // handle links of modules |
|
| 137 |
// }else |
|
| 138 |
// {
|
|
| 139 |
// // build name of the needed class |
|
| 140 |
// $sClass = 'm_'.$aReplacement['Args']['addon'].'_WbLink'; |
|
| 141 |
// // remove addon name from replacement array |
|
| 142 |
// unset($aReplacement['Args']['addon']); |
|
| 143 |
// if(class_exists($sClass)) |
|
| 144 |
// {
|
|
| 145 |
// // instantiate class |
|
| 146 |
// $oWbLink = new $sClass(); |
|
| 147 |
// // the class must implement the interface |
|
| 148 |
// if($oWbLink instanceof WbLinkAbstract) |
|
| 149 |
// {
|
|
| 150 |
// // create real link from replacement data |
|
| 151 |
// $aReplaceList[$sKey] = $oWbLink->makeLinkFromTag($aReplacement['Args']); |
|
| 152 |
// } |
|
| 153 |
// } |
|
| 154 |
// } |
|
| 155 |
// } |
|
| 156 |
// // extract indexes into a new array |
|
| 157 |
// $aSearchList = array_keys($aReplaceList); |
|
| 158 |
// // replace all identified wblink-tags in content |
|
| 159 |
// $sContent = str_replace($aSearchList, $aReplaceList, $sContent); |
|
| 160 |
// } |
|
| 161 |
// } |
|
| 162 |
// return $sContent; |
|
| 163 |
// } |
|
| branches/2.8.x/wb/modules/news/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
! [wblink] outputfilter now can handle ancors too
! WbLink Interface is much more easier to use now.