Esempio n. 1
0
 /**
  * Load the form
  *
  * @return	void
  */
 private function loadForm()
 {
     // create form
     $this->frm = new FrontendForm('search', FrontendNavigation::getURLForBlock('search'), 'get', null, false);
     // create elements
     $this->frm->addText('q_widget', null, 255, 'inputText autoSuggest', 'inputTextError autoSuggest');
 }
Esempio n. 2
0
 /**
  * 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);
 }
 /**
  * Parse the data into the template
  */
 private function parse()
 {
     // get vars
     $title = vsprintf(FL::msg('CommentsOn'), array($this->record['title']));
     $link = SITE_URL . FrontendNavigation::getURLForBlock('blog', 'article_comments_rss') . '/' . $this->record['url'];
     $detailLink = SITE_URL . FrontendNavigation::getURLForBlock('blog', 'detail');
     $description = null;
     // create new rss instance
     $rss = new FrontendRSS($title, $link, $description);
     // loop articles
     foreach ($this->items as $item) {
         // init vars
         $title = $item['author'] . ' ' . FL::lbl('On') . ' ' . $this->record['title'];
         $link = $detailLink . '/' . $this->record['url'] . '/#comment-' . $item['id'];
         $description = $item['text'];
         // create new instance
         $rssItem = new FrontendRSSItem($title, $link, $description);
         // set item properties
         $rssItem->setPublicationDate($item['created_on']);
         $rssItem->setAuthor($item['author']);
         // add item
         $rss->addItem($rssItem);
     }
     $rss->parse();
 }
Esempio n. 4
0
 /**
  * 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']);
         }
     }
 }
Esempio n. 5
0
 /**
  * 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);
         }
     }
 }
Esempio n. 6
0
 /**
  * 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));
     }
     // get by URL
     $this->record = FrontendFaqModel::get($this->URL->getParameter(1));
     // anything found?
     if (empty($this->record)) {
         $this->redirect(FrontendNavigation::getURL(404));
     }
     // overwrite URLs
     $this->record['category_full_url'] = FrontendNavigation::getURLForBlock('faq', 'category') . '/' . $this->record['category_url'];
     $this->record['full_url'] = FrontendNavigation::getURLForBlock('faq', 'detail') . '/' . $this->record['url'];
     // get tags
     $this->record['tags'] = FrontendTagsModel::getForItem('faq', $this->record['id']);
     // get settings
     $this->settings = FrontendModel::getModuleSettings('faq');
     // reset allow comments
     if (!$this->settings['allow_feedback']) {
         $this->record['allow_feedback'] = false;
     }
     // ge status
     $this->status = $this->URL->getParameter(2);
     if ($this->status == FL::getAction('Success')) {
         $this->status = 'success';
     }
     if ($this->status == FL::getAction('Spam')) {
         $this->status = 'spam';
     }
 }
Esempio n. 7
0
 /**
  * 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();
 }
 /**
  * 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)));
 }
Esempio n. 9
0
 /**
  * Load the form
  */
 private function loadForm()
 {
     // don't show the form if someone is logged in
     if (FrontendProfilesAuthentication::isLoggedIn()) {
         return;
     }
     $this->frm = new FrontendForm('login', FrontendNavigation::getURLForBlock('profiles', 'login'));
     $this->frm->addText('email');
     $this->frm->addPassword('password');
     $this->frm->addCheckbox('remember', true);
     // parse the form
     $this->frm->parse($this->tpl);
 }
Esempio n. 10
0
 /**
  * Parse the data into the template
  *
  * @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
     $this->header->addLink(array('rel' => 'alternate', 'type' => 'application/rss+xml', 'title' => FrontendModel::getModuleSetting('blog', 'rss_title_' . FRONTEND_LANGUAGE), 'href' => $rssLink), true);
     // assign articles
     $this->tpl->assign('items', $this->items);
     // parse the pagination
     $this->parsePagination();
 }
Esempio n. 11
0
 /**
  * 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));
     }
     // get by URL
     $this->record = FrontendFaqModel::getCategory($this->URL->getParameter(1));
     // anything found?
     if (empty($this->record)) {
         $this->redirect(FrontendNavigation::getURL(404));
     }
     $this->record['full_url'] = FrontendNavigation::getURLForBlock('faq', 'category') . '/' . $this->record['url'];
     $this->questions = FrontendFaqModel::getAllForCategory($this->record['id']);
 }
Esempio n. 12
0
 /**
  * Parse
  *
  * @return	void
  */
 private function parse()
 {
     // get categories
     $categories = FrontendBlogModel::getAllCategories();
     // any categories?
     if (!empty($categories)) {
         // build link
         $link = FrontendNavigation::getURLForBlock('blog', 'category');
         // loop and reset url
         foreach ($categories as &$row) {
             $row['url'] = $link . '/' . $row['url'];
         }
     }
     // assign comments
     $this->tpl->assign('widgetBlogCategories', $categories);
 }
