cancel
Showing results for 
Search instead for 
Did you mean: 

Mediawiki-Integration: Redirect to Wikipages

nicof
Champ in-the-making
Champ in-the-making
Hi everyone,

the current Mediawiki-Integration saves the content of Wikipages in the Alfresco-Repository.

If your search results in a Wikipage, you can open it and just see the plain text of the content. The following hack will make it redirect you to the referred Wikipage itself.

Open ExternalStoreAlfresco.php in the extensions-folder of your Mediawiki.
Change the function fetchFromURL($url) so it looks like this:
   public function fetchFromURL($url) 
   {
      $version = $this->urlToVersion($url);      
      return preg_replace("#\n<html>\n<head>\n<title></title><meta http-equiv=\"refresh\" content=\"0; URL=http://XXXYOURSERVERADDRESSXXX/index.php/.*\">\n</head>\n<body>\n#", "", preg_replace("#\n</body>\n</html>#", "", $version->cm_content->content, 1), 1);
   }

Replace the function &store($store, $data) with:
   public function &store($store, $data) 
   {
           $url = $_SESSION["lastVersionUrl"];
      $node = null;
      
      $isNormalText = (strpos($url, 'alfresco://') === false);
      
      if ($url != null && $isNormalText == false)
      {
         $node = $this->urlToNode($url);   
      }
      else
      {
         $node = $this->wikiSpace->createChild("cm_content", "cm_contains", "cm_".$_SESSION["title"]);
         $node->cm_name = $_SESSION["title"];
      
         $node->addAspect("cm_versionable");
         $node->cm_initialVersion = false;
         $node->cm_autoVersion = false;
      }
      
      // Set the content and save
      $node->setContent("cm_content", "text/html", "UTF-8", "\n<html>\n<head>\n<title></title><meta http-equiv=\"refresh\" content=\"0; URL=http://XXXYOURSERVERADDRESSXXX/index.php/" . preg_replace("#Image - #", "Image:", $_SESSION["title"]) . "\">\n</head>\n<body>\n" . $data . "\n</body>\n</html>");      
      $this->session->save();
      
      $description = $_SESSION["description"];
      if ($description == null)
      {
         $description = "";
      }
      
      // Create the version
      $version = $node->createVersion($description);
      
      $result = "alfresco://".$node->store->scheme."/".$node->store->address."/".$node->id."/".$version->store->scheme."/".$version->store->address."/".$version->id;      
      return $result;      
   }

That's all, I hope someone will like it. Smiley Happy


Regards

Nico
2 REPLIES 2

siquser
Champ in-the-making
Champ in-the-making
I'm having a issue opening a Mediawiki page in Alfresco. It doesn't even open a page (file association is missing). At least, in your case, you are able to open in text. For me, it gives me an option to download the page.

I installed Alfresco Labs 3c with Mediawiki and PHP amp on windows 2003 server. What's your environment?

I search for content and it listout the correct pages but I was unable to open them.

siquser
Champ in-the-making
Champ in-the-making
By the way, I tried your suggestion and it doesn't help. i.e. I'm unable open the Mediawiki page from Alfresco.
Getting started

Tags


Find what you came for

We want to make your experience in Hyland Connect as valuable as possible, so we put together some helpful links.