public static function is_connection_ok() { $mod = cms_utils::get_module('ModuleManager'); $url = $mod->GetPreference('module_repository'); if ($url) { $url .= 'version'; $req = new modmgr_cached_request($url); $req->setTimeout(3); $req->execute($url); if ($req->getStatus() == 200) { $tmp = $req->getResult(); if (empty($tmp)) { $req->clearCache(); return FALSE; } $data = json_decode($req->getResult(), true); if (version_compare($data, MINIMUM_REPOSITORY_VERSION) >= 0) { return TRUE; } } } return FALSE; }
public static function search($term, $advanced) { $qparms = array(); $filter = array(); $filter['term'] = $term; $filter['advanced'] = (int) $advanced; $filter['newest'] = 1; $filter['sortby'] = 'score'; $qparms['filter'] = $filter; $qparms['clientcmsversion'] = CMS_VERSION; $mod = cms_utils::get_module('ModuleManager'); $url = $mod->GetPreference('module_repository'); if ($url == '') { return array(FALSE, $mod->Lang('error_norepositoryurl')); } $url .= '/modulesearch'; $req = new modmgr_cached_request(); $req->execute($url, array('json' => json_encode($qparms))); $status = $req->getStatus(); $result = $req->getResult(); if ($status != 200 || $result == '') { return array(FALSE, $mod->Lang('error_request_problem')); } $data = json_decode($result, true); return array(TRUE, $data); }