1
0

Added Disqus Widget to [programs/view] and [blog/view]

This commit is contained in:
Mike Schwörer 2014-09-06 15:39:39 +02:00
parent 6718ad0470
commit 9cffea9ec3
11 changed files with 236 additions and 3 deletions

View File

@ -682,6 +682,16 @@ ul.nav li.dropdown-append:hover > ul.dropdown-menu {
font-weight: 900;
}
/* disqus
-------------------------------------------------- */
.disqus_owner {
border-radius: 6px;
border: 1px solid #D7E0E2;
padding: 10px;
background-color: #ECF0F1;
}
/* blog/view
-------------------------------------------------- */

View File

@ -1,8 +1,5 @@
<?php
require_once('protected/lib/ArrayX.php');
use Yiinitializr\Helpers\ArrayX;
return [
'components' =>
[

View File

@ -0,0 +1,13 @@
.orig
.orig.*
.chg.*
.rej
.conflict~
.idea/
nbproject/
.DS_Store
!.gitignore
assets/
protected/runtime/
themes/classic/views/

View File

@ -0,0 +1,27 @@
Copyright (c) 2013, Anton Kucherov
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 {organization} 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 THE COPYRIGHT HOLDER 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.

View File

@ -0,0 +1,48 @@
YiiDisqusWidget
===============
This is sample widget wich can help you to add DISQUS
support in to your Yii site.
##Requirements
You must be registered on [DISQUS](http://disqus.com/)
##Installation
Copy `YiiDisqusWidget` folder in you `protected/extensions` folder.
##Usage
Just add this code on your page where you need to include DISQUS.
Simple usage:
```php
// DISQUS_SHORTNAME - You disqus_shortname from DISQUS.
$this->widget('ext.YiiDisqusWidget.YiiDisqusWidget',array('shortname'=>'DISQUS_SHORTNAME'));
```
You can change all off `disqus_` parameters in options array:
```javascript
var disqus_shortname;
var disqus_identifier;
var disqus_title;
var disqus_url;
```
Just add it in option array:
```php
$this->widget(
'ext.YiiDisqusWidget.YiiDisqusWidget',
array(
'shortname' => 'DISQUS_SHORTNAME',
'identifier' => 'DISQUS_IDENTIFIER',
'title' => 'DISQUS_TITLE',
'url' => 'DISQUS_URL',
'category_id' => 'DISQUS_CATEGORY_ID',
)
);
```
More information about DISQUS variables on [http://help.disqus.com/](http://help.disqus.com/customer/portal/articles/472098-javascript-configuration-variables#disqus_shortname)
##Resources
* [GitHub](https://github.com/DexterHD/YiiDisqusWidget)

View File

@ -0,0 +1,56 @@
<?php
/**
* Widget for insert Disqus code in to page.
*
* @author Anton Kucherov <idexter.ru@gmail.com>
* @link http://idexter.ru/
* @copyright 2013 idexter.ru
*/
/**
* YiiDisqusWidget
* @author Anton Kucherov <idexter.ru@gmail.com>
*/
class YiiDisqusWidget extends CWidget
{
/**
* @var string disqus_shortname
*/
public $shortname;
/**
* @var string disqus_identifier
*/
public $identifier;
/**
* @var string disqus_title
*/
public $title;
/**
* @var string disqus_url
*/
public $url;
/**
* @var string disqus_category_id
*/
public $category_id;
/**
* @throws CHttpException
*/
public function init()
{
parent::init();
if (empty($this->shortname)) {
throw new CHttpException(500, Yii::t('YiiDisqusWidget', 'Parameter "disqus_shortname" is not set'));
}
$params = array();
$params['shortname'] = $this->shortname;
$params['identifier'] = $this->identifier;
$params['title'] = $this->title;
$params['url'] = $this->url;
$params['category_id'] = $this->category_id;
$this->render('yiidisqus',$params);
}
}

View File

@ -0,0 +1,39 @@
<?php
/**
* Template for YiiDisqusWidget
*
* @author Anton Kucherov <idexter.ru@gmail.com>
* @link http://idexter.ru/
* @copyright 2013 idexter.ru
*/
?>
<div id="disqus_thread"></div>
<script type="text/javascript">
/* * * CONFIGURATION VARIABLES: EDIT BEFORE PASTING INTO YOUR WEBPAGE * * */
var disqus_shortname = '<?php echo $shortname; ?>'; // required: replace example with your forum shortname
<?php if($identifier!=''): ?>
var disqus_identifier = '<?php echo $identifier; ?>';
<?php endif; ?>
<?php if($title!=''): ?>
var disqus_title = '<?php echo $title; ?>';
<?php endif; ?>
<?php if($url!=''): ?>
var disqus_url = '<?php echo $url; ?>';
<?php endif; ?>
<?php if($category_id!=''): ?>
var disqus_category_id = '<?php echo $category_id; ?>';
<?php endif; ?>
/* * * DON'T EDIT BELOW THIS LINE * * */
(function() {
var dsq = document.createElement('script'); dsq.type = 'text/javascript'; dsq.async = true;
dsq.src = '//' + disqus_shortname + '.disqus.com/embed.js';
(document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq);
})();
</script>
<noscript>Please enable JavaScript to view the <a href="http://disqus.com/?ref_noscript">comments powered by Disqus.</a></noscript>
<a href="http://disqus.com" class="dsq-brlink">comments powered by <span class="logo-disqus">Disqus</span></a>

View File

@ -120,6 +120,13 @@ class BlogPost extends CActiveRecord
return '/blog/' . $this->ID . '/' . rawurlencode($name);
}
/**
* @return string
*/
public function getAbsoluteLink() {
return 'http://www.mikescher.de' . $this->getLink();
}
/**
* @param $search string[]
* @return array()

View File

@ -176,6 +176,13 @@ class Program extends CActiveRecord
return '/programs/view/' . rawurlencode($this->Name);
}
/**
* @return string
*/
public function getAbsoluteLink() {
return 'http://www.mikescher.de' . $this->getLink();
}
/**
* @return string
*/

View File

@ -30,4 +30,19 @@ $this->breadcrumbs = array(
</div>
</div>
<div class="disqus_owner">
<?php
$this->widget(
'ext.YiiDisqusWidget.YiiDisqusWidget',
[
'shortname' => 'mikescher-de',
'identifier' => 'blog/view/' + $model->ID,
'title' => $model->Title,
'url' => $model->getAbsoluteLink(),
'category_id' => '3253401', // = blog/view
]
);
?>
</div>
</div>

View File

@ -82,6 +82,20 @@ if (!$model->visible && Yii::app()->user->name != 'admin') {
]
);
?>
<div class="disqus_owner">
<?php
$this->widget(
'ext.YiiDisqusWidget.YiiDisqusWidget',
[
'shortname' => 'mikescher-de',
'identifier' => 'programs/view/' + $model->ID,
'title' => $model->Name,
'url' => $model->getAbsoluteLink(),
'category_id' => '3253400', // = programs/view
]
);
?>
</div>
</div>
<div class="span3">