protected function loadFeedData()
 {
     $feeds = parent::loadFeedData();
     foreach ($feeds as $sport => &$sportData) {
         $localizedKey = sprintf("%s_BOOKMARK", strtoupper($sportData['GENDER']));
         $sportData['GENDER_TITLE'] = $this->getLocalizedString($localizedKey, $sportData['TITLE']);
     }
     return $feeds;
 }
Exemple #2
0
    {
        case 1:
            throw new Exception("Invalid API request: '{$_SERVER['REQUEST_URI']}'", 1);

        case 2: 
            $id = 'core';
            $command = $parts[1];
            if (!$module = CoreAPIModule::factory($command, $args)) {
                throw new Exception("Module $id cannot be loaded");
            }
            break;
            
        case 3:
            $id = isset($parts[1]) ? $parts[1] : '';
            $command = isset($parts[2]) ? $parts[2] : '';
            if (!$module = APIModule::factory($id, $command, $args)) {
                throw new Exception("Module $id cannot be loaded");
            }
            break;

        default:
            throw new Exception("Invalid API request: '{$_SERVER['REQUEST_URI']}'", 1);
            break;
    }    

    /* log the api call */
    PageViews::log_api($id, Kurogo::deviceClassifier()->getPlatform());
    $module->executeCommand();

    
} else {
 public static function getAllModules()
 {
     $dirs = array(MODULES_DIR, SITE_MODULES_DIR);
     $modules = array('core' => CoreAPIModule::factory());
     foreach ($dirs as $dir) {
         if (is_dir($dir)) {
             $d = dir($dir);
             while (false !== ($entry = $d->read())) {
                 if ($entry[0] != '.' && is_dir(sprintf("%s/%s", $dir, $entry))) {
                     try {
                         if ($module = APIModule::factory($entry)) {
                             $modules[$entry] = $module;
                         }
                     } catch (KurogoException $e) {
                     }
                 }
             }
             $d->close();
         }
     }
     ksort($modules);
     return $modules;
 }
 public function isEnabled()
 {
     return Kurogo::getSiteVar('AUTHENTICATION_ENABLED') && parent::isEnabled();
 }
Exemple #5
0
 public static function initStatsResult(KurogoStatsOption $OptionObject)
 {
     $result = array();
     foreach ($OptionObject->getGroup() as $group) {
         switch ($group) {
             case 'moduleID':
                 if ($OptionObject->getService() == 'web') {
                     $moduleData = WebModule::getAllModules();
                 } else {
                     $moduleData = APIModule::getAllModules();
                 }
                 $result = array_combine(array_keys($moduleData), array_fill(0, count($moduleData), 0));
                 break;
             case 'platform':
                 $platforms = self::$platforms;
                 $result = array_combine(array_keys($platforms), array_fill(0, count($platforms), 0));
                 break;
             case 'pagetype':
                 $pagetypes = self::$pagetypes;
                 $result = array_combine(array_keys($pagetypes), array_fill(0, count($pagetypes), 0));
                 break;
             case 'hour':
                 $result = array_combine(range(0, 23), array_fill(0, 24, 0));
                 break;
         }
     }
     return $result;
 }
 public static function isValidModuleID($service, $moduleID)
 {
     static $allModuleData = array('web' => array(), 'api' => array());
     $moduleData = array();
     if (isset($allModuleData[$service]) && !empty($allModuleData[$service])) {
         $moduleData = $allModuleData[$service];
     }
     if (!$moduleData) {
         if ($service == 'web') {
             $allModuleData['web'] = WebModule::getAllModules();
             $moduleData = $allModuleData['web'];
         } else {
             $allModuleData['api'] = APIModule::getAllModules();
             $moduleData = $allModuleData['api'];
         }
     }
     return isset($moduleData[$moduleID]) ? true : false;
 }
 public static function getAllModules()
 {
     $configFiles = glob(SITE_CONFIG_DIR . "/*/module.ini");
     $modules = array();
     foreach ($configFiles as $file) {
         if (preg_match("#" . preg_quote(SITE_CONFIG_DIR, "#") . "/([^/]+)/module.ini\$#", $file, $bits)) {
             $id = $bits[1];
             try {
                 if ($module = APIModule::factory($id)) {
                     $modules[$id] = $module;
                 }
             } catch (KurogoException $e) {
             }
         }
     }
     ksort($modules);
     return $modules;
 }