From 752c242560c8276f27d6a8120d6bd1f8a7b2b4ab Mon Sep 17 00:00:00 2001 From: Roland Haeder Date: Sat, 7 Mar 2015 00:26:35 +0100 Subject: [PATCH] Continued with crawler: - 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 --- .../hub/main/source/class_BaseUrlSource.php | 5 ++++ .../class_CrawlerUploadedListUrlSource.php | 26 ++++++++++++++----- core | 2 +- 3 files changed, 26 insertions(+), 7 deletions(-) diff --git a/application/hub/main/source/class_BaseUrlSource.php b/application/hub/main/source/class_BaseUrlSource.php index 726988415..18286ba28 100644 --- a/application/hub/main/source/class_BaseUrlSource.php +++ b/application/hub/main/source/class_BaseUrlSource.php @@ -22,6 +22,11 @@ * along with this program. If not, see . */ 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 * diff --git a/application/hub/main/source/urls/class_CrawlerUploadedListUrlSource.php b/application/hub/main/source/urls/class_CrawlerUploadedListUrlSource.php index 02ff77f32..dd5ff03bc 100644 --- a/application/hub/main/source/urls/class_CrawlerUploadedListUrlSource.php +++ b/application/hub/main/source/urls/class_CrawlerUploadedListUrlSource.php @@ -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 f9d9f2a93..23d0a8893 160000 --- a/core +++ b/core @@ -1 +1 @@ -Subproject commit f9d9f2a93c091cb3d6381927d4d20293207a9e30 +Subproject commit 23d0a889351670874a4b120e1487edf89dc1b540 -- 2.39.2