lbl() public static method

Get a label from the language-file
public static lbl ( string $key, string $module = null ) : string
$key string The key to get.
$module string The module wherein we should search.
return string
Beispiel #1
0
 /**
  * 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, 'form-control title', 'form-control danger 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, 'form-control js-tags-input', 'form-control danger js-tags-input');
     $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);
 }
Beispiel #2
0
 /**
  * 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);
 }
Beispiel #3
0
 /**
  * Load the forms
  */
 private function load()
 {
     $this->frm = new BackendForm(null, null, 'post', true, false);
     $this->frm->addText('backend_email')->setAttribute('placeholder', \SpoonFilter::ucfirst(BL::lbl('Email')))->setAttribute('type', 'email');
     $this->frm->addPassword('backend_password')->setAttribute('placeholder', \SpoonFilter::ucfirst(BL::lbl('Password')));
     $this->frmForgotPassword = new BackendForm('forgotPassword');
     $this->frmForgotPassword->addText('backend_email_forgot');
 }
Beispiel #4
0
 /**
  * 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')));
 }
Beispiel #5
0
 /**
  * Loads the settings form
  */
 private function loadForm()
 {
     $this->frm = new BackendForm('settings');
     // add map info (widgets)
     $this->frm->addDropdown('zoom_level_widget', array_combine(array_merge(array('auto'), range(3, 18)), array_merge(array(BL::lbl('Auto', $this->getModule())), range(3, 18))), $this->get('fork.settings')->get($this->URL->getModule(), 'zoom_level_widget', 13));
     $this->frm->addText('width_widget', $this->get('fork.settings')->get($this->URL->getModule(), 'width_widget'));
     $this->frm->addText('height_widget', $this->get('fork.settings')->get($this->URL->getModule(), 'height_widget'));
     $this->frm->addDropdown('map_type_widget', array('ROADMAP' => BL::lbl('Roadmap', $this->getModule()), 'SATELLITE' => BL::lbl('Satellite', $this->getModule()), 'HYBRID' => BL::lbl('Hybrid', $this->getModule()), 'TERRAIN' => BL::lbl('Terrain', $this->getModule()), 'STREET_VIEW' => BL::lbl('StreetView', $this->getModule())), $this->get('fork.settings')->get($this->URL->getModule(), 'map_type_widget', 'roadmap'));
 }
Beispiel #6
0
 /**
  * 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]');
     }
 }
Beispiel #7
0
 /**
  * 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'));
     }
 }
Beispiel #8
0
 /**
  * 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'));
     }
 }
Beispiel #9
0
 /**
  * Load the form
  */
 private function loadForm()
 {
     // get values for the form
     $rbtHiddenValues[] = array('label' => BL::lbl('Hidden'), 'value' => 'Y');
     $rbtHiddenValues[] = array('label' => BL::lbl('Published'), 'value' => 'N');
     $categories = BackendFaqModel::getCategories();
     // create form
     $this->frm = new BackendForm('edit');
     $this->frm->addText('title', $this->record['question'], null, 'form-control title', 'form-control danger title');
     $this->frm->addEditor('answer', $this->record['answer']);
     $this->frm->addRadiobutton('hidden', $rbtHiddenValues, $this->record['hidden']);
     $this->frm->addDropdown('category_id', $categories, $this->record['category_id']);
     $this->frm->addText('tags', BackendTagsModel::getTags($this->URL->getModule(), $this->record['id']), null, 'form-control js-tags-input', 'form-control danger js-tags-input');
     $this->meta = new BackendMeta($this->frm, $this->record['meta_id'], 'title', true);
 }
Beispiel #10
0
 /**
  * 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'));
     }
 }
Beispiel #11
0
 /**
  * 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);
 }
Beispiel #12
0
 /**
  * Loads the datagrids
  */
 private function loadDataGrid()
 {
     // create datagrid
     $this->dataGrid = new BackendDataGridDB(BackendSearchModel::QRY_DATAGRID_BROWSE_STATISTICS, BL::getWorkingLanguage());
     // hide column
     $this->dataGrid->setColumnsHidden('data');
     // create column
     $this->dataGrid->addColumn('referrer', BL::lbl('Referrer'));
     // header labels
     $this->dataGrid->setHeaderLabels(array('time' => \SpoonFilter::ucfirst(BL::lbl('SearchedOn'))));
     // set column function
     $this->dataGrid->setColumnFunction(array(__CLASS__, 'setReferrer'), '[data]', 'referrer');
     $this->dataGrid->setColumnFunction(array(new BackendDataGridFunctions(), 'getLongDate'), array('[time]'), 'time', true);
     // sorting columns
     $this->dataGrid->setSortingColumns(array('time', 'term'), 'time');
     $this->dataGrid->setSortParameter('desc');
 }
