コード例 #1
0
 public function MetaTags($includeTitle = true)
 {
     $customFields = array();
     if ($includeTitle === true || $includeTitle == 'true') {
         $customFields['AddHeaderTitle'] = true;
     }
     $customFields['Charset'] = ContentNegotiator::get_encoding();
     if (Permission::check('CMS_ACCESS_CMSMain') && in_array('CMSPreviewable', class_implements($this->owner->data())) && !$this->owner->data() instanceof ErrorPage && $this->owner->data()->ID > 0) {
         $customFields['CMSAccess'] = 1;
         $customFields['XPageID'] = $this->owner->data()->ID;
         $customFields['XCMSEditLink'] = $this->owner->data()->CMSEditLink();
     }
     $metadata = $this->owner->renderWith('MetaTags', $customFields);
     /* strip blank lines */
     $metadata = preg_replace('/(^[\\r\\n]*|[\\r\\n]+)[\\s\\t]*[\\r\\n]+/', "\n", $metadata);
     /* add tabs to neaten code */
     $metadata = preg_replace('/\\r?\\n</', "\n\t<", $metadata);
     return trim($metadata);
 }
コード例 #2
0
ファイル: SiteTree.php プロジェクト: rixrix/silverstripe-cms
 /**
  * Return the title, description, keywords and language metatags.
  * 
  * @todo Move <title> tag in separate getter for easier customization and more obvious usage
  * 
  * @param boolean|string $includeTitle Show default <title>-tag, set to false for custom templating
  * @param boolean $includeTitle Show default <title>-tag, set to false for
  *                              custom templating
  * @return string The XHTML metatags
  */
 public function MetaTags($includeTitle = true)
 {
     $tags = "";
     if ($includeTitle === true || $includeTitle == 'true') {
         $tags .= "<title>" . Convert::raw2xml($this->MetaTitle ? $this->MetaTitle : $this->Title) . "</title>\n";
     }
     $tags .= "<meta name=\"generator\" content=\"SilverStripe - http://silverstripe.org\" />\n";
     $charset = ContentNegotiator::get_encoding();
     $tags .= "<meta http-equiv=\"Content-type\" content=\"text/html; charset={$charset}\" />\n";
     if ($this->MetaKeywords) {
         $tags .= "<meta name=\"keywords\" content=\"" . Convert::raw2att($this->MetaKeywords) . "\" />\n";
     }
     if ($this->MetaDescription) {
         $tags .= "<meta name=\"description\" content=\"" . Convert::raw2att($this->MetaDescription) . "\" />\n";
     }
     if ($this->ExtraMeta) {
         $tags .= $this->ExtraMeta . "\n";
     }
     if (Permission::check('CMS_ACCESS_CMSMain')) {
         $tags .= "<meta name='x-page-id' content='{$this->ID}' />\n";
     }
     $this->extend('MetaTags', $tags);
     return $tags;
 }
コード例 #3
0
 /**
  * Generate custom metatags to display on the DataObject Item page
  */
 public function MetaTags($includeTitle = true)
 {
     $tags = "";
     if ($includeTitle === true || $includeTitle == 'true') {
         $tags .= "<title>" . Convert::raw2xml($this->MetaTitle ? $this->MetaTitle : $this->Title) . "</title>\n";
     }
     $tags .= "<meta name=\"generator\" content=\"SilverStripe - http://silverstripe.org\" />\n";
     $charset = ContentNegotiator::get_encoding();
     $tags .= "<meta http-equiv=\"Content-type\" content=\"text/html; charset={$charset}\" />\n";
     if ($this->MetaDescription) {
         $tags .= "<meta name=\"description\" content=\"" . Convert::raw2att($this->MetaDescription) . "\" />\n";
     }
     $this->extend('MetaTags', $tags);
     return $tags;
 }
コード例 #4
0
ファイル: SiteTree.php プロジェクト: ramziammar/websites
 /**
  * Return the title, description, keywords and language metatags.
  * @param boolean|string $includeTitle Show default <title>-tag, set to false for custom templating
  *
  * @param boolean $includeTitle Show default <title>-tag, set to false for
  *                              custom templating
  * @return string The XHTML metatags
  */
 public function MetaTags($includeTitle = true)
 {
     $tags = "";
     if ($includeTitle === true || $includeTitle == 'true') {
         $tags .= "<title>" . Convert::raw2xml($this->MetaTitle ? $this->MetaTitle : $this->Title) . "</title>\n";
     }
     $tags .= "<meta name=\"generator\" http-equiv=\"generator\" content=\"SilverStripe 2.0 - http://www.silverstripe.com\" />\n";
     $charset = ContentNegotiator::get_encoding();
     $tags .= "<meta http-equiv=\"Content-type\" content=\"text/html; charset={$charset}\" />\n";
     if ($this->MetaKeywords) {
         $tags .= "<meta name=\"keywords\" http-equiv=\"keywords\" content=\"" . Convert::raw2att($this->MetaKeywords) . "\" />\n";
     }
     if ($this->MetaDescription) {
         $tags .= "<meta name=\"description\" http-equiv=\"description\" content=\"" . Convert::raw2att($this->MetaDescription) . "\" />\n";
     }
     if ($this->ExtraMeta) {
         $tags .= $this->ExtraMeta . "\n";
     }
     $tags .= "<meta http-equiv=\"Content-Language\" content=\"" . Translatable::current_lang() . "\"/>\n";
     return $tags;
 }
コード例 #5
0
ファイル: SiteTree.php プロジェクト: redema/silverstripe-cms
	/**
	 * Return the title, description, keywords and language metatags.
	 * 
	 * @todo Move <title> tag in separate getter for easier customization and more obvious usage
	 * 
	 * @param boolean|string $includeTitle Show default <title>-tag, set to false for custom templating
	 * @param boolean $includeTitle Show default <title>-tag, set to false for
	 *                              custom templating
	 * @return string The XHTML metatags
	 */
	public function MetaTags($includeTitle = true) {
		$tags = "";
		if($includeTitle === true || $includeTitle == 'true') {
			$tags .= "<title>" . Convert::raw2xml(($this->MetaTitle)
				? $this->MetaTitle
				: $this->Title) . "</title>\n";
		}

		$tags .= "<meta name=\"generator\" content=\"SilverStripe - http://silverstripe.org\" />\n";

		$charset = ContentNegotiator::get_encoding();
		$tags .= "<meta http-equiv=\"Content-type\" content=\"text/html; charset=$charset\" />\n";
		if($this->MetaKeywords) {
			$tags .= "<meta name=\"keywords\" content=\"" . Convert::raw2att($this->MetaKeywords) . "\" />\n";
		}
		if($this->MetaDescription) {
			$tags .= "<meta name=\"description\" content=\"" . Convert::raw2att($this->MetaDescription) . "\" />\n";
		}
		if($this->ExtraMeta) { 
			$tags .= $this->ExtraMeta . "\n";
		} 
		
		if(Permission::check('CMS_ACCESS_CMSMain') && in_array('CMSPreviewable', class_implements($this))) {
			$tags .= "<meta name=\"x-page-id\" content=\"{$this->ID}\" />\n";
			$tags .= "<meta name=\"x-cms-edit-link\" content=\"" . $this->CMSEditLink() . "\" />\n";
		}

		$this->extend('MetaTags', $tags);

		return $tags;
	}
コード例 #6
0
ファイル: SiteTree.php プロジェクト: neopba/silverstripe-book
	/**
	 * Return the title, description, keywords and language metatags.
	 * 
	 * @todo Move <title> tag in separate getter for easier customization and more obvious usage
	 * 
	 * @param boolean|string $includeTitle Show default <title>-tag, set to false for custom templating
	 * @param boolean $includeTitle Show default <title>-tag, set to false for
	 *                              custom templating
	 * @return string The XHTML metatags
	 */
	public function MetaTags($includeTitle = true) {
		$tags = "";
		if($includeTitle === true || $includeTitle == 'true') {
			$tags .= "<title>" . Convert::raw2xml(($this->MetaTitle)
				? $this->MetaTitle
				: $this->Title) . "</title>\n";
		}
		$version = new SapphireInfo();

		$tags .= "<meta name=\"generator\" http-equiv=\"generator\" content=\"SilverStripe ". $version->Version() ." - http://www.silverstripe.com\" />\n";

		$charset = ContentNegotiator::get_encoding();
		$tags .= "<meta http-equiv=\"Content-type\" content=\"text/html; charset=$charset\" />\n";
		if($this->MetaKeywords) {
			$tags .= "<meta name=\"keywords\" http-equiv=\"keywords\" content=\"" .
				Convert::raw2att($this->MetaKeywords) . "\" />\n";
		}
		if($this->MetaDescription) {
			$tags .= "<meta name=\"description\" http-equiv=\"description\" content=\"" .
				Convert::raw2att($this->MetaDescription) . "\" />\n";
		}
		if($this->ExtraMeta) { 
			$tags .= $this->ExtraMeta . "\n";
		} 
		$tags .= "<meta http-equiv=\"Content-Language\" content=\"". Translatable::current_lang() ."\"/>\n";
		
		// DEPRECATED 2.3: Use MetaTags
		$this->extend('updateMetaTags', $tags);
		
		$this->extend('MetaTags', $tags);

		return $tags;
	}
