Пример #1
0
 /**
  * Execute the action
  */
 public function execute()
 {
     parent::execute();
     BackendCatalogModel::deleteCompletedOrders();
     // item was deleted, so redirect
     $this->redirect(BackendModel::createURLForAction('orders') . '&report=deleted-completed#tabCompleted');
 }
Пример #2
0
 /**
  * Execute the action
  */
 public function execute()
 {
     parent::execute();
     BackendCatalogModel::deleteSpamComments();
     // item was deleted, so redirect
     $this->redirect(BackendModel::createURLForAction('comments') . '&report=deleted-spam#tabSpam');
 }
Пример #3
0
 /**
  * Validate the form
  */
 private function validateForm()
 {
     if ($this->frm->isSubmitted()) {
         $this->frm->cleanupFields();
         // validate fields
         $this->meta->validate();
         if ($this->frm->isCorrect()) {
             // build item
             $item['language'] = BL::getWorkingLanguage();
             $item['meta_id'] = $this->meta->save();
             $item['sequence'] = BackendCatalogModel::getMaximumSpecificationSequence() + 1;
             // save the data
             $item['id'] = BackendCatalogModel::insertSpecification($item);
             //--Add the languages
             foreach ((array) BackendModel::get('fork.settings')->get('Core', 'languages') as $key => $language) {
                 $itemLanguage = array();
                 $itemLanguage['id'] = $item['id'];
                 $itemLanguage['language'] = $language;
                 $itemLanguage['title'] = $this->frm->getField('title_' . $language)->getValue();
                 BackendCatalogModel::insertSpecificationLanguage($itemLanguage);
             }
             // trigger event
             BackendModel::triggerEvent($this->getModule(), 'after_add_specification', array('item' => $item));
             // everything is saved, so redirect to the overview
             $this->redirect(BackendModel::createURLForAction('specifications') . '&report=added-specification&var=' . urlencode($this->frm->getField('title_nl')->getValue()) . '&highlight=row-' . $item['id']);
         }
     }
 }
Пример #4
0
 /**
  * Execute the action
  */
 public function execute()
 {
     $this->id = $this->getParameter('id', 'int');
     // does the item exist
     if ($this->id == null || !BackendCatalogModel::existsBrand($this->id)) {
         $this->redirect(BackendModel::createURLForAction('brands') . '&error=non-existing');
     }
     // fetch the brand
     $this->record = (array) BackendCatalogModel::getBrand($this->id);
     // delete item
     BackendCatalogModel::deleteBrand($this->id);
     // trigger event
     BackendModel::triggerEvent($this->getModule(), 'after_delete_brand', array('item' => $this->record));
     // brand was deleted, so redirect
     $this->redirect(BackendModel::createURLForAction('brands') . '&report=deleted-brand&var=' . urlencode($this->record['title']));
 }
Пример #5
0
 /**
  * Validate the form
  */
 private function validateForm()
 {
     if ($this->frm->isSubmitted()) {
         $this->frm->cleanupFields();
         // validate fields
         $this->frm->getField('title')->isFilled(BL::err('TitleIsRequired'));
         if ($this->frm->getField('image')->isFilled()) {
             $this->frm->getField('image')->isAllowedExtension(array('jpg', 'png', 'gif', 'jpeg'), BL::err('JPGGIFAndPNGOnly'));
             $this->frm->getField('image')->isAllowedMimeType(array('image/jpg', 'image/png', 'image/gif', 'image/jpeg'), BL::err('JPGGIFAndPNGOnly'));
         }
         $this->meta->validate();
         if ($this->frm->isCorrect()) {
             // build item
             $item['title'] = $this->frm->getField('title')->getValue();
             $item['meta_id'] = $this->meta->save();
             $item['sequence'] = BackendCatalogModel::getMaximumCategorySequence() + 1;
             $item['language'] = Language::getWorkingLanguage();
             // the image path
             $imagePath = FRONTEND_FILES_PATH . '/catalog/brands';
             // create folders if needed
             $fs = new Filesystem();
             if (!$fs->exists($imagePath . '/source')) {
                 $fs->mkdir($imagePath . '/source');
             }
             if (!$fs->exists($imagePath . '/150x150')) {
                 $fs->mkdir($imagePath . '/150x150');
             }
             // is there an image provided?
             if ($this->frm->getField('image')->isFilled()) {
                 // build the image name
                 $item['image'] = $this->meta->getUrl() . '.' . $this->frm->getField('image')->getExtension();
                 // upload the image & generate thumbnails
                 $this->frm->getField('image')->generateThumbnails($imagePath, $item['image']);
             }
             // save the data
             $item['id'] = BackendCatalogModel::insertBrand($item);
             // trigger event
             BackendModel::triggerEvent($this->getModule(), 'after_add_brand', array('item' => $item));
             // everything is saved, so redirect to the overview
             $this->redirect(BackendModel::createURLForAction('brands') . '&report=added-brand&var=' . urlencode($item['title']) . '&highlight=row-' . $item['id']);
         }
     }
 }
