Example #1
0
 /**
  * Execute the action
  */
 public function execute()
 {
     parent::execute();
     // get parameters
     $id = \SpoonFilter::getPostValue('id', null, 0, 'int');
     $tag = trim(\SpoonFilter::getPostValue('value', null, '', 'string'));
     // validate id
     if ($id === 0) {
         $this->output(self::BAD_REQUEST, null, 'no id provided');
     } else {
         // validate tag name
         if ($tag === '') {
             $this->output(self::BAD_REQUEST, null, BL::err('NameIsRequired'));
         } else {
             // check if tag exists
             if (BackendTagsModel::existsTag($tag)) {
                 $this->output(self::BAD_REQUEST, null, BL::err('TagAlreadyExists'));
             } else {
                 $item['id'] = $id;
                 $item['tag'] = \SpoonFilter::htmlspecialchars($tag);
                 $item['url'] = BackendTagsModel::getURL(CommonUri::getUrl(\SpoonFilter::htmlspecialcharsDecode($item['tag'])), $id);
                 BackendTagsModel::update($item);
                 $this->output(self::OK, $item, vsprintf(BL::msg('Edited'), array($item['tag'])));
             }
         }
     }
 }
Example #2
0
 /**
  * The default constructor
  *
  * @param string $title       The title off the feed.
  * @param string $link        The link of the feed.
  * @param string $description The description of the feed.
  * @param array  $items       An array with SpoonRSSItems.
  */
 public function __construct($title, $link, $description, array $items = array())
 {
     // decode
     $title = \SpoonFilter::htmlspecialcharsDecode($title);
     $description = \SpoonFilter::htmlspecialcharsDecode($description);
     // call the parent
     parent::__construct($title, Model::addURLParameters($link, array('utm_source' => 'feed', 'utm_medium' => 'rss', 'utm_campaign' => CommonUri::getUrl($title))), $description, $items);
     $siteTitle = \SpoonFilter::htmlspecialcharsDecode(Model::get('fork.settings')->get('Core', 'site_title_' . LANGUAGE));
     // set feed properties
     $this->setLanguage(LANGUAGE);
     $this->setCopyright(\SpoonDate::getDate('Y') . ' ' . $siteTitle);
     $this->setGenerator($siteTitle);
     $this->setImage(SITE_URL . FRONTEND_CORE_URL . '/Layout/images/rss_image.png', $title, $link);
     // theme was set
     if (Model::get('fork.settings')->get('Core', 'theme', null) != null) {
         // theme name
         $theme = Model::get('fork.settings')->get('Core', 'theme', null);
         // theme rss image exists
         if (is_file(PATH_WWW . '/src/Frontend/Themes/' . $theme . '/Core/images/rss_image.png')) {
             // set rss image
             $this->setImage(SITE_URL . '/src/Frontend/Themes/' . $theme . '/Core/images/rss_image.png', $title, $link);
         }
     }
 }
Example #3
0
 /**
  * Parse the fields
  */
 private function parseFields()
 {
     $fieldsHTML = array();
     // get fields
     $fields = BackendFormBuilderModel::getFields($this->id);
     // loop fields
     foreach ($fields as $field) {
         // submit button
         if ($field['type'] == 'submit') {
             // assign
             $this->tpl->assign('submitId', $field['id']);
             // add field
             $btn = $this->frm->addButton('submit_field', SpoonFilter::htmlspecialcharsDecode($field['settings']['values']), 'button');
             $btn->setAttribute('disabled', 'disabled');
             // skip
             continue;
         }
         // parse field to html
         $fieldsHTML[]['field'] = FormBuilderHelper::parseField($field);
     }
     // assign iteration
     $this->tpl->assign('fields', $fieldsHTML);
 }
