Exemplo n.º 1
0
 /**
  * Validate the form
  */
 private function validateForm()
 {
     if ($this->frm->isSubmitted()) {
         $this->frm->cleanupFields();
         // get fields
         $ddmGroup = $this->frm->getField('group');
         $fileFile = $this->frm->getField('file');
         $csv = array();
         // validate input
         $ddmGroup->isFilled(BL::getError('FieldIsRequired'));
         if ($fileFile->isFilled(BL::err('FieldIsRequired'))) {
             if ($fileFile->isAllowedExtension(array('csv'), sprintf(BL::getError('ExtensionNotAllowed'), 'csv'))) {
                 $csv = Csv::fileToArray($fileFile->getTempFileName());
                 if ($csv === false) {
                     $fileFile->addError(BL::getError('InvalidCSV'));
                 }
             }
         }
         if ($this->frm->isCorrect()) {
             // import the profiles
             $overwrite = $this->frm->getField('overwrite_existing')->isChecked();
             $statistics = BackendProfilesModel::importCsv($csv, $ddmGroup->getValue(), $overwrite);
             // trigger event
             BackendModel::triggerEvent($this->getModule(), 'after_import', array('statistics' => $statistics));
             // build redirect url with the right message
             $redirectUrl = BackendModel::createURLForAction('index') . '&report=';
             $redirectUrl .= $overwrite ? 'profiles-imported-and-updated' : 'profiles-imported';
             $redirectUrl .= '&var[]=' . $statistics['count']['inserted'];
             $redirectUrl .= '&var[]=' . $statistics['count']['exists'];
             // everything is saved, so redirect to the overview
             $this->redirect($redirectUrl);
         }
     }
 }
Exemplo n.º 2
0
 /**
  * Validate the form
  */
 private function validateForm()
 {
     if ($this->frm->isSubmitted()) {
         $this->frm->cleanupFields();
         // redefine fields
         /** @var $fileFile \SpoonFormFile */
         $fileFile = $this->frm->getField('file');
         $chkOverwrite = $this->frm->getField('overwrite');
         // name checks
         if ($fileFile->isFilled(BL::err('FieldIsRequired'))) {
             // only xml files allowed
             if ($fileFile->isAllowedExtension(array('xml'), sprintf(BL::getError('ExtensionNotAllowed'), 'xml'))) {
                 // load xml
                 $xml = @simplexml_load_file($fileFile->getTempFileName());
                 // invalid xml
                 if ($xml === false) {
                     $fileFile->addError(BL::getError('InvalidXML'));
                 }
             }
         }
         if ($this->frm->isCorrect()) {
             // import
             $statistics = BackendLocaleModel::importXML($xml, $chkOverwrite->getValue());
             // trigger event
             BackendModel::triggerEvent($this->getModule(), 'after_import', array('statistics' => $statistics));
             // everything is imported, so redirect to the overview
             $this->redirect(BackendModel::createURLForAction('Index') . '&report=imported&var=' . ($statistics['imported'] . '/' . $statistics['total']) . $this->filterQuery);
         }
     }
 }
Exemplo n.º 3
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 field
         $this->frm->getField('synonym')->isFilled(BL::err('SynonymIsRequired'));
         $this->frm->getField('term')->isFilled(BL::err('TermIsRequired'));
         if (BackendSearchModel::existsSynonymByTerm($this->frm->getField('term')->getValue())) {
             $this->frm->getField('term')->addError(BL::err('TermExists'));
         }
         // no errors?
         if ($this->frm->isCorrect()) {
             // build item
             $item = array();
             $item['term'] = $this->frm->getField('term')->getValue();
             $item['synonym'] = $this->frm->getField('synonym')->getValue();
             $item['language'] = BL::getWorkingLanguage();
             // insert the item
             $id = BackendSearchModel::insertSynonym($item);
             // trigger event
             BackendModel::triggerEvent($this->getModule(), 'after_add_synonym', array('item' => $item));
             // everything is saved, so redirect to the overview
             $this->redirect(BackendModel::createURLForAction('Synonyms') . '&report=added-synonym&var=' . rawurlencode($item['term']) . '&highlight=row-' . $id);
         }
     }
 }
