Example #1
0
 /**
  * Load the form
  */
 private function loadForm()
 {
     $this->isGod = BackendAuthentication::getUser()->isGod();
     $this->frm = new BackendForm('settingsEmail');
     // email settings
     $mailerFrom = $this->get('fork.settings')->get('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'] : '')->setAttribute('type', 'email');
     $mailerTo = $this->get('fork.settings')->get('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'] : '')->setAttribute('type', 'email');
     $mailerReplyTo = $this->get('fork.settings')->get('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'] : '')->setAttribute('type', 'email');
     if ($this->isGod) {
         $mailerType = $this->get('fork.settings')->get('Core', 'mailer_type', 'mail');
         $this->frm->addDropdown('mailer_type', array('mail' => 'PHP\'s mail', 'smtp' => 'SMTP'), $mailerType);
         // smtp settings
         $this->frm->addText('smtp_server', $this->get('fork.settings')->get('Core', 'smtp_server', ''));
         $this->frm->addText('smtp_port', $this->get('fork.settings')->get('Core', 'smtp_port', 25));
         $this->frm->addText('smtp_username', $this->get('fork.settings')->get('Core', 'smtp_username', ''));
         $this->frm->addPassword('smtp_password', $this->get('fork.settings')->get('Core', 'smtp_password', ''));
         $this->frm->addDropdown('smtp_secure_layer', array('no' => ucfirst(BL::lbl('None')), 'ssl' => 'SSL', 'tls' => 'TLS'), $this->get('fork.settings')->get('Core', 'smtp_secure_layer', 'no'));
     }
     $this->tpl->assign('isGod', $this->isGod);
 }
 /**
  * Build up the form
  */
 private function build()
 {
     $properties = $this->googleServiceAnalytics->management_webproperties->listManagementWebproperties($this->settings->get('Analytics', 'account'));
     $propertiesForDropDown = [];
     foreach ($properties->getItems() as $property) {
         $propertiesForDropDown[$property->getId()] = $property->getName();
     }
     $this->form->addDropdown('web_property_id', $propertiesForDropDown);
 }
Example #3
0
 public function loadForm()
 {
     $this->form = new Form('settings');
     // we don't even have a auth config file yet, let the user upload it
     if ($this->get('fork.settings')->get($this->getModule(), 'certificate') === null) {
         $this->form->addFile('certificate');
         $this->form->addtext('email');
         return;
     }
     // we are authenticated! Let's see which account the user wants to use
     if ($this->get('fork.settings')->get($this->getModule(), 'account') === null) {
         $analytics = $this->get('analytics.google_analytics_service');
         try {
             $accounts = $analytics->management_accounts->listManagementAccounts();
         } catch (Google_Service_Exception $e) {
             $this->tpl->assign('email', $this->get('fork.settings')->get($this->getModule(), 'email'));
             return $this->tpl->assign('noAccounts', true);
         }
         $accountsForDropdown = array();
         foreach ($accounts->getItems() as $account) {
             $accountsForDropdown[$account->getId()] = $account->getName();
         }
         $this->form->addDropdown('account', $accountsForDropdown);
         return;
     }
     // we have an account, but don't know which property to track
     if ($this->get('fork.settings')->get($this->getModule(), 'web_property_id') === null) {
         $analytics = $this->get('analytics.google_analytics_service');
         $properties = $analytics->management_webproperties->listManagementWebproperties($this->get('fork.settings')->get($this->getModule(), 'account'));
         $propertiesForDropdown = array();
         foreach ($properties->getItems() as $property) {
             $propertiesForDropdown[$property->getId()] = $property->getName();
         }
         $this->form->addDropdown('web_property_id', $propertiesForDropdown);
         return;
     }
     // we have an account, but don't know which property to track
     if ($this->get('fork.settings')->get($this->getModule(), 'profile') === null) {
         $analytics = $this->get('analytics.google_analytics_service');
         $profiles = $analytics->management_profiles->listManagementProfiles($this->get('fork.settings')->get($this->getModule(), 'account'), $this->get('fork.settings')->get($this->getModule(), 'web_property_id'));
         $profilesForDropdown = array();
         foreach ($profiles->getItems() as $property) {
             $profilesForDropdown[$property->getId()] = $property->getName();
         }
         $this->form->addDropdown('profile', $profilesForDropdown);
         return;
     }
 }
Example #4
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']);
 }
Example #5
0
 /**
  * Load the form
  */
 private function loadForm()
 {
     $this->frm = new BackendForm('filter', BackendModel::createURLForAction(), 'get');
     $this->frm->addDropdown('application', array('' => '-', 'Backend' => 'Backend', 'Frontend' => 'Frontend'), $this->filter['application']);
     $this->frm->addText('name', $this->filter['name']);
     $this->frm->addText('value', $this->filter['value']);
     $this->frm->addMultiCheckbox('language', BackendLocaleModel::getLanguagesForMultiCheckbox($this->isGod), $this->filter['language'], 'noFocus');
     $this->frm->addMultiCheckbox('type', BackendLocaleModel::getTypesForMultiCheckbox(), $this->filter['type'], 'noFocus');
     $this->frm->addDropdown('module', BackendModel::getModulesForDropDown(), $this->filter['module']);
     $this->frm->getField('module')->setDefaultElement('-');
     // manually parse fields
     $this->frm->parse($this->tpl);
 }