Пример #6
0
 public function execute()
 {
     parent::execute();
     // get parameters
     $newIdSequence = trim(\SpoonFilter::getPostValue('new_id_sequence', null, '', 'string'));
     // list id
     $ids = (array) explode(',', rtrim($newIdSequence, ','));
     // loop id's and set new sequence
     foreach ($ids as $i => $id) {
         $item['id'] = $id;
         $item['sequence'] = $i + 1;
         // update sequence
         if (BackendCatalogModel::existsBrand($id)) {
             BackendCatalogModel::updateBrand($item);
         }
     }
     // success output
     $this->output(self::OK, null, 'sequence updated');
 }
Пример #7
0
 /**
  * Execute the action
  */
 public function execute()
 {
     $this->id = $this->getParameter('id', 'int');
     // does the item exist
     if ($this->id !== null && BackendCatalogModel::exists($this->id)) {
         parent::execute();
         $this->record = BackendCatalogModel::get($this->id);
         // clean the tags
         BackendTagsModel::saveTags($this->id, '', $this->URL->getModule());
         // clean the related products
         BackendCatalogModel::saveRelatedProducts($this->id, array());
         // delete record
         BackendCatalogModel::delete($this->id);
         // delete search indexes
         BackendSearchModel::removeIndex($this->getModule(), $this->id);
         BackendModel::triggerEvent($this->getModule(), 'after_delete', array('id' => $this->id));
         $this->redirect(BackendModel::createURLForAction('index') . '&report=deleted&var=' . urlencode($this->record['title']));
     } else {
         $this->redirect(BackendModel::createURLForAction('index') . '&error=non-existing');
     }
 }
Пример #8
0
 /**
  * Execute the action
  */
 public function execute()
 {
     // call parent, this will probably add some general CSS/JS or other required files
     parent::execute();
     // get parameters
     $newIdSequence = trim(\SpoonFilter::getPostValue('new_id_sequence', null, '', 'string'));
     // list id
     $ids = (array) explode(',', rtrim($newIdSequence, ','));
     // loop id's and set new sequence
     foreach ($ids as $i => $id) {
         // build item
         $item['id'] = (int) $id;
         // change sequence
         $item['sequence'] = $i + 1;
         // update sequence
         if (BackendCatalogModel::existsImage($item['id'])) {
             BackendCatalogModel::updateImage($item);
         }
     }
     // success output
     $this->output(self::OK, null, 'sequence updated');
 }
Пример #9
0
 /**
  * Execute the action
  */
 public function execute()
 {
     parent::execute();
     // current status
     $from = \SpoonFilter::getGetValue('from', array('moderation', 'completed'), 'moderation');
     // action to execute
     $action = \SpoonFilter::getGetValue('action', array('moderation', 'completed', 'delete'), 'completed');
     // no id's provided
     if (!isset($_GET['id'])) {
         $this->redirect(BackendModel::createURLForAction('orders') . '&error=no-orders-selected');
     }
     // redefine id's
     $ids = (array) $_GET['id'];
     // delete comment(s)
     if ($action == 'delete') {
         BackendCatalogModel::deleteOrders($ids);
     }
     if ($action == 'completed') {
         BackendCatalogModel::updateOrderStatuses($ids, $action);
     }
     if ($action == 'moderation') {
         BackendCatalogModel::updateOrderStatuses($ids, $action);
     }
     // define report
     $report = count($ids) > 1 ? 'orders-' : 'order-';
     // init var
     if ($action == 'moderation') {
         $report .= 'moved-moderation';
     }
     if ($action == 'completed') {
         $report .= 'moved-completed';
     }
     if ($action == 'delete') {
         $report .= 'deleted';
     }
     // redirect
     $this->redirect(BackendModel::createURLForAction('orders') . '&report=' . $report . '#tab' . ucfirst($from));
 }