Beispiel #13
0
 /**
  * Load the form
  */
 private function loadForm()
 {
     // create form
     $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 = BackendFaqModel::getCategories();
     // create elements
     $this->frm->addText('title', null, null, 'form-control title', 'form-control danger title');
     $this->frm->addEditor('answer');
     $this->frm->addRadiobutton('hidden', $rbtHiddenValues, 'N');
     $this->frm->addDropdown('category_id', $categories);
     $this->frm->addText('tags', null, null, 'form-control js-tags-input', 'form-control danger js-tags-input');
     // meta
     $this->meta = new BackendMeta($this->frm, null, 'title', true);
 }
Beispiel #14
0
 /**
  * Loads the datagrids
  */
 private function loadDataGrid()
 {
     // create datagrid
     $this->dataGrid = new BackendDataGridDB(BackendBlogModel::QRY_DATAGRID_BROWSE_CATEGORIES, array('active', BL::getWorkingLanguage()));
     // set headers
     $this->dataGrid->setHeaderLabels(array('num_items' => \SpoonFilter::ucfirst(BL::lbl('Amount'))));
     // sorting columns
     $this->dataGrid->setSortingColumns(array('title', 'num_items'), 'title');
     // convert the count into a readable and clickable one
     $this->dataGrid->setColumnFunction(array(__CLASS__, 'setClickableCount'), array('[num_items]', BackendModel::createURLForAction('Index') . '&category=[id]'), 'num_items', true);
     // disable paging
     $this->dataGrid->setPaging(false);
     // add attributes, so the inline editing has all the needed data
     $this->dataGrid->setColumnAttributes('title', array('data-id' => '{id:[id]}'));
     // check if this action is allowed
     if (BackendAuthentication::isAllowedAction('EditCategory')) {
         // set column URLs
         $this->dataGrid->setColumnURL('title', BackendModel::createURLForAction('EditCategory') . '&id=[id]');
         // add column
         $this->dataGrid->addColumn('edit', null, BL::lbl('Edit'), BackendModel::createURLForAction('EditCategory') . '&id=[id]', BL::lbl('Edit'));
     }
 }
Beispiel #15
0
 /**
  * Loads the datagrids
  */
 private function loadDataGrid()
 {
     // create datagrid
     $this->dataGrid = new BackendDataGridDB(BackendTagsModel::QRY_DATAGRID_BROWSE, BL::getWorkingLanguage());
     // header labels
     $this->dataGrid->setHeaderLabels(array('tag' => \SpoonFilter::ucfirst(BL::lbl('Name')), 'num_tags' => \SpoonFilter::ucfirst(BL::lbl('Amount'))));
     // sorting columns
     $this->dataGrid->setSortingColumns(array('tag', 'num_tags'), 'num_tags');
     $this->dataGrid->setSortParameter('desc');
     // add the multicheckbox column
     $this->dataGrid->setMassActionCheckboxes('check', '[id]');
     // add mass action dropdown
     $ddmMassAction = new \SpoonFormDropdown('action', array('delete' => BL::lbl('Delete')), 'delete', false, 'form-control', 'form-control danger');
     $ddmMassAction->setOptionAttributes('delete', array('data-target' => '#confirmDelete'));
     $this->dataGrid->setMassAction($ddmMassAction);
     // add attributes, so the inline editing has all the needed data
     $this->dataGrid->setColumnAttributes('tag', array('data-id' => '{id:[id]}'));
     // check if this action is allowed
     if (BackendAuthentication::isAllowedAction('Edit')) {
         // add column
         $this->dataGrid->addColumn('edit', null, BL::lbl('Edit'), BackendModel::createURLForAction('Edit') . '&id=[id]', BL::lbl('Edit'));
     }
 }
Beispiel #16
0
 /**
  * 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->enableSequenceByDragAndDrop();
         $dataGrid->setColumnsHidden(array('category_id', 'sequence'));
         $dataGrid->setColumnAttributes('question', array('class' => 'title'));
         $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' => 'table table-hover table-striped fork-data-grid jsDataGrid sequenceByDragAndDrop emptyGrid'));
     $this->emptyDatagrid->setHeaderLabels(array('edit' => null, 'dragAndDropHandle' => null));
 }
Beispiel #17
0
 /**
  * Loads the dataGrid
  */
 private function loadDataGrid()
 {
     // are multiple categories allowed?
     $this->multipleCategoriesAllowed = $this->get('fork.settings')->get('Faq', 'allow_multiple_categories', true);
     // create dataGrid
     $this->dataGrid = new BackendDataGridDB(BackendFaqModel::QRY_DATAGRID_BROWSE_CATEGORIES, BL::getWorkingLanguage());
     $this->dataGrid->setHeaderLabels(array('num_items' => \SpoonFilter::ucfirst(BL::lbl('Amount'))));
     if ($this->multipleCategoriesAllowed) {
         $this->dataGrid->enableSequenceByDragAndDrop();
     } else {
         $this->dataGrid->setColumnsHidden(array('sequence'));
     }
     $this->dataGrid->setRowAttributes(array('id' => '[id]'));
     $this->dataGrid->setPaging(false);
     // check if this action is allowed
     if (BackendAuthentication::isAllowedAction('Index')) {
         $this->dataGrid->setColumnFunction(array(__CLASS__, 'setClickableCount'), array('[num_items]', BackendModel::createURLForAction('Index') . '&category=[id]'), 'num_items', true);
     }
     // check if this action is allowed
     if (BackendAuthentication::isAllowedAction('EditCategory')) {
         $this->dataGrid->setColumnURL('title', BackendModel::createURLForAction('EditCategory') . '&id=[id]');
         $this->dataGrid->addColumn('edit', null, BL::lbl('Edit'), BackendModel::createURLForAction('EditCategory') . '&id=[id]', BL::lbl('Edit'));
     }
 }
