Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- //App::import('Router');
- class FillTwitterQueueShell extends Shell {
- var $uses = array ( 'City', 'Departement', 'Region', 'TwitterQueue' ) ;
- function main ( ) {
- $regionList = $this->Region->find('all', array( 'contain' => false,
- 'conditions' => array(
- 'Region.is_available' => 1 ),
- 'fields' => array(
- 'Region.id',
- 'Region.slug',
- 'Region.name')
- )
- );
- foreach ( $regionList as $region ) {
- $regionUrl = Router::url ( array (
- 'controller' => 'departements',
- 'action' => 'index',
- 'ext' => 'html',
- 'RegionSlug' => $region['Region']['slug']),
- true
- );
- $regionData = array ( 'model' => 'region',
- 'model_id' => $region['Region']['id'],
- 'title' => 'Go-menage : ' . $region['Region']['name'],
- 'url' => $regionUrl ) ;
- $this->TwitterQueue->create ( ) ;
- $this->TwitterQueue->save ( $regionData ) ;
- $departementList = $this->Departement->find('all',array(
- 'contain' => false,
- 'conditions' => array (
- Departement.region_id' => $region['Region']['id'],
- Departement.is_available' => 1
- ),
- 'fields' => array (
- 'Departement.slug' ,
- 'Departement.id',
- 'Departement.name' )
- )
- );
- foreach ( $departementList as $departement ) {
- $departementUrl = Router::url ( array (
- 'controller' => 'cities',
- 'action' => 'index',
- 'ext' => 'html',
- 'RegionSlug' => $region['Region']['slug'],
- 'DepartementSlug' => $departement['Departement']['slug']
- ),
- true
- );
- $departementFullUrl = Router::url ( array (
- 'controller' => 'cities',
- 'action' => 'index',
- 'ext' => 'html',
- 'RegionSlug' => $region['Region']['slug'],
- 'DepartementSlug' => $departement['Departement']['slug'],
- true
- ),
- true
- );
- $departementData = array ( 'model' => 'departement',
- 'model_id' => $departement['Departement']['id'],
- 'title' => 'Go-menage : ' . $departement['Departement']['name'],
- 'url' => $departementUrl
- );
- $this->TwitterQueue->create ( ) ;
- $this->TwitterQueue->save ( $departementData ) ;
- // ON construit l'url de toutes les villes du département
- $departementFullData = array ( 'model' => 'departement',
- 'model_id' => $departement['Departement']['id'],
- 'title' => 'Go-menage : toutes les villes de ' . $departement['Departement']['name'],
- 'url' => $departementFullUrl
- );
- $this->TwitterQueue->create ( ) ;
- $this->TwitterQueue->save ( $departementFullData ) ;
- $cityList = $this->City->find (
- 'all',
- array (
- 'contain' => array ( ) ,
- 'conditions' => array (
- 'City.is_available' => 1,
- 'City.departement_id' => $departement['Departement']['id']
- ),
- 'fields' => array ( 'City.slug', 'City.id', 'City.name' )
- ));
- foreach ( $cityList as $city ) {
- $cityUrl = Router::url (
- array (
- 'controller' => 'cities',
- 'action' => 'view',
- 'ext' => 'html',
- 'RegionSlug' => $region['Region']['slug'],
- 'DepartementSlug' => $departement['Departement']['slug'],
- 'CitySlug' => $city['City']['slug'] )
- , true
- ) ;
- $cityData = array ( 'model' => 'city',
- 'model_id' => $city['City']['id'],
- 'title' => 'Go-menage : ' . $city['City']['name'],
- 'url' => $cityUrl
- );
- $this->TwitterQueue->create ( ) ;
- $this->TwitterQueue->save ( $cityData ) ;
- }
- }
- }
- }
- }
Add Comment
Please, Sign In to add comment