Changeset 1398
- Timestamp:
- Sep 22, 2010, 1:01:56 AM (10 years ago)
- Location:
- cpc/trunk/project
- Files:
-
- 5 added
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
cpc/trunk/project/config/doctrine/schema.yml
r1397 r1398 26 26 title: nom 27 27 extra_weight: 1.5 28 description: [num_circo, nom_circo ]28 description: [num_circo, nom_circo, villes] 29 29 moretags: [profession, nom_circo] 30 columns: 30 columns: 31 31 nom_circo: string(255) 32 32 num_circo: integer … … 50 50 mails: string 51 51 top: string 52 villes: string 52 53 inheritance: 53 54 extends: Personnalite … … 62 63 fields: [url_an] 63 64 type: unique 65 66 ParlementairePhoto: 67 columns: 68 slug: string(255) 69 photo: blob 70 64 71 65 72 Organisme: -
cpc/trunk/project/lib/model/doctrine/Parlementaire.class.php
r1386 r1398 200 200 } 201 201 202 public function hasPhoto()203 {204 $photo = $this->_get('photo');205 return (strlen($photo) > 0) ;206 }207 public function setPhoto($s) {208 if (preg_match('/http/', $s)) {209 $len = strlen($this->_get('photo'));210 if ($len < 5200) {211 $s = file_get_contents($s);212 }else213 return true;214 if (!$s)215 return false;216 }217 $this->_set('photo', $s);218 }219 202 public function getPageLink() { 220 203 return '@parlementaire?slug='.$this->slug; … … 574 557 } 575 558 559 public function addVille($ville) { 560 if (!isset($this->array_villes) || !$this->array_villes) { 561 $villes = $this->getVille(); 562 $this->array_villes = explode(', ', $villes); 563 } 564 array_push($this->array_villes, $ville); 565 return $this->_set('villes', implode(', ', $this->array_villes)); 566 } 567 568 public function setVille($ville) { 569 $this->array_villes = null; 570 return parent::setVille($ville); 571 } 572 576 573 public function getTop() { 577 574 //A supprimer lorsque les top seront unifiés (cf. parlementaire action) … … 580 577 } 581 578 579 private function setInternalPhoto($photo) { 580 if (!isset($this->photo) || !$this->photo) 581 $this->photo = doctrine::getTable('ParlementairePhoto')->findOrAdd($this->id, $this->slug); 582 return $this->photo->setPhoto($photo); 583 } 584 private function getInternalPhoto() { 585 if (!isset($this->photo) || !$this->photo) 586 $this->photo = doctrine::getTable('ParlementairePhoto')->find($this->id); 587 if (!$this->photo) 588 return null; 589 return $this->photo->getPhoto(); 590 } 591 592 public function hasPhoto() 593 { 594 $photo = $this->getInternalPhoto('photo'); 595 return (strlen($photo) > 0) ; 596 } 597 public function setPhoto($s) { 598 if (preg_match('/http/', $s)) { 599 $len = strlen($this->_get('photo')); 600 if ($len < 5200) { 601 $s = file_get_contents($s); 602 }else 603 return true; 604 if (!$s) 605 return false; 606 } 607 $this->setInternalPhoto($s); 608 } 609 public function save($c = null) { 610 if (isset($this->photo) && $this->photo) 611 $this->photo->save(); 612 return parent::save($c); 613 } 582 614 } -
cpc/trunk/project/lib/task/updateDeputesTask.class.php
r1274 r1398 25 25 $dir = dirname(__FILE__).'/../../batch/depute/out/'; 26 26 $manager = new sfDatabaseManager($this->configuration); 27 28 $villes = json_decode(file_get_contents($dir.'../static/villes.json')); 27 29 28 30 if (is_dir($dir)) { … … 74 76 if ($json->url_an) 75 77 $parl->url_an = $json->url_an; 78 $parl->villes = $villes->{$parl->getNumDepartement()}->{$parl->num_circo}; 76 79 $parl->save(); 77 80 }
Note: See TracChangeset
for help on using the changeset viewer.