Example #1
0
 /**
  * Create a new attachment document
  *
  * @param MidgardAttachment $attachment The Attachment to index.
  * @param MidgardObject $source The source objece to which the attachment is bound.
  */
 public function __construct($attachment, $source)
 {
     //before doing anything else, verify that the attachment is readable, otherwise we might get stuck in endless loops later on
     $test = $attachment->open('r');
     if (!$test) {
         debug_add('Attachment ' . $attachment->guid . ' cannot be read, aborting. Last midgard error: ' . midcom_connection::get_error_string(), MIDCOM_LOG_ERROR);
         return false;
     } else {
         fclose($test);
     }
     parent::__construct();
     $this->_set_type('midcom_attachment');
     $this->_attachment = $attachment;
     $this->_source = $source;
     debug_print_r("Processing this attachment:", $attachment);
     $this->source = $this->_source->guid;
     $this->RI = $this->_attachment->guid;
     $this->document_url = "{$GLOBALS['midcom_config']['midcom_site_url']}midcom-serveattachmentguid-{$this->RI}/{$this->_attachment->name}";
     $this->_process_attachment();
     $this->_process_topic();
 }
Example #2
0
 /**
  * The constructor initializes the content object, loads the metadata object
  * and populates the metadata fields accordingly.
  *
  * The source member is automatically populated with the GUID of the document,
  * the RI is set to it as well. The URL is set to a on-site permalink.
  *
  * @param mixed $object The content object to load, passed to the metadata constructor.
  * @see midcom_helper_metadata
  */
 public function __construct($object)
 {
     parent::__construct();
     if ($GLOBALS['midcom_config']['indexer_backend'] == false) {
         return;
     }
     $this->_set_type('midcom');
     if (is_a($object, 'midcom_helper_metadata')) {
         $this->_metadata =& $object;
     } else {
         $this->_metadata = midcom_helper_metadata::retrieve($object);
         if ($this->_metadata == false) {
             debug_add('document_midcom: Failed to retrieve a Metadata object, aborting.');
             return false;
         }
     }
     $this->source = $this->_metadata->object->guid;
     $this->lang = midcom::get('i18n')->get_content_language();
     // Add language code to RI as well so that different language versions of the object have unique identifiers
     $this->RI = "{$this->source}_{$this->lang}";
     $this->document_url = midcom::get('permalinks')->create_permalink($this->source);
     $this->_process_metadata();
 }