Exemplo n.º 4
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();
         // get field
         /** @var $txtName \SpoonFormText */
         $txtName = $this->frm->getField('name');
         // name filled in?
         if ($txtName->isFilled(BL::getError('NameIsRequired'))) {
             // name exists?
             if (BackendProfilesModel::existsGroupName($txtName->getValue())) {
                 // set error
                 $txtName->addError(BL::getError('GroupNameExists'));
             }
         }
         // no errors?
         if ($this->frm->isCorrect()) {
             // build item
             $values['name'] = $txtName->getValue();
             // insert values
             $id = BackendProfilesModel::insertGroup($values);
             // trigger event
             BackendModel::triggerEvent($this->getModule(), 'after_add_group', array('item' => $values));
             // everything is saved, so redirect to the overview
             $this->redirect(BackendModel::createURLForAction('Groups') . '&report=group-added&var=' . rawurlencode($values['name']) . '&highlight=row-' . $id);
         }
     }
 }
Exemplo n.º 5
0
 /**
  * Parse the correct messages into the template
  */
 protected function parse()
 {
     parent::parse();
     // grab the error-type from the parameters
     $errorType = $this->getParameter('type');
     // set correct headers
     switch ($errorType) {
         case 'module-not-allowed':
         case 'action-not-allowed':
             $this->statusCode = Response::HTTP_FORBIDDEN;
             break;
         case 'not-found':
             $this->statusCode = Response::HTTP_NOT_FOUND;
             break;
         default:
             $this->statusCode = Response::HTTP_BAD_REQUEST;
             break;
     }
     // querystring provided?
     if ($this->getParameter('querystring') !== null) {
         // split into file and parameters
         $chunks = explode('?', $this->getParameter('querystring'));
         // get extension
         $extension = pathinfo($chunks[0], PATHINFO_EXTENSION);
         // if the file has an extension it is a non-existing-file
         if ($extension != '' && $extension != $chunks[0]) {
             // give a nice error, so we can detect which file is missing
             throw new ExitException('File not found', 'Requested file (' . htmlspecialchars($this->getParameter('querystring')) . ') not found.', Response::HTTP_NOT_FOUND);
         }
     }
     // assign the correct message into the template
     $this->tpl->assign('message', BL::err(\SpoonFilter::toCamelCase(htmlspecialchars($errorType), '-')));
 }
Exemplo n.º 6
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'])));
             }
         }
     }
 }
Exemplo n.º 7
0
 /**
  * @return bool
  */
 private function isValid()
 {
     $fields = $this->form->getFields();
     if (!$fields['start_date']->isFilled(Language::err('FieldIsRequired')) || !$fields['end_date']->isFilled(Language::err('FieldIsRequired'))) {
         return $this->form->isCorrect();
     }
     if (!$fields['start_date']->isValid(Language::err('DateIsInvalid')) || !$fields['end_date']->isValid(Language::err('DateIsInvalid'))) {
         return $this->form->isCorrect();
     }
     $newStartDate = Model::getUTCTimestamp($fields['start_date']);
     $newEndDate = Model::getUTCTimestamp($fields['end_date']);
     // startdate cannot be before 2005 (earliest valid google startdate)
     if ($newStartDate < mktime(0, 0, 0, 1, 1, 2005)) {
         $fields['start_date']->setError(Language::err('DateRangeIsInvalid'));
     }
     // enddate cannot be in the future
     if ($newEndDate > time()) {
         $fields['start_date']->setError(Language::err('DateRangeIsInvalid'));
     }
     // enddate cannot be before the startdate
     if ($newStartDate > $newEndDate) {
         $fields['start_date']->setError(Language::err('DateRangeIsInvalid'));
     }
     return $this->form->isCorrect();
 }
