diff options
Diffstat (limited to 'core/include')
-rw-r--r-- | core/include/feed/main.php | 16 | ||||
-rw-r--r-- | core/include/home.php | 8 | ||||
-rw-r--r-- | core/include/page/list.php | 8 | ||||
-rw-r--r-- | core/include/post/list.php | 8 | ||||
-rw-r--r-- | core/include/search/main.php | 8 | ||||
-rw-r--r-- | core/include/user/list.php | 13 |
6 files changed, 34 insertions, 27 deletions
diff --git a/core/include/feed/main.php b/core/include/feed/main.php index 765f296..59be3d1 100644 --- a/core/include/feed/main.php +++ b/core/include/feed/main.php @@ -17,12 +17,12 @@ if(!isset($param) OR $param !== 'page') { $POST['FEED_SORT'] = Application::get('POST.FEED_SORT'); $POST['FEED_SIZE'] = Application::get('POST.FEED_SIZE'); - $execSQL = "SELECT id FROM %s ORDER BY {$POST['FEED_SORT']} LIMIT {$POST['FEED_SIZE']}"; - $postIDs = $Database->query(sprintf($execSQL, Post\Attribute::TABLE))->fetchAll($Database::FETCH_COLUMN); + $execSQL = "SELECT * FROM %s ORDER BY {$POST['FEED_SORT']} LIMIT {$POST['FEED_SIZE']}"; + $Statement = $Database->query(sprintf($execSQL, Post\Attribute::TABLE)); - foreach($postIDs as $postID) { + while($Attribute = $Statement->fetchObject('Post\Attribute')) { try { - $Post = Post\Factory::build($postID); + $Post = Post\Factory::buildByAttribute($Attribute); $User = User\Factory::build($Post->attr('user')); $ItemTemplate = Template\Factory::build('feed/item_post'); @@ -44,12 +44,12 @@ if(!isset($param) OR $param !== 'post') { $PAGE['FEED_SORT'] = Application::get('PAGE.FEED_SORT'); $PAGE['FEED_SIZE'] = Application::get('PAGE.FEED_SIZE'); - $execSQL = "SELECT id FROM %s ORDER BY {$PAGE['FEED_SORT']} LIMIT {$PAGE['FEED_SIZE']}"; - $pageIDs = $Database->query(sprintf($execSQL, Page\Attribute::TABLE))->fetchAll($Database::FETCH_COLUMN); + $execSQL = "SELECT * FROM %s ORDER BY {$PAGE['FEED_SORT']} LIMIT {$PAGE['FEED_SIZE']}"; + $Statement = $Database->query(sprintf($execSQL, Page\Attribute::TABLE)); - foreach($pageIDs as $pageID) { + while($Attribute = $Statement->fetchObject('Page\Attribute')) { try { - $Page = Page\Factory::build($pageID); + $Page = Page\Factory::buildByAttribute($Attribute); $User = User\Factory::build($Page->attr('user')); $ItemTemplate = Template\Factory::build('feed/item_page'); diff --git a/core/include/home.php b/core/include/home.php index dfa2a36..fe732de 100644 --- a/core/include/home.php +++ b/core/include/home.php @@ -5,14 +5,12 @@ $Database = Application::getDatabase(); $Language = Application::getLanguage(); -$execSQL = 'SELECT id FROM %s ORDER BY '.Application::get('POST.LIST_SORT').' LIMIT '.Application::get('POST.LIST_SIZE'); +$execSQL = 'SELECT * FROM %s ORDER BY '.Application::get('POST.LIST_SORT').' LIMIT '.Application::get('POST.LIST_SIZE'); $Statement = $Database->query(sprintf($execSQL, Post\Attribute::TABLE)); -$postIDs = $Statement->fetchAll($Database::FETCH_COLUMN); - -foreach($postIDs as $postID) { +while($Attribute = $Statement->fetchObject('Post\Attribute')) { try { - $Post = Post\Factory::build($postID); + $Post = Post\Factory::buildByAttribute($Attribute); $User = User\Factory::build($Post->attr('user')); $ItemTemplate = generatePostItemTemplate($Post, $User); diff --git a/core/include/page/list.php b/core/include/page/list.php index 0165116..2bb2639 100644 --- a/core/include/page/list.php +++ b/core/include/page/list.php @@ -30,12 +30,12 @@ if(Application::get('PAGE.SINGLE_REDIRECT') === TRUE AND $count === '1') { HTTP::redirect($Page->getURL()); } -$execSQL = "SELECT id FROM %s ORDER BY {$site_sort} LIMIT ".(($currentSite-1) * $site_size).", {$site_size}"; -$pageIDs = $Database->query(sprintf($execSQL, Page\Attribute::TABLE))->fetchAll($Database::FETCH_COLUMN); +$execSQL = "SELECT * FROM %s ORDER BY {$site_sort} LIMIT ".(($currentSite-1) * $site_size).", {$site_size}"; +$Statement = $Database->query(sprintf($execSQL, Page\Attribute::TABLE)); -foreach($pageIDs as $pageID) { +while($Attribute = $Statement->fetchObject('Page\Attribute')) { try { - $Page = Page\Factory::build($pageID); + $Page = Page\Factory::buildByAttribute($Attribute); $User = User\Factory::build($Page->attr('user')); $ItemTemplate = generatePageItemTemplate($Page, $User); diff --git a/core/include/post/list.php b/core/include/post/list.php index 0f5ef1f..68183c7 100644 --- a/core/include/post/list.php +++ b/core/include/post/list.php @@ -30,12 +30,12 @@ if(Application::get('POST.SINGLE_REDIRECT') === TRUE AND $count === '1') { HTTP::redirect($Post->getURL()); } -$execSQL = "SELECT id FROM %s ORDER BY {$site_sort} LIMIT ".(($currentSite-1) * $site_size).", {$site_size}"; -$postIDs = $Database->query(sprintf($execSQL, Post\Attribute::TABLE))->fetchAll($Database::FETCH_COLUMN); +$execSQL = "SELECT * FROM %s ORDER BY {$site_sort} LIMIT ".(($currentSite-1) * $site_size).", {$site_size}"; +$Statement = $Database->query(sprintf($execSQL, Post\Attribute::TABLE)); -foreach($postIDs as $postID) { +while($Attribute = $Statement->fetchObject('Post\Attribute')) { try { - $Post = Post\Factory::build($postID); + $Post = Post\Factory::buildByAttribute($Attribute); $User = User\Factory::build($Post->attr('user')); $ItemTemplate = generatePostItemTemplate($Post, $User); diff --git a/core/include/search/main.php b/core/include/search/main.php index f1b0693..ac7e23a 100644 --- a/core/include/search/main.php +++ b/core/include/search/main.php @@ -11,7 +11,7 @@ $M_LIST = $Database->query(sprintf('SELECT DISTINCT MONTH(time_insert) AS temp F $Y_LIST = $Database->query(sprintf('SELECT DISTINCT YEAR(time_insert) AS temp FROM %s ORDER BY temp', Post\Attribute::TABLE)); if($search = HTTP::GET('q')) { - if(!$postIDs = Post\Item::getSearchResultIDs($search, [HTTP::GET('d'), HTTP::GET('m'), HTTP::GET('y')], $Database)) { + if(!$attributes = Post\Item::getSearchResults($search, [HTTP::GET('d'), HTTP::GET('m'), HTTP::GET('y')], $Database)) { $message = $Language->text('search_no_results', escapeHTML($search)); } } @@ -37,10 +37,10 @@ $search_data = [ #=============================================================================== # Build document #=============================================================================== -if(isset($postIDs) AND !empty($postIDs)) { - foreach($postIDs as $postID) { +if(isset($attributes) AND !empty($attributes)) { + foreach($attributes as $Attribute) { try { - $Post = Post\Factory::build($postID); + $Post = Post\Factory::buildByAttribute($Attribute); $User = User\Factory::build($Post->attr('user')); $posts[] = generatePostItemTemplate($Post, $User); diff --git a/core/include/user/list.php b/core/include/user/list.php index afc8179..72375a4 100644 --- a/core/include/user/list.php +++ b/core/include/user/list.php @@ -30,8 +30,17 @@ if(Application::get('USER.SINGLE_REDIRECT') === TRUE AND $count === '1') { HTTP::redirect($User->getURL()); } -$execSQL = "SELECT id FROM %s ORDER BY {$site_sort} LIMIT ".(($currentSite-1) * $site_size).", {$site_size}"; -$userIDs = $Database->query(sprintf($execSQL, User\Attribute::TABLE))->fetchAll($Database::FETCH_COLUMN); +$execSQL = "SELECT * FROM %s ORDER BY {$site_sort} LIMIT ".(($currentSite-1) * $site_size).", {$site_size}"; +$Statement = $Database->query(sprintf($execSQL, User\Attribute::TABLE)); + +while($Attribute = $Statement->fetchObject('User\Attribute')) { + try { + $User = User\Factory::buildByAttribute($Attribute); + $ItemTemplate = generateUserItemTemplate($User); + + $users[] = $ItemTemplate; + } catch(User\Exception $Exception){} +} foreach($userIDs as $userID) { try { |