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


PHP SiteConfig::get方法代码示例

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


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

示例1: validate

 public function validate($validator)
 {
     $siteConfig = SiteConfig::get()->First();
     // don't bother querying the SimplestSpam-service if fields were empty
     if (!isset($_REQUEST['SimplestSpam_challenge_field']) || empty($_REQUEST['SimplestSpam_challenge_field'])) {
         $validator->validationError($this->name, $siteConfig->SimplestSpamWrongAnswerFieldMessage, "validation", false);
         Session::set("FormField.{$this->form->FormName()}.{$this->getName()}", $siteConfig->SimplestSpamWrongAnswerFieldMessage);
         $this->form->sessionMessage($siteConfig->SimplestSpamWrongAnswerFormMessage, "bad");
         return false;
     }
     $response = $_REQUEST['SimplestSpam_challenge_field'];
     $obj = $this->getQuestionAnswerObject();
     if (!$obj || !isset($obj->Answer)) {
         user_error("SimplestSpamField::validate(): could not find answer - sorry, please try again'", E_USER_ERROR);
         return false;
     }
     $answer = $obj->Answer;
     if ($this->cleanupAnswer($answer) != $this->cleanupAnswer($response)) {
         $validator->validationError($this->name, $siteConfig->SimplestSpamWrongAnswerFormMessage, "validation", false);
         Session::set("FormField.{$this->form->FormName()}.{$this->getName()}", $siteConfig->SimplestSpamWrongAnswerFieldMessage);
         $this->form->sessionMessage($siteConfig->SimplestSpamWrongAnswerFormMessage, "bad");
         return false;
     }
     return true;
 }
开发者ID:helpfulrobot,项目名称:sunnysideup-simplestspam,代码行数:25,代码来源:SimplestSpamField.php

示例2: updateCMSFields

 public function updateCMSFields(FieldList $fields)
 {
     $subsites = class_exists('Subsite');
     $onMainSite = TRUE;
     $currentSubsiteID = 0;
     $currentSiteConfig = SiteConfig::current_site_config();
     if ($subsites) {
         $currentSubsiteID = Subsite::currentSubsiteID();
         if ($currentSubsiteID) {
             $onMainSite = FALSE;
         }
         $mainSiteConfig = SiteConfig::get()->filter('SubsiteID', 0)->first();
     } else {
         $mainSiteConfig = $currentSiteConfig;
     }
     // Add mailblock CMS fields.
     if (Permission::check('MANAGE_MAILBLOCK') && ($mainSiteConfig->getField('MailblockApplyPerSubsite') || $onMainSite)) {
         $enabled = $currentSiteConfig->getField('MailblockEnabled');
         $tabSet = new TabSet('Mailblock', $settingsTab = $this->basicSettingsFields(), $advancedSettingsTab = $this->advancedSettingsFields($onMainSite, $currentSubsiteID), $testTab = $this->testEmailCMSFields($enabled));
         $fields->addFieldToTab('Root', $tabSet);
         $hiddenFields = array('MailblockEnabledOnLive', 'MailblockOverrideConfiguration', 'MailblockRecipients', 'MailblockWhitelist');
         if ($subsites && $currentSubsiteID == 0) {
             $hiddenFields[] = 'MailblockApplyPerSubsite';
         }
         foreach ($hiddenFields as $field) {
             $field = $fields->dataFieldByName($field);
             $field->displayIf('MailblockEnabled')->isChecked();
         }
     }
 }
开发者ID:signify-nz,项目名称:silverstripe-mailblock,代码行数:30,代码来源:MailblockSiteConfig.php

