Execute the action
public execute ( ) : |
||
리턴 |
/** * 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']))); } }
/** * Execute the action */ public function execute() { parent::execute(); // get parameters $formId = \SpoonFilter::getPostValue('form_id', null, '', 'int'); $newIdSequence = trim(\SpoonFilter::getPostValue('new_id_sequence', null, '', 'string')); // invalid form id if (!BackendFormBuilderModel::exists($formId)) { $this->output(self::BAD_REQUEST, null, 'form does not exist'); } else { // list id $ids = (array) explode('|', rtrim($newIdSequence, '|')); // loop id's and set new sequence foreach ($ids as $i => $id) { $id = (int) $id; // get field $field = BackendFormBuilderModel::getField($id); // from this form and not a submit button if (!empty($field) && $field['form_id'] == $formId && $field['type'] != 'submit') { BackendFormBuilderModel::updateField($id, array('sequence' => $i + 1)); } } $this->output(self::OK, null, 'sequence updated'); } }
/** * Execute the action */ public function execute() { parent::execute(); // Get api key $this->apiKey = BackendModel::getModuleSetting($this->getModule(), 'api_key', null); // Get uncompressed images list $this->images = BackendCompressionModel::getImagesFromFolders(); if (!empty($this->images)) { // Compress each image from each folder BackendCompressionModel::writeToCacheFile('Compressing ' . count($this->images) . ' images...' . "\r\n", true); foreach ($this->images as $image) { $tinyPNGApi = new TinyPNGApi($this->apiKey); // Shrink the image and check if succesful if ($tinyPNGApi->shrink($image['full_path'])) { // Check if the file was successfully downloaded. if ($tinyPNGApi->download($image['full_path'])) { $output = 'Compression succesful for image ' . $image['filename'] . '. Saved ' . number_format($tinyPNGApi->getSavingSize() / 1024, 2) . ' KB. (' . $tinyPNGApi->getSavingPercentage() . '%)'; BackendCompressionModel::writeToCacheFile($output); // Save to db $imageInfo = array('filename' => $image['filename'], 'path' => $image['full_path'], 'original_size' => $tinyPNGApi->getInputSize(), 'compressed_size' => $tinyPNGApi->getOutputSize(), 'saved_bytes' => $tinyPNGApi->getSavingSize(), 'saved_percentage' => $tinyPNGApi->getSavingPercentage(), 'checksum_hash' => sha1_file($image['full_path']), 'compressed_on' => BackendModel::getUTCDate()); BackendCompressionModel::insertImageHistory($imageInfo, $image['file_compressed_before']); } } else { BackendCompressionModel::writeToCacheFile($tinyPNGApi->getErrorMessage()); } } BackendCompressionModel::writeToCacheFile("...Done!"); } else { BackendCompressionModel::writeToCacheFile("There are no images that can be compressed.", true); } $this->output(self::OK); }
/** * Execute the action */ public function execute() { parent::execute(); // get parameters $formId = trim(\SpoonFilter::getPostValue('form_id', null, '', 'int')); $fieldId = trim(\SpoonFilter::getPostValue('field_id', null, '', 'int')); // invalid form id if (!BackendFormBuilderModel::exists($formId)) { $this->output(self::BAD_REQUEST, null, 'form does not exist'); } else { // invalid fieldId if (!BackendFormBuilderModel::existsField($fieldId, $formId)) { $this->output(self::BAD_REQUEST, null, 'field does not exist'); } else { // get field $field = BackendFormBuilderModel::getField($fieldId); // submit button cannot be deleted if ($field['type'] == 'submit') { $this->output(self::BAD_REQUEST, null, 'submit button cannot be deleted'); } else { // delete field BackendFormBuilderModel::deleteField($fieldId); // success output $this->output(self::OK, null, 'field deleted'); } } } }
/** * 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']))); } } } }
/** * Execute the action */ public function execute() { parent::execute(); // get parameters $formId = trim(\SpoonFilter::getPostValue('form_id', null, '', 'int')); $fieldId = trim(\SpoonFilter::getPostValue('field_id', null, '', 'int')); // invalid form id if (!BackendFormBuilderModel::exists($formId)) { $this->output(self::BAD_REQUEST, null, 'form does not exist'); } else { // invalid fieldId if (!BackendFormBuilderModel::existsField($fieldId, $formId)) { $this->output(self::BAD_REQUEST, null, 'field does not exist'); } else { // get field $field = BackendFormBuilderModel::getField($fieldId); if ($field['type'] == 'radiobutton') { $values = array(); foreach ($field['settings']['values'] as $value) { $values[] = $value['label']; } $field['settings']['values'] = $values; } // success output $this->output(self::OK, array('field' => $field)); } } }
/** * Execute the action */ public function execute() { parent::execute(); //--Get the ids as array $ids = \SpoonFilter::getPostValue('ids', null, '', 'array'); //--Set module $module = (string) \SpoonFilter::getPostValue('mediaModule', null, '', 'string'); //--Set action $action = (string) \SpoonFilter::getPostValue('mediaAction', null, '', 'string'); //--Set the id $id = (int) \SpoonFilter::getPostValue('mediaId', null, '', 'int'); //--Set the type $type = (string) \SpoonFilter::getPostValue('mediaType', null, '', 'string'); //--Create media object $media = new BackendMediaHelper(new BackendForm('add_image', null, 'post', false), $module, $id, $action, $type); //--Check if the ids is not empty if (!empty($ids)) { foreach ($ids as $id) { //--Link mediaitem with id to item $media->linkMediaToModule($id); } } // success output $this->output(self::OK, null, 'files added'); }
/** * Execute the action */ public function execute() { parent::execute(); // get parameters $id = \SpoonFilter::getPostValue('id', null, '', 'int'); $name = trim(\SpoonFilter::getPostValue('value', null, '', 'string')); // validate if ($name == '') { $this->output(self::BAD_REQUEST, null, 'no name provided'); } else { // get existing id $existingId = BackendMailmotorModel::getCampaignId($name); // validate if ($existingId !== 0 && $id !== $existingId) { $this->output(self::ERROR, array('id' => $existingId, 'error' => true), BL::err('CampaignExists', $this->getModule())); } else { // build array $item = array(); $item['id'] = $id; $item['name'] = $name; $item['created_on'] = BackendModel::getUTCDate('Y-m-d H:i:s'); // get page $rows = BackendMailmotorModel::updateCampaign($item); // trigger event BackendModel::triggerEvent($this->getModule(), 'edited_campaign', array('item' => $item)); // output if ($rows !== 0) { $this->output(self::OK, array('id' => $id), BL::msg('CampaignEdited', $this->getModule())); } else { $this->output(self::ERROR, null, BL::err('CampaignNotEdited', $this->getModule())); } } } }
/** * Execute the action */ public function execute() { // call parent, this will probably add some general CSS/JS or other required files parent::execute(); // init vars $templates = array(); $theme = $this->get('fork.settings')->get('Core', 'theme'); $files[] = BACKEND_PATH . '/Core/Layout/EditorTemplates/templates.js'; $themePath = FRONTEND_PATH . '/Themes/' . $theme . '/Core/Layout/EditorTemplates/templates.js'; if (is_file($themePath)) { $files[] = $themePath; } // loop all files foreach ($files as $file) { // process file $templates = array_merge($templates, $this->processFile($file)); } // set headers header('Content-type: text/javascript'); // output the templates if (!empty($templates)) { echo 'CKEDITOR.addTemplates(\'default\', { imagesPath: \'/\', templates:' . "\n"; echo json_encode($templates) . "\n"; echo '});'; } exit; }
/** * Execute the action */ public function execute() { // call parent, this will probably add some general CSS/JS or other required files parent::execute(); // create bogus form $frm = new BackendForm('meta'); // get parameters $URL = \SpoonFilter::getPostValue('url', null, '', 'string'); $metaId = \SpoonFilter::getPostValue('meta_id', null, null); $baseFieldName = \SpoonFilter::getPostValue('baseFieldName', null, '', 'string'); $custom = \SpoonFilter::getPostValue('custom', null, false, 'bool'); $className = \SpoonFilter::getPostValue('className', null, '', 'string'); $methodName = \SpoonFilter::getPostValue('methodName', null, '', 'string'); $parameters = \SpoonFilter::getPostValue('parameters', null, '', 'string'); // cleanup values $metaId = $metaId ? (int) $metaId : null; $parameters = @unserialize($parameters); // meta object $this->meta = new BackendMeta($frm, $metaId, $baseFieldName, $custom); // set callback for generating an unique URL $this->meta->setUrlCallback($className, $methodName, $parameters); // fetch generated meta url $URL = urldecode($this->meta->generateURL($URL)); // output $this->output(self::OK, $URL); }
/** * Execute the action */ public function execute() { parent::execute(); // get parameters $url = \SpoonFilter::getPostValue('url', null, ''); $username = \SpoonFilter::getPostValue('username', null, ''); $password = \SpoonFilter::getPostValue('password', null, ''); // filter out the 'http://' from the URL if (strpos($url, 'http://') !== false) { $url = str_replace('http://', '', $url); } if (strpos($url, 'https://') !== false) { $url = str_replace('https://', '', $url); } // init validation $errors = array(); // validate input if (empty($url)) { $errors['url'] = BL::err('NoCMAccountCredentials'); } if (empty($username)) { $errors['username'] = BL::err('NoCMAccountCredentials'); } if (empty($password)) { $errors['password'] = BL::err('NoCMAccountCredentials'); } // got errors if (!empty($errors)) { $this->output(self::OK, array('errors' => $errors), 'form contains errors'); } else { try { // check if the CampaignMonitor class exists if (!is_file(PATH_LIBRARY . '/external/campaignmonitor.php')) { throw new \Exception(BL::err('ClassDoesNotExist')); } // require CampaignMonitor class require_once PATH_LIBRARY . '/external/campaignmonitor.php'; // init CampaignMonitor object new \CampaignMonitor($url, $username, $password, 10); // save the new data $this->get('fork.settings')->set($this->getModule(), 'cm_url', $url); $this->get('fork.settings')->set($this->getModule(), 'cm_username', $username); $this->get('fork.settings')->set($this->getModule(), 'cm_password', $password); // account was linked $this->get('fork.settings')->set($this->getModule(), 'cm_account', true); // trigger event BackendModel::triggerEvent($this->getModule(), 'after_account_linked'); // CM was successfully initialized $this->output(self::OK, array('message' => 'account-linked'), BL::msg('AccountLinked', $this->getModule())); } catch (\Exception $e) { // timeout occurred if ($e->getMessage() == 'Error Fetching http headers') { $this->output(self::BAD_REQUEST, null, BL::err('CmTimeout', $this->getModule())); } // other error $this->output(self::ERROR, array('field' => 'url'), sprintf(BL::err('CampaignMonitorError', $this->getModule()), $e->getMessage())); } } }
public function execute() { parent::execute(); //--Get the video info //$video_type = \SpoonFilter::getPostValue('video_type', null, '', 'int'); $video_url = \SpoonFilter::getPostValue('video', null, '', 'string'); if (preg_match('%youtube|youtu\\.be%i', $video_url)) { $video_type = 0; $video_id = self::getYoutubeId($video_url); } elseif (preg_match('%vimeo%i', $video_url)) { $video_type = 1; $video_id = self::getVimeoId($video_url); } elseif (preg_match('%vine%i', $video_url)) { $video_type = 2; $video_id = preg_replace('/^.*\\//', '', $video_url); } if (isset($video_id)) { //--Set module $module = (string) \SpoonFilter::getPostValue('mediaModule', null, '', 'string'); //--Set action $action = (string) \SpoonFilter::getPostValue('mediaAction', null, '', 'string'); //--Set the id $id = (int) \SpoonFilter::getPostValue('mediaId', null, '', 'int'); //--Set the type $type = (string) \SpoonFilter::getPostValue('mediaType', null, '', 'string'); //--Create media object $media = new BackendMediaHelper(new BackendForm('add_image', null, 'post', false), $module, $id, $action, $type); //--Validate media -> add video $media->addVideo($video_type, $video_id); $tpl = new Template(); $media->item['txtText'] = $media->frm->addTextarea("text-" . $media->item["id"], $media->item['text'])->setAttribute('style', 'resize: none;')->parse(); switch ($media->item['extension']) { //youtube case 0: $media->item['video_html'] = '<iframe id="ytplayer" type="text/html" width="100%" src="http://www.youtube.com/embed/' . $media->item['filename'] . '?autoplay=0" frameborder="0"></iframe>'; break; //vimeo //vimeo case 1: $media->item['video_html'] = '<iframe src="//player.vimeo.com/video/' . $media->item['filename'] . '" width="100%" frameborder="0" webkitallowfullscreen mozallowfullscreen allowfullscreen></iframe>'; break; //vine //vine case 2: $media->item['video_html'] = '<iframe src="https://vine.co/v/' . $media->item['filename'] . '/embed/postcard" width="100%" frameborder="0"></iframe><script src="https://platform.vine.co/static/scripts/embed.js"></script>'; break; default: $media->item['video_html'] = ""; break; } $tpl->assign('mediaItems', array('videos' => array($media->item))); $html = $tpl->getContent(BACKEND_MODULES_PATH . '/Media/Layout/Templates/Ajax/Video.tpl'); $this->output(self::OK, array($media->item['filetype'], $html), FrontendLanguage::msg('Success')); } else { $this->output(self::OK, null, 'video not added'); } // success output }
/** * Execute the action */ public function execute() { parent::execute(); // get parameters $newSequence = \SpoonFilter::getPostValue('new_sequence', null, ''); // validate if ($newSequence == '') { $this->output(self::BAD_REQUEST, null, 'no new_sequence provided'); } else { // convert into array $json = @json_decode($newSequence, true); // validate if ($json === false) { $this->output(self::BAD_REQUEST, null, 'invalid new_sequence provided'); } else { // initialize $userSequence = array(); $hiddenItems = array(); // loop columns foreach ($json as $column => $widgets) { $columnValue = 'left'; if ($column == 1) { $columnValue = 'middle'; } elseif ($column == 2) { $columnValue = 'right'; } // loop widgets foreach ($widgets as $sequence => $widget) { // store position $userSequence[$widget['module']][$widget['widget']] = array('column' => $columnValue, 'position' => $sequence, 'hidden' => $widget['hidden'], 'present' => $widget['present']); // add to array if ($widget['hidden']) { $hiddenItems[] = $widget['module'] . '_' . $widget['widget']; } } } // get previous setting $currentSetting = BackendAuthentication::getUser()->getSetting('dashboard_sequence'); $data['reload'] = false; // any settings? if ($currentSetting !== null) { // loop modules foreach ($currentSetting as $module => $widgets) { foreach ($widgets as $widget => $values) { if ($values['hidden'] && isset($userSequence[$module][$widget]['hidden']) && !$userSequence[$module][$widget]['hidden']) { $data['reload'] = true; } } } } // store BackendAuthentication::getUser()->setSetting('dashboard_sequence', $userSequence); // output $this->output(self::OK, $data, BL::msg('Saved')); } } }
/** * Execute the action */ public function execute() { parent::execute(); $overwrite = (bool) \SpoonFilter::getPostValue('overwrite', null, ''); if ($overwrite) { BackendCompressionModel::writeToCacheFile(""); } $this->output(self::OK); }
/** * 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 (urlencode($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); } }
/** * Execute the action */ public function execute() { parent::execute(); //--Set post var to check submit $_POST["form"] = "add_image"; // get parameters $this->id = \SpoonFilter::getPostValue('id', null, '', 'int'); //--Load form $this->loadForm(); //--Validate form $this->validateForm(); }
/** * Execute the action */ public function execute() { parent::execute(); //--Create template object $tpl = new Template(); //--Add list of all mediaitems to template $tpl->assign('mediaItems', BackendMediaHelper::getAllMediaItems()); //--Get html list $html = $tpl->getContent(BACKEND_MODULES_PATH . '/Media/Layout/Templates/Ajax/Link.tpl'); // success output $this->output(self::OK, $html, ''); }
/** * Execute the action */ public function execute() { parent::execute(); //--Get the id of the link to mediaitem $id = \SpoonFilter::getPostValue('id', null, '', 'string'); //--Get new name for file $nameGet = \SpoonFilter::getPostValue('name', null, '', 'string'); //--Check if the id is not empty if (!empty($id)) { //--Get link to mediaitem $mediaModule = BackendMediaModel::getMediaModule($id); //--Get mediaitem $media = BackendMediaModel::get($mediaModule['media_id']); //--Clean new name for file $name = preg_replace("([^\\w\\s\\d\\-_~,;:\\[\\]\\(\\).])", '', $nameGet); //--Get all image folders defined by sizes $folders = BackendModel::getThumbnailFolders(FRONTEND_FILES_PATH . '/Media/Images', true); //--Create filesystem for file actions $fs = new Filesystem(); //--Get path to files $path = FRONTEND_FILES_PATH . '/Media/'; //--If old and new name is not the same -> do rename if ($media['filename'] != $name . '.' . $media['extension']) { //--Rename files on disk if ($media['filetype'] == 1) { if ($fs->exists($path . 'Images/Source/' . $media['filename'])) { $fs->rename($path . 'Images/Source/' . $media['filename'], FRONTEND_FILES_PATH . '/Media/Images/Source/' . $name . '.' . $media['extension']); } foreach ($folders as $folder) { if ($fs->exists($path . 'Images/' . $folder['dirname'] . '/' . $media['filename'])) { $fs->rename($path . 'Images/' . $folder['dirname'] . '/' . $media['filename'], FRONTEND_FILES_PATH . '/Media/Images/' . $folder['dirname'] . '/' . $name . '.' . $media['extension']); } } } else { if ($fs->exists($path . 'Files/' . $media['filename'])) { $fs->rename($path . 'Files/' . $media['filename'], FRONTEND_FILES_PATH . '/Media/Files/' . $name . '.' . $media['extension']); } } //--Set new name on mediaitem $media['filename'] = $name . '.' . $media['extension']; //--Update mediaitem BackendMediaModel::update($mediaModule['media_id'], $media); //--Create url to new file for ajax $url = FRONTEND_FILES_URL . '/Media/Files/' . $media['filename']; //--Return the new URL -> replaces the old url of the media on page $this->output(self::OK, $url, 'file renamed'); } else { $this->output(self::OK, null, 'file name is the same'); } } // success output }
/** * Execute the action */ public function execute() { parent::execute(); //--Get the id $id = \SpoonFilter::getPostValue('id', null, '', 'string'); //--Check if the id is not empty if (!empty($id)) { //--Delete file BackendGalleryModel::delete($id); } // success output $this->output(self::OK, null, 'image deleted'); }
/** * Execute the action */ public function execute() { parent::execute(); // get parameters $term = \SpoonFilter::getPostValue('term', null, ''); // validate if ($term == '') { $this->output(self::BAD_REQUEST, null, 'term-parameter is missing.'); } else { // get tags $tags = BackendTagsModel::getStartsWith($term); // output $this->output(self::OK, $tags); } }
/** * Execute the action */ public function execute() { parent::execute(); // get parameters $clientId = \SpoonFilter::getPostValue('client_id', null, ''); // check input if (empty($clientId)) { $this->output(self::BAD_REQUEST); } else { // get basic details for this client $client = BackendMailmotorCMHelper::getCM()->getClient($clientId); // CM was successfully initialized $this->output(self::OK, $client); } }
/** * Execute the action */ public function execute() { parent::execute(); //--Get the ids as array $ids = \SpoonFilter::getPostValue('ids', null, '', 'array'); //--Check if the id is not empty if (!empty($ids)) { foreach ($ids as $id) { //--Delete file BackendGalleryModel::delete($id); } } // success output $this->output(self::OK, null, 'images deleted'); }
/** * Execute the action */ public function execute() { // call parent parent::execute(); // get parameters $id = \SpoonFilter::getPostValue('id', null, 0, 'int'); // validate if ($id === 0) { $this->output(self::BAD_REQUEST, null, 'no id provided'); } else { // get page $page = BackendPagesModel::get($id); // output $this->output(self::OK, $page); } }
/** * Execute the action */ public function execute() { // call parent, this will probably add some general CSS/JS or other required files parent::execute(); // get parameters $url = \SpoonFilter::getPostValue('url', null, '', 'string'); $className = \SpoonFilter::getPostValue('className', null, '', 'string'); $methodName = \SpoonFilter::getPostValue('methodName', null, '', 'string'); $parameters = \SpoonFilter::getPostValue('parameters', null, '', 'string'); // cleanup values $parameters = @unserialize($parameters); // fetch generated meta url $url = urldecode($this->get('fork.repository.meta')->generateURL($url, $className, $methodName, $parameters)); // output $this->output(self::OK, $url); }
/** * Execute the action */ public function execute() { parent::execute(); // get parameters $id = \SpoonFilter::getPostValue('id', null, '', 'int'); // validate if ($id == '' || !BackendMailmotorModel::existsMailing($id)) { $this->output(self::BAD_REQUEST, null, 'No mailing found.'); } else { // get mailing record $mailing = BackendMailmotorModel::getMailing($id); /* mailing was already sent We use a custom status code 900 because we want to do more with JS than triggering an error */ if ($mailing['status'] == 'sent') { $this->output(500, null, BL::err('MailingAlreadySent', $this->getModule())); } else { // make a regular date out of the send_on timestamp $mailing['delivery_date'] = date('Y-m-d H:i:s', $mailing['send_on']); // send the mailing try { // only update the mailing if it was queued if ($mailing['status'] == 'queued') { BackendMailmotorCMHelper::updateMailing($mailing); } else { // send the mailing if it wasn't queued BackendMailmotorCMHelper::sendMailing($mailing); } } catch (\Exception $e) { // stop the script and show our error $this->output(500, null, $e->getMessage()); return; } // set status to 'sent' $item['id'] = $id; $item['status'] = $mailing['send_on'] > time() ? 'queued' : 'sent'; // update the mailing record BackendMailmotorModel::updateMailing($item); // trigger event BackendModel::triggerEvent($this->getModule(), 'after_mailing_status_' . $item['status'], array('item' => $item)); // we made it \o/ $this->output(self::OK, array('mailing_id' => $item['id']), BL::msg('MailingSent', $this->getModule())); } } }
/** * Contstructor * */ public function execute() { parent::execute(); //--Set post var to check submit $_POST["form"] = "add_image"; //--Set module $module = (string) \SpoonFilter::getPostValue('mediaModule', null, '', 'string'); //--Set action $action = (string) \SpoonFilter::getPostValue('mediaAction', null, '', 'string'); //--Set the id $id = (int) \SpoonFilter::getPostValue('mediaId', null, '', 'int'); //--Set the type $type = (string) \SpoonFilter::getPostValue('mediaType', null, '', 'string'); //--Create media helper $this->media = new BackendMediaHelper(new BackendForm('add_image', null, 'post', false), $module, $id, $action, $type); //--Validate media -> upload file $this->media->validate(); //--File is image if ($this->media->item['filetype'] == 1) { //Create html $tpl = new Template(); $this->media->item['txtText'] = $this->media->frm->addTextarea("text-" . $this->media->item["id"], $this->media->item['text'])->setAttribute('style', 'resize: none;')->parse(); //--Get file info (ext, filename, path) $path_parts = pathinfo(FRONTEND_FILES_PATH . '/Media/Images/Source/' . $this->media->item['filename']); $this->media->item['name'] = $path_parts['filename']; $folders = BackendModel::getThumbnailFolders(FRONTEND_FILES_PATH . '/Media/Images', true); foreach ($folders as $folder) { $this->media->item['image_' . $folder['dirname']] = $folder['url'] . '/' . $folder['dirname'] . '/' . $this->media->item['filename']; } $tpl->assign('mediaItems', array('images' => array($this->media->item))); $html = $tpl->getContent(BACKEND_MODULES_PATH . '/Media/Layout/Templates/Ajax/Image.tpl'); //--File is file } else { //Create html $tpl = new Template(); $this->media->item['txtText'] = $this->media->frm->addTextarea("text-" . $this->media->item["id"], $this->media->item['text'])->setAttribute('style', 'resize: none;')->parse(); //--Get file info (ext, filename, path) $path_parts = pathinfo(FRONTEND_FILES_PATH . '/Media/Files/' . $this->media->item['filename']); $this->media->item['url'] = FRONTEND_FILES_URL . '/Media/Files/' . $this->media->item['filename']; $this->media->item['name'] = $path_parts['filename']; $tpl->assign('mediaItems', array('files' => array($this->media->item))); $html = $tpl->getContent(BACKEND_MODULES_PATH . '/Media/Layout/Templates/Ajax/File.tpl'); } // output (filetype, html) $this->output(self::OK, array($this->media->item['filetype'], $html), FrontendLanguage::msg('Success')); }
/** * Execute the action */ public function execute() { parent::execute(); //--Get the ids and split them $id = \SpoonFilter::getPostValue('id', null, '', 'string'); //--Get new name for image $nameGet = \SpoonFilter::getPostValue('name', null, '', 'string'); //--Check if the id is not empty if (!empty($id)) { //--Get image $image = BackendGalleryModel::get($id); //--Clean new name for file $name = preg_replace("([^\\w\\s\\d\\-_~,;:\\[\\]\\(\\).])", '', $nameGet); //--Get all image folders defined by sizes $folders = BackendModel::getThumbnailFolders(FRONTEND_FILES_PATH . '/Gallery/Images', true); //--Create filesystem for file actions $fs = new Filesystem(); //--Get extention $extension = pathinfo($image['filename'], PATHINFO_EXTENSION); //--Get path to files $path = FRONTEND_FILES_PATH . '/Gallery/Images/'; //--If old and new name is not the same -> do rename if ($image['filename'] != $name . '.' . $extension) { //--Rename files on disk if (!$fs->exists($path . '/Source/' . $name . '.' . $extension)) { if ($fs->exists($path . '/Source/' . $image['filename'])) { $fs->rename($path . '/Source/' . $image['filename'], $path . '/Source/' . $name . '.' . $extension); } foreach ($folders as $folder) { if ($fs->exists($path . $folder['dirname'] . '/' . $image['filename'])) { $fs->rename($path . $folder['dirname'] . '/' . $image['filename'], $path . $folder['dirname'] . '/' . $name . '.' . $extension); } } //--Rename file $image['filename'] = $name . '.' . $extension; BackendGalleryModel::update($image); $this->output(self::OK, null, 'file renamed'); } else { $this->output(self::ERROR, null, 'file name already exists'); } } else { $this->output(self::OK, null, 'file name is the same'); } } }
/** * 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')); }
/** * Execute the action */ public function execute() { parent::execute(); //--Get the ids as array $ids = \SpoonFilter::getPostValue('ids', null, '', 'array'); //--Create filesystem for file actions $fs = new Filesystem(); //--Get all image folders defined by sizes $folders = BackendModel::getThumbnailFolders(FRONTEND_FILES_PATH . '/Media/Images', true); //--Check if the id is not empty if (!empty($ids)) { foreach ($ids as $id) { //--Get media link from id $mediaModule = BackendMediaModel::getMediaModule($id); //--Delete link from mediaitem to item BackendMediaModel::deleteLink($id); //--Check if there are any other links to the mediaitem if (!BackendMediaModel::existsMediaModules($id)) { //--Get mediaitem $media = BackendMediaModel::get($mediaModule['media_id']); //--Delete files if ($media['filetype'] == 1) { if ($fs->exists(FRONTEND_FILES_PATH . '/Media/Images/Source/' . $media['filename'])) { $fs->remove(FRONTEND_FILES_PATH . '/Media/Images/Source/' . $media['filename']); } foreach ($folders as $folder) { if ($fs->exists(FRONTEND_FILES_PATH . '/Media/Images/' . $folder['dirname'] . '/' . $media['filename'])) { $fs->remove(FRONTEND_FILES_PATH . '/Media/Images/' . $folder['dirname'] . '/' . $media['filename']); } } } else { if ($media['filetype'] == 2) { if ($fs->exists(FRONTEND_FILES_PATH . '/Media/Files/' . $media['filename'])) { $fs->remove(FRONTEND_FILES_PATH . '/Media/Files/' . $media['filename']); } } } //--Delete mediaitem BackendMediaModel::delete($mediaModule['media_id']); } } } // success output $this->output(self::OK, null, 'files deleted'); }
/** * 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); } }