当前位置: 首页>>代码示例>>PHP>>正文


PHP Translatable::is_enabled方法代码示例

本文整理汇总了PHP中Translatable::is_enabled方法的典型用法代码示例。如果您正苦于以下问题:PHP Translatable::is_enabled方法的具体用法?PHP Translatable::is_enabled怎么用?PHP Translatable::is_enabled使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Translatable的用法示例。


在下文中一共展示了Translatable::is_enabled方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: getNestedController

 public function getNestedController()
 {
     if ($this->urlParams['URLSegment']) {
         $SQL_URLSegment = Convert::raw2sql($this->urlParams['URLSegment']);
         if (Translatable::is_enabled()) {
             $child = Translatable::get_one("SiteTree", "URLSegment = '{$SQL_URLSegment}'");
         } else {
             $child = DataObject::get_one("SiteTree", "URLSegment = '{$SQL_URLSegment}'");
         }
         if (!$child) {
             $child = $this->get404Page();
         }
         if ($child) {
             if (isset($_REQUEST['debug'])) {
                 Debug::message("Using record #{$child->ID} of type {$child->class} with URL {$this->urlParams['URLSegment']}");
             }
             $controllerClass = "{$child->class}_Controller";
             if ($this->urlParams['Action'] && ClassInfo::exists($controllerClass . '_' . $this->urlParams['Action'])) {
                 $controllerClass = $controllerClass . '_' . $this->urlParams['Action'];
             }
             if (ClassInfo::exists($controllerClass)) {
                 $controller = new $controllerClass($child);
             } else {
                 $controller = $child;
             }
             $controller->setURLParams($this->urlParams);
             return $controller;
         } else {
             die("The requested page couldn't be found.");
         }
     } else {
         user_error("ModelAsController not geting a URLSegment.  It looks like the site isn't redirecting to home", E_USER_ERROR);
     }
 }
开发者ID:ramziammar,项目名称:websites,代码行数:34,代码来源:ModelAsController.php

示例2: setUp

	function setUp() {
		$this->origTranslatableSettings['enabled'] = Translatable::is_enabled();
		$this->origTranslatableSettings['default_lang'] = Translatable::default_lang();
		Translatable::enable();
		Translatable::set_default_lang("en");
		
		// needs to recreate the database schema with *_lang tables
		self::kill_temp_db();
		self::create_temp_db();
		
		parent::setUp();
	}
开发者ID:neopba,项目名称:silverstripe-book,代码行数:12,代码来源:TranslatableTest.php

示例3: get_existing_content_languages

 /**
  * Get a list of languages with at least one element translated in (including the default language)
  *
  * @param string $className Look for languages in elements of this class
  * @return array Map of languages in the form langCode => langName
  */
 static function get_existing_content_languages($className = 'SiteTree', $where = '')
 {
     if (!Translatable::is_enabled()) {
         return false;
     }
     $query = new SQLQuery('Lang', $className . '_lang', $where, "", 'Lang');
     $dbLangs = $query->execute()->column();
     $langlist = array_merge((array) Translatable::default_lang(), (array) $dbLangs);
     $returnMap = array();
     $allCodes = array_merge(self::$all_locales, self::$common_languages);
     foreach ($langlist as $langCode) {
         $returnMap[$langCode] = is_array($allCodes[$langCode]) ? $allCodes[$langCode][0] : $allCodes[$langCode];
     }
     return $returnMap;
 }
开发者ID:ramziammar,项目名称:websites,代码行数:21,代码来源:i18n.php

