本文整理汇总了PHP中SiteConfig::has_extension方法的典型用法代码示例。如果您正苦于以下问题:PHP SiteConfig::has_extension方法的具体用法?PHP SiteConfig::has_extension怎么用?PHP SiteConfig::has_extension使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SiteConfig
的用法示例。
在下文中一共展示了SiteConfig::has_extension方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: updateEditForm
function updateEditForm(&$form)
{
if ($form->getName() == 'RootForm' && SiteConfig::has_extension("Translatable")) {
$siteConfig = SiteConfig::current_site_config();
$form->Fields()->push(new HiddenField('Locale', '', $siteConfig->Locale));
}
}
示例2: get_google_config
/**
* Return various configuration values
*
* @param $key
* @return bool
*/
public static function get_google_config($key)
{
if (class_exists('SiteConfig') && SiteConfig::has_extension('GoogleAnalyticsLiteConfig')) {
$config = SiteConfig::current_site_config();
switch ($key) {
case 'code':
return $config->GoogleAnalyticsLiteCode ? $config->GoogleAnalyticsLiteCode : false;
case 'placement':
return $config->SnippetPlacement ? $config->SnippetPlacement : false;
}
}
return false;
}
示例3: preRequest
public function preRequest(SS_HTTPRequest $request, Session $session, DataModel $model)
{
// Skip if database isn't ready
if (!DB::isActive() || !DB::getConn()->hasField('SiteConfig', 'AkismetKey')) {
return;
}
// Skip if SiteConfig doesn't have this extension
if (!SiteConfig::has_extension('AkismetConfig')) {
return;
}
// Check if key exists
$akismetKey = SiteConfig::current_site_config()->AkismetKey;
if ($akismetKey) {
AkismetSpamProtector::set_api_key($akismetKey);
}
}
示例4: get_google_config
/**
* Return various configuration values
*
* @param $key String:
* 'profile' the Google Analytics profile id or
* 'email' the Google Analytics account's email address or
* 'password' the password for the above Google Analytics account
* @return String the config value
**/
public static function get_google_config($key)
{
if (class_exists('SiteConfig') && SiteConfig::has_extension('GoogleConfig')) {
$config = SiteConfig::current_site_config();
}
switch ($key) {
case 'code':
return !empty($config) && $config->GoogleAnalyticsCode ? $config->GoogleAnalyticsCode : GoogleLogger::$google_analytics_code;
case 'profile':
return !empty($config) && $config->GoogleAnalyticsProfileId ? $config->GoogleAnalyticsProfileId : GoogleAnalyzer::$profile_id;
case 'email':
return !empty($config) && $config->GoogleAnalyticsEmail ? $config->GoogleAnalyticsEmail : GoogleAnalyzer::$email;
case 'password':
return !empty($config) && $config->GoogleAnalyticsPassword ? $config->GoogleAnalyticsPassword : GoogleAnalyzer::$password;
case 'universal':
return !empty($config) && $config->UseGoogleUniversalSnippet ? $config->UseGoogleUniversalSnippet : GoogleAnalyzer::$use_universal_snippet;
}
}
示例5: getPrices
/**
* Grabs all prices into one place.
* @return ArrayList
*/
public function getPrices()
{
if (!isset($this->_prices)) {
$this->_prices = new ArrayList();
// Create a base tier
$base = new PriceTier();
$base->Label = $this->owner->BasePriceLabel;
$base->Price = $this->owner->sellingPrice();
$base->Percentage = 1;
$base->MinQty = 1;
$this->_prices->push($base);
// Integrate with promo pricing
if ($this->owner->hasExtension('HasPromotionalPricing') && $base->Price != $this->owner->BasePrice) {
$base->OriginalPrice = $this->owner->BasePrice;
}
// If this product has tiers, use those
$tiers = $this->owner->PriceTiers();
// If not, see if the parent has tiers
if ((!$tiers || !$tiers->exists()) && $this->owner->hasMethod('Parent')) {
$parent = $this->owner->Parent();
if ($parent && $parent->exists() && $parent->hasExtension('HasPriceTiers')) {
$tiers = $parent->PriceTiers();
if ($tiers && empty($base->Label) && !empty($parent->BasePriceLabel)) {
$base->Label = $parent->BasePriceLabel;
}
}
}
// If not, see if there are global tiers
if ((!$tiers || !$tiers->exists()) && SiteConfig::has_extension('HasPriceTiers')) {
$global = SiteConfig::current_site_config();
$tiers = $global->PriceTiers();
if ($tiers && empty($base->Label) && !empty($global->BasePriceLabel)) {
$base->Label = $global->BasePriceLabel;
}
}
// Fill in the additional tiers
foreach ($tiers as $tier) {
/** @var PriceTier $tier */
// calculate a price if needed
if ($tier->Price == 0 && $tier->Percentage > 0) {
$tier->Price = $tier->calcPrice($base->Price);
} elseif ($tier->Price > 0 && $tier->Percentage == 0 && $base->Price > 0) {
$price = $tier->Price;
$this->owner->extend('updateSellingPrice', $price);
// make sure discounts still apply
$price = $price < 0 ? 0 : $price;
$tier->Price = $price;
$tier->Percentage = $price / $base->Price;
}
// integrate with promo pricing
if ($this->owner->hasExtension('HasPromotionalPricing') && !empty($base->OriginalPrice)) {
$tier->OriginalPrice = $tier->calcPrice($base->OriginalPrice);
}
// add it to the stack
$this->_prices->push($tier);
}
// now make one more pass through and generate missing labels
$num = $this->_prices->count();
if ($num > 1) {
for ($i = 0; $i < $num; $i++) {
if (empty($this->_prices[$i]->Label)) {
$this->_prices[$i]->Label = (string) $this->_prices[$i]->MinQty;
if ($i == $num - 1) {
$this->_prices[$i]->Label .= '+';
} else {
$this->_prices[$i]->Label .= '-' . ($this->_prices[$i + 1]->MinQty - 1);
}
}
}
}
}
return $this->_prices;
}
示例6: getUsersBlogs
/**
* Gets the site config or subsites for the current site
* @return {array} Nested array of sites
*/
protected function getUsersBlogs($app_id)
{
if (SiteConfig::has_extension('SiteConfigSubsites')) {
$response = array();
//Disable subsite filter
Subsite::disable_subsite_filter();
$subsites = Subsite::get();
foreach ($subsites as $subsite) {
$response[] = array('blogid' => $subsite->ID, 'blogname' => $subsite->Title);
}
//Re-enable subsite filter
Subsite::disable_subsite_filter(false);
return $response;
}
$siteConfig = SiteConfig::current_site_config();
return array(array('blogid' => $siteConfig->ID, 'blogname' => $siteConfig->Title));
}