Exemplo n.º 8
0
 /**
  * Execute the action
  * We will build the classname, require the class and call the execute method.
  */
 public function execute()
 {
     $this->loadConfig();
     // is the requested action available? If not we redirect to the error page.
     if (!$this->config->isActionAvailable($this->action)) {
         // build the url
         $errorUrl = '/' . NAMED_APPLICATION . '/' . $this->get('request')->getLocale() . '/error?type=action-not-allowed';
         // redirect to the error page
         return $this->redirect($errorUrl, 307);
     }
     // build action-class
     $actionClass = 'Backend\\Modules\\' . $this->getModule() . '\\Actions\\' . $this->getAction();
     if ($this->getModule() == 'Core') {
         $actionClass = 'Backend\\Core\\Actions\\' . $this->getAction();
     }
     if (!class_exists($actionClass)) {
         throw new Exception('The class ' . $actionClass . ' could not be found.');
     }
     // get working languages
     $languages = BackendLanguage::getWorkingLanguages();
     $workingLanguages = array();
     // loop languages and build an array that we can assign
     foreach ($languages as $abbreviation => $label) {
         $workingLanguages[] = array('abbr' => $abbreviation, 'label' => $label, 'selected' => $abbreviation == BackendLanguage::getWorkingLanguage());
     }
     // assign the languages
     $this->tpl->assign('workingLanguages', $workingLanguages);
     // create action-object
     /** @var $object BackendBaseAction */
     $object = new $actionClass($this->getKernel());
     $this->getContainer()->get('logger')->info("Executing backend action '{$object->getAction()}' for module '{$object->getModule()}'.");
     $object->execute();
     return $object->getContent();
 }
Exemplo n.º 9
0
 /**
  * Validate the form
  */
 private function validateForm()
 {
     if ($this->frm->isSubmitted()) {
         // cleanup the submitted fields, ignore fields that were added by hackers
         $this->frm->cleanupFields();
         // validate fields
         $this->frm->getField('author')->isFilled(BL::err('AuthorIsRequired'));
         $this->frm->getField('email')->isEmail(BL::err('EmailIsInvalid'));
         $this->frm->getField('text')->isFilled(BL::err('FieldIsRequired'));
         if ($this->frm->getField('website')->isFilled()) {
             $this->frm->getField('website')->isURL(BL::err('InvalidURL'));
         }
         // no errors?
         if ($this->frm->isCorrect()) {
             // build item
             $item['id'] = $this->id;
             $item['status'] = $this->record['status'];
             $item['author'] = $this->frm->getField('author')->getValue();
             $item['email'] = $this->frm->getField('email')->getValue();
             $item['website'] = $this->frm->getField('website')->isFilled() ? $this->frm->getField('website')->getValue() : null;
             $item['text'] = $this->frm->getField('text')->getValue();
             // insert the item
             BackendBlogModel::updateComment($item);
             // trigger event
             BackendModel::triggerEvent($this->getModule(), 'after_edit_comment', array('item' => $item));
             // everything is saved, so redirect to the overview
             $this->redirect(BackendModel::createURLForAction('Comments') . '&report=edited-comment&id=' . $item['id'] . '&highlight=row-' . $item['id'] . '#tab' . \SpoonFilter::toCamelCase($item['status']));
         }
     }
 }
Exemplo n.º 10
0
 /**
  * Execute the action
  */
 public function execute()
 {
     parent::execute();
     // get parameters
     $categoryTitle = trim(\SpoonFilter::getPostValue('value', null, '', 'string'));
     // validate
     if ($categoryTitle === '') {
         $this->output(self::BAD_REQUEST, null, BL::err('TitleIsRequired'));
     } else {
         // get the data
         // build array
         $item['title'] = \SpoonFilter::htmlspecialchars($categoryTitle);
         $item['language'] = BL::getWorkingLanguage();
         $meta['keywords'] = $item['title'];
         $meta['keywords_overwrite'] = 'N';
         $meta['description'] = $item['title'];
         $meta['description_overwrite'] = 'N';
         $meta['title'] = $item['title'];
         $meta['title_overwrite'] = 'N';
         $meta['url'] = BackendBlogModel::getURLForCategory(\SpoonFilter::urlise($item['title']));
         // update
         $item['id'] = BackendBlogModel::insertCategory($item, $meta);
         // output
         $this->output(self::OK, $item, vsprintf(BL::msg('AddedCategory'), array($item['title'])));
     }
 }
Exemplo n.º 11
0
 /**
  * @param KernelInterface $kernel
  */
 public function __construct(KernelInterface $kernel)
 {
     parent::__construct($kernel);
     // store for later use throughout the application
     $this->getContainer()->set('navigation', $this);
     $this->URL = $this->getContainer()->get('url');
     // check if navigation cache file exists
     if (!is_file(self::getCacheDirectory() . 'navigation.php')) {
         $this->buildCache();
     }
     // check if editor_link_list_LANGUAGE.js cache file exists
     if (!is_file(FRONTEND_CACHE_PATH . '/Navigation/editor_link_list_' . BackendLanguage::getWorkingLanguage() . '.js')) {
         BackendPagesModel::buildCache(BackendLanguage::getWorkingLanguage());
     }
     $navigation = array();
     // require navigation-file
     require self::getCacheDirectory() . 'navigation.php';
     // load it
     $this->navigation = (array) $navigation;
     $this->navigation = $this->addActiveStateToNavigation($this->navigation);
     // cleanup navigation (not needed for god user)
     if (!Authentication::getUser()->isGod()) {
         $this->navigation = $this->cleanup($this->navigation);
     }
 }
