1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47
| class AjaxController extends Zend_Controller_Action {
protected $_db_home;
/* Globale à toute les actions */
public function init() {
/* récupération de données */
$this->_db_home = Zend_Registry::get('db_home');
/* Activation AJAX */
$ajaxContext = $this->_helper->getHelper('AjaxContext');
$ajaxContext->addActionContext('topthemes', 'html')
->addActionContext('lastthemes', 'html')
->addActionContext('seekgame', 'html')
->initContext();
}
/***************************/
/* Récupère les top thèmes */
public function topthemesAction() {
$top_themes = Egame_Cache_Init::get('top_themes');
$this->view->cached = (boolean) $top_themes;
if(!$top_themes) {
$table = new Db_Theme(array('db'=>$this->_db_home));
$result = $table->seekTopThemes(6);
$top_themes = array();
foreach($result as $theme) {
$theme['note'] = ceil($theme['popularite']/$theme['nbnote']);
$top_themes[] = $theme;
}
Egame_Cache_Init::set($top_themes, 'top_themes');
}
$this->view->top_themes = $top_themes;
}
} |