Skip to content

Commit

Permalink
managing assets rewrite
Browse files Browse the repository at this point in the history
  • Loading branch information
samdark committed Feb 18, 2013
1 parent 2a3d551 commit c83b653
Show file tree
Hide file tree
Showing 9 changed files with 41 additions and 38 deletions.
Expand Up @@ -11,7 +11,7 @@ class QuoteController extends Controller

private function getRandomQuote()
{
return $this->quotes[array_rand($this->quotes, 1)];
return $this->quotes[array_rand($this->quotes)];
}

function actionIndex()
Expand Down

This file was deleted.

This file was deleted.

@@ -1,14 +1,14 @@
<?php
class EFacebookEvents extends CWidget
class EYiiCookbook extends CWidget
{
public $keyword;
public $object;

private $loadingImageUrl;
protected $url = "https://graph.facebook.com/search?q=%s&type=event&callback=?";
protected $url = "http://yiicookbook.org/api/%s?callback=?";

protected function getUrl()
{
return sprintf($this->url, urlencode($this->keyword));
return sprintf($this->url, urlencode($this->object));
}

public function init()
Expand All @@ -21,15 +21,15 @@ public function init()
// Publishing and registering JavaScript file
$cs->registerScriptFile(
Yii::app()->assetManager->publish(
$assetsDir.'/facebook_events.js'
$assetsDir.'/yiicookbook.js'
),
CClientScript::POS_END
);

// Publishing and registering CSS file
$cs->registerCssFile(
Yii::app()->assetManager->publish(
$assetsDir.'/facebook_events.css'
$assetsDir.'/yiicookbook.css'
)
);

Expand All @@ -45,7 +45,7 @@ public function run()
$this->render("body", array(
'url' => $this->getUrl(),
'loadingImageUrl' => $this->loadingImageUrl,
'keyword' => $this->keyword,
'object' => $this->object,
));
}
}
@@ -1,14 +1,14 @@
.facebook-events {
.results {
padding: 10px;
width: 400px;
float: left;
}

.facebook-events ul {
.results ul {
padding: 0;
}

.facebook-events li {
.results li {
list-style: none;
border: 1px solid #ccc;
padding: 10px;
Expand Down
@@ -0,0 +1,20 @@
jQuery(function($){
$(".results").each(function(){
var url = $(this).data("url");
var container = $(".data", this);

$.getJSON(url,function(json){
var html = "<ul>";
$.each(json,function(){
html += "<li>";
html += '<a href="'+this.url+'">'+this.name+'</a>';
if(this.author) {
html += '<br />by '+this.author;
}
html += "</li>";
});
html += "</ul>";
container.html(html);
});
});
});
@@ -0,0 +1,6 @@
<div class="results" data-url="<?php echo $url?>">
<h2><?php echo $object?>:</h2>
<div class="data">
<?php echo CHtml::image($loadingImageUrl)?>
</div>
</div>
8 changes: 4 additions & 4 deletions 03/managing_assets/protected/views/site/index.php
Expand Up @@ -15,10 +15,10 @@
Feel free to ask in the <a href="http://www.yiiframework.com/forum/">forum</a>,
should you have any questions.</p>

<?php $this->widget("ext.facebook_events.EFacebookEvents", array(
'keyword' => 'php',
<?php $this->widget("ext.yiicookbook.EYiiCookbook", array(
'object' => 'book',
))?>

<?php $this->widget("ext.facebook_events.EFacebookEvents", array(
'keyword' => 'jquery',
<?php $this->widget("ext.yiicookbook.EYiiCookbook", array(
'object' => 'website',
))?>

0 comments on commit c83b653

Please sign in to comment.