Пример #10
0
 /**
  * Execute the action
  */
 public function execute()
 {
     parent::execute();
     // action to execute
     $action = \SpoonFilter::getGetValue('action', array('deleteImages', 'deleteFiles', 'deleteVideos'), 'delete');
     if (!isset($_GET['id'])) {
         $this->redirect(BackendModel::createURLForAction('index') . '&error=no-selection');
     } else {
         // at least one id
         // redefine id's
         $aIds = (array) $_GET['id'];
         $slideshowID = (int) $_GET['product_id'];
         // delete media
         if ($action == 'deleteImages') {
             BackendCatalogModel::deleteImage($aIds);
         } elseif ($action == 'deleteFiles') {
             BackendCatalogModel::deleteFile($aIds);
         } elseif ($action == 'deleteVideos') {
             BackendCatalogModel::deleteVideo($aIds);
         }
     }
     $this->redirect(BackendModel::createURLForAction('media') . '&product_id=' . $slideshowID . '&report=deleted');
 }
Пример #11
0
 /**
  * Validate the form
  */
 protected 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
         $file = $this->frm->getField('file');
         $this->frm->getField('title')->isFilled(BL::err('NameIsRequired'));
         if ($this->file['filename'] === null) {
             $file->isFilled(BL::err('FieldIsRequired'));
         }
         // validate the file
         if ($this->frm->getField('file')->isFilled()) {
             // file extension
             $this->frm->getField('file')->isAllowedExtension($this->allowedExtensions, BL::err('FileExtensionNotAllowed'));
         }
         // no errors?
         if ($this->frm->isCorrect()) {
             // build image record to insert
             $item['id'] = $this->id;
             $item['title'] = $this->frm->getField('title')->getValue();
             $item['filename'] = $this->file['filename'];
             // the file path
             $filePath = FRONTEND_FILES_PATH . '/' . $this->getModule() . '/' . $item['id'] . '/source';
             if ($file->isFilled()) {
                 $item['filename'] = time() . '.' . $file->getExtension();
                 $file->moveFile($filePath . '/' . $item['filename']);
             }
             // save the item
             $id = BackendCatalogModel::saveFile($item);
             // trigger event
             BackendModel::triggerEvent($this->getModule(), 'after_edit_file', array('item' => $item));
             // everything is saved, so redirect to the overview
             $this->redirect(BackendModel::createURLForAction('media') . '&product_id=' . $this->product['id'] . '&report=edited&var=' . urlencode($item['title']) . '&highlight=row-' . $id . '#tabFiles');
         }
     }
 }
