1
0
mirror of https://github.com/e107inc/e107.git synced 2025-07-29 19:00:26 +02:00

Navigation and News shortcode cleanup.

This commit is contained in:
Cameron
2020-12-28 07:46:08 -08:00
parent 15a277349a
commit 044c5324e2
4 changed files with 209 additions and 151 deletions

View File

@@ -16,7 +16,12 @@ require_once(__DIR__.'/navigation_shortcodes_legacy.php');
public $depth = 0;
public $navClass;
/**
* As set by {NAVIGATION: class=xxxx}
* @example {NAV_CLASS}
* @param null $parm
* @return mixed
*/
function sc_nav_class($parm = null)
{
return $this->navClass;
@@ -26,9 +31,9 @@ require_once(__DIR__.'/navigation_shortcodes_legacy.php');
/**
*
* @return string 'active' on the active link.
* @example {LINK_ACTIVE}
* @example {NAV_LINK_ACTIVE}
*/
function sc_nav_active($parm = null)
function sc_nav_link_active($parm = null)
{
if($this->active == true)
@@ -46,13 +51,13 @@ require_once(__DIR__.'/navigation_shortcodes_legacy.php');
*
* @return integer
*/
function sc_nav_id($parm = null)
function sc_nav_link_id($parm = null)
{
return (int) $this->var['link_id'];
}
function sc_nav_depth($parm = null)
function sc_nav_link_depth($parm = null)
{
unset($parm);
@@ -72,9 +77,9 @@ require_once(__DIR__.'/navigation_shortcodes_legacy.php');
* Return the name of the current link
*
* @return string
* @example {LINK_NAME}
* @example {NAV_LINK_NAME}
*/
function sc_nav_name($parm = null)
function sc_nav_link_name($parm = null)
{
if(empty($this->var['link_name']))
@@ -101,14 +106,14 @@ require_once(__DIR__.'/navigation_shortcodes_legacy.php');
*
* @return integer
*/
function sc_nav_parent($parm = null)
function sc_nav_link_parent($parm = null)
{
return (int) $this->var['link_parent'];
}
function sc_nav_identifier($parm = null)
function sc_nav_link_identifier($parm = null)
{
return isset($this->var['link_identifier']) ? $this->var['link_identifier'] : '';
@@ -119,7 +124,7 @@ require_once(__DIR__.'/navigation_shortcodes_legacy.php');
*
* @return string
*/
function sc_nav_url($parm = null)
function sc_nav_link_url($parm = null)
{
$tp = e107::getParser();
@@ -153,7 +158,7 @@ require_once(__DIR__.'/navigation_shortcodes_legacy.php');
}
/*
function sc_nav_sub_oversized($parm='')
function sc_nav_link_sub_oversized($parm='')
{
$count = count($this->var['link_sub']);
@@ -169,11 +174,11 @@ require_once(__DIR__.'/navigation_shortcodes_legacy.php');
/**
* Returns only the anchor target in the URL if one is found.
*
* @example {NAV_LINK_TARGET}
* @param array $parm
* @return null|string
*/
function sc_nav_target($parm = null)
function sc_nav_link_target($parm = null)
{
if(strpos($this->var['link_url'], '#') !== false)
@@ -187,8 +192,12 @@ require_once(__DIR__.'/navigation_shortcodes_legacy.php');
return '#';
}
function sc_nav_open($parm = null)
/**
* @param null $parm
* @example {NAV_LINK_OPEN}
* @return string
*/
function sc_nav_link_open($parm = null)
{
$type = $this->var['link_open'] ? (int) $this->var['link_open'] : 0;
@@ -216,10 +225,10 @@ require_once(__DIR__.'/navigation_shortcodes_legacy.php');
/**
* Return the link icon of the current link
* @example {NAV_ICON}
* @example {NAV_LINK_ICON}
* @return string
*/
function sc_nav_icon($parm = null)
function sc_nav_link_icon($parm = null)
{
$tp = e107::getParser();
@@ -245,10 +254,10 @@ require_once(__DIR__.'/navigation_shortcodes_legacy.php');
/**
* Return the link description of the current link
* @example {NAV_DESCRIPTION}
* @example {NAV_LINK_DESCRIPTION}
* @return string
*/
function sc_nav_description($parm = null)
function sc_nav_link_description($parm = null)
{
$toolTipEnabled = e107::pref('core', 'linkpage_screentip', false);
@@ -265,10 +274,10 @@ require_once(__DIR__.'/navigation_shortcodes_legacy.php');
/**
* Return the parsed sublinks of the current link
*
* @example {NAV_LINK_SUB}
* @return string
*/
function sc_nav_sub($parm = null)
function sc_nav_link_sub($parm = null)
{
if(empty($this->var['link_sub']))
@@ -317,9 +326,9 @@ require_once(__DIR__.'/navigation_shortcodes_legacy.php');
*
* @param unused
* @return string - a generated anchor for the current link.
* @example {LINK_ANCHOR}
* @example {NAV_LINK_ANCHOR}
*/
function sc_nav_anchor($parm = null)
function sc_nav_link_anchor($parm = null)
{
return $this->var['link_name'] ? '#' . e107::getForm()->name2id($this->var['link_name']) : '';

View File

@@ -11,8 +11,8 @@
*/
function sc_link_active($parm = null)
{
trigger_error('<b>{LINK_ACTIVE} is deprecated</b> Use {NAV_ACTIVE} instead', E_USER_DEPRECATED); // NO LAN
return $this->sc_nav_active($parm);
trigger_error('<b>{LINK_ACTIVE} is deprecated</b> Use {NAV_LINK_ACTIVE} instead', E_USER_DEPRECATED); // NO LAN
return $this->sc_nav_link_active($parm);
}
/**
@@ -22,8 +22,8 @@
*/
function sc_link_id($parm = null)
{
trigger_error('<b>{LINK_ID} is deprecated</b> Use {NAV_ID} instead', E_USER_DEPRECATED); // NO LAN
return $this->sc_nav_id($parm);
trigger_error('<b>{LINK_ID} is deprecated</b> Use {NAV_LINK_ID} instead', E_USER_DEPRECATED); // NO LAN
return $this->sc_nav_link_id($parm);
}
/**
@@ -33,8 +33,8 @@
*/
function sc_link_depth($parm = null)
{
trigger_error('<b>{LINK_DEPTH} is deprecated</b> Use {NAV_DEPTH} instead', E_USER_DEPRECATED); // NO LAN
return $this->sc_nav_depth($parm);
trigger_error('<b>{LINK_DEPTH} is deprecated</b> Use {NAV_LINK_DEPTH} instead', E_USER_DEPRECATED); // NO LAN
return $this->sc_nav_link_depth($parm);
}
@@ -46,8 +46,8 @@
*/
function sc_link_name($parm = null)
{
trigger_error('<b>{LINK_NAME} is deprecated</b> Use {NAV_NAME} instead', E_USER_DEPRECATED); // NO LAN
return $this->sc_nav_name($parm);
trigger_error('<b>{LINK_NAME} is deprecated</b> Use {NAV_LINK_NAME} instead', E_USER_DEPRECATED); // NO LAN
return $this->sc_nav_link_name($parm);
}
@@ -58,8 +58,8 @@
*/
function sc_link_parent($parm = null)
{
trigger_error('<b>{LINK_PARENT} is deprecated</b> Use {NAV_PARENT} instead', E_USER_DEPRECATED); // NO LAN
return $this->sc_nav_parent($parm);
trigger_error('<b>{LINK_PARENT} is deprecated</b> Use {NAV_LINK_PARENT} instead', E_USER_DEPRECATED); // NO LAN
return $this->sc_nav_link_parent($parm);
}
/**
@@ -69,8 +69,8 @@
*/
function sc_link_identifier($parm = null)
{
trigger_error('<b>{LINK_IDENTIFIER} is deprecated</b> Use {NAV_IDENTIFIER} instead', E_USER_DEPRECATED); // NO LAN
return $this->sc_nav_identifier($parm);
trigger_error('<b>{LINK_IDENTIFIER} is deprecated</b> Use {NAV_LINK_IDENTIFIER} instead', E_USER_DEPRECATED); // NO LAN
return $this->sc_nav_link_identifier($parm);
}
/**
@@ -80,8 +80,8 @@
*/
function sc_link_url($parm = null)
{
trigger_error('<b>{LINK_URL} is deprecated</b> Use {NAV_URL} instead', E_USER_DEPRECATED); // NO LAN
return $this->sc_nav_url($parm);
trigger_error('<b>{LINK_URL} is deprecated</b> Use {NAV_LINK_URL} instead', E_USER_DEPRECATED); // NO LAN
return $this->sc_nav_link_url($parm);
}
@@ -93,8 +93,8 @@
*/
function sc_link_target($parm = null)
{
trigger_error('<b>{LINK_TARGET} is deprecated</b> Use {NAV_TARGET} instead', E_USER_DEPRECATED); // NO LAN
return $this->sc_nav_target($parm);
trigger_error('<b>{LINK_TARGET} is deprecated</b> Use {NAV_LINK_TARGET} instead', E_USER_DEPRECATED); // NO LAN
return $this->sc_nav_link_target($parm);
}
/**
@@ -104,7 +104,8 @@
*/
function sc_link_open($parm = null)
{
return $this->sc_nav_open($parm);
trigger_error('<b>{LINK_OPEN} is deprecated</b> Use {NAV_LINK_ICON} instead', E_USER_DEPRECATED); // NO LAN
return $this->sc_nav_link_open($parm);
}
/**
@@ -112,9 +113,8 @@
*/
function sc_link_image($parm = null)
{
trigger_error('<b>{LINK_IMAGE} is deprecated</b> Use {NAV_ICON} instead', E_USER_DEPRECATED); // NO LAN
return $this->sc_nav_icon($parm);
trigger_error('<b>{LINK_IMAGE} is deprecated</b> Use {NAV_LINK_ICON} instead', E_USER_DEPRECATED); // NO LAN
return $this->sc_nav_link_icon($parm);
}
@@ -125,8 +125,8 @@
*/
function sc_link_icon($parm = null)
{
trigger_error('<b>{LINK_ICON} is deprecated</b> Use {NAV_ICON} instead', E_USER_DEPRECATED); // NO LAN
return $this->sc_nav_icon($parm);
trigger_error('<b>{LINK_ICON} is deprecated</b> Use {NAV_LINK_ICON} instead', E_USER_DEPRECATED); // NO LAN
return $this->sc_nav_link_icon($parm);
}
@@ -137,8 +137,8 @@
*/
function sc_link_description($parm = null)
{
trigger_error('<b>{LINK_DESCRIPTION} is deprecated</b> Use {NAV_DESCRIPTION} instead', E_USER_DEPRECATED); // NO LAN
return $this->sc_nav_description($parm);
trigger_error('<b>{LINK_DESCRIPTION} is deprecated</b> Use {NAV_LINK_DESCRIPTION} instead', E_USER_DEPRECATED); // NO LAN
return $this->sc_nav_link_description($parm);
}
@@ -149,7 +149,8 @@
*/
function sc_link_sub($parm = null)
{
return $this->sc_nav_sub($parm);
trigger_error('<b>{LINK_SUB} is deprecated</b> Use {NAV_LINK_SUB} instead', E_USER_DEPRECATED); // NO LAN
return $this->sc_nav_link_sub($parm);
}
/**
@@ -161,7 +162,8 @@
*/
function sc_link_anchor($parm = null)
{
return $this->sc_nav_anchor($parm);
trigger_error('<b>{LINK_ANCHOR} is deprecated</b> Use {NAV_LINK_ANCHOR} instead', E_USER_DEPRECATED); // NO LAN
return $this->sc_nav_link_anchor($parm);
}

View File

@@ -48,7 +48,7 @@ class news_shortcodes extends e_shortcode
}
}
function sc_newstitle($parm=null)
function newsTitle($parm=null)
{
$text = e107::getParser()->toHTML($this->news_item['news_title'], TRUE, 'TITLE');
@@ -71,12 +71,6 @@ class news_shortcodes extends e_shortcode
return $text;
}
function sc_newsurltitle()
{
$title = $this->sc_newstitle();
// FIXME generic parser toAttribute method (currently toAttribute() isn't appropriate)
return '<a href="'.$this->sc_news_url().'" title="'.preg_replace('/\'|"|<|>/s', '', $this->news_item['news_title']).'">'.$title.'</a>';
}
function sc_news_body($parm=null)
{
@@ -101,10 +95,7 @@ class news_shortcodes extends e_shortcode
return $news_body;
}
function sc_newsicon($parm=null)
{
return $this->sc_news_category_icon('url');
}
function sc_news_author($parm)
{
@@ -330,17 +321,13 @@ class news_shortcodes extends e_shortcode
//New v2.x Aliases
public function sc_news_id($parm=null)
{
return $this->sc_newsid();
}
public function sc_news_title($parm=null)
{
return (!empty($parm['link'])) ? $this->sc_newstitlelink($parm) : $this->sc_newstitle($parm);
return (!empty($parm['link'])) ? $this->newsTitleLink($parm) : $this->newsTitle($parm);
}
public function sc_news_author_signature($parm=null)
{
$user = e107::user($this->news_item['user_id']);
@@ -374,35 +361,21 @@ class news_shortcodes extends e_shortcode
public function sc_news_description($parm=null)
{
return $this->sc_newsmetadiz($parm);
}
public function sc_news_comment_count($parm=null)
{
return $this->sc_newscommentcount($parm);
}
public function sc_news_comment_label($parm=null)
{
return ($this->news_item['news_comment_total'] == 1) ? COMLAN_8 : LAN_COMMENTS;
}
public function sc_news_date($parm=null)
{
return $this->sc_newsdate($parm);
}
public function sc_news_user_avatar($parm=null)
{
return $this->sc_newsavatar($parm);
}
/**
* Display News Images (but not video thumbnails )
*
* @param $parm array
* @example {NEWS_IMAGE: type=src&placeholder=true}
* @example {NEWS_IMAGE: class=img-responsive img-fluid}
*/
public function sc_news_image($parm=null)
{
if(!empty($parm['carousel']))
@@ -426,13 +399,13 @@ class news_shortcodes extends e_shortcode
$class .= ' news-image-'.$tmp['count'];
$dimensions = null;
$srcset = null;
$src = '';
if ($tp->isVideo($srcPath))
{
return null;
}
else
{
if (empty($srcPath))
{
@@ -441,22 +414,21 @@ class news_shortcodes extends e_shortcode
$src = $tp->thumbUrl(); // placeholder;
$dimensions = $tp->thumbDimensions();
}
}
elseif ($srcPath[0] == '{') // Always resize. Use {SETIMAGE: w=x&y=x&crop=0} PRIOR to calling shortcode to change.
{
$src = $tp->thumbUrl($srcPath);
$dimensions = $tp->thumbDimensions();
$srcset = $tp->thumbSrcSet($srcPath, array('size' => '2x'));
}
else
{
// We store SC path in DB now + BC
$src = $srcPath[0] == '{' ? $tp->replaceConstants($srcPath, 'abs') : e_IMAGE_ABS . "newspost_images/" . $srcPath;
}
}
@@ -551,19 +523,6 @@ class news_shortcodes extends e_shortcode
return e107::getForm()->carousel('news-carousel-'.$this->news_item['news_id'],$images, $options);
}
/**
*
* @param array $array
* @param string $array['types']
* @param int $array['limit']
* @example {NEWS_RELATED: types=news&limit-3}
* @return string
*/
public function sc_news_related($parm=null)
{
return $this->sc_newsrelated($parm);
}
public function sc_news_visibility($parm=null)
{
$string= e107::getUserClass()->getIdentifier($this->news_item['news_class']);
@@ -588,13 +547,13 @@ class news_shortcodes extends e_shortcode
return "<a ".$style." href='".e107::getUrl()->create('news/list/category', $category)."'>".$category_name."</a>";
}
function sc_newsdate($parm)
function sc_news_date($parm=null)
{
$date = ($this->news_item['news_start'] > 0) ? $this->news_item['news_start'] : $this->news_item['news_datestamp'];
$con = e107::getDate();
$tp = e107::getParser();
if($parm == '')
if(empty($parm))
{
return $tp->toDate($date, 'long');
}
@@ -656,7 +615,7 @@ class news_shortcodes extends e_shortcode
/**
* {NEWSCOMMENTCOUNT: glyph=x}
*/
function sc_newscommentcount($parm=null)
function sc_news_comment_count($parm=null)
{
if($this->commentsDisabled || ($this->commentsEngine != 'e107'))
{
@@ -698,7 +657,7 @@ class news_shortcodes extends e_shortcode
return e107::getParser()->parseTemplate('{PDF='.LAN_NEWS_24.'^news.'.$this->news_item['news_id'].'}');
}
function sc_newsid()
function sc_news_id()
{
return $this->news_item['news_id'];
}
@@ -812,9 +771,9 @@ class news_shortcodes extends e_shortcode
* Auto-thumbnailing now allowed.
* New sc parameter standards
* Exampes:
* - {NEWSTHUMBNAIL=link|w=200} render link with thumbnail max width 200px
* - {NEWSTHUMBNAIL=|w=200} same as above
* - {NEWSTHUMBNAIL=src|aw=200&ah=200} return thumb link only, size forced to 200px X 200px (smart thumbnailing close to how Facebook is doing it)
* - {NEWS_THUMBNAIL=link|w=200} render link with thumbnail max width 200px
* - {NEWS_THUMBNAIL=|w=200} same as above
* - {NEWS_THUMBNAIL=src|aw=200&ah=200} return thumb link only, size forced to 200px X 200px (smart thumbnailing close to how Facebook is doing it)
*
* First parameter values: link|src|tag
* Second parameter format: aw|w=xxx&ah|ah=xxx
@@ -823,7 +782,7 @@ class news_shortcodes extends e_shortcode
* @see eHelper::scParams()
* XXX Also returns Video thumbnails.
*/
function sc_newsthumbnail($parm = '') //TODO Add support {NEWSTHUMBNAIL: x=y} format
function sc_news_thumbnail($parm = '') //TODO Add support {NEWSTHUMBNAIL: x=y} format
{
$tmp = $this->handleMultiple($parm,'all');
$newsThumb = $tmp['file'];
@@ -918,9 +877,9 @@ class news_shortcodes extends e_shortcode
/**
* XXX Experimental Images/Video - supports multiple items
* {NEWSMEDIA: item=1}
* @example {NEWS_MEDIA: item=1}
*/
function sc_newsmedia($parm=array())
function sc_news_media($parm=array())
{
$media = explode(",", $this->news_item['news_thumbnail']);
@@ -959,7 +918,7 @@ class news_shortcodes extends e_shortcode
}
function sc_newsvideo($parm='')
function sc_news_video($parm=null)
{
$tmp = $this->handleMultiple($parm,'video');
$file = $tmp['file'];
@@ -1023,17 +982,8 @@ class news_shortcodes extends e_shortcode
/**
* Display News Images (but not video thumbnails )
* @deprecated Use {NEWS_IMAGE} instead.
* @param $parm array
* @example {NEWSIMAGE: type=src&placeholder=true}
* @example {NEWSIMAGE: class=img-responsive img-fluid}
*/
function sc_newsimage($parm = null)
{
return $this->sc_news_image($parm);
}
function sc_sticky_icon()
@@ -1043,7 +993,7 @@ class news_shortcodes extends e_shortcode
function sc_newstitlelink($parm = null)
function newsTitleLink($parm = null)
{
if(is_string($parm))
{
@@ -1098,7 +1048,7 @@ class news_shortcodes extends e_shortcode
return e107::getParser()->parseTemplate('{'.strtoupper($parm[0]).'='.$parm[1].'}');
}
function sc_newsinfo()
public function sc_news_info($parm=null)
{
$news_item = $this->news_item;
$param = $this->param;
@@ -1158,8 +1108,15 @@ class news_shortcodes extends e_shortcode
}
function sc_newsrelated($array=array())
/**
*
* @param array $array
* @param string $array['types']
* @param int $array['limit']
* @example {NEWS_RELATED: types=news&limit-3}
* @return string
*/
function sc_news_related($array=array())
{
if(!varset($array['types']))
{
@@ -1172,7 +1129,7 @@ class news_shortcodes extends e_shortcode
}
function sc_newsmetadiz($parm=null)
function sc_news_description($parm=null)
{
$text = e107::getParser()->toHTML($this->news_item['news_meta_description'],true);

View File

@@ -47,4 +47,94 @@ trait news_shortcodes_legacy
return $this->sc_news_summary($parm);
}
public function sc_newsmetadiz($parm=null)
{
trigger_error('<b>{NEWSSUMMARY} is deprecated</b> Use {NEWS_DESCRIPTION} instead', E_USER_DEPRECATED); // NO LAN
return $this->sc_news_description($parm);
}
public function sc_newsdate($parm=null)
{
trigger_error('<b>{NEWSDATE} is deprecated</b> Use {NEWS_DATE} instead', E_USER_DEPRECATED); // NO LAN
return $this->sc_news_date($parm);
}
public function sc_news_user_avatar($parm=null)
{
trigger_error('<b>{NEWS_USER_AVATAR} is deprecated</b> Use {NEWS_AUTHOR_AVATAR} instead', E_USER_DEPRECATED); // NO LAN
return $this->sc_news_author_avatar($parm);
}
public function sc_newsrelated($parm=null)
{
trigger_error('<b>{NEWSRELATED} is deprecated</b> Use {NEWS_RELATED} instead', E_USER_DEPRECATED); // NO LAN
return $this->sc_news_related($parm);
}
function sc_newsicon($parm=null)
{
trigger_error('<b>{NEWSICON} is deprecated</b> Use {NEWS_CATEGORY_ICON=url} instead', E_USER_DEPRECATED); // NO LAN
return $this->sc_news_category_icon('url');
}
public function sc_newsid($parm=null)
{
trigger_error('<b>{NEWSID} is deprecated</b> Use {NEWS_ID} instead', E_USER_DEPRECATED); // NO LAN
return $this->sc_news_id($parm);
}
public function sc_newsinfo($parm=null)
{
trigger_error('<b>{NEWSINFO} is deprecated</b> Use {NEWS_INFO} instead', E_USER_DEPRECATED); // NO LAN
return $this->sc_news_info($parm);
}
public function sc_newstitlelink($parm=null)
{
trigger_error('<b>{NEWSTITLELINK} is deprecated</b> Use {NEWS_TITLE: link=1} instead', E_USER_DEPRECATED); // NO LAN
return $this->newsTitleLink($parm);
}
public function sc_newstitle($parm=null)
{
trigger_error('<b>{NEWSTITLE} is deprecated</b> Use {NEWS_TITLE} instead', E_USER_DEPRECATED); // NO LAN
return $this->newsTitle($parm);
}
public function sc_newsurltitle()
{
trigger_error('<b>{NEWSURLTITLE} is deprecated</b> Use {NEWS_TITLE: link=1} instead', E_USER_DEPRECATED); // NO LAN
return $this->newsTitleLink();
}
public function sc_newsvideo($parm=null)
{
trigger_error('<b>{NEWSVIDEO} is deprecated</b> Use {NEWS_VIDEO} instead', E_USER_DEPRECATED); // NO LAN
return $this->sc_news_video($parm);
}
public function sc_newsimage($parm = null)
{
trigger_error('<b>{NEWSIMAGE} is deprecated</b> Use {NEWS_IMAGE} instead', E_USER_DEPRECATED); // NO LAN
return $this->sc_news_image($parm);
}
public function sc_newsmedia($parm = null)
{
trigger_error('<b>{NEWSMEDIA} is deprecated</b> Use {NEWS_MEDIA} instead', E_USER_DEPRECATED); // NO LAN
return $this->sc_news_media($parm);
}
public function sc_newscommentcount($parm=null)
{
trigger_error('<b>{NEWSCOMMENTCOUNT} is deprecated</b> Use {NEWS_COMMENT_COUNT} instead', E_USER_DEPRECATED); // NO LAN
return $this->sc_news_comment_count($parm);
}
public function sc_newsthumbnail($parm=null)
{
trigger_error('<b>{NEWSTHUMBNAIL} is deprecated</b> Use {NEWS_THUMBNAIL} instead', E_USER_DEPRECATED); // NO LAN
return $this->sc_news_thumbnail($parm);
}
}