コード例 #7
0
ファイル: SiteTree.php プロジェクト: racontemoi/shibuichi
 /**
  * Return the title, description, keywords and language metatags.
  * 
  * @todo Move <title> tag in separate getter for easier customization and more obvious usage
  * 
  * @param boolean|string $includeTitle Show default <title>-tag, set to false for custom templating
  * @param boolean $includeTitle Show default <title>-tag, set to false for
  *                              custom templating
  * @return string The XHTML metatags
  */
 public function MetaTags($includeTitle = true)
 {
     $tags = "";
     if ($includeTitle === true || $includeTitle == 'true') {
         $tags .= "<title>" . Convert::raw2xml($this->MetaTitle ? $this->MetaTitle : $this->Title) . "</title>\n";
     }
     $version = new SapphireInfo();
     $tags .= "<meta name=\"generator\" http-equiv=\"generator\" content=\"SilverStripe - http://www.silverstripe.com\" />\n";
     $charset = ContentNegotiator::get_encoding();
     $tags .= "<meta http-equiv=\"Content-type\" content=\"text/html; charset={$charset}\" />\n";
     if ($this->MetaKeywords) {
         $tags .= "<meta name=\"keywords\" http-equiv=\"keywords\" content=\"" . Convert::raw2att($this->MetaKeywords) . "\" />\n";
     }
     if ($this->MetaDescription) {
         $tags .= "<meta name=\"description\" http-equiv=\"description\" content=\"" . Convert::raw2att($this->MetaDescription) . "\" />\n";
     }
     if ($this->ExtraMeta) {
         $tags .= $this->ExtraMeta . "\n";
     }
     // get the "long" lang name suitable for the HTTP content-language flag (with hyphens instead of underscores)
     $currentLang = $this->hasExtension('Translatable') ? Translatable::get_current_locale() : i18n::get_locale();
     $tags .= "<meta http-equiv=\"Content-Language\" content=\"" . i18n::convert_rfc1766($currentLang) . "\"/>\n";
     // DEPRECATED 2.3: Use MetaTags
     $this->extend('updateMetaTags', $tags);
     $this->extend('MetaTags', $tags);
     return $tags;
 }
 public function MetaTags($includeTitle = true)
 {
     $tags = "";
     if ($includeTitle === true || $includeTitle == 'true') {
         $tags .= "<title>" . Convert::raw2xml($this->MetaTitle ? $this->MetaTitle : $this->Title) . "</title>\n";
     }
     $charset = ContentNegotiator::get_encoding();
     $tags .= "<meta charset=\"utf-8\"> \n<meta http-equiv=\"X-UA-Compatible\" content=\"IE=edge,chrome=1\"> \n";
     if ($this->MetaKeywords) {
         $tags .= "<meta name=\"keywords\" content=\"" . Convert::raw2att($this->MetaKeywords) . "\" />\n";
     }
     if ($this->MetaDescription) {
         $tags .= "<meta name=\"description\" content=\"" . Convert::raw2att($this->MetaDescription) . "\" />\n";
     }
     $tags .= $this->ViewPortMeta();
     if ($this->ExtraMeta) {
         $tags .= $this->ExtraMeta . "\n";
     }
     $this->extend('MetaTags', $tags);
     return $tags;
 }