share = true;
}
if(!empty($pref['display_datestamp']))
{
$this->datestamp = true;
}
if(!empty($pref['submit_question_char_limit']))
{
$this->questionCharLimit = intval($pref['submit_question_char_limit']);
}
}
// Simply FAQ count when needed.
function sc_faq_counter($parm='')
{
return $this->counter;
}
function sc_faq_hide($parm=null)
{
if(empty($parm))
{
$parm = 'collapse';
}
return ($this->item != $this->var['faq_id']) ? $parm : '';
}
function sc_faq_question($parm='')
{
$tp = e107::getParser();
$parm = eHelper::scDualParams($parm);
$param = $parm[1];
$params = $parm[2];
$new = e107::pref('faqs','new',3);
$newDate = strtotime($new." days ago");
$faqNew = ($this->var['faq_datestamp'] > $newDate) ? " faq-new" : "";
if($param == 'expand' && !empty($this->var['faq_answer']))
{
$id = "faq_".$this->var['faq_id'];
$url = e107::url('faqs','item', $this->var, 'full');
$question = $tp->toHTML($this->var['faq_question'],true,'TITLE');
$hide = ($this->item != $this->var['faq_id']) ? 'e-hideme' : '';
$text = "
".$question."
";
$text .= $tp->toHTML($this->var['faq_answer'],true,'BODY');
$text .= "
";
}
else
{
$text = $tp->toHTML($this->var['faq_question'],true, 'TITLE');
}
return $text;
}
function sc_faq_share($parm=null)
{
$tp = e107::getParser();
$url = e107::url('faqs','item', $this->var, 'full');
$question = $tp->toHTML($this->var['faq_question'],true,'TITLE');
return $tp->parseTemplate("{SOCIALSHARE: size=sm&type=basic&url=".$url."&title=".$question."&tags=".$this->var['faq_tags']."}",true);
}
function sc_faq_question_link($parm='')
{
$tp = e107::getParser();
return "var)."' >".$tp -> toHTML($this->var['faq_question'],true,'TITLE')."";
}
function sc_faq_answer()
{
return e107::getParser()->toHTML($this->var['faq_answer'],true,'BODY');
}
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);
$url = e107::url('faqs', 'tag',$urlparms);
$tag = htmlspecialchars($tag, ENT_QUOTES, 'utf-8');
$ret[] = ''.$tag.'';
}
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);
$url = e107::url('faqs', 'tag', $urlparms);
if($parm == 'url') return $url;
return ''.$tag.'';
}
function sc_faq_edit()
{
$tp = e107::getParser();
$faqpref = e107::getPlugConfig('faqs')->getPref();
//if(($faqpref['add_faq'] && $this->var['faq_author'] == USERID) || ADMIN )
// {
// UNDER CONSTRUCTION
//return "[ var['faq_id']."'>Edit ]";
// }
}
/* {FAQ_CATEGORY_ID} */
function sc_faq_category_id($parm = '')
{
return $this->var['faq_parent'];
}
function sc_faq_category($parm = '')
{
// $tp = e107::getParser();
// return $tp->toHTML($this->var['faq_info_title']);
$tp = e107::getParser();
$url = e107::url('faqs','category', $this->var); //@See faqs/e_url.php
return "".$tp->toHTML($this->var['faq_info_title'])."";
/*
return " $this->var['faq_info_id']))."'>".$tp->toHTML($this->var['faq_info_title'])."";
$tp = e107::getParser();
if($parm == 'extend' && $this->tag)
{
return "".$tp->toHTML($this->var['faq_info_title'])." » ".$this->sc_faq_current_tag('raw')."";
}
if($parm == 'raw')
{
return $tp->toHTML($this->var['faq_info_title']);
}
return " $this->var['faq_info_id']))."'>".$tp->toHTML($this->var['faq_info_title'])."";
*/
}
function sc_faq_category_description($parm='')
{
$tp = e107::getParser();
return $tp->toHTML($this->var['faq_info_about'],true, 'BODY');
}
function sc_faq_caturl()
{
return e107::url('faqs', 'category', $this->var);
}
function sc_faq_datestamp($parm)
{
$type = vartrue($parm, 'relative');
return e107::getParser()->toDate($this->var['faq_datestamp'], $type);
}
function sc_faq_caption()
{
$customCaption = e107::pref('faqs', 'page_title');
if(!empty($customCaption[e_LANGUAGE]))
{
return e107::getParser()->toHTML($customCaption[e_LANGUAGE],true);
}
return LAN_PLUGIN_FAQS_FRONT_NAME;
}
function sc_faq_count()
{
$faqTotal = e107::pref('faqs', 'display_total');
if(!empty($faqTotal))
{
return "(".($this->counter -1).")";
}
return $this->var['f_count'];
}
function sc_faq_cat_diz()
{
$tp = e107::getParser();
return $tp->toHTML($this->var['faq_info_about'], true);
}
function sc_faq_icon()
{
return "
";
}
function sc_faq_submit_question($parms)
{
$faqpref = e107::pref('faqs');
if(empty($faqpref['submit_question_language']) && e107::getPref('sitelanguage') != e_LANGUAGE)
{
return false;
}
if(!empty($parms['expand']) && $faqpref['submit_question'] != e_UC_NOBODY)
{
$hide = 'e-hideme';
$button = "".LAN_FAQS_ASK_A_QUESTION."";
}
else
{
$hide = "";
$button = "";
}
if ($faqpref['submit_question'] != e_UC_NOBODY)
{
$frm = e107::getForm();
$text = $button;
$text .= "";
return $text;
}
}
function sc_faq_submit_question_list()
{
$faqpref = e107::pref('faqs');
if (check_class($faqpref['submit_question']))
{
$tp = e107::getParser();
$list = e107::getDb()->retrieve('faqs','faq_question,faq_datestamp',"faq_answer='' AND faq_author_ip = '".USERIP."' ORDER BY faq_datestamp DESC ", true);
$text = "";
if(!empty($list))
{
$text = "";
$text .= "
".LAN_FAQS_016."
";
$text .= "
";
foreach($list as $row)
{
$text .= "- ".$tp->toHTML($row['faq_question'],true)."
";
}
$text .= "
";
$text .= "
";
}
return $text;
}
}
function sc_faq_search($parm='')
{
$frm = e107::getForm();
$tp = e107::getParser();
$target = e107::url('faqs','search');
$text = $frm->open('faq-search-form','get', $target);
$text .= '';
$text .= $frm->text('srch', $_GET['srch'], 20,'class=search-query&placeholder='.LAN_SEARCH).'
';
$text .= '';
$text .= $frm->close();
return $text;
}
function sc_faq_breadcrumb() //TODO Category Detection. and proper SEF Urls with category names.
{
$array = array();
// $array[0] = array('url'=> e_REQUEST_SELF, 'text'=>LAN_PLUGIN_FAQS_NAME);
$array[0] = array('url'=> e107::url('faqs','index'), 'text'=>LAN_PLUGIN_FAQS_NAME);
if(!empty($_GET['srch']))
{
$array[1] = array('url'=> null, 'text'=>LAN_FAQS_002 .": ".e107::getParser()->filter($_GET['srch'], 'w'));
}
return e107::getForm()->breadcrumb($array);
}
}