Пример #12
0
 /**
  * Validate the form
  */
 protected function validateForm()
 {
     if ($this->frm->isSubmitted()) {
         $this->frm->cleanupFields();
         // validation
         $fields = $this->frm->getFields();
         // required fields
         $fields['category_id']->isFilled(BL::err('FieldIsRequired'));
         if ($fields['category_id']->getValue() == 'no_category') {
             $fields['category_id']->addError(BL::err('FieldIsRequired'));
         }
         // validate meta
         $this->meta->validate();
         if ($this->frm->isCorrect()) {
             // build the item
             $item['language'] = BL::getWorkingLanguage();
             $item['price'] = $fields['price']->getValue();
             $item['summary'] = $fields['summary_nl']->getValue();
             $item['text'] = $fields['text_nl']->getValue();
             $item['allow_comments'] = $fields['allow_comments']->getChecked() ? 'Y' : 'N';
             $item['num_comments'] = 0;
             $item['sequence'] = BackendCatalogModel::getMaximumSequence() + 1;
             $item['category_id'] = $fields['category_id']->getValue();
             $item['brand_id'] = $fields['brand_id']->getValue();
             $item['meta_id'] = $this->meta->save();
             $item['ballcolor'] = $fields['ballcolor']->getValue();
             $item['frontpage'] = $fields['frontpage']->getChecked();
             $item['contact'] = $fields['contact']->getChecked();
             // insert it
             $item['id'] = BackendCatalogModel::insert($item);
             //--Add the languages
             foreach ((array) BackendModel::get('fork.settings')->get('Core', 'languages') as $key => $language) {
                 $itemLanguage = array();
                 $itemLanguage['id'] = $item['id'];
                 $itemLanguage['language'] = $language;
                 $itemLanguage['title'] = $this->frm->getField('title_' . $language)->getValue();
                 $itemLanguage['text'] = $this->frm->getField('text_' . $language)->getValue();
                 $itemLanguage['summary'] = $this->frm->getField('summary_' . $language)->getValue();
                 $itemLanguage['url'] = BackendCatalogModel::getURLLanguage($this->frm->getField('title_' . $language)->getValue(), null, $language);
                 $itemLanguage['balltext'] = $this->frm->getField('balltext_' . $language)->getValue();
                 BackendCatalogModel::insertLanguage($itemLanguage);
             }
             $specificationArray = array();
             // loop trough specifications and insert values
             foreach ($this->specifications as $specification) {
                 // build the specification
                 $specificationArray['product_id'] = $item['id'];
                 $specificationArray['specification_id'] = $specification['id'];
                 foreach ((array) BackendModel::get('fork.settings')->get('Core', 'languages') as $key => $language) {
                     $field = 'specification' . $specification['id'] . '_' . $language;
                     // check if there is an value
                     if ($fields[$field]->getValue() != null) {
                         $specificationArray['value'] = $fields[$field]->getValue();
                         $specificationArray['language'] = $language;
                         // insert specification with product id and value
                         BackendCatalogModel::insertSpecificationValue($specificationArray);
                     }
                 }
             }
             // save the tags
             BackendTagsModel::saveTags($item['id'], $fields['tags']->getValue(), $this->URL->getModule());
             // save the related products
             BackendCatalogModel::saveRelatedProducts($item['id'], $this->frm->getField('related_products')->getValue());
             // add search index
             BackendSearchModel::saveIndex($this->getModule(), $item['id'], array('title' => $this->frm->getField('title_nl')->getValue(), 'summary' => $this->frm->getField('summary_nl')->getValue(), 'text' => $this->frm->getField('text_nl')->getValue()));
             // trigger event
             BackendModel::triggerEvent($this->getModule(), 'after_add', $item);
             // redirect page
             $this->redirect(BackendModel::createURLForAction('index') . '&report=added&highlight=row-' . $item['id']);
         }
     }
 }
Пример #13
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
         $file = $this->frm->getField('file');
         $this->frm->getField('title')->isFilled(BL::err('NameIsRequired'));
         $file->isFilled(BL::err('FieldIsRequired'));
         // validate the file
         if ($this->frm->getField('file')->isFilled()) {
             // file extension
             $this->frm->getField('file')->isAllowedExtension($this->allowedExtensions, BL::err('FileExtensionNotAllowed'));
         }
         // no errors?
         if ($this->frm->isCorrect()) {
             // build file record to insert
             $item['product_id'] = $this->product['id'];
             $item['title'] = $this->frm->getField('title')->getValue();
             // the file path
             $filePath = FRONTEND_FILES_PATH . '/' . $this->getModule() . '/' . $item['product_id'] . '/source';
             // create folders if needed
             $fs = new Filesystem();
             if (!$fs->exists($filePath)) {
                 $fs->mkdir($filePath);
             }
             // file provided?
             if ($file->isFilled()) {
                 // build the file name
                 $item['filename'] = time() . '.' . $file->getExtension();
                 // upload the file
                 $file->moveFile($filePath . '/' . $item['filename']);
             }
             $item['sequence'] = BackendCatalogModel::getMaximumFilesSequence($item['product_id']) + 1;
             // insert it
             $item['id'] = BackendCatalogModel::saveFile($item);
             // trigger event
             BackendModel::triggerEvent($this->getModule(), 'after_add_file', array('item' => $item));
             // everything is saved, so redirect to the overview
             $this->redirect(BackendModel::createURLForAction('media') . '&product_id=' . $item['product_id'] . '&report=added&var=' . urlencode($item['title']) . '&highlight=row-' . $item['id'] . '#tabFiles');
         }
     }
 }
Пример #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);
     }
 }
