コード例 #1
0
ファイル: email.php プロジェクト: netconstructor/forkcms
 /**
  * Validates the form
  *
  * @return	void
  */
 private function validateForm()
 {
     // is the form submitted?
     if ($this->frm->isSubmitted()) {
         // validate required fields
         $this->frm->getField('mailer_from_name')->isFilled(BL::err('FieldIsRequired'));
         $this->frm->getField('mailer_from_email')->isEmail(BL::err('EmailIsInvalid'));
         $this->frm->getField('mailer_to_name')->isFilled(BL::err('FieldIsRequired'));
         $this->frm->getField('mailer_to_email')->isEmail(BL::err('EmailIsInvalid'));
         $this->frm->getField('mailer_reply_to_name')->isFilled(BL::err('FieldIsRequired'));
         $this->frm->getField('mailer_reply_to_email')->isEmail(BL::err('EmailIsInvalid'));
         // SMTP type was chosen
         if ($this->frm->getField('mailer_type')->getValue() == 'smtp') {
             // server & port are required
             $this->frm->getField('smtp_server')->isFilled(BL::err('FieldIsRequired'));
             $this->frm->getField('smtp_port')->isFilled(BL::err('FieldIsRequired'));
         }
         // no errors ?
         if ($this->frm->isCorrect()) {
             // e-mail settings
             BackendModel::setModuleSetting('core', 'mailer_type', $this->frm->getField('mailer_type')->getValue());
             BackendModel::setModuleSetting('core', 'mailer_from', array('name' => $this->frm->getField('mailer_from_name')->getValue(), 'email' => $this->frm->getField('mailer_from_email')->getValue()));
             BackendModel::setModuleSetting('core', 'mailer_to', array('name' => $this->frm->getField('mailer_to_name')->getValue(), 'email' => $this->frm->getField('mailer_to_email')->getValue()));
             BackendModel::setModuleSetting('core', 'mailer_reply_to', array('name' => $this->frm->getField('mailer_reply_to_name')->getValue(), 'email' => $this->frm->getField('mailer_reply_to_email')->getValue()));
             // smtp settings
             BackendModel::setModuleSetting('core', 'smtp_server', $this->frm->getField('smtp_server')->getValue());
             BackendModel::setModuleSetting('core', 'smtp_port', $this->frm->getField('smtp_port')->getValue());
             BackendModel::setModuleSetting('core', 'smtp_username', $this->frm->getField('smtp_username')->getValue());
             BackendModel::setModuleSetting('core', 'smtp_password', $this->frm->getField('smtp_password')->getValue());
             // assign report
             $this->tpl->assign('report', true);
             $this->tpl->assign('reportMessage', BL::msg('Saved'));
         }
     }
 }
コード例 #2
0
 /**
  * Validate the form
  *
  * @return	void
  */
 private function validateForm()
 {
     // is the form submitted
     if ($this->frm->isSubmitted()) {
         // shorten fields
         $newPassword = $this->frm->getField('backend_new_password');
         $newPasswordRepeated = $this->frm->getField('backend_new_password_repeated');
         // required fields
         $newPassword->isFilled(BL::err('PasswordIsRequired'));
         $newPasswordRepeated->isFilled(BL::err('PasswordRepeatIsRequired'));
         // all fields are ok?
         if ($newPassword->isFilled() && $newPasswordRepeated->isFilled()) {
             // the passwords entered match
             if ($newPassword->getValue() !== $newPasswordRepeated->getValue()) {
                 // add error
                 $this->frm->addError(BL::err('PasswordsDontMatch'));
                 // show error
                 $this->tpl->assign('error', BL::err('PasswordsDontMatch'));
             }
         }
         // is the form submitted
         if ($this->frm->isCorrect()) {
             // change the users password
             BackendUsersModel::updatePassword($this->user, $newPassword->getValue());
             // attempt to login the user
             if (!BackendAuthentication::loginUser($this->user->getEmail(), $newPassword->getValue())) {
                 // redirect to the login form with an error
                 $this->redirect(BackendModel::createURLForAction('index', null, null, array('login' => 'failed')));
             }
             // redirect to the login form
             $this->redirect(BackendModel::createUrlForAction('index', 'dashboard', null, array('password_reset' => 'success')));
         }
     }
 }
コード例 #3
0
ファイル: groups.php プロジェクト: netconstructor/forkcms
 /**
  * Load the form.
  *
  * @return	void
  */
 private function loadForm()
 {
     // create form
     $this->frm = new BackendForm('filter', BackendModel::createURLForAction(), 'get');
     // add fields
     $this->frm->addText('name', $this->filter['name']);
     // manually parse fields
     $this->frm->parse($this->tpl);
 }
