/** * Parse the form */ protected function parse() { parent::parse(); // assign the data $this->tpl->assign('item', $this->record); $this->tpl->assign('showFaqDeleteCategory', BackendFaqModel::deleteCategoryAllowed($this->id) && BackendAuthentication::isAllowedAction('DeleteCategory')); }
/** * Load the form */ private function loadForm() { $this->imageIsAllowed = $this->get('fork.settings')->get($this->URL->getModule(), 'show_image_form', true); $this->frm = new BackendForm('add'); // set hidden values $rbtHiddenValues[] = array('label' => BL::lbl('Hidden', $this->URL->getModule()), 'value' => 'Y'); $rbtHiddenValues[] = array('label' => BL::lbl('Published'), 'value' => 'N'); // get categories $categories = BackendBlogModel::getCategories(); $categories['new_category'] = \SpoonFilter::ucfirst(BL::getLabel('AddCategory')); // create elements $this->frm->addText('title', null, null, 'inputText title', 'inputTextError title'); $this->frm->addEditor('text'); $this->frm->addEditor('introduction'); $this->frm->addRadiobutton('hidden', $rbtHiddenValues, 'N'); $this->frm->addCheckbox('allow_comments', $this->get('fork.settings')->get($this->getModule(), 'allow_comments', false)); $this->frm->addDropdown('category_id', $categories, \SpoonFilter::getGetValue('category', null, null, 'int')); if (count($categories) != 2) { $this->frm->getField('category_id')->setDefaultElement(''); } $this->frm->addDropdown('user_id', BackendUsersModel::getUsers(), BackendAuthentication::getUser()->getUserId()); $this->frm->addText('tags', null, null, 'inputText tagBox', 'inputTextError tagBox'); $this->frm->addDate('publish_on_date'); $this->frm->addTime('publish_on_time'); if ($this->imageIsAllowed) { $this->frm->addImage('image'); } // meta $this->meta = new BackendMeta($this->frm, null, 'title', true); }
/** * Validate the form */ private function validateForm() { if ($this->frm->isSubmitted()) { $this->frm->cleanupFields(); $fields = $this->frm->getFields(); // validate fields $fields['title']->isFilled(BL::err('TitleIsRequired')); if ($this->frm->isCorrect()) { // build item $item['id'] = BackendContentBlocksModel::getMaximumId() + 1; $item['user_id'] = BackendAuthentication::getUser()->getUserId(); $item['template'] = count($this->templates) > 1 ? $fields['template']->getValue() : $this->templates[0]; $item['language'] = BL::getWorkingLanguage(); $item['title'] = $fields['title']->getValue(); $item['text'] = $fields['text']->getValue(); $item['hidden'] = $fields['hidden']->getValue() ? 'N' : 'Y'; $item['status'] = 'active'; $item['created_on'] = BackendModel::getUTCDate(); $item['edited_on'] = BackendModel::getUTCDate(); // insert the item $item['revision_id'] = BackendContentBlocksModel::insert($item); // trigger event BackendModel::triggerEvent($this->getModule(), 'after_add', array('item' => $item)); // everything is saved, so redirect to the overview $this->redirect(BackendModel::createURLForAction('Index') . '&report=added&var=' . urlencode($item['title']) . '&highlight=row-' . $item['id']); } } }
/** * Loads the settings form */ private function loadForm() { $this->isGod = BackendAuthentication::getUser()->isGod(); $this->frm = new BackendForm('settings'); // add fields for pagination $this->frm->addDropdown('overview_number_of_items', array_combine(range(1, 30), range(1, 30)), $this->get('fork.settings')->get($this->URL->getModule(), 'overview_num_items', 10)); $this->frm->addDropdown('recent_articles_full_number_of_items', array_combine(range(1, 10), range(1, 10)), $this->get('fork.settings')->get($this->URL->getModule(), 'recent_articles_full_num_items', 5)); $this->frm->addDropdown('recent_articles_list_number_of_items', array_combine(range(1, 10), range(1, 10)), $this->get('fork.settings')->get($this->URL->getModule(), 'recent_articles_list_num_items', 5)); // add fields for spam $this->frm->addCheckbox('spamfilter', $this->get('fork.settings')->get($this->URL->getModule(), 'spamfilter', false)); // no Akismet-key, so we can't enable spam-filter if ($this->get('fork.settings')->get('Core', 'akismet_key') == '') { $this->frm->getField('spamfilter')->setAttribute('disabled', 'disabled'); $this->tpl->assign('noAkismetKey', true); } // add fields for comments $this->frm->addCheckbox('allow_comments', $this->get('fork.settings')->get($this->URL->getModule(), 'allow_comments', false)); $this->frm->addCheckbox('moderation', $this->get('fork.settings')->get($this->URL->getModule(), 'moderation', false)); // add fields for notifications $this->frm->addCheckbox('notify_by_email_on_new_comment_to_moderate', $this->get('fork.settings')->get($this->URL->getModule(), 'notify_by_email_on_new_comment_to_moderate', false)); $this->frm->addCheckbox('notify_by_email_on_new_comment', $this->get('fork.settings')->get($this->URL->getModule(), 'notify_by_email_on_new_comment', false)); // add fields for SEO // @TODO remove this when the api is kicked out $this->frm->addCheckbox('ping_services', $this->get('fork.settings')->get($this->URL->getModule(), 'ping_services', false)); // add fields for RSS $this->frm->addCheckbox('rss_meta', $this->get('fork.settings')->get($this->URL->getModule(), 'rss_meta_' . BL::getWorkingLanguage(), true)); $this->frm->addText('rss_title', $this->get('fork.settings')->get($this->URL->getModule(), 'rss_title_' . BL::getWorkingLanguage())); $this->frm->addTextarea('rss_description', $this->get('fork.settings')->get($this->URL->getModule(), 'rss_description_' . BL::getWorkingLanguage())); // god user? if ($this->isGod) { $this->frm->addCheckbox('show_image_form', $this->get('fork.settings')->get($this->URL->getModule(), 'show_image_form', true)); } }
/** * Loads the dataGrids */ private function loadDatagrids() { // load all categories $categories = BackendFaqModel::getCategories(true); // loop categories and create a dataGrid for each one foreach ($categories as $categoryId => $categoryTitle) { $dataGrid = new BackendDataGridDB(BackendFaqModel::QRY_DATAGRID_BROWSE, array(BL::getWorkingLanguage(), $categoryId)); $dataGrid->setAttributes(array('class' => 'dataGrid sequenceByDragAndDrop')); $dataGrid->setColumnsHidden(array('category_id', 'sequence')); $dataGrid->addColumn('dragAndDropHandle', null, '<span>' . BL::lbl('Move') . '</span>'); $dataGrid->setColumnsSequence('dragAndDropHandle'); $dataGrid->setColumnAttributes('question', array('class' => 'title')); $dataGrid->setColumnAttributes('dragAndDropHandle', array('class' => 'dragAndDropHandle')); $dataGrid->setRowAttributes(array('id' => '[id]')); // check if this action is allowed if (BackendAuthentication::isAllowedAction('Edit')) { $dataGrid->setColumnURL('question', BackendModel::createURLForAction('Edit') . '&id=[id]'); $dataGrid->addColumn('edit', null, BL::lbl('Edit'), BackendModel::createURLForAction('Edit') . '&id=[id]', BL::lbl('Edit')); } // add dataGrid to list $this->dataGrids[] = array('id' => $categoryId, 'title' => $categoryTitle, 'content' => $dataGrid->getContent()); } // set empty datagrid $this->emptyDatagrid = new BackendDataGridArray(array(array('dragAndDropHandle' => '', 'question' => BL::msg('NoQuestionInCategory'), 'edit' => ''))); $this->emptyDatagrid->setAttributes(array('class' => 'dataGrid sequenceByDragAndDrop emptyGrid')); $this->emptyDatagrid->setHeaderLabels(array('edit' => null, 'dragAndDropHandle' => null)); }
/** * Execute the action */ public function execute() { parent::execute(); BackendAuthentication::logout(); // redirect to login-screen $this->redirect(BackendModel::createURLForAction('Index', $this->getModule())); }
/** * Output a CSV-file as a download * * @param string $filename The name of the file. * @param array $array The array to convert. * @param array $columns The column names you want to use. * @param array $excludeColumns The columns you want to exclude. */ public static function outputCSV($filename, array $array, array $columns = null, array $excludeColumns = null) { // get settings $splitCharacter = Authentication::getUser()->getSetting('csv_split_character'); $lineEnding = Authentication::getUser()->getSetting('csv_line_ending'); // reformat if ($lineEnding == '\\n') { $lineEnding = "\n"; } if ($lineEnding == '\\r\\n') { $lineEnding = "\r\n"; } // convert into CSV $csv = \SpoonFileCSV::arrayToString($array, $columns, $excludeColumns, $splitCharacter, '"', $lineEnding); // set headers for download $charset = BackendModel::getContainer()->getParameter('kernel.charset'); $headers[] = 'Content-type: application/csv; charset=' . $charset; $headers[] = 'Content-Disposition: attachment; filename="' . $filename . '"'; $headers[] = 'Content-Length: ' . strlen($csv); $headers[] = 'Pragma: no-cache'; // overwrite the headers \SpoonHTTP::setHeaders($headers); // output the CSV echo $csv; exit; }
/** * Load the form */ private function loadForm() { $this->isGod = BackendAuthentication::getUser()->isGod(); $this->frm = new BackendForm('settingsEmail'); // email settings $mailerFrom = $this->get('fork.settings')->get('Core', 'mailer_from'); $this->frm->addText('mailer_from_name', isset($mailerFrom['name']) ? $mailerFrom['name'] : ''); $this->frm->addText('mailer_from_email', isset($mailerFrom['email']) ? $mailerFrom['email'] : '')->setAttribute('type', 'email'); $mailerTo = $this->get('fork.settings')->get('Core', 'mailer_to'); $this->frm->addText('mailer_to_name', isset($mailerTo['name']) ? $mailerTo['name'] : ''); $this->frm->addText('mailer_to_email', isset($mailerTo['email']) ? $mailerTo['email'] : '')->setAttribute('type', 'email'); $mailerReplyTo = $this->get('fork.settings')->get('Core', 'mailer_reply_to'); $this->frm->addText('mailer_reply_to_name', isset($mailerReplyTo['name']) ? $mailerReplyTo['name'] : ''); $this->frm->addText('mailer_reply_to_email', isset($mailerReplyTo['email']) ? $mailerReplyTo['email'] : '')->setAttribute('type', 'email'); if ($this->isGod) { $mailerType = $this->get('fork.settings')->get('Core', 'mailer_type', 'mail'); $this->frm->addDropdown('mailer_type', array('mail' => 'PHP\'s mail', 'smtp' => 'SMTP'), $mailerType); // smtp settings $this->frm->addText('smtp_server', $this->get('fork.settings')->get('Core', 'smtp_server', '')); $this->frm->addText('smtp_port', $this->get('fork.settings')->get('Core', 'smtp_port', 25)); $this->frm->addText('smtp_username', $this->get('fork.settings')->get('Core', 'smtp_username', '')); $this->frm->addPassword('smtp_password', $this->get('fork.settings')->get('Core', 'smtp_password', '')); $this->frm->addDropdown('smtp_secure_layer', array('no' => ucfirst(BL::lbl('None')), 'ssl' => 'SSL', 'tls' => 'TLS'), $this->get('fork.settings')->get('Core', 'smtp_secure_layer', 'no')); } $this->tpl->assign('isGod', $this->isGod); }
/** * 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'))); }
/** * 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')); } } }
/** * 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') . '&id=[id]'); $this->dataGrid->setColumnURL('num_users', BackendModel::createURLForAction('Edit') . '&id=[id]#tabUsers'); $this->dataGrid->addColumn('edit', null, BL::lbl('Edit'), BackendModel::createURLForAction('Edit') . '&id=[id]'); } }
/** * Load the datagrids */ private function loadDataGrid() { $this->dataGrid = new BackendDataGridDB(BackendContentBlocksModel::QRY_BROWSE, array('active', BL::getWorkingLanguage())); $this->dataGrid->setSortingColumns(array('title')); // check if this action is allowed if (BackendAuthentication::isAllowedAction('Edit')) { $this->dataGrid->setColumnURL('title', BackendModel::createURLForAction('Edit') . '&id=[id]'); $this->dataGrid->addColumn('edit', null, BL::lbl('Edit'), BackendModel::createURLForAction('Edit') . '&id=[id]', BL::lbl('Edit')); } }
/** * Parse & display the page */ protected function parse() { parent::parse(); $this->tpl->assign('dataGrid', $this->dataGrid->getNumResults() != 0 ? $this->dataGrid->getContent() : false); // check if this action is allowed if (BackendAuthentication::isAllowedAction('AddCategory') && $this->multipleCategoriesAllowed) { $this->tpl->assign('showAgendaAddCategory', true); } else { $this->tpl->assign('showAgendaAddCategory', false); } }
/** * Load the dataGrid */ protected function loadDataGrid() { $this->dataGrid = new DataGridDB(BackendInstagramModel::QRY_DATAGRID_BROWSE, Language::getWorkingLanguage()); // Reform date $this->dataGrid->setColumnFunction(array('Backend\\Core\\Engine\\DataGridFunctions', 'getLongDate'), array('[created_on]'), 'created_on', true); // Check if this action is allowed if (Authentication::isAllowedAction('Edit')) { $this->dataGrid->addColumn('edit', null, Language::lbl('Edit'), Model::createURLForAction('Edit') . '&id=[id]', Language::lbl('Edit')); $this->dataGrid->setColumnURL('username', Model::createURLForAction('Edit') . '&id=[id]'); } }
/** * This function must check the user session to be sure that he/she is * authorized to upload and access files in the File Browser. * * @return boolean */ function CheckAuthentication() { // WARNING : DO NOT simply return "true". By doing so, you are allowing // "anyone" to upload and list the files in your server. You must implement // some kind of session validation here. Even something very simple as... // return isset($_SESSION['IsAuthorized']) && $_SESSION['IsAuthorized']; // ... where $_SESSION['IsAuthorized'] is set to "true" as soon as the // user logs in your system. To be able to use session variables don't // forget to add session_start() at the top of this file. return BackendAuthentication::isLoggedIn(); }
/** * 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); } }
/** * Load the dataGrid */ private function loadDataGrid() { $this->dataGrid = new BackendDataGridDB(BackendCatalogModel::QRY_DATAGRID_BROWSE_BRANDS, array(BL::getWorkingLanguage())); // check if this action is allowed if (BackendAuthentication::isAllowedAction('EditBrand')) { $this->dataGrid->setColumnURL('title', BackendModel::createURLForAction('edit_brand') . '&id=[id]'); $this->dataGrid->addColumn('edit', null, BL::lbl('Edit'), BackendModel::createURLForAction('edit_brand') . '&id=[id]', BL::lbl('Edit')); } // sequence $this->dataGrid->enableSequenceByDragAndDrop(); $this->dataGrid->setAttributes(array('data-action' => 'SequenceBrands')); }
/** * 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') . '&id=[id]'); // add edit column $this->dataGrid->addColumn('edit', null, BL::lbl('Edit'), BackendModel::createURLForAction('EditThemeTemplate') . '&id=[id]', BL::lbl('Edit')); } }
/** * Copy content blocks * * @param string $from The language code to copy the content blocks from. * @param string $to The language code we want to copy the content blocks to. * * @return array * * @deprecated use the CopyContentBlocksToOtherLocale command */ public static function copy($from, $to) { trigger_error('Backend\\Modules\\ContentBlocks\\Engine::copy is deprecated. Switch the CopyContentBlocksToOtherLocale command instead.', E_USER_DEPRECATED); // get db $db = BackendModel::getContainer()->get('database'); // init variables $contentBlockIds = $oldIds = $newIds = array(); // copy the contentblocks $contentBlocks = (array) $db->getRecords('SELECT * FROM content_blocks WHERE language = ? AND status = "active"', array($from)); // define counter $i = 1; // loop existing content blocks foreach ($contentBlocks as $contentBlock) { // define old id $oldId = $contentBlock['extra_id']; // init new block $newBlock = array(); // build new block $newBlock['id'] = self::getMaximumId() + $i; $newBlock['language'] = $to; $newBlock['created_on'] = BackendModel::getUTCDate(); $newBlock['edited_on'] = BackendModel::getUTCDate(); $newBlock['status'] = $contentBlock['status']; $newBlock['user_id'] = BackendAuthentication::getUser()->getUserId(); $newBlock['template'] = $contentBlock['template']; $newBlock['title'] = $contentBlock['title']; $newBlock['text'] = $contentBlock['text']; $newBlock['hidden'] = $contentBlock['hidden']; // inset content block $newId = self::insert($newBlock); // save ids for later $oldIds[] = $oldId; $newIds[$oldId] = $newId; // redefine counter ++$i; } // get the extra Ids for the content blocks if (!empty($newIds)) { // get content block extra ids $contentBlockExtraIds = (array) $db->getRecords('SELECT revision_id, extra_id FROM content_blocks WHERE revision_id IN (' . implode(',', $newIds) . ')'); // loop new ids foreach ($newIds as $oldId => $newId) { foreach ($contentBlockExtraIds as $extraId) { if ($extraId['revision_id'] == $newId) { $contentBlockIds[$oldId] = $extraId['extra_id']; } } } } // return contentBlockIds return $contentBlockIds; }
/** * Parse the form */ protected function parse() { parent::parse(); // assign the data $this->tpl->assign('item', $this->record); $this->tpl->assign('showFaqDeleteCategory', BackendFaqModel::deleteCategoryAllowed($this->id) && BackendAuthentication::isAllowedAction('DeleteCategory')); $url = BackendModel::getURLForBlock($this->URL->getModule(), 'Category'); $url404 = BackendModel::getURL(404); if ($url404 != $url) { $this->tpl->assign('detailURL', SITE_URL . $url); } }
/** * Load the datagrid */ protected function loadDataGrid() { $this->dataGrid = new BackendDataGridDB(BackendMailengineModel::QRY_DATAGRID_BROWSE_TEMPLATES); // sorting columns $this->dataGrid->setSortingColumns(array('title')); $this->dataGrid->setSortParameter('asc'); // check if this action is allowed if (BackendAuthentication::isAllowedAction('EditTemplate')) { $this->dataGrid->setColumnURL('title', BackendModel::createURLForAction('edit_template') . '&id=[id]'); $this->dataGrid->addColumn('edit', null, BL::lbl('Edit'), BackendModel::createURLForAction('edit_template') . '&id=[id]', BL::lbl('Edit')); } }
/** * Load the dataGrid */ private function loadDataGrid() { $this->dataGrid = new DataGridDB(BackendBlocksModel::QRY_DATAGRID_BROWSE_CATEGORIES, Language::getWorkingLanguage()); // check if this action is allowed if (Authentication::isAllowedAction('EditCategory')) { $this->dataGrid->addColumn('edit', null, Language::lbl('Edit'), Model::createURLForAction('EditCategory') . '&id=[id]', Language::lbl('Edit')); $this->dataGrid->setColumnURL('title', Model::createURLForAction('EditCategory') . '&id=[id]'); } // sequence $this->dataGrid->enableSequenceByDragAndDrop(); $this->dataGrid->setAttributes(array('data-action' => 'sequence_categories')); }
/** * Load the dataGrid */ protected function loadDataGrid() { $this->dataGrid = new DataGridDB(BackendBlocksModel::QRY_DATAGRID_BROWSE, Language::getWorkingLanguage()); // reform date $this->dataGrid->setColumnFunction(array('Backend\\Core\\Engine\\DataGridFunctions', 'getLongDate'), array('[created_on]'), 'created_on', true); // drag and drop sequencing $this->dataGrid->enableSequenceByDragAndDrop(); // check if this action is allowed if (Authentication::isAllowedAction('Edit')) { $this->dataGrid->addColumn('edit', null, Language::lbl('Edit'), Model::createURLForAction('Edit') . '&id=[id]', Language::lbl('Edit')); $this->dataGrid->setColumnURL('title', Model::createURLForAction('Edit') . '&id=[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); } } } }
/** * Loads the datagrids */ private function loadDataGrid() { // create datagrid $this->dataGrid = new DataGridDB($this->get('team_repository')->getDataGridQuery(), ['language' => Language::getWorkingLanguage()]); $this->dataGrid->setColumnFunction(['Rhumsaa\\Uuid\\Uuid', 'fromBytes'], ['[id]'], 'id', true); $this->dataGrid->setColumnFunction([new DataGridFunctions(), 'getLongDate'], ['[created_on]'], 'created_on', true); // check if this action is allowed if (Authentication::isAllowedAction('Edit')) { // add column $this->dataGrid->addColumn('edit', null, Language::lbl('Edit'), Model::createURLForAction('Edit'), Language::lbl('Edit')); $this->dataGrid->setColumnFunction([__CLASS__, 'addIdToEditUrl'], ['[edit]', '[id]'], 'edit', true); } $this->tpl->assign('dataGrid', (string) $this->dataGrid->getContent()); }
/** * 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')); } }
/** * Checks the settings and optionally returns an array with warnings * * @return array */ public static function checkSettings() { $warnings = array(); // check if this action is allowed if (BackendAuthentication::isAllowedAction('Settings', 'Mailmotor')) { // analytics session token if (BackendModel::get('fork.settings')->get('Mailmotor', 'cm_account') == false) { $warnings[] = array('message' => sprintf(BL::err('AnalysisNoCMAccount', 'Mailmotor'), BackendModel::createURLForAction('Settings', 'Mailmotor'))); } elseif (BackendModel::get('fork.settings')->get('Mailmotor', 'cm_client_id') == '') { // add warning $warnings[] = array('message' => sprintf(BL::err('AnalysisNoCMClientID', 'Mailmotor'), BackendModel::createURLForAction('Settings', 'Mailmtor'))); } } return $warnings; }
/** * Load the dataGrid */ protected function loadDataGrid() { $this->dataGrid = new BackendDataGridDB(BackendMailengineModel::QRY_DATAGRID_BROWSE_MAILS); // sorting columns $this->dataGrid->setSortingColumns(array('subject')); $this->dataGrid->setSortParameter('asc'); $this->dataGrid->setColumnFunction(array(new BackendDataGridFunctions(), 'getLongDate'), array('[date]'), 'date', true); // check if this action is allowed if (BackendAuthentication::isAllowedAction('Edit')) { $this->dataGrid->setColumnURL('subject', BackendModel::createURLForAction('edit') . '&id=[id]'); $this->dataGrid->addColumn('edit', null, BL::lbl('Edit'), BackendModel::createURLForAction('edit') . '&id=[id]', BL::lbl('Edit')); $this->dataGrid->addColumn('detail', null, BL::lbl('Preview'), BackendModel::createURLForAction('edit') . '&id=[id]#tabPreview', BL::lbl('Preview')); $this->dataGrid->addColumn('test', null, BL::lbl('SendTest'), BackendModel::createURLForAction('test') . '&id=[id]', BL::lbl('SendTest')); $this->dataGrid->addColumn('approve', null, BL::lbl('Send'), BackendModel::createURLForAction('send') . '&id=[id]', BL::lbl('Send')); } }
/** * 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') . '&id=[id]'); // add column $this->dataGrid->addColumn('edit', null, BL::lbl('Edit'), BackendModel::createURLForAction('EditSynonym') . '&id=[id]', BL::lbl('Edit')); } }
/** * 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') . '&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') . '&id=[id]'); } } // show the user's nickname $this->dataGrid->setColumnFunction(array('Backend\\Modules\\Users\\Engine\\Model', 'getSetting'), array('[id]', 'nickname'), 'nickname', false); }