]> git.mxchange.org Git - mailer.git/blobdiff - inc/classes/main/reader/class_DefaultNewsReader.php
Code base synced
[mailer.git] / inc / classes / main / reader / class_DefaultNewsReader.php
index 7fa8ff2e6b813e0f20f17ab1f7a55c88f8e82f5a..b0dbac671522f27e7c59cfcd5acb18fae4aeda2c 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
  *
@@ -19,9 +19,9 @@
  * GNU General Public License for more details.
  *
  * You should have received a copy of the GNU General Public License
- * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ * 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 {
        /**
         * Protected constructor
         *
@@ -31,12 +31,6 @@ class DefaultNewsReader extends BaseFrameworkSystem implements ReadableNews {
                // Call parent constructor
                parent::__construct(__CLASS__);
 
-               // Set part description
-               $this->setObjectDescription("Default news reader");
-
-               // Create unique ID number
-               $this->generateUniqueId();
-
                // Clean up a little
                $this->removeNumberFormaters();
                $this->removeSystemArray();
@@ -66,7 +60,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->setResultInstance($resultInstance);
        }
 }