示例3: getForm

 public static function getForm()
 {
     $form = parent::getForm();
     $paypalHost = 'https://' . SiteConfig::get('Cart::PaypalHostName') . '/cgi-bin/webscr';
     $form->updateAttributes(array('action' => $paypalHost));
     $form->updateAttributes(array('onSubmit' => "return checkBeforeSendToPaypal()"));
     $form->setConstants(array('cmd' => '_cart'));
     $form->addElement('hidden', 'cmd');
     $form->setConstants(array('upload' => 1));
     $form->addElement('hidden', 'upload');
     //Set the ID of the customer making this order
     $form->setConstants(array('custom' => session_id()));
     $form->addElement('hidden', 'custom');
     $form->setConstants(array('currency_code' => "CAD"));
     $form->addElement('hidden', 'currency_code');
     $form->setConstants(array('business' => SiteConfig::get('Cart::PaypalBusinessEmailAddress')));
     $form->addElement('hidden', 'business');
     $form->setConstants(array('return' => "http://" . $_SERVER['HTTP_HOST'] . "/store/orderComplete"));
     $form->addElement('hidden', 'return');
     //		<input type="hidden" name="return" value="ordercomplete.php?req=success">
     $items = CartBasket::getUserCartBaskets($_SESSION['authenticated_user']->getId());
     $count = 0;
     foreach ($items as $item) {
         $form->setConstants(array('item_name_' . ++$count => $item->getProduct()->getName()));
         $form->addElement('hidden', 'item_name_' . $count);
         $form->setConstants(array('item_number_' . $count => $item->getProduct()->getModel()));
         $form->addElement('hidden', 'item_number_' . $count);
         $form->setConstants(array('amount_' . $count => round($item->getPrice(), 2)));
         $form->addElement('hidden', 'amount_' . $count);
         $form->setConstants(array('quantity_' . $count => $item->getQuantity()));
         $form->addElement('hidden', 'quantity_' . $count);
         //The tax will be passed as one value
         //$taxRate = CartTaxRate::getTaxRate($item->getProduct()->getTaxClass(), $_SESSION['cart_checkout']['address']['shipping_address'])->getRate();
         //$taxValue = $taxRate * $item->getPrice();//Do not multiply by the quantity because paypal does it automatically
         //$taxValue = ceil($taxValue);
         //$taxValue = $taxValue / 100;
         //$form->setConstants( array ( 'tax_' . $count => $taxValue ) );
         //$form->addElement( 'hidden', 'tax_' . $count );
         //Charge the shipping cost only for the first item because the shipping cost will apply on all the items
         $shippingCost = 0;
         if ($count == 1) {
             $shipping = @$_SESSION['cart_checkout']['shipping'];
             if ($shipping) {
                 $shippingCost = number_format($_SESSION['cart_checkout']['shipping']->getCost(), 2);
             }
             $shippingCost = ceil($shippingCost * 100) / 100;
         }
         $form->setConstants(array('shipping_' . $count => $shippingCost));
         $form->addElement('hidden', 'shipping_' . $count);
     }
     $temp = new Module_Cart();
     $form->setConstants(array('tax_cart' => $temp->getTax()));
     $form->addElement('hidden', 'tax_cart');
     //$form->setConstants( array ( 'shipping' => number_format($_SESSION['cart_checkout']['shipping']->getCost(), 2) ) );
     //$form->addElement( 'hidden', 'shipping' );
     $form->addElement('image', 'cart_submit', 'https://www.paypal.com/en_US/i/btn/x-click-but23.gif');
     return $form;
 }
开发者ID:anas,项目名称:feedstore,代码行数:58,代码来源:Paypal.php

示例4: run

 public function run()
 {
     $this->log("Upgrading settings");
     // List of rules that have been created in all stages
     $configs = SiteConfig::get()->filter(array("GoogleAnalyticsUpgradedV2" => false, "GoogleAnalyticsType" => ""));
     foreach ($configs as $config) {
         $this->upgradeConfig($config);
     }
 }
开发者ID:xini,项目名称:silverstripe-googleanalytics,代码行数:9,代码来源:GoogleAnalyticsUpgradeService.php

示例5: ContactInformations

 /**
  * @return DataObject
  */
 public function ContactInformations()
 {
     // 	checks for the active environment type, to load minified css and js files if in live mode
     if (Director::get_environment_type() == "dev" || Director::get_environment_type() == "test") {
         Requirements::css("widget_Contact/css/contactwidget.css");
     } else {
         Requirements::css("widget_Contact/css/contactwidget.min.css");
     }
     return SiteConfig::get()->First();
 }