Пример #15
0
 /**
  * Execute the action
  */
 public function execute()
 {
     parent::execute();
     // current status
     $from = \SpoonFilter::getGetValue('from', array('published', 'moderation', 'spam'), 'published');
     // action to execute
     $action = \SpoonFilter::getGetValue('action', array('published', 'moderation', 'spam', 'delete'), 'spam');
     // no id's provided
     if (!isset($_GET['id'])) {
         $this->redirect(BackendModel::createURLForAction('comments') . '&error=no-comments-selected');
     }
     // redefine id's
     $ids = (array) $_GET['id'];
     // delete comment(s)
     if ($action == 'delete') {
         BackendCatalogModel::deleteComments($ids);
     } elseif ($action == 'spam') {
         // is the spamfilter active?
         if (BackendModel::getModuleSetting($this->URL->getModule(), 'spamfilter', false)) {
             // get data
             $comments = BackendCatalogModel::getComments($ids);
             // loop comments
             foreach ($comments as $row) {
                 // unserialize data
                 $row['data'] = unserialize($row['data']);
                 // check if needed data is available
                 if (!isset($row['data']['server']['REMOTE_ADDR'])) {
                     continue;
                 }
                 if (!isset($row['data']['server']['HTTP_USER_AGENT'])) {
                     continue;
                 }
                 // build vars
                 $userIp = $row['data']['server']['REMOTE_ADDR'];
                 $userAgent = $row['data']['server']['HTTP_USER_AGENT'];
                 $content = $row['text'];
                 $author = $row['author'];
                 $email = $row['email'];
                 $url = isset($row['website']) && $row['website'] != '' ? $row['website'] : null;
                 $referrer = isset($row['data']['server']['HTTP_REFERER']) ? $row['data']['server']['HTTP_REFERER'] : null;
                 $others = $row['data']['server'];
                 // submit as spam
                 BackendModel::submitSpam($userIp, $userAgent, $content, $author, $email, $url, null, 'comment', $referrer, $others);
             }
         }
         // set new status
         BackendCatalogModel::updateCommentStatuses($ids, $action);
     } else {
         // other actions data
         // published?
         if ($action == 'published') {
             // is the spamfilter active?
             if (BackendModel::getModuleSetting($this->URL->getModule(), 'spamfilter', false)) {
                 // get data
                 $comments = BackendCatalogModel::getComments($ids);
                 // loop comments
                 foreach ($comments as $row) {
                     // previous status is spam
                     if ($row['status'] == 'spam') {
                         // unserialize data
                         $row['data'] = unserialize($row['data']);
                         // check if needed data is available
                         if (!isset($row['data']['server']['REMOTE_ADDR'])) {
                             continue;
                         }
                         if (!isset($row['data']['server']['HTTP_USER_AGENT'])) {
                             continue;
                         }
                         // build vars
                         $userIp = $row['data']['server']['REMOTE_ADDR'];
                         $userAgent = $row['data']['server']['HTTP_USER_AGENT'];
                         $content = $row['text'];
                         $author = $row['author'];
                         $email = $row['email'];
                         $url = isset($row['website']) && $row['website'] != '' ? $row['website'] : null;
                         $referrer = isset($row['data']['server']['HTTP_REFERER']) ? $row['data']['server']['HTTP_REFERER'] : null;
                         $others = $row['data']['server'];
                         // submit as spam
                         BackendModel::submitHam($userIp, $userAgent, $content, $author, $email, $url, null, 'comment', $referrer, $others);
                     }
                 }
             }
         }
         // set new status
         BackendCatalogModel::updateCommentStatuses($ids, $action);
     }
     // define report
     $report = count($ids) > 1 ? 'comments-' : 'comment-';
     // init var
     if ($action == 'published') {
         $report .= 'moved-published';
     }
     if ($action == 'moderation') {
         $report .= 'moved-moderation';
     }
     if ($action == 'spam') {
         $report .= 'moved-spam';
     }
     if ($action == 'delete') {
         $report .= 'deleted';
     }
     // redirect
     $this->redirect(BackendModel::createURLForAction('comments') . '&report=' . $report . '#tab' . ucfirst($from));
 }
