]> git.mxchange.org Git - hub.git/commitdiff
Merge branch 'master' into refacuring/protocol_handler
authorRoland Haeder <roland@mxchange.org>
Sun, 7 Dec 2014 22:30:22 +0000 (23:30 +0100)
committerRoland Haeder <roland@mxchange.org>
Sun, 7 Dec 2014 22:30:22 +0000 (23:30 +0100)
Signed-off-by: Roland Haeder <roland@mxchange.org>
Conflicts:
application/hub/config.php
application/hub/interfaces/resolver/.htaccess
application/hub/main/nodes/class_BaseHubNode.php
application/hub/main/resolver/protocol/class_BaseProtocolResolver.php
application/hub/main/source/urls/class_CrawlerUploadedListUrlSource.php

1  2 
application/hub/config.php
application/hub/main/source/urls/class_CrawlerUploadedListUrlSource.php

Simple merge
index c98aa6ff039e347b3a808259f5b93a6ff702f77f,ec77631f0c64191c4ca852d3974b6e1f97ca667c..5b1814594a3b565105a4a83f92c4d48c866637cb
@@@ -57,22 -94,21 +78,25 @@@ class CrawlerUploadedListUrlSource exte
         * @return      $isFound        Whether a CSV file is found
         */
        private function isCsvFileFound () {
 -              // Is the instance valid?
+               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('CRAWLER-SOURCE [' . __METHOD__ . ':' . __LINE__ . ']: CALLED!');
 +              // Is it valid?
                if (!$this->getDirectoryInstance()->getDirectoryIteratorInstance()->valid()) {
 -                      // Then rewind it
 +                      // Rewind to start
                        $this->getDirectoryInstance()->getDirectoryIteratorInstance()->rewind();
                } // END - if
  
                // Read next entry
-               $directoryEntry = $this->getDirectoryInstance()->readDirectoryExcept(array('.htaccess', '.', '..'));
+               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('CRAWLER-SOURCE [' . __METHOD__ . ':' . __LINE__ . ']: this->csvFileImported=' . print_r($this->csvFileImported, TRUE));
+               $directoryEntry = $this->getDirectoryInstance()->readDirectoryExcept(array_merge(array('.htaccess', '.', '..'), $this->csvFileImported));
  
 -              // The read entry has not to be empty and extension must be '.csv'
 +              // Debug message
 +              /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('SOURCE[' . __METHOD__ . ':' . __LINE__ . '] directoryEntry(' . strlen($directoryEntry) . ')=' . $directoryEntry);
 +
 +              // Is it empty or wrong file extension?
                if ((empty($directoryEntry)) || (substr($directoryEntry, -4, 4) != '.csv')) {
                        // Skip further processing
 +                      /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('SOURCE[' . __METHOD__ . ':' . __LINE__ . '] directoryEntry(' . strlen($directoryEntry) . ')=' . $directoryEntry . ' - SKIPPED!');
                        return FALSE;
                } // END - if
  
                return TRUE;
        }
  
-               // Get a ??? @TODO
 +      /**
 +       * Creates an instance of this class
 +       *
 +       * @return      $sourceInstance         An instance of a Source class
 +       */
 +      public final static function createCrawlerUploadedListUrlSource () {
 +              // Get new instance
 +              $sourceInstance = new CrawlerUploadedListUrlSource();
 +
 +              // Init source
 +              $sourceInstance->initSource('crawler', 'uploaded_list');
 +
 +              // Return the prepared instance
 +              return $sourceInstance;
 +      }
 +
+       /**
+        * Initializes the import of the CSV file which is being processed by other task
+        *
+        * @return      void
+        * @throws      NullPointerException    If lastCsvFileInstance is not set
+        */
+       private function importCsvFile () {
+               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('CRAWLER-SOURCE [' . __METHOD__ . ':' . __LINE__ . ']: CALLED!');
+               // Is the instance set?
+               if (is_null($this->lastCsvFileInstance)) {
+                       // This should not happen
+                       throw new NullPointerException($this, self::EXCEPTION_IS_NULL_POINTER);
+               } // END - if
+               // Stack this file
+               $this->getStackSourceInstance()->pushNamed(self::STACK_NAME_CSV_FILE, $this->lastCsvFileInstance);
+               // ... and mark it as "imported"
+               array_push($this->csvFileImported, basename($this->lastCsvFileInstance->getFileName()));
+               // ... and finally NULL it (to save some RAM)
+               $this->lastCsvFileInstance = NULL;
+               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('CRAWLER-SOURCE [' . __METHOD__ . ':' . __LINE__ . ']: EXIT!');
+       }
+       /**
+        * Getter for stackSourceInstance variable
+        *
+        * @return      $stackSourceInstance    An instance of an additional stack
+        */
+       public final function getStackSourceInstance () {
+               return $this->stackSourceInstance;
+       }
        /**
         * Processes entries in the stack.
         *