示例4: init

	/**
	 * @uses LeftAndMainDecorator->init()
	 * @uses LeftAndMainDecorator->accessedCMS()
	 * @uses CMSMenu
	 * @uses Director::set_site_mode()
	 */
	function init() {
		parent::init();

		Director::set_site_mode('cms');
		
		// set language
		$member = Member::currentUser();
		if(!empty($member->Locale)) {
			i18n::set_locale($member->Locale);
		}
		
		// can't be done in cms/_config.php as locale is not set yet
		CMSMenu::add_link(
			'Help', 
			_t('LeftAndMain.HELP', 'Help', PR_HIGH, 'Menu title'), 
			'http://userhelp.silverstripe.com'
		);
		
		// set reading lang
		if(Translatable::is_enabled() && !Director::is_ajax()) {
			Translatable::choose_site_lang(array_keys(Translatable::get_existing_content_languages('SiteTree')));
		}

		// Allow customisation of the access check by a decorator
		if(!$this->canView()) {
			// When access /admin/, we should try a redirect to another part of the admin rather than be locked out
			$menu = $this->MainMenu();
			foreach($menu as $candidate) {
				if(
					$candidate->Link && 
					$candidate->Link != $this->Link() 
					&& $candidate->MenuItem->controller 
					&& singleton($candidate->MenuItem->controller)->canView()
				) {
					return Director::redirect($candidate->Link);
				}
			}
			
			if(Member::currentUser()) {
				Session::set("BackURL", null);
			}
			
			// if no alternate menu items have matched, return a permission error
			$messageSet = array(
				'default' => _t('LeftAndMain.PERMDEFAULT',"Please choose an authentication method and enter your credentials to access the CMS."),
				'alreadyLoggedIn' => _t('LeftAndMain.PERMALREADY',"I'm sorry, but you can't access that part of the CMS.  If you want to log in as someone else, do so below"),
				'logInAgain' => _t('LeftAndMain.PERMAGAIN',"You have been logged out of the CMS.  If you would like to log in again, enter a username and password below."),
			);

			return Security::permissionFailure($this, $messageSet);
		}

		// Don't continue if there's already been a redirection request.
		if(Director::redirected_to()) return;

		// Audit logging hook
		if(empty($_REQUEST['executeForm']) && !Director::is_ajax()) $this->extend('accessedCMS');
		
		Requirements::css(CMS_DIR . '/css/typography.css');
		Requirements::css(CMS_DIR . '/css/layout.css');
		Requirements::css(CMS_DIR . '/css/cms_left.css');
		Requirements::css(CMS_DIR . '/css/cms_right.css');
		Requirements::css(SAPPHIRE_DIR . '/css/Form.css');
		
		if(isset($_REQUEST['debug_firebug'])) {
			// Firebug is a useful console for debugging javascript
			// Its available as a Firefox extension or a javascript library
			// for easy inclusion in other browsers (just append ?debug_firebug=1 to the URL)
			Requirements::javascript(THIRDPARTY_DIR . '/firebug/firebug-lite-compressed.js');
		} else {
			// By default, we include fake-objects for all firebug calls
			// to avoid javascript errors when referencing console.log() etc in javascript code
			Requirements::javascript(THIRDPARTY_DIR . '/firebug/firebugx.js');
		}
		
		Requirements::javascript(THIRDPARTY_DIR . '/prototype.js');
		Requirements::javascript(THIRDPARTY_DIR . '/jquery/jquery.js');
		Requirements::javascript(THIRDPARTY_DIR . '/jquery/jquery_improvements.js');
		Requirements::javascript(THIRDPARTY_DIR . '/behaviour.js');
		Requirements::javascript(THIRDPARTY_DIR . '/jquery/plugins/livequery/jquery.livequery.js');
		Requirements::javascript(SAPPHIRE_DIR . '/javascript/core/jquery.ondemand.js');
		Requirements::javascript(THIRDPARTY_DIR . '/prototype_improvements.js');
		Requirements::javascript(THIRDPARTY_DIR . '/loader.js');
		Requirements::javascript(THIRDPARTY_DIR . '/hover.js');
		Requirements::javascript(THIRDPARTY_DIR . '/layout_helpers.js');
		Requirements::javascript(SAPPHIRE_DIR . "/javascript/i18n.js");
		
		Requirements::javascript(THIRDPARTY_DIR . '/scriptaculous/effects.js');
		Requirements::javascript(THIRDPARTY_DIR . '/scriptaculous/dragdrop.js');
		Requirements::javascript(THIRDPARTY_DIR . '/scriptaculous/controls.js');

		Requirements::css(THIRDPARTY_DIR . '/greybox/greybox.css');
		Requirements::javascript(THIRDPARTY_DIR . '/greybox/AmiJS.js');
		Requirements::javascript(THIRDPARTY_DIR . '/greybox/greybox.js');
//.........这里部分代码省略.........
开发者ID:neopba,项目名称:silverstripe-book,代码行数:101,代码来源:LeftAndMain.php

示例5: getNewItem

	/**
	 * @uses LeftAndMainDecorator->augmentNewSiteTreeItem()
	 */
	public function getNewItem($id, $setID = true) {
		list($dummy, $className, $parentID, $suffix) = array_pad(explode('-',$id),4,null);
		
		if(Translatable::is_enabled()) {
			if (!Translatable::is_default_lang()) {
				$originalItem = Translatable::get_original($className,Session::get("{$id}_originalLangID"));
				if ($setID) $originalItem->ID = $id;
				else {
					$originalItem->ID = null;
					Translatable::creating_from(Session::get($id.'_originalLangID'));
				}
				return $originalItem;
			}
		}
		
		$newItem = new $className();

	    if( !$suffix ) {
			$sessionTag = "NewItems." . $parentID . "." . $className;
    		if(Session::get($sessionTag)) {
		    	$suffix = '-' . Session::get($sessionTag);
		    	Session::set($sessionTag, Session::get($sessionTag) + 1);
		    }
		    else
		    	Session::set($sessionTag, 1);

		    	$id = $id . $suffix;
	    }

		$newItem->Title = _t('CMSMain.NEW',"New ",PR_MEDIUM,'"New " followed by a className').$className;
		$newItem->URLSegment = "new-" . strtolower($className);
		$newItem->ClassName = $className;
		$newItem->ParentID = $parentID;

		// DataObject::fieldExists only checks the current class, not the hierarchy
		// This allows the CMS to set the correct sort value
		if($newItem->castingHelperPair('Sort')) {
			$newItem->Sort = DB::query("SELECT MAX(Sort)  FROM SiteTree WHERE ParentID = '" . Convert::raw2sql($parentID) . "'")->value() + 1;
		}

		if( Member::currentUser() )
			$newItem->OwnerID = Member::currentUser()->ID;

		if($setID) $newItem->ID = $id;

		# Some modules like subsites add extra fields that need to be set when the new item is created
		$this->extend('augmentNewSiteTreeItem', $newItem);
		
		return $newItem;
	}
开发者ID:neopba,项目名称:silverstripe-book,代码行数:53,代码来源:CMSMain.php

示例6: getRecord

 /**
  * Get a database record to be managed by the CMS
  */
 public function getRecord($id)
 {
     $treeClass = $this->stat('tree_class');
     if ($id && is_numeric($id)) {
         // First, try getting a record from the stage site
         $record = DataObject::get_one($treeClass, "`{$treeClass}`.ID = {$id}");
         // Then, try getting a record from the live site
         if (!$record) {
             // $record = Versioned::get_one_by_stage($treeClass, "Live", "`$treeClass`.ID = $id");
             Versioned::reading_stage('Live');
             singleton($treeClass)->flushCache();
             $record = DataObject::get_one($treeClass, "`{$treeClass}`.ID = {$id}");
             if ($record) {
                 Versioned::reading_stage(null);
             }
         }
         // Then, try getting a deleted record
         if (!$record) {
             $record = Versioned::get_latest_version($treeClass, $id);
         }
         // Don't open a page from a different locale
         if ($record && Translatable::is_enabled() && $record->Locale && $record->Locale != Translatable::get_current_locale()) {
             $record = null;
         }
         return $record;
     } else {
         if (substr($id, 0, 3) == 'new') {
             return $this->getNewItem($id);
         }
     }
 }
开发者ID:racontemoi,项目名称:shibuichi,代码行数:34,代码来源:CMSMain.php

示例7: init

 function init()
 {
     Director::set_site_mode('cms');
     // set language
     $member = Member::currentUser();
     if (!empty($member->Locale)) {
         i18n::set_locale($member->Locale);
     }
     // set reading lang
     if (Translatable::is_enabled() && !Director::is_ajax()) {
         Translatable::choose_site_lang(array_keys(i18n::get_existing_content_languages('SiteTree')));
     }
     parent::init();
     // Allow customisation of the access check by a decorator
     if ($this->hasMethod('alternateAccessCheck')) {
         $isAllowed = $this->alternateAccessCheck();
         // Default security check for LeftAndMain sub-class permissions
     } else {
         $isAllowed = Permission::check("CMS_ACCESS_{$this->class}");
         if (!$isAllowed && $this->class == 'CMSMain') {
             // When access /admin/, we should try a redirect to another part of the admin rather than be locked out
             $menu = $this->MainMenu();
             if (($first = $menu->First()) && $first->Link) {
                 Director::redirect($first->Link);
             }
         }
     }
     // Don't continue if there's already been a redirection request.
     if (Director::redirected_to()) {
         return;
     }
     // Access failure!
     if (!$isAllowed) {
         $messageSet = array('default' => _t('LeftAndMain.PERMDEFAULT', "Please choose an authentication method and enter your credentials to access the CMS."), 'alreadyLoggedIn' => _t('LeftAndMain.PERMALREADY', "I'm sorry, but you can't access that part of the CMS.  If you want to log in as someone else, do so below"), 'logInAgain' => _t('LeftAndMain.PERMAGAIN', "You have been logged out of the CMS.  If you would like to log in again, enter a username and password below."));
         Security::permissionFailure($this, $messageSet);
         return;
     }
     Requirements::javascript('jsparty/prototype.js');
     Requirements::javascript('jsparty/behaviour.js');
     Requirements::javascript('jsparty/prototype_improvements.js');
     Requirements::javascript('jsparty/loader.js');
     Requirements::javascript('jsparty/hover.js');
     Requirements::javascript('jsparty/layout_helpers.js');
     Requirements::javascript(MCE_ROOT . 'tiny_mce_src.js');
     Requirements::javascript('cms/javascript/ImageEditor/Activator.js');
     Requirements::javascript('jsparty/tiny_mce_improvements.js');
     Requirements::javascript('jsparty/scriptaculous/effects.js');
     Requirements::javascript('jsparty/scriptaculous/dragdrop.js');
     Requirements::javascript('jsparty/scriptaculous/controls.js');
     Requirements::css('jsparty/greybox/greybox.css');
     Requirements::javascript('jsparty/greybox/AmiJS.js');
     Requirements::javascript('jsparty/greybox/greybox.js');
     Requirements::javascript('jsparty/tree/tree.js');
     Requirements::css('jsparty/tree/tree.css');
     Requirements::javascript('jsparty/tabstrip/tabstrip.js');
     Requirements::css('jsparty/tabstrip/tabstrip.css');
     Requirements::css('cms/css/TinyMCEImageEnhancement.css');
     Requirements::javascript('cms/javascript/TinyMCEImageEnhancement.js');
     Requirements::javascript('cms/javascript/LeftAndMain.js');
     Requirements::javascript('cms/javascript/LeftAndMain_left.js');
     Requirements::javascript('cms/javascript/LeftAndMain_right.js');
     Requirements::css('sapphire/css/Form.css');
     // Requirements::javascript('cms/javascript/MemberList.js');
     Requirements::javascript('cms/javascript/ForumAdmin.js');
     Requirements::javascript('cms/javascript/SideTabs.js');
     Requirements::javascript('cms/javascript/TaskList.js');
     Requirements::javascript('cms/javascript/CommentList.js');
     Requirements::javascript('cms/javascript/SideReports.js');
     Requirements::javascript('cms/javascript/LangSelector.js');
     Requirements::javascript('cms/javascript/TranslationTab.js');
     Requirements::javascript('sapphire/javascript/Validator.js');
     Requirements::javascript('sapphire/javascript/UniqueFields.js');
     Requirements::javascript('sapphire/javascript/RedirectorPage.js');
     Requirements::javascript('sapphire/javascript/DataReport.js');
     Requirements::javascript('sapphire/javascript/ToggleCompositeField.js');
     Requirements::css('sapphire/css/SubmittedFormReportField.css');
     Requirements::javascript('sapphire/javascript/FieldEditor.js');
     Requirements::css('sapphire/css/FieldEditor.css');
     Requirements::css('sapphire/css/TableListField.css');
     Requirements::css('sapphire/css/ComplexTableField.css');
     Requirements::javascript('sapphire/javascript/TableListField.js');
     Requirements::javascript('sapphire/javascript/TableField.js');
     Requirements::javascript('sapphire/javascript/ComplexTableField.js');
     Requirements::javascript('sapphire/javascript/RelationComplexTableField.js');
     Requirements::css('sapphire/css/TreeDropdownField.css');
     Requirements::css('sapphire/css/CheckboxSetField.css');
     Requirements::javascript('jsparty/calendar/calendar.js');
     Requirements::javascript('jsparty/calendar/lang/calendar-en.js');
     Requirements::javascript('jsparty/calendar/calendar-setup.js');
     Requirements::css('sapphire/css/CalendarDateField.css');
     Requirements::css('jsparty/calendar/calendar-win2k-1.css');
     Requirements::javascript('sapphire/javascript/DropdownTimeField.js');
     Requirements::css('sapphire/css/DropdownTimeField.css');
     Requirements::css('sapphire/css/PopupDateTimeField.css');
     Requirements::javascript('sapphire/javascript/SelectionGroup.js');
     Requirements::css('sapphire/css/SelectionGroup.css');
     Requirements::javascript('jsparty/SWFUpload/SWFUpload.js');
     Requirements::javascript('cms/javascript/Upload.js');
     Requirements::javascript('sapphire/javascript/HasManyFileField.js');
     Requirements::css('sapphire/css/HasManyFileField.css');
//.........这里部分代码省略.........
开发者ID:ramziammar,项目名称:websites,代码行数:101,代码来源:LeftAndMain.php

示例8: currentPage

 static function currentPage()
 {
     if (isset(Director::$urlParams['URLSegment'])) {
         $SQL_urlSegment = Convert::raw2sql(Director::$urlParams['URLSegment']);
         if (Translatable::is_enabled()) {
             return Translatable::get_one("SiteTree", "URLSegment = '{$SQL_urlSegment}'");
         } else {
             return DataObject::get_one("SiteTree", "URLSegment = '{$SQL_urlSegment}'");
         }
     } else {
         return Controller::curr();
     }
 }
开发者ID:ramziammar,项目名称:websites,代码行数:13,代码来源:Director.php

示例9: init

	function init() {
		// set language
		$member = Member::currentUser();
		if(!empty($member->Locale)) {
			i18n::set_locale($member->Locale);
		}
		
		// set reading lang
		if(Translatable::is_enabled() && !Director::is_ajax()) {
			Translatable::choose_site_lang(array_keys(Translatable::get_existing_content_languages('SiteTree')));
		}
		
		parent::init();
	}
开发者ID:neopba,项目名称:silverstripe-book,代码行数:14,代码来源:Image.php


注:本文中的Translatable::is_enabled方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。