コード例 #4
0
ファイル: index.php プロジェクト: nickmancol/forkcms-rhcloud
 /**
  * Parse the datagrid
  */
 protected function parse()
 {
     parent::parse();
     $this->tpl->assign('dataGrid', $this->dataGrid->getNumResults() != 0 ? $this->dataGrid->getContent() : false);
     $this->tpl->assign('godUser', BackendAuthentication::getUser()->isGod());
     // assign to template
     $this->tpl->assign('items', $this->items);
     $this->tpl->assign('settings', $this->settings);
     $this->form->parse($this->tpl);
 }
コード例 #5
0
ファイル: edit.php プロジェクト: nickmancol/forkcms-rhcloud
 /**
  * Parse the form
  */
 protected function parse()
 {
     parent::parse();
     // assign to template
     $this->tpl->assign('item', $this->record);
     $this->tpl->assign('settings', $this->settings);
     $this->tpl->assign('godUser', BackendAuthentication::getUser()->isGod());
     $this->settingsForm->parse($this->tpl);
     // assign message if address was not be geocoded
     if ($this->record['lat'] == null || $this->record['lng'] == null) {
         $this->tpl->assign('errorMessage', BL::err('AddressCouldNotBeGeocoded'));
     }
 }
コード例 #6
0
ファイル: index.php プロジェクト: netconstructor/forkcms
 /**
  * Load the form.
  *
  * @return	void
  */
 private function loadForm()
 {
     // create form
     $this->frm = new BackendForm('filter', BackendModel::createURLForAction(), 'get');
     // values for dropdowns
     $status = BackendProfilesModel::getStatusForDropDown();
     $groups = BackendProfilesModel::getGroups();
     // add fields
     $this->frm->addText('email', $this->filter['email']);
     $this->frm->addDropdown('status', $status, $this->filter['status']);
     $this->frm->getField('status')->setDefaultElement('');
     // add a group filter if wa have groups
     if (!empty($groups)) {
         $this->frm->addDropdown('group', $groups, $this->filter['group']);
         $this->frm->getField('group')->setDefaultElement('');
     }
     // manually parse fields
     $this->frm->parse($this->tpl);
 }
コード例 #7
0
ファイル: seo.php プロジェクト: netconstructor/forkcms
 /**
  * Validates the form
  *
  * @return	void
  */
 private function validateForm()
 {
     // is the form submitted?
     if ($this->frm->isSubmitted()) {
         // no errors ?
         if ($this->frm->isCorrect()) {
             // smtp settings
             BackendModel::setModuleSetting('core', 'seo_noodp', $this->frm->getField('seo_noodp')->getValue());
             BackendModel::setModuleSetting('core', 'seo_noydir', $this->frm->getField('seo_noydir')->getValue());
             BackendModel::setModuleSetting('core', 'seo_nofollow_in_comments', $this->frm->getField('seo_nofollow_in_comments')->getValue());
             // assign report
             $this->tpl->assign('report', true);
             $this->tpl->assign('reportMessage', BL::msg('Saved'));
         }
     }
 }
コード例 #8
0
ファイル: model.php プロジェクト: netconstructor/forkcms
 /**
  * Parse a field and return the HTML.
  *
  * @return	string
  * @param	array $field	Field data.
  */
 public static function parseField(array $field)
 {
     // got a field
     if (!empty($field)) {
         // init
         $frm = new BackendForm('tmp', '');
         $tpl = Spoon::exists('template') ? Spoon::get('template') : new BackendTemplate();
         $fieldHTML = '';
         $fieldName = 'field' . $field['id'];
         $values = isset($field['settings']['values']) ? $field['settings']['values'] : null;
         $defaultValues = isset($field['settings']['default_values']) ? $field['settings']['default_values'] : null;
         /**
          * Create form and parse to HTML
          */
         // dropdown
         if ($field['type'] == 'dropdown') {
             // get index of selected item
             $defaultIndex = array_search($defaultValues, $values, true);
             if ($defaultIndex === false) {
                 $defaultIndex = null;
             }
             // create element
             $ddm = $frm->addDropdown($fieldName, $values, $defaultIndex);
             // empty default element
             $ddm->setDefaultElement('');
             // get content
             $fieldHTML = $ddm->parse();
         } elseif ($field['type'] == 'radiobutton') {
             // rebuild values
             foreach ($values as $value) {
                 $newValues[] = array('label' => $value, 'value' => $value);
             }
             // create element
             $rbt = $frm->addRadiobutton($fieldName, $newValues, $defaultValues);
             // get content
             $fieldHTML = $rbt->parse();
         } elseif ($field['type'] == 'checkbox') {
             // rebuild values
             foreach ($values as $value) {
                 $newValues[] = array('label' => $value, 'value' => $value);
             }
             // create element
             $chk = $frm->addMultiCheckbox($fieldName, $newValues, $defaultValues);
             // get content
             $fieldHTML = $chk->parse();
         } elseif ($field['type'] == 'textbox') {
             // create element
             $txt = $frm->addText($fieldName, $defaultValues);
             $txt->setAttribute('disabled', 'disabled');
             // get content
             $fieldHTML = $txt->parse();
         } elseif ($field['type'] == 'textarea') {
             // create element
             $txt = $frm->addTextarea($fieldName, $defaultValues);
             $txt->setAttribute('cols', 30);
             $txt->setAttribute('disabled', 'disabled');
             // get content
             $fieldHTML = $txt->parse();
         } elseif ($field['type'] == 'heading') {
             $fieldHTML = '<h3>' . $values . '</h3>';
         } elseif ($field['type'] == 'paragraph') {
             $fieldHTML = $values;
         }
         /**
          * Parse the field into the template
          */
         // init
         $tpl->assign('plaintext', false);
         $tpl->assign('simple', false);
         $tpl->assign('multiple', false);
         $tpl->assign('id', $field['id']);
         $tpl->assign('required', isset($field['validations']['required']));
         // plaintext items
         if ($field['type'] == 'heading' || $field['type'] == 'paragraph') {
             // assign
             $tpl->assign('content', $fieldHTML);
             $tpl->assign('plaintext', true);
         } elseif ($field['type'] == 'checkbox' || $field['type'] == 'radiobutton') {
             // name (prefixed by type)
             $name = $field['type'] == 'checkbox' ? 'chk' . ucfirst($fieldName) : 'rbt' . ucfirst($fieldName);
             // rebuild so the html is stored in a general name (and not rbtName)
             foreach ($fieldHTML as &$item) {
                 $item['field'] = $item[$name];
             }
             // show multiple
             $tpl->assign('label', $field['settings']['label']);
             $tpl->assign('items', $fieldHTML);
             $tpl->assign('multiple', true);
         } else {
             // assign
             $tpl->assign('label', $field['settings']['label']);
             $tpl->assign('field', $fieldHTML);
             $tpl->assign('simple', true);
         }
         // cough up created html
         return $tpl->getContent(BACKEND_MODULE_PATH . '/layout/templates/field.tpl');
     } else {
         return '';
     }
 }
コード例 #9
0
ファイル: themes.php プロジェクト: netconstructor/forkcms
 /**
  * Validates the form
  *
  * @return	void
  */
 private function validateForm()
 {
     // is the form submitted?
     if ($this->frm->isSubmitted()) {
         // no errors?
         if ($this->frm->isCorrect()) {
             // determine themes
             $newTheme = $this->frm->getField('theme')->getValue();
             $oldTheme = BackendModel::getModuleSetting('core', 'theme', 'core');
             // check if we actually switched themes
             if ($newTheme != $oldTheme) {
                 // fetch templates
                 $oldTemplates = BackendPagesModel::getTemplates($oldTheme);
                 $newTemplates = BackendPagesModel::getTemplates($newTheme);
                 // check if templates already exist
                 if (empty($newTemplates)) {
                     // templates do not yet exist; don't switch
                     $this->redirect(BackendModel::createURLForAction('themes') . '&error=no-templates-available');
                     exit;
                 }
                 // fetch current default template
                 $oldDefaultTemplatePath = $oldTemplates[BackendModel::getModuleSetting('pages', 'default_template')]['path'];
                 // loop new templates
                 foreach ($newTemplates as $newTemplateId => $newTemplate) {
                     // check if a a similar default template exists
                     if ($newTemplate['path'] == $oldDefaultTemplatePath) {
                         // set new default id
                         $newDefaultTemplateId = (int) $newTemplateId;
                         break;
                     }
                 }
                 // no default template was found, set first template as default
                 if (!isset($newDefaultTemplateId)) {
                     $newDefaultTemplateId = array_keys($newTemplates);
                     $newDefaultTemplateId = $newDefaultTemplateId[0];
                 }
                 // update theme
                 BackendModel::setModuleSetting('core', 'theme', $newTheme);
                 // set amount of blocks
                 BackendPagesModel::setMaximumBlocks();
                 // save new default template
                 BackendModel::setModuleSetting('pages', 'default_template', $newDefaultTemplateId);
                 // loop old templates
                 foreach ($oldTemplates as $oldTemplateId => $oldTemplate) {
                     // loop new templates
                     foreach ($newTemplates as $newTemplateId => $newTemplate) {
                         // check if we have a matching template
                         if ($oldTemplate['path'] == $newTemplate['path']) {
                             // switch template
                             BackendPagesModel::updatePagesTemplates($oldTemplateId, $newTemplateId);
                             // break loop
                             continue 2;
                         }
                     }
                     // getting here meant we found no matching template for the new theme; pick first theme's template as default
                     BackendPagesModel::updatePagesTemplates($oldTemplateId, $newDefaultTemplateId);
                 }
                 // trigger event
                 BackendModel::triggerEvent($this->getModule(), 'after_changed_theme');
             }
             // assign report
             $this->tpl->assign('report', true);
             $this->tpl->assign('reportMessage', BL::msg('Saved'));
         }
     }
 }
コード例 #10
0
ファイル: index.php プロジェクト: netconstructor/forkcms
 /**
  * Validates the form
  *
  * @return	void
  */
 private function validateForm()
 {
     // is the form submitted?
     if ($this->frm->isSubmitted()) {
         // validate required fields
         $this->frm->getField('site_title')->isFilled(BL::err('FieldIsRequired'));
         // date & time
         $this->frm->getField('time_format')->isFilled(BL::err('FieldIsRequired'));
         $this->frm->getField('date_format_short')->isFilled(BL::err('FieldIsRequired'));
         $this->frm->getField('date_format_long')->isFilled(BL::err('FieldIsRequired'));
         // number
         $this->frm->getField('number_format')->isFilled(BL::err('FieldIsRequired'));
         // akismet key may be filled in
         if ($this->needsAkismet && $this->frm->getField('akismet_key')->isFilled()) {
             // key has changed
             if ($this->frm->getField('akismet_key')->getValue() != BackendModel::getModuleSetting('core', 'akismet_key', null)) {
                 // load akismet
                 require_once PATH_LIBRARY . '/external/akismet.php';
                 // create instance
                 $akismet = new Akismet($this->frm->getField('akismet_key')->getValue(), SITE_URL);
                 // invalid key
                 if (!$akismet->verifyKey()) {
                     $this->frm->getField('akismet_key')->setError(BL::err('InvalidAPIKey'));
                 }
             }
         }
         // domains filled in
         if ($this->frm->getField('site_domains')->isFilled()) {
             // split on newlines
             $domains = explode("\n", trim($this->frm->getField('site_domains')->getValue()));
             // loop domains
             foreach ($domains as $domain) {
                 // strip funky stuff
                 $domain = trim(str_replace(array('www.', 'http://', 'https://'), '', $domain));
                 // invalid URL
                 if (!SpoonFilter::isURL('http://' . $domain)) {
                     // set error
                     $this->frm->getField('site_domains')->setError(BL::err('InvalidDomain'));
                     // stop looping domains
                     break;
                 }
             }
         }
         // no errors ?
         if ($this->frm->isCorrect()) {
             // general settings
             BackendModel::setModuleSetting('core', 'site_title_' . BL::getWorkingLanguage(), $this->frm->getField('site_title')->getValue());
             BackendModel::setModuleSetting('core', 'site_html_header', $this->frm->getField('site_html_header')->getValue());
             BackendModel::setModuleSetting('core', 'site_html_footer', $this->frm->getField('site_html_footer')->getValue());
             // facebook settings
             BackendModel::setModuleSetting('core', 'facebook_admin_ids', $this->frm->getField('facebook_admin_ids')->isFilled() ? $this->frm->getField('facebook_admin_ids')->getValue() : null);
             BackendModel::setModuleSetting('core', 'facebook_app_id', $this->frm->getField('facebook_application_id')->isFilled() ? $this->frm->getField('facebook_application_id')->getValue() : null);
             BackendModel::setModuleSetting('core', 'facebook_app_secret', $this->frm->getField('facebook_application_secret')->isFilled() ? $this->frm->getField('facebook_application_secret')->getValue() : null);
             // api keys
             BackendModel::setModuleSetting('core', 'fork_api_public_key', $this->frm->getField('fork_api_public_key')->getValue());
             BackendModel::setModuleSetting('core', 'fork_api_private_key', $this->frm->getField('fork_api_private_key')->getValue());
             if ($this->needsAkismet) {
                 BackendModel::setModuleSetting('core', 'akismet_key', $this->frm->getField('akismet_key')->getValue());
             }
             if ($this->needsGoogleMaps) {
                 BackendModel::setModuleSetting('core', 'google_maps_key', $this->frm->getField('google_maps_key')->getValue());
             }
             // date & time formats
             BackendModel::setModuleSetting('core', 'time_format', $this->frm->getField('time_format')->getValue());
             BackendModel::setModuleSetting('core', 'date_format_short', $this->frm->getField('date_format_short')->getValue());
             BackendModel::setModuleSetting('core', 'date_format_long', $this->frm->getField('date_format_long')->getValue());
             // date & time formats
             BackendModel::setModuleSetting('core', 'number_format', $this->frm->getField('number_format')->getValue());
             // before we save the languages, we need to ensure that each language actually exists and may be chosen.
             $languages = array(SITE_DEFAULT_LANGUAGE);
             // save active languages
             BackendModel::setModuleSetting('core', 'active_languages', array_unique(array_merge($languages, $this->frm->getField('active_languages')->getValue())));
             BackendModel::setModuleSetting('core', 'redirect_languages', array_unique(array_merge($languages, $this->frm->getField('redirect_languages')->getValue())));
             // domains may not contain www, http or https. Therefor we must loop and create the list of domains.
             $siteDomains = array();
             // domains filled in
             if ($this->frm->getField('site_domains')->isFilled()) {
                 // split on newlines
                 $domains = explode("\n", trim($this->frm->getField('site_domains')->getValue()));
                 // loop domains
                 foreach ($domains as $domain) {
                     // strip funky stuff
                     $siteDomains[] = trim(str_replace(array('www.', 'http://', 'https://'), '', $domain));
                 }
             }
             // save domains
             BackendModel::setModuleSetting('core', 'site_domains', $siteDomains);
             // assign report
             $this->tpl->assign('report', true);
             $this->tpl->assign('reportMessage', BL::msg('Saved'));
         }
     }
 }
