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


PHP SiteConfig类代码示例

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


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


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