Example #6
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()), 'STREET_VIEW' => BL::lbl('StreetView', $this->getModule()));
     $mapStyles = array('standard' => BL::lbl('Default', $this->getModule()), 'custom' => BL::lbl('Custom', $this->getModule()), 'gray' => BL::lbl('Gray', $this->getModule()), 'blue' => BL::lbl('Blue', $this->getModule()));
     $zoomLevels = array_combine(array_merge(array('auto'), range(1, 18)), array_merge(array(BL::lbl('Auto', $this->getModule())), range(1, 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']);
     $this->form->addDropdown('map_style', $mapStyles, isset($this->settings['map_style']) ? $this->settings['map_style'] : null);
 }
Example #7
0
 /**
  * Load the form.
  */
 private function loadForm()
 {
     // create form
     $this->frm = new BackendForm('filter', BackendModel::createURLForAction(), 'get');
     // add fields
     $this->frm->addText('email', $this->filter['email']);
     $this->frm->addText('name', $this->filter['name']);
     // get categories
     $groups = BackendMailengineModel::getAllGroupsForDropdown();
     $groups = array("0" => "") + $groups;
     // multiple categories?
     if (count($groups) > 1) {
         // create element
         $this->frm->addDropdown('group', $groups, $this->filter["group"]);
         $this->frm->getField('group')->setDefaultElement('');
     }
     // manually parse fields
     $this->frm->parse($this->tpl);
 }
Example #8
0
 /**
  * Load the form.
  */
 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);
 }
Example #9
0
 /**
  * Parse a field and return the HTML.
  *
  * @param array $field Field data.
  * @return string
  */
 public static function parseField(array $field)
 {
     if (!empty($field)) {
         // init
         $frm = new BackendForm('tmp', '');
         $tpl = BackendModel::getContainer()->has('template') ? BackendModel::getContainer()->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;
         $placeholder = isset($field['settings']['placeholder']) ? $field['settings']['placeholder'] : null;
         /**
          * Create form and parse to HTML
          */
         // dropdown
         if ($field['type'] == 'dropdown') {
             // values and labels are the same
             $values = array_combine($values, $values);
             // 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'] == 'datetime') {
             // create element
             if ($field['settings']['input_type'] == 'date') {
                 // calculate default value
                 $amount = $field['settings']['value_amount'];
                 $type = $field['settings']['value_type'];
                 if ($type != '') {
                     switch ($type) {
                         case 'today':
                             $defaultValues = date('d/m/Y');
                             break;
                         case 'day':
                         case 'week':
                         case 'month':
                         case 'year':
                             if ($amount != '') {
                                 $defaultValues = date('d/m/Y', strtotime('+' . $amount . ' ' . $type));
                             }
                             break;
                     }
                 }
                 $datetime = $frm->addText($fieldName, $defaultValues);
             } else {
                 $datetime = $frm->addTime($fieldName, $defaultValues);
             }
             $datetime->setAttribute('disabled', 'disabled');
             // get content
             $fieldHTML = $datetime->parse();
         } elseif ($field['type'] == 'radiobutton') {
             // create element
             $rbt = $frm->addRadiobutton($fieldName, $values, $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');
             $txt->setAttribute('placeholder', $placeholder);
             // get content
             $fieldHTML = $txt->parse();
         } elseif ($field['type'] == 'textarea') {
             // create element
             $txt = $frm->addTextarea($fieldName, $defaultValues);
             $txt->setAttribute('cols', 30);
             $txt->setAttribute('disabled', 'disabled');
             $txt->setAttribute('placeholder', $placeholder);
             // 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' . \SpoonFilter::ucfirst($fieldName) : 'rbt' . \SpoonFilter::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);
         }
         return $tpl->getContent(BACKEND_MODULES_PATH . '/FormBuilder/Layout/Templates/Field.tpl');
     } else {
         // empty field so return empty string
         return '';
     }
 }
Example #10
0
 /**
  * Load the form
  */
 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', $this->get('fork.settings')->get('Core', 'site_title_' . BL::getWorkingLanguage(), SITE_DEFAULT_TITLE));
     $this->frm->addTextarea('site_html_header', $this->get('fork.settings')->get('Core', 'site_html_header', null), 'textarea code', 'textareaError code', true);
     $this->frm->addTextarea('site_start_of_body_scripts', $this->get('fork.settings')->get('Core', 'site_start_of_body_scripts', null), 'textarea code', 'textareaError code', true);
     $this->frm->addTextarea('site_html_footer', $this->get('fork.settings')->get('Core', 'site_html_footer', null), 'textarea code', 'textareaError code', true);
     $this->frm->addTextarea('site_domains', implode("\n", (array) $this->get('fork.settings')->get('Core', 'site_domains', $defaultDomains)), 'textarea code', 'textareaError code');
     // facebook settings
     $this->frm->addText('facebook_admin_ids', $this->get('fork.settings')->get('Core', 'facebook_admin_ids', null));
     $this->frm->addText('facebook_application_id', $this->get('fork.settings')->get('Core', 'facebook_app_id', null));
     $this->frm->addText('facebook_application_secret', $this->get('fork.settings')->get('Core', 'facebook_app_secret', null));
     // twitter settings
     $this->frm->addText('twitter_site_name', ltrim($this->get('fork.settings')->get('Core', 'twitter_site_name', null), '@'));
     // ckfinder
     $this->frm->addText('ckfinder_license_name', $this->get('fork.settings')->get('Core', 'ckfinder_license_name', null));
     $this->frm->addText('ckfinder_license_key', $this->get('fork.settings')->get('Core', 'ckfinder_license_key', null));
     $this->frm->addText('ckfinder_image_max_width', $this->get('fork.settings')->get('Core', 'ckfinder_image_max_width', 1600));
     $this->frm->addText('ckfinder_image_max_height', $this->get('fork.settings')->get('Core', 'ckfinder_image_max_height', 1200));
     // api keys
     $this->frm->addText('fork_api_public_key', $this->get('fork.settings')->get('Core', 'fork_api_public_key', null));
     $this->frm->addText('fork_api_private_key', $this->get('fork.settings')->get('Core', 'fork_api_private_key', null));
     // date & time formats
     $this->frm->addDropdown('time_format', BackendModel::getTimeFormats(), $this->get('fork.settings')->get('Core', 'time_format'));
     $this->frm->addDropdown('date_format_short', BackendModel::getDateFormatsShort(), $this->get('fork.settings')->get('Core', 'date_format_short'));
     $this->frm->addDropdown('date_format_long', BackendModel::getDateFormatsLong(), $this->get('fork.settings')->get('Core', 'date_format_long'));
     // number formats
     $this->frm->addDropdown('number_format', BackendModel::getNumberFormats(), $this->get('fork.settings')->get('Core', 'number_format'));
     // create a list of the languages
     foreach ($this->get('fork.settings')->get('Core', 'languages', array('en')) 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::lbl(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));
     }
     $hasMultipleLanguages = BackendModel::getContainer()->getParameter('site.multilanguage');
     // create multilanguage checkbox
     $this->frm->addMultiCheckbox('active_languages', $activeLanguages, $this->get('fork.settings')->get('Core', 'active_languages', array($hasMultipleLanguages)));
     $this->frm->addMultiCheckbox('redirect_languages', $redirectLanguages, $this->get('fork.settings')->get('Core', 'redirect_languages', array($hasMultipleLanguages)));
     // api keys are not required for every module
     if ($this->needsAkismet) {
         $this->frm->addText('akismet_key', $this->get('fork.settings')->get('Core', 'akismet_key', null));
     }
     if ($this->needsGoogleMaps) {
         $this->frm->addText('google_maps_key', $this->get('fork.settings')->get('Core', 'google_maps_key', null));
     }
     // cookies
     $this->frm->addCheckbox('show_cookie_bar', $this->get('fork.settings')->get('Core', 'show_cookie_bar', false));
 }
