/** * Execute the action */ public function execute() { // get parameters $this->id = $this->getParameter('id', 'int'); // does the item exist if ($this->id !== null && BackendGalleriaModel::existsAlbum($this->id)) { // call parent, this will probably add some general CSS/JS or other required files parent::execute(); // get album $this->album = BackendGalleriaModel::getAlbumFromId($this->id); // is this album allowed to be deleted? if (!BackendGalleriaModel::deleteAlbumAllowed($this->id)) { $this->redirect(BackendModel::createURLForAction('albums') . '&error=album-not-deletable'); } else { // delete the item BackendGalleriaModel::deleteAlbumById($this->id); // trigger event BackendModel::triggerEvent($this->getModule(), 'after_delete_album', array('id' => $this->id)); // item was deleted, so redirect $this->redirect(BackendModel::createURLForAction('albums') . '&report=album-deleted&var=' . urlencode($this->album['title'])); } } else { $this->redirect(BackendModel::createURLForAction('albums') . '&error=non-existing'); } }
/** * 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('TitleIsRequired')); // no errors? if ($this->frm->isCorrect()) { // build item $item['title'] = $this->frm->getField('title')->getValue(); $item['language'] = BL::getWorkingLanguage(); $item['publish_on'] = BackendModel::getUTCDate('Y-m-d H:i:s'); $item['hidden'] = $this->frm->getField('hidden')->getValue(); // get the highest sequence available $item['sequence'] = BackendGalleriaModel::getMaximumCategorySequence() + 1; // insert the item $item['id'] = BackendGalleriaModel::insertCategory($item); // trigger event BackendModel::triggerEvent($this->getModule(), 'after_add_category', array('item' => $item)); // everything is saved, so redirect to the overview $this->redirect(BackendModel::createURLForAction('categories') . '&report=added-category&var=' . urlencode($item['title']) . '&highlight=row-' . $item['id']); } } }
/** * Execute the action */ public function execute() { $this->id = $this->getParameter('id', 'int'); // does the item exist if ($this->id !== null && BackendGalleriaModel::existsCategory($this->id)) { parent::execute(); // is this category allowed to be deleted? if (!BackendGalleriaModel::deleteCategoryAllowed($this->id)) { $this->redirect(BackendModel::createURLForAction('categories') . '&error=category-not-deletable'); } else { // get category $this->record = BackendGalleriaModel::getCategoryFromId($this->id); // delete category BackendGalleriaModel::deleteCategoryById($this->id); BackendModel::triggerEvent($this->getModule(), 'after_delete_category', array('id' => $this->id)); $this->redirect(BackendModel::createURLForAction('categories') . '&report=category-deleted&var=' . urlencode($this->record['title'])); } } else { $this->redirect(BackendModel::createURLForAction('categories') . '&error=non-existing'); } }
/** * Execute the action */ 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) { // build item $item['id'] = (int) $id; // change sequence $item['sequence'] = $i + 1; // update sequence if (BackendGalleriaModel::existsAlbum($item['id'])) { BackendGalleriaModel::updateAlbum($item); } } // success output $this->output(self::OK, null, 'sequence updated'); }
/** * Execute the action */ public function execute() { parent::execute(); //--Get the ids and split them $ids = explode(',', trim(\SpoonFilter::getPostValue('ids', null, '', 'string'))); //--Check if the id is not empty if (!empty($ids)) { //--Set the sequence to 1 $sequence = 1; //--Loop the id's foreach ($ids as $id) { //--Set the item array $item = array(); $item["id"] = (int) $id; $item["sequence"] = $sequence; BackendGalleriaModel::exists($item["id"]) ? BackendGalleriaModel::update($item) : null; //--Add the sequence for each id $sequence++; } } // success output $this->output(self::OK, null, 'sequence updated'); }
/** * Validate the form delete image * * @return void */ private function validateFormDeleteImage() { //--Check if the delete-image form is submitted if ($this->frmDeleteImage->isSubmitted()) { //--Clean up fields in the form $this->frmDeleteImage->cleanupFields(); //--Check if the image-array is not empty. if (!empty($this->images)) { //--Loop the images foreach ($this->images as $row) { //--Check if the delete parameter is filled in. if (\SpoonFilter::getPostValue("delete_" . $row["id"], null, "") == "Y") { //--Delete the image BackendGalleriaModel::delete($row["id"]); } //--Update item $item['id'] = $row['id']; $item['language'] = $row['language']; $item['description'] = \SpoonFilter::getPostValue("description_" . $row["id"], null, ""); BackendGalleriaModel::updateImage($item); } $this->redirect(BackendModel::createURLForAction('edit_album') . '&id=' . $this->id . '&report=deleted-images#tabImages'); } } }
/** * Validate the form * * @return void */ 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('title')->isFilled(BL::err('TitleIsRequired')); // no errors? if ($this->frm->isCorrect()) { // first, build the category array $category['id'] = (int) $this->id; $category['title'] = (string) $this->frm->getField('title')->getValue(); $category['language'] = (string) BL::getWorkingLanguage(); $category['hidden'] = (string) $this->frm->getField('hidden')->getValue(); // ... then, update the category $category_update = BackendGalleriaModel::updateCategory($category); // trigger event BackendModel::triggerEvent($this->getModule(), 'after_edit_category', array('item' => $category)); // everything is saved, so redirect to the overview $this->redirect(BackendModel::createURLForAction('categories') . '&report=edited-category&var=' . urlencode($category['title']) . '&highlight=row-' . $category['id']); } } }
/** * Validate the form add image * * @return void */ private function validateForm() { //--Check if the add-image form is submitted if ($this->frm->isSubmitted()) { //--Clean up fields in the form $this->frm->cleanupFields(); //--Get image field $filImage = $this->frm->getField('images'); //--Check if the field is filled in if ($filImage->isFilled()) { //--Image extension and mime type $filImage->isAllowedExtension(array('jpg', 'png', 'gif', 'jpeg'), BL::err('JPGGIFAndPNGOnly')); $filImage->isAllowedMimeType(array('image/jpg', 'image/png', 'image/gif', 'image/jpeg'), BL::err('JPGGIFAndPNGOnly')); //--Check if there are no errors. $strError = $filImage->getErrors(); if ($strError === null) { //--Get the filename $strFilename = BackendGalleriaModel::checkFilename(substr($filImage->getFilename(), 0, 0 - (strlen($filImage->getExtension()) + 1)), $filImage->getExtension()); //--Fill in the item $item = array(); $item["album_id"] = (int) $this->id; $item["user_id"] = BackendAuthentication::getUser()->getUserId(); $item["language"] = BL::getWorkingLanguage(); $item["filename"] = $strFilename; $item["description"] = ""; $item["publish_on"] = BackendModel::getUTCDate(); $item["hidden"] = "N"; $item["sequence"] = BackendGalleriaModel::getMaximumImageSequence($this->id) + 1; //--the image path $imagePath = FRONTEND_FILES_PATH . '/Galleria/Images'; //--create folders if needed if (!\SpoonDirectory::exists($imagePath . '/Source')) { \SpoonDirectory::create($imagePath . '/Source'); } if (!\SpoonDirectory::exists($imagePath . '/128x128')) { \SpoonDirectory::create($imagePath . '/128x128'); } if (!\SpoonDirectory::exists($imagePath . '/800x')) { \SpoonDirectory::create($imagePath . '/800x'); } //--image provided? if ($filImage->isFilled()) { //--upload the image & generate thumbnails $filImage->generateThumbnails($imagePath, $item["filename"]); } //--Add item to the database BackendGalleriaModel::insert($item); } } } }
/** * Validate the form * * @return void */ 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('title')->isFilled(BL::err('TitleIsRequired')); // no errors? if ($this->frm->isCorrect()) { // build album array $album['language'] = BL::getWorkingLanguage(); $album['meta_id'] = $this->meta->save(); $album['title'] = (string) $this->frm->getField('title')->getValue(); $album['sequence'] = (int) BackendGalleriaModel::getMaximumAlbumSequence() + 1; $album['hidden'] = (string) $this->frm->getField('hidden')->getValue(); $album['show_in_overview'] = (string) $this->frm->getField('show_in_overview')->getValue(); $album['category_id'] = (int) $this->frm->getField('category')->getValue(); $album['publish_on'] = BackendModel::getUTCDate(); $album['description'] = (string) $this->frm->getField('description')->getValue(); // first, insert the album $album['id'] = BackendGalleriaModel::insertAlbum($album); // save the tags BackendTagsModel::saveTags($album['id'], $this->frm->getField('tags')->getValue(), $this->URL->getModule()); // trigger event BackendModel::triggerEvent($this->getModule(), 'after_add_album', array('item' => $album)); // everything is saved, so redirect to the overview $this->redirect(BackendModel::createURLForAction('albums') . '&report=added-album&var=' . urlencode($album['title']) . '&highlight=row-' . $album['id']); } } }