* fix square categories.
This commit is contained in:
@@ -219,12 +219,11 @@ class ai extends control
|
||||
}
|
||||
else if($category === 'discovery')
|
||||
{
|
||||
$popularIDs = $this->ai->getPopularMiniProgramIDs($pager);
|
||||
$miniPrograms = $this->ai->getMiniProgramsByID($popularIDs);
|
||||
$miniPrograms = $this->ai->getMiniPrograms('', 'active', 'createdDate_desc', $pager);
|
||||
}
|
||||
else if($category === 'latest')
|
||||
{
|
||||
$miniPrograms = $this->ai->getMiniPrograms('', 'active', 'createdDate_desc', $pager);
|
||||
$miniPrograms = $this->ai->getLatestMiniPrograms($pager);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -239,10 +238,14 @@ class ai extends control
|
||||
if(in_array($key, $usedCustomCategories)) $usedCustomCategoryList[$key] = $value;
|
||||
}
|
||||
$squareCategories = $this->lang->ai->miniPrograms->squareCategories;
|
||||
unset($squareCategories['collection']);
|
||||
$this->view->collectedIDs = empty($collectedIDs) ? $this->ai->getCollectedMiniProgramIDs($this->app->user->id) : $collectedIDs;
|
||||
$latestSum = $this->ai->countLatestMiniPrograms();
|
||||
if(empty($collectedIDs)) $collectedIDs = $this->ai->getCollectedMiniProgramIDs($this->app->user->id);
|
||||
if(empty($collectedIDs)) unset($squareCategories['collection']);
|
||||
if($latestSum == 0) unset($squareCategories['latest']);
|
||||
|
||||
$this->view->collectedIDs = $collectedIDs;
|
||||
$this->view->category = $category;
|
||||
$this->view->categoryList = empty($this->view->collectedIDs) ? array_merge($squareCategories, $usedCustomCategoryList) : array_merge($this->lang->ai->miniPrograms->squareCategories, $usedCustomCategoryList);
|
||||
$this->view->categoryList = array_merge($squareCategories, $usedCustomCategoryList);
|
||||
$this->view->pager = $pager;
|
||||
$this->view->miniPrograms = $miniPrograms ?: array();
|
||||
$this->view->title = $this->lang->ai->miniPrograms->common;
|
||||
|
||||
+19
-7
@@ -312,20 +312,32 @@ class aiModel extends model
|
||||
}
|
||||
|
||||
/**
|
||||
* Get popular mini programIDs.
|
||||
* Get latest mini programs.
|
||||
*
|
||||
* @param pager $pager
|
||||
* @access public
|
||||
* @return array
|
||||
*/
|
||||
public function getPopularMiniProgramIDs($pager = null)
|
||||
public function getLatestMiniPrograms($pager = null, $order = 'createdDate_desc')
|
||||
{
|
||||
$paris = $this->dao->select('appID, COUNT(*) AS count')->from(TABLE_MINIPROGRAMSTAR)
|
||||
->groupBy('appID')
|
||||
->orderBy('count_desc')
|
||||
return $this->dao->select('*')
|
||||
->from(TABLE_MINIPROGRAM)
|
||||
->where('deleted')->eq('0')
|
||||
->andWhere('published')->eq('1')
|
||||
->andWhere('createdDate')->ge(date('Y-m-d H:i:s', strtotime('-3 months')))
|
||||
->orderBy($order)
|
||||
->page($pager)
|
||||
->fetchPairs();
|
||||
return array_keys($paris);
|
||||
->fetchAll();
|
||||
}
|
||||
|
||||
public function countLatestMiniPrograms()
|
||||
{
|
||||
return $this->dao->select('COUNT(*) as count')
|
||||
->from(TABLE_MINIPROGRAM)
|
||||
->where('deleted')->eq('0')
|
||||
->andWhere('published')->eq('1')
|
||||
->andWhere('createdDate')->ge(date('Y-m-d H:i:s', strtotime('-3 months')))
|
||||
->fetch('count');
|
||||
}
|
||||
|
||||
public function saveMiniProgramMessage($appID, $type, $content)
|
||||
|
||||
@@ -77,6 +77,7 @@ $star = in_array($miniProgram->id, $collectedIDs) ? 'star' : 'star-empty';
|
||||
$delete = $star === 'star' ? 'true' : 'false';
|
||||
|
||||
btn(
|
||||
setClass('hidden'),
|
||||
setID('open-dialog'),
|
||||
setData('toggle', 'modal'),
|
||||
setData('target', '#disabled-dialog')
|
||||
|
||||
Reference in New Issue
Block a user