-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f4693de
commit a16f692
Showing
3 changed files
with
60 additions
and
72 deletions.
There are no files selected for viewing
51 changes: 51 additions & 0 deletions
51
app/code/community/TM/Core/Model/Resource/Module/Collection/Abstract.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
<?php | ||
|
||
class TM_Core_Model_Resource_Module_Collection_Abstract extends Varien_Data_Collection | ||
{ | ||
protected $_collectedModules = array(); | ||
|
||
/** | ||
* Lauch data collecting | ||
* | ||
* @param bool $printQuery | ||
* @param bool $logQuery | ||
* @return TM_Core_Model_Resource_Module_Collection_Abstract | ||
*/ | ||
public function loadData($printQuery = false, $logQuery = false) | ||
{ | ||
if ($this->isLoaded()) { | ||
return $this; | ||
} | ||
|
||
$this->_collectedModules = $this->_loadModules(); | ||
|
||
// calculate totals | ||
$this->_totalRecords = count($this->_collectedModules); | ||
$this->_setIsLoaded(); | ||
|
||
// paginate and add items | ||
$from = ($this->getCurPage() - 1) * $this->getPageSize(); | ||
$to = $from + $this->getPageSize() - 1; | ||
$isPaginated = $this->getPageSize() > 0; | ||
|
||
$cnt = 0; | ||
foreach ($this->_collectedModules as $row) { | ||
$cnt++; | ||
if ($isPaginated && ($cnt < $from || $cnt > $to)) { | ||
continue; | ||
} | ||
$item = new $this->_itemObjectClass(); | ||
$this->addItem($item->addData($row)); | ||
if (!$item->hasId()) { | ||
$item->setId($cnt); | ||
} | ||
} | ||
|
||
return $this; | ||
} | ||
|
||
protected function _loadModules() | ||
{ | ||
return array(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters