Changeset 9572 for extensions/ContestResults/include
- Timestamp:
- Mar 8, 2011, 1:19:06 PM (13 years ago)
- Location:
- extensions/ContestResults/include
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
extensions/ContestResults/include/cr_comment_picture.php
r9200 r9572 1 1 <?php 2 2 if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!'); 3 4 // +-----------------------------------------------------------------------+ 5 // Affichage du commentaire sur la page d'une image participante 6 // +-----------------------------------------------------------------------+ 3 7 4 8 // Requète simple pour savoir si l'image a participé à des concours … … 6 10 7 11 if(pwg_db_num_rows($participation)){ 12 // requète complète 8 13 $results = pwg_query("SELECT 9 14 i.rank, … … 46 51 </style>'; 47 52 53 // +-----------------------------------------------------------------------+ 54 // Template 55 // +-----------------------------------------------------------------------+ 48 56 $template->assign('COMMENT_IMG', $template->get_template_vars('COMMENT_IMG') . $comment); 49 $template->a ssign('PLUGIN_PICTURE_BEFORE', $template->get_template_vars('PLUGIN_PICTURE_BEFORE') .$css);57 $template->append('footer_elements', $css); 50 58 } 51 59 ?> -
extensions/ContestResults/include/cr_main.php
r9200 r9572 11 11 date_begin, 12 12 date_end, 13 status,14 13 logo, 15 14 summary … … 19 18 while ($contest = pwg_db_fetch_assoc($contests)) { 20 19 if ($contest['visible'] OR is_admin()) { 20 $contest['finished'] = is_date_passed($contest['date_end']); 21 21 22 // infos sur le concours 22 23 $item = array( … … 24 25 'NAME' => trigger_event('render_CR_content', $contest['name']), 25 26 'VISIBLE' => $contest['visible'], 26 ' STATUS' => $contest['status'],27 'FINISHED' => $contest['finished'], 27 28 'DATE_END' => format_date($contest['date_end']), 28 29 'DATE_BEGIN' => format_date($contest['date_begin']), … … 30 31 'SUMMARY' => CR_cut_string(trigger_event('render_CR_content', $contest['summary']), 350), 31 32 'URL' => CR_PUBLIC . $contest['id'] . '-' . str2url(trigger_event('render_CR_content', $contest['name'])), 33 'DAYS' => DateDiff($contest['date_end'], date('Y-m-d')), 32 34 ); 33 35 34 36 // podium si terminé 35 if ($contest[' status'] == 'finished') {37 if ($contest['finished'] == true) { 36 38 $results = pwg_query("SELECT 37 39 i.id, … … 67 69 // Template 68 70 // +-----------------------------------------------------------------------+ 71 if (is_admin()) { 72 $template->assign('U_EDIT', CR_ADMIN); 73 } 69 74 $template->assign('CR_PATH', CR_PATH); 70 75 $template->assign('SEPARATOR', $conf['level_separator']); -
extensions/ContestResults/include/cr_menubar.php
r9200 r9572 37 37 name, 38 38 visible, 39 status,40 39 date_begin, 41 40 date_end … … 43 42 ORDER BY date_begin DESC;"); 44 43 45 $m = 0; // co pteur pour limiter le nombre de concours affichés44 $m = 0; // compteur pour limiter le nombre de concours affichés 46 45 while($contest = pwg_db_fetch_assoc($contests)){ 47 46 if (($contest['visible'] OR is_admin()) AND $m < $config['menubar_block']['number']) { … … 50 49 'LABEL' => trigger_event('render_CR_content', $contest['name']), 51 50 'DATE' => format_date($contest['date_begin']) . ' - ' . format_date($contest['date_end']), 52 'STATUS' => $contest['status'], 53 'VISIBLE' => $contest['visible'] 51 'VISIBLE' => $contest['visible'], 52 'FINISHED' => is_date_passed($contest['date_end']), 53 'DAYS' => DateDiff($contest['date_end'],date('Y-m-d')), 54 54 )); 55 55 } -
extensions/ContestResults/include/cr_page.php
r9200 r9572 15 15 if (pwg_db_num_rows($contest)) { 16 16 $contest = pwg_db_fetch_assoc($contest); 17 $contest['finished'] = is_date_passed($contest['date_end']); 17 18 18 19 // Concours non-publique … … 25 26 'ID' => $contest['id'], 26 27 'NAME' => trigger_event('render_CR_content', $contest['name']), 27 'STATUS' => $contest['status'],28 28 'VISIBLE' => $contest['visible'], 29 'FINISHED' => $contest['finished'], 29 30 'DATE_BEGIN' => format_date($contest['date_begin']), 30 31 'DATE_END' => format_date($contest['date_end']), … … 32 33 'BANNER' => $contest['banner'], 33 34 'URL' => CR_PUBLIC . $contest['id'] . '-' . str2url(trigger_event('render_CR_content', $contest['name'])), 35 'DAYS' => DateDiff($contest['date_end'], date('Y-m-d')), 34 36 )); 35 37 36 38 // Les quatre zones texte 37 foreach (array('presentation','rules','prices','final') AS $key) { 38 $template->assign(strtoupper($key), trigger_event('render_CR_content', $contest[$key])); 39 if (!empty($contest['description'])) { 40 $contest['description'] = unserialize(base64_decode($contest['description'])); 41 foreach ($contest['description'] as $desc) { 42 $template->append('description', array( 43 'NAME' => trigger_event('render_CR_content', stripslashes($desc['name'])), 44 'CONTENT' => trigger_event('render_CR_content', stripslashes($desc['content'])), 45 )); 46 } 39 47 } 40 48 41 49 // Affichage des résultats 42 if ($contest[' status'] == 'finished') {50 if ($contest['finished'] == true) { 43 51 // Infos des résultats 44 52 $results = pwg_query("SELECT * FROM " . CR_TABLE_2 . " WHERE contest_id=" . $contest['id'] . " ORDER BY rank ASC;"); -
extensions/ContestResults/include/cutstring.class.php
r6782 r9572 6 6 7 7 class HtmlCutString{ 8 function __construct($string, $limit){ 9 // create dom element using the html string 10 $this->tempDiv = new DomDocument; 11 $this->tempDiv->loadXML('<div>'.$string.'</div>'); 12 // keep the characters count till now 13 $this->charCount = 0; 14 $this->encoding = 'UTF-8'; 15 // character limit need to check 16 $this->limit = $limit; 17 } 18 function cut(){ 19 // create empty document to store new html 20 $this->newDiv = new DomDocument; 21 // cut the string by parsing through each element 22 $this->searchEnd($this->tempDiv->documentElement,$this->newDiv); 23 $newhtml = $this->newDiv->saveHTML(); 24 return $newhtml; 25 } 26 27 function deleteChildren($node) { 28 while (isset($node->firstChild)) { 29 $this->deleteChildren($node->firstChild); 30 $node->removeChild($node->firstChild); 31 } 32 } 33 function searchEnd($parseDiv, $newParent){ 34 foreach($parseDiv->childNodes as $ele){ 35 // not text node 36 if($ele->nodeType != 3){ 37 $newEle = $this->newDiv->importNode($ele,true); 38 if(count($ele->childNodes) === 0){ 39 $newParent->appendChild($newEle); 40 continue; 41 } 42 $this->deleteChildren($newEle); 43 $newParent->appendChild($newEle); 44 $res = $this->searchEnd($ele,$newEle); 45 if($res) 46 return $res; 47 else 48 continue; 8 function __construct($string, $limit){ 9 // create dom element using the html string 10 $this->tempDiv = new DomDocument; 11 $this->tempDiv->loadXML('<div>'.$string.'</div>'); 12 // keep the characters count till now 13 $this->charCount = 0; 14 $this->encoding = 'UTF-8'; 15 // character limit need to check 16 $this->limit = $limit; 49 17 } 50 51 // the limit of the char count reached52 if(mb_strlen($ele->nodeValue,$this->encoding) + $this->charCount >= $this->limit){53 $newEle = $this->newDiv->importNode($ele);54 $newEle->nodeValue = substr($newEle->nodeValue,0, $this->limit - $this->charCount);55 $newParent->appendChild($newEle);56 return true;18 function cut(){ 19 // create empty document to store new html 20 $this->newDiv = new DomDocument; 21 // cut the string by parsing through each element 22 $this->searchEnd($this->tempDiv->documentElement,$this->newDiv); 23 $newhtml = $this->newDiv->saveHTML(); 24 return $newhtml; 57 25 } 58 $newEle = $this->newDiv->importNode($ele); 59 $newParent->appendChild($newEle); 60 $this->charCount += mb_strlen($newEle->nodeValue,$this->encoding); 61 } 62 return false; 63 } 26 function deleteChildren($node) { 27 while (isset($node->firstChild)) { 28 $this->deleteChildren($node->firstChild); 29 $node->removeChild($node->firstChild); 30 } 31 } 32 function searchEnd($parseDiv, $newParent){ 33 foreach($parseDiv->childNodes as $ele){ 34 // not text node 35 if($ele->nodeType != 3){ 36 $newEle = $this->newDiv->importNode($ele,true); 37 if(count($ele->childNodes) === 0){ 38 $newParent->appendChild($newEle); 39 continue; 40 } 41 $this->deleteChildren($newEle); 42 $newParent->appendChild($newEle); 43 $res = $this->searchEnd($ele,$newEle); 44 if($res) 45 return $res; 46 else 47 continue; 48 } 49 // the limit of the char count reached 50 if(mb_strlen($ele->nodeValue,$this->encoding) + $this->charCount >= $this->limit){ 51 $newEle = $this->newDiv->importNode($ele); 52 $newEle->nodeValue = substr($newEle->nodeValue,0, $this->limit - $this->charCount); 53 $newParent->appendChild($newEle); 54 return true; 55 } 56 $newEle = $this->newDiv->importNode($ele); 57 $newParent->appendChild($newEle); 58 $this->charCount += mb_strlen($newEle->nodeValue,$this->encoding); 59 } 60 return false; 61 } 64 62 } 65 63 ?> -
extensions/ContestResults/include/functions.php
r9200 r9572 23 23 } 24 24 } 25 26 // Nombre de jours entre deux dates 27 function DateDiff($date2, $date1) { 28 return ceil((strtotime($date2)-strtotime($date1))/(3600*24)); 29 } 30 31 // Date passée 32 function is_date_passed($date) { 33 if (time() > strtotime($date)) { 34 return true; 35 } else { 36 return false; 37 } 38 } 25 39 ?>
Note: See TracChangeset
for help on using the changeset viewer.