Example #11
0
 /**
  * Parse all datagrids
  */
 protected function parse()
 {
     parent::parse();
     // parse the datagrid for the drafts
     $this->tpl->assign('dgDrafts', (string) $this->dgDrafts->getContent());
     // parse the datagrid for all blogposts
     $this->tpl->assign('dgPosts', (string) $this->dgPosts->getContent());
     // parse the datagrid for the most recent blogposts
     $this->tpl->assign('dgRecent', is_object($this->dgRecent) ? $this->dgRecent->getContent() : false);
     // get categories
     $categories = BackendBlogModel::getCategories(true);
     $hasMultipleCategories = count($categories) > 1;
     $this->tpl->assign('hasMultipleCategories', $hasMultipleCategories);
     // multiple categories?
     if ($hasMultipleCategories) {
         // 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);
     }
 }
Example #12
0
 private function loadFilterForm()
 {
     // get categories
     $groups = BackendAddressesModel::getAllGroupsTree();
     //$groups = array('') + $groups;
     // multiple categories?
     if (count($groups) > 1) {
         // create form
         $frm = new BackendForm('filter', null, 'get', false);
         // create element
         $frm->addDropdown('group', $groups, $this->groupId);
         //			$frm->getField('category')->setDefaultElement('');
         // parse the form
         $frm->parse($this->tpl);
     }
     // parse category
     if (!empty($this->category)) {
         $this->tpl->assign('filterGroup', $this->group);
     }
 }
Example #13
0
 private function loadFilterForm()
 {
     // get categories
     $categories = BackendCatalogModel::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);
     }
 }
Example #14
0
 /**
  * Parse the page
  */
 protected function parse()
 {
     // parse the datagrid for all products
     $this->tpl->assign('dgProducts', $this->dgProducts->getNumResults() != 0 ? $this->dgProducts->getContent() : false);
     // get categories
     $categories = BackendCatalogModel::getCategories(true);
     // multiple categories?
     if (count($categories) > 1) {
         // create form
         $frm = new BackendForm('filter', null, 'get', true);
         // 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);
     }
 }