PageRenderTime 42ms CodeModel.GetById 19ms RepoModel.GetById 0ms app.codeStats 0ms

/components/com_jevents/views/alternative/helpers/alternativebuildmonthselect.php

https://bitbucket.org/kraymitchell/saiu
PHP | 45 lines | 38 code | 6 blank | 1 comment | 3 complexity | 6bb6ad5c8a497be2c4de67ee599a09da MD5 | raw file
Possible License(s): GPL-2.0, LGPL-3.0, BSD-3-Clause, LGPL-2.1, GPL-3.0
  1. <?php
  2. defined('_JEXEC') or die('Restricted access');
  3. class AlternativeBuildMonthSelect {
  4. var $view = null;
  5. var $result = "";
  6. function AlternativeBuildMonthSelect($view, $link, $month, $year){
  7. for( $a=-6; $a<6; $a++ ){
  8. $m = $month+$a;
  9. $y=$year;
  10. if ($m<=0){
  11. $m+=12;
  12. $y-=1;
  13. }
  14. if ($m>12){
  15. $m-=12;
  16. $y+=1;
  17. }
  18. $name_of_month = JEVHelper::getMonthName($m)." $y";
  19. $monthslist[] = JHTML::_('select.option', "$m|$y", $name_of_month );
  20. }
  21. $tosend = "<script type='text/javascript'>\n";
  22. $tosend .= "/* <![CDATA[ */\n";
  23. $tosend .= " function selectMD(elem) {
  24. var ym = elem.options[elem.selectedIndex].value.split('|');\n";
  25. $link.="day=1&month=MMMMmmmm&year=YYYYyyyy";
  26. $link2 = JRoute::_($link,false);
  27. $tosend .= "var link = '$link2';\n";
  28. // This is needed in case SEF is not activated
  29. $tosend .= "link = link.replace(/&/g,'&');\n";
  30. $tosend .= "link = link.replace(/MMMMmmmm/g,ym[0]);\n";
  31. $tosend .= "link = link.replace(/YYYYyyyy/g,ym[1]);\n";
  32. $tosend .= "location.replace(link);\n";
  33. $tosend .= "}\n";
  34. $tosend .= "/* ]]> */\n";
  35. $tosend .= "</script>\n";
  36. $tosend .= JHTML::_('select.genericlist', $monthslist, 'monthyear', "onchange=\"selectMD(this);\"", 'value', 'text', "$month|$year" );
  37. $this->result = $tosend;
  38. }
  39. }