コード例 #11
0
ファイル: base.php プロジェクト: netconstructor/forkcms
 /**
  * Parse the form
  *
  * @return	void
  */
 protected function parse()
 {
     $this->frm->parse($this->tpl);
 }
コード例 #12
0
ファイル: settings.php プロジェクト: naujasdizainas/forkcms
 /**
  * Parse
  */
 protected function parse()
 {
     parent::parse();
     if (!isset($this->sessionToken)) {
         // show the link to the google account authentication form
         $this->tpl->assign('NoSessionToken', true);
         $this->tpl->assign('Wizard', true);
         // build the link to the google account authentication form
         $redirectUrl = SITE_URL . '/' . (strpos($this->URL->getQueryString(), '?') === false ? $this->URL->getQueryString() : substr($this->URL->getQueryString(), 0, strpos($this->URL->getQueryString(), '?')));
         $googleAccountAuthenticationForm = sprintf(BackendAnalyticsModel::GOOGLE_ACCOUNT_AUTHENTICATION_URL, urlencode($redirectUrl), urlencode(BackendAnalyticsModel::GOOGLE_ACCOUNT_AUTHENTICATION_SCOPE));
         // parse the link to the google account authentication form
         $this->tpl->assign('googleAccountAuthenticationForm', $googleAccountAuthenticationForm);
     }
     // session token is present but no table id
     if (isset($this->sessionToken) && isset($this->profiles) && !isset($this->tableId)) {
         // show all possible accounts with their profiles
         $this->tpl->assign('NoTableId', true);
         $this->tpl->assign('Wizard', true);
         $accounts = array();
         // no profiles or not authorized
         if (!empty($this->profiles) && $this->profiles !== 'UNAUTHORIZED') {
             $accounts[''][0] = BL::msg('ChooseWebsiteProfile');
             // prepare accounts array
             foreach ((array) $this->profiles as $profile) {
                 $accounts[$profile['accountName']][$profile['tableId']] = $profile['title'];
             }
             // there are accounts
             if (!empty($accounts)) {
                 // sort accounts
                 uksort($accounts, array('BackendAnalyticsSettings', 'sortAccounts'));
                 // create form
                 $frm = new BackendForm('linkProfile', BackendModel::createURLForAction(), 'get');
                 $frm->addDropdown('table_id', $accounts);
                 $frm->parse($this->tpl);
                 if ($frm->isSubmitted()) {
                     if ($frm->getField('table_id')->getValue() == '0') {
                         $this->tpl->assign('ddmTableIdError', BL::err('FieldIsRequired'));
                     }
                 }
                 // parse accounts
                 $this->tpl->assign('accounts', true);
             }
         }
     }
     // everything is fine
     if (isset($this->sessionToken) && isset($this->tableId) && isset($this->accountName)) {
         // show the linked account
         $this->tpl->assign('EverythingIsPresent', true);
         // show the title of the linked account and profile
         $this->tpl->assign('accountName', $this->accountName);
         $this->tpl->assign('profileTitle', $this->profileTitle);
     }
 }
