/** * Calculate time ago. * * @param int $timestamp Unix timestamp from the past. * @return string */ public static function calculateTimeAgo($timestamp) { $secondsBetween = time() - $timestamp; // calculate $hours = floor($secondsBetween / (60 * 60)); $minutes = floor($secondsBetween / 60); $seconds = floor($secondsBetween); // today start $todayStart = (int) strtotime(date('d F Y')); // today if ($timestamp >= $todayStart) { // today if ($hours >= 1) { return BL::getLabel('Today') . ' ' . date('H:i', $timestamp); } elseif ($minutes > 1) { // more than one minute return sprintf(BL::getLabel('MinutesAgo'), $minutes); } elseif ($minutes == 1) { // one minute return BL::getLabel('OneMinuteAgo'); } elseif ($seconds > 1) { // more than one second return sprintf(BL::getLabel('SecondsAgo'), $seconds); } elseif ($seconds <= 1) { // one second return BL::getLabel('OneSecondAgo'); } } elseif ($timestamp < $todayStart && $timestamp >= $todayStart - 86400) { // yesterday return BL::getLabel('Yesterday') . ' ' . date('H:i', $timestamp); } else { // older return date('d/m/Y H:i', $timestamp); } }
/** * Load the form */ private function loadForm() { // gender dropdown values $genderValues = array('male' => \SpoonFilter::ucfirst(BL::getLabel('Male')), 'female' => \SpoonFilter::ucfirst(BL::getLabel('Female'))); // birthdate dropdown values $days = range(1, 31); $months = \SpoonLocale::getMonths(BL::getInterfaceLanguage()); $years = range(date('Y'), 1900); // create form $this->frm = new BackendForm('add'); // create elements $this->frm->addText('email'); $this->frm->addPassword('password'); $this->frm->addText('display_name'); $this->frm->addText('first_name'); $this->frm->addText('last_name'); $this->frm->addText('city'); $this->frm->addDropdown('gender', $genderValues); $this->frm->addDropdown('day', array_combine($days, $days)); $this->frm->addDropdown('month', $months); $this->frm->addDropdown('year', array_combine($years, $years)); $this->frm->addDropdown('country', Intl::getRegionBundle()->getCountryNames(BL::getInterfaceLanguage())); // set default elements dropdowns $this->frm->getField('gender')->setDefaultElement(''); $this->frm->getField('day')->setDefaultElement(''); $this->frm->getField('month')->setDefaultElement(''); $this->frm->getField('year')->setDefaultElement(''); $this->frm->getField('country')->setDefaultElement(''); }
/** * 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); }
/** * Load the form */ private function loadForm() { $this->frm = new BackendForm('add'); $this->frm->addText('name'); $this->frm->addDropdown('method', array('database' => BL::getLabel('MethodDatabase'), 'database_email' => BL::getLabel('MethodDatabaseEmail')), 'database_email'); $this->frm->addText('email'); $this->frm->addText('identifier', BackendFormBuilderModel::createIdentifier()); $this->frm->addEditor('success_message'); }
/** * Convert the count in a human readable one. * * @param int $count The count. * @param string $link The link for the count. * @return string */ public static function setClickableCount($count, $link) { $count = (int) $count; $link = (string) $link; $return = ''; if ($count > 1) { $return = '<a href="' . $link . '">' . $count . ' ' . BL::getLabel('Articles') . '</a>'; } elseif ($count == 1) { $return = '<a href="' . $link . '">' . $count . ' ' . BL::getLabel('Article') . '</a>'; } return $return; }
/** * Load the datagrids */ private function loadDataGrid() { $this->dataGrid = new BackendDataGridDB(BackendFormBuilderModel::QRY_BROWSE, BL::getWorkingLanguage()); $this->dataGrid->setHeaderLabels(array('email' => \SpoonFilter::ucfirst(BL::getLabel('Recipient')), 'sent_forms' => '')); $this->dataGrid->setSortingColumns(array('name', 'email', 'method', 'sent_forms'), 'name'); $this->dataGrid->setColumnFunction(array(new BackendFormBuilderModel(), 'formatRecipients'), array('[email]'), 'email'); $this->dataGrid->setColumnFunction(array(new BackendFormBuilderModel(), 'getLocale'), array('Method_[method]'), 'method'); $this->dataGrid->setColumnFunction(array(__CLASS__, 'parseNumForms'), array('[id]', '[sent_forms]'), 'sent_forms'); // check if edit action is allowed if (BackendAuthentication::isAllowedAction('Edit')) { $this->dataGrid->setColumnURL('name', BackendModel::createURLForAction('Edit') . '&id=[id]'); $this->dataGrid->addColumn('edit', null, BL::getLabel('Edit'), BackendModel::createURLForAction('Edit') . '&id=[id]', BL::getLabel('Edit')); } }
/** * Load the data grid for installable modules. */ private function loadDataGridInstallable() { // create datagrid $this->dataGridInstallableModules = new BackendDataGridArray($this->installableModules); $this->dataGridInstallableModules->setSortingColumns(array('raw_name')); $this->dataGridInstallableModules->setHeaderLabels(array('raw_name' => \SpoonFilter::ucfirst(BL::getLabel('Name')))); $this->dataGridInstallableModules->setColumnsHidden(array('installed', 'name', 'cronjobs_active')); // check if this action is allowed if (BackendAuthentication::isAllowedAction('DetailModule')) { $this->dataGridInstallableModules->setColumnURL('raw_name', BackendModel::createURLForAction('DetailModule') . '&module=[raw_name]'); $this->dataGridInstallableModules->addColumn('details', null, BL::lbl('Details'), BackendModel::createURLForAction('DetailModule') . '&module=[raw_name]', BL::lbl('Details')); } // check if this action is allowed if (BackendAuthentication::isAllowedAction('InstallModule')) { // add install column $this->dataGridInstallableModules->addColumn('install', null, BL::lbl('Install'), BackendModel::createURLForAction('InstallModule') . '&module=[raw_name]', BL::lbl('Install')); $this->dataGridInstallableModules->setColumnConfirm('install', sprintf(BL::msg('ConfirmModuleInstall'), '[raw_name]'), null, \SpoonFilter::ucfirst(BL::lbl('Install')) . '?'); } }
/** * Load the data grid which contains the cronjobs. */ private function loadDataGridCronjobs() { // no cronjobs = don't bother if (!isset($this->information['cronjobs'])) { return; } // create data grid $this->dataGridCronjobs = new BackendDataGridArray($this->information['cronjobs']); // hide columns $this->dataGridCronjobs->setColumnsHidden(array('minute', 'hour', 'day-of-month', 'month', 'day-of-week', 'action', 'description', 'active')); // add cronjob data column $this->dataGridCronjobs->addColumn('cronjob', BL::getLabel('Cronjob'), '[description]<br /><strong>[minute] [hour] [day-of-month] [month] [day-of-week]</strong> php ' . PATH_WWW . '/backend/cronjob module=<strong>' . $this->currentModule . '</strong> action=<strong>[action]</strong>', null, null, null, 0); // no paging $this->dataGridCronjobs->setPaging(false); }
/** * Update a certain category * * @param array $item */ public static function updateCategory(array $item) { $item['edited_on'] = BackendModel::getUTCDate(); BackendModel::getContainer()->get('database')->update('catalog_categories', $item, 'id = ?', array($item['id'])); // update extra BackendModel::updateExtra($item['extra_id'], 'data', array('id' => $item['id'], 'extra_label' => BL::getLabel('Category') . ' ' . $item['title'], 'language' => $item['language'], 'edit_url' => BackendModel::createURLForAction('EditCategory') . '&id=' . $item['id'])); }
/** * Load the data grid with groups. */ private function loadGroups() { // create the data grid $this->dgGroups = new BackendDataGridDB(BackendProfilesModel::QRY_DATAGRID_BROWSE_PROFILE_GROUPS, array($this->profile['id'])); // sorting columns $this->dgGroups->setSortingColumns(array('group_name'), 'group_name'); // disable paging $this->dgGroups->setPaging(false); // set column function $this->dgGroups->setColumnFunction(array(new BackendDataGridFunctions(), 'getLongDate'), array('[expires_on]'), 'expires_on', true); // check if this action is allowed if (BackendAuthentication::isAllowedAction('EditProfileGroup')) { // set column URLs $this->dgGroups->setColumnURL('group_name', BackendModel::createURLForAction('EditProfileGroup') . '&id=[id]&profile_id=' . $this->id); // edit column $this->dgGroups->addColumn('edit', null, BL::getLabel('Edit'), BackendModel::createURLForAction('EditProfileGroup') . '&id=[id]&profile_id=' . $this->id, BL::getLabel('Edit')); } }
/** * Load the form */ private function loadForm() { // create form $this->frm = new BackendForm('edit'); // set hidden values $rbtHiddenValues[] = array('label' => BL::lbl('Hidden'), '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', $this->record['title'], null, 'inputText title', 'inputTextError title'); $this->frm->addEditor('text', $this->record['text']); $this->frm->addEditor('introduction', $this->record['introduction']); $this->frm->addRadiobutton('hidden', $rbtHiddenValues, $this->record['hidden']); $this->frm->addCheckbox('allow_comments', $this->record['allow_comments'] === 'Y' ? true : false); $this->frm->addDropdown('category_id', $categories, $this->record['category_id']); if (count($categories) != 2) { $this->frm->getField('category_id')->setDefaultElement(''); } $this->frm->addDropdown('user_id', BackendUsersModel::getUsers(), $this->record['user_id']); $this->frm->addText('tags', BackendTagsModel::getTags($this->URL->getModule(), $this->record['id']), null, 'inputText tagBox', 'inputTextError tagBox'); $this->frm->addDate('publish_on_date', $this->record['publish_on']); $this->frm->addTime('publish_on_time', date('H:i', $this->record['publish_on'])); if ($this->imageIsAllowed) { $this->frm->addImage('image'); $this->frm->addCheckbox('delete_image'); } // meta object $this->meta = new BackendMeta($this->frm, $this->record['meta_id'], 'title', true); // set callback for generating a unique URL $this->meta->setUrlCallback('Backend\\Modules\\Blog\\Engine\\Model', 'getURL', array($this->record['id'])); }
/** * Add all element into the form */ protected function loadForm() { // is the form submitted? if ($this->frm->isSubmitted()) { /** * If the fields are disabled we don't have any values in the post. * When an error occurs in the other fields of the form the meta-fields would be cleared * therefore we alter the POST so it contains the initial values. */ if (!isset($_POST['page_title'])) { $_POST['page_title'] = isset($this->data['title']) ? $this->data['title'] : null; } if (!isset($_POST['meta_description'])) { $_POST['meta_description'] = isset($this->data['description']) ? $this->data['description'] : null; } if (!isset($_POST['meta_keywords'])) { $_POST['meta_keywords'] = isset($this->data['keywords']) ? $this->data['keywords'] : null; } if (!isset($_POST['url'])) { $_POST['url'] = isset($this->data['url']) ? $this->data['url'] : null; } if ($this->custom && !isset($_POST['meta_custom'])) { $_POST['meta_custom'] = isset($this->data['custom']) ? $this->data['custom'] : null; } if (!isset($_POST['seo_index'])) { $_POST['seo_index'] = isset($this->data['data']['seo_index']) ? $this->data['data']['seo_index'] : 'none'; } if (!isset($_POST['seo_follow'])) { $_POST['seo_follow'] = isset($this->data['data']['seo_follow']) ? $this->data['data']['seo_follow'] : 'none'; } } // add page title elements into the form $this->frm->addCheckbox('page_title_overwrite', isset($this->data['title_overwrite']) && $this->data['title_overwrite'] == 'Y'); $this->frm->addText('page_title', isset($this->data['title']) ? $this->data['title'] : null); // add meta description elements into the form $this->frm->addCheckbox('meta_description_overwrite', isset($this->data['description_overwrite']) && $this->data['description_overwrite'] == 'Y'); $this->frm->addText('meta_description', isset($this->data['description']) ? $this->data['description'] : null); // add meta keywords elements into the form $this->frm->addCheckbox('meta_keywords_overwrite', isset($this->data['keywords_overwrite']) && $this->data['keywords_overwrite'] == 'Y'); $this->frm->addText('meta_keywords', isset($this->data['keywords']) ? $this->data['keywords'] : null); // add URL elements into the form $this->frm->addCheckbox('url_overwrite', isset($this->data['url_overwrite']) && $this->data['url_overwrite'] == 'Y'); $this->frm->addText('url', isset($this->data['url']) ? urldecode($this->data['url']) : null); // advanced SEO $indexValues = array(array('value' => 'none', 'label' => Language::getLabel('None')), array('value' => 'index', 'label' => 'index'), array('value' => 'noindex', 'label' => 'noindex')); $this->frm->addRadiobutton('seo_index', $indexValues, isset($this->data['data']['seo_index']) ? $this->data['data']['seo_index'] : 'none'); $followValues = array(array('value' => 'none', 'label' => Language::getLabel('None')), array('value' => 'follow', 'label' => 'follow'), array('value' => 'nofollow', 'label' => 'nofollow')); $this->frm->addRadiobutton('seo_follow', $followValues, isset($this->data['data']['seo_follow']) ? $this->data['data']['seo_follow'] : 'none'); // should we add the meta-custom field if ($this->custom) { // add meta custom element into the form $this->frm->addTextarea('meta_custom', isset($this->data['custom']) ? $this->data['custom'] : null); } $this->frm->addHidden('meta_id', $this->id); $this->frm->addHidden('base_field_name', $this->baseFieldName); $this->frm->addHidden('custom', $this->custom); $this->frm->addHidden('class_name', $this->callback['class']); $this->frm->addHidden('method_name', $this->callback['method']); $this->frm->addHidden('parameters', \SpoonFilter::htmlspecialchars(serialize($this->callback['parameters']))); }
/** * Load the datagrid */ private function loadDataGrid() { // fetch query and parameters list($query, $parameters) = $this->buildQuery(); // create datagrid $this->dgProfiles = new BackendDataGridDB($query, $parameters); // overrule default URL $this->dgProfiles->setURL(BackendModel::createURLForAction(null, null, null, array('offset' => '[offset]', 'order' => '[order]', 'sort' => '[sort]', 'email' => $this->filter['email'], 'status' => $this->filter['status'], 'group' => $this->filter['group']), false)); // sorting columns $this->dgProfiles->setSortingColumns(array('email', 'display_name', 'status', 'registered_on'), 'email'); // set column function $this->dgProfiles->setColumnFunction(array(new BackendDataGridFunctions(), 'getLongDate'), array('[registered_on]'), 'registered_on', true); // add the mass action controls $this->dgProfiles->setMassActionCheckboxes('checkbox', '[id]'); $ddmMassAction = new \SpoonFormDropdown('action', array('addToGroup' => BL::getLabel('AddToGroup'), 'delete' => BL::getLabel('Delete')), 'addToGroup'); $ddmMassAction->setAttribute('id', 'massAction'); $ddmMassAction->setOptionAttributes('addToGroup', array('data-message-id' => 'confirmAddToGroup')); $ddmMassAction->setOptionAttributes('delete', array('data-message-id' => 'confirmDelete')); $this->dgProfiles->setMassAction($ddmMassAction); // check if this action is allowed if (BackendAuthentication::isAllowedAction('Edit')) { // set column URLs $this->dgProfiles->setColumnURL('email', BackendModel::createURLForAction('Edit') . '&id=[id]'); // add columns $this->dgProfiles->addColumn('edit', null, BL::getLabel('Edit'), BackendModel::createURLForAction('Edit', null, null, null) . '&id=[id]', BL::getLabel('Edit')); } }
/** * Load the datagrids */ private function loadDataGrid() { list($query, $parameters) = $this->buildQuery(); // create datagrid $this->dataGrid = new BackendDataGridDB($query, $parameters); // overrule default URL $this->dataGrid->setURL(BackendModel::createURLForAction(null, null, null, array('offset' => '[offset]', 'order' => '[order]', 'sort' => '[sort]', 'start_date' => $this->filter['start_date'], 'end_date' => $this->filter['end_date']), false) . '&id=' . $this->id); // sorting columns $this->dataGrid->setSortingColumns(array('sent_on'), 'sent_on'); $this->dataGrid->setSortParameter('desc'); // check if this action is allowed if (BackendAuthentication::isAllowedAction('DataDetails')) { // set colum URLs $this->dataGrid->setColumnURL('sent_on', BackendModel::createURLForAction('DataDetails', null, null, array('start_date' => $this->filter['start_date'], 'end_date' => $this->filter['end_date']), false) . '&id=[id]'); // add edit column $this->dataGrid->addColumn('details', null, BL::getLabel('Details'), BackendModel::createURLForAction('DataDetails', null, null, array('start_date' => $this->filter['start_date'], 'end_date' => $this->filter['end_date'])) . '&id=[id]', BL::getLabel('Details')); } // date $this->dataGrid->setColumnFunction(array(new BackendFormBuilderModel(), 'calculateTimeAgo'), '[sent_on]', 'sent_on', false); $this->dataGrid->setColumnFunction('ucfirst', '[sent_on]', 'sent_on', false); // add the multicheckbox column $this->dataGrid->setMassActionCheckboxes('checkbox', '[id]'); // mass action $ddmMassAction = new \SpoonFormDropdown('action', array('delete' => BL::getLabel('Delete')), 'delete'); $ddmMassAction->setOptionAttributes('delete', array('data-message-id' => 'confirmDelete')); $this->dataGrid->setMassAction($ddmMassAction); }
/** * Update a certain category * * @param array $item */ public static function updateCategory(array $item) { $item['edited_on'] = BackendModel::getUTCDate(); BackendModel::get('database')->update('blocks_categories', $item, 'id = ?', array($item['id'])); // build array $extra['data'] = serialize(array('language' => Language::getWorkingLanguage(), 'extra_label' => 'Block ' . Language::getLabel('Category') . ' ' . $item['title'], 'id' => $item['id'])); // update extra BackendModel::get('database')->update('modules_extras', $extra, 'id= ?', array($item['extra_id'])); }
/** * Convert the count in a human readable one. * * @param int $count * @param string $link * @return string */ public static function setClickableCount($count, $link) { // redefine $count = (int) $count; $link = (string) $link; // return link in case of more than one item, one item, other if ($count > 1) { return '<a href="' . $link . '">' . $count . ' ' . BL::getLabel('Agenda') . '</a>'; } if ($count == 1) { return '<a href="' . $link . '">' . $count . ' ' . BL::getLabel('Agenda') . '</a>'; } else { return BL::getLabel('NoAgenda'); } }
/** * Load the data grid for installable modules. */ private function loadDataGridInstallable() { // create datagrid $this->dataGridInstallableModules = new DataGridArray($this->installableModules); $this->dataGridInstallableModules->setSortingColumns(array('raw_name')); $this->dataGridInstallableModules->setHeaderLabels(array('raw_name' => \SpoonFilter::ucfirst(Language::getLabel('Name')))); $this->dataGridInstallableModules->setColumnsHidden(array('installed', 'name', 'cronjobs_active')); // check if this action is allowed if (Authentication::isAllowedAction('detail_module')) { $this->dataGridInstallableModules->setColumnURL('raw_name', Model::createURLForAction('detail_module') . '&module=[raw_name]'); $this->dataGridInstallableModules->addColumn('details', null, Language::lbl('Details'), Model::createURLForAction('detail_module') . '&module=[raw_name]', Language::lbl('Details')); } // add create zip column $this->dataGridInstallableModules->addColumn('install', null, ucfirst(Language::lbl('CreateZip')), Model::createURLForAction('create_zip', 'module_maker') . '&module=[raw_name]', ucfirst(Language::lbl('CreateZip'))); }
public static function getStatsOverlay($id) { //--Get the mail $stats = self::getStatsMail($id); $mail = $stats['text']; //--Get the total stats from the clicked links $links = self::getStatsLinksClickedTotalArray($id); $total = 0; //--Calculate the total foreach ($links as $link) { $total += $link["clicked"]; } //--Loop the links foreach ($links as $link) { //--Encrypt the id $encrypt = self::encryptId($link['id']); //---Find the link in the mail (translate the ID) $pos = strpos($mail, $encrypt . "-"); //--- (find double or single quote) while ($pos > 0) { if (substr($mail, $pos, 1) == "'") { $quote = "'"; $posQuoteFirst = $pos; } if (substr($mail, $pos, 1) == '"') { $quote = '"'; $posQuoteFirst = $pos; } //--- Search the start of the a-element if (substr($mail, $pos, 2) == "<a") { break; } $pos--; } //--Find the last quote $posQuoteLast = $posQuoteFirst + 1; while ($posQuoteLast != false && $posQuoteLast <= strlen($mail)) { //--Search the last quote if (substr($mail, $posQuoteLast, 1) != $quote) { $posQuoteLast++; } else { //--Stop in the while break; } } //--Find the correct encrypted link $encryptedLink = substr($mail, $posQuoteFirst + 1, $posQuoteLast - 1 - $posQuoteFirst); //--Replace the encrypted link with the correct one (so we don't add another click if we click on the overlay) $mail = str_replace($encryptedLink, $link['url'], $mail); //--Get correct label $strClick = $link['clicked'] == 1 ? BL::getLabel("Click") : BL::getLabel("Clicks"); //--Calculate percentage $percentage = $link['clicked'] > 0 ? round($link['clicked'] / $total, 3) * 100 : 0; //---Add a absotule div with the information about the link $span = "<span style='background-color:#EBF3F9;border:1px solid #BED7E9;color:#000;font-size:12px;height:auto;margin:15px 0 0 0;padding:5px 10px;position:absolute;width:auto;'>" . $link['clicked'] . " " . $strClick . " (" . $percentage . "%)</span>"; //--Add span to the mail $mail = substr($mail, 0, $pos) . $span . substr($mail, $pos); } //--Find the open-image url (at the end of the page) $posImage = strrpos($mail, "<img"); //--Replace the open-image-tag $mail = substr($mail, 0, $posImage) . "</body></html>"; return $mail; }
/** * Fetch the list of status, but for a dropdown. * * @return array */ public static function getStatusForDropDown() { // fetch types $status = BackendModel::getContainer()->get('database')->getEnumValues('profiles', 'status'); // init $labels = $status; // loop and build labels foreach ($labels as &$row) { $row = \SpoonFilter::ucfirst(BL::getLabel(\SpoonFilter::ucfirst($row))); } // build array return array_combine($status, $labels); }
/** * Get all the categories * * @param bool [optional] $includeCount * @return array */ public static function getAllGroupsTree() { $db = BackendModel::getContainer()->get('database'); $allCategories = (array) $db->getRecords('SELECT i.id, i.parent_id, CONCAT(i.title, " (", COUNT(g.id) ,")") AS title FROM addresses_groups AS i LEFT OUTER JOIN addresses_groups AS g ON g.parent_id = i.id GROUP BY i.id ORDER BY i.sequence'); $tree = array(); $categoryTree = self::buildTree($tree, $allCategories); $categoryTree = array(ucfirst(BL::getLabel('None'))) + $categoryTree; return $categoryTree; }
/** * Load the form */ private function loadForm() { $this->frm = new BackendForm('edit'); $this->frm->addText('name', $this->record['name']); $this->frm->addDropdown('method', array('database' => BL::getLabel('MethodDatabase'), 'database_email' => BL::getLabel('MethodDatabaseEmail')), $this->record['method']); $this->frm->addText('email', implode(',', (array) $this->record['email'])); $this->frm->addText('identifier', $this->record['identifier']); $this->frm->addEditor('success_message', $this->record['success_message']); // textfield dialog $this->frm->addText('textbox_label'); $this->frm->addText('textbox_value'); $this->frm->addText('textbox_placeholder'); $this->frm->addCheckbox('textbox_required'); $this->frm->addCheckbox('textbox_reply_to'); $this->frm->addText('textbox_required_error_message'); $this->frm->addDropdown('textbox_validation', array('' => '', 'email' => BL::getLabel('Email'), 'numeric' => BL::getLabel('Numeric'))); $this->frm->addText('textbox_validation_parameter'); $this->frm->addText('textbox_error_message'); // textarea dialog $this->frm->addText('textarea_label'); $this->frm->addTextarea('textarea_value'); $this->frm->getField('textarea_value')->setAttribute('cols', 30); $this->frm->addText('textarea_placeholder'); $this->frm->addCheckbox('textarea_required'); $this->frm->addText('textarea_required_error_message'); $this->frm->addDropdown('textarea_validation', array('' => '')); $this->frm->addText('textarea_validation_parameter'); $this->frm->addText('textarea_error_message'); // datetime dialog $this->frm->addText('datetime_label'); $this->frm->addDropdown('datetime_value_amount', array('' => '', '1' => '+1', '2' => '+2', '3' => '+3', '4' => '+4', '5' => '+5')); $this->frm->addDropdown('datetime_value_type', array('' => '', 'today' => BL::getLabel('Today'), 'day' => BL::getLabel('Day'), 'week' => BL::getLabel('Week'), 'month' => BL::getLabel('Month'), 'year' => BL::getLabel('Year'))); $this->frm->addDropdown('datetime_type', array('date' => BL::getLabel('Date'), 'time' => BL::getLabel('Time'))); $this->frm->addCheckbox('datetime_required'); $this->frm->addText('datetime_required_error_message'); $this->frm->addDropdown('datetime_type', array('date' => BL::getLabel('Date'), 'time' => BL::getLabel('Time'))); $this->frm->addDropdown('datetime_validation', array('' => '', 'time' => BL::getLabel('Time'))); //$this->frm->addText('datetime_validation_parameter'); $this->frm->addText('datetime_error_message'); // dropdown dialog $this->frm->addText('dropdown_label'); $this->frm->addText('dropdown_values'); $this->frm->addDropdown('dropdown_default_value', array('' => ''))->setAttribute('rel', 'dropDownValues'); $this->frm->addCheckbox('dropdown_required'); $this->frm->addText('dropdown_required_error_message'); // radiobutton dialog $this->frm->addText('radiobutton_label'); $this->frm->addText('radiobutton_values'); $this->frm->addDropdown('radiobutton_default_value', array('' => ''))->setAttribute('rel', 'radioButtonValues'); $this->frm->addCheckbox('radiobutton_required'); $this->frm->addText('radiobutton_required_error_message'); // checkbox dialog $this->frm->addText('checkbox_label'); $this->frm->addText('checkbox_values'); $this->frm->addDropdown('checkbox_default_value', array('' => ''))->setAttribute('rel', 'checkBoxValues'); $this->frm->addCheckbox('checkbox_required'); $this->frm->addText('checkbox_required_error_message'); // heading dialog $this->frm->addText('heading'); // paragraph dialog $this->frm->addEditor('paragraph'); $this->frm->getField('paragraph')->setAttribute('cols', 30); // submit dialog $this->frm->addText('submit'); }
/** * Loads the datagrid * * @return void */ private function loadDataGrid() { // create datagrid $this->dataGrid = new BackendDataGridDB(BackendSlideshowModel::QRY_DATAGRID_BROWSE_IMAGES, array($this->id)); // add mass checkboxes $this->dataGrid->setMassActionCheckboxes('checkbox', '[id]'); // disable paging $this->dataGrid->setPaging(false); // create a thumbnail preview $this->dataGrid->addColumn('preview', 'Preview'); $this->dataGrid->setColumnFunction(array('Backend\\Modules\\Slideshow\\Engine\\Model', 'getPreview'), '[filename]', 'preview', true); // enable drag and drop $this->dataGrid->enableSequenceByDragAndDrop(); // our JS needs to know an id, so we can send the new order $this->dataGrid->setRowAttributes(array('id' => '[id]')); $this->dataGrid->setAttributes(array('data-action' => "ImageSequence")); // hide $this->dataGrid->setColumnHidden('filename'); // add edit column $this->dataGrid->addColumn('edit', null, BL::lbl('Edit'), BackendModel::createURLForAction('EditImage') . '&id=[id]&galleryid=' . $this->id, BL::lbl('Edit')); // set column order $this->dataGrid->setColumnsSequence('dragAndDropHandle', 'checkbox', 'preview', 'hidden', 'caption', 'edit'); // add mass action dropdown $ddmMassAction = new \SpoonFormDropdown('action', array('delete' => BL::getLabel('Delete'), 'hide' => BL::getLabel('Hide'), 'publish' => BL::getLabel('Publish')), 'delete'); $ddmMassAction->setAttribute('id', 'actionDeleted'); $this->dataGrid->setMassAction($ddmMassAction); $this->frm->add($ddmMassAction); }
/** * Parse the header into the template */ public function parse() { // put the page title in the <title> $this->tpl->assign('page_title', BL::getLabel($this->URL->getModule())); // parse CSS $this->parseCSS(); // parse JS $this->parseJS(); }
/** * Get modules based on the directory listing in the backend application. * * If a module contains a info.xml it will be parsed. * * @return array */ public static function getModules() { $installedModules = (array) BackendModel::getContainer()->getParameter('installed_modules'); $modules = BackendModel::getModulesOnFilesystem(false); $manageableModules = array(); // get more information for each module foreach ($modules as $moduleName) { if (in_array($moduleName, self::$ignoredModules)) { continue; } $module = array(); $module['id'] = 'module_' . $moduleName; $module['raw_name'] = $moduleName; $module['name'] = \SpoonFilter::ucfirst(BL::getLabel(\SpoonFilter::toCamelCase($moduleName))); $module['description'] = ''; $module['version'] = ''; $module['installed'] = false; $module['cronjobs_active'] = true; if (in_array($moduleName, $installedModules)) { $module['installed'] = true; } try { $infoXml = @new \SimpleXMLElement(BACKEND_MODULES_PATH . '/' . $module['raw_name'] . '/info.xml', LIBXML_NOCDATA, true); $info = self::processModuleXml($infoXml); // set fields if they were found in the XML if (isset($info['description'])) { $module['description'] = BackendDataGridFunctions::truncate($info['description'], 80); } if (isset($info['version'])) { $module['version'] = $info['version']; } // check if cronjobs are set if (isset($info['cronjobs'])) { foreach ($info['cronjobs'] as $cronjob) { if (!$cronjob['active']) { $module['cronjobs_active'] = false; break; } } } } catch (\Exception $e) { // don't act upon error, we simply won't possess some info } $manageableModules[] = $module; } return $manageableModules; }
/** * Parse amount of profiles for the datagrid. * * @param int $groupId Group id. * @param int $numProfiles Number of profiles. * @return string */ public static function parseNumProfiles($groupId, $numProfiles) { // 1 item if ($numProfiles == 1) { $output = '1 ' . BL::getLabel('Profile'); } else { // no items $output = $numProfiles . ' ' . BL::getLabel('Profiles'); } // check if this action is allowed if (BackendAuthentication::isAllowedAction('Edit')) { // complete output $output = '<a href="' . BackendModel::createURLForAction('Index') . '&group=' . $groupId . '" title="' . $output . '">' . $output . '</a>'; } return $output; }
/** * @param $email * @param $postedFields * @param $form * @param $dataId */ public static function mailEndUser($email, $postedFields, $form, $dataId) { $field_info = ''; foreach ($postedFields as $field) { $label = isset($field['label']) ? $field['label'] : ''; $value = isset($field['value']) ? unserialize($field['value']) : ''; $field_info .= $label . ': ' . $value . "\n"; } $title = sprintf(BL::getLabel('Subject', self::MODULE_NAME), $form['name']); $data = array('title' => $title, 'fields' => $field_info); $translations = array('ReceivedData', 'Greetings'); foreach ($translations as $translation) { $data[$translation] = BL::getLabel($translation, self::MODULE_NAME); } /** @var $mailer Mailer */ $mailer = BackendModel::get('mailer'); if ($mailer) { // @TODO remove this when https://github.com/forkcms/forkcms/issues/716 is fixed. define('FRONTEND_LANGUAGE', SITE_DEFAULT_LANGUAGE); // work around $result = $mailer->addEmail($title, BACKEND_MODULES_PATH . '/' . self::MODULE_NAME . '/Layout/Templates/Mails/Notification.tpl', $data, $email); } $useLog = BackendModel::getModuleSetting(self::MODULE_NAME, 'log', true); if ($useLog) { $logger = BackendModel::get('logger'); if ($logger) { $logger->notice(sprintf('Sending email to %s, status %s', $email, $result ? 'OK' : 'FAILED'), $data); } } $addExtraData = BackendModel::getModuleSetting(self::MODULE_NAME, 'add_data', true); $error = BL::getLabel('Error', self::MODULE_NAME); $success = BL::getLabel('OK', self::MODULE_NAME); if ($addExtraData) { $label = BL::getLabel('DataLabel', self::MODULE_NAME); $item = array('data_id' => $dataId, 'label' => $label, 'value' => serialize($email . ' - ' . ($result ? $success : $error))); /** @var $db SpoonDatabase */ $db = BackendModel::getContainer()->get('database'); $db->insert('forms_data_fields', $item); } }