$items = array(); if ($pages->items_total > 0) { $q = $session->createFindQuery('erLhcoreClassModelFaq'); $whereConditions = array(); $whereConditions[] = $q->expr->eq('active', 1); $whereConditions[] = $q->expr->lOr($q->expr->eq('url', $q->bindValue('')), $q->expr->eq('url', $q->bindValue(trim($matchStringURL))), $q->expr->lAnd($q->expr->eq('is_wildcard', $q->bindValue(1)), $q->expr->like($session->database->quote(trim($matchStringURL)), 'concat(left(url,length(url)-1),\'%\')'))); if ($identifier != '') { $whereConditions[] = $q->expr->eq('identifier', $q->bindValue($identifier)); } $q->where($whereConditions); $q->limit($pages->items_per_page, $pages->low); $q->orderBy('has_url DESC, id DESC'); // Questions with matched URL has higher priority $items = $session->find($q); } $item_new = new erLhcoreClassModelFaq(); if (isset($_POST['send'])) { $definition = array('question' => new ezcInputFormDefinitionElement(ezcInputFormDefinitionElement::OPTIONAL, 'unsafe_raw'), 'email' => new ezcInputFormDefinitionElement(ezcInputFormDefinitionElement::OPTIONAL, 'validate_email'), 'url' => new ezcInputFormDefinitionElement(ezcInputFormDefinitionElement::OPTIONAL, 'unsafe_raw')); if (erLhcoreClassModelChatConfig::fetch('session_captcha')->current_value == 1) { // Start session if required only $currentUser = erLhcoreClassUser::instance(); $hashCaptcha = isset($_SESSION[$_SERVER['REMOTE_ADDR']]['form']) ? $_SESSION[$_SERVER['REMOTE_ADDR']]['form'] : null; $nameField = 'captcha_' . $hashCaptcha; } else { // Captcha stuff $nameField = 'captcha_' . sha1(erLhcoreClassIPDetect::getIP() . $_POST['tscaptcha'] . erConfigClassLhConfig::getInstance()->getSetting('site', 'secrethash')); } $definition[$nameField] = new ezcInputFormDefinitionElement(ezcInputFormDefinitionElement::OPTIONAL, 'string'); $form = new ezcInputForm(INPUT_POST, $definition); $Errors = array(); if (!$form->hasValidData('question') || $form->question == '') {
<?php $tpl = erLhcoreClassTemplate::getInstance('lhfaq/list.tpl.php'); $response = erLhcoreClassChatEventDispatcher::getInstance()->dispatch('faq.list', array('tpl' => &$tpl)); $pages = new lhPaginator(); $pages->serverURL = erLhcoreClassDesign::baseurl('faq/list'); $pages->items_total = erLhcoreClassModelFaq::getCount(); $pages->setItemsPerPage(10); $pages->paginate(); $items = array(); if ($pages->items_total > 0) { $items = erLhcoreClassModelFaq::getList(array('offset' => $pages->low, 'limit' => $pages->items_per_page, 'sort' => 'id DESC')); } $tpl->set('items', $items); $tpl->set('pages', $pages); $Result['content'] = $tpl->fetch(); $Result['path'] = array(array('url' => erLhcoreClassDesign::baseurl('faq/list'), 'title' => erTranslationClassLhTranslation::getInstance()->getTranslation('faq/list', 'FAQ')));
<?php $tpl = erLhcoreClassTemplate::getInstance('lhfaq/view.tpl.php'); $faq = erLhcoreClassModelFaq::fetch($Params['user_parameters']['id']); if (isset($_POST['Update'])) { if (!isset($_POST['csfr_token']) || !$currentUser->validateCSFRToken($_POST['csfr_token'])) { erLhcoreClassModule::redirect(); exit; } $Errors = erLhcoreClassFaq::validateFaq($faq); if (count($Errors) == 0) { $faq->saveThis(); $tpl->set('updated', true); } else { $tpl->set('errors', $Errors); } } if (isset($_POST['Cancel'])) { erLhcoreClassModule::redirect('faq/list'); exit; } $tpl->set('faq', $faq); $Result['content'] = $tpl->fetch(); $Result['path'] = array(array('url' => erLhcoreClassDesign::baseurl('faq/list'), 'title' => erTranslationClassLhTranslation::getInstance()->getTranslation('faq/list', 'FAQ')), array('title' => erTranslationClassLhTranslation::getInstance()->getTranslation('faq/view', 'FAQ description')));