Exemplo n.º 12
0
 /**
  * Parse into template
  */
 private function parse()
 {
     // get the logged in user
     $authenticatedUser = BackendAuthentication::getUser();
     // check if we need to show the password strength and parse the label
     $this->tpl->assign('showPasswordStrength', $authenticatedUser->getSetting('password_strength') !== 'strong');
     $this->tpl->assign('passwordStrengthLabel', BL::lbl($authenticatedUser->getSetting('password_strength')));
 }
Exemplo n.º 13
0
 /**
  * Loads the settings form
  */
 private function loadForm()
 {
     $this->frm = new BackendForm('settings');
     // add map info (widgets)
     $this->frm->addDropdown('zoom_level_widget', array_combine(array_merge(array('auto'), range(3, 18)), array_merge(array(BL::lbl('Auto', $this->getModule())), range(3, 18))), $this->get('fork.settings')->get($this->URL->getModule(), 'zoom_level_widget', 13));
     $this->frm->addText('width_widget', $this->get('fork.settings')->get($this->URL->getModule(), 'width_widget'));
     $this->frm->addText('height_widget', $this->get('fork.settings')->get($this->URL->getModule(), 'height_widget'));
     $this->frm->addDropdown('map_type_widget', 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())), $this->get('fork.settings')->get($this->URL->getModule(), 'map_type_widget', 'roadmap'));
 }
Exemplo n.º 14
0
 /**
  * Sets the filter based on the $_GET array.
  */
 private function setFilter()
 {
     $this->filter['language'] = $this->getParameter('language', 'array') != '' ? $this->getParameter('language', 'array') : BL::getWorkingLanguage();
     $this->filter['application'] = $this->getParameter('application');
     $this->filter['module'] = $this->getParameter('module');
     $this->filter['type'] = $this->getParameter('type', 'array');
     $this->filter['name'] = $this->getParameter('name');
     $this->filter['value'] = $this->getParameter('value');
     $this->filterQuery = BackendLocaleModel::buildURLQueryByFilter($this->filter);
 }
Exemplo n.º 15
0
 /**
  * Load the datagrid
  */
 public function loadDataGrid()
 {
     $this->dataGrid = new BackendDataGridDB(BackendGroupsModel::QRY_BROWSE);
     // check if this action is allowed
     if (BackendAuthentication::isAllowedAction('Edit')) {
         $this->dataGrid->setColumnURL('name', BackendModel::createURLForAction('Edit') . '&amp;id=[id]');
         $this->dataGrid->setColumnURL('num_users', BackendModel::createURLForAction('Edit') . '&amp;id=[id]#tabUsers');
         $this->dataGrid->addColumn('edit', null, BL::lbl('Edit'), BackendModel::createURLForAction('Edit') . '&amp;id=[id]');
     }
 }