Esempio n. 13
0
 /**
  * Validate the form.
  */
 private function validateForm()
 {
     // is the form submitted
     if ($this->frm->isSubmitted()) {
         // get fields
         $txtEmail = $this->frm->getField('email');
         $txtPassword = $this->frm->getField('password');
         $chkRemember = $this->frm->getField('remember');
         // required fields
         $txtEmail->isFilled(FL::getError('EmailIsRequired'));
         $txtPassword->isFilled(FL::getError('PasswordIsRequired'));
         // both fields filled in
         if ($txtEmail->isFilled() && $txtPassword->isFilled()) {
             // valid email?
             if ($txtEmail->isEmail(FL::getError('EmailIsInvalid'))) {
                 // get the status for the given login
                 $loginStatus = FrontendProfilesAuthentication::getLoginStatus($txtEmail->getValue(), $txtPassword->getValue());
                 // valid login?
                 if ($loginStatus !== FrontendProfilesAuthentication::LOGIN_ACTIVE) {
                     // get the error string to use
                     $errorString = sprintf(FL::getError('Profiles' . SpoonFilter::toCamelCase($loginStatus) . 'Login'), FrontendNavigation::getURLForBlock('profiles', 'resend_activation'));
                     // add the error to stack
                     $this->frm->addError($errorString);
                     // add the error to the template variables
                     $this->tpl->assign('loginError', $errorString);
                 }
             }
         }
         // valid login
         if ($this->frm->isCorrect()) {
             // get profile id
             $profileId = FrontendProfilesModel::getIdByEmail($txtEmail->getValue());
             // login
             FrontendProfilesAuthentication::login($profileId, $chkRemember->getChecked());
             // update salt and password for Dieter's security features
             FrontendProfilesAuthentication::updatePassword($profileId, $txtPassword->getValue());
             // trigger event
             FrontendModel::triggerEvent('profiles', 'after_logged_in', array('id' => $profileId));
             // querystring
             $queryString = urldecode(SpoonFilter::getGetValue('queryString', null, SITE_URL));
             // redirect
             $this->redirect($queryString);
         }
     }
 }
Esempio n. 14
0
 /**
  * Parse
  *
  * @return	void
  */
 private function parse()
 {
     // get categories
     $tags = FrontendTagsModel::getAll();
     // we just need the 10 first items
     $tags = array_slice($tags, 0, 10);
     // build link
     $link = FrontendNavigation::getURLForBlock('tags', 'detail');
     // any tags?
     if (!empty($tags)) {
         // loop and reset url
         foreach ($tags as &$row) {
             $row['url'] = $link . '/' . $row['url'];
         }
     }
     // assign comments
     $this->tpl->assign('widgetTagsTagCloud', $tags);
 }
Esempio n. 15
0
 /**
  * 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, '');
     $limit = (int) FrontendModel::getModuleSetting('search', 'autocomplete_num_items', 10);
     // validate
     if ($term == '') {
         $this->output(self::BAD_REQUEST, null, 'term-parameter is missing.');
     }
     // get matches
     $matches = FrontendSearchModel::getStartsWith($term, FRONTEND_LANGUAGE, $limit);
     // get search url
     $url = FrontendNavigation::getURLForBlock('search');
     // loop items and set search url
     foreach ($matches as &$match) {
         $match['url'] = $url . '?form=search&q=' . $match['term'];
     }
     // output
     $this->output(self::OK, $matches);
 }
Esempio n. 16
0
    /**
     * Parse the search results for this module
     *
     * Note: a module's search function should always:
     * 		- accept an array of entry id's
     * 		- return only the entries that are allowed to be displayed, with their array's index being the entry's id
     *
     *
     * @return	array
     * @param	array $ids		The ids of the found results.
     */
    public static function search(array $ids)
    {
        // get items
        $items = (array) FrontendModel::getDB()->getRecords('SELECT i.id, i.title, i.introduction, i.text, m.url
																FROM blog_posts AS i
																INNER JOIN meta AS m ON i.meta_id = m.id
																WHERE i.status = ? AND i.hidden = ? AND i.language = ? AND i.publish_on <= ? AND i.id IN (' . implode(',', $ids) . ')', array('active', 'N', FRONTEND_LANGUAGE, date('Y-m-d H:i') . ':00'), 'id');
        // prepare items for search
        foreach ($items as &$item) {
            $item['full_url'] = FrontendNavigation::getURLForBlock('blog', 'detail') . '/' . $item['url'];
        }
        // return
        return $items;
    }
Esempio n. 17
0
 /**
  * Validate the form
  */
 private function validateForm()
 {
     // is the form submitted
     if ($this->frm->isSubmitted()) {
         // get field
         $txtEmail = $this->frm->getField('email');
         // field is filled in?
         if ($txtEmail->isFilled(FL::getError('EmailIsRequired'))) {
             // valid email?
             if ($txtEmail->isEmail(FL::getError('EmailIsInvalid'))) {
                 // email exists?
                 if (!FrontendProfilesModel::existsByEmail($txtEmail->getValue())) {
                     $txtEmail->addError(FL::getError('EmailIsUnknown'));
                 }
             }
         }
         // valid login
         if ($this->frm->isCorrect()) {
             // get profile id
             $profileId = FrontendProfilesModel::getIdByEmail($txtEmail->getValue());
             // generate forgot password key
             $key = FrontendProfilesModel::getEncryptedString($profileId . microtime(), FrontendProfilesModel::getRandomString());
             // insert forgot password key
             FrontendProfilesModel::setSetting($profileId, 'forgot_password_key', $key);
             // reset url
             $mailValues['resetUrl'] = SITE_URL . FrontendNavigation::getURLForBlock('profiles', 'reset_password') . '/' . $key;
             $mailValues['firstName'] = FrontendProfilesModel::getSetting($profileId, 'first_name');
             $mailValues['lastName'] = FrontendProfilesModel::getSetting($profileId, 'last_name');
             // trigger event
             FrontendModel::triggerEvent('profiles', 'after_forgot_password', array('id' => $profileId));
             // send email
             FrontendMailer::addEmail(FL::getMessage('ForgotPasswordSubject'), FRONTEND_MODULES_PATH . '/profiles/layout/templates/mails/forgot_password.tpl', $mailValues, $txtEmail->getValue(), '');
             // redirect
             $this->redirect(SELF . '?sent=true');
         } else {
             $this->tpl->assign('forgotPasswordHasError', true);
         }
     }
 }
Esempio n. 18
0
 /**
  * Parse the data into the template
  *
  * @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
     $this->header->addLink(array('rel' => 'alternate', 'type' => 'application/rss+xml', 'title' => FrontendModel::getModuleSetting('blog', 'rss_title_' . FRONTEND_LANGUAGE), 'href' => $rssLink), true);
     // add into breadcrumb
     $this->breadcrumb->addElement(ucfirst(FL::lbl('Category')));
     $this->breadcrumb->addElement($this->category['label']);
     // set pageTitle
     $this->header->setPageTitle(ucfirst(FL::lbl('Category')));
     $this->header->setPageTitle($this->category['label']);
     // advanced SEO-attributes
     if (isset($this->category['meta_data']['seo_index'])) {
         $this->header->addMetaData(array('name' => 'robots', 'content' => $this->category['meta_data']['seo_index']));
     }
     if (isset($this->category['meta_data']['seo_follow'])) {
         $this->header->addMetaData(array('name' => 'robots', 'content' => $this->category['meta_data']['seo_follow']));
     }
     // assign category
     $this->tpl->assign('category', $this->category);
     // assign articles
     $this->tpl->assign('items', $this->items);
     // parse the pagination
     $this->parsePagination();
 }
Esempio n. 19
0
 /**
  * Parse the data into the template
  */
 private function parse()
 {
     // get RSS-link
     $rssLink = FrontendModel::getModuleSetting('blog', 'feedburner_url_' . FRONTEND_LANGUAGE);
     if ($rssLink == '') {
         $rssLink = FrontendNavigation::getURLForBlock('blog', 'rss');
     }
     // add RSS-feed
     $this->header->addLink(array('rel' => 'alternate', 'type' => 'application/rss+xml', 'title' => FrontendModel::getModuleSetting('blog', 'rss_title_' . FRONTEND_LANGUAGE), 'href' => $rssLink), true);
     // get RSS-link for the comments
     $rssCommentsLink = FrontendNavigation::getURLForBlock('blog', 'article_comments_rss') . '/' . $this->record['url'];
     // add RSS-feed into the metaCustom
     $this->header->addLink(array('rel' => 'alternate', 'type' => 'application/rss+xml', 'title' => vsprintf(FL::msg('CommentsOn'), array($this->record['title'])), 'href' => $rssCommentsLink), true);
     // build Facebook Open Graph-data
     if (FrontendModel::getModuleSetting('core', 'facebook_admin_ids', null) !== null || FrontendModel::getModuleSetting('core', 'facebook_app_id', null) !== null) {
         // add specified image
         if (isset($this->record['image']) && $this->record['image'] != '') {
             $this->header->addOpenGraphImage(FRONTEND_FILES_URL . '/blog/images/source/' . $this->record['image']);
         }
         // add images from content
         $this->header->extractOpenGraphImages($this->record['text']);
         // add additional OpenGraph data
         $this->header->addOpenGraphData('title', $this->record['title'], true);
         $this->header->addOpenGraphData('type', 'article', true);
         $this->header->addOpenGraphData('url', SITE_URL . $this->record['full_url'], true);
         $this->header->addOpenGraphData('site_name', FrontendModel::getModuleSetting('core', 'site_title_' . FRONTEND_LANGUAGE, SITE_DEFAULT_TITLE), true);
         $this->header->addOpenGraphData('description', $this->record['title'], true);
     }
     // when there are 2 or more categories with at least one item in it, the category will be added in the breadcrumb
     if (count(FrontendBlogModel::getAllCategories()) > 1) {
         $this->breadcrumb->addElement($this->record['category_title'], FrontendNavigation::getURLForBlock('blog', 'category') . '/' . $this->record['category_url']);
     }
     // add into breadcrumb
     $this->breadcrumb->addElement($this->record['title']);
     // set meta
     $this->header->setPageTitle($this->record['meta_title'], $this->record['meta_title_overwrite'] == 'Y');
     $this->header->addMetaDescription($this->record['meta_description'], $this->record['meta_description_overwrite'] == 'Y');
     $this->header->addMetaKeywords($this->record['meta_keywords'], $this->record['meta_keywords_overwrite'] == 'Y');
     // advanced SEO-attributes
     if (isset($this->record['meta_data']['seo_index'])) {
         $this->header->addMetaData(array('name' => 'robots', 'content' => $this->record['meta_data']['seo_index']));
     }
     if (isset($this->record['meta_data']['seo_follow'])) {
         $this->header->addMetaData(array('name' => 'robots', 'content' => $this->record['meta_data']['seo_follow']));
     }
     $this->header->setCanonicalUrl($this->record['full_url']);
     // assign article
     $this->tpl->assign('item', $this->record);
     // count comments
     $commentCount = count($this->comments);
     // assign the comments
     $this->tpl->assign('commentsCount', $commentCount);
     $this->tpl->assign('comments', $this->comments);
     // options
     if ($commentCount > 1) {
         $this->tpl->assign('blogCommentsMultiple', true);
     }
     // parse the form
     $this->frm->parse($this->tpl);
     // some options
     if ($this->URL->getParameter('comment', 'string') == 'moderation') {
         $this->tpl->assign('commentIsInModeration', true);
     }
     if ($this->URL->getParameter('comment', 'string') == 'spam') {
         $this->tpl->assign('commentIsSpam', true);
     }
     if ($this->URL->getParameter('comment', 'string') == 'true') {
         $this->tpl->assign('commentIsAdded', true);
     }
     // assign settings
     $this->tpl->assign('settings', $this->settings);
     // assign navigation
     $this->tpl->assign('navigation', FrontendBlogModel::getNavigation($this->record['id']));
 }
Esempio n. 20
0
 /**
  * Validate the form
  */
 private function validateForm()
 {
     // is the form submitted
     if ($this->frm->isSubmitted()) {
         // get fields
         $txtEmail = $this->frm->getField('email');
         $txtPassword = $this->frm->getField('password');
         // check email
         if ($txtEmail->isFilled(FL::getError('EmailIsRequired'))) {
             // valid email?
             if ($txtEmail->isEmail(FL::getError('EmailIsInvalid'))) {
                 // email already exists?
                 if (FrontendProfilesModel::existsByEmail($txtEmail->getValue())) {
                     // set error
                     $txtEmail->setError(FL::getError('EmailExists'));
                 }
             }
         }
         // check password
         $txtPassword->isFilled(FL::getError('PasswordIsRequired'));
         // no errors
         if ($this->frm->isCorrect()) {
             // generate salt
             $salt = FrontendProfilesModel::getRandomString();
             // init values
             $values = array();
             // values
             $values['email'] = $txtEmail->getValue();
             $values['password'] = FrontendProfilesModel::getEncryptedString($txtPassword->getValue(), $salt);
             $values['status'] = 'inactive';
             $values['display_name'] = $txtEmail->getValue();
             $values['registered_on'] = FrontendModel::getUTCDate();
             /*
              * Add a profile.
              * We use a try-catch statement to catch errors when more users sign up simultaneously.
              */
             try {
                 // insert profile
                 $profileId = FrontendProfilesModel::insert($values);
                 // use the profile id as url until we have an actual url
                 FrontendProfilesModel::update($profileId, array('url' => FrontendProfilesModel::getUrl($values['display_name'])));
                 // trigger event
                 FrontendModel::triggerEvent('profiles', 'after_register', array('id' => $profileId));
                 // generate activation key
                 $activationKey = FrontendProfilesModel::getEncryptedString($profileId . microtime(), $salt);
                 // set settings
                 FrontendProfilesModel::setSetting($profileId, 'salt', $salt);
                 FrontendProfilesModel::setSetting($profileId, 'activation_key', $activationKey);
                 // login
                 FrontendProfilesAuthentication::login($profileId);
                 // activation URL
                 $mailValues['activationUrl'] = SITE_URL . FrontendNavigation::getURLForBlock('profiles', 'activate') . '/' . $activationKey;
                 // send email
                 FrontendMailer::addEmail(FL::getMessage('RegisterSubject'), FRONTEND_MODULES_PATH . '/profiles/layout/templates/mails/register.tpl', $mailValues, $values['email'], '');
                 // redirect
                 $this->redirect(SELF . '?sent=true');
             } catch (Exception $e) {
                 // when debugging we need to see the exceptions
                 if (SPOON_DEBUG) {
                     throw $e;
                 }
                 // show error
                 $this->tpl->assign('registerHasFormError', true);
             }
         } else {
             $this->tpl->assign('registerHasFormError', true);
         }
     }
 }
Esempio n. 21
0
 public function parse()
 {
     // more matches to be found than?
     if ($this->pagination['num_items'] > count($this->items)) {
         // remove last result (to add this reference)
         array_pop($this->items);
         // add reference to full search results page
         $this->items[] = array('title' => FL::lbl('More'), 'text' => FL::msg('MoreResults'), 'full_url' => FrontendNavigation::getURLForBlock('search') . '?form=search&q=' . $this->term);
     }
     // format data
     foreach ($this->items as &$item) {
         // full url is set?
         if (!isset($item['full_url'])) {
             continue;
         }
         // build utm array
         $utm['utm_source'] = SpoonFilter::urlise(FrontendModel::getModuleSetting('core', 'site_title_' . FRONTEND_LANGUAGE, SITE_DEFAULT_TITLE));
         $utm['utm_medium'] = 'fork-search';
         $utm['utm_term'] = $this->term;
         // get parameters in url already
         if (strpos($item['full_url'], '?') !== false) {
             $glue = '&';
         } else {
             $glue = '?';
         }
         // add utm to url
         $item['full_url'] .= $glue . http_build_query($utm, '', '&');
         // format description
         $item['text'] = !empty($item['text']) ? mb_strlen($item['text']) > $this->length ? mb_substr(strip_tags($item['text']), 0, $this->length, SPOON_CHARSET) . '…' : $item['text'] : '';
     }
     // output
     $this->output(self::OK, $this->items);
 }
Esempio n. 22
0
 /**
  * Get the URL for a give module & action combination
  * 	syntax: {$var|geturlforblock:module[:action[:language]]}
  *
  * @param string $var The string passed from the template.
  * @param string $module The module wherefor the URL should be build.
  * @param string[optional] $action A specific action wherefor the URL should be build, otherwise the default will be used.
  * @param string[optional] $language The language to use, if not provided we will use the loaded language.
  * @return string
  */
 public static function getURLForBlock($var, $module, $action = null, $language = null)
 {
     // redefine
     $var = (string) $var;
     $module = (string) $module;
     $action = $action !== null ? (string) $action : null;
     $language = $language !== null ? (string) $language : null;
     // return url
     return FrontendNavigation::getURLForBlock($module, $action, $language);
 }
Esempio n. 23
0
 /**
  * Validate the form
  */
 private function validateForm()
 {
     // is the form submitted
     if ($this->frm->isSubmitted()) {
         // get field
         $txtEmail = $this->frm->getField('email');
         // field is filled in?
         if ($txtEmail->isFilled(FL::getError('EmailIsRequired'))) {
             // valid email?
             if ($txtEmail->isEmail(FL::getError('EmailIsInvalid'))) {
                 // email exists?
                 if (FrontendProfilesModel::existsByEmail($txtEmail->getValue())) {
                     // get profile id using the filled in email
                     $profileId = FrontendProfilesModel::getIdByEmail($txtEmail->getValue());
                     // get profile
                     $profile = FrontendProfilesModel::get($profileId);
                     // must be inactive
                     if ($profile->getStatus() != FrontendProfilesAuthentication::LOGIN_INACTIVE) {
                         $txtEmail->addError(FL::getError('ProfileIsActive'));
                     }
                 } else {
                     $txtEmail->addError(FL::getError('EmailIsInvalid'));
                 }
             }
         }
         // valid login
         if ($this->frm->isCorrect()) {
             // activation URL
             $mailValues['activationUrl'] = SITE_URL . FrontendNavigation::getURLForBlock('profiles', 'activate') . '/' . $profile->getSetting('activation_key');
             // trigger event
             FrontendModel::triggerEvent('profiles', 'after_resend_activation', array('id' => $profileId));
             // send email
             FrontendMailer::addEmail(FL::getMessage('RegisterSubject'), FRONTEND_MODULES_PATH . '/profiles/layout/templates/mails/register.tpl', $mailValues, $profile->getEmail(), '');
             // redirect
             $this->redirect(SELF . '?sent=true');
         } else {
             $this->tpl->assign('resendActivationHasError', true);
         }
     }
 }
Esempio n. 24
0
 /**
  * Validate the form
  *
  * @return	void
  */
 private function validateForm()
 {
     // is the form submitted
     if ($this->frm->isSubmitted()) {
         // get fields
         $txtOldPassword = $this->frm->getField('old_password');
         $txtNewPassword = $this->frm->getField('new_password');
         // old password filled in?
         if ($txtOldPassword->isFilled(FL::getError('PasswordIsRequired'))) {
             // old password correct?
             if (FrontendProfilesAuthentication::getLoginStatus($this->profile->getEmail(), $txtOldPassword->getValue()) !== FrontendProfilesAuthentication::LOGIN_ACTIVE) {
                 // set error
                 $txtOldPassword->addError(FL::getError('InvalidPassword'));
             }
             // new password filled in?
             $txtNewPassword->isFilled(FL::getError('PasswordIsRequired'));
         }
         // no errors
         if ($this->frm->isCorrect()) {
             // update password
             FrontendProfilesAuthentication::updatePassword($this->profile->getId(), $txtNewPassword->getValue());
             // trigger event
             FrontendModel::triggerEvent('profiles', 'after_profile_password', array('id' => $this->profile->getId()));
             // redirect
             $this->redirect(SITE_URL . FrontendNavigation::getURLForBlock('profiles', 'profile_password') . '?saved=true');
         } else {
             $this->tpl->assign('updatePasswordHasFormError', true);
         }
     }
 }
Esempio n. 25
0
 /**
  * Validate the form.
  */
 private function validateForm()
 {
     // is the form submitted
     if ($this->frm->isSubmitted()) {
         // get fields
         $txtPassword = $this->frm->getField('password');
         $txtEmail = $this->frm->getField('email');
         // password filled in?
         if ($txtPassword->isFilled(FL::getError('PasswordIsRequired'))) {
             // password correct?
             if (FrontendProfilesAuthentication::getLoginStatus($this->profile->getEmail(), $txtPassword->getValue()) !== FrontendProfilesAuthentication::LOGIN_ACTIVE) {
                 // set error
                 $txtPassword->addError(FL::getError('InvalidPassword'));
             }
             // email filled in?
             if ($txtEmail->isFilled(FL::getError('EmailIsRequired'))) {
                 // valid email?
                 if ($txtEmail->isEmail(FL::getError('EmailIsInvalid'))) {
                     // email already exists?
                     if (FrontendProfilesModel::existsByEmail($txtEmail->getValue(), $this->profile->getId())) {
                         // set error
                         $txtEmail->setError(FL::getError('EmailExists'));
                     }
                 }
             }
         }
         // no errors
         if ($this->frm->isCorrect()) {
             // update email
             FrontendProfilesModel::update($this->profile->getId(), array('email' => $txtEmail->getValue()));
             // trigger event
             FrontendModel::triggerEvent('profiles', 'after_change_email', array('id' => $this->profile->getId()));
             // redirect
             $this->redirect(SITE_URL . FrontendNavigation::getURLForBlock('profiles', 'change_email') . '?sent=true');
         } else {
             $this->tpl->assign('updateEmailHasFormError', true);
         }
     }
 }
Esempio n. 26
0
 /**
  * Parse the data into the template
  */
 private function parse()
 {
     // get RSS-link
     $rssLink = FrontendModel::getModuleSetting('blog', 'feedburner_url_' . FRONTEND_LANGUAGE);
     if ($rssLink == '') {
         $rssLink = FrontendNavigation::getURLForBlock('blog', 'rss');
     }
     // add RSS-feed
     $this->header->addLink(array('rel' => 'alternate', 'type' => 'application/rss+xml', 'title' => FrontendModel::getModuleSetting('blog', 'rss_title_' . FRONTEND_LANGUAGE), 'href' => $rssLink), true);
     // add into breadcrumb
     $this->breadcrumb->addElement(SpoonFilter::ucfirst(FL::lbl('Archive')));
     $this->breadcrumb->addElement($this->year);
     if ($this->month !== null) {
         $this->breadcrumb->addElement(SpoonDate::getDate('F', $this->startDate, FRONTEND_LANGUAGE, true));
     }
     // set pageTitle
     $this->header->setPageTitle(SpoonFilter::ucfirst(FL::lbl('Archive')));
     $this->header->setPageTitle($this->year);
     if ($this->month !== null) {
         $this->header->setPageTitle(SpoonDate::getDate('F', $this->startDate, FRONTEND_LANGUAGE, true));
     }
     // assign category
     $this->tpl->assign('archive', array('start_date' => $this->startDate, 'end_date' => $this->endDate, 'year' => $this->year, 'month' => $this->month));
     // assign items
     $this->tpl->assign('items', $this->items);
     // parse the pagination
     $this->parsePagination();
 }
Esempio n. 27
0
 /**
  * Validate the form
  */
 private function validateForm()
 {
     // get settings
     $commentsAllowed = isset($this->settings['allow_comments']) && $this->settings['allow_comments'];
     // comments aren't allowed so we don't have to validate
     if (!$commentsAllowed) {
         return false;
     }
     // is the form submitted
     if ($this->frm->isSubmitted()) {
         // cleanup the submitted fields, ignore fields that were added by hackers
         $this->frm->cleanupFields();
         // does the key exists?
         if (SpoonSession::exists('blog_comment_' . $this->record['id'])) {
             // calculate difference
             $diff = time() - (int) SpoonSession::get('blog_comment_' . $this->record['id']);
             // calculate difference, it it isn't 10 seconds the we tell the user to slow down
             if ($diff < 10 && $diff != 0) {
                 $this->frm->getField('message')->addError(FL::err('CommentTimeout'));
             }
         }
         // validate required fields
         $this->frm->getField('author')->isFilled(FL::err('AuthorIsRequired'));
         $this->frm->getField('email')->isEmail(FL::err('EmailIsRequired'));
         $this->frm->getField('message')->isFilled(FL::err('MessageIsRequired'));
         // validate optional fields
         if ($this->frm->getField('website')->isFilled() && $this->frm->getField('website')->getValue() != 'http://') {
             $this->frm->getField('website')->isURL(FL::err('InvalidURL'));
         }
         // no errors?
         if ($this->frm->isCorrect()) {
             // get module setting
             $spamFilterEnabled = isset($this->settings['spamfilter']) && $this->settings['spamfilter'];
             $moderationEnabled = isset($this->settings['moderation']) && $this->settings['moderation'];
             // reformat data
             $author = $this->frm->getField('author')->getValue();
             $email = $this->frm->getField('email')->getValue();
             $website = $this->frm->getField('website')->getValue();
             if (trim($website) == '' || $website == 'http://') {
                 $website = null;
             }
             $text = $this->frm->getField('message')->getValue();
             // build array
             $comment['post_id'] = $this->record['id'];
             $comment['language'] = FRONTEND_LANGUAGE;
             $comment['created_on'] = FrontendModel::getUTCDate();
             $comment['author'] = $author;
             $comment['email'] = $email;
             $comment['website'] = $website;
             $comment['text'] = $text;
             $comment['status'] = 'published';
             $comment['data'] = serialize(array('server' => $_SERVER));
             // get URL for article
             $permaLink = FrontendNavigation::getURLForBlock('blog', 'detail') . '/' . $this->record['url'];
             $redirectLink = $permaLink;
             // is moderation enabled
             if ($moderationEnabled) {
                 // if the commenter isn't moderated before alter the comment status so it will appear in the moderation queue
                 if (!FrontendBlogModel::isModerated($author, $email)) {
                     $comment['status'] = 'moderation';
                 }
             }
             // should we check if the item is spam
             if ($spamFilterEnabled) {
                 // check for spam
                 $result = FrontendModel::isSpam($text, SITE_URL . $permaLink, $author, $email, $website);
                 // if the comment is spam alter the comment status so it will appear in the spam queue
                 if ($result) {
                     $comment['status'] = 'spam';
                 } elseif ($result == 'unknown') {
                     $comment['status'] = 'moderation';
                 }
             }
             // insert comment
             $comment['id'] = FrontendBlogModel::insertComment($comment);
             // trigger event
             FrontendModel::triggerEvent('blog', 'after_add_comment', array('comment' => $comment));
             // append a parameter to the URL so we can show moderation
             if (strpos($redirectLink, '?') === false) {
                 if ($comment['status'] == 'moderation') {
                     $redirectLink .= '?comment=moderation#' . FL::act('Comment');
                 }
                 if ($comment['status'] == 'spam') {
                     $redirectLink .= '?comment=spam#' . FL::act('Comment');
                 }
                 if ($comment['status'] == 'published') {
                     $redirectLink .= '?comment=true#comment-' . $comment['id'];
                 }
             } else {
                 if ($comment['status'] == 'moderation') {
                     $redirectLink .= '&comment=moderation#' . FL::act('Comment');
                 }
                 if ($comment['status'] == 'spam') {
                     $redirectLink .= '&comment=spam#' . FL::act('Comment');
                 }
                 if ($comment['status'] == 'published') {
                     $redirectLink .= '&comment=true#comment-' . $comment['id'];
                 }
             }
             // set title
             $comment['post_title'] = $this->record['title'];
             $comment['post_url'] = $this->record['url'];
             // notify the admin
             FrontendBlogModel::notifyAdmin($comment);
             // store timestamp in session so we can block excesive usage
             SpoonSession::set('blog_comment_' . $this->record['id'], time());
             // store author-data in cookies
             try {
                 SpoonCookie::set('comment_author', $author, 30 * 24 * 60 * 60, '/', '.' . $this->URL->getDomain());
                 SpoonCookie::set('comment_email', $email, 30 * 24 * 60 * 60, '/', '.' . $this->URL->getDomain());
                 SpoonCookie::set('comment_website', $website, 30 * 24 * 60 * 60, '/', '.' . $this->URL->getDomain());
             } catch (Exception $e) {
                 // settings cookies isn't allowed, but because this isn't a real problem we ignore the exception
             }
             // redirect
             $this->redirect($redirectLink);
         }
     }
 }
Esempio n. 28
0
 /**
  * Parse the general profiles info into the template.
  */
 public static function parse()
 {
     // get the template
     $tpl = Spoon::get('template');
     // logged in
     if (FrontendProfilesAuthentication::isLoggedIn()) {
         // get profile
         $profile = FrontendProfilesAuthentication::getProfile();
         // display name set?
         if ($profile->getDisplayName() != '') {
             $tpl->assign('profileDisplayName', $profile->getDisplayName());
         } else {
             $tpl->assign('profileDisplayName', $profile->getEmail());
         }
         // show logged in
         $tpl->assign('isLoggedIn', true);
     }
     // ignore these url's in the querystring
     $ignoreUrls = array(FrontendNavigation::getURLForBlock('profiles', 'login'), FrontendNavigation::getURLForBlock('profiles', 'register'), FrontendNavigation::getURLForBlock('profiles', 'forgot_password'));
     // querystring
     $queryString = isset($_GET['queryString']) ? SITE_URL . '/' . urldecode($_GET['queryString']) : SELF;
     // check all ignore urls
     foreach ($ignoreUrls as $url) {
         // querystring contains a boeboe url
         if (stripos($queryString, $url) !== false) {
             $queryString = '';
             break;
         }
     }
     // no need to add this if its empty
     $queryString = $queryString != '' ? '?queryString=' . urlencode($queryString) : '';
     // useful urls
     $tpl->assign('loginUrl', FrontendNavigation::getURLForBlock('profiles', 'login') . $queryString);
     $tpl->assign('registerUrl', FrontendNavigation::getURLForBlock('profiles', 'register'));
     $tpl->assign('forgotPasswordUrl', FrontendNavigation::getURLForBlock('profiles', 'forgot_password'));
 }
Esempio n. 29
0
    /**
     * Get tags for multiple items.
     *
     * @param string $module The module wherefor you want to retrieve the tags.
     * @param array $otherIds The ids for the items.
     * @return array
     */
    public static function getForMultipleItems($module, array $otherIds)
    {
        $module = (string) $module;
        // get db
        $db = FrontendModel::getDB();
        // init var
        $return = array();
        // get tags
        $linkedTags = (array) $db->getRecords('SELECT mt.other_id, t.tag AS name, t.url
			 FROM modules_tags AS mt
			 INNER JOIN tags AS t ON mt.tag_id = t.id
			 WHERE mt.module = ? AND mt.other_id IN (' . implode(', ', $otherIds) . ')', array($module));
        // return
        if (empty($linkedTags)) {
            return $return;
        }
        // create link
        $tagLink = FrontendNavigation::getURLForBlock('tags', 'detail');
        // loop tags
        foreach ($linkedTags as $row) {
            // add full URL
            $row['full_url'] = $tagLink . '/' . $row['url'];
            // add
            $return[$row['other_id']][] = $row;
        }
        return $return;
    }
Esempio n. 30
0
 /**
  * Load the form
  */
 private function loadForm()
 {
     // create form
     $this->frm = new FrontendForm('search', null, 'get', null, false);
     // could also have been submitted by our widget
     if (!SpoonFilter::getGetValue('q', null, '')) {
         $_GET['q'] = SpoonFilter::getGetValue('q_widget', null, '');
     }
     // create elements
     $this->frm->addText('q', null, 255, 'inputText liveSuggest autoComplete', 'inputTextError liveSuggest autoComplete');
     // since we know the term just here we should set the canonical url here
     $canonicalUrl = SITE_URL . FrontendNavigation::getURLForBlock('search');
     if (isset($_GET['q']) && $_GET['q'] != '') {
         $canonicalUrl .= '?q=' . $_GET['q'];
     }
     $this->header->setCanonicalUrl($canonicalUrl);
 }