getTitle(); if( $title->getNamespace() == NS_PATHWAY && preg_match("/^\s*\<\?xml/", $text)) { $parser->disableCache(); $oldId = $_REQUEST['oldid']; try { $pathway = Pathway::newFromTitle($title); if($oldId) { $pathway->setActiveRevision($oldId); } $pathway->updateCache(FILETYPE_IMG); //In case the image page is removed $page = new PathwayPage($pathway); $text = $page->getContent(); } catch(Exception $e) { //Return error message on any exception $text = << === Error details ===
{$e}
ERROR; } } return true; } function addPreloaderScript($out) { global $wgTitle, $wgUser, $wgScriptPath; if($wgTitle->getNamespace() == NS_PATHWAY && $wgUser->isLoggedIn()) { $base = $wgScriptPath . "/wpi/applet/"; $class = "org.wikipathways.applet.Preloader.class"; $out->addHTML(""); } return true; } class PathwayPage { private $pathway; private $data; function __construct($pathway) { $this->pathway = $pathway; $this->data = $pathway->getPathwayData(); } function getContent() { $text = <<titleEditor()} {$this->privateWarning()} {{Template:PathwayPage:Top}} {$this->curationTags()} {$this->descriptionText()} {$this->ontologyTags()} {$this->bibliographyText()} {$this->categoryText()} {{Template:PathwayPage:Bottom}} TEXT; return $text; } function titleEditor() { $title = $this->pathway->getName(); return "$title\n"; } function privateWarning() { global $wgScriptPath, $wgLang; $warn = ''; if(!$this->pathway->isPublic()) { $url = SITE_URL; $msg = wfMsg('private_warning'); $pp = $this->pathway->getPermissionManager()->getPermissions(); $expdate = $pp->getExpires(); $expdate = $wgLang->date($expdate, true); $msg = str_replace('$DATE', $expdate, $msg); $warn = "
$msg
"; } return $warn; } function curationTags() { $tags = "== Curation Tags ==\n" . ""; return $tags; } function descriptionText() { //Get WikiPathways description $content = $this->data->getWikiDescription(); $description = $content; if(!$description) { $description = "No description"; } $description = "== Description ==\n
" . $description . "
"; $description .= "$content\n"; //Get additional comments $comments = ''; foreach($this->data->getGpml()->Comment as $comment) { if( $comment['Source'] == COMMENT_WP_DESCRIPTION || $comment['Source'] == COMMENT_WP_CATEGORY) { continue; //Skip description and category comments } $text = (string)$comment; $text = html_entity_decode($text); $text = nl2br($text); $text = PathwayPage::formatPubMed($text); if(!$text) continue; $comments .= "; " . $comment['Source'] . " : " . $text . "\n"; } if($comments) { $description .= "\n=== Comments ===\n
\n$comments
"; } return $description; } function ontologyTags() { global $wpiEnableOtag; if($wpiEnableOtag) { $otags = "== Ontology Tags ==\n" . ""; return $otags; } } function bibliographyText() { global $wgUser; $out = ""; //No edit button for now, show help on how to add bibliography instead //$button = $this->editButton('javascript:;', 'Edit bibliography', 'bibEdit'); #&$parser, $idClick = 'direct', $idReplace = 'pwThumb', $new = '', $pwTitle = '', $type = 'editor' $help = ''; if($wgUser->isLoggedIn()) { $help = "{{Template:Help:LiteratureReferences}}"; } return "== Bibliography ==\n$out\n$help"; //"
$button
\n" . //"$out
\n{{#editApplet:bibEdit|bibliography|0||bibliography|0|250px}}"; } function categoryText() { $categories = $this->pathway->getCategoryHandler()->getCategories(); $species = Pathway::getAvailableSpecies(); $catlist = ''; foreach($categories as $c) { $cat = Title::newFromText($c, NS_CATEGORY); if(!$cat) continue; //Prevent error when empty category is introduced in GPML $name = $cat->getText(); if(in_array($name, $species)) { $browseCat = '&browseCat=All+Categories'; $browse = "&browse=" . urlencode($name); } else { $browse = '&browse=All+Species'; $browseCat = "&browseCat=" . urlencode($name); } $link = SITE_URL . "/index.php?title=Special:BrowsePathwaysPage{$browse}{$browseCat}"; $catlist .= "* [{$link} {$name}]\n"; } $button = $this->editButton('javascript:;', 'Edit categories', 'catEdit'); $title = $this->pathway->getIdentifier(); $cats = "== Categories ==\n
\n$catlist
\n"; $catArray = array(); foreach(Pathway::getAvailableCategories() as $c) { $present = 0; if(in_array(str_replace(' ', '_', $c), $categories)) $present = 1; $catArray[$c] = $present; } $catValue = json_encode($catArray); $cats .= "$catValue\n"; return $cats; } function editButton($href, $title, $id = '') { global $wgUser, $wgTitle; # Check permissions if( $wgUser->isLoggedIn() && $wgTitle && $wgTitle->userCan('edit')) { $label = 'edit'; } else { /* $pathwayURL = $this->pathway->getTitleObject()->getFullText(); $href = SITE_URL . "/index.php?title=Special:Userlogin&returnto=$pathwayURL"; $label = 'log in'; $title = 'Log in to edit'; */ return ""; } return "$label"; } static function getDownloadURL($pathway, $type) { if($pathway->getActiveRevision()) { $oldid = "&oldid={$pathway->getActiveRevision()}"; } return WPI_SCRIPT_URL . "?action=downloadFile&type=$type&pwTitle={$pathway->getTitleObject()->getFullText()}{$oldid}"; } static function editDropDown($pathway) { global $wgOut; //AP20081218: Operating System Detection require_once 'DetectBrowserOS.php'; //echo (browser_detection( 'os' )); $download = array( 'PathVisio (.gpml)' => self::getDownloadURL($pathway, 'gpml'), 'Scalable Vector Graphics (.svg)' => self::getDownloadURL($pathway, 'svg'), 'Gene list (.txt)' => self::getDownloadURL($pathway, 'txt'), 'Biopax level 3 (.owl)' => self::getDownloadURL($pathway, 'owl'), 'Eu.Gene (.pwf)' => self::getDownloadURL($pathway, 'pwf'), 'Png image (.png)' => self::getDownloadURL($pathway, 'png'), 'Acrobat (.pdf)' => self::getDownloadURL($pathway, 'pdf'), ); if (browser_detection( 'os' ) == 'win' || browser_detection( 'os' ) == 'nt'){ $download['GenMAPP (.mapp)'] = self::getDownloadURL($pathway, 'mapp'); } $downloadlist = ''; foreach(array_keys($download) as $key) { $downloadlist .= "
  • $key
  • "; } $dropdown = <<
  • Download
      $downloadlist
  • DROPDOWN; $script = << SCRIPT; $wgOut->addScript($script); return $dropdown; } static function formatPubMed($text) { $link = "http://www.ncbi.nlm.nih.gov/entrez/query.fcgi?db=pubmed&cmd=Retrieve&dopt=AbstractPlus&list_uids="; if(preg_match_all("/PMID: ([0-9]+)/", $text, $ids)) { foreach($ids[1] as $id) { $text = str_replace($id, "[$link$id $id]", $text); } } return $text; } } ?>