Exemplo n.º 16
0
 /**
  * Execute the action
  */
 public function execute()
 {
     parent::execute();
     $isGod = BackendAuthentication::getUser()->isGod();
     // get possible languages
     if ($isGod) {
         $possibleLanguages = array_unique(array_merge(BL::getWorkingLanguages(), BL::getInterfaceLanguages()));
     } else {
         $possibleLanguages = BL::getWorkingLanguages();
     }
     // get parameters
     $language = \SpoonFilter::getPostValue('language', array_keys($possibleLanguages), null, 'string');
     $module = \SpoonFilter::getPostValue('module', BackendModel::getModules(), null, 'string');
     $name = \SpoonFilter::getPostValue('name', null, null, 'string');
     $type = \SpoonFilter::getPostValue('type', BackendModel::getContainer()->get('database')->getEnumValues('locale', 'type'), null, 'string');
     $application = \SpoonFilter::getPostValue('application', array('Backend', 'Frontend'), null, 'string');
     $value = \SpoonFilter::getPostValue('value', null, null, 'string');
     // validate values
     if (trim($value) == '' || $language == '' || $module == '' || $type == '' || $application == '' || $application == 'Frontend' && $module != 'Core') {
         $error = BL::err('InvalidValue');
     }
     // in case this is a 'act' type, there are special rules concerning possible values
     if ($type == 'act' && !isset($error)) {
         if (rawurlencode($value) != CommonUri::getUrl($value)) {
             $error = BL::err('InvalidActionValue', $this->getModule());
         }
     }
     // no error?
     if (!isset($error)) {
         // build item
         $item['language'] = $language;
         $item['module'] = $module;
         $item['name'] = $name;
         $item['type'] = $type;
         $item['application'] = $application;
         $item['value'] = $value;
         $item['edited_on'] = BackendModel::getUTCDate();
         $item['user_id'] = BackendAuthentication::getUser()->getUserId();
         // does the translation exist?
         if (BackendLocaleModel::existsByName($name, $type, $module, $language, $application)) {
             // add the id to the item
             $item['id'] = (int) BackendLocaleModel::getByName($name, $type, $module, $language, $application);
             // update in db
             BackendLocaleModel::update($item);
         } else {
             // insert in db
             BackendLocaleModel::insert($item);
         }
         // output OK
         $this->output(self::OK);
     } else {
         $this->output(self::ERROR, null, $error);
     }
 }
 /**
  * @return bool
  */
 private function isValid()
 {
     $fileField = $this->form->getField('certificate');
     $emailField = $this->form->getField('email');
     if ($fileField->isFilled(Language::err('FieldIsRequired'))) {
         $fileField->isAllowedExtension(['p12'], Language::err('P12Only'));
     }
     $emailField->isFilled(Language::err('FieldIsRequired'));
     $emailField->isEmail(Language::err('EmailIsInvalid'));
     return $this->form->isCorrect();
 }
Exemplo n.º 18
0
 /**
  * Convert the count in a human readable one.
  *
  * @param int $count The count.
  * @param string $link The link for the count.
  *
  * @return string
  */
 public static function setClickableCount($count, $link)
 {
     $count = (int) $count;
     $link = (string) $link;
     $return = '';
     if ($count > 1) {
         $return = '<a href="' . $link . '">' . $count . ' ' . BL::getLabel('Articles') . '</a>';
     } elseif ($count == 1) {
         $return = '<a href="' . $link . '">' . $count . ' ' . BL::getLabel('Article') . '</a>';
     }
     return $return;
 }
Exemplo n.º 19
0
 /**
  * Load the datagrids
  */
 private function loadDataGrid()
 {
     // create datagrid
     $this->dataGrid = new BackendDataGridDB(BackendExtensionsModel::QRY_BROWSE_TEMPLATES, array($this->selectedTheme));
     // check if this action is allowed
     if (BackendAuthentication::isAllowedAction('EditThemeTemplate')) {
         // set colum URLs
         $this->dataGrid->setColumnURL('title', BackendModel::createURLForAction('EditThemeTemplate') . '&amp;id=[id]');
         // add edit column
         $this->dataGrid->addColumn('edit', null, BL::lbl('Edit'), BackendModel::createURLForAction('EditThemeTemplate') . '&amp;id=[id]', BL::lbl('Edit'));
     }
 }
Exemplo n.º 20
0
 /**
  * This function will return the errors. It is extended so we can do file checks automatically.
  *
  * @return string
  */
 public function getErrors()
 {
     // if the image is bigger then the allowed configuration it won't show up as filled but it is submitted
     // the empty check is added because otherwise this error is shown like 7 times
     if ($this->isSubmitted() && isset($_FILES[$this->getName()]['error']) && empty($this->errors)) {
         $imageError = $_FILES[$this->getName()]['error'];
         if ($imageError === UPLOAD_ERR_INI_SIZE && empty($this->errors)) {
             $this->addError(SpoonFilter::ucfirst(sprintf(BackendLanguage::err('FileTooBig'), Form::getUploadMaxFileSize())));
         }
     }
     return $this->errors;
 }
