Exemple #1
0
 protected function process_data(&$signal)
 {
     parent::process_data($signal);
     $id = $signal->data_blockid($this->default_data_key);
     if (is_null($this->id)) {
         return false;
     }
     $params = array('prop' => $this->prop, 'ids' => $id);
     require_once dirname(__FILE__) . '/../../../../core/queries/list/blocks.php';
     $query = new Query_List_Blocks($this->core);
     $block = $query->go($params);
     $result = $this->set_fetched_data($signal, $block);
     $this->set_jobdata($result, array('id' => $id, 'prop' => $this->prop));
     return $result;
 }
 protected function process_data(&$signal)
 {
     if (!parent::process_data($signal)) {
         return false;
     }
     $file = $signal->data_element($this->default_data_key);
     if (is_object($file) && $file instanceof Dataobject) {
         $element = $file->data();
     } elseif (is_string($file)) {
         $element = array('url' => $file, 'title' => basename($file));
     } else {
         $this->log("Could not determine the URL to fetch the file body from!", LL_ERROR);
         return false;
     }
     if (isset($this->body_file)) {
         if ($this->body_file === "") {
             $this->core->browser->write_into_file = sha1($element['title']);
         } else {
             $this->core->browser->write_into_file = $this->body_file;
         }
     }
     $browser_max_retries = $this->core->browser->max_retries;
     $this->core->browser->max_retries = 50;
     try {
         $result = $this->core->browser->xfer($element['url']);
     } catch (Exception $e) {
         $result = false;
     }
     if ($result) {
         if (isset($this->body_file)) {
             $element['body_link'] = $this->core->browser->write_into_file;
             $element['body_link_is_tempfile'] = true;
             $filesize = filesize($element['body_link']);
         } else {
             $element['body'] = $this->core->browser->content;
             $filesize = strlen($element['body']);
         }
         $this->log("Fetched also file body ({$filesize} bytes)", LL_DEBUG);
     } else {
         $this->log("Tried, but could not fetch the file body!", LL_WARNING);
     }
     $this->core->browser->max_retries = $browser_max_retries;
     unset($this->core->browser->write_into_file);
     $file = new File($this->core, $element);
     $result = $this->set_fetched_data($signal, $file);
     $this->set_jobdata($result);
     return $result;
 }
 protected function process_data(&$signal)
 {
     parent::process_data($signal);
     $params = array();
     if (isset($this->properties)) {
         $params['properties'] = $this->properties;
     }
     if (isset($this->revid)) {
         $params['revid'] = $this->revid;
     }
     if (isset($this->section)) {
         $params['section'] = $this->section;
     }
     $page = $this->fetch_page($signal, $params);
     if ($page === false && $this->create_missing_pages && !is_null($title = $signal->data_title($this->default_data_key))) {
         $page = new Page($this->core, array('title' => $title));
         $this->log("Creating page [[{$title}]] object by title only...");
     }
     $result = $this->set_fetched_data($signal, $page);
     $this->set_jobdata($result);
     return $result;
 }
 protected function fetch_and_propagate_batch()
 {
     if (count($this->titles) > 0) {
         $this->log("Fetching batch (" . count($this->titles) . " titles)...", LL_DEBUG);
         $params = array();
         $params['_pageset'] = array('titles' => $this->titles, 'limit' => "max");
         if (isset($this->properties) && is_array($this->properties)) {
             $params['_prop'] = $this->properties;
         }
         $query = new Query_Pageset_Titles($this->core);
         $query->set_params($params);
         $result = true;
         $counter = 0;
         while ($element = $query->element()) {
             if ($element === NULL) {
                 $this->log("Could not fetch a batch", LL_ERROR);
                 $result = false;
                 break;
             }
             $counter++;
             if (isset($element['invalid'])) {
                 $this->log("[[" . $element['title'] . "]] is invalid - skipping it", LL_INFO);
             } else {
                 $this->log("Fetched (from batch) [[" . $element['title'] . "]] (" . $counter . " of " . count($this->titles) . ")");
                 $signal = $this->element_to_signal($element);
                 parent::propagate_signal($signal);
             }
         }
     } else {
         $result = true;
     }
     $this->titles = array();
     return $result;
 }
Exemple #5
0
 protected function process_data(&$signal)
 {
     if (!parent::process_data($signal)) {
         return false;
     }
     $title = $signal->data_title($this->default_data_key);
     if (is_null($title)) {
         return false;
     }
     $namespace = $this->core->info->title_namespace($title);
     if (empty($namespace)) {
         $title = $this->core->info->namespace_name('File') . ':' . $title;
     }
     $params = array('title' => $title, 'properties' => array('imageinfo' => array()));
     $paramnames = $this->core->info->param_querymodule_parameters_names('imageinfo');
     foreach ($paramnames as $paramname) {
         if (isset($this->{$paramname}) && !is_null($this->{$paramname})) {
             $params['properties']['imageinfo'][$paramname] = $this->{$paramname};
         }
     }
     if (empty($params['properties']['imageinfo']['prop'])) {
         $params['properties']['imageinfo']['prop'] = $this->core->info->param_querymodule_parameter_type('prop', 'imageinfo');
     }
     require_once dirname(__FILE__) . '/../../../../core/tasks/fetch_filename.php';
     $task = new Task_FetchFilename($this->core);
     $file = $task->go($params);
     if ($file !== false && $this->fetch_body) {
         if (isset($this->body_file)) {
             if ($this->body_file == "") {
                 $this->core->browser->write_into_file = sha1($title);
             } else {
                 $this->core->browser->write_into_file = $this->body_file;
             }
         }
         $browser_max_retries = $this->core->browser->max_retries;
         $this->core->browser->max_retries = 50;
         try {
             $result = $this->core->browser->xfer($file->url);
         } catch (Exception $e) {
             $result = false;
         }
         if ($result) {
             if (!isset($this->body_file)) {
                 $file->body = $this->core->browser->content;
                 $filesize = strlen($file->body);
             } else {
                 $file->body_link = $this->core->browser->write_into_file;
                 $file->body_link_is_tempfile = true;
                 $filesize = filesize($file->body_link);
             }
             $this->log("Fetched also the file body - {$filesize} bytes", LL_DEBUG);
         } else {
             $this->log("Tried, but could not fetch the file body!", LL_WARNING);
         }
         $this->core->browser->max_retries = $browser_max_retries;
         unset($this->core->browser->write_into_file);
     }
     $result = $this->set_fetched_data($signal, $file);
     $this->set_jobdata($result, array_merge(array('title' => $title, 'fetch_body' => $this->fetch_body), $params['properties']['imageinfo']));
     return $result;
 }