Пример #16
0
 /**
  * Validate the form
  */
 private function validateForm()
 {
     if ($this->frm->isSubmitted()) {
         $this->frm->cleanupFields();
         $recordId = $this->record['id'];
         $newParent = $this->frm->getField('parent_id')->getValue();
         if ($recordId == $newParent) {
             $this->frm->getField('parent_id')->setError(BL::err('SameCategory'));
         }
         // validate fields
         if ($this->frm->getField('image')->isFilled()) {
             $this->frm->getField('image')->isAllowedExtension(array('jpg', 'png', 'gif', 'jpeg'), BL::err('JPGGIFAndPNGOnly'));
             $this->frm->getField('image')->isAllowedMimeType(array('image/jpg', 'image/png', 'image/gif', 'image/jpeg'), BL::err('JPGGIFAndPNGOnly'));
         }
         $this->meta->validate();
         //--Validate Media
         $this->media->validate();
         if ($this->frm->isCorrect()) {
             // build item
             $item['id'] = $this->id;
             $item['language'] = $this->record['language'];
             $item['extra_id'] = $this->record['extra_id'];
             $item['title'] = $this->frm->getField('title_nl')->getValue();
             $item['parent_id'] = $this->frm->getField('parent_id')->getValue();
             $item['meta_id'] = $this->meta->save(true);
             $item['ballcolor'] = $this->frm->getField('ballcolor')->getValue();
             // the image path
             $imagePath = FRONTEND_FILES_PATH . '/' . $this->getModule() . '/categories';
             // create folders if needed
             $fs = new Filesystem();
             if (!$fs->exists($imagePath . '/150x150/')) {
                 $fs->mkdir($imagePath . '/150x150/');
             }
             if (!$fs->exists($imagePath . '/source/')) {
                 $fs->mkdir($imagePath . '/source/');
             }
             if (!$fs->exists($imagePath . '/800x')) {
                 $fs->mkdir($imagePath . '/800x');
             }
             if (!$fs->exists($imagePath . '/400x480')) {
                 $fs->mkdir($imagePath . '/400x480');
             }
             if ($this->frm->getField('delete_image')->isChecked()) {
                 BackendModel::deleteThumbnails($imagePath, $this->record['image']);
                 $item['image'] = null;
             }
             // image provided?
             if ($this->frm->getField('image')->isFilled()) {
                 // build the image name
                 $item['image'] = $this->meta->getUrl() . '.' . $this->frm->getField('image')->getExtension();
                 // upload the image & generate thumbnails
                 $this->frm->getField('image')->generateThumbnails($imagePath, $item['image']);
             }
             // update the item
             BackendCatalogModel::updateCategory($item);
             //--Add the languages
             foreach ((array) BackendModel::get('fork.settings')->get('Core', 'languages') as $key => $language) {
                 $itemLanguage = array();
                 $itemLanguage['id'] = $item['id'];
                 $itemLanguage['language'] = $language;
                 $itemLanguage['title'] = $this->frm->getField('title_' . $language)->getValue();
                 $itemLanguage['description'] = $this->frm->getField('description_' . $language)->getValue();
                 $itemLanguage['summary'] = $this->frm->getField('summary_' . $language)->getValue();
                 $itemLanguage['url'] = BackendCatalogModel::getURLForCategoryLanguage($this->frm->getField('title_' . $language)->getValue(), $item['id'], $language);
                 $itemLanguage['balltext'] = $this->frm->getField('balltext_' . $language)->getValue();
                 BackendCatalogModel::updateCategoryLanguage($itemLanguage);
             }
             // trigger event
             BackendModel::triggerEvent($this->getModule(), 'after_edit_category', array('item' => $item));
             // everything is saved, so redirect to the overview
             $this->redirect(BackendModel::createURLForAction('categories') . '&report=edited-category&var=' . urlencode($this->frm->getField('title_nl')->getValue()) . '&highlight=row-' . $item['id']);
         }
     }
 }
