Changeset 1333533
- Timestamp:
- 01/22/2016 08:56:03 AM (10 years ago)
- Location:
- calj/trunk
- Files:
-
- 2 edited
-
CalJPlugin.php (modified) (3 diffs)
-
readme.txt (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
calj/trunk/CalJPlugin.php
r1331961 r1333533 80 80 81 81 if (isset($json['success']) && $json['success']) { 82 switch($decodedAttr['val']) { 83 case 'shabbatBegins': $result = $json['shabbat']['begins']; break; 84 case 'shabbatEnds': $result = $json['shabbat']['ends']; break; 85 case 'parasha': $result = $json['shabbat']['parasha']; break; 86 case 'cityName': $result = $json['city']['name']; break; 87 default: break; 82 83 // dot notation to access the json properties 84 $jsonPath = preg_split('#\.#', $decodedAttr['val']); 85 $jsonCursor = $json; 86 for($i = 0; $i < count($jsonPath); ++ $i) { 87 $component = $jsonPath[$i]; 88 if (array_key_exists($component, $jsonCursor)) { 89 $jsonCursor = $jsonCursor[$component]; 90 } 91 else { 92 $jsonCursor = ''; 93 break; 94 } 95 } 96 97 if (is_array($jsonCursor)) { 98 $result = ''; 99 } 100 else { 101 $result = $jsonCursor; 88 102 } 89 103 } … … 98 112 $city = $options['city']; 99 113 $response = file_get_contents('http://api.calj.net/wp/1/shabbat.json?city='.$city.'&key='.$key); 100 $response = self::xorString(base64_decode($response));101 114 102 115 $response = json_decode($response, true); 103 if (! $response) { 116 if ( (! $response) || (! isset($response['data'])) || (! $response['data']) ) { 117 return null; 118 } 119 120 $response = json_decode( self::xorString($response['data']), true ); 121 if ( ! $response ) { 104 122 return null; 105 123 } … … 145 163 // Iterate through each character 146 164 for($i = 0; $i < strlen($text); ) 147 for($j = 0; ($j < strlen($key) && $i < strlen($text)); $j++, $i++)148 $outText .= $text{$i} ^ $key{$j};165 for($j = 0; ($j < strlen($key) && $i < strlen($text)); $j++, $i++) 166 $outText .= $text{$i} ^ $key{$j}; 149 167 150 168 return $outText; -
calj/trunk/readme.txt
r1331973 r1333533 30 30 The `caljshabbat` shortcode accepts several directives, which you can arrange the way you want in your pages. 31 31 32 * `[caljshabbat val="city Name"]`32 * `[caljshabbat val="city.name"]` 33 33 34 34 Prints the name of the location for which you are showing the times. You may configure the city on the CalJ API configuration page. 35 35 36 * `[caljshabbat val=" parasha"]`36 * `[caljshabbat val="shabbat.parasha"]` 37 37 38 38 Prints the name of the current week's Parasha. 39 39 40 * `[caljshabbat val="shabbat Begins"]`40 * `[caljshabbat val="shabbat.begins"]` 41 41 42 Prints the candle-lighting time for the for ecoming Shabbat, in 24-hour format.42 Prints the candle-lighting time for the forthcoming Shabbat, in 24-hour format. 43 43 44 * `[caljshabbat val="shabbat Ends"]`44 * `[caljshabbat val="shabbat.ends"]` 45 45 46 46 Prints the end of shabbat, in 24-hour format. 47 48 * `[caljshabbat val="shabbat.day"]` 49 50 Prints the day of month (secular) of Shabbat. 51 52 * `[caljshabbat val="shabbat.month"]` 53 54 Prints the month number (secular) of Shabbat. 55 56 * `[caljshabbat val="shabbat.year"]` 57 58 Prints the year (secular) of Shabbat. 59 60 * `[caljshabbat val="shabbat.jday"]` 61 62 Prints the day of month (Jewish) of Shabbat. 63 64 * `[caljshabbat val="shabbat.jmonthName"]` 65 66 Prints the name of the Jewish month of Shabbat. 67 68 * `[caljshabbat val="shabbat.jyear"]` 69 70 Prints the Jewish year of Shabbat. 47 71 48 72
Note: See TracChangeset
for help on using the changeset viewer.