开发者ID:helpfulrobot,项目名称:denkfabrik-neue-medien-silverstripe-widget-contact,代码行数:13,代码来源:ContactWidget.php

示例6: setUp

 public function setUp()
 {
     parent::setUp();
     // Clear automatically created siteconfigs (in case one was created outside of the specified fixtures).
     $ids = $this->allFixtureIDs('SiteConfig');
     if ($ids) {
         foreach (SiteConfig::get()->exclude('ID', $ids) as $config) {
             $config->delete();
         }
     }
 }
开发者ID:aaronleslie,项目名称:aaronunix,代码行数:11,代码来源:CMSMainTest.php

示例7: getAllPagesInDir

 public function getAllPagesInDir($sPath, $sUrl, $sGlobalConfigFile)
 {
     $oConfig = new SiteConfig($sGlobalConfigFile);
     $sSortKey = $oConfig->get('site', 'menu', 'sort_by');
     $bAsc = (bool) $oConfig->get('site', 'menu', 'sort_asc');
     $aPages = array();
     $aDirs = $this->getDirectories($sPath, false);
     foreach ($aDirs as $sDir) {
         $aPage = $this->getPageFromDir($sDir, $sUrl, $sGlobalConfigFile);
         if (isset($aPage['config'][$sSortKey]) && !empty($aPage['config'][$sSortKey])) {
             $aPages[$aPage['config'][$sSortKey]] = $aPage;
         } else {
             $aPages[] = $aPage;
         }
     }
     if ($bAsc === false) {
         krsort($aPages);
     } else {
         ksort($aPages);
     }
     return $aPages;
 }
开发者ID:rbnvrw,项目名称:crispus,代码行数:22,代码来源:Filesystem.php

示例8: mailblockTestEmail

 public function mailblockTestEmail($data, $form)
 {
     if (class_exists('Subsite')) {
         $siteConfig = SiteConfig::get()->filter('SubsiteID', 0)->first();
     } else {
         $siteConfig = SiteConfig::current_site_config();
     }
     $to = $siteConfig->getField('MailblockTestTo');
     $from = $siteConfig->getField('MailblockTestFrom');
     $subject = $siteConfig->getField('MailblockTestSubject');
     $body = $siteConfig->getField('MailblockTestBody');
     $cc = $siteConfig->getField('MailblockTestCc');
     $bcc = $siteConfig->getField('MailblockTestBcc');
     $email = new Email($from, $to, $subject, $body, NULL, $cc, $bcc);
     $email->send();
     $this->owner->response->addHeader('X-Status', rawurlencode('Test email sent!'));
     return $this->owner->getResponseNegotiator()->respond($this->owner->request);
 }
开发者ID:signify-nz,项目名称:silverstripe-mailblock,代码行数:18,代码来源:MailblockSiteConfigLeftAndMain.php

示例9: calculateCost

 public function calculateCost($session, $cartItems)
 {
     /*
      * The shipping cost is calculated as the following:
      * The pallet count is how many items can fit onto one pallet.
      * We ship items by pallets and determine our delivery costs by how many pallets are shipped. 
      * If we're shipping 20 bags of product X and 40 bags of products Y where:
      * pallet count of X is 10
      * pallet count of Y is 5
      * That means that we are shipping: 2 pallets for X and 8 pallets for Y. Thus 10 pallets in total
      * 
      * The Shipping rates will be determined by the number of pallets each order makes up AND also by the total cost (before GST) for the order.
      * Freight charges:
      * $70/pallet on orders up to $499
      * $60/pallet on orders $550 - $999
      * $50/pallet on orders +$1000
      */
     if (!is_array($cartItems)) {
         return 0.0;
     }
     $totalAmount = 0.0;
     $palletCount = 0.0;
     foreach ($cartItems as $item) {
         $product = $item->getCartItemProduct();
         $productProperty = ProductPropertiesTbl::getPropertiesBasedOnProductId($product->getId());
         $totalAmount += $product->getPrice() * $item->getQuantity();
         if ($productProperty->getPalletCount() != 0) {
             $palletCount += $item->getQuantity() / $productProperty->getPalletCount();
         } else {
             $palletCount += 0;
         }
     }
     $palletCount = ceil($palletCount);
     //Round up the number of pallets to an integer number
     if ($totalAmount >= 1000) {
         return SiteConfig::get("Cart::ShippingCostMoreThan1000") * $palletCount;
     } elseif ($totalAmount >= 500) {
         return SiteConfig::get("Cart::ShippingCostLessThan999") * $palletCount;
     } else {
         return SiteConfig::get("Cart::ShippingCostLessThan499") * $palletCount;
     }
 }