Пример #17
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
         $image = $this->frm->getField('image');
         $this->frm->getField('title')->isFilled(BL::err('NameIsRequired'));
         $image->isFilled(BL::err('FieldIsRequired'));
         // no errors?
         if ($this->frm->isCorrect()) {
             // build image record to insert
             $item['product_id'] = $this->product['id'];
             $item['title'] = $this->frm->getField('title')->getValue();
             // set files path for this record
             $path = FRONTEND_FILES_PATH . '/' . $this->module . '/' . $item['product_id'];
             // set formats
             $formats = array();
             $formats[] = array('size' => '64x64', 'allow_enlargement' => true, 'force_aspect_ratio' => false);
             $formats[] = array('size' => '128x128', 'allow_enlargement' => true, 'force_aspect_ratio' => false);
             $formats[] = array('size' => BackendModel::getModuleSetting($this->URL->getModule(), 'width1') . 'x' . BackendModel::getModuleSetting($this->URL->getModule(), 'height1'), 'allow_enlargement' => BackendModel::getModuleSetting($this->URL->getModule(), 'allow_enlargment1'), 'force_aspect_ratio' => BackendModel::getModuleSetting($this->URL->getModule(), 'force_aspect_ratio1'));
             $formats[] = array('size' => BackendModel::getModuleSetting($this->URL->getModule(), 'width2') . 'x' . BackendModel::getModuleSetting($this->URL->getModule(), 'height2'), 'allow_enlargement' => BackendModel::getModuleSetting($this->URL->getModule(), 'allow_enlargment2'), 'force_aspect_ratio' => BackendModel::getModuleSetting($this->URL->getModule(), 'force_aspect_ratio2'));
             $formats[] = array('size' => BackendModel::getModuleSetting($this->URL->getModule(), 'width3') . 'x' . BackendModel::getModuleSetting($this->URL->getModule(), 'height3'), 'allow_enlargement' => BackendModel::getModuleSetting($this->URL->getModule(), 'allow_enlargment3'), 'force_aspect_ratio' => BackendModel::getModuleSetting($this->URL->getModule(), 'force_aspect_ratio3'));
             // set the filename
             $item['filename'] = time() . '.' . $image->getExtension();
             $item['sequence'] = BackendCatalogModel::getMaximumImagesSequence($item['product_id']) + 1;
             // add images
             BackendCatalogHelper::addImages($image, $path, $item['filename'], $formats);
             // save the item
             $item['id'] = BackendCatalogModel::saveImage($item);
             // trigger event
             BackendModel::triggerEvent($this->getModule(), 'after_add_image', array('item' => $item));
             // everything is saved, so redirect to the overview
             $this->redirect(BackendModel::createURLForAction('media') . '&product_id=' . $item['product_id'] . '&report=added&var=' . urlencode($item['title']) . '&highlight=row-' . $item['id']);
         }
     }
 }
Пример #18
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
             BackendCatalogModel::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' . ucwords($item['status']));
         }
     }
 }
Пример #19
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('email')->isEmail(FL::err('EmailIsRequired'));
         $this->frm->getField('fname')->isFilled(BL::err('FirstNameIsRequired'));
         $this->frm->getField('lname')->isFilled(BL::err('LastNameIsRequired'));
         $this->frm->getField('address')->isFilled(BL::err('AddressIsRequired'));
         $this->frm->getField('hnumber')->isFilled(BL::err('HouseNumberIsRequired'));
         $this->frm->getField('postal')->isFilled(BL::err('PostalIsRequired'));
         $this->frm->getField('hometown')->isFilled(BL::err('HometownIsRequired'));
         // no errors?
         if ($this->frm->isCorrect()) {
             // build item
             $order['id'] = $this->id;
             $order['email'] = $this->frm->getField('email')->getValue();
             $order['fname'] = $this->frm->getField('fname')->getValue();
             $order['lname'] = $this->frm->getField('lname')->getValue();
             $order['address'] = $this->frm->getField('address')->getValue();
             $order['hnumber'] = $this->frm->getField('hnumber')->getValue();
             $order['postal'] = $this->frm->getField('postal')->getValue();
             $order['hometown'] = $this->frm->getField('hometown')->getValue();
             // insert the item
             BackendCatalogModel::updateOrder($order);
             // trigger event
             BackendModel::triggerEvent($this->getModule(), 'after_edit_order', array('item' => $order));
             // everything is saved, so redirect to the overview
             $this->redirect(BackendModel::createURLForAction('orders') . '&report=edited-order&id=' . $order['id'] . '&highlight=row-' . $order['id'] . '#tab' . ucwords($this->record['status']));
         }
     }
 }
Пример #20
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);
     }
 }
