本文整理汇总了PHP中FrontendModel类的典型用法代码示例。如果您正苦于以下问题:PHP FrontendModel类的具体用法?PHP FrontendModel怎么用?PHP FrontendModel使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了FrontendModel类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: parse
/**
* Parse the data into the template
*/
private function parse()
{
// show message
$this->tpl->assign('widgetLocationItems', FrontendLocationModel::get((int) $this->data['id']));
// hide form
$this->tpl->assign('widgetLocationSettings', FrontendModel::getModuleSettings('location'));
}
示例2: validateForm
/**
* Validate the form
*/
private function validateForm()
{
// is the form submitted
if ($this->frm->isSubmitted()) {
// validate required fields
$email = $this->frm->getField('email');
// validate required fields
if ($email->isEmail(FL::err('EmailIsInvalid'))) {
if (FrontendMailmotorModel::isSubscribed($email->getValue())) {
$email->addError(FL::err('AlreadySubscribed'));
}
}
// no errors
if ($this->frm->isCorrect()) {
try {
// subscribe the user to our default group
FrontendMailmotorCMHelper::subscribe($email->getValue());
// trigger event
FrontendModel::triggerEvent('mailmotor', 'after_subscribe', array('email' => $email->getValue()));
// redirect
$this->redirect(FrontendNavigation::getURLForBlock('mailmotor', 'subscribe') . '?sent=true#subscribeForm');
} catch (Exception $e) {
// when debugging we need to see the exceptions
if (SPOON_DEBUG) {
throw $e;
}
// show error
$this->tpl->assign('subscribeHasError', true);
}
} else {
$this->tpl->assign('subscribeHasFormError', true);
}
}
}
示例3: getData
/**
* Load the data, don't forget to validate the incoming data
*/
private function getData()
{
// validate incoming parameters
if ($this->URL->getParameter(1) === null) {
$this->redirect(FrontendNavigation::getURL(404));
}
// fetch record
$this->record = FrontendTagsModel::get($this->URL->getParameter(1));
// validate record
if (empty($this->record)) {
$this->redirect(FrontendNavigation::getURL(404));
}
// fetch modules
$this->modules = FrontendTagsModel::getModulesForTag($this->record['id']);
// loop modules
foreach ($this->modules as $module) {
// set module class
$class = 'Frontend' . SpoonFilter::toCamelCase($module) . 'Model';
// get the ids of the items linked to the tag
$otherIds = (array) FrontendModel::getDB()->getColumn('SELECT other_id
FROM modules_tags
WHERE module = ? AND tag_id = ?', array($module, $this->record['id']));
// set module class
$class = 'Frontend' . SpoonFilter::toCamelCase($module) . 'Model';
// get the items that are linked to the tags
$items = (array) FrontendTagsModel::callFromInterface($module, $class, 'getForTags', $otherIds);
// add into results array
if (!empty($items)) {
$this->results[] = array('name' => $module, 'label' => FL::lbl(SpoonFilter::ucfirst($module)), 'items' => $items);
}
}
}
示例4: loadDataGrid
/**
* Load the datagrid
*/
private function loadDataGrid()
{
// create a new source-object
$source = new SpoonDataGridSourceDB(FrontendModel::getDB(), array(FrontendMailmotorModel::QRY_DATAGRID_BROWSE_SENT, array('sent', FRONTEND_LANGUAGE)));
// create datagrid
$this->dataGrid = new SpoonDataGrid($source);
$this->dataGrid->setCompileDirectory(FRONTEND_CACHE_PATH . '/compiled_templates');
// set hidden columns
$this->dataGrid->setColumnsHidden(array('id', 'status'));
// set headers values
$headers['name'] = SpoonFilter::ucfirst(FL::lbl('Name'));
$headers['send_on'] = SpoonFilter::ucfirst(FL::lbl('Sent'));
// set headers
$this->dataGrid->setHeaderLabels($headers);
// sorting columns
$this->dataGrid->setSortingColumns(array('name', 'send_on'), 'name');
$this->dataGrid->setSortParameter('desc');
// set colum URLs
$this->dataGrid->setColumnURL('name', FrontendNavigation::getURLForBlock('mailmotor', 'detail') . '/[id]');
// set column functions
$this->dataGrid->setColumnFunction(array('SpoonDate', 'getTimeAgo'), array('[send_on]'), 'send_on', true);
// add styles
$this->dataGrid->setColumnAttributes('name', array('class' => 'title'));
// set paging limit
$this->dataGrid->setPagingLimit(self::MAILINGS_PAGING_LIMIT);
}
示例5: execute
/**
* Execute the action
*
* @return void
*/
public function execute()
{
// call parent, this will probably add some general CSS/JS or other required files
parent::execute();
// get parameters
$term = SpoonFilter::getGetValue('term', null, '');
// validate
if ($term == '') {
$this->output(self::BAD_REQUEST, null, 'term-parameter is missing.');
}
// previous search result
$previousTerm = SpoonSession::exists('searchTerm') ? SpoonSession::get('searchTerm') : '';
SpoonSession::set('searchTerm', '');
// save this term?
if ($previousTerm != $term) {
// format data
$this->statistics = array();
$this->statistics['term'] = $term;
$this->statistics['language'] = FRONTEND_LANGUAGE;
$this->statistics['time'] = FrontendModel::getUTCDate();
$this->statistics['data'] = serialize(array('server' => $_SERVER));
$this->statistics['num_results'] = FrontendSearchModel::getTotal($term);
// save data
FrontendSearchModel::save($this->statistics);
}
// save current search term in cookie
SpoonSession::set('searchTerm', $term);
// output
$this->output(self::OK);
}
示例6: execute
/**
* Execute the extra.
*/
public function execute()
{
// get activation key
$key = $this->URL->getParameter(0);
// load template
$this->loadTemplate();
// do we have an activation key?
if (isset($key)) {
// get profile id
$profileId = FrontendProfilesModel::getIdBySetting('activation_key', $key);
// have id?
if ($profileId != null) {
// update status
FrontendProfilesModel::update($profileId, array('status' => 'active'));
// delete activation key
FrontendProfilesModel::deleteSetting($profileId, 'activation_key');
// login profile
FrontendProfilesAuthentication::login($profileId);
// trigger event
FrontendModel::triggerEvent('profiles', 'after_activate', array('id' => $profileId));
// show success message
$this->tpl->assign('activationSuccess', true);
} else {
$this->redirect(FrontendNavigation::getURL(404));
}
} else {
$this->redirect(FrontendNavigation::getURL(404));
}
}
示例7: validateForm
/**
* Validate the form
*/
private function validateForm()
{
if ($this->frm->isSubmitted()) {
$this->frm->cleanupFields();
// validate required fields
$this->frm->getField('name')->isFilled(FL::err('NameIsRequired'));
$this->frm->getField('email')->isEmail(FL::err('EmailIsInvalid'));
$this->frm->getField('message')->isFilled(FL::err('QuestionIsRequired'));
if ($this->frm->isCorrect()) {
$spamFilterEnabled = FrontendModel::getModuleSetting('faq', 'spamfilter');
$variables['sentOn'] = time();
$variables['name'] = $this->frm->getField('name')->getValue();
$variables['email'] = $this->frm->getField('email')->getValue();
$variables['message'] = $this->frm->getField('message')->getValue();
if ($spamFilterEnabled) {
// if the comment is spam alter the comment status so it will appear in the spam queue
if (FrontendModel::isSpam($variables['message'], SITE_URL . FrontendNavigation::getURLForBlock('faq'), $variables['name'], $variables['email'])) {
$this->status = 'errorSpam';
return;
}
}
$this->status = 'success';
FrontendMailer::addEmail(sprintf(FL::getMessage('FaqOwnQuestionSubject'), $variables['name']), FRONTEND_MODULES_PATH . '/faq/layout/templates/mails/own_question.tpl', $variables, $variables['email'], $variables['name']);
}
}
}
示例8: getQuestions
/**
* Get all items in a category
*
* @return array
* @param int $categoryId The id of the category.
*/
public static function getQuestions($categoryId)
{
return (array) FrontendModel::getDB()->getRecords('SELECT i.*
FROM faq_questions AS i
WHERE i.category_id = ? AND i.language = ? AND i.hidden = ?
ORDER BY i.sequence', array((int) $categoryId, FRONTEND_LANGUAGE, 'N'));
}
示例9: execute
/**
* Execute the action
*/
public function execute()
{
parent::execute();
// get parameters
$searchTerm = SpoonFilter::getPostValue('term', null, '');
$term = SPOON_CHARSET == 'utf-8' ? SpoonFilter::htmlspecialchars($searchTerm) : SpoonFilter::htmlentities($searchTerm);
// validate
if ($term == '') {
$this->output(self::BAD_REQUEST, null, 'term-parameter is missing.');
}
// previous search result
$previousTerm = SpoonSession::exists('searchTerm') ? SpoonSession::get('searchTerm') : '';
SpoonSession::set('searchTerm', '');
// save this term?
if ($previousTerm != $term) {
// format data
$this->statistics = array();
$this->statistics['term'] = $term;
$this->statistics['language'] = FRONTEND_LANGUAGE;
$this->statistics['time'] = FrontendModel::getUTCDate();
$this->statistics['data'] = serialize(array('server' => $_SERVER));
$this->statistics['num_results'] = FrontendSearchModel::getTotal($term);
// save data
FrontendSearchModel::save($this->statistics);
}
// save current search term in cookie
SpoonSession::set('searchTerm', $term);
// output
$this->output(self::OK);
}
示例10: parse
/**
* Parse the data into the template
*/
private function parse()
{
// show message
$this->tpl->assign('locationItems', FrontendLocationModel::getAll());
// hide form
$this->tpl->assign('locationSettings', FrontendModel::getModuleSettings('location'));
}
示例11: getTheme
/**
* Gets the active theme name
*
* @return string
*/
public static function getTheme()
{
// theme nama has not yet been saved, fetch and save it
if (!self::$theme) {
self::$theme = FrontendModel::getModuleSetting('core', 'theme', null);
}
// return theme name
return self::$theme;
}
示例12: parse
/**
* Parse the footer into the template
*/
public function parse()
{
// get footer links
$footerLinks = (array) FrontendNavigation::getFooterLinks();
// assign footer links
$this->tpl->assign('footerLinks', $footerLinks);
// initial value for footer HTML
$siteHTMLFooter = (string) FrontendModel::getModuleSetting('core', 'site_html_footer', null);
// facebook admins given?
if (FrontendModel::getModuleSetting('core', 'facebook_admin_ids', null) !== null || FrontendModel::getModuleSetting('core', 'facebook_app_id', null) !== null) {
// build correct locale
switch (FRONTEND_LANGUAGE) {
case 'en':
$locale = 'en_US';
break;
case 'zh':
$locale = 'zh_CN';
break;
case 'cs':
$locale = 'cs_CZ';
break;
case 'el':
$locale = 'el_GR';
break;
case 'ja':
$locale = 'ja_JP';
break;
case 'sv':
$locale = 'sv_SE';
break;
case 'uk':
$locale = 'uk_UA';
break;
default:
$locale = strtolower(FRONTEND_LANGUAGE) . '_' . strtoupper(FRONTEND_LANGUAGE);
}
// add Facebook container
$siteHTMLFooter .= "\n" . '<div id="fb-root"></div>' . "\n";
// add facebook JS
$siteHTMLFooter .= '<script>' . "\n";
if (FrontendModel::getModuleSetting('core', 'facebook_app_id', null) !== null) {
$siteHTMLFooter .= ' window.fbAsyncInit = function() {' . "\n";
$siteHTMLFooter .= ' FB.init({ appId: \'' . FrontendModel::getModuleSetting('core', 'facebook_app_id', null) . '\', status: true, cookie: true, xfbml: true, oauth: true });' . "\n";
$siteHTMLFooter .= ' jsFrontend.facebook.afterInit();' . "\n";
$siteHTMLFooter .= ' };' . "\n";
}
$siteHTMLFooter .= ' (function() {' . "\n";
$siteHTMLFooter .= ' var e = document.createElement(\'script\'); e.async = true; e.src = document.location.protocol + "//connect.facebook.net/' . $locale . '/all.js#xfbml=1";' . "\n";
$siteHTMLFooter .= ' document.getElementById(\'fb-root\').appendChild(e);' . "\n";
$siteHTMLFooter .= ' }());' . "\n";
$siteHTMLFooter .= '</script>';
}
// assign site wide html
$this->tpl->assign('siteHTMLFooter', $siteHTMLFooter);
}
示例13: parse
/**
* Parse the data into the template
*
* @return void
*/
private function parse()
{
// get vars
$title = isset($this->settings['rss_title_' . FRONTEND_LANGUAGE]) ? $this->settings['rss_title_' . FRONTEND_LANGUAGE] : FrontendModel::getModuleSetting('blog', 'rss_title_' . FRONTEND_LANGUAGE, SITE_DEFAULT_TITLE);
$link = SITE_URL . FrontendNavigation::getURLForBlock('blog');
$description = isset($this->settings['rss_description_' . FRONTEND_LANGUAGE]) ? $this->settings['rss_description_' . FRONTEND_LANGUAGE] : null;
// create new rss instance
$rss = new FrontendRSS($title, $link, $description);
// loop articles
foreach ($this->items as $item) {
// init vars
$title = $item['title'];
$link = $item['full_url'];
$description = $item['introduction'] != '' ? $item['introduction'] : $item['text'];
// meta is wanted
if (FrontendModel::getModuleSetting('blog', 'rss_meta_' . FRONTEND_LANGUAGE, true)) {
// append meta
$description .= '<div class="meta">' . "\n";
$description .= ' <p><a href="' . $link . '" title="' . $title . '">' . $title . '</a> ' . sprintf(FL::msg('WrittenBy'), FrontendUser::getBackendUser($item['user_id'])->getSetting('nickname'));
$description .= ' ' . FL::lbl('In') . ' <a href="' . $item['category_full_url'] . '" title="' . $item['category_title'] . '">' . $item['category_title'] . '</a>.</p>' . "\n";
// any tags
if (isset($item['tags'])) {
// append tags-paragraph
$description .= ' <p>' . ucfirst(FL::lbl('Tags')) . ': ';
$first = true;
// loop tags
foreach ($item['tags'] as $tag) {
// prepend separator
if (!$first) {
$description .= ', ';
}
// add
$description .= '<a href="' . $tag['full_url'] . '" rel="tag" title="' . $tag['name'] . '">' . $tag['name'] . '</a>';
// reset
$first = false;
}
// end
$description .= '.</p>' . "\n";
}
// end HTML
$description .= '</div>' . "\n";
}
// create new instance
$rssItem = new FrontendRSSItem($title, $link, $description);
// set item properties
$rssItem->setPublicationDate($item['publish_on']);
$rssItem->addCategory($item['category_title']);
$rssItem->setAuthor(FrontendUser::getBackendUser($item['user_id'])->getSetting('nickname'));
// add item
$rss->addItem($rssItem);
}
// output
$rss->parse();
}
示例14: execute
/**
* Execute the extra.
*
* @return void
*/
public function execute()
{
// logout
if (FrontendProfilesAuthentication::isLoggedIn()) {
FrontendProfilesAuthentication::logout();
}
// trigger event
FrontendModel::triggerEvent('profiles', 'after_logout');
// redirect
$this->redirect(SITE_URL);
}
示例15: parse
/**
* Parse
*
* @return void
*/
private function parse()
{
// get RSS-link
$rssLink = FrontendModel::getModuleSetting('blog', 'feedburner_url_' . FRONTEND_LANGUAGE);
if ($rssLink == '') {
$rssLink = FrontendNavigation::getURLForBlock('blog', 'rss');
}
// add RSS-feed into the metaCustom
$this->header->addLink(array('rel' => 'alternate', 'type' => 'application/rss+xml', 'title' => FrontendModel::getModuleSetting('blog', 'rss_title_' . FRONTEND_LANGUAGE), 'href' => $rssLink), true);
// assign comments
$this->tpl->assign('widgetBlogRecentArticlesList', FrontendBlogModel::getAll(FrontendModel::getModuleSetting('blog', 'recent_articles_list_num_items', 5)));
}