]> git.mxchange.org Git - shipsimu.git/blobdiff - inc/classes/main/reader/class_DefaultNewsReader.php
More conventions than code added:
[shipsimu.git] / inc / classes / main / reader / class_DefaultNewsReader.php
index 7fa8ff2e6b813e0f20f17ab1f7a55c88f8e82f5a..d6b8fc9b08d4f031304ceb0f067a31a7784a200a 100644 (file)
@@ -4,7 +4,7 @@
  *
  * @author             Roland Haeder <webmaster@ship-simu.org>
  * @version            0.0.0
- * @copyright  Copyright(c) 2007, 2008 Roland Haeder, this is free software
+ * @copyright  Copyright (c) 2007, 2008 Roland Haeder, this is free software
  * @license            GNU GPL 3.0 or any newer version
  * @link               http://www.ship-simu.org
  *
  * You should have received a copy of the GNU General Public License
  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  */
-class DefaultNewsReader extends BaseFrameworkSystem implements ReadableNews {
+class DefaultNewsReader extends BaseFrameworkSystem implements ReadableNews, Registerable {
+       /**
+        * Result set with news
+        */
+       private $resultInstance = null;
+
        /**
         * Protected constructor
         *
@@ -66,7 +71,26 @@ class DefaultNewsReader extends BaseFrameworkSystem implements ReadableNews {
         * @return      void
         */
        public function initializeReader () {
-               // TODO Need to implement this method
+               // Get "page" for saving some calls
+               $page = $this->getRequestInstance()->getRequestElement('page');
+
+               // First get a wrapper instance
+               $wrapperInstance = ObjectFactory::createObjectByConfiguredName('news_db_wrapper_class');
+
+               // Next create a searchable criteria instance
+               $criteriaInstance = ObjectFactory::createObjectByConfiguredName('search_criteria_class');
+
+               // Add the page as criteria to it at lease
+               $criteriaInstance->addCriteria('page', $page);
+
+               // Add limitation from config
+               $criteriaInstance->setLimit($this->getConfigInstance()->readConfig("news_{$page}_limit"));
+
+               // Get a resultInstance back from the database
+               $resultInstance = $wrapperInstance->doSelectByCriteria($criteriaInstance);
+
+               // Save that resultInstance in this class
+               $this->resultInstance = $resultInstance;
        }
 }