Ejemplo n.º 1
0
 /**
  * Load the form
  */
 private function loadForm()
 {
     $this->isGod = BackendAuthentication::getUser()->isGod();
     $this->frm = new BackendForm('settingsEmail');
     // email settings
     $mailerFrom = BackendModel::getModuleSetting('core', 'mailer_from');
     $this->frm->addText('mailer_from_name', isset($mailerFrom['name']) ? $mailerFrom['name'] : '');
     $this->frm->addText('mailer_from_email', isset($mailerFrom['email']) ? $mailerFrom['email'] : '');
     $mailerTo = BackendModel::getModuleSetting('core', 'mailer_to');
     $this->frm->addText('mailer_to_name', isset($mailerTo['name']) ? $mailerTo['name'] : '');
     $this->frm->addText('mailer_to_email', isset($mailerTo['email']) ? $mailerTo['email'] : '');
     $mailerReplyTo = BackendModel::getModuleSetting('core', 'mailer_reply_to');
     $this->frm->addText('mailer_reply_to_name', isset($mailerReplyTo['name']) ? $mailerReplyTo['name'] : '');
     $this->frm->addText('mailer_reply_to_email', isset($mailerReplyTo['email']) ? $mailerReplyTo['email'] : '');
     if ($this->isGod) {
         $mailerType = BackendModel::getModuleSetting('core', 'mailer_type', 'mail');
         $this->frm->addDropdown('mailer_type', array('mail' => 'PHP\'s mail', 'smtp' => 'SMTP'), $mailerType);
         // smtp settings
         $this->frm->addText('smtp_server', BackendModel::getModuleSetting('core', 'smtp_server', ''));
         $this->frm->addText('smtp_port', BackendModel::getModuleSetting('core', 'smtp_port', 25));
         $this->frm->addText('smtp_username', BackendModel::getModuleSetting('core', 'smtp_username', ''));
         $this->frm->addPassword('smtp_password', BackendModel::getModuleSetting('core', 'smtp_password', ''));
     }
     $this->tpl->assign('isGod', $this->isGod);
 }
Ejemplo n.º 2
0
 /**
  * Load the form
  *
  * @return	void
  */
 private function loadForm()
 {
     // create form
     $this->frm = new BackendForm('settingsThemes');
     // theme
     $this->frm->addDropdown('theme', BackendModel::getThemes(), BackendModel::getModuleSetting('core', 'theme', 'core'));
 }
Ejemplo n.º 3
0
 /**
  * Load the settings form
  */
 protected function loadSettingsForm()
 {
     $mapTypes = array('ROADMAP' => BL::lbl('Roadmap', $this->getModule()), 'SATELLITE' => BL::lbl('Satellite', $this->getModule()), 'HYBRID' => BL::lbl('Hybrid', $this->getModule()), 'TERRAIN' => BL::lbl('Terrain', $this->getModule()));
     $zoomLevels = array_combine(array_merge(array('auto'), range(3, 18)), array_merge(array(BL::lbl('Auto', $this->getModule())), range(3, 18)));
     $this->form = new BackendForm('settings');
     // add map info (overview map)
     $this->form->addHidden('map_id', 0);
     $this->form->addDropdown('zoom_level', $zoomLevels, $this->settings['zoom_level']);
     $this->form->addText('width', $this->settings['width']);
     $this->form->addText('height', $this->settings['height']);
     $this->form->addDropdown('map_type', $mapTypes, $this->settings['map_type']);
 }
