PageRenderTime 45ms CodeModel.GetById 11ms app.highlight 25ms RepoModel.GetById 1ms app.codeStats 0ms

/Documentation/ReferenceManualScripts/related/redirect.php

https://github.com/aivanov-cern/cmssw
PHP | 171 lines | 83 code | 6 blank | 82 comment | 4 complexity | 9014d95e6cca60572041e9cc29f81ece MD5 | raw file
  1<?php
  2
  3        //$doxy_URL = "http://cms-service-sdtweb.web.cern.ch/cms-service-sdtweb/doxygen/";
  4        //$doxy_PATH = "/afs/cern.ch/cms/sdt/web/doxygen/";
  5        $doxy_URL = "http://cmssdt.cern.ch/SDT/doxygen/";
  6        $doxy_PATH = "/data/doxygen/";
  7	
  8	
  9	$output = "";
 10	$object = "";
 11	$object_name = "";
 12	$grep = "";
 13	$star = "";
 14	$ext = "\.html";
 15
 16	$r = isset($_GET["r"])?$_GET["r"]:""; // release
 17	$c = isset($_GET["c"])?$_GET["c"]:""; // class
 18	$s = isset($_GET["s"])?$_GET["s"]:""; // struct
 19	$n = isset($_GET["n"])?$_GET["n"]:""; // namespace
 20	$o = isset($_GET["o"])?$_GET["o"]:""; // source
 21	$k =  isset($_GET["k"])?$_GET["k"]:""; // keywords
 22        $K =  isset($_GET["K"])?$_GET["K"]:""; // keywords strict // changed: 10-07-08
 23	
 24	
 25	if ($K != "" && $k != "")	// changed: 10-07-08
 26	{
 27		print "K and k can't be specified at the same time !!!";
 28		exit;
 29	}
 30		
 31	if ($K != "") $k = $K;	// changed: 10-07-08
 32
 33	if ($k != "")
 34	{
 35		$k = trim($k,"{");
 36		$k = trim($k,"}");
 37		$k = trim($k);
 38		if ($k != "")
 39		{
 40			$k = str_replace("*",".*",$k);
 41			$keywords = explode(",", $k);   // changed: 10-07-08
 42			for ($i=0; $i<count($keywords); $i++)
 43			{
 44				$grep = $grep." | egrep ".'"'.$keywords[$i].'"';
 45			}
 46			//$grep = " | grep ".str_replace(",", " | grep ", $k);
 47			//$grep = " | egrep ".str_replace(",", " | egrep ", '"'.$k.'"');
 48		}
 49	}
 50	
 51	if ($r == "" && ($c =="" || $s =="" || $n =="" || $o ==""))
 52	{
 53		//header("Location: http://cmsdoc.cern.ch/cms/cpt/Software/html/General/gendoxy-doc.php");
 54		header("http://cmssdt.cern.ch/SDT/cgi-bin/doxygen.php");
 55	}
 56	else 
 57	{
 58		if ($c != "")
 59		{
 60			$object = "class";
 61			$object_name = $c;
 62		}
 63                else if ($s != "")
 64                {
 65                        $object = "struct";
 66                        $object_name = $s;
 67                }
 68                else if ($n != "")
 69                {
 70                        $object = "namespace";
 71                        $object_name = $n;
 72                }
 73                else if ($o != "")
 74		{
 75                        $object = "";
 76                        $object_name = $o;
 77			$ext = "_8(cc|h|py)[-,_]source\.html";
 78                }		
 79		
 80		$object_name = str_replace("_", "__", $object_name);
 81		$object_name = str_replace("*", ".*", $object_name);
 82		if ($k != "" && substr_count($object_name,'*') == 0 )
 83		{
 84			$object_name = '.*'.$object_name.'.*';
 85		}
 86	}
 87
 88	//$query1 = 'cd '.$doxy_PATH.'; ls CMSSW_'.$r.'/doc/html/'.$object.$star.$object_name.$ext.$grep;
 89	//$query2 = 'cd '.$doxy_PATH.'; ls CMSSW_'.$r.'/doc/html/*/*/'.$object.$star.$object_name.$ext.$grep;
 90	
 91	$query0 = 'cat '.$doxy_PATH.'CMSSW_'.$r.'/*.index | egrep "'.$object.$object_name.$ext.'"'.$grep; 
 92
 93	//print $query1;
 94	//print $query2;
 95	//print $query0; exit;
 96	
 97	//$output = shell_exec($query1);
 98	//$output = $output==""? shell_exec($query2):$output;
 99	$output = shell_exec($query0);
