diff --git a/helper.php b/helper.php index 3fd03ec..3af5908 100644 --- a/helper.php +++ b/helper.php @@ -1,42 +1,41 @@ 'AM', // american-us - '' => 'AR', // arabic - '' => 'DE', // german - '' => 'FR', // french - '' => 'GR', // greek (hellenic) - '' => 'IT', // italian - '' => 'MG', // malagasy - '' => 'NL', // dutch - '' => 'PL', // polish - '' => 'PT', // portuges - '' => 'SP', // spanish - '' => 'ARM' // armenian + 'en' => 'AM', // american-us + 'ar' => 'AR', // arabic + 'de' => 'DE', // german + 'fr' => 'FR', // french + 'el' => 'GR', // greek (hellenic) + 'it' => 'IT', // italian + 'mg' => 'MG', // malagasy + 'nl' => 'NL', // dutch + 'pl' => 'PL', // polish + 'pt' => 'PT', // portuges + 'es' => 'SP', // spanish + 'hy' => 'ARM' // armenian ); - if(array_key_exists($jlang, $apilang)) { - $lang = apilang[$jlang]; + if(array_key_exists($iso_lang, $apilang)) { + $result = $apilang[$iso_lang]; } - return $lang; + return $result; } /** @@ -45,25 +44,26 @@ public static function getAPIFormattedLanguage() { * @param type Inform about what you want to get * @access public */ - public static function getDataFromAPI($type = 'saint', $lang = 'AM') { + public static function getDataFromAPI($type = 'saint', $lang = 'en-GB') { + $result = false; + + $lang = self::translateISOLangToAPIFormat($lang); $date = date("Ymd"); - $url = "http:// feed.evangelizo.org/v2/reader.php?type=$type&lang=$lang&date=$date"; + $url = "http://feed.evangelizo.org/v2/reader.php?date=$date&type=$type&lang=$lang"; if(extension_loaded('curl') && function_exists('curl_init')) { - + $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); $result = curl_exec($ch); - curl_close($ch); - - } else { - - $stream = fopen($url, 'r'); + curl_close($ch); + + } else if ($stream = fopen($url, 'r')) { + // fopen fallback $result = stream_get_contents($stream); fclose($stream); - } return $result; diff --git a/mod_saintoftheday.php b/mod_saintoftheday.php index 6c2eee5..1b4647e 100644 --- a/mod_saintoftheday.php +++ b/mod_saintoftheday.php @@ -1,20 +1,26 @@ getTag(); +$params = new JRegistry(); +$params->loadString($module->params); + +$sod_title = ModSaintOfTheDayHelper::getDataFromAPI('liturgic_t', $lang); +$sod_list = ModSaintOfTheDayHelper::getDataFromAPI('saint', $lang); -$lang = ModSaintOfTheDayHelper::getAPIFormattedLanguage(); -$params = JFactory::getParams('mod_saintoftheday'); - -if($params->get('show_title')) { $sod_title = ModSaintOfTheDayHelper::getDataFromAPI('liturgic_t', $lang); } -if($params->get('show_list')) { $sod_list = ModSaintOfTheDayHelper::getDataFromAPI('saint', $lang); } \ No newline at end of file +require_once JModuleHelper::getLayoutPath('mod_saintoftheday'); \ No newline at end of file diff --git a/mod_saintoftheday.xml b/mod_saintoftheday.xml index 52fdd9a..a827cbd 100644 --- a/mod_saintoftheday.xml +++ b/mod_saintoftheday.xml @@ -3,42 +3,13 @@ Saint Of The Day Giovanni Mansillo 1.0.0 + GNU/GPLv3 http://www.gnu.org/licenses/gpl-3.0.html + https:// github.com/gmansillo/saintoftheday mod_saintoftheday.xml mod_saintoftheday.php index.html helper.php tmpl - lang - - - - - - - - - - - - - \ No newline at end of file diff --git a/tmpl/default.php b/tmpl/default.php index ebe1236..7f58c38 100644 --- a/tmpl/default.php +++ b/tmpl/default.php @@ -1,12 +1,21 @@ '.$sod_title.'

'; -if ($sod_list) echo '

'.$sod_list.'

'; +?> + +

+ +

+ +

+ +

\ No newline at end of file