From: Verdon V. <ve...@us...> - 2009-03-02 19:59:27
|
Update of /cvsroot/phpwebsite-comm/modules/elections/class In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv10916/class Modified Files: ELEC_Ballot.php ELEC_Candidate.php ELEC_Forms.php Election.php Log Message: preparing 2.0.1 Index: ELEC_Candidate.php =================================================================== RCS file: /cvsroot/phpwebsite-comm/modules/elections/class/ELEC_Candidate.php,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** ELEC_Candidate.php 19 Feb 2009 21:30:10 -0000 1.1 --- ELEC_Candidate.php 2 Mar 2009 19:59:11 -0000 1.2 *************** *** 154,158 **** } ! public function getImage() { if (!$this->image_id) { --- 154,158 ---- } ! public function getFile() { if (!$this->image_id) { *************** *** 162,165 **** --- 162,192 ---- } + public function getThumbnail($link=false) + { + if (empty($this->image_id)) { + return null; + } + + PHPWS_Core::initModClass('filecabinet', 'Cabinet.php'); + $file = Cabinet::getFile($this->image_id); + + if ($file->isImage(true)) { + $file->allowImageLink(false); + if ($link) { + return sprintf('<a href="%s">%s</a>', $this->viewLink(true), $file->getThumbnail()); + } else { + return $file->getThumbnail(); + } + } elseif ($file->isMedia() && $file->_source->isVideo()) { + if ($link) { + return sprintf('<a href="%s">%s</a>', $this->viewLink(), $file->getThumbnail()); + } else { + return $file->getThumbnail(); + } + } else { + return $file->getTag(); + } + } + public function getVotes() { *************** *** 260,263 **** --- 287,291 ---- $tpl['TITLE'] = $this->getTitle(true); $tpl['DESCRIPTION'] = PHPWS_Text::parseTag($this->getDescription(true)); + $tpl['FILE'] = $this->getFile(); *************** *** 310,313 **** --- 338,342 ---- { $vars['candidate_id'] = $this->id; + $vars['ballot_id'] = $this->ballot_id; if (Current_User::isUnrestricted('elections')) { *************** *** 337,340 **** --- 366,374 ---- $tpl['DESCRIPTION'] = $this->getDescription(true); $tpl['LINKS'] = $this->candidateLinks(false); + if ($this->image_id) { + $tpl['CANDIDATE_THUMBNAIL'] = $this->getThumbnail(true); + } else { + $tpl['CANDIDATE_THUMBNAIL'] = null; + } $tpl['VOTE_BOX'] = $this->getVoteBox(); Index: ELEC_Ballot.php =================================================================== RCS file: /cvsroot/phpwebsite-comm/modules/elections/class/ELEC_Ballot.php,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** ELEC_Ballot.php 19 Feb 2009 21:30:10 -0000 1.1 --- ELEC_Ballot.php 2 Mar 2009 19:59:11 -0000 1.2 *************** *** 172,176 **** } ! public function getImage() { if (!$this->image_id) { --- 172,176 ---- } ! public function getFile() { if (!$this->image_id) { *************** *** 180,183 **** --- 180,210 ---- } + public function getThumbnail($link=false) + { + if (empty($this->image_id)) { + return null; + } + + PHPWS_Core::initModClass('filecabinet', 'Cabinet.php'); + $file = Cabinet::getFile($this->image_id); + + if ($file->isImage(true)) { + $file->allowImageLink(false); + if ($link) { + return sprintf('<a href="%s">%s</a>', $this->viewLink(true), $file->getThumbnail()); + } else { + return $file->getThumbnail(); + } + } elseif ($file->isMedia() && $file->_source->isVideo()) { + if ($link) { + return sprintf('<a href="%s">%s</a>', $this->viewLink(), $file->getThumbnail()); + } else { + return $file->getThumbnail(); + } + } else { + return $file->getTag(); + } + } + public function getOpening($type=ELEC_DATE_FORMAT) { *************** *** 298,301 **** --- 325,329 ---- $tpl['TITLE'] = $this->getTitle(true); $tpl['DESCRIPTION'] = PHPWS_Text::parseTag($this->getDescription(true)); + $tpl['FILE'] = $this->getFile(); if (!empty($this->opening)) { *************** *** 486,489 **** --- 514,522 ---- $tpl['TITLE'] = $this->viewLink(); $tpl['DESCRIPTION'] = $this->getListDescription(120); + if ($this->image_id) { + $tpl['THUMBNAIL'] = $this->getThumbnail(true); + } else { + $tpl['THUMBNAIL'] = null; + } // $tpl['OPENS'] = $this->getOpening('%H:%M %a, %b %d, %y'); // $tpl['CLOSES'] = $this->getClosing('%H:%M %a, %b %d, %y'); Index: ELEC_Forms.php =================================================================== RCS file: /cvsroot/phpwebsite-comm/modules/elections/class/ELEC_Forms.php,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** ELEC_Forms.php 19 Feb 2009 21:30:10 -0000 1.1 --- ELEC_Forms.php 2 Mar 2009 19:59:11 -0000 1.2 *************** *** 224,228 **** PHPWS_Core::initModClass('filecabinet', 'Cabinet.php'); ! $manager = Cabinet::fileManager('media_id', $ballot->image_id); $manager->imageOnly(); $manager->maxImageWidth(PHPWS_Settings::get('elections', 'max_width')); --- 224,228 ---- PHPWS_Core::initModClass('filecabinet', 'Cabinet.php'); ! $manager = Cabinet::fileManager('image_id', $ballot->image_id); $manager->imageOnly(); $manager->maxImageWidth(PHPWS_Settings::get('elections', 'max_width')); *************** *** 315,318 **** --- 315,319 ---- $candidate = & $this->election->candidate; $ballot = & $this->election->ballot; + //print_r($candidate); print_r($ballot); $form->addHidden('module', 'elections'); $form->addHidden('aop', 'post_candidate'); *************** *** 320,324 **** if ($candidate->id) { $this->election->title = sprintf(dgettext('elections', 'Update %s candidate'), $ballot->title); ! $form->addHidden('id', $candidate->id); $form->addSubmit(dgettext('elections', 'Update')); } else { --- 321,325 ---- if ($candidate->id) { $this->election->title = sprintf(dgettext('elections', 'Update %s candidate'), $ballot->title); ! $form->addHidden('candidate_id', $candidate->id); $form->addSubmit(dgettext('elections', 'Update')); } else { *************** *** 337,341 **** PHPWS_Core::initModClass('filecabinet', 'Cabinet.php'); ! $manager = Cabinet::fileManager('media_id', $candidate->image_id); $manager->imageOnly(); $manager->maxImageWidth(PHPWS_Settings::get('elections', 'max_width')); --- 338,342 ---- PHPWS_Core::initModClass('filecabinet', 'Cabinet.php'); ! $manager = Cabinet::fileManager('image_id', $candidate->image_id); $manager->imageOnly(); $manager->maxImageWidth(PHPWS_Settings::get('elections', 'max_width')); Index: Election.php =================================================================== RCS file: /cvsroot/phpwebsite-comm/modules/elections/class/Election.php,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** Election.php 19 Feb 2009 20:32:00 -0000 1.7 --- Election.php 2 Mar 2009 19:59:11 -0000 1.8 *************** *** 411,414 **** --- 411,418 ---- } + if (isset($_POST['image_id'])) { + $this->ballot->setImage_id((int)$_POST['image_id']); + } + isset($_POST['pubview']) ? $this->ballot->setPubview(1) : *************** *** 478,482 **** --- 482,488 ---- public function postCandidate() { + //print_r($_POST); exit; $this->loadCandidate(); + //print_r($this->candidate); exit; if (empty($_POST['title'])) { |