Example #4
0
 /**
  * Retrieve a unique URL for a profile based on the display name.
  *
  * @param  string $displayName The display name to base on.
  * @param  int    $id          The id of the profile to ignore.
  * @return string
  */
 public static function getUrl($displayName, $id = null)
 {
     // decode special chars
     $displayName = \SpoonFilter::htmlspecialcharsDecode((string) $displayName);
     // urlise
     $url = (string) CommonUri::getUrl($displayName);
     // get db
     $db = FrontendModel::getContainer()->get('database');
     // new item
     if ($id === null) {
         // get number of profiles with this URL
         $number = (int) $db->getVar('SELECT 1
              FROM profiles AS p
              WHERE p.url = ?
              LIMIT 1', (string) $url);
         // already exists
         if ($number != 0) {
             // add number
             $url = FrontendModel::addNumber($url);
             // try again
             return self::getURL($url);
         }
     } else {
         // current profile should be excluded
         // get number of profiles with this URL
         $number = (int) $db->getVar('SELECT 1
              FROM profiles AS p
              WHERE p.url = ? AND p.id != ?
              LIMIT 1', array((string) $url, (int) $id));
         // already exists
         if ($number != 0) {
             // add number
             $url = FrontendModel::addNumber($url);
             // try again
             return self::getURL($url, $id);
         }
     }
     return $url;
 }
Example #5
0
    /**
     * Retrieve a unique URL for a profile based on the display name.
     *
     * @param string $displayName The display name to base on.
     * @param int[optional] $id The id of the profile to ignore.
     * @return string
     */
    public static function getUrl($displayName, $id = null)
    {
        // decode specialchars
        $displayName = SpoonFilter::htmlspecialcharsDecode((string) $displayName);
        // urlise
        $url = (string) SpoonFilter::urlise($displayName);
        // get db
        $db = FrontendModel::getDB();
        // new item
        if ($id === null) {
            // get number of profiles with this URL
            $number = (int) $db->getVar('SELECT COUNT(p.id)
				 FROM profiles AS p
				 WHERE p.url = ?', (string) $url);
            // already exists
            if ($number != 0) {
                // add number
                $url = FrontendModel::addNumber($url);
                // try again
                return self::getURL($url);
            }
        } else {
            // get number of profiles with this URL
            $number = (int) $db->getVar('SELECT COUNT(p.id)
				 FROM profiles AS p
				 WHERE p.url = ? AND p.id != ?', array((string) $url, (int) $id));
            // already exists
            if ($number != 0) {
                // add number
                $url = FrontendModel::addNumber($url);
                // try again
                return self::getURL($url, $id);
            }
        }
        return $url;
    }
Example #6
0
 /**
  * Execute the action
  */
 public function execute()
 {
     parent::execute();
     // get parameters
     $formId = \SpoonFilter::getPostValue('form_id', null, '', 'int');
     $fieldId = \SpoonFilter::getPostValue('field_id', null, '', 'int');
     $type = \SpoonFilter::getPostValue('type', array('checkbox', 'dropdown', 'datetime', 'heading', 'paragraph', 'radiobutton', 'submit', 'textarea', 'textbox'), '', 'string');
     $label = trim(\SpoonFilter::getPostValue('label', null, '', 'string'));
     $values = trim(\SpoonFilter::getPostValue('values', null, '', 'string'));
     // this is somewhat a nasty hack, but it makes special chars work.
     $values = \SpoonFilter::htmlspecialcharsDecode($values);
     $defaultValues = trim(\SpoonFilter::getPostValue('default_values', null, '', 'string'));
     $placeholder = trim(\SpoonFilter::getPostValue('placeholder', null, '', 'string'));
     $required = \SpoonFilter::getPostValue('required', array('Y', 'N'), 'N', 'string');
     $requiredErrorMessage = trim(\SpoonFilter::getPostValue('required_error_message', null, '', 'string'));
     $validation = \SpoonFilter::getPostValue('validation', array('email', 'numeric', 'time'), '', 'string');
     $validationParameter = trim(\SpoonFilter::getPostValue('validation_parameter', null, '', 'string'));
     $errorMessage = trim(\SpoonFilter::getPostValue('error_message', null, '', 'string'));
     // special field for textbox: reply to
     $replyTo = \SpoonFilter::getPostValue('reply_to', array('Y', 'N'), 'N', 'string');
     // special fields for datetime
     $inputType = \SpoonFilter::getPostValue('input_type', array('date', 'time'), 'date', 'string');
     $valueAmount = trim(\SpoonFilter::getPostValue('value_amount', null, '', 'string'));
     $valueType = trim(\SpoonFilter::getPostValue('value_type', null, '', 'string'));
     // invalid form id
     if (!BackendFormBuilderModel::exists($formId)) {
         $this->output(self::BAD_REQUEST, null, 'form does not exist');
     } else {
         // invalid fieldId
         if ($fieldId !== 0 && !BackendFormBuilderModel::existsField($fieldId, $formId)) {
             $this->output(self::BAD_REQUEST, null, 'field does not exist');
         } else {
             // invalid type
             if ($type == '') {
                 $this->output(self::BAD_REQUEST, null, 'invalid type provided');
             } else {
                 // extra validation is only possible for textfields & datetime fields
                 if ($type != 'textbox' && $type != 'datetime') {
                     $validation = '';
                     $validationParameter = '';
                     $errorMessage = '';
                 }
                 // init
                 $errors = array();
                 // validate textbox
                 if ($type == 'textbox') {
                     if ($label == '') {
                         $errors['label'] = BL::getError('LabelIsRequired');
                     }
                     if ($required == 'Y' && $requiredErrorMessage == '') {
                         $errors['required_error_message'] = BL::getError('ErrorMessageIsRequired');
                     }
                     if ($validation != '' && $errorMessage == '') {
                         $errors['error_message'] = BL::getError('ErrorMessageIsRequired');
                     }
                     if ($replyTo == 'Y' && $validation != 'email') {
                         $errors['reply_to_error_message'] = BL::getError('EmailValidationIsRequired');
                     }
                 } elseif ($type == 'textarea') {
                     // validate textarea
                     if ($label == '') {
                         $errors['label'] = BL::getError('LabelIsRequired');
                     }
                     if ($required == 'Y' && $requiredErrorMessage == '') {
                         $errors['required_error_message'] = BL::getError('ErrorMessageIsRequired');
                     }
                     if ($validation != '' && $errorMessage == '') {
                         $errors['error_message'] = BL::getError('ErrorMessageIsRequired');
                     }
                 } elseif ($type == 'datetime') {
                     // validate datetime
                     if ($label == '') {
                         $errors['label'] = BL::getError('LabelIsRequired');
                     }
                     if (in_array($valueType, array('day', 'week', 'month', 'year')) && $valueAmount == '') {
                         $errors['default_value_error_message'] = BL::getError('ValueIsRequired');
                     }
                     if ($required == 'Y' && $requiredErrorMessage == '') {
                         $errors['required_error_message'] = BL::getError('ErrorMessageIsRequired');
                     }
                     if ($validation != '' && $errorMessage == '') {
                         $errors['error_message'] = BL::getError('ErrorMessageIsRequired');
                     }
                 } elseif ($type == 'heading' && $values == '') {
                     // validate heading
                     $errors['values'] = BL::getError('ValueIsRequired');
                 } elseif ($type == 'paragraph' && $values == '') {
                     // validate paragraphs
                     $errors['values'] = BL::getError('ValueIsRequired');
                 } elseif ($type == 'submit' && $values == '') {
                     // validate submitbuttons
                     $errors['values'] = BL::getError('ValueIsRequired');
                 } elseif ($type == 'dropdown') {
                     // validate dropdown
                     $values = trim($values, ',');
                     // validate
                     if ($label == '') {
                         $errors['label'] = BL::getError('LabelIsRequired');
                     }
                     if ($required == 'Y' && $requiredErrorMessage == '') {
                         $errors['required_error_message'] = BL::getError('ErrorMessageIsRequired');
                     }
                     if ($values == '') {
                         $errors['values'] = BL::getError('ValueIsRequired');
                     }
                 } elseif ($type == 'radiobutton') {
                     // validate radiobutton
                     if ($label == '') {
                         $errors['label'] = BL::getError('LabelIsRequired');
                     }
                     if ($required == 'Y' && $requiredErrorMessage == '') {
                         $errors['required_error_message'] = BL::getError('ErrorMessageIsRequired');
                     }
                     if ($values == '') {
                         $errors['values'] = BL::getError('ValueIsRequired');
                     }
                 } elseif ($type == 'checkbox') {
                     // validate checkbox
                     if ($label == '') {
                         $errors['label'] = BL::getError('LabelIsRequired');
                     }
                     if ($required == 'Y' && $requiredErrorMessage == '') {
                         $errors['required_error_message'] = BL::getError('ErrorMessageIsRequired');
                     }
                 }
                 // got errors
                 if (!empty($errors)) {
                     $this->output(self::OK, array('errors' => $errors), 'form contains errors');
                 } else {
                     // htmlspecialchars except for paragraphs
                     if ($type != 'paragraph') {
                         if ($values != '') {
                             $values = \SpoonFilter::htmlspecialchars($values);
                         }
                         if ($defaultValues != '') {
                             $defaultValues = \SpoonFilter::htmlspecialchars($defaultValues);
                         }
                     }
                     // split
                     if ($type == 'dropdown' || $type == 'checkbox') {
                         $values = (array) explode('|', $values);
                     } elseif ($type == 'radiobutton') {
                         $postedValues = (array) explode('|', $values);
                         $values = array();
                         foreach ($postedValues as $postedValue) {
                             $values[] = array('value' => CommonUri::getUrl($postedValue), 'label' => $postedValue);
                         }
                     }
                     /**
                      * Save!
                      */
                     // settings
                     $settings = array();
                     if ($label != '') {
                         $settings['label'] = \SpoonFilter::htmlspecialchars($label);
                     }
                     if (isset($values)) {
                         $settings['values'] = $values;
                     }
                     if ($defaultValues != '') {
                         $settings['default_values'] = $defaultValues;
                     }
                     if ($placeholder != '') {
                         $settings['placeholder'] = \SpoonFilter::htmlspecialchars($placeholder);
                     }
                     // reply-to, only for textboxes
                     if ($type == 'textbox') {
                         $settings['reply_to'] = $replyTo == 'Y';
                     }
                     // only for datetime input
                     if ($type == 'datetime') {
                         $settings['input_type'] = $inputType;
                         if ($inputType == 'date') {
                             $settings['value_amount'] = $valueAmount;
                             $settings['value_type'] = $valueType;
                         }
                     }
                     // build array
                     $field = array();
                     $field['form_id'] = $formId;
                     $field['type'] = $type;
                     $field['settings'] = !empty($settings) ? serialize($settings) : null;
                     // existing field
                     if ($fieldId !== 0) {
                         // update field
                         BackendFormBuilderModel::updateField($fieldId, $field);
                         // delete all validation (added again later)
                         BackendFormBuilderModel::deleteFieldValidation($fieldId);
                     } else {
                         // sequence
                         $field['sequence'] = BackendFormBuilderModel::getMaximumSequence($formId) + 1;
                         // insert
                         $fieldId = BackendFormBuilderModel::insertField($field);
                     }
                     // required
                     if ($required == 'Y') {
                         // build array
                         $validate['field_id'] = $fieldId;
                         $validate['type'] = 'required';
                         $validate['error_message'] = \SpoonFilter::htmlspecialchars($requiredErrorMessage);
                         // add validation
                         BackendFormBuilderModel::insertFieldValidation($validate);
                         // add to field (for parsing)
                         $field['validations']['required'] = $validate;
                     }
                     // other validation
                     if ($validation != '') {
                         // build array
                         $validate['field_id'] = $fieldId;
                         $validate['type'] = $validation;
                         $validate['error_message'] = \SpoonFilter::htmlspecialchars($errorMessage);
                         $validate['parameter'] = $validationParameter != '' ? \SpoonFilter::htmlspecialchars($validationParameter) : null;
                         // add validation
                         BackendFormBuilderModel::insertFieldValidation($validate);
                         // add to field (for parsing)
                         $field['validations'][$type] = $validate;
                     }
                     // get item from database (i do this call again to keep the pof as low as possible)
                     $field = BackendFormBuilderModel::getField($fieldId);
                     // submit button isnt parsed but handled directly via javascript
                     if ($type == 'submit') {
                         $fieldHTML = '';
                     } else {
                         // parse field to html
                         $fieldHTML = FormBuilderHelper::parseField($field);
                     }
                     // success output
                     $this->output(self::OK, array('field_id' => $fieldId, 'field_html' => $fieldHTML), 'field saved');
                 }
             }
         }
     }
 }
Example #7
0
 /**
  * Save the link list
  *
  * @param  array  $navigation The full navigation array
  * @param  array  $keys       The page keys
  * @param  string $language   The language to save the file for
  * @return string             The full content for the cache file
  */
 protected function dumpEditorLinkList($navigation, $keys, $language)
 {
     // get the order
     foreach (array_keys($navigation) as $type) {
         $order[$type] = $this->getOrder($navigation, $type, 0);
     }
     // start building the cache file
     $editorLinkListString = $this->getCacheHeader('the links that can be used by the editor');
     // init var
     $links = array();
     // init var
     $cachedTitles = (array) $this->database->getPairs('SELECT i.id, i.navigation_title
          FROM pages AS i
          WHERE i.id IN(' . implode(',', array_keys($keys)) . ')
          AND i.language = ? AND i.status = ?', array($language, 'active'));
     // loop the types in the order we want them to appear
     foreach (array('page', 'meta', 'footer', 'root') as $type) {
         // any pages?
         if (isset($order[$type])) {
             // loop pages
             foreach ($order[$type] as $pageId => $url) {
                 // skip if we don't have a title
                 if (!isset($cachedTitles[$pageId])) {
                     continue;
                 }
                 // get the title
                 $title = \SpoonFilter::htmlspecialcharsDecode($cachedTitles[$pageId]);
                 // split into chunks
                 $urlChunks = explode('/', $url);
                 // remove the language chunk
                 $hasMultiLanguages = BackendModel::getContainer()->getParameter('site.multilanguage');
                 $urlChunks = $hasMultiLanguages ? array_slice($urlChunks, 2) : array_slice($urlChunks, 1);
                 // subpage?
                 if (count($urlChunks) > 1) {
                     // loop while we have more then 1 chunk
                     while (count($urlChunks) > 1) {
                         // remove last chunk of the url
                         array_pop($urlChunks);
                         // build the temporary URL, so we can search for an id
                         $tempUrl = implode('/', $urlChunks);
                         // search the pageID
                         $tempPageId = array_search($tempUrl, $keys);
                         // prepend the title
                         if (!isset($cachedTitles[$tempPageId])) {
                             $title = ' > ' . $title;
                         } else {
                             $title = $cachedTitles[$tempPageId] . ' > ' . $title;
                         }
                     }
                 }
                 // add
                 $links[] = array($title, $url);
             }
         }
     }
     // add JSON-string
     $editorLinkListString .= 'var linkList = ' . json_encode($links) . ';';
     return $editorLinkListString;
 }
Example #8
0
 /**
  * Set the description.
  * All links and images that link to internal files will be prepended with the sites URL
  *
  * @param string $description The content of the item.
  */
 public function setDescription($description)
 {
     // remove special chars
     $description = (string) \SpoonFilter::htmlspecialcharsDecode($description);
     // process links
     $description = $this->processLinks($description);
     // call parent
     parent::setDescription($description);
 }
Example #9
0
 /**
  * Validate the form
  */
 private function validateForm()
 {
     // is the form submitted?
     if ($this->frm->isSubmitted()) {
         // cleanup the submitted fields, ignore fields that were added by hackers
         $this->frm->cleanupFields();
         // validate fields
         $this->frm->getField('name')->isFilled(BL::err('NameIsRequired'));
         // no errors?
         if ($this->frm->isCorrect()) {
             // build tag
             $item['id'] = $this->id;
             $item['tag'] = $this->frm->getField('name')->getValue();
             $item['url'] = BackendTagsModel::getURL(CommonUri::getUrl(\SpoonFilter::htmlspecialcharsDecode($item['tag'])), $this->id);
             // update the item
             BackendTagsModel::update($item);
             // trigger event
             BackendModel::triggerEvent($this->getModule(), 'after_edit', array('item' => $item));
             // everything is saved, so redirect to the overview
             $this->redirect(BackendModel::createURLForAction('Index') . '&report=edited&var=' . urlencode($item['tag']) . '&highlight=row-' . $item['id']);
         }
     }
 }
Example #10
0
 /**
  * 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();
         }
     }
 }
Example #11
0
 /**
  * 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();
         }
     }
 }