예제 #1
0
파일: action.php 프로젝트: Aarontse/Door43
 /**
  * Adds links to pre-processed text
  *
  * @param object $event The event data
  * @param array  $param Passed parameters
  *
  * @return array The parameters for render()
  */
 public function handle_parser_wikitext_preprocess(Doku_Event &$event, $param)
 {
     global $INFO;
     global $ID;
     global $conf;
     // Don't process sidebar-type pages, only the main page.
     // In sidebar pages, the $INFO["id"] is set to the main page.
     // On the main page, the $ID is set but the $INFO["id"] is null.
     // error_log("--------------- chunkprogress:action.php:handle_parser_wikitext_preprocess()");
     // error_log("ID: " . $ID);
     // error_log("INFO['id']: " . $INFO["id"]);
     if ($INFO["id"] != null && $INFO["id"] != $ID) {
         // error_log("Diff links won't be processed for this page.");
         return;
     }
     // Get namespace for this page
     $namespace = getNS(cleanID(getID()));
     // error_log("Namespace: " . $namespace);
     // Scan all pages in namespace to find previous and next chunks
     // Only search depth 1 since all we care about is siblings
     $pages_in_ns = getAllPagesInNamespace($namespace, 0);
     $previous_chunk_id = null;
     $next_chunk_id = null;
     $prior_page = null;
     foreach ($pages_in_ns as $page_info) {
         $page_id = $page_info["id"];
         // // error_log("page_id: $page_id");
         if ($page_id == $ID) {
             // This is the requested page, which means that the prior
             // page is the previous chunk
             $previous_chunk_id = $prior_page;
         } elseif ($prior_page == $ID) {
             // The prior page is the requested page, which means that
             // this is the next chunk
             $next_chunk_id = $page_id;
             // We don't need to search further
             break;
         }
         $prior_page = $page_id;
     }
     // error_log("Previous chunk ID: " . $previous_chunk_id);
     // error_log("This chunk: " . $ID);
     // error_log("Next chunk ID: " . $next_chunk_id);
     // Show links for previous chunk, if it exists
     if ($previous_chunk_id != null) {
         $diff_links = generateDiffLinks($previous_chunk_id);
         if ($diff_links != "") {
             $event->data = $event->data . "\n  * [[{$previous_chunk_id}|Prev chunk]]: ";
             $event->data = $event->data . $diff_links;
         }
     }
     // Show links for this chunk
     $diff_links = generateDiffLinks($ID);
     if ($diff_links != "") {
         $event->data = $event->data . "\n  * [[{$ID}|This chunk]]: ";
         $event->data = $event->data . $diff_links;
     }
     // Show links for next chunk, if it exists
     if ($next_chunk_id != null) {
         $diff_links = generateDiffLinks($next_chunk_id);
         if ($diff_links != "") {
             $event->data = $event->data . "\n  * [[{$next_chunk_id}|Next chunk]]: ";
             $event->data = $event->data . $diff_links;
         }
     }
 }
예제 #2
0
파일: action.php 프로젝트: Jocai/Door43
 /**
  * Adds links to pre-processed text
  *
  * @param object $event The event data
  * @param array  $param Passed parameters
  *
  * @return array The parameters for render()
  */
 public function handle_parser_wikitext_preprocess(Doku_Event &$event, $param)
 {
     global $INFO;
     global $ID;
     global $ACT;
     global $conf;
     if ($this->should_process_page() == false) {
         return;
     }
     // error_log("GEN DIFF");
     // Get namespace for this page
     $namespace = getNS(cleanID(getID()));
     // Scan all pages in namespace to find previous and next chunks
     // Only search depth 1 since all we care about is siblings
     $pages_in_ns = getAllPagesInNamespace($namespace, 1);
     $previous_chunk_id = null;
     $next_chunk_id = null;
     $prior_page = null;
     foreach ($pages_in_ns as $page_info) {
         $page_id = $page_info["id"];
         // // error_log("page_id: $page_id");
         if ($page_id == $ID) {
             // This is the requested page, which means that the prior
             // page is the previous chunk
             $previous_chunk_id = $prior_page;
         } elseif ($prior_page == $ID) {
             // The prior page is the requested page, which means that
             // this is the next chunk
             $next_chunk_id = $page_id;
             // We don't need to search further
             break;
         }
         $prior_page = $page_id;
     }
     // error_log("Previous chunk ID: " . $previous_chunk_id);
     // error_log("This chunk: " . $ID);
     // error_log("Next chunk ID: " . $next_chunk_id);
     // Show links for previous chunk, if it exists
     if ($previous_chunk_id != null) {
         $diff_links = generateDiffLinks($previous_chunk_id);
         if ($diff_links != "") {
             $event->data = $event->data . "\n  * [[{$previous_chunk_id}|Prev chunk]]: ";
             $event->data = $event->data . $diff_links;
         }
     }
     // Show links for this chunk
     $diff_links = generateDiffLinks($ID);
     if ($diff_links != "") {
         $event->data = $event->data . "\n  * [[{$ID}|This chunk]]: ";
         $event->data = $event->data . $diff_links;
     }
     // Show links for next chunk, if it exists
     if ($next_chunk_id != null) {
         $diff_links = generateDiffLinks($next_chunk_id);
         if ($diff_links != "") {
             $event->data = $event->data . "\n  * [[{$next_chunk_id}|Next chunk]]: ";
             $event->data = $event->data . $diff_links;
         }
     }
 }