Пример #21
0
 /**
  * Validate the form
  */
 protected function validateForm()
 {
     if ($this->frm->isSubmitted()) {
         $this->frm->cleanupFields();
         // validation
         $fields = $this->frm->getFields();
         //            $fields['title']->isFilled(BL::err('FieldIsRequired'));
         //            $fields['summary']->isFilled(BL::err('FieldIsRequired'));
         $fields['category_id']->isFilled(BL::err('FieldIsRequired'));
         if ($fields['category_id']->getValue() == 'no_category') {
             $fields['category_id']->addError(BL::err('FieldIsRequired'));
         }
         // validate meta
         $this->meta->validate();
         //--Validate Media
         $this->media->validate();
         if ($this->frm->isCorrect()) {
             $item['id'] = $this->id;
             $item['language'] = BL::getWorkingLanguage();
             $item['price'] = $fields['price']->getValue();
             $item['category_id'] = $this->frm->getField('category_id')->getValue();
             $item['brand_id'] = $fields['brand_id']->getValue();
             $item['allow_comments'] = $this->frm->getField('allow_comments')->getChecked() ? 'Y' : 'N';
             $item['frontpage'] = $this->frm->getField('frontpage')->getChecked();
             $item['contact'] = $this->frm->getField('contact')->getChecked();
             $item['meta_id'] = $this->meta->save();
             $item['ballcolor'] = $fields['ballcolor']->getValue();
             BackendCatalogModel::update($item);
             $item['id'] = $this->id;
             //--Add the languages
             foreach ((array) BackendModel::get('fork.settings')->get('Core', 'languages') as $key => $language) {
                 $itemLanguage = array();
                 $itemLanguage['id'] = $item['id'];
                 $itemLanguage['language'] = $language;
                 $itemLanguage['title'] = $this->frm->getField('title_' . $language)->getValue();
                 $itemLanguage['summary'] = $this->frm->getField('summary_' . $language)->getValue();
                 $itemLanguage['text'] = $this->frm->getField('text_' . $language)->getValue();
                 $itemLanguage['url'] = BackendCatalogModel::getURLLanguage($this->frm->getField('title_' . $language)->getValue(), $item['id'], $language);
                 $itemLanguage['balltext'] = $this->frm->getField('balltext_' . $language)->getValue();
                 BackendCatalogModel::updateLanguage($itemLanguage, $language);
             }
             $specificationArray = array();
             // loop trough specifications and insert values
             foreach ($this->specifications as $specification) {
                 foreach ((array) BackendModel::get('fork.settings')->get('Core', 'languages') as $key => $language) {
                     $field = 'specification' . $specification['id'] . '_' . $language;
                     $specificationArray['value'] = $fields[$field]->getValue();
                     $specificationArray['language'] = $language;
                     $specificationArray['product_id'] = $item['id'];
                     $specificationArray['specification_id'] = $specification['id'];
                     // when specification value already exists. update value
                     if (BackendCatalogModel::existsSpecificationValue($item['id'], $specification['id'], $language) != false) {
                         // update specification with product id and value
                         BackendCatalogModel::updateSpecificationValue($specification['id'], $item['id'], $language, $specificationArray);
                     } else {
                         // when specification value doesnt exists, insert new value
                         BackendCatalogModel::insertSpecificationValue($specificationArray);
                     }
                 }
             }
             // save the tags
             BackendTagsModel::saveTags($item['id'], $fields['tags']->getValue(), $this->URL->getModule());
             // add search index
             BackendSearchModel::saveIndex($this->getModule(), $item['id'], array('title' => $this->frm->getField('title_nl')->getValue(), 'summary' => $this->frm->getField('summary_nl')->getValue(), 'text' => $this->frm->getField('text_nl')->getValue()));
             // save related projects
             BackendCatalogModel::saveRelatedProducts($item['id'], $this->frm->getField('related_products')->getValue(), $this->relatedProducts);
             // trigger event
             BackendModel::triggerEvent($this->getModule(), 'after_edit', $item);
             $this->redirect(BackendModel::createURLForAction('index') . '&report=edited&highlight=row-' . $item['id']);
         }
     }
 }
Пример #22
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('title')->isFilled(BL::err('NameIsRequired'));
         $this->frm->getField('video')->isFilled(BL::err('FieldIsRequired'));
         // no errors?
         if ($this->frm->isCorrect()) {
             // build video record to insert
             $item['product_id'] = $this->product['id'];
             $item['title'] = $this->frm->getField('title')->getValue();
             $item['embedded_url'] = $this->frm->getField('video')->getValue();
             $item['sequence'] = BackendCatalogModel::getMaximumVideosSequence($item['product_id']) + 1;
             // save the item
             $item['id'] = BackendCatalogModel::saveVideo($item);
             // trigger event
             BackendModel::triggerEvent($this->getModule(), 'after_add_video', array('item' => $item));
             // everything is saved, so redirect to the overview
             $this->redirect(BackendModel::createURLForAction('media') . '&product_id=' . $item['product_id'] . '&report=added&var=' . urlencode($item['title']) . '&highlight=row-' . $item['id'] . '#tabVideos');
         }
     }
 }
Пример #23
0
 /**
  * Gets all necessary data
  */
 protected function getData()
 {
     $this->product = BackendCatalogModel::get($this->id);
 }