PageRenderTime 45ms CodeModel.GetById 20ms RepoModel.GetById 0ms app.codeStats 0ms

/phpical2/functions/list_functions.php

https://gitlab.com/endomorphosis/fusenews
PHP | 127 lines | 110 code | 17 blank | 0 comment | 18 complexity | 0ab6a79cac6f99b4074814a0b1cf5df5 MD5 | raw file
  1. <?php
  2. function list_jumps() {
  3. global $phpiCal_config, $lang, $cal;
  4. $calName = join(',', array_map("getCalendarName", split(',', $cal)));
  5. $today = date('Ymd', time() + $phpiCal_config->second_offset);
  6. $return = '<option value="#">'.$lang['l_jump'].'</option>';
  7. $return .= '<option value="day.php?cal='.$calName.'&amp;getdate='.$today.'">'.$lang['l_goday'].'</option>';
  8. $return .= '<option value="week.php?cal='.$calName.'&amp;getdate='.$today.'">'.$lang['l_goweek'].'</option>';
  9. $return .= '<option value="month.php?cal='.$calName.'&amp;getdate='.$today.'">'.$lang['l_gomonth'].'</option>';
  10. $return .= '<option value="year.php?cal='.$calName.'&amp;getdate='.$today.'">'.$lang['l_goyear'].'</option>';
  11. return $return;
  12. }
  13. function list_calcolors() {
  14. global $phpiCal_config, $master_array;
  15. $return = '';
  16. $i = 1;
  17. if (is_array($master_array['-3'])) {
  18. foreach ($master_array['-3'] as $key => $val) {
  19. if ($i > $phpiCal_config->unique_colors) $i = 1;
  20. $val = str_replace ("\,", ",", $val);
  21. $return .= '<img src="templates/'.$phpiCal_config->template.'/images/monthdot_'.$i.'.gif" alt="" /> '.$val.'<br />';
  22. $i++;
  23. }
  24. }
  25. return $return;
  26. }
  27. function list_months() {
  28. global $getdate, $this_year, $cal, $dateFormat_month;
  29. $month_time = strtotime("$this_year-01-01");
  30. $getdate_month = date("m", strtotime($getdate));
  31. $return = '';
  32. for ($i=0; $i<12; $i++) {
  33. $monthdate = date ("Ymd", $month_time);
  34. $month_month = date("m", $month_time);
  35. $select_month = localizeDate($dateFormat_month, $month_time);
  36. if ($month_month == $getdate_month) {
  37. $return .= "<option value=\"month.php?cal=$cal&amp;getdate=$monthdate\" selected=\"selected\">$select_month</option>\n";
  38. } else {
  39. $return .= "<option value=\"month.php?cal=$cal&amp;getdate=$monthdate\">$select_month</option>\n";
  40. }
  41. $month_time = strtotime ("+1 month", $month_time);
  42. }
  43. return $return;
  44. }
  45. function list_years() {
  46. global $getdate, $this_year, $cal, $phpiCal_config;
  47. $year_time = strtotime($getdate);
  48. $return = '';
  49. for ($i=0; $i < $phpiCal_config->num_years; $i++) {
  50. $offset = $phpiCal_config->num_years - $i;
  51. $prev_time = strtotime("-$offset year", $year_time);
  52. $prev_date = date("Ymd", $prev_time);
  53. $prev_year = date("Y", $prev_time);
  54. $return .= "<option value=\"year.php?cal=$cal&amp;getdate=$prev_date\">$prev_year</option>\n";
  55. }
  56. $getdate_date = date("Ymd", $year_time);
  57. $getdate_year = date("Y", $year_time);
  58. $return .= "<option value=\"year.php?cal=$cal&amp;getdate=$getdate_date\" selected=\"selected\">$getdate_year</option>\n";
  59. for ($i=0; $i < $phpiCal_config->num_years; $i++) {
  60. $offset = $i + 1;
  61. $next_time = strtotime("+$offset year", $year_time);
  62. $next_date = date("Ymd", $next_time);
  63. $next_year = date("Y", $next_time);
  64. $return .= "<option value=\"year.php?cal=$cal&amp;getdate=$next_date\">$next_year</option>\n";
  65. }
  66. return $return;
  67. }
  68. function list_weeks() {
  69. global $getdate, $this_year, $cal, $dateFormat_week_jump, $phpiCal_config;
  70. ereg ("([0-9]{4})([0-9]{2})([0-9]{2})", $getdate, $day_array2);
  71. $this_day = $day_array2[3];
  72. $this_month = $day_array2[2];
  73. $this_year = $day_array2[1];
  74. $check_week = strtotime($getdate);
  75. $start_week_time = strtotime(dateOfWeek(date("Ymd", strtotime("$this_year-01-01")), $phpiCal_config->week_start_day));
  76. $end_week_time = $start_week_time + (6 * 25 * 60 * 60);
  77. $return = '';
  78. do {
  79. $weekdate = date ("Ymd", $start_week_time);
  80. $select_week1 = localizeDate($dateFormat_week_jump, $start_week_time);
  81. $select_week2 = localizeDate($dateFormat_week_jump, $end_week_time);
  82. if (($check_week >= $start_week_time) && ($check_week <= $end_week_time)) {
  83. $return .= "<option value=\"week.php?cal=$cal&amp;getdate=$weekdate\" selected=\"selected\">$select_week1 - $select_week2</option>\n";
  84. } else {
  85. $return .= "<option value=\"week.php?cal=$cal&amp;getdate=$weekdate\">$select_week1 - $select_week2</option>\n";
  86. }
  87. $start_week_time = strtotime ("+1 week", $start_week_time);
  88. $end_week_time = $start_week_time + (6 * 25 * 60 * 60);
  89. } while (date("Y", $start_week_time) <= $this_year);
  90. return $return;
  91. }
  92. function list_languages() {
  93. global $getdate, $cal, $current_view;
  94. $return = '';
  95. $dir_handle = @opendir(BASE.'languages/');
  96. $tmp_pref_language = urlencode(ucfirst($language));
  97. while ($file = readdir($dir_handle)) {
  98. if (substr($file, -8) == ".inc.php") {
  99. $language_tmp = urlencode(ucfirst(substr($file, 0, -8)));
  100. if ($language_tmp == $tmp_pref_language) {
  101. $return .= "<option value=\"$current_view.php?chlang=$language_tmp\" selected=\"selected\">in $language_tmp</option>\n";
  102. } else {
  103. $return .= "<option value=\"$current_view.php?chlang=$language_tmp\">in $language_tmp</option>\n";
  104. }
  105. }
  106. }
  107. closedir($dir_handle);
  108. return $return;
  109. }
  110. ?>