]> git.mxchange.org Git - hub.git/commitdiff
Continued with crawler:
authorRoland Haeder <roland@mxchange.org>
Fri, 6 Mar 2015 23:26:35 +0000 (00:26 +0100)
committerRoland Haeder <roland@mxchange.org>
Fri, 6 Mar 2015 23:26:35 +0000 (00:26 +0100)
- The indexed array needs to be converted to assoziative as other URL sources
  may use index X for something else.
- Renamed $isLoaded to $isAdded as it fits more
- Updated 'core' to latest commit

Signed-off-by: Roland Haeder <roland@mxchange.org>
application/hub/main/source/class_BaseUrlSource.php
application/hub/main/source/urls/class_CrawlerUploadedListUrlSource.php
core

index 7269884155675f09024422bba20edc50b7a2c49c..18286ba28a81fc05f181798a53119cf5e775d4fc 100644 (file)
  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  */
 class BaseUrlSource extends BaseSource {
+       // Array elements for CSV data array
+       const CRAWL_JOB_ARRAY_START_URL      = 'start_url';
+       const CRAWL_JOB_ARRAY_DEPTH          = 'start_depth';
+       const CRAWL_JOB_ARRAY_EXTERNAL_DEPTH = 'external_depth';
+
        /**
         * Protected constructor
         *
index 02ff77f32eb81c9c73f8f766db080acb776dc264..dd5ff03bcd9db1761e5ecaa168adc93abde7042b 100644 (file)
@@ -161,6 +161,20 @@ class CrawlerUploadedListUrlSource extends BaseUrlSource implements UrlSource, R
                // Debug message
                /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('CRAWLER-SOURCE [' . __METHOD__ . ':' . __LINE__ . ']: csvData()=' . count($csvData) . ' - CALLED!');
 
+               // The array has 3 elements, later enhancements may accept more
+               assert(count($csvData) == self::CRAWL_ENTRY_SIZE);
+
+               /*
+                * First converted the indexed array into an assoziative array. Don't
+                * forget to expand this array as well when you want to add another
+                * column to the CSV file.
+                */
+               $csvArray = array(
+                       self::CRAWL_JOB_ARRAY_START_URL      => $csvData[0],
+                       self::CRAWL_JOB_ARRAY_DEPTH          => $csvData[1],
+                       self::CRAWL_JOB_ARRAY_EXTERNAL_DEPTH => $csvData[2]
+               );
+
                // Debug message
                /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('CRAWLER-SOURCE [' . __METHOD__ . ':' . __LINE__ . ']: EXIT!');
        }
@@ -168,27 +182,27 @@ class CrawlerUploadedListUrlSource extends BaseUrlSource implements UrlSource, R
        /**
         * Checks whether a CSV file has been loaded (added to the stack)
         *
-        * @return      $isLoaded       Whether a CSV file has been loaded
+        * @return      $isAdded        Whether a CSV file has been loaded
         */
        private function isCsvFileAdded () {
                // Check whether the stacker is not empty
-               $isLoaded = (($this->getStackSourceInstance()->isStackInitialized(self::STACK_NAME_CSV_FILE)) && (!$this->getStackSourceInstance()->isStackEmpty(self::STACK_NAME_CSV_FILE)));
+               $isAdded = (($this->getStackSourceInstance()->isStackInitialized(self::STACK_NAME_CSV_FILE)) && (!$this->getStackSourceInstance()->isStackEmpty(self::STACK_NAME_CSV_FILE)));
 
                // Return the result
-               return $isLoaded;
+               return $isAdded;
        }
 
        /**
         * Checks whether a CSV entry has been added to the stack
         *
-        * @return      $isLoaded       Whether a CSV entry has been added
+        * @return      $isAdded        Whether a CSV entry has been added
         */
        private function isCsvEntryAdded () {
                // Check whether the stacker is not empty
-               $isLoaded = (($this->getStackSourceInstance()->isStackInitialized(self::STACK_NAME_CSV_ENTRY)) && (!$this->getStackSourceInstance()->isStackEmpty(self::STACK_NAME_CSV_ENTRY)));
+               $isAdded = (($this->getStackSourceInstance()->isStackInitialized(self::STACK_NAME_CSV_ENTRY)) && (!$this->getStackSourceInstance()->isStackEmpty(self::STACK_NAME_CSV_ENTRY)));
 
                // Return the result
-               return $isLoaded;
+               return $isAdded;
        }
 
        /**
diff --git a/core b/core
index f9d9f2a93c091cb3d6381927d4d20293207a9e30..23d0a889351670874a4b120e1487edf89dc1b540 160000 (submodule)
--- a/core
+++ b/core
@@ -1 +1 @@
-Subproject commit f9d9f2a93c091cb3d6381927d4d20293207a9e30
+Subproject commit 23d0a889351670874a4b120e1487edf89dc1b540