Ejemplo n.º 4
0
 /**
  * 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);
 }
Ejemplo n.º 5
0
 /**
  * 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 '';
     }
 }
Ejemplo n.º 6
0
 /**
  * Load the form
  *
  * @return	void
  */
 private function loadForm()
 {
     // list of default domains
     $defaultDomains = array(str_replace(array('http://', 'www.', 'https://'), '', SITE_URL));
     // create form
     $this->frm = new BackendForm('settingsIndex');
     // general settings
     $this->frm->addText('site_title', BackendModel::getModuleSetting('core', 'site_title_' . BL::getWorkingLanguage(), SITE_DEFAULT_TITLE));
     $this->frm->addTextarea('site_html_header', BackendModel::getModuleSetting('core', 'site_html_header', null), 'textarea code', 'textareaError code', true);
     $this->frm->addTextarea('site_html_footer', BackendModel::getModuleSetting('core', 'site_html_footer', null), 'textarea code', 'textareaError code', true);
     $this->frm->addTextarea('site_domains', implode("\n", (array) BackendModel::getModuleSetting('core', 'site_domains', $defaultDomains)), 'textarea code', 'textareaError code');
     // facebook settings
     $this->frm->addText('facebook_admin_ids', BackendModel::getModuleSetting('core', 'facebook_admin_ids', null));
     $this->frm->addText('facebook_application_id', BackendModel::getModuleSetting('core', 'facebook_app_id', null));
     $this->frm->addText('facebook_application_secret', BackendModel::getModuleSetting('core', 'facebook_app_secret', null));
     // api keys
     $this->frm->addText('fork_api_public_key', BackendModel::getModuleSetting('core', 'fork_api_public_key', null));
     $this->frm->addText('fork_api_private_key', BackendModel::getModuleSetting('core', 'fork_api_private_key', null));
     // date & time formats
     $this->frm->addDropdown('time_format', BackendModel::getTimeFormats(), BackendModel::getModuleSetting('core', 'time_format'));
     $this->frm->addDropdown('date_format_short', BackendModel::getDateFormatsShort(), BackendModel::getModuleSetting('core', 'date_format_short'));
     $this->frm->addDropdown('date_format_long', BackendModel::getDateFormatsLong(), BackendModel::getModuleSetting('core', 'date_format_long'));
     // number formats
     $this->frm->addDropdown('number_format', BackendModel::getNumberFormats(), BackendModel::getModuleSetting('core', 'number_format'));
     // create a list of the languages
     foreach (BackendModel::getModuleSetting('core', 'languages', array('nl')) as $abbreviation) {
         // is this the default language
         $defaultLanguage = $abbreviation == SITE_DEFAULT_LANGUAGE ? true : false;
         // attributes
         $activeAttributes = array();
         $activeAttributes['id'] = 'active_language_' . $abbreviation;
         $redirectAttributes = array();
         $redirectAttributes['id'] = 'redirect_language_' . $abbreviation;
         // fetch label
         $label = BL::msg(mb_strtoupper($abbreviation), 'core');
         // default may not be unselected
         if ($defaultLanguage) {
             // add to attributes
             $activeAttributes['disabled'] = 'disabled';
             $redirectAttributes['disabled'] = 'disabled';
             // overrule in $_POST
             if (!isset($_POST['active_languages']) || !is_array($_POST['active_languages'])) {
                 $_POST['active_languages'] = array(SITE_DEFAULT_LANGUAGE);
             } elseif (!in_array($abbreviation, $_POST['active_languages'])) {
                 $_POST['active_languages'][] = $abbreviation;
             }
             if (!isset($_POST['redirect_languages']) || !is_array($_POST['redirect_languages'])) {
                 $_POST['redirect_languages'] = array(SITE_DEFAULT_LANGUAGE);
             } elseif (!in_array($abbreviation, $_POST['redirect_languages'])) {
                 $_POST['redirect_languages'][] = $abbreviation;
             }
         }
         // add to the list
         $activeLanguages[] = array('label' => $label, 'value' => $abbreviation, 'attributes' => $activeAttributes, 'variables' => array('default' => $defaultLanguage));
         $redirectLanguages[] = array('label' => $label, 'value' => $abbreviation, 'attributes' => $redirectAttributes, 'variables' => array('default' => $defaultLanguage));
     }
     // create multilanguage checkbox
     $this->frm->addMultiCheckbox('active_languages', $activeLanguages, BackendModel::getModuleSetting('core', 'active_languages', array(SITE_MULTILANGUAGE)));
     $this->frm->addMultiCheckbox('redirect_languages', $redirectLanguages, BackendModel::getModuleSetting('core', 'redirect_languages', array(SITE_MULTILANGUAGE)));
     // api keys are not required for every module
     if ($this->needsAkismet) {
         $this->frm->addText('akismet_key', BackendModel::getModuleSetting('core', 'akismet_key', null));
     }
     if ($this->needsGoogleMaps) {
         $this->frm->addText('google_maps_key', BackendModel::getModuleSetting('core', 'google_maps_key', null));
     }
 }
Ejemplo n.º 7
0
 /**
  * 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);
     }
 }
Ejemplo n.º 8
0
 /**
  * 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);
     }
 }