| [ Index ] |
PHP Cross Reference of Drupal 6 (yi-drupal) |
[Summary view] [Print] [Text view]
1 <?php 2 /** 3 * @file 4 * Token module integration. 5 */ 6 7 function date_token_list($type = 'all') { 8 if ($type == 'field' || $type == 'all') { 9 $tokens = array(); 10 11 $tokens['date']['value'] = t("The raw date value."); 12 $tokens['date']['view'] = t("The formatted date."); 13 $tokens['date']['timestamp'] = t("The raw date timestamp."); 14 $tokens['date']['yyyy'] = t("Date year (four digit)"); 15 $tokens['date']['yy'] = t("Date year (two digit)"); 16 $tokens['date']['month'] = t("Date month (full word)"); 17 $tokens['date']['mon'] = t("Date month (abbreviated)"); 18 $tokens['date']['mm'] = t("Date month (two digit, zero padded)"); 19 $tokens['date']['m'] = t("Date month (one or two digit)"); 20 $tokens['date']['ww'] = t("Date week (two digit)"); 21 $tokens['date']['date'] = t("Date date (YYYY-MM-DD)"); 22 $tokens['date']['datetime'] = t("Date datetime (YYYY-MM-DDTHH:MM:SS)"); 23 $tokens['date']['day'] = t("Date day (full word)"); 24 $tokens['date']['ddd'] = t("Date day (abbreviation)"); 25 $tokens['date']['dd'] = t("Date day (two digit, zero-padded)"); 26 $tokens['date']['d'] = t("Date day (one or two digit)"); 27 $tokens['date']['dS'] = t("Date day (one or two digit) with ordinal suffix (st, nd, rd or th)"); 28 $tokens['date']['time'] = t("Time H:i"); 29 30 $tokens['date']['to-????'] = t("If the field has a to-date defined, the same tokens exist in the form: [to-????], where ???? is the normal token."); 31 32 return $tokens; 33 } 34 } 35 36 function date_token_values($type, $object = NULL) { 37 if ($type == 'field') { 38 $item = $object[0]; 39 $item['value'] = trim($item['value']); 40 $item_type = isset($item['date_type']) ? $item['date_type'] : (is_numeric($item['value']) ? DATE_UNIX : DATE_ISO); 41 $timezone = !empty($item['timezone']) ? $item['timezone'] : date_default_timezone_name(); 42 $timezone_db = !empty($item['timezone_db']) ? $item['timezone_db'] : 'UTC'; 43 $date = date_make_date($item['value'], $timezone_db, $item_type); 44 if (!empty($date) && $timezone_db != $timezone) { 45 date_timezone_set($date, timezone_open($timezone)); 46 } 47 48 $tokens['value'] = $item['value']; 49 $tokens['view'] = $item['view']; 50 $tokens['timestamp'] = !empty($date) ? date_format_date($date, 'custom', 'U') : ''; 51 $tokens['yyyy'] = !empty($date) ? date_format_date($date, 'custom', 'Y') : ''; 52 $tokens['yy'] = !empty($date) ? date_format_date($date, 'custom', 'y') : ''; 53 $tokens['month'] = !empty($date) ? date_format_date($date, 'custom', 'F') : ''; 54 $tokens['mon'] = !empty($date) ? date_format_date($date, 'custom', 'M') : ''; 55 $tokens['mm'] = !empty($date) ? date_format_date($date, 'custom', 'm') : ''; 56 $tokens['m'] = !empty($date) ? date_format_date($date, 'custom', 'n') : ''; 57 $tokens['ww'] = !empty($date) ? date_format_date($date, 'custom', 'W') : ''; 58 $tokens['date'] = !empty($date) ? date_format_date($date, 'custom', DATE_FORMAT_DATE) : ''; 59 $tokens['datetime'] = !empty($date) ? date_format_date($date, 'custom', DATE_FORMAT_ISO) : ''; 60 $tokens['day'] = !empty($date) ? date_format_date($date, 'custom', 'l') : ''; 61 $tokens['ddd'] = !empty($date) ? date_format_date($date, 'custom', 'D') : ''; 62 $tokens['dd'] = !empty($date) ? date_format_date($date, 'custom', 'd') : ''; 63 $tokens['d'] = !empty($date) ? date_format_date($date, 'custom', 'j') : ''; 64 $tokens['dS'] = !empty($date) ? date_format_date($date, 'custom', 'jS') : ''; 65 $tokens['time'] = !empty($date) ? date_format_date($date, 'custom', 'H:i') : ''; 66 67 if (!empty($item['value2'])) { 68 69 $item['value2'] = trim($item['value2']); 70 $date = date_make_date($item['value2'], $timezone_db, $item_type); 71 if ($timezone_db != $timezone) { 72 date_timezone_set($date, timezone_open($timezone)); 73 } 74 75 $tokens['to-value'] = $item['value2']; 76 $tokens['to-view'] = $item['view']; 77 $tokens['to-timestamp'] = !empty($date) ? date_format_date($date, 'custom', 'U') : ''; 78 $tokens['to-yyyy'] = !empty($date) ? date_format_date($date, 'custom', 'Y') : ''; 79 $tokens['to-yy'] = !empty($date) ? date_format_date($date, 'custom', 'y') : ''; 80 $tokens['to-month'] = !empty($date) ? date_format_date($date, 'custom', 'F') : ''; 81 $tokens['to-mon'] = !empty($date) ? date_format_date($date, 'custom', 'M') : ''; 82 $tokens['to-mm'] = !empty($date) ? date_format_date($date, 'custom', 'm') : ''; 83 $tokens['to-m'] = !empty($date) ? date_format_date($date, 'custom', 'n') : ''; 84 $tokens['to-ww'] = !empty($date) ? date_format_date($date, 'custom', 'W') : ''; 85 $tokens['to-date'] = !empty($date) ? date_format_date($date, 'custom', DATE_FORMAT_DATE) : ''; 86 $tokens['to-datetime'] = !empty($date) ? date_format_date($date, 'custom', DATE_FORMAT_ISO) : ''; 87 $tokens['to-day'] = !empty($date) ? date_format_date($date, 'custom', 'l') : ''; 88 $tokens['to-ddd'] = !empty($date) ? date_format_date($date, 'custom', 'D') : ''; 89 $tokens['to-dd'] = !empty($date) ? date_format_date($date, 'custom', 'd') : ''; 90 $tokens['to-d'] = !empty($date) ? date_format_date($date, 'custom', 'j') : ''; 91 $tokens['to-dS'] = !empty($date) ? date_format_date($date, 'custom', 'jS') : ''; 92 $tokens['to-time'] = !empty($date) ? date_format_date($date, 'custom', 'H:i') : ''; 93 94 } 95 return $tokens; 96 } 97 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| Generated: Mon Jul 9 18:01:44 2012 | Cross-referenced by PHPXref 0.7 |