本文整理汇总了PHP中SiteConfig类的典型用法代码示例。如果您正苦于以下问题:PHP SiteConfig类的具体用法?PHP SiteConfig怎么用?PHP SiteConfig使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了SiteConfig类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: subscribe
/**
* Handles the action when subscribe is being done
*
* @param Array $data
* @param Form $form
*/
public function subscribe(array $data, Form $form)
{
$settings = SiteConfig::current_site_config();
$MailChimp = new \Drewm\MailChimp($settings->APIKey);
$apiData = array('id' => $settings->MailChimpList()->filter(array('Code' => 'NEWSLETTER'))->First()->ListID, 'email' => array('email' => $data['Email']), 'double_optin' => false, 'update_existing' => false, 'replace_interests' => false, 'send_welcome' => false);
$this->extend('updateAPIData', $apiData);
$result = $MailChimp->call('lists/subscribe', $apiData);
if (Director::is_ajax()) {
if (isset($result['status']) && $result['status'] == 'error') {
if ($result['code'] == 214) {
return json_encode(array('success' => false, 'message' => $data['Email'] . ' is already subscribed'));
} else {
return json_encode(array('success' => false, 'message' => $result['error']));
}
} else {
return json_encode(array('success' => true, 'message' => 'Thank you for subscribing to our newsletter'));
}
} else {
if (isset($result['status']) && $result['status'] == 'error') {
if ($result['code'] == 214) {
$this->sessionMessage($data['Email'] . ' is already subscribed.', 'bad');
} else {
$this->sessionMessage($result['error'], 'bad');
}
} else {
$this->sessionMessage('Thank you for subscribing to our newsletter', 'good');
}
Controller::curr()->redirectBack();
}
}
开发者ID:sentromedia,项目名称:letsfund,代码行数:36,代码来源:MailChimpForm.php
示例2: update
public function update($title, $subtitle, $siteAuthor, $siteContactEmail,
$friendlyURL, $UUID, $sitePath, $defaultLanguage,
$databaseConnection, $databaseUser, $databasePassword)
{
$config = new SiteConfig;
$config->title = $title;
$config->subtitle = $subtitle;
$config->siteAuthor = $siteAuthor;
$config->siteContactEmail = $siteContactEmail;
$config->friendlyURL = $friendlyURL;
$config->UUID = $UUID;
$config->sitePath = $sitePath;
$config->databaseConnection = $databaseConnection;
$config->databaseUser = $databaseUser;
$config->defaultLanguage = $defaultLanguage;
try
{
$config->save();
$this->notice(t('Saved site configuration'));
$this->redirect('admin/system');
}
catch (ValidationException $e)
{
$this->config = $config;
$this->languages = $this->getLanguages();
$this->error(t('Failed saving configuration'));
$this->render('config');
}
}
开发者ID:nathansamson,项目名称:CoOrg,代码行数:31,代码来源:admin.system.controller.php
示例3: upgradeConfig
protected function upgradeConfig(SiteConfig $config)
{
$this->log("Upgrading site config ID = " . $config->ID);
if ($config->GoogleAnalyticsUseUniversalAnalytics) {
$config->GoogleAnalyticsType = 'Universal Analytics';
} else {
$config->GoogleAnalyticsType = 'Old Asynchronous Analytics';
}
$config->GoogleAnalyticsUpgradedV2 = true;
$config->write();
}
开发者ID:xini,项目名称:silverstripe-googleanalytics,代码行数:11,代码来源:GoogleAnalyticsUpgradeService.php
示例4: updateMetadata
/**
* @param SiteConfig $config
* @param SiteTree $owner
* @param string $metadata
*
* @return void
*
*/
public function updateMetadata(SiteConfig $config, SiteTree $owner, &$metadata)
{
// Facebook App ID
if ($config->FacebookAppID) {
$metadata .= $owner->MarkupComment('Facebook Insights');
$metadata .= $owner->MarkupFacebook('fb:app_id', $config->FacebookAppID, false);
// Admins (if App ID)
foreach ($config->FacebookAdmins() as $admin) {
if ($admin->FacebookProfileID) {
$metadata .= $owner->MarkupFacebook('fb:admins', $admin->FacebookProfileID, false);
}
}
}
}
开发者ID:graphiques-digitale,项目名称:silverstripe-seo-facebook-domain-insights,代码行数:22,代码来源:SEO_FacebookDomainInsights_SiteTree_DataExtension.php
示例5: alternateSiteConfig
public function alternateSiteConfig()
{
if (!$this->owner->SubsiteID) {
return false;
}
$sc = DataObject::get_one('SiteConfig', '"SubsiteID" = ' . $this->owner->SubsiteID);
if (!$sc) {
$sc = new SiteConfig();
$sc->SubsiteID = $this->owner->SubsiteID;
$sc->Title = _t('Subsite.SiteConfigTitle', 'Your Site Name');
$sc->Tagline = _t('Subsite.SiteConfigSubtitle', 'Your tagline here');
$sc->write();
}
return $sc;
}
开发者ID:mikenz,项目名称:silverstripe-simplesubsites,代码行数:15,代码来源:SiteTreeSubsites.php
示例6: getCMSFields
public function getCMSFields()
{
$conf = SiteConfig::current_site_config();
$themes = $conf->getAvailableThemes();
$theme = new DropdownField('Theme', _t('Multisites.THEME', 'Theme'), $themes);
$theme->setEmptyString(_t('Multisites.DEFAULTTHEME', '(Default theme)'));
$fields = new FieldList(new TabSet('Root', new Tab('Main', new HeaderField('SiteConfHeader', _t('Multisites.SITECONF', 'Site Configuration')), new TextField('Title', _t('Multisites.TITLE', 'Title')), new TextField('Tagline', _t('Multisites.TAGLINE', 'Tagline/Slogan')), $theme, new HeaderField('SiteURLHeader', _t('Multisites.SITEURL', 'Site URL')), new OptionsetField('Scheme', _t('Multisites.SCHEME', 'Scheme'), array('any' => _t('Multisites.ANY', 'Any'), 'http' => _t('Multisites.HTTP', 'HTTP'), 'https' => _t('Multisites.HTTPS', 'HTTPS (HTTP Secure)'))), new TextField('Host', _t('Multisites.HOST', 'Host')), new MultiValueTextField('HostAliases', _t('Multisites.HOSTALIASES', 'Host Aliases')), new CheckboxField('IsDefault', _t('Multisites.ISDEFAULT', 'Is this the default site?')), new HeaderField('SiteAdvancedHeader', _t('Multisites.SiteAdvancedHeader', 'Advanced Settings')), TextareaField::create('RobotsTxt', _t('Multisites.ROBOTSTXT', 'Robots.txt'))->setDescription(_t('Multisites.ROBOTSTXTUSAGE', '<p>Please consult <a href="http://www.robotstxt.org/robotstxt.html" target="_blank">http://www.robotstxt.org/robotstxt.html</a> for usage of the robots.txt file.</p>')))));
$devIDs = Config::inst()->get('Multisites', 'developer_identifiers');
if (is_array($devIDs)) {
if (!ArrayLib::is_associative($devIDs)) {
$devIDs = ArrayLib::valuekey($devIDs);
}
$fields->addFieldToTab('Root.Main', DropdownField::create('DevID', _t('Multisites.DeveloperIdentifier', 'Developer Identifier'), $devIDs));
}
if (Multisites::inst()->assetsSubfolderPerSite()) {
$fields->addFieldToTab('Root.Main', new TreeDropdownField('FolderID', _t('Multisites.ASSETSFOLDER', 'Assets Folder'), 'Folder'), 'SiteURLHeader');
}
if (!Permission::check('SITE_EDIT_CONFIGURATION')) {
foreach ($fields->dataFields() as $field) {
$fields->makeFieldReadonly($field);
}
}
$this->extend('updateSiteCMSFields', $fields);
return $fields;
}
开发者ID:silverstripe-australia,项目名称:silverstripe-multisites,代码行数:25,代码来源:Site.php
示例7: 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));
}
}
开发者ID:helpfulrobot,项目名称:silverstripe-translatable,代码行数:7,代码来源:TranslatableCMSMainExtension.php
示例8: OpenGraphMetadata
/**
* @name OpenGraphMetadata
*/
public function OpenGraphMetadata()
{
$self = $this->owner;
if ($self->OpenGraphType != 'off') {
// variables
$config = SiteConfig::current_site_config();
$metadata = $self->MarkupHeader('Open Graph');
//// Type
$metadata .= $self->MarkupFacebook('og:type', $self->OpenGraphType, false);
//// Site Name
$metadata .= $self->MarkupFacebook('og:site_name', $config->Title, true, $config->Charset);
//// URL
$metadata .= $self->MarkupFacebook('og:url', $self->AbsoluteLink(), false);
//// Title
$title = $self->OpenGraphTitle ? $self->OpenGraphTitle : $self->Title;
$metadata .= $self->MarkupFacebook('og:title', $title, true, $config->Charset);
//// Description
$description = $self->OpenGraphDescription ? $self->OpenGraphDescription : $self->GenerateDescription();
$metadata .= $self->MarkupFacebook('og:description', $description, true, $config->Charset);
//// Image
if ($self->OpenGraphImage()->exists()) {
$metadata .= $self->MarkupFacebook('og:image', $self->OpenGraphImage()->getAbsoluteURL(), false);
}
//// og:locale
//// article:author
// in Core
//// article:publisher
// in Core
// return
return $metadata;
} else {
return false;
}
}
开发者ID:helpfulrobot,项目名称:graphiques-digitale-ssseo,代码行数:37,代码来源:SSSEO_OpenGraph_SiteTree_DataExtension.php
示例9: updateSettingsFields
public function updateSettingsFields(FieldList $fields)
{
$systemThemes = SiteConfig::current_site_config()->getAvailableThemes();
$partials = $themes = array('' => '', 'none' => '(none)');
foreach ($systemThemes as $key => $themeName) {
if (file_exists(Director::baseFolder() . '/themes/' . $themeName . '/templates/Page.ss')) {
$themes[$key] = $themeName;
} else {
$partials[$key] = $themeName;
}
}
$themeDropdownField = new DropdownField("AppliedTheme", 'Applied Theme', $themes);
$fields->addFieldToTab('Root.Theme', $themeDropdownField);
$current = $this->appliedTheme();
if ($current) {
$themeDropdownField->setRightTitle('Current effective theme: ' . $current);
} else {
$themeDropdownField->setRightTitle('Using default site theme');
}
$themeDropdownField = new DropdownField("PartialTheme", 'Partial Theme', $partials);
$fields->addFieldToTab('Root.Theme', $themeDropdownField);
$current = $this->appliedPartialTheme();
if ($current) {
$themeDropdownField->setRightTitle('Current effective partial theme: ' . $current);
} else {
$themeDropdownField->setRightTitle('Please only use a specific applied theme OR a partial theme, not both!');
}
}
开发者ID:helpfulrobot,项目名称:silverstripe-australia-silverstripe-partial-themes,代码行数:28,代码来源:PartialThemesExtension.php
示例10: run
/**
* @param SS_HTTPRequest $request
*/
public function run($request)
{
// Only allow execution from the command line (for simplicity).
if (!Director::is_cli()) {
echo "<p>Sorry, but this can only be run from the command line.</p>";
return;
}
try {
// Get and validate desired maintenance mode setting.
$get = $request->getVars();
if (empty($get["args"])) {
throw new Exception("Please provide an argument (e.g. 'on' or 'off').", 1);
}
$arg = strtolower(current($get["args"]));
if ($arg != "on" && $arg != "off") {
throw new Exception("Invalid argument: '{$arg}' (expected 'on' or 'off')", 2);
}
// Get and write site configuration now.
$config = SiteConfig::current_site_config();
$previous = !empty($config->MaintenanceMode) ? "on" : "off";
$config->MaintenanceMode = $arg == "on";
$config->write();
// Output status and exit.
if ($arg != $previous) {
$this->output("Maintenance mode is now '{$arg}'.");
} else {
$this->output("NOTE: Maintenance mode was already '{$arg}' (nothing has changed).");
}
} catch (Exception $e) {
$this->output("ERROR: " . $e->getMessage());
if ($e->getCode() <= 2) {
$this->output("Usage: sake dev/tasks/MaintenanceMode [on|off]");
}
}
}
开发者ID:helpfulrobot,项目名称:thisisbd-silverstripe-maintenance-mode,代码行数:38,代码来源:MaintenanceMode.php
示例11: complete
/**
* Completes the job by zipping up the generated export and creating an
* export record for it.
*/
protected function complete()
{
$siteTitle = SiteConfig::current_site_config()->Title;
$filename = preg_replace('/[^a-zA-Z0-9-.+]/', '-', sprintf('%s-%s.zip', $siteTitle, date('c')));
$dir = Folder::findOrMake(SiteExportExtension::EXPORTS_DIR);
$dirname = ASSETS_PATH . '/' . SiteExportExtension::EXPORTS_DIR;
$pathname = "{$dirname}/{$filename}";
SiteExportUtils::zip_directory($this->tempDir, "{$dirname}/{$filename}");
Filesystem::removeFolder($this->tempDir);
$file = new File();
$file->ParentID = $dir->ID;
$file->Title = $siteTitle . ' ' . date('c');
$file->Filename = $dir->Filename . $filename;
$file->write();
$export = new SiteExport();
$export->ParentClass = $this->rootClass;
$export->ParentID = $this->rootId;
$export->Theme = $this->theme;
$export->BaseUrlType = ucfirst($this->baseUrlType);
$export->BaseUrl = $this->baseUrl;
$export->ArchiveID = $file->ID;
$export->write();
if ($this->email) {
$email = new Email();
$email->setTo($this->email);
$email->setTemplate('SiteExportCompleteEmail');
$email->setSubject(sprintf('Site Export For "%s" Complete', $siteTitle));
$email->populateTemplate(array('SiteTitle' => $siteTitle, 'Link' => $file->getAbsoluteURL()));
$email->send();
}
}
开发者ID:rodneyway,项目名称:silverstripe-siteexporter,代码行数:35,代码来源:SiteExportJob.php
示例12: updateCMSFields
public function updateCMSFields(FieldList $fields)
{
// vars
$config = SiteConfig::current_site_config();
$owner = $this->owner;
// decode data into array
$data = json_decode($owner->OpenGraphData, true);
// @todo Add repair method if data is missing / corrupt ~ for fringe cases
// tab
$tab = new Tab('OpenGraph');
// add disabled/error state if `off`
if ($data['og:type'] === 'off') {
$tab->addExtraClass('error');
}
// add the tab
$fields->addFieldToTab('Root.Metadata', $tab, 'FullOutput');
// new identity
$tab = 'Root.Metadata.OpenGraph';
// add description
// type always visible
$fields->addFieldsToTab($tab, array(LabelField::create('OpenGraphHeader', '@todo Information</a>')->addExtraClass('information'), DropdownField::create('OpenGraphType', '<a href="http://ogp.me/#types">og:type</a>', self::$types, $data['og:type'])));
if ($data['og:type'] !== 'off') {
$fields->addFieldsToTab($tab, array(ReadonlyField::create('OpenGraphURL', 'Canonical URL', $owner->AbsoluteLink()), TextField::create('OpenGraphSiteName', 'Site Name', $data['og:site_name'])->setAttribute('placeholder', $config->Title), TextField::create('OpenGraphTitle', 'Page Title', $data['og:title'])->setAttribute('placeholder', $owner->Title), TextareaField::create('OpenGraphDescription', 'Description', $data['og:description'])->setAttribute('placeholder', $owner->GenerateDescription()), UploadField::create('OpenGraphImage', 'Image<pre>type: png/jpg/gif</pre><pre>size: variable *</pre>', $owner->OpenGraphImage)->setAllowedExtensions(array('png', 'jpg', 'jpeg', 'gif'))->setFolderName(self::$SEOOpenGraphUpload . $owner->Title)->setDescription('* <a href="https://developers.facebook.com/docs/sharing/best-practices#images" target="_blank">Facebook image best practices</a>, or use any preferred Open Graph guide.')));
}
}
开发者ID:graphiques-digitale,项目名称:silverstripe-seo-open-graph,代码行数:25,代码来源:SEO_OpenGraph_SiteTree_DataExtension.php
示例13: processComment
public function processComment()
{
if ($comment = $this->getComment()) {
$config = SiteConfig::current_site_config();
if (isset($_GET['token'])) {
$realtoken = md5($config->SiteTitle . $comment->ID);
if ($_GET['token'] == $realtoken) {
if (isset($_GET['delete'])) {
echo "Comment Deleted.";
$parent = $comment->getParent();
$comment->delete();
$this->redirect($parent->Link());
} else {
$comment->Moderated = true;
$comment->write();
echo "Comment Approved.";
$this->redirect($comment->Link());
}
} else {
die("Oh dear: Error 1A");
}
} else {
die("Oh dear: Error 1B");
}
} else {
die("Comment not found. Already deleted?");
}
}
开发者ID:helpfulrobot,项目名称:purplespider-mypswd-blog-tweaks,代码行数:28,代码来源:CommentApproval.php
示例14: getConf
public function getConf()
{
if (!static::$conf_instance) {
static::$conf_instance = SiteConfig::current_site_config();
}
return static::$conf_instance;
}
开发者ID:helpfulrobot,项目名称:azt3k-abc-silverstripe-social,代码行数:7,代码来源:SyncFacebook.php
示例15: Subscribe
/**
* Submit the form
*
* @param $data
* @param $form
* @return bool|SS_HTTPResponse
*/
public function Subscribe($data, $form)
{
/** @var Form $form */
$data = $form->getData();
/** Set the form state */
Session::set('FormInfo.Form_' . $this->name . '.data', $data);
$siteConfig = SiteConfig::current_site_config();
/** Check if the API key, and List ID have been set. */
if ($siteConfig->MailChimpAPI && $siteConfig->MailChimpListID) {
$mailChimp = new \Drewm\MailChimp($siteConfig->MailChimpAPI);
$result = $mailChimp->call('lists/subscribe', array('id' => $siteConfig->MailChimpListID, 'email' => array('email' => $data['Email'])));
} else {
/** If not, redirect back and display a flash error. */
$this->controller->setFlash('Missing API key, or List ID', 'danger');
return $this->controller->redirectBack();
}
/**
* If the status of the request returns an error,
* display the error
*/
if (isset($result['status'])) {
if ($result['status'] == 'error') {
$this->controller->setFlash($result['error'], 'danger');
return $this->controller->redirectBack();
}
}
/** Clear the form state */
Session::clear('FormInfo.Form_' . $this->name . '.data');
if ($siteConfig->MailChimpSuccessMessage) {
$this->controller->setFlash($siteConfig->MailChimpSuccessMessage, 'success');
} else {
$this->controller->setFlash('Your subscription has been received, you will be sent a confirmation email shortly.', 'success');
}
return $this->controller->redirect($this->controller->data()->Link());
}
开发者ID:helpfulrobot,项目名称:ryanpotter-silverstripe-boilerplate,代码行数:42,代码来源:SubscriptionForm.php
示例16: LatestTweetsList
public function LatestTweetsList($limit = '5')
{
$conf = SiteConfig::current_site_config();
if (empty($conf->TwitterName) || empty($conf->TwitterConsumerKey) || empty($conf->TwitterConsumerSecret) || empty($conf->TwitterAccessToken) || empty($conf->TwitterAccessTokenSecret)) {
return new ArrayList();
}
$cache = SS_Cache::factory('LatestTweets_cache');
if (!($results = unserialize($cache->load(__FUNCTION__)))) {
$results = new ArrayList();
require_once dirname(__FILE__) . '/tmhOAuth/tmhOAuth.php';
require_once dirname(__FILE__) . '/tmhOAuth/tmhUtilities.php';
$tmhOAuth = new tmhOAuth(array('consumer_key' => $conf->TwitterConsumerKey, 'consumer_secret' => $conf->TwitterConsumerSecret, 'user_token' => $conf->TwitterAccessToken, 'user_secret' => $conf->TwitterAccessTokenSecret, 'curl_ssl_verifypeer' => false));
$code = $tmhOAuth->request('GET', $tmhOAuth->url('1.1/statuses/user_timeline'), array('screen_name' => $conf->TwitterName, 'count' => $limit));
$tweets = $tmhOAuth->response['response'];
$json = new JSONDataFormatter();
if (($arr = $json->convertStringToArray($tweets)) && is_array($arr) && isset($arr[0]['text'])) {
foreach ($arr as $tweet) {
try {
$here = new DateTime(SS_Datetime::now()->getValue());
$there = new DateTime($tweet['created_at']);
$there->setTimezone($here->getTimezone());
$date = $there->Format('Y-m-d H:i:s');
} catch (Exception $e) {
$date = 0;
}
$results->push(new ArrayData(array('Text' => nl2br(tmhUtilities::entify_with_options($tweet, array('target' => '_blank'))), 'Date' => SS_Datetime::create_field('SS_Datetime', $date))));
}
}
$cache->save(serialize($results), __FUNCTION__);
}
return $results;
}
开发者ID:unisolutions,项目名称:silverstripe-latesttweets,代码行数:32,代码来源:LaTw_Page_Controller_Extension.php
示例17: TwitterCardsMetadata
/**
* @name TwitterCardsMetadata
* outputs Twitter metadata
*/
public function TwitterCardsMetadata()
{
$self = $this->owner;
if ($self->TwitterCardsType != 'off') {
// variables
$config = SiteConfig::current_site_config();
$metadata = $self->MarkupHeader('Twitter Cards');
//// Type
$metadata .= $self->MarkupTwitter('twitter:card', $self->TwitterCardsType, false);
//// Site Name
$metadata .= $self->MarkupTwitter('twitter:site', $config->Title, true, $config->Charset);
//// URL
$metadata .= $self->MarkupTwitter('twitter:url', $self->AbsoluteLink(), false);
//// Title
// default to SiteTree::$Title
$title = $self->TwitterCardsTitle ? $self->TwitterCardsTitle : $self->Title;
$metadata .= $self->MarkupTwitter('twitter:title', $title, true, $config->Charset);
//// Description
// default to SiteTree::$Description
$description = $self->TwitterCardsDescription ? $self->TwitterCardsDescription : $self->GenerateDescription();
$metadata .= $self->MarkupTwitter('twitter:description', $description, true, $config->Charset);
//// Image
if ($self->TwitterCardsImage()->exists()) {
$metadata .= $self->MarkupTwitter('twitter:image', $self->TwitterCardsImage()->getAbsoluteURL(), false);
}
// return
return $metadata;
} else {
return false;
}
}
开发者ID:helpfulrobot,项目名称:graphiques-digitale-ssseo,代码行数:35,代码来源:SSSEO_TwitterCards_SiteTree_DataExtension.php
示例18: index
public function index()
{
$site = SiteConfig::current_site_config();
$order = $this->order;
// Setup the paypal gateway URL
if (Director::isDev()) {
$gateway_url = "https://www.sandbox.paypal.com/cgi-bin/webscr";
} else {
$gateway_url = "https://www.paypal.com/cgi-bin/webscr";
}
$callback_url = Controller::join_links(Director::absoluteBaseURL(), Payment_Controller::config()->url_segment, "callback", $this->payment_gateway->ID);
$success_url = Controller::join_links(Director::absoluteBaseURL(), Payment_Controller::config()->url_segment, 'complete');
$error_url = Controller::join_links(Director::absoluteBaseURL(), Payment_Controller::config()->url_segment, 'complete', 'error');
$back_url = Controller::join_links(Director::absoluteBaseURL(), Checkout_Controller::config()->url_segment, "finish");
$fields = new FieldList(HiddenField::create('business', null, $this->payment_gateway->BusinessID), HiddenField::create('item_name', null, $site->Title), HiddenField::create('cmd', null, "_cart"), HiddenField::create('paymentaction', null, "sale"), HiddenField::create('invoice', null, $order->OrderNumber), HiddenField::create('custom', null, $order->OrderNumber), HiddenField::create('upload', null, 1), HiddenField::create('discount_amount_cart', null, $order->DiscountAmount), HiddenField::create('amount', null, $order->Total), HiddenField::create('currency_code', null, $site->Currency()->GatewayCode), HiddenField::create('first_name', null, $order->FirstName), HiddenField::create('last_name', null, $order->Surname), HiddenField::create('address1', null, $order->Address1), HiddenField::create('address2', null, $order->Address2), HiddenField::create('city', null, $order->City), HiddenField::create('zip', null, $order->PostCode), HiddenField::create('country', null, $order->Country), HiddenField::create('email', null, $order->Email), HiddenField::create('return', null, $success_url), HiddenField::create('notify_url', null, $callback_url), HiddenField::create('cancel_return', null, $error_url));
$i = 1;
foreach ($order->Items() as $item) {
$fields->add(HiddenField::create('item_name_' . $i, null, $item->Title));
$fields->add(HiddenField::create('amount_' . $i, null, number_format($item->Price + $item->Tax, 2)));
$fields->add(HiddenField::create('quantity_' . $i, null, $item->Quantity));
$i++;
}
// Add shipping as an extra product
$fields->add(HiddenField::create('item_name_' . $i, null, _t("Commerce.Postage", "Postage")));
$fields->add(HiddenField::create('amount_' . $i, null, number_format($order->PostageCost + $order->PostageTax, 2)));
$fields->add(HiddenField::create('quantity_' . $i, null, "1"));
$actions = FieldList::create(LiteralField::create('BackButton', '<a href="' . $back_url . '" class="btn btn-red commerce-action-back">' . _t('Commerce.Back', 'Back') . '</a>'), FormAction::create('Submit', _t('Commerce.ConfirmPay', 'Confirm and Pay'))->addExtraClass('btn')->addExtraClass('btn-green'));
$form = Form::create($this, 'Form', $fields, $actions)->addExtraClass('forms')->setFormMethod('POST')->setFormAction($gateway_url);
$this->extend('updateForm', $form);
return array("Title" => _t('Commerce.CheckoutSummary', "Summary"), "MetaTitle" => _t('Commerce.CheckoutSummary', "Summary"), "Form" => $form);
}
开发者ID:helpfulrobot,项目名称:i-lateral-silverstripe-commerce,代码行数:31,代码来源:PayPalHandler.php
示例19: validateStep
/**
* This does not actually perform any validation, but just creates the
* initial registration object.
*/
public function validateStep($data, $form)
{
$form = $this->getForm();
$datetime = $form->getController()->getDateTime();
$confirmation = $datetime->Event()->RegEmailConfirm;
$registration = $this->getForm()->getSession()->getRegistration();
// If we require email validation for free registrations, then send
// out the email and mark the registration. Otherwise immediately
// mark it as valid.
if ($confirmation) {
$email = new Email();
$config = SiteConfig::current_site_config();
$registration->TimeID = $datetime->ID;
$registration->Status = 'Unconfirmed';
$registration->write();
if (Member::currentUserID()) {
$details = array('Name' => Member::currentUser()->getName(), 'Email' => Member::currentUser()->Email);
} else {
$details = $form->getSavedStepByClass('EventRegisterTicketsStep');
$details = $details->loadData();
}
$link = Controller::join_links($this->getForm()->getController()->Link(), 'confirm', $registration->ID, '?token=' . $registration->Token);
$regLink = Controller::join_links($datetime->Event()->Link(), 'registration', $registration->ID, '?token=' . $registration->Token);
$email->setTo($details['Email']);
$email->setSubject(sprintf('Confirm Registration For %s (%s)', $datetime->getTitle(), $config->Title));
$email->setTemplate('EventRegistrationConfirmationEmail');
$email->populateTemplate(array('Name' => $details['Name'], 'Registration' => $registration, 'RegLink' => $regLink, 'Title' => $datetime->getTitle(), 'SiteConfig' => $config, 'ConfirmLink' => Director::absoluteURL($link)));
$email->send();
Session::set("EventRegistration.{$registration->ID}.message", $datetime->Event()->EmailConfirmMessage);
} else {
$registration->Status = 'Valid';
$registration->write();
}
return true;
}
开发者ID:tardinha,项目名称:silverstripe-eventmanagement,代码行数:39,代码来源:EventRegisterFreeConfirmationStep.php
示例20: postFacebook
/**
* @todo fix this BIG mess.
*/
public static function postFacebook($message, $link = null, $impression = null)
{
$member = Member::currentUser();
$postresult = false;
$SiteConfig = SiteConfig::current_site_config();
if ($member && $SiteConfig->FBAppID && $SiteConfig->FBSecret) {
if ($link == null) {
$link = Director::absoluteBaseURL();
}
$page = '/' . $SiteConfig->FBPageID . '/feed';
$facebook = new Facebook(array('appId' => $SiteConfig->FBAppID, 'secret' => $SiteConfig->FBSecret));
$token = $facebook->api('/me/accounts');
foreach ($token['data'] as $pages) {
if ($pages['id'] == $SiteConfig->FBPageID) {
$facebook->setAccessToken($pages['access_token']);
$verified = true;
break;
}
}
if ($verified) {
$data = array('message' => $message, 'link' => $link, 'picture' => $impression);
$postresult = $facebook->api($page, 'post', $data);
}
}
return $postresult;
}
开发者ID:helpfulrobot,项目名称:firesphere-social,代码行数:29,代码来源:FacebookController.php
注:本文中的SiteConfig类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论