Exemplo n.º 21
0
 /**
  * Load the datagrid
  */
 private function loadDataGrid()
 {
     $this->dataGrid = new ContentBlockDataGrid(Locale::workingLocale());
     $this->dataGrid->setSortingColumns(['title']);
     // show the hidden status
     $this->dataGrid->addColumn('isHidden', ucfirst(BL::lbl('VisibleOnSite')), '[hidden]');
     $this->dataGrid->setColumnFunction([TemplateModifiers::class, 'showBool'], ['[hidden]', true], 'isHidden');
     // check if this action is allowed
     if (BackendAuthentication::isAllowedAction('Edit')) {
         $editUrl = BackendModel::createURLForAction('Edit', null, null, ['id' => '[id]'], false);
         $this->dataGrid->setColumnURL('title', $editUrl);
         $this->dataGrid->addColumn('edit', null, BL::lbl('Edit'), $editUrl, BL::lbl('Edit'));
     }
 }
Exemplo n.º 22
0
 /**
  * Loads the datagrids
  */
 private function loadDataGrid()
 {
     // create datagrid
     $this->dataGrid = new BackendDataGridDB(BackendSearchModel::QRY_DATAGRID_BROWSE_SYNONYMS, BL::getWorkingLanguage());
     // sorting columns
     $this->dataGrid->setSortingColumns(array('term'), 'term');
     // column function
     $this->dataGrid->setColumnFunction('str_replace', array(',', ', ', '[synonym]'), 'synonym', true);
     // check if this action is allowed
     if (BackendAuthentication::isAllowedAction('EditSynonym')) {
         // set column URLs
         $this->dataGrid->setColumnURL('term', BackendModel::createURLForAction('EditSynonym') . '&amp;id=[id]');
         // add column
         $this->dataGrid->addColumn('edit', null, BL::lbl('Edit'), BackendModel::createURLForAction('EditSynonym') . '&amp;id=[id]', BL::lbl('Edit'));
     }
 }
Exemplo n.º 23
0
 /**
  * Load the datagrid.
  */
 private function loadDataGrid()
 {
     // create datagrid with an overview of all active and undeleted users
     $this->dataGrid = new BackendDataGridDB(BackendUsersModel::QRY_BROWSE, array('N'));
     // check if this action is allowed
     if (BackendAuthentication::isAllowedAction('Edit')) {
         // add column
         $this->dataGrid->addColumn('nickname', \SpoonFilter::ucfirst(BL::lbl('Nickname')), null, BackendModel::createURLForAction('Edit') . '&amp;id=[id]', BL::lbl('Edit'));
         // add edit column
         if (BackendAuthentication::isAllowedAction('Add') || BackendAuthentication::getUser()->isGod()) {
             $this->dataGrid->addColumn('edit', null, BL::lbl('Edit'), BackendModel::createURLForAction('Edit') . '&amp;id=[id]');
         }
     }
     // show the user's nickname
     $this->dataGrid->setColumnFunction(array('Backend\\Modules\\Users\\Engine\\Model', 'getSetting'), array('[id]', 'nickname'), 'nickname', false);
 }
Exemplo n.º 24
0
 /**
  * Validates the form
  */
 private function validateForm()
 {
     // is the form submitted?
     if ($this->frm->isSubmitted()) {
         // no errors ?
         if ($this->frm->isCorrect()) {
             // smtp settings
             $this->get('fork.settings')->set('Core', 'seo_noodp', $this->frm->getField('seo_noodp')->getValue());
             $this->get('fork.settings')->set('Core', 'seo_noydir', $this->frm->getField('seo_noydir')->getValue());
             $this->get('fork.settings')->set('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'));
         }
     }
 }
Exemplo n.º 25
0
 /**
  * Loads the datagrids
  */
 private function loadDataGrid()
 {
     // create datagrid
     $this->dataGrid = new BackendDataGridDB(BackendSearchModel::QRY_DATAGRID_BROWSE_STATISTICS, BL::getWorkingLanguage());
     // hide column
     $this->dataGrid->setColumnsHidden('data');
     // create column
     $this->dataGrid->addColumn('referrer', BL::lbl('Referrer'));
     // header labels
     $this->dataGrid->setHeaderLabels(array('time' => \SpoonFilter::ucfirst(BL::lbl('SearchedOn'))));
     // set column function
     $this->dataGrid->setColumnFunction(array(__CLASS__, 'setReferrer'), '[data]', 'referrer');
     $this->dataGrid->setColumnFunction(array(new BackendDataGridFunctions(), 'getLongDate'), array('[time]'), 'time', true);
     // sorting columns
     $this->dataGrid->setSortingColumns(array('time', 'term'), 'time');
     $this->dataGrid->setSortParameter('desc');
 }
