1
0
mirror of https://github.com/e107inc/e107.git synced 2025-01-17 20:58:30 +01:00

FAQs: 'faq-new' css class added for recently added FAQs.

This commit is contained in:
Cameron 2015-05-11 14:07:11 -07:00
parent 1af1bd9c09
commit 76d7a802c6
5 changed files with 101 additions and 15 deletions

View File

@ -210,7 +210,8 @@ class faq_main_ui extends e_admin_ui
'u.user_name' => array('title'=> LANA_FAQ_UNAME, 'tab' => 1, 'type' => 'user', 'width' => 'auto', 'noedit' => true, 'readParms'=>'idField=faq_author&link=1'), // User name
'u.user_loginname' => array('title'=> LANA_FAQ_ULOGINNAME, 'tab' => 1, 'type' => 'user', 'width' => 'auto', 'noedit' => true, 'readParms'=>'idField=faq_author&link=1'), // User login name
'faq_order' => array('title'=> LAN_ORDER, 'tab' => 1, 'type' => 'number', 'data'=> 'int','width' => '5%', 'thclass' => 'center','nolist' => false, 'noedit'=>false, 'readParms'=>'editable=1'),
'options' => array('title'=> LAN_OPTIONS, 'type' => null, 'forced'=>TRUE, 'width' => '10%', 'thclass' => 'center last', 'class' => 'center','readParms'=>'sort=1')
'options' => array('title'=> LAN_OPTIONS, 'type' => null, 'forced'=>TRUE, 'width' => '10%', 'thclass' => 'center last', 'class' => 'center','readParms'=>'sort=1'),
'pending' => array('title' => 'internal', 'type' => 'hidden', 'data'=>false, 'writeParms'=>array()),
);
protected $fieldpref = array('checkboxes', 'faq_question', 'faq_answer', 'faq_parent', 'faq_datestamp', 'options');
@ -224,7 +225,9 @@ class faq_main_ui extends e_admin_ui
'classic_look' => array('title'=> LANA_FAQ_PREF_3, 'type'=>'boolean' ),
'list_type' => array('title'=> "List Type", 'type'=>'dropdown', 'writeParms'=>array('ul'=>'Unordered List', 'ol'=>'Ordered List') ),
'page_title' => array('title'=> "Page Title", 'type'=>'text', 'help'=>'Leave blank to use default' ),
);
'new' => array('title'=> "'New' FAQs are no more than", 'type'=>'number', 'writeParms'=>'size=mini&default=0&post=days old', 'help'=>'Leave blank to use default' ),
'display_total' => array('title'=> "Display FAQ total", 'type'=>'boolean' ),
);
protected $categories = array();
@ -242,6 +245,17 @@ class faq_main_ui extends e_admin_ui
}
$this->fields['faq_parent']['writeParms'] = $this->categories;
//$this->fields['pending']['writeParms']['show'] = 1;
$this->fields['pending']['writeParms']['value'] = ($_GET['filter'] == 'pending') ? 1 : 0;
if(!empty($_GET['filter'])) // hide re-ordering when looking at 'unanswered' list and sort by datestamp.
{
$this->listOrder = "faq_datestamp ASC";
$this->fields['options']['readParms'] = '';
$this->sortField = false;
}
}
public function beforeCreate($new_data)
@ -266,6 +280,13 @@ class faq_main_ui extends e_admin_ui
$new_data['faq_tags'] = implode(',', array_map('trim', explode(',', $new_data['faq_tags'])));
}
// e107::getMessage()->addInfo(print_a($new_data, true));
if(!empty($new_data['pending']))
{
$new_data['faq_datestamp'] = time();
}
return $new_data;
}
}
@ -291,7 +312,8 @@ class faq_admin_form_ui extends e_admin_form_ui
break;
case 'write':
return $this->selectbox('faq_parent', $controller->getFaqCategory(), $curVal);
return $this->selectbox('faq_parent', $controller->getFaqCategory(), $curVal).$this->hidden('pending', $pending);
break;
case 'filter':

