mirror of
https://github.com/e107inc/e107.git
synced 2025-08-06 06:38:00 +02:00
FAQ tags support
This commit is contained in:
@@ -35,16 +35,26 @@ class faqs_shortcodes extends e_shortcode
|
||||
function sc_faq_question($parm='')
|
||||
{
|
||||
$tp = e107::getParser();
|
||||
|
||||
if($parm == 'expand')
|
||||
$parm = eHelper::scDualParams($parm);
|
||||
$param = $parm[1];
|
||||
$params = $parm[2];
|
||||
|
||||
if($param == 'expand')
|
||||
{
|
||||
$tags = '';
|
||||
if(vartrue($params['tags']) && $this->var['faq_tags'])
|
||||
{
|
||||
$tags = "<div class='faq-tags'>".$this->sc_faq_tags()."</div>";
|
||||
}
|
||||
$id = "faq_".$this->var['faq_id'];
|
||||
$text = "<a class='e-expandit faq-question' href='#{$id}'>".$tp->toHtml($this->var['faq_question'],true)."</a>
|
||||
<div id='{$id}' class='e-hideme faq-answer faq_answer'>".$tp->toHTML($this->var['faq_answer'],TRUE)."</div>";
|
||||
$text = "<a class='e-expandit faq-question' href='#{$id}'>".$tp->toHTML($this->var['faq_question'],true)."</a>
|
||||
<div id='{$id}' class='e-hideme faq-answer faq_answer'>".$tp->toHTML($this->var['faq_answer'],TRUE).$tags."</div>
|
||||
";
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
$text = $tp->toHtml($this->var['faq_question'],true);
|
||||
$text = $tp->toHTML($this->var['faq_question'],true);
|
||||
}
|
||||
return $text;
|
||||
}
|
||||
@@ -52,12 +62,50 @@ class faqs_shortcodes extends e_shortcode
|
||||
function sc_faq_question_link($parm='')
|
||||
{
|
||||
$tp = e107::getParser();
|
||||
return "<a class='faq-question' href='". e107::getUrl()->create('faqs/view/item', array('id' => $this->var['faq_id']))."' >".$tp -> toHtml($this->var['faq_question'])."</a>";
|
||||
return "<a class='faq-question' href='". e107::getUrl()->create('faqs/view/item', array('id' => $this->var['faq_id']))."' >".$tp -> toHTML($this->var['faq_question'])."</a>";
|
||||
}
|
||||
|
||||
function sc_faq_answer()
|
||||
{
|
||||
return e107::getParser()->toHtml($this->var['faq_answer'],true);
|
||||
return e107::getParser()->toHTML($this->var['faq_answer'],true);
|
||||
}
|
||||
|
||||
|
||||
function sc_faq_tags($parm='')
|
||||
{
|
||||
$tags = $this->var['faq_tags'];
|
||||
if(!$tags) return '';
|
||||
|
||||
if(!$parm) $parm = ' | ';
|
||||
|
||||
$ret = $urlparms = array();
|
||||
if($this->category) $urlparms['category'] = $this->category;
|
||||
$tags = array_map('trim', explode(',', $tags));
|
||||
foreach ($tags as $tag)
|
||||
{
|
||||
$urlparms['tag'] = $tag;
|
||||
$url = e107::getUrl()->create('faqs/list/all', $urlparms);
|
||||
$tag = htmlspecialchars($tag, ENT_QUOTES, 'utf-8');
|
||||
$ret[] = '<a href="'.$url.'" title="'.$tag.'">'.$tag.'</a>';
|
||||
}
|
||||
|
||||
return implode($parm, $ret);
|
||||
}
|
||||
|
||||
function sc_faq_current_tag($parm='')
|
||||
{
|
||||
if(!$this->tag) return '';
|
||||
|
||||
$tag = $this->tag;
|
||||
if($parm == 'raw') return $tag;
|
||||
|
||||
$urlparms = array();
|
||||
if($this->category) $urlparms['category'] = $this->category;
|
||||
$urlparms['tag'] = $tag;
|
||||
$url = e107::getUrl()->create('faqs/list/all', $urlparms);
|
||||
if($parm == 'url') return $url;
|
||||
|
||||
return '<a href="'.$url.'" title="'.$tag.'">'.$tag.'</a>';
|
||||
}
|
||||
|
||||
function sc_faq_edit()
|
||||
@@ -71,10 +119,14 @@ class faqs_shortcodes extends e_shortcode
|
||||
}
|
||||
}
|
||||
|
||||
function sc_faq_category()
|
||||
function sc_faq_category($parm = '')
|
||||
{
|
||||
$tp = e107::getParser();
|
||||
return "<a href='".e107::getUrl()->create('faqs/list/all', array('category' => $this->var['faq_info_id']))."'>".$tp->toHtml($this->var['faq_info_title'])."</a>";
|
||||
if($parm == 'extend' && $this->tag)
|
||||
{
|
||||
return "<a href='".$this->sc_faq_current_tag('url')."'>".$tp->toHTML($this->var['faq_info_title'])." » ".$this->sc_faq_current_tag('raw')."</a>";
|
||||
}
|
||||
return "<a href='".e107::getUrl()->create('faqs/list/all', array('category' => $this->var['faq_info_id']))."'>".$tp->toHTML($this->var['faq_info_title'])."</a>";
|
||||
}
|
||||
|
||||
function sc_faq_caturl()
|
||||
@@ -91,7 +143,7 @@ class faqs_shortcodes extends e_shortcode
|
||||
function sc_faq_cat_diz()
|
||||
{
|
||||
$tp = e107::getParser();
|
||||
return $tp->toHtml($this->var['faq_info_about']);
|
||||
return $tp->toHTML($this->var['faq_info_about'], true);
|
||||
}
|
||||
|
||||
function sc_faq_icon()
|
||||
@@ -127,6 +179,3 @@ class faqs_shortcodes extends e_shortcode
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
?>
|
Reference in New Issue
Block a user