开发者ID:anas,项目名称:feedstore,代码行数:42,代码来源:EAndA.php

示例10: run

 public function run($request)
 {
     set_time_limit(0);
     increase_memory_limit_to();
     Subsite::$disable_subsite_filter = true;
     $mainConfig = SiteConfig::current_site_config();
     $mainConfig->compileStyles();
     DB::alteration_message("Compile styles for main site");
     $subsites = Subsite::get();
     foreach ($subsites as $subsite) {
         $subsiteConfig = SiteConfig::get()->filter('SubsiteID', $subsite->ID)->first();
         if (!$subsiteConfig) {
             DB::alteration_message("No config for subsite " . $subsite->ID, "error");
             continue;
         }
         $subsiteConfig->compileStyles();
         DB::alteration_message("Compile styles for subsite " . $subsite->ID);
     }
     DB::alteration_message("All done");
 }
开发者ID:lekoala,项目名称:silverstripe-theme-framework,代码行数:20,代码来源:ThemeRebuildAllStylesTask.php

示例11: process

 /**
  * Send a request to the gateway to process the payment
  * @param {array} $data Data to be passed to the gateway
  * @return {PaymentGateway_Result} Payment result object
  */
 public function process($data)
 {
     $api_key = '';
     if (PaymentGateway::get_environment() == 'dev') {
         $api_key = Config::inst()->get('StripeGateway', 'test_api_secret');
     } else {
         $api_key = Config::inst()->get('StripeGateway', 'api_secret');
     }
     if (empty($api_key)) {
         return new PaymentGateway_Failure(403, _t('StripeGateway.NO_API_KEY', '_No api key configured, you must configure StripeGateway.api_secret for live and StripeGateway.test_api_secret for dev'));
     }
     //Set the api key in the Stripe library
     Stripe::setApiKey($api_key);
     //Create the Stripe charge
     try {
         $response = Stripe_Charge::create(array('amount' => intval($data['Amount']) * 100, 'currency' => $data['Currency'], 'card' => array('number' => implode('', $data['CardNumber']), 'exp_month' => $data['MonthExpiry'], 'exp_year' => $data['YearExpiry'], 'cvc' => $data['Cvc2'], 'name' => $data['FirstName'] . ' ' . $data['LastName'], 'address_line1' => $data['BillingAddress'], 'address_line2' => $data['BillingAddress2'], 'address_city' => $data['BillingCity'], 'address_zip' => $data['BillingZIPCode'], 'address_state' => $data['BillingState'], 'address_country' => $data['BillingCountry']), 'description' => _t('StripeGateway.PAYMENT_DESCRIPTION', '_{sitetitle} Store Sale', array('sitetitle' => class_exists('SiteConfig') ? SiteConfig::get()->first()->Title : 'SilverStripe'))));
         if ($response->paid) {
             return new PaymentGateway_Success($status);
         } else {
             if ($response->cvc_check == 'fail' || $response->address_line1_check == 'fail' || $response->address_zip_check == 'fail') {
                 $errors = array();
                 if ($response->cvc_check == 'fail') {
                     $errors[] = _t('StripeGateway.FAIL_CVC', '_The credit card\'s security code (cvc) is invalid');
                 }
                 if ($response->address_line1_check == 'fail') {
                     $errors[] = _t('StripeGateway.FAIL_ADDRESS', '_Your bank declined the charge based on your address information, please verify the information and try again');
                 }
                 if ($response->address_zip_check == 'fail') {
                     $errors[] = _t('StripeGateway.FAIL_ZIP_CODE', '_Your bank declined the charge based on your postal code/zip code, please verify it and try again');
                 }
                 return new PaymentGateway_Failure(null, $errors);
             } else {
                 return new PaymentGateway_Incomplete();
             }
         }
     } catch (Stripe_Error $e) {
         return new PaymentGateway_Failure(new SS_HTTPResponse('', $e->getHttpStatus()), array($e->getCode() => $e->getMessage()));
     }
     return new PaymentGateway_Failure();
 }
