function updateEditForm(&$form) { if ($form->getName() == 'RootForm' && SiteConfig::has_extension("Translatable")) { $siteConfig = SiteConfig::current_site_config(); $form->Fields()->push(new HiddenField('Locale', '', $siteConfig->Locale)); } }
/** * 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; }
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); } }
/** * 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; } }
/** * 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; }
/** * 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)); }