Exemplo n.º 26
0
 /**
  * Execute the action
  */
 public function execute()
 {
     parent::execute();
     $generalSettings = $this->get('fork.settings')->getForModule('Location');
     // get parameters
     $itemId = \SpoonFilter::getPostValue('id', null, null, 'int');
     $zoomLevel = trim(\SpoonFilter::getPostValue('zoom', null, 'auto'));
     $mapType = strtoupper(trim(\SpoonFilter::getPostValue('type', array('roadmap', 'satellite', 'hybrid', 'terrain', 'street_view'), 'roadmap')));
     $mapStyle = trim(\SpoonFilter::getPostValue('style', array('standard', 'custom', 'gray', 'blue'), 'standard'));
     $centerLat = \SpoonFilter::getPostValue('centerLat', null, 1, 'float');
     $centerlng = \SpoonFilter::getPostValue('centerLng', null, 1, 'float');
     $height = \SpoonFilter::getPostValue('height', null, $generalSettings['height'], 'int');
     $width = \SpoonFilter::getPostValue('width', null, $generalSettings['width'], 'int');
     $showLink = \SpoonFilter::getPostValue('link', array('true', 'false'), 'false', 'string');
     $showDirections = \SpoonFilter::getPostValue('directions', array('true', 'false'), 'false', 'string');
     $showOverview = \SpoonFilter::getPostValue('showOverview', array('true', 'false'), 'true', 'string');
     // reformat
     $center = array('lat' => $centerLat, 'lng' => $centerlng);
     $showLink = $showLink == 'true';
     $showDirections = $showDirections == 'true';
     $showOverview = $showOverview == 'true';
     // standard dimensions
     if ($width > 800) {
         $width = 800;
     }
     if ($width < 300) {
         $width = $generalSettings['width'];
     }
     if ($height < 150) {
         $height = $generalSettings['height'];
     }
     // no id given, this means we should update the main map
     BackendLocationModel::setMapSetting($itemId, 'zoom_level', (string) $zoomLevel);
     BackendLocationModel::setMapSetting($itemId, 'map_type', (string) $mapType);
     BackendLocationModel::setMapSetting($itemId, 'map_style', (string) $mapStyle);
     BackendLocationModel::setMapSetting($itemId, 'center', (array) $center);
     BackendLocationModel::setMapSetting($itemId, 'height', (int) $height);
     BackendLocationModel::setMapSetting($itemId, 'width', (int) $width);
     BackendLocationModel::setMapSetting($itemId, 'directions', $showDirections);
     BackendLocationModel::setMapSetting($itemId, 'full_url', $showLink);
     $item = array('id' => $itemId, 'language' => BL::getWorkingLanguage(), 'show_overview' => $showOverview ? 'Y' : 'N');
     BackendLocationModel::update($item);
     // output
     $this->output(self::OK, null, BL::msg('Success'));
 }
Exemplo n.º 27
0
 public function configureOptions(OptionsResolver $optionsResolver)
 {
     $optionsResolver->setDefaults(['attr' => ['class' => 'inputEditor']]);
     if (!Model::has('header')) {
         return;
     }
     // add the needed javascript to the header;
     $header = Model::get('header');
     // we add JS because we need CKEditor
     $header->addJS('ckeditor/ckeditor.js', 'Core', false);
     $header->addJS('ckeditor/adapters/jquery.js', 'Core', false);
     $header->addJS('ckfinder/ckfinder.js', 'Core', false);
     // add the internal link lists-file
     if (is_file(FRONTEND_CACHE_PATH . '/Navigation/editor_link_list_' . Language::getWorkingLanguage() . '.js')) {
         $timestamp = @filemtime(FRONTEND_CACHE_PATH . '/Navigation/editor_link_list_' . Language::getWorkingLanguage() . '.js');
         $header->addJS('/src/Frontend/Cache/Navigation/editor_link_list_' . Language::getWorkingLanguage() . '.js?m=' . $timestamp, null, false, true, false);
     }
 }
