Sometimes 'page' is wanted, sometimes 'command' but basicly both want a command
[core.git] / inc / classes / main / reader / class_ConsoleNewsReader.php
index 0240b74da57e77a262cce8181f67735205b307c1..9f5cc8e5a1088ce40397a35b06413510f59a9a06 100644 (file)
@@ -1,12 +1,12 @@
 <?php
 /**
 <?php
 /**
- * A default news reader class reads news from database layer
+ * A console news reader class reads news from database layer
  *
  *
- * @author             Roland Haeder <webmaster@ship-simu.org>
+ * @author             Roland Haeder <webmaster@shipsimu.org>
  * @version            0.0.0
  * @version            0.0.0
- * @copyright  Copyright (c) 2007, 2008 Roland Haeder, 2009 Core Developer Team
+ * @copyright  Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team
  * @license            GNU GPL 3.0 or any newer version
  * @license            GNU GPL 3.0 or any newer version
- * @link               http://www.ship-simu.org
+ * @link               http://www.shipsimu.org
  *
  * This program is free software: you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
  *
  * This program is free software: you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -21,7 +21,7 @@
  * You should have received a copy of the GNU General Public License
  * along with this program. If not, see <http://www.gnu.org/licenses/>.
  */
  * 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, Registerable {
+class ConsoleNewsReader extends BaseFrameworkSystem implements ReadableNews, Registerable {
        /**
         * Protected constructor
         *
        /**
         * Protected constructor
         *
@@ -30,10 +30,6 @@ class DefaultNewsReader extends BaseFrameworkSystem implements ReadableNews, Reg
        protected function __construct () {
                // Call parent constructor
                parent::__construct(__CLASS__);
        protected function __construct () {
                // Call parent constructor
                parent::__construct(__CLASS__);
-
-               // Clean up a little
-               $this->removeNumberFormaters();
-               $this->removeSystemArray();
        }
 
        /**
        }
 
        /**
@@ -42,9 +38,9 @@ class DefaultNewsReader extends BaseFrameworkSystem implements ReadableNews, Reg
         * @param       $requestInstance        An instance of a Requestable class
         * @return      $readerInstance         An instance of this reader class
         */
         * @param       $requestInstance        An instance of a Requestable class
         * @return      $readerInstance         An instance of this reader class
         */
-       public final static function createDefaultNewsReader (Requestable $requestInstance) {
+       public static final function createConsoleNewsReader (Requestable $requestInstance) {
                // Get a new instance
                // Get a new instance
-               $readerInstance = new DefaultNewsReader();
+               $readerInstance = new ConsoleNewsReader();
 
                // Set request instance
                $readerInstance->setRequestInstance($requestInstance);
 
                // Set request instance
                $readerInstance->setRequestInstance($requestInstance);
@@ -54,14 +50,14 @@ class DefaultNewsReader extends BaseFrameworkSystem implements ReadableNews, Reg
        }
 
        /**
        }
 
        /**
-        * Initializes this reader class by pre-fetching news depending on 'page'
+        * Initializes this reader class by pre-fetching news depending on 'command'
         * (outside or login area), which amount of news and how much to skip
         *
         * @return      void
         */
        public function initializeReader () {
         * (outside or login area), which amount of news and how much to skip
         *
         * @return      void
         */
        public function initializeReader () {
-               // Get 'page' for saving some calls
-               $page = $this->getRequestInstance()->getRequestElement('page');
+               // Get 'command' for saving some calls
+               $command = $this->getRequestInstance()->getRequestElement('command');
 
                // First get a wrapper instance
                $wrapperInstance = ObjectFactory::createObjectByConfiguredName('news_db_wrapper_class');
 
                // First get a wrapper instance
                $wrapperInstance = ObjectFactory::createObjectByConfiguredName('news_db_wrapper_class');
@@ -69,11 +65,11 @@ class DefaultNewsReader extends BaseFrameworkSystem implements ReadableNews, Reg
                // Next create a searchable criteria instance
                $criteriaInstance = ObjectFactory::createObjectByConfiguredName('search_criteria_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 the command as criteria to it at lease
+               $criteriaInstance->addCriteria('command', $command);
 
                // Add limitation from config
 
                // Add limitation from config
-               $criteriaInstance->setLimit($this->getConfigInstance()->readConfig('news_' . $page . '_limit'));
+               $criteriaInstance->setConfiguredLimit('news_' . $command . '_limit');
 
                // Get a resultInstance back from the database
                $resultInstance = $wrapperInstance->doSelectByCriteria($criteriaInstance);
 
                // Get a resultInstance back from the database
                $resultInstance = $wrapperInstance->doSelectByCriteria($criteriaInstance);