Exemplo n.º 1
0
 protected function process_data(&$signal)
 {
     parent::process_data($signal);
     $record = $this->element_record($signal);
     if (is_null($record)) {
         return NULL;
     } else {
         $result = $this->write_record($this->fp, $record);
     }
     $this->set_jobdata($result);
     return $result !== false;
 }
Exemplo n.º 2
0
 protected function process_data(&$signal)
 {
     if (parent::process_data($signal) === false) {
         return false;
     }
     if (!isset($this->path)) {
         $this->log('Property $path is not set - exitting!', LL_PANIC);
         die;
     }
     $element = $signal->data_element($this->default_data_key);
     if (is_object($element) && $element instanceof File) {
         $element = $element->data();
     }
     if (is_array($element) && isset($element['title'])) {
         $filename = $this->core->info->title_pagename($element['title']);
         if (isset($element['body'])) {
             $result = file_put_contents($filename, $element['body']);
             $this->log("Wrote file {$filename}");
         } elseif (isset($element['body_link'])) {
             $result = $this->copy_file($element['body_link'], $filename);
             if (isset($element['body_link_is_tempfile']) && $element['body_link_is_tempfile']) {
                 @unlink($element['body_link']);
             }
             $result = true;
             $this->log("Wrote file {$filename}");
         } else {
             $this->log("Could not determine {$filename}'s body - cannot write it!", LL_ERROR);
             $result = false;
         }
     } else {
         $result = false;
         $filename = "";
         $this->log("Could not determine a title for a file - cannot write it!", LL_ERROR);
     }
     $this->set_jobdata($result, array('filename' => $filename));
     return true;
 }