Exemple #1
0
 /**
  * Iterate over all articles and create index record using the datamanager indexer
  * method.
  */
 public function _on_reindex($topic, $config, &$indexer)
 {
     if (is_null($config->get('symlink_topic'))) {
         $qb = midcom::get('dbfactory')->new_query_builder('midcom_db_article');
         $qb->add_constraint('topic', '=', $topic->id);
         $result = $qb->execute();
         if ($result) {
             $schemadb = midcom_helper_datamanager2_schema::load_database($config->get('schemadb'));
             $datamanager = new midcom_helper_datamanager2_datamanager($schemadb);
             if (!$datamanager) {
                 debug_add('Warning, failed to create a datamanager instance with this schemapath:' . $config->get('schemadb'), MIDCOM_LOG_WARN);
                 continue;
             }
             foreach ($result as $article) {
                 if (!$datamanager->autoset_storage($article)) {
                     debug_add("Warning, failed to initialize datamanager for Article {$article->id}. Skipping it.", MIDCOM_LOG_WARN);
                     continue;
                 }
                 net_nehmer_static_viewer::index($datamanager, $indexer, $topic);
             }
         }
     } else {
         debug_add("The topic {$topic->id} is symlinked to another topic, skipping indexing.");
     }
     return true;
 }
Exemple #2
0
 /**
  * Displays an article edit view.
  *
  * Note, that the article for non-index mode operation is automatically determined in the can_handle
  * phase.
  *
  * If create privileges apply, we relocate to the index creation article
  *
  * @param mixed $handler_id The ID of the handler.
  * @param Array $args The argument list.
  * @param Array &$data The local request data.
  */
 public function _handler_create($handler_id, array $args, array &$data)
 {
     $this->_content_topic->require_do('midgard:create');
     $this->_schema = $args[0];
     if ($handler_id == 'createindex') {
         $this->_indexmode = true;
     }
     $data['controller'] = $this->get_controller('create');
     switch ($data['controller']->process_form()) {
         case 'save':
             /**
              * http://trac.midgard-project.org/ticket/809 should have taken care of this.
              * BUT: to be extra careful, let's do this sanity-check anyway.
              */
             if (strlen($this->_article->name) == 0) {
                 // Generate something to avoid empty "/" links in case of failures
                 $this->_article->name = time();
                 $this->_article->update();
             }
             // Index the article
             $indexer = midcom::get('indexer');
             net_nehmer_static_viewer::index($data['controller']->datamanager, $indexer, $this->_content_topic);
             if ($this->_article->name === 'index') {
                 return new midcom_response_relocate('');
             }
             return new midcom_response_relocate("{$this->_article->name}/");
         case 'cancel':
             return new midcom_response_relocate('');
     }
     $this->_prepare_request_data();
     $title = sprintf($this->_l10n_midcom->get('create %s'), $this->_schemadb[$this->_schema]->description);
     midcom::get('head')->set_pagetitle("{$this->_topic->extra}: {$title}");
     $this->add_breadcrumb("create/{$this->_schema}/", sprintf($this->_l10n_midcom->get('create %s'), $this->_schemadb[$this->_schema]->description));
 }
Exemple #3
0
 /**
  * Displays an article edit view.
  *
  * Note, that the article for non-index mode operation is automatically determined in the can_handle
  * phase.
  *
  * If create privileges apply, we relocate to the index creation article
  *
  * @param mixed $handler_id The ID of the handler.
  * @param Array $args The argument list.
  * @param Array &$data The local request data.
  */
 public function _handler_edit($handler_id, array $args, array &$data)
 {
     $this->_article = new midcom_db_article($args[0]);
     // Relocate for the correct content topic, let the true content topic take care of the ACL
     if ($this->_article->topic !== $this->_content_topic->id) {
         $nap = new midcom_helper_nav();
         $node = $nap->get_node($this->_article->topic);
         if ($node && isset($node[MIDCOM_NAV_FULLURL])) {
             return new midcom_response_relocate($node[MIDCOM_NAV_FULLURL] . "edit/{$args[0]}/");
         }
         throw new midcom_error_notfound("The article with GUID {$args[0]} was not found.");
     }
     $this->_article->require_do('midgard:update');
     $this->_load_controller();
     switch ($this->_controller->process_form()) {
         case 'save':
             // Reindex the article
             $indexer = midcom::get('indexer');
             net_nehmer_static_viewer::index($this->_controller->datamanager, $indexer, $this->_content_topic);
             // *** FALL-THROUGH ***
         // *** FALL-THROUGH ***
         case 'cancel':
             if ($this->_article->name == 'index') {
                 return new midcom_response_relocate('');
             }
             return new midcom_response_relocate("{$this->_article->name}/");
     }
     $this->_prepare_request_data();
     $this->bind_view_to_object($this->_article, $this->_controller->datamanager->schema->name);
     midcom::get('style')->append_substyle('admin');
     midcom::get('metadata')->set_request_metadata($this->_article->metadata->revised, $this->_article->guid);
     $this->set_active_leaf($this->_article->id);
     midcom::get('head')->set_pagetitle("{$this->_topic->extra}: {$this->_article->title}");
     $this->_update_breadcrumb_line($handler_id);
 }