* Fix bug #32593.
This commit is contained in:
+83
-49
@@ -506,7 +506,7 @@ class adminModel extends model
|
||||
}
|
||||
|
||||
/**
|
||||
* Get extensions from zentao.net.
|
||||
* Set extensions from zentao.net.
|
||||
*
|
||||
* @param string $type plugin|patch
|
||||
* @param int $limit
|
||||
@@ -514,44 +514,22 @@ class adminModel extends model
|
||||
* @access public
|
||||
* @return array
|
||||
*/
|
||||
public function getExtensionsByAPI($type = 'plugin', $limit = 6, $hasInternet = false)
|
||||
public function setExtensionsByAPI($type = 'plugin', $limit = 5)
|
||||
{
|
||||
if($hasInternet)
|
||||
$searchType = $type == 'plugin' ? 'byModule,offcial' : 'byModule';
|
||||
$param = $type == 'plugin' ? '' : 'MTIxOA==';
|
||||
$extensions = $this->loadModel('extension')->getExtensionsByAPI($searchType, $param, 0, $limit);
|
||||
$extensions = isset($extensions->extensions) ? (array)$extensions->extensions : array();
|
||||
$plugins = array();
|
||||
foreach($extensions as $extension)
|
||||
{
|
||||
$searchType = $type == 'plugin' ? 'byModule,offcial' : 'byModule';
|
||||
$param = $type == 'plugin' ? '' : 'MTIxOA==';
|
||||
$extensions = $this->loadModel('extension')->getExtensionsByAPI($searchType, $param, 0, $limit);
|
||||
$extensions = isset($extensions->extensions) ? (array)$extensions->extensions : array();
|
||||
$plugins = array();
|
||||
foreach($extensions as $extension)
|
||||
{
|
||||
if($type == 'patch' and !isset($extension->compatibleRelease)) continue;
|
||||
if($type == 'patch' and !isset($extension->compatibleRelease)) continue;
|
||||
|
||||
$extension->viewLink = str_replace(array('info', 'client'), '', $extension->viewLink);
|
||||
$plugins[] = $extension;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if($this->config->edition == 'open')
|
||||
{
|
||||
$plugins = array(
|
||||
$this->config->admin->plugins[27],
|
||||
$this->config->admin->plugins[26],
|
||||
$this->config->admin->plugins[30]
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
$plugins = array(
|
||||
$this->config->admin->plugins[198],
|
||||
$this->config->admin->plugins[194],
|
||||
$this->config->admin->plugins[203]
|
||||
);
|
||||
}
|
||||
$extension->viewLink = str_replace(array('info', 'client'), '', $extension->viewLink);
|
||||
$plugins[] = $extension;
|
||||
}
|
||||
|
||||
return $plugins;
|
||||
return $this->loadModel('block')->setZentaoData($type, $plugins);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -575,13 +553,13 @@ class adminModel extends model
|
||||
}
|
||||
|
||||
/**
|
||||
* Get public class from zentao.net.
|
||||
* Set public class from zentao.net.
|
||||
*
|
||||
* @param int $limit
|
||||
* @access public
|
||||
* @return array
|
||||
* @return void
|
||||
*/
|
||||
public function getPublicClassByAPI($limit = 2)
|
||||
public function setPublicClassByAPI($limit = 3)
|
||||
{
|
||||
$apiURL = $this->config->admin->videoAPIURL;
|
||||
$data = $this->fetchAPI($apiURL);
|
||||
@@ -599,24 +577,25 @@ class adminModel extends model
|
||||
$publicClass[$index]->viewLink = $this->config->admin->apiRoot . '/publicclass/' . ($course->alias ? "{$course->alias}-" : '') . "{$course->id}.html";
|
||||
$index ++;
|
||||
}
|
||||
return $publicClass;
|
||||
|
||||
return $this->loadModel('block')->setZentaoData('publicclass', $publicClass);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get dynamics by API.
|
||||
* Set dynamics by API.
|
||||
*
|
||||
* @param int $limit
|
||||
* @access public
|
||||
* @return array
|
||||
* @return void
|
||||
*/
|
||||
public function getDynamicsByAPI($limit = 2)
|
||||
public function setDynamicsByAPI($limit = 2)
|
||||
{
|
||||
$apiURL = $this->config->admin->downloadAPIURL;
|
||||
$data = $this->fetchAPI($apiURL);
|
||||
$articles = $data->articles;
|
||||
|
||||
$index = 1;
|
||||
$downloads = array();
|
||||
$index = 1;
|
||||
$news = array();
|
||||
foreach($articles as $article)
|
||||
{
|
||||
if($index > $limit) break;
|
||||
@@ -625,14 +604,15 @@ class adminModel extends model
|
||||
if(!isset($this->lang->admin->$tagKey)) break;
|
||||
if(!preg_match("/{$this->lang->admin->$tagKey}\d/", $article->title)) continue;
|
||||
|
||||
$downloads[$index] = new stdClass();
|
||||
$downloads[$index]->id = $article->id;
|
||||
$downloads[$index]->title = $article->title;
|
||||
$downloads[$index]->addedDate = $article->addedDate;
|
||||
$downloads[$index]->link = $this->config->admin->apiRoot . "/download/{$article->alias}-{$article->id}.html";
|
||||
$news[$index] = new stdClass();
|
||||
$news[$index]->id = $article->id;
|
||||
$news[$index]->title = $article->title;
|
||||
$news[$index]->addedDate = $article->addedDate;
|
||||
$news[$index]->link = $this->config->admin->apiRoot . "/download/{$article->alias}-{$article->id}.html";
|
||||
$index ++;
|
||||
}
|
||||
return $downloads;
|
||||
|
||||
return $this->loadModel('block')->setZentaoData('news', $news);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -674,4 +654,58 @@ class adminModel extends model
|
||||
|
||||
return helper::getDateInterval($firstUseDate);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get zentao.net data.
|
||||
*
|
||||
* @access public
|
||||
* @return object
|
||||
*/
|
||||
public function getZentaoData()
|
||||
{
|
||||
$zentaoData = $this->loadModel('block')->getZentaoData();
|
||||
|
||||
$data = new stdclass();
|
||||
$data->hasData = true;
|
||||
|
||||
$news = array();
|
||||
$publicclass = array();
|
||||
$plugins = array();
|
||||
$patches = array();
|
||||
if(empty($zentaoData))
|
||||
{
|
||||
$data->hasData = false;
|
||||
if($this->config->edition == 'open')
|
||||
{
|
||||
$plugins = array(
|
||||
$this->config->admin->plugins[27],
|
||||
$this->config->admin->plugins[26],
|
||||
$this->config->admin->plugins[30]
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
$plugins = array(
|
||||
$this->config->admin->plugins[198],
|
||||
$this->config->admin->plugins[194],
|
||||
$this->config->admin->plugins[203]
|
||||
);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$news = json_decode($zentaoData['news']);
|
||||
$publicclass = json_decode($zentaoData['publicclass']);
|
||||
$plugins = json_decode($zentaoData['plugin']);
|
||||
$patches = json_decode($zentaoData['patch']);
|
||||
if(common::checkNotCN()) array_pop($plugins);
|
||||
}
|
||||
|
||||
$data->news = $news;
|
||||
$data->publicclass = $publicclass;
|
||||
$data->plugins = $plugins;
|
||||
$data->patches = $patches;
|
||||
|
||||
return $data;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user