开发者ID:helpfulrobot,项目名称:webbuilders-group-silverstripe-stripe-gateway,代码行数:45,代码来源:StripeGateway.php

示例12: getPaymentForm

 public function getPaymentForm()
 {
     $form = new Form('payment_form', 'payment_form', '/Store/Payment');
     $paypalHost = 'https://' . $this->hostName . '/cgi-bin/webscr';
     $form->updateAttributes(array('action' => $paypalHost));
     $form->updateAttributes(array('onSubmit' => "return checkBeforePayment()"));
     $tid = @$_SESSION['ECommTID'];
     if ($tid) {
         $transaction = Transaction::getTransactionBasedOnTID($tid);
         $sessionId = $transaction->getSession();
         $session = Session::getActiveSession($sessionId);
         $cartItems = CartItem::getAll($sessionId);
         //$form->setConstants( array ( 'cmd' => '_cart' ) );
         $form->setConstants(array('cmd' => '_xclick'));
         $form->addElement('hidden', 'cmd');
         $form->setConstants(array('upload' => 1));
         $form->addElement('hidden', 'upload');
         //Set the ID of the transaction for this order
         $form->setConstants(array('custom' => $tid));
         $form->addElement('hidden', 'custom');
         $form->setConstants(array('currency_code' => SiteConfig::get("EComm::Currency")));
         $form->addElement('hidden', 'currency_code');
         $form->setConstants(array('business' => $this->accountEmail));
         $form->addElement('hidden', 'business');
         $form->setConstants(array('return' => "http://" . $_SERVER['HTTP_HOST'] . "/Store/IPN/&action=OrderComplete&tid={$tid}"));
         $form->addElement('hidden', 'return');
         $cartDetails = Module_EComm::getCartDetails($sessionId, $cartItems);
         $form->setConstants(array('amount' => $cartDetails["subTotal"]));
         $form->addElement('hidden', 'amount');
         $form->setConstants(array('shipping' => $cartDetails["shipping"]));
         $form->addElement('hidden', 'shipping');
         $form->setConstants(array('tax' => $cartDetails["tax"]));
         $form->addElement('hidden', 'tax');
     }
     $form->addElement('image', 'cart_submit', 'https://www.paypal.com/en_US/i/btn/x-click-but23.gif');
     return $form->display();
 }
开发者ID:anas,项目名称:feedstore,代码行数:37,代码来源:Paypal.php

示例13: __construct

 public function __construct()
 {
     $this->hostName = SiteConfig::get('Cart::PaypalHostName');
     $this->accountEmail = SiteConfig::get('Cart::PaypalBusinessEmailAddress');
 }
开发者ID:anas,项目名称:feedstore,代码行数:5,代码来源:PaypalIPN.php

示例14: make_site_config

 /**
  * Create SiteConfig with defaults from language file.
  * if Translatable is enabled on SiteConfig, see if one already exist
  * and use those values for the translated defaults. 
  * 
  * @param string $locale
  * @return SiteConfig
  */
 static function make_site_config($locale = null)
 {
     if (class_exists('Translatable') && !$locale) {
         $locale = Translatable::get_current_locale();
     }
     $siteConfig = new SiteConfig();
     $siteConfig->Title = _t('SiteConfig.SITENAMEDEFAULT', "Your Site Name");
     $siteConfig->Tagline = _t('SiteConfig.TAGLINEDEFAULT', "your tagline here");
     if (class_exists('Translatable') && $siteConfig->hasExtension('Translatable')) {
         Translatable::disable_locale_filter();
         $defaultConfig = SiteConfig::get()->first();
         Translatable::enable_locale_filter();
         if ($defaultConfig) {
             return $defaultConfig->createTranslation($locale);
         }
         // TODO Copy view/edit group settings
         // set the correct Locale
         $siteConfig->Locale = $locale;
     }
     $siteConfig->write();
     return $siteConfig;
 }