コード例 #13
0
ファイル: meta.php プロジェクト: naujasdizainas/forkcms
 /**
  * Validates the form
  * It checks if there is a value when a checkbox is checked
  */
 public function validate()
 {
     // page title overwrite is checked
     if ($this->frm->getField('page_title_overwrite')->isChecked()) {
         $this->frm->getField('page_title')->isFilled(BL::err('FieldIsRequired'));
     }
     // meta description overwrite is checked
     if ($this->frm->getField('meta_description_overwrite')->isChecked()) {
         $this->frm->getField('meta_description')->isFilled(BL::err('FieldIsRequired'));
     }
     // meta keywords overwrite is checked
     if ($this->frm->getField('meta_keywords_overwrite')->isChecked()) {
         $this->frm->getField('meta_keywords')->isFilled(BL::err('FieldIsRequired'));
     }
     // URL overwrite is checked
     if ($this->frm->getField('url_overwrite')->isChecked()) {
         // filled
         $this->frm->getField('url')->isFilled(BL::err('FieldIsRequired'));
         // fetch url
         $URL = $this->frm->getField('url')->getValue();
         // get the real url
         $generatedUrl = $this->generateURL($URL);
         // check if urls are different
         if ($URL != $generatedUrl) {
             $this->frm->getField('url')->addError(BL::err('URLAlreadyExists'));
         }
     }
     // if the form was submitted correctly the data array should be populated
     if ($this->frm->isCorrect()) {
         // get meta keywords
         if ($this->frm->getField('meta_keywords_overwrite')->isChecked()) {
             $keywords = $this->frm->getField('meta_keywords')->getValue();
         } else {
             $keywords = $this->frm->getField($this->baseFieldName)->getValue();
         }
         // get meta description
         if ($this->frm->getField('meta_description_overwrite')->isChecked()) {
             $description = $this->frm->getField('meta_description')->getValue();
         } else {
             $description = $this->frm->getField($this->baseFieldName)->getValue();
         }
         // get page title
         if ($this->frm->getField('page_title_overwrite')->isChecked()) {
             $title = $this->frm->getField('page_title')->getValue();
         } else {
             $title = $this->frm->getField($this->baseFieldName)->getValue();
         }
         // get URL
         if ($this->frm->getField('url_overwrite')->isChecked()) {
             $URL = SpoonFilter::htmlspecialcharsDecode($this->frm->getField('url')->getValue());
         } else {
             $URL = SpoonFilter::htmlspecialcharsDecode($this->frm->getField($this->baseFieldName)->getValue());
         }
         // get the real URL
         $URL = $this->generateURL($URL);
         // get meta custom
         if ($this->custom && $this->frm->getField('meta_custom')->isFilled()) {
             $custom = $this->frm->getField('meta_custom')->getValue();
         } else {
             $custom = null;
         }
         // set data
         $this->data['keywords'] = $keywords;
         $this->data['keywords_overwrite'] = $this->frm->getField('meta_keywords_overwrite')->isChecked() ? 'Y' : 'N';
         $this->data['description'] = $description;
         $this->data['description_overwrite'] = $this->frm->getField('meta_description_overwrite')->isChecked() ? 'Y' : 'N';
         $this->data['title'] = $title;
         $this->data['title_overwrite'] = $this->frm->getField('page_title_overwrite')->isChecked() ? 'Y' : 'N';
         $this->data['url'] = $URL;
         $this->data['url_overwrite'] = $this->frm->getField('url_overwrite')->isChecked() ? 'Y' : 'N';
         $this->data['custom'] = $custom;
         if ($this->frm->getField('seo_index')->getValue() == 'none') {
             unset($this->data['data']['seo_index']);
         } else {
             $this->data['data']['seo_index'] = $this->frm->getField('seo_index')->getValue();
         }
         if ($this->frm->getField('seo_follow')->getValue() == 'none') {
             unset($this->data['data']['seo_follow']);
         } else {
             $this->data['data']['seo_follow'] = $this->frm->getField('seo_follow')->getValue();
         }
     }
 }
