Commit 9962251a by Crisu83

Added SEO to the demo app and added the Facebook and SEO extensions.

parent 95c23a99
Options +followSymLinks
IndexIgnore */*
<ifModule mod_rewrite.c>
RewriteEngine on
# if a directory or a file exists, use it directly
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# otherwise forward it to index.php
RewriteRule ^(.*)$ index.php
</ifModule>
\ No newline at end of file
...@@ -32,6 +32,12 @@ return array( ...@@ -32,6 +32,12 @@ return array(
'errorHandler'=>array( 'errorHandler'=>array(
'errorAction'=>'site/error', 'errorAction'=>'site/error',
), ),
'fb'=>array(
'class'=>'ext.facebook.components.FacebookConnect',
'appID'=>'106265262835735',
'appSecret'=>'941d6e0fa554b725ec258311e4ddc4b6',
'appNamespace'=>'yii-bootstrap',
),
'log'=>array( 'log'=>array(
'class'=>'CLogRouter', 'class'=>'CLogRouter',
'routes'=>array( 'routes'=>array(
...@@ -47,14 +53,21 @@ return array( ...@@ -47,14 +53,21 @@ return array(
*/ */
), ),
), ),
'urlManager'=>array(
'showScriptName'=>false,
'urlFormat'=>'path',
'urlSuffix'=>'.html',
'rules'=>array(
'demo'=>'site/index',
'setup'=>'site/setup',
),
),
'user'=>array( 'user'=>array(
'allowAutoLogin'=>true, 'allowAutoLogin'=>true,
), ),
), ),
// application-level parameters that can be accessed // Application-level parameters
// using Yii::app()->params['paramName']
'params'=>array( 'params'=>array(
'adminEmail'=>'webmaster@example.com',
), ),
); );
\ No newline at end of file
...@@ -3,7 +3,19 @@ ...@@ -3,7 +3,19 @@
class SiteController extends Controller class SiteController extends Controller
{ {
/** /**
* Declares the behaviors.
* @return array the behaviors
*/
public function behaviors()
{
return array(
'seo'=>'ext.seo.components.SeoControllerBehavior',
);
}
/**
* Declares class-based actions. * Declares class-based actions.
* @return array the actions
*/ */
public function actions() public function actions()
{ {
......
Copyright (c) 2010, Christoffer Niska
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
* Neither the name of the Christoffer Niska nor the
names of its contributors may be used to endorse or promote products
derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
\ No newline at end of file
<?php
/**
* FacebookConnect class file.
* @author Christoffer Niska <ChristofferNiska@gmail.com>
* @copyright Copyright &copy; Christoffer Niska 2011-
* @license http://www.opensource.org/licenses/bsd-license.php New BSD License
* @package facebook.components
*/
/**
* Facebook connection application component.
*/
require(dirname(__FILE__) . '/../lib/facebook/src/facebook.php'); // Yii::import() will not work in this case
class FacebookConnect extends CApplicationComponent
{
/**
* @var string Facebook application id.
*/
public $appID;
/**
* @var string Facebook application secret.
*/
public $appSecret;
/**
* @var string the application namespace.
*/
public $appNamespace;
/**
* @var boolean whether file uploads are enabled.
*/
public $fileUpload;
protected $_facebook;
/**
* Initializes this component.
*/
public function init()
{
$config = array(
'appId' => $this->appID,
'secret' => $this->appSecret
);
if ($this->fileUpload !== null)
$config['fileUpload'] = $this->fileUpload;
$this->_facebook = new Facebook($config);
}
/**
* Registers an Open Graph action with Facebook.
* @param string $action the action to register.
* @param array $params the query parameters.
*/
public function registerAction($action, $params=array())
{
$this->api('me/'.$this->appNamespace.':'.$action, $params);
}
/**
* Calls the Facebook API.
* @param string $query the query to send.
* @param array $params the query paramters.
* @return array the response.
*/
public function api($query, $params=array())
{
$data = array();
if ($params !== array())
$query .= '?'.http_build_query($params);
try
{
$data = $this->_facebook->api('/'.$query);
}
catch (FacebookApiException $e)
{
}
return $data;
}
/**
* Returns the locale based on the application language.
* @return string the locale.
*/
public function getLocale()
{
$language = Yii::app()->language;
if ($language !== null)
{
$pieces = explode('_', $language);
if (count($pieces) === 2)
return $pieces[0].'_'.strtoupper($pieces[1]);
}
return 'en_US';
}
/**
* Returns the Facebook application instance.
* @return Facebook the instance
*/
public function getFacebook()
{
return $this->_facebook;
}
}
Facebook PHP SDK (v.3.0.0)
==========================
The new PHP SDK (v3.0.0) is a major upgrade to the older one (v2.2.x):
- Uses OAuth authentication flows instead of our legacy authentication flow
- Consists of two classes. The first (class BaseFacebook) maintains the core of the upgrade, and the second one (class Facebook) is a small subclass that uses PHP sessions to store the user id and access token.
If you’re currently using the PHP SDK (v2.2.x) for authentication, you will recall that the login code looked like this:
$facebook = new Facebook(…);
$session = $facebook->getSession();
if ($session) {
// proceed knowing you have a valid user session
} else {
// proceed knowing you require user login and/or authentication
}
The login code is now:
$facebook = new Facebook(…);
$user = $facebook->getUser();
if ($user) {
// proceed knowing you have a logged in user who's authenticated
} else {
// proceed knowing you require user login and/or authentication
}
<?php
/**
* Copyright 2011 Facebook, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License. You may obtain
* a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*/
require '../src/facebook.php';
// Create our Application instance (replace this with your appId and secret).
$facebook = new Facebook(array(
'appId' => '344617158898614',
'secret' => '6dc8ac871858b34798bc2488200e503d',
));
// Get User ID
$user = $facebook->getUser();
// We may or may not have this data based on whether the user is logged in.
//
// If we have a $user id here, it means we know the user is logged into
// Facebook, but we don't know if the access token is valid. An access
// token is invalid if the user logged out of Facebook.
if ($user) {
try {
// Proceed knowing you have a logged in user who's authenticated.
$user_profile = $facebook->api('/me');
} catch (FacebookApiException $e) {
error_log($e);
$user = null;
}
}
// Login or logout url will be needed depending on current user state.
if ($user) {
$logoutUrl = $facebook->getLogoutUrl();
} else {
$loginUrl = $facebook->getLoginUrl();
}
// This call will always work since we are fetching public data.
$naitik = $facebook->api('/naitik');
?>
<!doctype html>
<html xmlns:fb="http://www.facebook.com/2008/fbml">
<head>
<title>php-sdk</title>
<style>
body {
font-family: 'Lucida Grande', Verdana, Arial, sans-serif;
}
h1 a {
text-decoration: none;
color: #3b5998;
}
h1 a:hover {
text-decoration: underline;
}
</style>
</head>
<body>
<h1>php-sdk</h1>
<?php if ($user): ?>
<a href="<?php echo $logoutUrl; ?>">Logout</a>
<?php else: ?>
<div>
Login using OAuth 2.0 handled by the PHP SDK:
<a href="<?php echo $loginUrl; ?>">Login with Facebook</a>
</div>
<?php endif ?>
<h3>PHP Session</h3>
<pre><?php print_r($_SESSION); ?></pre>
<?php if ($user): ?>
<h3>You</h3>
<img src="https://graph.facebook.com/<?php echo $user; ?>/picture">
<h3>Your User Object (/me)</h3>
<pre><?php print_r($user_profile); ?></pre>
<?php else: ?>
<strong><em>You are not Connected.</em></strong>
<?php endif ?>
<h3>Public profile of Naitik</h3>
<img src="https://graph.facebook.com/naitik/picture">
<?php echo $naitik['name']; ?>
</body>
</html>
<?php
require '../src/facebook.php';
$facebook = new Facebook(array(
'appId' => '344617158898614',
'secret' => '6dc8ac871858b34798bc2488200e503d',
));
// See if there is a user from a cookie
$user = $facebook->getUser();
if ($user) {
try {
// Proceed knowing you have a logged in user who's authenticated.
$user_profile = $facebook->api('/me');
} catch (FacebookApiException $e) {
echo '<pre>'.htmlspecialchars(print_r($e, true)).'</pre>';
$user = null;
}
}
?>
<!DOCTYPE html>
<html xmlns:fb="http://www.facebook.com/2008/fbml">
<body>
<?php if ($user) { ?>
Your user profile is
<pre>
<?php print htmlspecialchars(print_r($user_profile, true)) ?>
</pre>
<?php } else { ?>
<fb:login-button></fb:login-button>
<?php } ?>
<div id="fb-root"></div>
<script>
window.fbAsyncInit = function() {
FB.init({
appId: '<?php echo $facebook->getAppID() ?>',
cookie: true,
xfbml: true,
oauth: true
});
FB.Event.subscribe('auth.login', function(response) {
window.location.reload();
});
FB.Event.subscribe('auth.logout', function(response) {
window.location.reload();
});
};
(function() {
var e = document.createElement('script'); e.async = true;
e.src = document.location.protocol +
'//connect.facebook.net/en_US/all.js';
document.getElementById('fb-root').appendChild(e);
}());
</script>
</body>
</html>
We have created a new repository for this project: https://github.com/facebook/facebook-php-sdk. Please update anything you have pointing at this repostory to this location before April 1, 2012.
Facebook PHP SDK (v.3.1.1)
==========================
The [Facebook Platform](http://developers.facebook.com/) is
a set of APIs that make your app more social
This repository contains the open source PHP SDK that allows you to access Facebook Platform from your PHP app. Except as otherwise noted, the Facebook PHP SDK
is licensed under the Apache Licence, Version 2.0
(http://www.apache.org/licenses/LICENSE-2.0.html)
Usage
-----
The [examples][examples] are a good place to start. The minimal you'll need to
have is:
require 'facebook-php-sdk/src/facebook.php';
$facebook = new Facebook(array(
'appId' => 'YOUR_APP_ID',
'secret' => 'YOUR_APP_SECRET',
));
// Get User ID
$user = $facebook->getUser();
To make [API][API] calls:
if ($user) {
try {
// Proceed knowing you have a logged in user who's authenticated.
$user_profile = $facebook->api('/me');
} catch (FacebookApiException $e) {
error_log($e);
$user = null;
}
}
Login or logout url will be needed depending on current user state.
if ($user) {
$logoutUrl = $facebook->getLogoutUrl();
} else {
$loginUrl = $facebook->getLoginUrl();
}
[examples]: http://github.com/facebook/facebook-php-sdk/blob/master/examples/example.php
[API]: http://developers.facebook.com/docs/api
Tests
-----
In order to keep us nimble and allow us to bring you new functionality, without
compromising on stability, we have ensured full test coverage of the SDK.
We are including this in the open source repository to assure you of our
commitment to quality, but also with the hopes that you will contribute back to
help keep it stable. The easiest way to do so is to file bugs and include a
test case.
The tests can be executed by using this command from the base directory:
phpunit --stderr --bootstrap tests/bootstrap.php tests/tests.php
Contributing
===========
For us to accept contributions you will have to first have signed the [Contributor License Agreement](https://developers.facebook.com/opensource/cla).
When commiting, keep all lines to less than 80 characters, and try to follow the existing style.
Before creating a pull request, squash your commits into a single commit.
Add the comments where needed, and provide ample explanation in the commit message.
Report Issues/Bugs
===============
[Bugs](https://developers.facebook.com/bugs)
[Questions](http://facebook.stackoverflow.com)
<?php
/**
* Copyright 2011 Facebook, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License. You may obtain
* a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*/
require_once "base_facebook.php";
/**
* Extends the BaseFacebook class with the intent of using
* PHP sessions to store user ids and access tokens.
*/
class Facebook extends BaseFacebook
{
/**
* Identical to the parent constructor, except that
* we start a PHP session to store the user ID and
* access token if during the course of execution
* we discover them.
*
* @param Array $config the application configuration.
* @see BaseFacebook::__construct in facebook.php
*/
public function __construct($config) {
if (!session_id()) {
session_start();
}
parent::__construct($config);
}
protected static $kSupportedKeys =
array('state', 'code', 'access_token', 'user_id');
/**
* Provides the implementations of the inherited abstract
* methods. The implementation uses PHP sessions to maintain
* a store for authorization codes, user ids, CSRF states, and
* access tokens.
*/
protected function setPersistentData($key, $value) {
if (!in_array($key, self::$kSupportedKeys)) {
self::errorLog('Unsupported key passed to setPersistentData.');
return;
}
$session_var_name = $this->constructSessionVariableName($key);
$_SESSION[$session_var_name] = $value;
}
protected function getPersistentData($key, $default = false) {
if (!in_array($key, self::$kSupportedKeys)) {
self::errorLog('Unsupported key passed to getPersistentData.');
return $default;
}
$session_var_name = $this->constructSessionVariableName($key);
return isset($_SESSION[$session_var_name]) ?
$_SESSION[$session_var_name] : $default;
}
protected function clearPersistentData($key) {
if (!in_array($key, self::$kSupportedKeys)) {
self::errorLog('Unsupported key passed to clearPersistentData.');
return;
}
$session_var_name = $this->constructSessionVariableName($key);
unset($_SESSION[$session_var_name]);
}
protected function clearAllPersistentData() {
foreach (self::$kSupportedKeys as $key) {
$this->clearPersistentData($key);
}
}
protected function constructSessionVariableName($key) {
return implode('_', array('fb',
$this->getAppId(),
$key));
}
}
-----BEGIN CERTIFICATE-----
MIIFgjCCBGqgAwIBAgIQDKKbZcnESGaLDuEaVk6fQjANBgkqhkiG9w0BAQUFADBm
MQswCQYDVQQGEwJVUzEVMBMGA1UEChMMRGlnaUNlcnQgSW5jMRkwFwYDVQQLExB3
d3cuZGlnaWNlcnQuY29tMSUwIwYDVQQDExxEaWdpQ2VydCBIaWdoIEFzc3VyYW5j
ZSBDQS0zMB4XDTEwMDExMzAwMDAwMFoXDTEzMDQxMTIzNTk1OVowaDELMAkGA1UE
BhMCVVMxEzARBgNVBAgTCkNhbGlmb3JuaWExEjAQBgNVBAcTCVBhbG8gQWx0bzEX
MBUGA1UEChMORmFjZWJvb2ssIEluYy4xFzAVBgNVBAMUDiouZmFjZWJvb2suY29t
MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQC9rzj7QIuLM3sdHu1HcI1VcR3g
b5FExKNV646agxSle1aQ/sJev1mh/u91ynwqd2BQmM0brZ1Hc3QrfYyAaiGGgEkp
xbhezyfeYhAyO0TKAYxPnm2cTjB5HICzk6xEIwFbA7SBJ2fSyW1CFhYZyo3tIB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LmNybDArBgNVHRAEJDAigA8xOTk5MDUyNTE2MDk0
MFqBDzIwMTkwNTI1MTYwOTQwWjALBgNVHQ8EBAMCAQYwHwYDVR0jBBgwFoAU8Bdi
E1U9s/8KAGv7UISX8+1i0BowHQYDVR0OBBYEFPAXYhNVPbP/CgBr+1CEl/PtYtAa
MAwGA1UdEwQFMAMBAf8wGQYJKoZIhvZ9B0EABAwwChsEVjQuMAMCBJAwDQYJKoZI
hvcNAQEFBQADgYEAkNwwAvpkdMKnCqV8IY00F6j7Rw7/JXyNEwr75Ji174z4xRAN
95K+8cPV1ZVqBLssziY2ZcgxxufuP+NXdYR6Ee9GTxj005i7qIcyunL2POI9n9cd
2cNgQ4xYDiKWL2KjLB+6rQXvqzJ4h6BUcxm1XAX5Uj5tLUUL9wqT6u0G+bI=
-----END CERTIFICATE-----
<?php
$base = realpath(dirname(__FILE__) . '/..');
require "$base/src/base_facebook.php";
require "$base/src/facebook.php";
Copyright (c) 2010, Christoffer Niska
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
* Neither the name of the Christoffer Niska nor the
names of its contributors may be used to endorse or promote products
derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
\ No newline at end of file
<?php
/**
* SeoControllerBehavior class file.
* @author Christoffer Niska <ChristofferNiska@gmail.com>
* @copyright Copyright &copy; Christoffer Niska 2011-
* @license http://www.opensource.org/licenses/bsd-license.php New BSD License
* @package seo.components
*/
class SeoControllerBehavior extends CBehavior
{
/**
* @property string the page meta title.
*/
public $metaTitle;
/**
* @property string the page meta description.
*/
public $metaDescription;
/**
* @property string the page meta keywords.
*/
public $metaKeywords;
/**
* @property array the page meta properties.
*/
public $metaProperties = array();
/**
* @property string the canonical URL.
*/
public $canonical;
/**
* Adds a meta property to the current page.
* @param string $name the property name
* @param string $content the property content
*/
public function addMetaProperty($name, $content)
{
$this->metaProperties[$name] = $content;
}
}
<?php
/**
* SeoFilter class file.
* @author Christoffer Niska <ChristofferNiska@gmail.com>
* @copyright Copyright &copy; Christoffer Niska 2011-
* @license http://www.opensource.org/licenses/bsd-license.php New BSD License
* @package seo.components
*/
class SeoFilter extends CFilter
{
/**
* Performs the pre-action filtering.
* @param CFilterChain $filterChain the filter chain that the filter is on.
* @return boolean whether the filtering process should continue and the action
* should be executed.
*/
protected function preFilter($filterChain)
{
$controller = $filterChain->controller;
if (isset($_GET['id']) && method_exists($controller, 'loadModel'))
{
$model = $controller->loadModel($_GET['id']);
$url = $model->getUrl();
if (strpos(Yii::app()->request->getRequestUri(), $url) === false)
$controller->redirect($url, true, 301);
}
return parent::preFilter($filterChain);
}
}
<?php
/**
* SeoRecordBehavior class file.
* @author Christoffer Niska <ChristofferNiska@gmail.com>
* @copyright Copyright &copy; Christoffer Niska 2011-
* @license http://www.opensource.org/licenses/bsd-license.php New BSD License
* @package seo.components
*/
class SeoRecordBehavior extends CActiveRecordBehavior
{
/**
* @property string the route used for SEO.
*/
public $route;
/**
* @property array GET parameters used for SEO.
*/
public $params = array();
/**
* Returns the URL for this model.
* @param array $params additional GET parameters (name=>value)
* @return string the URL
*/
public function getUrl($params=array())
{
return Yii::app()->createUrl($this->route, CMap::mergeArray($params, $this->params));
}
/**
* Returns the absolute URL for this model.
* @param array $params additional GET parameters (name=>value)
* @return string the URL
*/
public function getAbsoluteUrl($params=array())
{
return Yii::app()->createAbsoluteUrl($this->route, CMap::mergeArray($params, $this->params));
}
}
<?php
/**
* SeoHead class file.
* @author Christoffer Niska <ChristofferNiska@gmail.com>
* @copyright Copyright &copy; Christoffer Niska 2011-
* @license http://www.opensource.org/licenses/bsd-license.php New BSD License
* @package seo.widgets
*/
class SeoHead extends CWidget
{
/**
* @property array the configuration for the title.
* Defaults to <code>array('class'=>'ext.seo.widgets.SeoTitle')</code>.
* @see enableTitle
*/
public $title = array('class'=>'ext.seo.widgets.SeoTitle');
/**
* @property boolean whether to enable the title.
*/
public $enableTitle = true;
/**
* @property array the page http-equivs.
*/
public $httpEquivs = array();
/**
* @property string the page meta title.
*/
public $defaultTitle;
/**
* @property string the page meta description.
*/
public $defaultDescription;
/**
* @property string the page meta keywords.
*/
public $defaultKeywords;
/**
* @property array the page meta properties.
*/
public $defaultProperties = array();
protected $_title;
protected $_description;
protected $_keywords;
protected $_properties = array();
protected $_canonical;
/**
* Initializes the widget.
*/
public function init()
{
$behavior = $this->controller->asa('seo');
if ($behavior !== null && $behavior->metaTitle !== null)
$this->_title = $behavior->metaTitle;
else if ($this->defaultDescription !== null)
$this->_title = $this->defaultTitle;
if ($behavior !== null && $behavior->metaDescription !== null)
$this->_description = $behavior->metaDescription;
else if ($this->defaultDescription !== null)
$this->_description = $this->defaultDescription;
if ($behavior !== null && $behavior->metaKeywords !== null)
$this->_keywords = $behavior->metaKeywords;
else if ($this->defaultKeywords !== null)
$this->_keywords = $this->defaultKeywords;
if ($behavior !== null)
$this->_properties = CMap::mergeArray($behavior->metaProperties, $this->defaultProperties);
else
$this->_properties = $this->defaultProperties;
if ($behavior !== null && $behavior->canonical !== null)
$this->_canonical = $behavior->canonical;
}
/**
* Runs the widget.
*/
public function run()
{
$this->renderContent();
}
/**
* Renders the widget content.
*/
protected function renderContent()
{
$this->renderTitle().PHP_EOL;
foreach ($this->httpEquivs as $name => $content)
echo '<meta http-equiv="'.$name.'" content="'.$content.'" />'.PHP_EOL;
if ($this->_description !== null)
echo CHtml::metaTag($this->_title, 'title').PHP_EOL;
if ($this->_description !== null)
echo CHtml::metaTag($this->_description, 'description').PHP_EOL;
if ($this->_keywords !== null)
echo CHtml::metaTag($this->_keywords, 'keywords').PHP_EOL;
foreach ($this->_properties as $name => $content)
echo '<meta property="'.$name.'" content="'.$content.'" />'.PHP_EOL; // we can't use Yii's method for this.
if ($this->_canonical !== null)
$this->renderCanonical();
}
/**
* Renders the page title.
*/
protected function renderTitle()
{
if (!$this->enableTitle)
return;
$title = array();
$class = 'ext.seo.widgets.SeoTitle';
if (is_string($this->title))
$class = $this->title;
else if (is_array($this->title))
{
$title = $this->title;
if (isset($title['class']))
{
$class = $title['class'];
unset($title['class']);
}
}
$this->widget($class, $title);
}
/**
* Renders the canonical link tag.
*/
protected function renderCanonical()
{
$request = Yii::app()->getRequest();
$url = $request->getUrl();
// Make sure that we do not create a recursive canonical redirect.
if ($this->_canonical !== $url && $this->_canonical !== $request->getHostInfo().$url)
echo '<link rel="canonical" href="'.$this->_canonical.'" />'.PHP_EOL;
}
}
<?php
/**
* SeoTitle class file.
* @author Christoffer Niska <ChristofferNiska@gmail.com>
* @copyright Copyright &copy; Christoffer Niska 2011-
* @license http://www.opensource.org/licenses/bsd-license.php New BSD License
* @package seo.widgets
* @since 0.9.1
*/
class SeoTitle extends CWidget
{
/**
* @property string the page title separator.
*/
public $separator = ' - ';
/**
* Runs the widget.
*/
public function run()
{
$parts = array();
$controller = $this->getController();
$pageTitle = $controller->pageTitle;
// We do not want to use the default page title generated by Yii
// because it is not very SEO friendly.
if ($this->isDefaultPageTitle($pageTitle, $controller))
$pageTitle = null;
if ($pageTitle !== null)
{
if (!is_array($pageTitle))
$pageTitle = array($pageTitle);
$parts = $pageTitle;
}
else
{
if (($breadcrumbs = $controller->breadcrumbs) !== array())
{
foreach ($breadcrumbs as $key => $value)
$parts[] = is_string($key) || is_array($value) ? $key : $value;
$parts = array_reverse($parts);
}
else
{
$name = ucfirst($controller->getId());
$action = $controller->getAction();
$module = $controller->getModule();
if ($action !== null && strcasecmp($action->getId(), $controller->defaultAction))
$parts[] = ucfirst($action->getId()).' '.$name;
else if ($module !== null && strcasecmp($name, $module->defaultController))
$parts[] = $name;
if ($module !== null)
{
$pieces = explode('/', $module->getId());
foreach (array_reverse($pieces) as $piece)
$parts[] = ucfirst($piece);
}
}
$parts[] = Yii::app()->name;
}
echo '<title>'.implode($parts, $this->separator).'</title>';
}
/**
* Returns whether or not the given title is the default page title.
* @param mixed $pageTitle the page title
* @param CController $controller the controller
* @return bool
*/
protected function isDefaultPageTitle($pageTitle, $controller)
{
$name = ucfirst(basename($controller->getId()));
return is_string($pageTitle)
&& ($pageTitle === Yii::app()->name.' - '.ucfirst($controller->getAction()->getId()).' '.$name
|| $pageTitle === Yii::app()->name.' - '.$name);
}
}
<!doctype html> <!doctype html>
<html> <html>
<head> <head>
<title><?php echo CHtml::encode($this->pageTitle); ?></title> <?php Yii::app()->controller->widget('ext.seo.widgets.SeoHead', array(
'defaultDescription'=>'Yii-Bootstrap is an extension for Yii that focuses on server-side that allows you to easily use Bootstrap in your Yii applications.',
'httpEquivs'=>array('Content-Type'=>'text/html; charset=utf-8', 'Content-Language'=>'en-US'),
)); ?>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="language" content="en" /> <meta name="language" content="en" />
<!--[if lt IE 9]> <!--[if lt IE 9]>
<script type="text/javascript" src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script> <script type="text/javascript" src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
<![endif]--> <![endif]-->
<?php Yii::app()->bootstrap->registerCss(); ?>
<?php Yii::app()->bootstrap->registerResponsiveCss(); ?>
<link rel="stylesheet/less" type="text/css" href="<?php echo Yii::app()->request->baseUrl; ?>/less/styles.less" /> <link rel="stylesheet/less" type="text/css" href="<?php echo Yii::app()->request->baseUrl; ?>/less/styles.less" />
<script type="text/javascript" src="<?php echo Yii::app()->request->baseUrl; ?>/js/less-1.2.1.min.js"></script> <script type="text/javascript" src="<?php echo Yii::app()->request->baseUrl; ?>/js/less-1.2.1.min.js"></script>
<script type="text/javascript"> <script type="text/javascript">
...@@ -104,9 +105,11 @@ ...@@ -104,9 +105,11 @@
<footer> <footer>
<p class="powered"> <p class="powered">
Powered by <?php echo CHtml::link('Yii 1.1.9', 'http://www.yiiframework.com', array('target'=>'_blank')); ?> // Powered by <?php echo CHtml::link('Yii PHP framework 1.1.9', 'http://www.yiiframework.com', array('target'=>'_blank')); ?> //
<?php echo CHtml::link('jQuery 1.7.1', 'http://www.jquery.com', array('target'=>'_blank')); ?> // <?php echo CHtml::link('jQuery 1.7.1', 'http://www.jquery.com', array('target'=>'_blank')); ?> //
<?php echo CHtml::link('Yii-Bootstrap 0.9.8', 'http://www.yiiframework.com/extension/bootstrap', array('target'=>'_blank')); ?> // <?php echo CHtml::link('Yii-Bootstrap 0.9.8', 'http://www.yiiframework.com/extension/bootstrap', array('target'=>'_blank')); ?> //
<?php echo CHtml::link('Yii-SEO 0.9.3', 'http://www.yiiframework.com/extension/seo', array('target'=>'_blank')); ?> //
<?php echo CHtml::link('Yii-Facebook 0.9.1', '#', array('rel'=>'tooltip', 'title'=>'Link available soon')); ?> //
<?php echo CHtml::link('Bootstrap 2', 'http://twitter.github.com/bootstrap', array('target'=>'_blank')); ?> // <?php echo CHtml::link('Bootstrap 2', 'http://twitter.github.com/bootstrap', array('target'=>'_blank')); ?> //
<?php echo CHtml::link('LESS 1.2.1', 'http://www.lesscss.org', array('target'=>'_blank')); ?> <?php echo CHtml::link('LESS 1.2.1', 'http://www.lesscss.org', array('target'=>'_blank')); ?>
</p> </p>
......
<?php $this->pageTitle=Yii::app()->name; ?> <?php
$this->pageTitle = array('Demo', Yii::app()->name);
$this->addMetaProperty('og:title', Yii::app()->name);
$this->addMetaProperty('og:type', 'website');
$this->addMetaProperty('og:url', Yii::app()->request->requestUri);
$this->addMetaProperty('og:site_name', Yii::app()->name);
$this->addMetaProperty('og:locale',Yii::app()->fb->locale);
$this->addMetaProperty('fb:app_id', Yii::app()->fb->appID);
?>
<section id="bootAlert"> <section id="bootAlert">
......
<?php $this->pageTitle = Yii::app()->name.' - Setup'; ?> <?php
$this->pageTitle = array('Setup', Yii::app()->name);
$this->addMetaProperty('og:title', 'Setup - '.Yii::app()->name);
$this->addMetaProperty('og:type', 'website');
$this->addMetaProperty('og:url', Yii::app()->request->requestUri);
$this->addMetaProperty('og:site_name', Yii::app()->name);
$this->addMetaProperty('og:locale',Yii::app()->fb->locale);
$this->addMetaProperty('fb:app_id', Yii::app()->fb->appID);
?>
<section id="setup"> <section id="setup">
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment