[Frugalware-darcs] homepage-ng: frugalware: support for /packages/id/documentation

VMiklos vmiklos at frugalware.org
Wed Jun 13 00:43:46 CEST 2007


Darcsweb-Url: http://darcs.frugalware.org/darcsweb/darcsweb.cgi?r=homepage-ng;a=darcs_commitdiff;h=20070612224319-e2957-99b225602767ed543b5501daf390f5a4e29eda09.gz;

[frugalware: support for /packages/id/documentation
VMiklos <vmiklos at frugalware.org>**20070612224319] {
hunk ./frugalware/footer.php 5
-<div id="footer">
+<div id="fwfooter">
hunk ./frugalware/packages.php 50
+		else if ($_GET['s'] == "documentation")
+			documentation_from_id($_GET['id']);
hunk ./frugalware/packages.php 393
+		if(file_exists($top_path."/source/".$parent['group']."/".$parent['pkgname']."/".$parent['pkgname'].".html"))
+			$content .= "<tr><td>" . gettext("Documentation:") . "</td><td><a href=\"/packages/".$id."/documentation\">".$arr['pkgname'].".html</a></td></tr>\n";
hunk ./frugalware/packages.php 563
+	else
+	{
+		fwmiddlebox( '', gettext("No such package!") );
+	}
+	$db->doClose();
+}
+
+function documentation_from_id($id)
+{
+	global $sqlhost, $sqluser, $sqlpass, $top_path;
+
+	$db = new FwDB();
+	$db->doConnect($sqlhost, $sqluser, $sqlpass, "frugalware2");
+	$res = $db->doQuery("select pkgname, pkgver, arch, parent_id, fwver from packages where id=$id");
+	if ( $db->doCountRows( $res ) > 0 )
+	{
+		$arr = $db->doFetchRow($res);
+		if($arr['parent_id']!=0)
+		{
+			$res = $db->doQuery("select pkgname from packages where id=" . $arr['parent_id']);
+			$parent = $db->doFetchRow($res);
+		}
+		else
+			$parent['pkgname']=$arr['pkgname'];
+		$query = "select ct_groups.pkg_id, groups.id, groups.name from groups, ct_groups where (ct_groups.pkg_id=$id or ct_groups.pkg_id=".$arr['parent_id'].") and ct_groups.group_id = groups.id order by groups.id";
+		$res = $db->doQuery($query);
+		while($i=$db->doFetchRow($res))
+			if($i['pkg_id']==$id)
+				$groups[]=$i;
+			else if(!isset($parent['group']))
+				$parent['group']=$i['name'];
+		if(!isset($parent['group']))
+			$parent['group']=$groups[0]['name'];
+
+		$slog = $parent['pkgname']."-".$arr['pkgver']."-".$arr['arch'];
+		$doc = str_replace("current", $arr['fwver'], $top_path)."/source/".$parent['group']."/".$parent['pkgname']."/".$parent['pkgname'].".html";
+		print("<fieldset class=\"pkg\"><legend>".sprintf(gettext("Documentation for %s"), $slog)."</legend>");
+		if(file_exists($doc))
+		{
+			print("<div class=\"documentation\">");
+			$lines = explode("\n", file_get_contents($doc));
+			$display = false;
+			foreach($lines as $i)
+			{
+				if(substr(trim($i), -7, 7) == "</body>")
+					$display = false;
+				if($display)
+					print($i);
+				if(substr(trim($i), -5, 5) == "</h2>")
+					$display = true;
+				/*else
+					print("DEBUG: '" . substr($i, -6, 6) . "' != '</h2>\n'\n");*/
+			}
+			print("</div>\n</fieldset>\n");
+		}
+		else
+			print(gettext("Sorry, currently no documentation available."));
+	}
hunk ./frugalware/rewrite.php 96
+			else if($params[1]=="documentation")
+				$urlsuffix.="&s=documentation";
hunk ./frugalware/static/common.css 57
-#footer {
+#fwfooter {
hunk ./frugalware/static/old.css 180
-#footer {
+#fwfooter {
}


More information about the Frugalware-darcs mailing list