This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public function view($id = null) { | |
$this->Noticia->id = $id; | |
if (!$this->Noticia->exists()) { | |
throw new NotFoundException(__('Invalid noticia')); | |
} | |
$this->set('noticia', $this->Noticia->read(null, $id)); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public function view($id = null) { | |
$this->Noticia->id = $id; | |
if (!$this->Noticia->exists()) { | |
throw new NotFoundException(__('Invalid noticia')); | |
} | |
$this->set('noticia', $this->Noticia->read(null, $id)); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Helper to generate thumbnail images dynamically by saving them to the cache. | |
* Alternative to phpthumb. | |
* | |
* Esta classe foi adaptada para o uso da classe VEROT para manipulação das imagens (por Gabriel Lau) | |
* | |
* Inspired in http://net.tutsplus.com/tutorials/php/image-resizing-made-easy-with-php/ | |
* | |
* @author Emerson Soares ([email protected]) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$highlightCategories = array(1,2,3,4,5,6,7,8,9); // IDs das Categorias selecionadas | |
// Estrutura principal da consulta | |
$sql = ""; | |
$sqlBody = " (SELECT `Noticia`.`id` as `Noticia.id`, `Noticia`.`categoria_id` as `Noticia.categoria_id`, `Noticia`.`titulo` as `Noticia.titulo`, `Noticiascategoria`.`id` as `Noticiascategoria.id`, `Noticiascategoria`.`titulo` as `Noticiascategoria.titulo`, `Noticiascategoria`.`slug` as `Noticiascategoria.slug` FROM `noticias` AS `Noticia` LEFT JOIN `noticiascategorias` AS `Noticiascategoria` ON (`Noticia`.`categoria_id` = `Noticiascategoria`.`id`) WHERE `Noticia`.`status` = '1' AND "; | |
// Gera a consulta para cada categoria | |
foreach($highlightCategories as $categoria){ | |
$sql .= $sqlBody." `Noticia`.`destaque` = '1' AND `Noticia`.`categoria_id` = '".$categoria."' ORDER BY `Noticia`.`id` DESC LIMIT 2) UNION "; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
** Função para validação personalizada | |
** @link http://snook.ca/archives/cakephp/multiple_validation_sets_cakephp | |
*/ | |
function validates($options = array()) { | |
// copy the data over from a custom var, otherwise | |
$actionSet = 'validate' . Inflector::camelize(Router::getParam('action')); | |
if (isset($this->validationSet)) { | |
$temp = $this->validate; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
Router::connect( | |
'/projetos/:categoria' , | |
array('controller' => 'projetos', 'action' => 'index'), // Local à ser redirecionado | |
array('pass' => array('categoria'), 'categoria' => '[a-zA-Z-0-9_]*') | |
); | |
Router::connect( | |
'/projetos/:categoria/:codigo' , | |
array('controller' => 'projetos', 'action' => 'view'), // Local à ser redirecionado | |
array('pass' => array('codigo'), 'categoria' => '[a-zA-Z-0-9_]*', 'codigo' => '[a-zA-Z-0-9_]{7}') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
App::uses('AppModel', 'Model'); | |
/** | |
* Cidade Model | |
* | |
*/ | |
class Cidade extends AppModel { | |
var $name = 'Cidade'; | |
var $displayField = 'nome'; | |
var $useDbConfig = 'geobase'; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
App::uses('AppModel', 'Model'); | |
/** | |
* Projeto Model | |
* | |
*/ | |
class Projeto extends AppModel { | |
/** | |
* Display field | |
* |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* add method | |
* | |
* @return void | |
*/ | |
public function add() { | |
if ($this->request->is('post')) { | |
$this->request->data['Page']['created'] = date('Y-m-d H:i:s'); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
App::uses('AppController', 'Controller'); | |
/** | |
* Users Controller | |
* | |
* @property User $User | |
*/ | |
class GeoController extends AppController { | |
public $components = array('RequestHandler','Json'); |
OlderNewer