コード例 #14
0
ファイル: helper.php プロジェクト: netconstructor/forkcms
 /**
  * Form for periodpicker
  *
  * @return	void
  * @param	BackendTemplate $tpl			The template to parse the period picker in.
  * @param	int $startTimestamp				The start timestamp for the google call.
  * @param	int $endTimestamp				The end timestamp for the google call.
  * @param	array[optional] $parameters		The extra GET parameters to set on redirect.
  */
 public static function parsePeriodPicker(BackendTemplate $tpl, $startTimestamp, $endTimestamp, $parameters = array())
 {
     // redefine
     $startTimestamp = (int) $startTimestamp;
     $endTimestamp = (int) $endTimestamp;
     // assign
     $tpl->assign('startTimestamp', $startTimestamp);
     $tpl->assign('endTimestamp', $endTimestamp);
     // create form
     $frm = new BackendForm('periodPickerForm');
     // create datepickers
     $frm->addDate('start_date', $startTimestamp, 'range', mktime(0, 0, 0, 1, 1, 2005), time(), 'noFocus');
     $frm->addDate('end_date', $endTimestamp, 'range', mktime(0, 0, 0, 1, 1, 2005), time(), 'noFocus');
     // submitted
     if ($frm->isSubmitted()) {
         // show the form
         $tpl->assign('showForm', true);
         // cleanup fields
         $frm->cleanupFields();
         // shorten fields
         $txtStartDate = $frm->getField('start_date');
         $txtEndDate = $frm->getField('end_date');
         // required fields
         $txtStartDate->isFilled(BL::err('StartDateIsInvalid'));
         $txtEndDate->isFilled(BL::err('EndDateIsInvalid'));
         // dates within valid range
         if ($txtStartDate->isFilled() && $txtEndDate->isFilled()) {
             // valid dates
             if ($txtStartDate->isValid(BL::err('StartDateIsInvalid')) && $txtEndDate->isValid(BL::err('EndDateIsInvalid'))) {
                 // get timestamps
                 $newStartDate = BackendModel::getUTCTimestamp($txtStartDate);
                 $newEndDate = BackendModel::getUTCTimestamp($txtEndDate);
                 // init valid
                 $valid = true;
                 // startdate cannot be before 2005 (earliest valid google startdate)
                 if ($newStartDate < mktime(0, 0, 0, 1, 1, 2005)) {
                     $valid = false;
                 } elseif ($newEndDate > time()) {
                     $valid = false;
                 } elseif ($newStartDate > $newEndDate) {
                     $valid = false;
                 }
                 // invalid range
                 if (!$valid) {
                     $txtStartDate->setError(BL::err('DateRangeIsInvalid'));
                 }
             }
         }
         // valid
         if ($frm->isCorrect()) {
             // parameters
             $parameters['start_timestamp'] = $newStartDate;
             $parameters['end_timestamp'] = $newEndDate;
             // build redirect string
             $redirect = html_entity_decode(BackendModel::createURLForAction(null, null, null, $parameters));
             // redirect
             SpoonHTTP::redirect($redirect);
         }
     }
     // parse
     $frm->parse($tpl);
     // we only allow live data fetching when the end date is today, no point in fetching and older range because it will never change
     if ($endTimestamp == mktime(0, 0, 0, date('n'), date('j'), date('Y'))) {
         // url of current action
         $liveDataUrl = BackendModel::createURLForAction('loading') . '&amp;redirect_action=' . Spoon::get('url')->getAction();
         // page id set
         if (isset($_GET['page_id']) && $_GET['page_id'] != '') {
             $liveDataUrl .= '&amp;page_id=' . (int) $_GET['page_id'];
         }
         // page path set
         if (isset($_GET['page_path']) && $_GET['page_path'] != '') {
             $liveDataUrl .= '&amp;page_path=' . (string) $_GET['page_path'];
         }
         // assign
         $tpl->assign('liveDataURL', $liveDataUrl);
     }
 }
コード例 #15
0
ファイル: base.php プロジェクト: richsage/forkcms
 /**
  * Parse the form
  */
 protected function parse()
 {
     parent::parse();
     if ($this->frm) {
         $this->frm->parse($this->tpl);
     }
 }
コード例 #16
0
ファイル: index.php プロジェクト: naujasdizainas/forkcms
 /**
  * Parse all datagrids
  */
 protected function parse()
 {
     parent::parse();
     // parse the datagrid for the drafts
     $this->tpl->assign('dgDrafts', $this->dgDrafts->getNumResults() != 0 ? $this->dgDrafts->getContent() : false);
     // parse the datagrid for all blogposts
     $this->tpl->assign('dgPosts', $this->dgPosts->getNumResults() != 0 ? $this->dgPosts->getContent() : false);
     // parse the datagrid for the most recent blogposts
     $this->tpl->assign('dgRecent', is_object($this->dgRecent) && $this->dgRecent->getNumResults() != 0 ? $this->dgRecent->getContent() : false);
     // get categories
     $categories = BackendBlogModel::getCategories(true);
     // multiple categories?
     if (count($categories) > 1) {
         // create form
         $frm = new BackendForm('filter', null, 'get', false);
         // create element
         $frm->addDropdown('category', $categories, $this->categoryId);
         $frm->getField('category')->setDefaultElement('');
         // parse the form
         $frm->parse($this->tpl);
     }
     // parse category
     if (!empty($this->category)) {
         $this->tpl->assign('filterCategory', $this->category);
     }
 }
