本文整理汇总了PHP中Backend\Core\Language\Language::getWorkingLanguage方法的典型用法代码示例。如果您正苦于以下问题:PHP Language::getWorkingLanguage方法的具体用法?PHP Language::getWorkingLanguage怎么用?PHP Language::getWorkingLanguage使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Backend\Core\Language\Language
的用法示例。
在下文中一共展示了Language::getWorkingLanguage方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: execute
/**
* Execute the action
* We will build the classname, require the class and call the execute method.
*/
public function execute()
{
$this->loadConfig();
// is the requested action available? If not we redirect to the error page.
if (!$this->config->isActionAvailable($this->action)) {
// build the url
$errorUrl = '/' . NAMED_APPLICATION . '/' . $this->get('request')->getLocale() . '/error?type=action-not-allowed';
// redirect to the error page
return $this->redirect($errorUrl, 307);
}
// build action-class
$actionClass = 'Backend\\Modules\\' . $this->getModule() . '\\Actions\\' . $this->getAction();
if ($this->getModule() == 'Core') {
$actionClass = 'Backend\\Core\\Actions\\' . $this->getAction();
}
if (!class_exists($actionClass)) {
throw new Exception('The class ' . $actionClass . ' could not be found.');
}
// get working languages
$languages = BackendLanguage::getWorkingLanguages();
$workingLanguages = array();
// loop languages and build an array that we can assign
foreach ($languages as $abbreviation => $label) {
$workingLanguages[] = array('abbr' => $abbreviation, 'label' => $label, 'selected' => $abbreviation == BackendLanguage::getWorkingLanguage());
}
// assign the languages
$this->tpl->assign('workingLanguages', $workingLanguages);
// create action-object
/** @var $object BackendBaseAction */
$object = new $actionClass($this->getKernel());
$this->getContainer()->get('logger')->info("Executing backend action '{$object->getAction()}' for module '{$object->getModule()}'.");
$object->execute();
return $object->getContent();
}
示例2: execute
/**
* Execute the action
*/
public function execute()
{
parent::execute();
// get parameters
$categoryTitle = trim(\SpoonFilter::getPostValue('value', null, '', 'string'));
// validate
if ($categoryTitle === '') {
$this->output(self::BAD_REQUEST, null, BL::err('TitleIsRequired'));
} else {
// get the data
// build array
$item['title'] = \SpoonFilter::htmlspecialchars($categoryTitle);
$item['language'] = BL::getWorkingLanguage();
$meta['keywords'] = $item['title'];
$meta['keywords_overwrite'] = 'N';
$meta['description'] = $item['title'];
$meta['description_overwrite'] = 'N';
$meta['title'] = $item['title'];
$meta['title_overwrite'] = 'N';
$meta['url'] = BackendBlogModel::getURLForCategory(\SpoonFilter::urlise($item['title']));
// update
$item['id'] = BackendBlogModel::insertCategory($item, $meta);
// output
$this->output(self::OK, $item, vsprintf(BL::msg('AddedCategory'), array($item['title'])));
}
}
示例3: __construct
/**
* @param KernelInterface $kernel
*/
public function __construct(KernelInterface $kernel)
{
parent::__construct($kernel);
// store for later use throughout the application
$this->getContainer()->set('navigation', $this);
$this->URL = $this->getContainer()->get('url');
// check if navigation cache file exists
if (!is_file(self::getCacheDirectory() . 'navigation.php')) {
$this->buildCache();
}
// check if editor_link_list_LANGUAGE.js cache file exists
if (!is_file(FRONTEND_CACHE_PATH . '/Navigation/editor_link_list_' . BackendLanguage::getWorkingLanguage() . '.js')) {
BackendPagesModel::buildCache(BackendLanguage::getWorkingLanguage());
}
$navigation = array();
// require navigation-file
require self::getCacheDirectory() . 'navigation.php';
// load it
$this->navigation = (array) $navigation;
$this->navigation = $this->addActiveStateToNavigation($this->navigation);
// cleanup navigation (not needed for god user)
if (!Authentication::getUser()->isGod()) {
$this->navigation = $this->cleanup($this->navigation);
}
}
示例4: validateForm
/**
* Validate the form
*/
private function validateForm()
{
// is the form submitted?
if ($this->frm->isSubmitted()) {
// cleanup the submitted fields, ignore fields that were added by hackers
$this->frm->cleanupFields();
// validate field
$this->frm->getField('synonym')->isFilled(BL::err('SynonymIsRequired'));
$this->frm->getField('term')->isFilled(BL::err('TermIsRequired'));
if (BackendSearchModel::existsSynonymByTerm($this->frm->getField('term')->getValue())) {
$this->frm->getField('term')->addError(BL::err('TermExists'));
}
// no errors?
if ($this->frm->isCorrect()) {
// build item
$item = array();
$item['term'] = $this->frm->getField('term')->getValue();
$item['synonym'] = $this->frm->getField('synonym')->getValue();
$item['language'] = BL::getWorkingLanguage();
// insert the item
$id = BackendSearchModel::insertSynonym($item);
// trigger event
BackendModel::triggerEvent($this->getModule(), 'after_add_synonym', array('item' => $item));
// everything is saved, so redirect to the overview
$this->redirect(BackendModel::createURLForAction('Synonyms') . '&report=added-synonym&var=' . rawurlencode($item['term']) . '&highlight=row-' . $id);
}
}
}
示例5: setFilter
/**
* Sets the filter based on the $_GET array.
*/
private function setFilter()
{
$this->filter['language'] = $this->getParameter('language', 'array') != '' ? $this->getParameter('language', 'array') : BL::getWorkingLanguage();
$this->filter['application'] = $this->getParameter('application');
$this->filter['module'] = $this->getParameter('module');
$this->filter['type'] = $this->getParameter('type', 'array');
$this->filter['name'] = $this->getParameter('name');
$this->filter['value'] = $this->getParameter('value');
$this->filterQuery = BackendLocaleModel::buildURLQueryByFilter($this->filter);
}
示例6: loadDataGrid
/**
* 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'));
}
}
示例7: loadDataGrid
/**
* 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'));
}
}
示例8: loadDataGrid
/**
* 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');
}
示例9: execute
/**
* Execute the action
*/
public function execute()
{
parent::execute();
$generalSettings = $this->get('fork.settings')->getForModule('Location');
// get parameters
$itemId = \SpoonFilter::getPostValue('id', null, null, 'int');
$zoomLevel = trim(\SpoonFilter::getPostValue('zoom', null, 'auto'));
$mapType = strtoupper(trim(\SpoonFilter::getPostValue('type', array('roadmap', 'satellite', 'hybrid', 'terrain', 'street_view'), 'roadmap')));
$mapStyle = trim(\SpoonFilter::getPostValue('style', array('standard', 'custom', 'gray', 'blue'), 'standard'));
$centerLat = \SpoonFilter::getPostValue('centerLat', null, 1, 'float');
$centerlng = \SpoonFilter::getPostValue('centerLng', null, 1, 'float');
$height = \SpoonFilter::getPostValue('height', null, $generalSettings['height'], 'int');
$width = \SpoonFilter::getPostValue('width', null, $generalSettings['width'], 'int');
$showLink = \SpoonFilter::getPostValue('link', array('true', 'false'), 'false', 'string');
$showDirections = \SpoonFilter::getPostValue('directions', array('true', 'false'), 'false', 'string');
$showOverview = \SpoonFilter::getPostValue('showOverview', array('true', 'false'), 'true', 'string');
// reformat
$center = array('lat' => $centerLat, 'lng' => $centerlng);
$showLink = $showLink == 'true';
$showDirections = $showDirections == 'true';
$showOverview = $showOverview == 'true';
// standard dimensions
if ($width > 800) {
$width = 800;
}
if ($width < 300) {
$width = $generalSettings['width'];
}
if ($height < 150) {
$height = $generalSettings['height'];
}
// no id given, this means we should update the main map
BackendLocationModel::setMapSetting($itemId, 'zoom_level', (string) $zoomLevel);
BackendLocationModel::setMapSetting($itemId, 'map_type', (string) $mapType);
BackendLocationModel::setMapSetting($itemId, 'map_style', (string) $mapStyle);
BackendLocationModel::setMapSetting($itemId, 'center', (array) $center);
BackendLocationModel::setMapSetting($itemId, 'height', (int) $height);
BackendLocationModel::setMapSetting($itemId, 'width', (int) $width);
BackendLocationModel::setMapSetting($itemId, 'directions', $showDirections);
BackendLocationModel::setMapSetting($itemId, 'full_url', $showLink);
$item = array('id' => $itemId, 'language' => BL::getWorkingLanguage(), 'show_overview' => $showOverview ? 'Y' : 'N');
BackendLocationModel::update($item);
// output
$this->output(self::OK, null, BL::msg('Success'));
}
示例10: execute
/**
* Execute the action
*/
public function execute()
{
parent::execute();
// get parameters
$itemId = trim(\SpoonFilter::getPostValue('id', null, '', 'int'));
$lat = \SpoonFilter::getPostValue('lat', null, null, 'float');
$lng = \SpoonFilter::getPostValue('lng', null, null, 'float');
// validate id
if ($itemId == 0) {
$this->output(self::BAD_REQUEST, null, BL::err('NonExisting'));
} else {
//update
$updateData = array('id' => $itemId, 'lat' => $lat, 'lng' => $lng, 'language' => BL::getWorkingLanguage());
BackendLocationModel::update($updateData);
// output
$this->output(self::OK);
}
}
示例11: configureOptions
public function configureOptions(OptionsResolver $optionsResolver)
{
$optionsResolver->setDefaults(['attr' => ['class' => 'inputEditor']]);
if (!Model::has('header')) {
return;
}
// add the needed javascript to the header;
$header = Model::get('header');
// we add JS because we need CKEditor
$header->addJS('ckeditor/ckeditor.js', 'Core', false);
$header->addJS('ckeditor/adapters/jquery.js', 'Core', false);
$header->addJS('ckfinder/ckfinder.js', 'Core', false);
// add the internal link lists-file
if (is_file(FRONTEND_CACHE_PATH . '/Navigation/editor_link_list_' . Language::getWorkingLanguage() . '.js')) {
$timestamp = @filemtime(FRONTEND_CACHE_PATH . '/Navigation/editor_link_list_' . Language::getWorkingLanguage() . '.js');
$header->addJS('/src/Frontend/Cache/Navigation/editor_link_list_' . Language::getWorkingLanguage() . '.js?m=' . $timestamp, null, false, true, false);
}
}
示例12: execute
/**
* Execute the action
*/
public function execute()
{
// get parameters
$this->id = $this->getParameter('id', 'int');
// does the item exist
if ($this->id !== null && BackendPagesModel::exists($this->id)) {
// call parent, this will probably add some general CSS/JS or other required files
parent::execute();
// init var
$success = false;
// cannot have children
if (BackendPagesModel::getFirstChildId($this->id) !== false) {
$this->redirect(BackendModel::createURLForAction('Edit') . '&error=non-existing');
}
$revisionId = $this->getParameter('revision_id', 'int');
if ($revisionId == 0) {
$revisionId = null;
}
// get page (we need the title)
$page = BackendPagesModel::get($this->id, $revisionId);
// valid page?
if (!empty($page)) {
// delete the page
$success = BackendPagesModel::delete($this->id, null, $revisionId);
// trigger event
BackendModel::triggerEvent($this->getModule(), 'after_delete', array('id' => $this->id));
// delete search indexes
BackendSearchModel::removeIndex($this->getModule(), $this->id);
// build cache
BackendPagesModel::buildCache(BL::getWorkingLanguage());
}
// page is deleted, so redirect to the overview
if ($success) {
$this->redirect(BackendModel::createURLForAction('Index') . '&id=' . $page['parent_id'] . '&report=deleted&var=' . rawurlencode($page['title']));
} else {
$this->redirect(BackendModel::createURLForAction('Edit') . '&error=non-existing');
}
} else {
$this->redirect(BackendModel::createURLForAction('Edit') . '&error=non-existing');
}
}
示例13: loadDataGridRecentlyEdited
/**
* Load the datagrid with the recently edited items
*/
private function loadDataGridRecentlyEdited()
{
// create dgRecentlyEdited
$this->dgRecentlyEdited = new BackendDataGridDB(BackendPagesModel::QRY_BROWSE_RECENT, array('active', BL::getWorkingLanguage(), 7));
// disable paging
$this->dgRecentlyEdited->setPaging(false);
// hide columns
$this->dgRecentlyEdited->setColumnsHidden(array('id'));
// set functions
$this->dgRecentlyEdited->setColumnFunction(array(new BackendDataGridFunctions(), 'getUser'), array('[user_id]'), 'user_id');
$this->dgRecentlyEdited->setColumnFunction(array(new BackendDataGridFunctions(), 'getTimeAgo'), array('[edited_on]'), 'edited_on');
// set headers
$this->dgRecentlyEdited->setHeaderLabels(array('user_id' => \SpoonFilter::ucfirst(BL::lbl('By')), 'edited_on' => \SpoonFilter::ucfirst(BL::lbl('LastEdited'))));
// check if allowed to edit
if (BackendAuthentication::isAllowedAction('Edit', $this->getModule())) {
// set column URL
$this->dgRecentlyEdited->setColumnURL('title', BackendModel::createURLForAction('Edit') . '&id=[id]', BL::lbl('Edit'));
// add column
$this->dgRecentlyEdited->addColumn('edit', null, BL::lbl('Edit'), BackendModel::createURLForAction('Edit') . '&id=[id]', BL::lbl('Edit'));
}
}
示例14: execute
/**
* Execute the action
*/
public function execute()
{
// call parent
parent::execute();
// get parameters
$id = \SpoonFilter::getPostValue('id', null, 0, 'int');
$droppedOn = \SpoonFilter::getPostValue('dropped_on', null, -1, 'int');
$typeOfDrop = \SpoonFilter::getPostValue('type', null, '');
$tree = \SpoonFilter::getPostValue('tree', array('main', 'meta', 'footer', 'root'), '');
// init validation
$errors = array();
// validate
if ($id === 0) {
$errors[] = 'no id provided';
}
if ($droppedOn === -1) {
$errors[] = 'no dropped_on provided';
}
if ($typeOfDrop == '') {
$errors[] = 'no type provided';
}
if ($tree == '') {
$errors[] = 'no tree provided';
}
// got errors
if (!empty($errors)) {
$this->output(self::BAD_REQUEST, array('errors' => $errors), 'not all fields were filled');
} else {
// get page
$success = BackendPagesModel::move($id, $droppedOn, $typeOfDrop, $tree);
// build cache
BackendPagesModel::buildCache(BL::getWorkingLanguage());
// output
if ($success) {
$this->output(self::OK, BackendPagesModel::get($id), 'page moved');
} else {
$this->output(self::ERROR, null, 'page not moved');
}
}
}
示例15: loadDataGrid
/**
* 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'));
}
}