View File

@ -53,6 +53,8 @@ li.faq-listall-loop
}
.faq-question.faq-new { font-weight: bold; }
.faq-answer
{
margin:20px 0px;

View File

@ -141,9 +141,9 @@ if (isset($_POST['commentsubmit']))
}
if (vartrue($faqpref['faq_title']))
if (vartrue($faqpref['page_title']))
{
define("e_PAGETITLE", $faqpref['faq_title']);
define("e_PAGETITLE", $faqpref['page_title']);
}
else
{
@ -242,15 +242,12 @@ class faq
function view_all($srch) // new funtion to render all FAQs
{
$sql = e107::getDb();
$tp = e107::getParser();
$ret = array();
$template = e107::getTemplate('faqs');
$this->template = $template;
$prevcat = "";
$this->sc = e107::getScBatch('faqs',TRUE);
$text = $tp->parseTemplate($template['start'], true, $this->sc); // header
@ -265,8 +262,6 @@ class faq
$text .= $tp->parseTemplate($template['end'], true, $this->sc); // footer
$ret['title'] = FAQLAN_FAQ;
$ret['text'] = $text;
$ret['caption'] = varset($template['caption']) ? $tp->parseTemplate($template['caption'], true, $this->sc) : LAN_PLUGIN_FAQS_FRONT_NAME;

View File

@ -38,7 +38,13 @@ class faqs_shortcodes extends e_shortcode
$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')
{
$tags = '';
@ -47,8 +53,8 @@ class faqs_shortcodes extends e_shortcode
$tags = "<div class='faq-tags'>".LAN_FAQS_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,'TITLE')."</a>
<div id='{$id}' class='e-hideme faq-answer faq_answer clearfix'>".$tp->toHTML($this->var['faq_answer'],true,'BODY').$tags."</div>
$text = "<a class='e-expandit faq-question{$faqNew}' href='#{$id}'>".$tp->toHTML($this->var['faq_question'],true,'TITLE')."</a>
<div id='{$id}' class='e-hideme faq-answer faq_answer clearfix {$faqNew}'>".$tp->toHTML($this->var['faq_answer'],true,'BODY').$tags."</div>
";
}
@ -162,10 +168,30 @@ class faqs_shortcodes extends e_shortcode
{
return e107::getUrl()->create('faqs/list/all', array('category' => $this->var['faq_info_id']));
}
function sc_faq_caption()
{
$customCaption = e107::pref('faqs', 'page_title');
if(!empty($customCaption))
{
return e107::getParser()->toHtml($customCaption,true);
}
return LAN_PLUGIN_FAQS_FRONT_NAME;
}
function sc_faq_count()
{
$tp = e107::getParser();
$faqTotal = e107::pref('faqs', 'display_total');
if(!empty($faqTotal))
{
return "<span class='faq-total'>(".($this->counter -1).")</span>";
}
return $this->var['f_count'];
}
@ -204,6 +230,45 @@ class faqs_shortcodes extends e_shortcode
}
}
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))
{
//TODO LAN
$text = "<div class='alert alert-warning alert-block faq-submit-question-list'>";
$text .= "<h4>You have requested answers to the following questions:</h4>";
$text .= "<ul>";
foreach($list as $row)
{
$text .= "<li>".$tp->toHtml($row['faq_question'],true)."</li>";
}
$text .= "</ul>";
$text .= "</div>";
}
return $text;
}
}
function sc_faq_search($parm='')
{

View File

@ -10,6 +10,7 @@
$FAQS_TEMPLATE['start'] = "
<div class='faq-start'>{FAQ_SUBMIT_QUESTION}
{FAQ_SUBMIT_QUESTION_LIST}
";
$FAQS_TEMPLATE['end'] = "
@ -31,5 +32,6 @@ $FAQS_TEMPLATE['all']['end'] = "
</div>
";
$FAQS_TEMPLATE['caption'] = "{FAQ_CAPTION} <small>{FAQ_COUNT}</small>";