コード例 #17
0
ファイル: meta.php プロジェクト: netconstructor/forkcms
 /**
  * Validates the form
  * It checks if there is a value when a checkbox is checked
  *
  * @return	void
  */
 public function validate()
 {
     // no callback set by user?
     if (empty($this->callback)) {
         // build class- & method-name
         $className = 'Backend' . SpoonFilter::toCamelCase($this->URL->getModule()) . 'Model';
         $methodName = 'getURL';
         // set
         $this->setUrlCallback($className, $methodName);
     }
     // page title overwrite is checked
     if ($this->frm->getField('page_title_overwrite')->isChecked()) {
         $this->frm->getField('page_title')->isFilled(BL::err('FieldIsRequired'));
     }
     // meta description overwrite is checked
     if ($this->frm->getField('meta_description_overwrite')->isChecked()) {
         $this->frm->getField('meta_description')->isFilled(BL::err('FieldIsRequired'));
     }
     // meta keywords overwrite is checked
     if ($this->frm->getField('meta_keywords_overwrite')->isChecked()) {
         $this->frm->getField('meta_keywords')->isFilled(BL::err('FieldIsRequired'));
     }
     // URL overwrite is checked
     if ($this->frm->getField('url_overwrite')->isChecked()) {
         // filled
         $this->frm->getField('url')->isFilled(BL::err('FieldIsRequired'));
         // fetch url
         $URL = SpoonFilter::urlise($this->frm->getField('url')->getValue());
         // build parameters for use in the callback
         $parameters[] = $URL;
         // add parameters set by user
         if (!empty($this->callback['parameters'])) {
             foreach ($this->callback['parameters'] as $parameter) {
                 $parameters[] = $parameter;
             }
         }
         // get the real url
         $generatedUrl = call_user_func_array(array($this->callback['class'], $this->callback['method']), $parameters);
         // check if urls are different
         if ($URL != $generatedUrl) {
             $this->frm->getField('url')->addError(BL::err('URLAlreadyExists'));
         }
     }
     // if the form was submitted correctly the data array should be populated
     if ($this->frm->isCorrect()) {
         // no callback set by user?
         if (empty($this->callback)) {
             // build class- & method-name
             $className = 'Backend' . SpoonFilter::toCamelCase($this->URL->getModule()) . 'Model';
             $methodName = 'getURL';
             // set
             $this->setUrlCallback($className, $methodName);
         }
         // get meta keywords
         if ($this->frm->getField('meta_keywords_overwrite')->isChecked()) {
             $keywords = $this->frm->getField('meta_keywords')->getValue();
         } else {
             $keywords = $this->frm->getField($this->baseFieldName)->getValue();
         }
         // get meta description
         if ($this->frm->getField('meta_description_overwrite')->isChecked()) {
             $description = $this->frm->getField('meta_description')->getValue();
         } else {
             $description = $this->frm->getField($this->baseFieldName)->getValue();
         }
         // get page title
         if ($this->frm->getField('page_title_overwrite')->isChecked()) {
             $title = $this->frm->getField('page_title')->getValue();
         } else {
             $title = $this->frm->getField($this->baseFieldName)->getValue();
         }
         // get URL
         if ($this->frm->getField('url_overwrite')->isChecked()) {
             $URL = SpoonFilter::urlise(SpoonFilter::htmlspecialcharsDecode($this->frm->getField('url')->getValue()));
         } else {
             $URL = SpoonFilter::urlise(SpoonFilter::htmlspecialcharsDecode($this->frm->getField($this->baseFieldName)->getValue()));
         }
         // build parameters for use in the callback
         $parameters[] = $URL;
         // add parameters set by user
         if (!empty($this->callback['parameters'])) {
             foreach ($this->callback['parameters'] as $parameter) {
                 $parameters[] = $parameter;
             }
         }
         // get the real URL
         $URL = call_user_func_array(array($this->callback['class'], $this->callback['method']), $parameters);
         // get meta custom
         if ($this->custom && $this->frm->getField('meta_custom')->isFilled()) {
             $custom = $this->frm->getField('meta_custom')->getValue();
         } else {
             $custom = null;
         }
         // set data
         $this->data['keywords'] = $keywords;
         $this->data['keywords_overwrite'] = $this->frm->getField('meta_keywords_overwrite')->isChecked() ? 'Y' : 'N';
         $this->data['description'] = $description;
         $this->data['description_overwrite'] = $this->frm->getField('meta_description_overwrite')->isChecked() ? 'Y' : 'N';
         $this->data['title'] = $title;
         $this->data['title_overwrite'] = $this->frm->getField('page_title_overwrite')->isChecked() ? 'Y' : 'N';
         $this->data['url'] = $URL;
         $this->data['url_overwrite'] = $this->frm->getField('url_overwrite')->isChecked() ? 'Y' : 'N';
         $this->data['custom'] = $custom;
         if ($this->frm->getField('seo_index')->getValue() == 'none') {
             unset($this->data['data']['seo_index']);
         } else {
             $this->data['data']['seo_index'] = $this->frm->getField('seo_index')->getValue();
         }
         if ($this->frm->getField('seo_follow')->getValue() == 'none') {
             unset($this->data['data']['seo_follow']);
         } else {
             $this->data['data']['seo_follow'] = $this->frm->getField('seo_follow')->getValue();
         }
     }
 }