本文整理汇总了PHP中BOL_LanguageService::getInstance方法的典型用法代码示例。如果您正苦于以下问题:PHP BOL_LanguageService::getInstance方法的具体用法?PHP BOL_LanguageService::getInstance怎么用?PHP BOL_LanguageService::getInstance使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BOL_LanguageService
的用法示例。
在下文中一共展示了BOL_LanguageService::getInstance方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: index
public function index($params)
{
$id = (int) $params['id'];
$this->assign('id', $id);
$menu = BOL_NavigationService::getInstance()->findMenuItemById($id);
$service = BOL_NavigationService::getInstance();
$form = new EditExternalPageForm('edit-form', $menu);
if (OW::getRequest()->isPost() && $form->isValid($_POST)) {
$data = $form->getValues();
$visibleFor = 0;
$arr = !empty($data['visible-for']) ? $data['visible-for'] : array();
foreach ($arr as $val) {
$visibleFor += $val;
}
$service->saveMenuItem($menu->setExternalUrl($data['url'])->setVisibleFor($visibleFor)->setNewWindow(!empty($_POST['ext-open-in-new-window']) && $_POST['ext-open-in-new-window'] == 'on'));
$languageService = BOL_LanguageService::getInstance();
$plugin = OW::getPluginManager()->getPlugin('base');
$langKey = $languageService->findKey($plugin->getKey(), $menu->getKey());
if (empty($langKey)) {
$langPrefixDto = $languageService->findPrefix($menu->getPrefix());
$langKey = $languageService->addKey($langPrefixDto->getId(), $menu->getKey());
}
$langValue = $languageService->findValue($languageService->getCurrent()->getId(), $langKey->getId());
if (empty($langValue)) {
$languageService->addValue($languageService->getCurrent()->getId(), $menu->getPrefix(), $langKey->getKey(), $data['name']);
} else {
$languageService->saveValue($langValue->setValue($data['name']));
}
$adminPlugin = OW::getPluginManager()->getPlugin('admin');
OW::getFeedback()->info(OW::getLanguage()->text($adminPlugin->getKey(), 'updated_msg'));
$this->redirect();
}
$this->addForm($form);
}
示例2: __construct
/**
* Constructor.
*
*/
public function __construct()
{
parent::__construct('');
$template = OW::getPluginManager()->getPlugin('BASE')->getCmpViewDir() . 'console_switch_language.html';
$this->setTemplate($template);
$languages = BOL_LanguageService::getInstance()->getLanguages();
$session_language_id = BOL_LanguageService::getInstance()->getCurrent()->getId();
$active_languages = array();
foreach ($languages as $id => $language) {
if ($language->status == 'active') {
$tag = $this->parseCountryFromTag($language->tag);
$active_lang = array('id' => $language->id, 'label' => $tag['label'], 'order' => $language->order, 'tag' => $language->tag, 'class' => "ow_console_lang{$tag['country']}", 'url' => OW::getRequest()->buildUrlQueryString(null, array("language_id" => $language->id)), 'is_current' => false);
if ($session_language_id == $language->id) {
$active_lang['is_current'] = true;
$this->assign('label', $tag['label']);
$this->assign('class', "ow_console_lang{$tag['country']}");
}
$active_languages[] = $active_lang;
}
}
if (count($active_languages) <= 1) {
$this->setVisible(false);
return;
}
function sortActiveLanguages($lang1, $lang2)
{
return $lang1['order'] < $lang2['order'] ? -1 : 1;
}
usort($active_languages, 'sortActiveLanguages');
$switchLanguage = new BASE_CMP_SwitchLanguage($active_languages);
$this->setContent($switchLanguage->render());
}
示例3: import
public function import($params)
{
$importDir = $params['importDir'];
$sqlFile = $importDir . 'configs.sql';
//import configs
if (file_exists($sqlFile)) {
DATAIMPORTER_BOL_ImportService::getInstance()->sqlImport($sqlFile);
}
$configFile = $importDir . 'config.txt';
$string = file_get_contents($configFile);
$this->configs = json_decode($string, true);
$this->importAvatars($this->configs['avatarUrl']);
$this->importTheme($importDir);
$this->importMediaPanelFiles();
if (OW::getPluginManager()->getPlugin('dataimporter')) {
if (file_exists(OW::getPluginManager()->getPlugin('dataimporter')->getRootDir() . 'langs.zip')) {
OW::getLanguage()->importPluginLangs(OW::getPluginManager()->getPlugin('dataimporter')->getRootDir() . 'langs.zip', 'dataimporter');
}
}
$languageId = OW::getLanguage()->getCurrentId();
BOL_LanguageService::getInstance()->generateCache($languageId);
OW::getDbo()->query("TRUNCATE " . OW_DB_PREFIX . 'base_component_place_cache');
//TODO: Use service function
// ADD MENU ITEMS add plugin and add theme
try {
OW::getDbo()->query("INSERT IGNORE INTO `" . OW_DB_PREFIX . "base_menu_item` ( `prefix`, `key`, `documentKey`, `type`, `order`, `routePath`, `externalUrl`, `newWindow`, `visibleFor`) VALUES ( 'admin', 'sidebar_menu_plugins_add', '', 'admin_plugins', 3, 'admin_plugins_add', NULL, 0, 2) ");
} catch (Exception $ex) {
}
try {
OW::getDbo()->query("INSERT IGNORE INTO `" . OW_DB_PREFIX . "base_menu_item` ( `prefix`, `key`, `documentKey`, `type`, `order`, `routePath`, `externalUrl`, `newWindow`, `visibleFor`) VALUES ( 'admin', 'sidebar_menu_themes_add', '', 'admin_appearance', 3, 'admin_themes_add_new', NULL, 0, 3) ");
} catch (Exception $ex) {
}
}
示例4: smarty_function_text_edit
function smarty_function_text_edit($params, $smarty)
{
$key = $params['key'];
unset($params['key']);
$key = explode('+', $key);
if (empty($key[0]) || empty($key[1])) {
return '_INVALID_KEY_';
}
$prefix = $key[0];
$key = $key[1];
$text = OW::getLanguage()->text($prefix, $key, $params);
$keyDto = BOL_LanguageService::getInstance()->findKey($prefix, $key);
if (!$keyDto) {
return '<span class="ow_red">' . $text . '</span>';
}
$script = '$("a.ow_text_edit").click(function(){
var self=$(this), lang = this.rel.split("+");
OW.editLanguageKey(lang[0],lang[1], function(e){
self.text(e.value);
});
});';
OW::getDocument()->addOnloadScript($script);
$rel = json_encode($prefix . '+' . $key);
return '<a href="javascript://" rel=' . $rel . ' class="ow_text_edit">' . $text . '</a>';
}
示例5: process
/**
* Updates user settings configuration
*
* @return boolean
*/
public function process($post, $plugins)
{
$values = $this->getValues();
$config = OW::getConfig();
if ($plugins['photo']) {
$config->saveConfig('attachments', 'photo_share', empty($values['photo_share']) ? 0 : 1);
if (!empty($values['photo_share'])) {
$languageService = BOL_LanguageService::getInstance();
$langKey = $languageService->findKey('attachments', 'default_photo_album_name');
if (!empty($langKey)) {
$langValue = $languageService->findValue($languageService->getCurrent()->getId(), $langKey->getId());
if ($langValue === null) {
$langValue = new BOL_LanguageValue();
$langValue->setKeyId($langKey->getId());
$langValue->setLanguageId($languageService->getCurrent()->getId());
}
$languageService->saveValue($langValue->setValue($values['photo_album_name']));
}
}
}
if ($plugins['video']) {
$config->saveConfig('attachments', 'video_share', empty($values['video_share']) ? 0 : 1);
}
if ($plugins['links']) {
$config->saveConfig('attachments', 'link_share', empty($values['link_share']) ? 0 : 1);
}
return true;
}
示例6: index
public function index($params)
{
$id = (int) $params['id'];
$menu = BOL_NavigationService::getInstance()->findMenuItemById($id);
$form = new EditPluginPageForm('edit-form', $menu);
$service = BOL_NavigationService::getInstance();
if (OW::getRequest()->isPost() && $form->isValid($_POST)) {
$data = $form->getValues();
$visibleFor = 0;
$arr = !empty($data['visible-for']) ? $data['visible-for'] : array();
foreach ($arr as $val) {
$visibleFor += $val;
}
$service->saveMenuItem($menu->setVisibleFor($visibleFor));
$languageService = BOL_LanguageService::getInstance();
$langKey = $languageService->findKey($menu->getPrefix(), $menu->getKey());
$langValue = $languageService->findValue($languageService->getCurrent()->getId(), $langKey->getId());
$languageService->saveValue($langValue->setValue($data['name']));
$adminPlugin = OW::getPluginManager()->getPlugin('admin');
OW::getFeedback()->info(OW::getLanguage()->text($adminPlugin->getKey(), 'updated_msg'));
$this->redirect();
}
//--
$this->addForm($form);
}
示例7: __construct
public function __construct()
{
parent::__construct();
$language = OW::getLanguage();
$serviceLang = BOL_LanguageService::getInstance();
$addSectionForm = new Form('qst_add_section_form');
$addSectionForm->setAjax();
$addSectionForm->setAjaxResetOnSuccess(true);
$addSectionForm->setAction(OW::getRouter()->urlFor("ADMIN_CTRL_Questions", "ajaxResponder"));
$input = new HiddenField('command');
$input->setValue('addSection');
$addSectionForm->addElement($input);
$qstSectionName = new TextField('section_name');
$qstSectionName->addAttribute('class', 'ow_text');
$qstSectionName->addAttribute('style', 'width: auto;');
$qstSectionName->setRequired();
$qstSectionName->setLabel($language->text('admin', 'questions_new_section_label'));
$addSectionForm->addElement($qstSectionName);
$this->addForm($addSectionForm);
$addSectionForm->bindJsFunction('success', ' function (result) {
if ( result.result )
{
OW.info(result.message);
}
else
{
OW.error(result.message);
}
window.location.reload();
} ');
}
示例8: deleteDepartment
public function deleteDepartment($id)
{
$id = (int) $id;
if ($id > 0) {
$key = BOL_LanguageService::getInstance()->findKey('contactus', $this->getDepartmentKey($id));
BOL_LanguageService::getInstance()->deleteKey($key->id, true);
CONTACTUS_BOL_DepartmentDao::getInstance()->deleteById($id);
}
}
示例9: deleteDepartment
public function deleteDepartment($id)
{
$id = (int) $id;
if ($id > 0) {
$key = BOL_LanguageService::getInstance()->findKey('shoppro', $this->getDepartmentKey($id));
BOL_LanguageService::getInstance()->deleteKey($key->id, true);
SHOPPRO_BOL_DepartmentDao::getInstance()->deleteById($id);
}
}
示例10: init
/**
* Application init actions.
*/
public function init()
{
require_once OW_DIR_SYSTEM_PLUGIN . 'base' . DS . 'classes' . DS . 'json_err_output.php';
OW_ErrorManager::getInstance()->setErrorOutput(new BASE_CLASS_JsonErrOutput());
$authToken = empty($_SERVER["HTTP_API_AUTH_TOKEN"]) ? null : $_SERVER["HTTP_API_AUTH_TOKEN"];
OW_Auth::getInstance()->setAuthenticator(new OW_TokenAuthenticator($authToken));
if (!empty($_SERVER["HTTP_API_LANGUAGE"])) {
$tag = $_SERVER["HTTP_API_LANGUAGE"];
$languageDto = BOL_LanguageService::getInstance()->findByTag($tag);
if (empty($languageDto)) {
$tag = mb_substr($tag, 0, 2);
$languageDto = BOL_LanguageService::getInstance()->findByTag($tag);
}
if (!empty($languageDto) && $languageDto->status == "active") {
BOL_LanguageService::getInstance()->setCurrentLanguage($languageDto);
}
}
$this->detectLanguage();
// setting default time zone
date_default_timezone_set(OW::getConfig()->getValue('base', 'site_timezone'));
if (OW::getUser()->isAuthenticated()) {
$userId = OW::getUser()->getId();
$timeZone = BOL_PreferenceService::getInstance()->getPreferenceValue('timeZoneSelect', $userId);
if (!empty($timeZone)) {
date_default_timezone_set($timeZone);
}
}
// synchronize the db's time zone
OW::getDbo()->setTimezone();
// OW::getRequestHandler()->setIndexPageAttributes('BASE_CTRL_ComponentPanel');
// OW::getRequestHandler()->setStaticPageAttributes('BASE_CTRL_StaticDocument');
//
// // router init - need to set current page uri and base url
$router = OW::getRouter();
$router->setBaseUrl(OW_URL_HOME . 'api/');
$uri = OW::getRequest()->getRequestUri();
// before setting in router need to remove get params
if (strstr($uri, '?')) {
$uri = substr($uri, 0, strpos($uri, '?'));
}
$router->setUri($uri);
$router->setDefaultRoute(new OW_ApiDefaultRoute());
OW::getPluginManager()->initPlugins();
$event = new OW_Event(OW_EventManager::ON_PLUGINS_INIT);
OW::getEventManager()->trigger($event);
$beckend = OW::getEventManager()->call('base.cache_backend_init');
if ($beckend !== null) {
OW::getCacheManager()->setCacheBackend($beckend);
OW::getCacheManager()->setLifetime(3600);
OW::getDbo()->setUseCashe(true);
}
OW::getResponse()->setDocument($this->newDocument());
if (OW::getUser()->isAuthenticated()) {
BOL_UserService::getInstance()->updateActivityStamp(OW::getUser()->getId(), $this->getContext());
}
}
示例11: getLanguageCode
public function getLanguageCode()
{
$tag = BOL_LanguageService::getInstance()->getCurrent()->getTag();
$matches = array();
preg_match("/^([a-zA-Z]{2})-[a-zA-Z]{2}.*\$/", $tag, $matches);
$language = 'en';
if (!empty($matches[1])) {
$language = mb_strtolower($matches[1]);
}
return $language;
}
示例12: addCategory
public function addCategory($label, $parent, $id = null)
{
$category = new SPDOWNLOAD_BOL_Category();
$category->id = $id;
$category->name = $label;
$category->parentId = $parent;
SPDOWNLOAD_BOL_CategoryDao::getInstance()->save($category);
if ($id == null) {
BOL_LanguageService::getInstance()->addValue(OW::getLanguage()->getCurrentId(), 'spdownload', $this->getCategoryKey($category->id), trim($label));
}
}
示例13: isValidLangs
protected function isValidLangs()
{
$langService = BOL_LanguageService::getInstance();
$prefix = BOL_LanguageService::getInstance()->findPrefix('test_prefix');
$this->assertTrue((bool) (!empty($prefix) && $prefix instanceof BOL_LanguagePrefix));
$this->assertEquals('Test prefix', $prefix->label);
$lang = BOL_LanguageService::getInstance()->findByTag('en');
$this->assertEquals('test1', $langService->getText($lang->id, 'test_prefix', 'test_key_1'));
$this->assertEquals('test2', $langService->getText($lang->id, 'test_prefix', 'test_key_2'));
$this->assertEquals('test3', $langService->getText($lang->id, 'test_prefix', 'test_key_3'));
}
示例14: __construct
public function __construct()
{
$accountType = new BOL_QuestionAccountType();
$accountType->name = md5(uniqid());
$accountType->roleId = 0;
$form = new ADMIN_CLASS_AddAccountTypeForm($accountType);
$this->addForm($form);
$list = BOL_LanguageService::getInstance()->findActiveList();
$this->assign('langs', $list);
$this->assign('prefix', 'base');
$this->assign('key', BOL_QuestionService::getInstance()->getQuestionLangKeyName(BOL_QuestionService::LANG_KEY_TYPE_ACCOUNT_TYPE, $accountType->name));
$this->assign('form', $form);
}
示例15: process
public function process()
{
$values = $this->getValues();
$languageService = BOL_LanguageService::getInstance();
$langKey = $languageService->findKey('uavatars', 'default_photo_album_name');
if (!empty($langKey)) {
$langValue = $languageService->findValue($languageService->getCurrent()->getId(), $langKey->getId());
if ($langValue === null) {
$langValue = new BOL_LanguageValue();
$langValue->setKeyId($langKey->getId());
$langValue->setLanguageId($languageService->getCurrent()->getId());
}
$languageService->saveValue($langValue->setValue($values['photo_album_name']));
}
return true;
}