Exemplo n.º 28
0
 /**
  * Execute the action
  */
 public function execute()
 {
     parent::execute();
     // get parameters
     $itemId = trim(\SpoonFilter::getPostValue('id', null, '', 'int'));
     $lat = \SpoonFilter::getPostValue('lat', null, null, 'float');
     $lng = \SpoonFilter::getPostValue('lng', null, null, 'float');
     // validate id
     if ($itemId == 0) {
         $this->output(self::BAD_REQUEST, null, BL::err('NonExisting'));
     } else {
         //update
         $updateData = array('id' => $itemId, 'lat' => $lat, 'lng' => $lng, 'language' => BL::getWorkingLanguage());
         BackendLocationModel::update($updateData);
         // output
         $this->output(self::OK);
     }
 }
Exemplo n.º 29
0
 /**
  * Execute the action
  */
 public function execute()
 {
     parent::execute();
     $questionId = \SpoonFilter::getPostValue('questionId', null, '', 'int');
     $fromCategoryId = \SpoonFilter::getPostValue('fromCategoryId', null, '', 'int');
     $toCategoryId = \SpoonFilter::getPostValue('toCategoryId', null, '', 'int');
     $fromCategorySequence = \SpoonFilter::getPostValue('fromCategorySequence', null, '', 'string');
     $toCategorySequence = \SpoonFilter::getPostValue('toCategorySequence', null, '', 'string');
     // invalid question id
     if (!BackendFaqModel::exists($questionId)) {
         $this->output(self::BAD_REQUEST, null, 'question does not exist');
     } else {
         // list ids
         $fromCategorySequence = (array) explode(',', ltrim($fromCategorySequence, ','));
         $toCategorySequence = (array) explode(',', ltrim($toCategorySequence, ','));
         // is the question moved to a new category?
         if ($fromCategoryId != $toCategoryId) {
             $item['id'] = $questionId;
             $item['category_id'] = $toCategoryId;
             BackendFaqModel::update($item);
             // loop id's and set new sequence
             foreach ($toCategorySequence as $i => $id) {
                 $item = array();
                 $item['id'] = (int) $id;
                 $item['sequence'] = $i + 1;
                 // update sequence if the item exists
                 if (BackendFaqModel::exists($item['id'])) {
                     BackendFaqModel::update($item);
                 }
             }
         }
         // loop id's and set new sequence
         foreach ($fromCategorySequence as $i => $id) {
             $item['id'] = (int) $id;
             $item['sequence'] = $i + 1;
             // update sequence if the item exists
             if (BackendFaqModel::exists($item['id'])) {
                 BackendFaqModel::update($item);
             }
         }
         // success output
         $this->output(self::OK, null, Language::msg('SequenceSaved'));
     }
 }
Exemplo n.º 30
0
 /**
  * Execute the action
  */
 public function execute()
 {
     // get parameters
     $this->id = $this->getParameter('id', 'int');
     // does the item exist
     if ($this->id !== null && BackendPagesModel::exists($this->id)) {
         // call parent, this will probably add some general CSS/JS or other required files
         parent::execute();
         // init var
         $success = false;
         // cannot have children
         if (BackendPagesModel::getFirstChildId($this->id) !== false) {
             $this->redirect(BackendModel::createURLForAction('Edit') . '&error=non-existing');
         }
         $revisionId = $this->getParameter('revision_id', 'int');
         if ($revisionId == 0) {
             $revisionId = null;
         }
         // get page (we need the title)
         $page = BackendPagesModel::get($this->id, $revisionId);
         // valid page?
         if (!empty($page)) {
             // delete the page
             $success = BackendPagesModel::delete($this->id, null, $revisionId);
             // trigger event
             BackendModel::triggerEvent($this->getModule(), 'after_delete', array('id' => $this->id));
             // delete search indexes
             BackendSearchModel::removeIndex($this->getModule(), $this->id);
             // build cache
             BackendPagesModel::buildCache(BL::getWorkingLanguage());
         }
         // page is deleted, so redirect to the overview
         if ($success) {
             $this->redirect(BackendModel::createURLForAction('Index') . '&id=' . $page['parent_id'] . '&report=deleted&var=' . rawurlencode($page['title']));
         } else {
             $this->redirect(BackendModel::createURLForAction('Edit') . '&error=non-existing');
         }
     } else {
         $this->redirect(BackendModel::createURLForAction('Edit') . '&error=non-existing');
     }
 }