开发者ID:prostart,项目名称:cobblestonepath,代码行数:30,代码来源:SiteConfig.php

示例15: mailblockRewrite

 /**
  * Replace the recipients with the recipients entered in Mailblock.
  *
  * @param string $recipients Original email recipients.
  * @param string $subject Original email subject.
  * @return array Rewritten subject and recipients.
  */
 protected function mailblockRewrite($recipients, $subject, $customHeaders)
 {
     // Get the correct mailblock config.
     if (class_exists('Subsite')) {
         $mainSiteConfig = SiteConfig::get()->filter('SubsiteID', 0)->first();
     } else {
         $mainSiteConfig = SiteConfig::current_site_config();
     }
     if ($mainSiteConfig->getField('MailblockApplyPerSubsite')) {
         $siteConfig = SiteConfig::current_site_config();
     } else {
         $siteConfig = $mainSiteConfig;
     }
     $enabled = $siteConfig->getField('MailblockEnabled');
     $enabledOnLive = $siteConfig->getField('MailblockEnabledOnLive');
     $overrideConfiguration = $siteConfig->getField('MailblockOverrideConfiguration');
     $configuration = Config::inst()->get('Email', 'send_all_emails_to');
     if ($enabled && ($enabledOnLive || SS_ENVIRONMENT_TYPE != 'live') && (!$configuration || $overrideConfiguration)) {
         // Get the CC/BCC recipients from the headers.
         $ccHeaders = '';
         $bccHeaders = '';
         if (isset($customHeaders['Cc'])) {
             $ccHeaders = $customHeaders['Cc'];
         }
         if (isset($customHeaders['Bcc'])) {
             $bccHeaders = $customHeaders['Bcc'];
         }
         $mailblockRecipients = $siteConfig->getField('MailblockRecipients');
         // Rewrite subject if 'send_all_emails_to' is not set.
         // If it is set, the subject has already been rewritten.
         if (!$configuration) {
             $subject .= " [addressed to {$recipients}";
             if ($ccHeaders) {
                 $subject .= ", cc to {$ccHeaders}";
             }
             if ($bccHeaders) {
                 $subject .= ", bcc to {$bccHeaders}";
             }
             $subject .= ']';
         }
         $newRecipients = implode(', ', preg_split("/\r\n|\n|\r/", $mailblockRecipients));
         // If one of the orignial recipients is in the whitelist, add them
         // to the new recipients list.
         $mailblockWhitelist = $siteConfig->getField('MailblockWhitelist');
         $whitelist = preg_split("/\r\n|\n|\r/", $mailblockWhitelist);
         $cc = '';
         $bcc = '';
         foreach ($whitelist as $whiteListed) {
             if (strpos($recipients, $whiteListed) !== false) {
                 $newRecipients .= ', ' . $whiteListed;
             }
             if (strpos($ccHeaders, $whiteListed) !== false) {
                 $cc = $whiteListed . ', ';
             }
             if (strpos($bccHeaders, $whiteListed) !== false) {
                 $bcc = $whiteListed . ', ';
             }
         }
         $recipients = $newRecipients;
         $customHeaders['Cc'] = $cc;
         $customHeaders['Bcc'] = $bcc;
     }
     $rewrites = array('to' => $recipients, 'subject' => $subject, 'headers' => $customHeaders);
     return $rewrites;
 }
开发者ID:signify-nz,项目名称:silverstripe-mailblock,代码行数:72,代码来源:MailblockMailer.php


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