100
101	if ($output == "") 
102	{
103		$URL = $doxy_URL.$r."/doc/html/".$object.str_replace(".*", "*", $object_name).".html";
104                $html_s = "<html><head><title>Doxygen Links</title></head><body>";
105                $div_s = "<div style='width: 95%; margin: 0 auto; border: 1px solid black; text-style: Arial, Helvetica, sans-serif;'><div style='font-size: 18px; border-bottom: 1px solid black; text-align: center; font-weight: bold; padding: 10px; background-color: #b7cade;'>SORRY, NO MATCH FOUND!!!</div><div style='margin: 10px; font-size: 14px;'>";
106                $body = $URL;
107                $div_e = "<p style='color: red;'>Either there is no documenation for that release or the query syntax is faulty, please check it out:<br />$query0</p></div></div>";
108                $html_e = "</body></html>";
109                print $html_s.$div_s.$body.$div_e.$html_e;
110		//echo "Doxygen documentation not available for ".$URL;
111	}
112	else
113	{
114		$output = ereg_replace("[[:space:]]+", ",", trim($output));
115		$list = explode(",", $output);
116		
117		if (count($list) == 1)
118		{ 
119			$URL = $doxy_URL.$output;
120			header("Location: ".$URL);
121		}
122		else
123		{
124
125                	if ($K != "") // changed: 10-07-08
126                	{
127	                	for ($i=0; $i<count($list); $i++)
128	                	{
129	                		$explodedpath = explode("/",$list[$i]);
130	                		$pattern = $explodedpath[count($explodedpath)-1];
131	                		$pattern = str_replace("struct", "", $pattern);
132	                		$pattern = str_replace("namespace", "", $pattern);
133	                		$pattern = str_replace("class", "", $pattern);
134	                		$pattern = str_replace($c, "", $pattern);
135	                		$pattern = str_replace($s, "", $pattern);
136	                		$pattern = str_replace($n, "", $pattern);
137	                		$pattern = str_replace(".html", "", $pattern);
138	                		for ($j=0; $j<count($keywords); $j++)
139	                			$pattern = str_replace($keywords[$j], "", $pattern);
140					$pattern = str_replace("_", "", $pattern);
141					$pattern = ereg_replace("[0-9]+", "", $pattern);
142	                		if (strlen($pattern) == 0)
143			                {
144			                	$URL = $doxy_URL.$list[$i];
145			                	header("Location: ".$URL);
146			                }
147	                	}
148                	}
149
150
151			$anchor_s = "<a href='";
152			$anchor_m = "'>";
153			$anchor_e = "</a>";
154			
155			$html_s = "<html><head><title>Doxygen Links</title></head><body>";
156			$div_s = "<div style='width: 95%; margin: 0 auto; border: 1px solid black; text-style: Arial, Helvetica, sans-serif;'><div style='font-size: 18px; border-bottom: 1px solid black; text-align: center; font-weight: bold; padding: 10px; background-color: #b7cade;'>MANY ENTRIES MATCH YOUR QUERY !!!</div><div style='margin: 10px; font-size: 14px;'>";
157			$body = "";
158			$div_e = "</div></div>";
159			$html_e = "</body></html>";
160		
161			for ($i=0; $i<count($list); $i++) 
162				$body = $body.$anchor_s.$doxy_URL.$list[$i].$anchor_m.$list[$i].$anchor_e."<br /><br />";
163		
164			print $html_s.$div_s.$body.$div_e.$html_e;
165		}
166		
167	}
168	
169	exit;
170
171?>