Beispiel #18
0
 /**
  * Get the possible block types
  *
  * @return array
  */
 public static function getTypes()
 {
     return array('rich_text' => BL::lbl('Editor'), 'block' => BL::lbl('Module'), 'widget' => BL::lbl('Widget'));
 }
Beispiel #19
0
 /**
  * Get a label from the language-file
  *
  * @param string $key The key to get.
  * @param string $module The module wherein we should search.
  *
  * @deprecated
  *
  * @return string
  */
 public static function lbl($key, $module = null)
 {
     trigger_error('Backend\\Core\\Engine\\Language is deprecated.
          It has been moved to Backend\\Core\\Language\\Language', E_USER_DEPRECATED);
     return parent::lbl($key, $module);
 }
Beispiel #20
0
 /**
  * Load the datagrid
  */
 private function loadDataGrid()
 {
     // init vars
     $langWidth = 60 / count($this->filter['language']);
     // if nothing is submitted
     // we don't need to fetch all the locale
     $this->hasSubmissions = '' !== $this->filter['application'] . $this->filter['module'] . $this->filter['name'] . $this->filter['value'];
     if ($this->hasSubmissions) {
         // get all the translations for the selected languages
         $translations = BackendLocaleModel::getTranslations($this->filter['application'], $this->filter['module'], $this->filter['type'], $this->filter['language'], $this->filter['name'], $this->filter['value']);
     }
     // create datagrids
     $this->dgLabels = new BackendDataGridArray(isset($translations['lbl']) ? $translations['lbl'] : array());
     $this->dgMessages = new BackendDataGridArray(isset($translations['msg']) ? $translations['msg'] : array());
     $this->dgErrors = new BackendDataGridArray(isset($translations['err']) ? $translations['err'] : array());
     $this->dgActions = new BackendDataGridArray(isset($translations['act']) ? $translations['act'] : array());
     // put the datagrids (references) in an array so we can loop them
     $dataGrids = array('lbl' => &$this->dgLabels, 'msg' => &$this->dgMessages, 'err' => &$this->dgErrors, 'act' => &$this->dgActions);
     // loop the datagrids (as references)
     foreach ($dataGrids as $type => &$dataGrid) {
         /** @var $dataGrid BackendDataGridArray */
         $dataGrid->setSortingColumns(array('module', 'name', 'application'), 'name');
         // disable paging
         $dataGrid->setPaging(false);
         // set header label for reference code
         $dataGrid->setHeaderLabels(array('name' => \SpoonFilter::ucfirst(BL::lbl('ReferenceCode'))));
         // hide the application when only one application is shown
         if ($this->filter['application'] != '') {
             $dataGrid->setColumnHidden('application');
         }
         // hide edite_on
         $dataGrid->setColumnHidden('edited_on');
         // set column attributes for each language
         foreach ($this->filter['language'] as $lang) {
             // add a class for the inline edit
             $dataGrid->setColumnAttributes($lang, array('class' => 'translationValue'));
             // add attributes, so the inline editing has all the needed data
             $dataGrid->setColumnAttributes($lang, array('data-id' => '{language: \'' . $lang . '\',application: \'[application]\',module: \'[module]\',name: \'[name]\',type: \'' . $type . '\'}'));
             // escape the double quotes
             $dataGrid->setColumnFunction(array('SpoonFilter', 'htmlentities'), array('[' . $lang . ']', null, ENT_QUOTES), $lang, true);
             if ($type == 'act') {
                 $dataGrid->setColumnFunction('urldecode', array('[' . $lang . ']'), $lang, true);
             }
             // set header labels
             $dataGrid->setHeaderLabels(array($lang => \SpoonFilter::ucfirst(BL::lbl(mb_strtoupper($lang)))));
             // only 1 language selected?
             if (count($this->filter['language']) == 1) {
                 $dataGrid->setColumnAttributes($lang, array('style' => 'width: ' . $langWidth . '%'));
                 // add id of translation for the export
                 $dataGrid->setColumnAttributes($lang, array('data-numeric-id' => '[translation_id]'));
                 // Hide translation_id column (only if only one language is selected
                 // because the key doesn't exist if more than 1 language is selected)
                 $dataGrid->setColumnHidden('translation_id');
                 // check if this action is allowed
                 if (BackendAuthentication::isAllowedAction('Add')) {
                     // add copy button
                     $dataGrid->addColumnAction('copy', null, BL::lbl('Copy'), BackendModel::createURLForAction('Add') . '&id=[translation_id]' . $this->filterQuery);
                 }
                 // check if this action is allowed
                 if (BackendAuthentication::isAllowedAction('Edit')) {
                     // add edit button
                     $dataGrid->addColumn('edit', null, BL::lbl('Edit'), BackendModel::createURLForAction('Edit') . '&id=[translation_id]' . $this->filterQuery);
                 }
             } else {
                 // add id of translation for the export
                 $dataGrid->setColumnAttributes($lang, array('data-numeric-id' => '[translation_id_' . $lang . ']'));
                 $dataGrid->setColumnHidden('translation_id_' . $lang);
                 //ugly fix but the browser does funny things with the percentage when showing lots of languages
                 $dataGrid->setColumnAttributes($lang, array('style' => 'width: ' . $langWidth . '%; max-width: ' . 600 / count($this->filter['language']) . 'px;'));
             }
         }
     }
 }
Beispiel #21
0
 /**
  * Load the data grid for installed modules.
  */
 private function loadDataGridInstalled()
 {
     // create datagrid
     $this->dataGridInstalledModules = new BackendDataGridArray($this->installedModules);
     $this->dataGridInstalledModules->setSortingColumns(array('name'));
     $this->dataGridInstalledModules->setColumnsHidden(array('installed', 'raw_name', 'cronjobs_active'));
     // check if this action is allowed
     if (BackendAuthentication::isAllowedAction('DetailModule')) {
         $this->dataGridInstalledModules->setColumnURL('name', BackendModel::createURLForAction('DetailModule') . '&module=[raw_name]');
         $this->dataGridInstalledModules->addColumn('details', null, BL::lbl('Details'), BackendModel::createURLForAction('DetailModule') . '&module=[raw_name]', BL::lbl('Details'));
     }
     // add the greyed out option to modules that have warnings
     $this->dataGridInstalledModules->addColumn('hidden');
     $this->dataGridInstalledModules->setColumnFunction(array(new BackendExtensionsModel(), 'hasModuleWarnings'), array('[raw_name]'), array('hidden'));
 }
Beispiel #22
0
 /**
  * Loads the datagrid with the most recent posts.
  */
 private function loadDataGridRecentPosts()
 {
     // filter on category?
     if ($this->categoryId != null) {
         // create datagrid
         $this->dgRecent = new BackendDataGridDB(BackendBlogModel::QRY_DATAGRID_BROWSE_RECENT_FOR_CATEGORY, array($this->categoryId, 'active', BL::getWorkingLanguage(), 4));
         // set the URL
         $this->dgRecent->setURL('&category=' . $this->categoryId, true);
     } else {
         // create datagrid
         $this->dgRecent = new BackendDataGridDB(BackendBlogModel::QRY_DATAGRID_BROWSE_RECENT, array('active', BL::getWorkingLanguage(), 4));
     }
     // set headers
     $this->dgRecent->setHeaderLabels(array('user_id' => \SpoonFilter::ucfirst(BL::lbl('Author'))));
     // hide columns
     $this->dgRecent->setColumnsHidden(array('revision_id'));
     // set paging
     $this->dgRecent->setPaging(false);
     // set column functions
     $this->dgRecent->setColumnFunction(array(new BackendDataGridFunctions(), 'getLongDate'), array('[edited_on]'), 'edited_on', true);
     $this->dgRecent->setColumnFunction(array(new BackendDataGridFunctions(), 'getUser'), array('[user_id]'), 'user_id', true);
     // our JS needs to know an id, so we can highlight it
     $this->dgRecent->setRowAttributes(array('id' => 'row-[revision_id]'));
     // check if this action is allowed
     if (BackendAuthentication::isAllowedAction('Edit')) {
         // set colum URLs
         $this->dgRecent->setColumnURL('title', BackendModel::createURLForAction('Edit') . '&id=[id]&category=' . $this->categoryId);
         // add edit column
         $this->dgRecent->addColumn('edit', null, BL::lbl('Edit'), BackendModel::createURLForAction('Edit') . '&id=[id]&category=' . $this->categoryId, BL::lbl('Edit'));
     }
 }
Beispiel #23
0
 /**
  * Fetch the list of available themes
  *
  * @return array
  */
 public static function getThemes()
 {
     $records = array();
     $records['Core'] = array('value' => 'Core', 'label' => BL::lbl('NoTheme'), 'thumbnail' => '/src/Frontend/Core/Layout/images/thumbnail.png', 'installed' => self::isThemeInstalled('Core'), 'installable' => false);
     $finder = new Finder();
     foreach ($finder->directories()->in(FRONTEND_PATH . '/Themes')->depth(0) as $directory) {
         $pathInfoXml = PATH_WWW . '/src/Frontend/Themes/' . $directory->getBasename() . '/info.xml';
         if (!is_file($pathInfoXml)) {
             throw new Exception('info.xml is missing for the theme ' . $directory->getBasename());
         }
         try {
             $infoXml = @new \SimpleXMLElement($pathInfoXml, LIBXML_NOCDATA, true);
             $information = self::processThemeXml($infoXml);
             if (!$information) {
                 throw new Exception('Invalid info.xml');
             }
         } catch (Exception $e) {
             $information['thumbnail'] = 'thumbnail.png';
         }
         $item = array();
         $item['value'] = $directory->getBasename();
         $item['label'] = $directory->getBasename();
         $item['thumbnail'] = '/src/Frontend/Themes/' . $item['value'] . '/' . $information['thumbnail'];
         $item['installed'] = self::isThemeInstalled($item['value']);
         $item['installable'] = isset($information['templates']);
         $records[$item['value']] = $item;
     }
     return (array) $records;
 }
Beispiel #24
0
 /**
  * Load the form
  */
 private function loadForm()
 {
     // create form
     $this->frm = new BackendForm('add');
     // widgets available?
     if (isset($this->widgets)) {
         // loop through widgets
         foreach ($this->widgets as $j => $widget) {
             // add widget checkboxes
             $widgetBoxes[$j]['check'] = '<span>' . $this->frm->addCheckbox('widgets_' . $widget['checkbox_name'], true)->parse() . '</span>';
             $widgetBoxes[$j]['module'] = \SpoonFilter::ucfirst(BL::lbl($widget['module_name']));
             $widgetBoxes[$j]['widget'] = '<label for="widgets' . \SpoonFilter::toCamelCase($widget['checkbox_name']) . '">' . $widget['label'] . '</label>';
             $widgetBoxes[$j]['description'] = $widget['description'];
         }
     }
     // loop through modules
     foreach ($this->modules as $key => $module) {
         // add module label
         $permissionBoxes[$key]['label'] = $module['label'];
         // init var
         $addedBundles = array();
         // loop through actions
         foreach ($this->actions[$module['value']] as $i => $action) {
             // action is bundled?
             if (array_key_exists('group', $action)) {
                 // bundle not yet in array?
                 if (!in_array($action['group'], $addedBundles)) {
                     // assign bundled action boxes
                     $actionBoxes[$key]['actions'][$i]['check'] = $this->frm->addCheckbox('actions_' . $module['label'] . '_' . 'Group_' . \SpoonFilter::ucfirst($action['group']))->parse();
                     $actionBoxes[$key]['actions'][$i]['action'] = \SpoonFilter::ucfirst($action['group']);
                     $actionBoxes[$key]['actions'][$i]['description'] = $this->actionGroups[$action['group']];
                     // add the group to the added bundles
                     $addedBundles[] = $action['group'];
                 }
             } else {
                 // assign action boxes
                 $actionBoxes[$key]['actions'][$i]['check'] = $this->frm->addCheckbox('actions_' . $module['label'] . '_' . $action['label'])->parse();
                 $actionBoxes[$key]['actions'][$i]['action'] = '<label for="actions' . \SpoonFilter::toCamelCase($module['label'] . '_' . $action['label']) . '">' . $action['label'] . '</label>';
                 $actionBoxes[$key]['actions'][$i]['description'] = $action['description'];
             }
         }
         // widgetboxes available?
         if (isset($widgetBoxes)) {
             // create datagrid
             $widgetGrid = new BackendDataGridArray($widgetBoxes);
             $widgetGrid->setHeaderLabels(array('check' => '<span class="checkboxHolder"><input id="toggleChecksWidgets" type="checkbox" name="toggleChecks" value="toggleChecks" /><span class="visuallyHidden"></span>'));
             // get content
             $widgets = $widgetGrid->getContent();
         }
         // create datagrid
         $actionGrid = new BackendDataGridArray($actionBoxes[$key]['actions']);
         $actionGrid->setHeaderLabels(array('check' => ''));
         // disable paging
         $actionGrid->setPaging(false);
         // get content of datagrids
         $permissionBoxes[$key]['actions']['dataGrid'] = $actionGrid->getContent();
         $permissionBoxes[$key]['chk'] = $this->frm->addCheckbox($module['label'], null, 'inputCheckbox checkBeforeUnload jsSelectAll')->parse();
         $permissionBoxes[$key]['id'] = \SpoonFilter::toCamelCase($module['label']);
     }
     // create elements
     $this->frm->addText('name');
     $this->frm->addDropdown('manage_users', array('Deny', 'Allow'));
     $this->frm->addDropdown('manage_groups', array('Deny', 'Allow'));
     $this->tpl->assign('permissions', $permissionBoxes);
     $this->tpl->assign('widgets', isset($widgets) ? $widgets : false);
 }
Beispiel #25
0
 /**
  * Parse the form
  */
 protected function parse()
 {
     parent::parse();
     // get url
     $url = BackendModel::getURLForBlock($this->URL->getModule(), 'detail');
     $url404 = BackendModel::getURL(404);
     // parse additional variables
     if ($url404 != $url) {
         $this->tpl->assign('detailURL', SITE_URL . $url);
     }
     // fetch proper slug
     $this->record['url'] = $this->meta->getURL();
     // assign the active record and additional variables
     $this->tpl->assign('item', $this->record);
     $this->tpl->assign('status', BL::lbl(\SpoonFilter::ucfirst($this->record['status'])));
     // assign revisions-datagrid
     $this->tpl->assign('revisions', $this->dgRevisions->getNumResults() != 0 ? $this->dgRevisions->getContent() : false);
     $this->tpl->assign('drafts', $this->dgDrafts->getNumResults() != 0 ? $this->dgDrafts->getContent() : false);
     $this->tpl->assign('imageIsAllowed', $this->imageIsAllowed);
     // assign category
     if ($this->categoryId !== null) {
         $this->tpl->assign('categoryId', $this->categoryId);
     }
 }
Beispiel #26
0
 /**
  * Load the settings form
  */
 protected function loadSettingsForm()
 {
     $mapTypes = array('ROADMAP' => BL::lbl('Roadmap', $this->getModule()), 'SATELLITE' => BL::lbl('Satellite', $this->getModule()), 'HYBRID' => BL::lbl('Hybrid', $this->getModule()), 'TERRAIN' => BL::lbl('Terrain', $this->getModule()), 'STREET_VIEW' => BL::lbl('StreetView', $this->getModule()));
     $mapStyles = array('standard' => BL::lbl('Default', $this->getModule()), 'custom' => BL::lbl('Custom', $this->getModule()), 'gray' => BL::lbl('Gray', $this->getModule()), 'blue' => BL::lbl('Blue', $this->getModule()));
     $zoomLevels = array_combine(array_merge(array('auto'), range(1, 18)), array_merge(array(BL::lbl('Auto', $this->getModule())), range(1, 18)));
     $this->settingsForm = new BackendForm('settings');
     // add map info (overview map)
     $this->settingsForm->addHidden('map_id', $this->id);
     $this->settingsForm->addDropdown('zoom_level', $zoomLevels, $this->settings['zoom_level']);
     $this->settingsForm->addText('width', $this->settings['width']);
     $this->settingsForm->addText('height', $this->settings['height']);
     $this->settingsForm->addDropdown('map_type', $mapTypes, $this->settings['map_type']);
     $this->settingsForm->addDropdown('map_style', $mapStyles, isset($this->settings['map_style']) ? $this->settings['map_style'] : null);
     $this->settingsForm->addCheckbox('full_url', $this->settings['full_url']);
     $this->settingsForm->addCheckbox('directions', $this->settings['directions']);
     $this->settingsForm->addCheckbox('marker_overview', $this->record['show_overview'] == 'Y');
 }
Beispiel #27
0
 /**
  * Load the form
  */
 private function loadForm()
 {
     // create form
     $this->frm = new BackendForm('add');
     // create elements
     $this->frm->addDropdown('theme', $this->availableThemes, $this->selectedTheme);
     $this->frm->addText('label');
     $this->frm->addText('file');
     $this->frm->addTextarea('format');
     $this->frm->addCheckbox('active', true);
     $this->frm->addCheckbox('default');
     $this->frm->addCheckbox('image');
     // init vars
     $positions = array();
     $blocks = array();
     $widgets = array();
     $extras = BackendExtensionsModel::getExtras();
     // loop extras to populate the default extras
     foreach ($extras as $item) {
         if ($item['type'] == 'block') {
             $blocks[$item['id']] = \SpoonFilter::ucfirst(BL::lbl($item['label']));
             if (isset($item['data']['extra_label'])) {
                 $blocks[$item['id']] = \SpoonFilter::ucfirst($item['data']['extra_label']);
             }
         } elseif ($item['type'] == 'widget') {
             $widgets[$item['id']] = \SpoonFilter::ucfirst(BL::lbl(\SpoonFilter::toCamelCase($item['module']))) . ': ' . \SpoonFilter::ucfirst(BL::lbl($item['label']));
             if (isset($item['data']['extra_label'])) {
                 $widgets[$item['id']] = \SpoonFilter::ucfirst(BL::lbl(\SpoonFilter::toCamelCase($item['module']))) . ': ' . $item['data']['extra_label'];
             }
         }
     }
     // sort
     asort($blocks, SORT_STRING);
     asort($widgets, SORT_STRING);
     // create array
     $defaultExtras = array('' => array(0 => \SpoonFilter::ucfirst(BL::lbl('Editor'))), \SpoonFilter::ucfirst(BL::lbl('Widgets')) => $widgets);
     // create default position field
     $position = array();
     $position['i'] = 0;
     $position['formElements']['txtPosition'] = $this->frm->addText('position_' . $position['i'], null, 255, 'form-control positionName', 'form-control danger positionName');
     $position['blocks'][]['formElements']['ddmType'] = $this->frm->addDropdown('type_' . $position['i'] . '_' . 0, $defaultExtras, null, false, 'form-control positionBlock', 'form-control danger positionBlockError');
     $positions[] = $position;
     // content has been submitted: re-create submitted content rather than the db-fetched content
     if (isset($_POST['position_0'])) {
         // init vars
         $this->names = array();
         $this->extras = array();
         $i = 1;
         $errors = array();
         // loop submitted positions
         while (isset($_POST['position_' . $i])) {
             // init vars
             $j = 0;
             $extras = array();
             // gather position names
             $name = $_POST['position_' . $i];
             // loop submitted blocks
             while (isset($_POST['type_' . $i . '_' . $j])) {
                 // gather blocks id
                 $extras[] = (int) $_POST['type_' . $i . '_' . $j];
                 // increment counter; go fetch next block
                 ++$j;
             }
             // increment counter; go fetch next position
             ++$i;
             // position already exists -> error
             if (in_array($name, $this->names)) {
                 $errors[] = sprintf(BL::getError('DuplicatePositionName'), $name);
             }
             // position name == fallback -> error
             if ($name == 'fallback') {
                 $errors[] = sprintf(BL::getError('ReservedPositionName'), $name);
             }
             // not alphanumeric -> error
             if (!\SpoonFilter::isValidAgainstRegexp('/^[a-z0-9]+$/i', $name)) {
                 $errors[] = sprintf(BL::getError('NoAlphaNumPositionName'), $name);
             }
             // save positions
             $this->names[] = $name;
             $this->extras[$name] = $extras;
         }
         // add errors
         if ($errors) {
             $this->frm->addError(implode('<br />', array_unique($errors)));
         }
     }
     // build blocks array
     foreach ($this->names as $i => $name) {
         // create default position field
         $position = array();
         $position['i'] = $i + 1;
         $position['formElements']['txtPosition'] = $this->frm->addText('position_' . $position['i'], $name, 255, 'form-control positionName', 'form-control danger positionName');
         foreach ($this->extras[$name] as $extra) {
             $position['blocks'][]['formElements']['ddmType'] = $this->frm->addDropdown('type_' . $position['i'] . '_' . 0, $defaultExtras, $extra, false, 'form-control positionBlock', 'form-control danger positionBlockError');
         }
         $positions[] = $position;
     }
     // assign
     $this->tpl->assign('positions', $positions);
 }
Beispiel #28
0
 /**
  * Parses a data grid with the revisions in the template
  */
 private function parseRevisionsDataGrid()
 {
     // create datagrid
     $revisions = new ContentBlockRevisionDataGrid($this->contentBlock, Locale::workingLocale());
     // hide columns
     $revisions->setColumnsHidden(['id', 'revision_id']);
     // disable paging
     $revisions->setPaging(false);
     // set headers
     $revisions->setHeaderLabels(['user_id' => SpoonFilter::ucfirst(Language::lbl('By')), 'edited_on' => SpoonFilter::ucfirst(Language::lbl('LastEditedOn'))]);
     // set column-functions
     $revisions->setColumnFunction([DataGridFunctions::class, 'getUser'], ['[user_id]'], 'user_id');
     $revisions->setColumnFunction([DataGridFunctions::class, 'getTimeAgo'], ['[edited_on]'], 'edited_on');
     // check if this action is allowed
     if (Authentication::isAllowedAction('Edit')) {
         $editRevisionUrl = BackendModel::createURLForAction('Edit', null, null, ['id' => '[id]', 'revision' => '[revision_id]'], false);
         // set column URLs
         $revisions->setColumnURL('title', $editRevisionUrl);
         // add use column
         $revisions->addColumn('use_revision', null, Language::lbl('UseThisVersion'), $editRevisionUrl, Language::lbl('UseThisVersion'));
     }
     $this->tpl->assign('revisions', (string) $revisions->getContent());
 }
Beispiel #29
0
 /**
  * Sets all the default settings needed when attempting to use sorting
  */
 private function setSortingOptions()
 {
     // default URL
     if (BackendModel::getContainer()->get('url')) {
         $this->setURL(BackendModel::createURLForAction(null, null, null, array('offset' => '[offset]', 'order' => '[order]', 'sort' => '[sort]'), false));
     }
     // sorting labels
     $this->setSortingLabels(BackendLanguage::lbl('SortAscending'), BackendLanguage::lbl('SortedAscending'), BackendLanguage::lbl('SortDescending'), BackendLanguage::lbl('SortedDescending'));
 }
Beispiel #30
0
 /**
  * Load the form
  */
 private function loadForm()
 {
     // get default template id
     $defaultTemplateId = $this->get('fork.settings')->get('Pages', 'default_template', 1);
     // create form
     $this->frm = new BackendForm('add');
     // assign in template
     $this->tpl->assign('defaultTemplateId', $defaultTemplateId);
     // create elements
     $this->frm->addText('title', null, null, 'form-control title', 'form-control danger title');
     $this->frm->addEditor('html');
     $this->frm->addHidden('template_id', $defaultTemplateId);
     $this->frm->addRadiobutton('hidden', array(array('label' => BL::lbl('Hidden'), 'value' => 'Y'), array('label' => BL::lbl('Published'), 'value' => 'N')), 'N');
     // image related fields
     $this->frm->addImage('image');
     // a god user should be able to adjust the detailed settings for a page easily
     if ($this->isGod) {
         // init some vars
         $items = array('move' => true, 'children' => true, 'edit' => true, 'delete' => true);
         $checked = array();
         $values = array();
         foreach ($items as $value => $itemIsChecked) {
             $values[] = array('label' => BL::msg(\SpoonFilter::toCamelCase('allow_' . $value)), 'value' => $value);
             if ($itemIsChecked) {
                 $checked[] = $value;
             }
         }
         $this->frm->addMultiCheckbox('allow', $values, $checked);
     }
     // build prototype block
     $block['index'] = 0;
     $block['formElements']['chkVisible'] = $this->frm->addCheckbox('block_visible_' . $block['index'], true);
     $block['formElements']['hidExtraId'] = $this->frm->addHidden('block_extra_id_' . $block['index'], 0);
     $block['formElements']['hidPosition'] = $this->frm->addHidden('block_position_' . $block['index'], 'fallback');
     $block['formElements']['txtHTML'] = $this->frm->addTextarea('block_html_' . $block['index']);
     // this is no editor; we'll add the editor in JS
     // add default block to "fallback" position, the only one which we can rest assured to exist
     $this->positions['fallback']['blocks'][] = $block;
     // content has been submitted: re-create submitted content rather than the db-fetched content
     if (isset($_POST['block_html_0'])) {
         // init vars
         $this->blocksContent = array();
         $hasBlock = false;
         $i = 1;
         // loop submitted blocks
         while (isset($_POST['block_position_' . $i])) {
             // init var
             $block = array();
             // save block position
             $block['position'] = $_POST['block_position_' . $i];
             $positions[$block['position']][] = $block;
             // set linked extra
             $block['extra_id'] = $_POST['block_extra_id_' . $i];
             // reset some stuff
             if ($block['extra_id'] <= 0) {
                 $block['extra_id'] = null;
             }
             // init html
             $block['html'] = null;
             // extra-type is HTML
             if ($block['extra_id'] === null) {
                 // reset vars
                 $block['extra_id'] = null;
                 $block['html'] = $_POST['block_html_' . $i];
             } else {
                 // type of block
                 if (isset($this->extras[$block['extra_id']]['type']) && $this->extras[$block['extra_id']]['type'] == 'block') {
                     // set error
                     if ($hasBlock) {
                         $this->frm->addError(BL::err('CantAdd2Blocks'));
                     }
                     // reset var
                     $hasBlock = true;
                 }
             }
             // set data
             $block['created_on'] = BackendModel::getUTCDate();
             $block['edited_on'] = $block['created_on'];
             $block['visible'] = isset($_POST['block_visible_' . $i]) && $_POST['block_visible_' . $i] == 'Y' ? 'Y' : 'N';
             $block['sequence'] = count($positions[$block['position']]) - 1;
             // add to blocks
             $this->blocksContent[] = $block;
             // increment counter; go fetch next block
             ++$i;
         }
     }
     // build blocks array
     foreach ($this->blocksContent as $i => $block) {
         $block['index'] = $i + 1;
         $block['formElements']['chkVisible'] = $this->frm->addCheckbox('block_visible_' . $block['index'], $block['visible'] == 'Y');
         $block['formElements']['hidExtraId'] = $this->frm->addHidden('block_extra_id_' . $block['index'], (int) $block['extra_id']);
         $block['formElements']['hidPosition'] = $this->frm->addHidden('block_position_' . $block['index'], $block['position']);
         $block['formElements']['txtHTML'] = $this->frm->addTextarea('block_html_' . $block['index'], $block['html']);
         // this is no editor; we'll add the editor in JS
         $this->positions[$block['position']]['blocks'][] = $block;
     }
     // redirect
     $redirectValues = array(array('value' => 'none', 'label' => \SpoonFilter::ucfirst(BL::lbl('None'))), array('value' => 'internal', 'label' => \SpoonFilter::ucfirst(BL::lbl('InternalLink')), 'variables' => array('isInternal' => true)), array('value' => 'external', 'label' => \SpoonFilter::ucfirst(BL::lbl('ExternalLink')), 'variables' => array('isExternal' => true)));
     $this->frm->addRadiobutton('redirect', $redirectValues, 'none');
     $this->frm->addDropdown('internal_redirect', BackendPagesModel::getPagesForDropdown());
     $this->frm->addText('external_redirect', null, null, null, null, true);
     // page info
     $this->frm->addCheckbox('navigation_title_overwrite');
     $this->frm->addText('navigation_title');
     if ($this->showTags()) {
         // tags
         $this->frm->addText('tags', null, null, 'form-control js-tags-input', 'form-control danger js-tags-input');
     }
     // a specific action
     $this->frm->addCheckbox('is_action', false);
     // extra
     $blockTypes = BackendPagesModel::getTypes();
     $this->frm->addDropdown('extra_type', $blockTypes, key($blockTypes));
     // meta
     $this->meta = new BackendMeta($this->frm, null, 'title', true);
     // set callback for generating an unique URL
     $this->meta->setURLCallback('Backend\\Modules\\Pages\\Engine\\Model', 'getURL', array(0, null, false));
 }