Commits

joshjcarrier  committed 8feb9ba

Continued transition to new theme system

  • Participants
  • Parent commits f145419

Comments (0)

Files changed (12)

File admin/application/config/config.php

 | http://codeigniter.com/user_guide/general/creating_libraries.html
 |
 */
-$config['subclass_prefix'] = 'MY_';
+$config['subclass_prefix'] = 'phphg_';
 
 
 /*

File admin/application/controllers/hgrepo.php

 		}
 		
 		$this->load->vars(array('title'=>$repositoryName . ' | ' . HGPHP_NAME));
-		$this->load->vars(array('pagetype'=>'browse'));
+		$this->load->vars(array('pagetype'=>'browser'));
 
 		$this->load->view('../../themes/paper/index');
 	}

File admin/application/helpers/hg_repo_helper.php

 
 function item_dirty_value()
 {
-	$hgrc_form = phphginfo('hgrc_form');
+	$hgrc_form = get_phphginfo('hgrc_form');
 	if(!empty($hgrc_form) && isset($hgrc_form[section_name()]) && isset($hgrc_form[section_name()][item_name()]))
     {
     	return $hgrc_form[section_name()][item_name()];
 
 function item_is_boolean()
 {
-	$bools = phphginfo('hgrc_bools_arr');
+	$bools = get_phphginfo('hgrc_bools_arr');
 	return isset($bools[section_name()]) && in_array(item_name(), $bools[section_name()]);
 }

File admin/application/helpers/hg_template_helper.php

 <?php 
 
+function theme_name()
+{
+	return get_phphginfo('theme_name');
+}
+
+function get_theme_resource($rel_path)
+{
+	// FIXME do not allow reverse directory traversal
+	include(FCPATH . 'themes/'.theme_name().'/'.$rel_path);
+}
+
 function get_header()
 {
-	include('C:\Users\joshjcarrier\workspace\hg-php.joshjcarrier.com\admin\themes\paper\header.php');
+	get_theme_resource('header.php');
 }
 
 function get_footer()
 {
-	include('C:\Users\joshjcarrier\workspace\hg-php.joshjcarrier.com\admin\themes\paper\footer.php');
+	get_theme_resource('footer.php');
 }
 
 function is_directory()
 {
-	return phphginfo('pagetype') === 'directory';
+	return get_phphginfo('pagetype') === 'directory';
 }
 
 function is_repo_config()
 {
-	return phphginfo('pagetype') === 'config';
+	return get_phphginfo('pagetype') === 'config';
+}
+
+function is_repo_browser()
+{
+	return get_phphginfo('pagetype') == 'browser';
 }
 
 function has_messages()
 {
-	return user_messages() !== FALSE;
+	return get_phphginfo('user_msg') !== FALSE;
 }
 
 function user_messages()
 {
-	return phphginfo('user_msg');
+	phphginfo('user_msg');
 }
 
 function has_errors()
 {
-	return user_errors() !== FALSE;
+	return get_phphginfo('user_err') !== FALSE;
 }
 
 function user_errors()
 {
-	return phphginfo('user_err');
+	phphginfo('user_err');
 }
 
 function the_title()
 {
-	return phphginfo('title');
+	phphginfo('title');
 }
 
 function phphginfo($item)
 {
+	echo get_phphginfo($item);
+}
+
+function get_phphginfo($item)
+{
 	$ci =& get_instance();
 	if(isset($ci->load->_ci_cached_vars[$item]))
 	{

File admin/application/libraries/MY_Controller.php

-<?php
-class MY_Controller extends Controller {
-
-	function MY_Controller() {
-		parent :: Controller();
-	}
-}
-
-class Public_Controller extends MY_Controller {
-
-	function Public_Controller() {
-		parent :: MY_Controller();
-	}
-}
-
-class Private_Controller extends MY_Controller {
-
-	function Private_Controller() {
-		parent :: MY_Controller();
-		
-		if($_SERVER['SERVER_NAME'] == 'localhost')
-		{return; /* AUTH DISABLED */}
-		
-		if(isset($_SERVER['PHP_AUTH_USER']) && $_SERVER['PHP_AUTH_PW'] 
-			&& !$this->mantis_auth->trustExternal($_SERVER['PHP_AUTH_USER'], $_SERVER['PHP_AUTH_PW']))
-		{
-			$CI = &get_instance();
-			$CI->load->helper('url');
-			redirect('/login');
-		}
-	}
-}

File admin/application/libraries/phphg_Controller.php

+<?php
+class phphg_Controller extends Controller {
+
+	function phphg_Controller() {
+		parent :: Controller();
+		
+		$this->load->vars(array('title'=>HGPHP_NAME, 'theme_name'=>'paper','stylesheet_url'=>base_url().'themes/paper/style.css'));
+	}
+}
+
+class Public_Controller extends phphg_Controller {
+
+	function Public_Controller() {
+		parent :: phphg_Controller();
+		
+		
+	}
+}
+
+class Private_Controller extends phphg_Controller {
+
+	function Private_Controller() {
+		parent :: phphg_Controller();
+		
+		if($_SERVER['SERVER_NAME'] == 'localhost')
+		{return; /* AUTH DISABLED */}
+		
+		if(isset($_SERVER['PHP_AUTH_USER']) && $_SERVER['PHP_AUTH_PW'] 
+			&& !$this->mantis_auth->trustExternal($_SERVER['PHP_AUTH_USER'], $_SERVER['PHP_AUTH_PW']))
+		{
+			$CI = &get_instance();
+			$CI->load->helper('url');
+			redirect('/login');
+		}
+	}
+}

File admin/static/style-paper.css

-body {
-  margin: 0;
-  padding: 0;
-  background: white;
-  font-family: sans-serif;
-}
-
-.container {
-  padding-left: 115px;
-}
-
-.main {
-  position: relative;
-  background: white;
-  padding: 2em 2em 2em 0;
-}
-
-#.main {
-  width: 98%;
-}
-
-.overflow {
-  width: 100%;
-  overflow: auto;
-}
-
-.menu {
-  width: 90px;
-  margin: 0;
-  font-size: 80%;
-  text-align: left;
-  position: absolute;
-  top: 20px;
-  left: 20px;
-  right: auto;
-}
-
-.menu ul {
-  list-style: none;
-  padding: 0;
-  margin: 10px 0 0 0;
-  border-left: 2px solid #999;
-}
-
-.menu li {
-  margin-bottom: 3px;
-  padding: 2px 4px;
-  background: white;
-  color: black;
-  font-weight: normal;
-}
-
-.menu li.active {
-  font-weight: bold;
-}
-
-.menu img {
-  width: 75px;
-  height: 90px;
-  border: 0;
-}
-
-.menu a { color: black; display: block; }
-
-.search {
-  position: absolute;
-  top: .7em;
-  right: 2em;
-}
-
-form.search div#hint {
-  display: none;
-  position: absolute;
-  top: 40px;
-  right: 0px;
-  width: 190px;
-  padding: 5px;
-  background: #ffc;
-  font-size: 70%;
-  border: 1px solid yellow;
-  -moz-border-radius: 5px; /* this works only in camino/firefox */
-  -webkit-border-radius: 5px; /* this is just for Safari */
-}
-
-form.search:hover div#hint { display: block; }
-
-a { text-decoration:none; }
-.age { white-space:nowrap; }
-.date { white-space:nowrap; }
-.indexlinks { white-space:nowrap; }
-.parity0 { background-color: #f0f0f0; }
-.parity1 { background-color: white; }
-.plusline { color: green; }
-.minusline { color: #dc143c; } /* crimson */
-.atline { color: purple; }
-
-.navigate {
-  text-align: right;
-  font-size: 60%;
-  margin: 1em 0;
-}
-
-.tag {
-  color: #999;
-  font-size: 70%;
-  font-weight: normal;
-  margin-left: .5em;
-  vertical-align: baseline;
-}
-
-.branchhead {
-  color: #000;
-  font-size: 80%;
-  font-weight: normal;
-  margin-left: .5em;
-  vertical-align: baseline;
-}
-
-ul#graphnodes .branchhead {
-  font-size: 75%;
-}
-
-.branchname {
-  color: #000;
-  font-size: 60%;
-  font-weight: normal;
-  margin-left: .5em;
-  vertical-align: baseline;
-}
-
-h3 .branchname {
-  font-size: 80%;
-}
-
-/* Common */
-pre { margin: 0; }
-
-h2 { font-size: 120%; border-bottom: 1px solid #999; }
-h2 a { color: #000; }
-h3 {
-  margin-top: -.7em;
-  font-size: 100%;
-}
-
-/* log and tags tables */
-.bigtable {
-  border-bottom: 1px solid #999;
-  border-collapse: collapse;
-  font-size: 90%;
-  width: 100%;
-  font-weight: normal;
-  text-align: left;
-}
-
-.bigtable td {
-  vertical-align: top;
-}
-
-.bigtable th {
-  padding: 1px 4px;
-  border-bottom: 1px solid #999;
-}
-.bigtable tr { border: none; }
-.bigtable .age { width: 7em; }
-.bigtable .author { width: 12em; }
-.bigtable .description { }
-.bigtable .node { width: 5em; font-family: monospace;}
-.bigtable .permissions { width: 8em; text-align: left;}
-.bigtable .size { width: 5em; text-align: right; }
-.bigtable .annotate { text-align: right; }
-.bigtable td.annotate { font-size: smaller; }
-.bigtable td.source { font-size: inherit; }
-
-.source, .sourcefirst, .sourcelast {
-  font-family: monospace;
-  white-space: pre;
-  padding: 1px 4px;
-  font-size: 90%;
-}
-.sourcefirst { border-bottom: 1px solid #999; font-weight: bold; }
-.sourcelast { border-top: 1px solid #999; }
-.source a { color: #999; font-size: smaller; font-family: monospace;}
-.bottomline { border-bottom: 1px solid #999; }
-
-.fileline { font-family: monospace; }
-.fileline img { border: 0; }
-
-.tagEntry .closed { color: #99f; }
-
-/* Changeset entry */
-#changesetEntry {
-  border-collapse: collapse;
-  font-size: 90%;
-  width: 100%;
-  margin-bottom: 1em;
-}
-
-#changesetEntry th {
-  padding: 1px 4px;
-  width: 4em;
-  text-align: right;
-  font-weight: normal;
-  color: #999;
-  margin-right: .5em;
-  vertical-align: top;
-}
-
-div.description {
-  border-left: 2px solid #999;
-  margin: 1em 0 1em 0;
-  padding: .3em;
-}
-
-/* Graph */
-div#wrapper {
-	position: relative;
-	border-top: 1px solid black;
-	border-bottom: 1px solid black;
-	margin: 0;
-	padding: 0;
-}
-
-canvas {
-	position: absolute;
-	z-index: 5;
-	top: -0.7em;
-	margin: 0;
-}
-
-ul#graphnodes {
-	position: absolute;
-	z-index: 10;
-	top: -1.0em;
-	list-style: none inside none;
-	padding: 0;
-}
-
-ul#nodebgs {
-	list-style: none inside none;
-	padding: 0;
-	margin: 0;
-	top: -0.7em;
-}
-
-ul#graphnodes li, ul#nodebgs li {
-	height: 39px;
-}
-
-ul#graphnodes li .info {
-	display: block;
-	font-size: 70%;
-	position: relative;
-	top: -3px;
-}

File admin/themes/paper/header.php

 <head> 
 <link rel="icon" href="<?php echo base_url(); ?>static/hgicon.png" type="image/png" /> 
 <meta name="robots" content="index, nofollow" /> 
-<link rel="stylesheet" href="<?php echo base_url(); ?>static/style-paper.css" type="text/css" /> 
+<link rel="stylesheet" href="<?php phphginfo('stylesheet_url'); ?>" type="text/css" /> 
 <link rel="stylesheet" href="<?php echo base_url(); ?>themes/mercurial/css/smoothness/jquery-ui-1.8.1.custom.css" type="text/css" /> 
 <script type="text/javascript" src="<?php echo base_url(); ?>themes/mercurial/js/jquery-1.4.2.min.js"></script>
 <script type="text/javascript" src="<?php echo base_url(); ?>themes/mercurial/js/jquery-ui-1.8.1.custom.min.js"></script>

File admin/themes/paper/index.php

 <?php endif; ?>
   <tr>
     <td> 
-<?php if(is_directory()){ include('repo_directory.php'); }?>
-<?php if(is_repo_config()){ include('repository.php'); }?>
+<?php if(is_directory()): include('repo_directory.php'); ?>
+<?php elseif(is_repo_config()): include('repository.php'); ?>
+<?php elseif(is_repo_browser()): include('repo_browse.php'); ?>
+<?php else: echo 'Content unsupported by theme.'; endif;?>
     </td>
   </tr>
 

File admin/themes/paper/repo_browse.php

+<table class="bigtable" style="border-bottom: 0">
+<form action="<?php echo current_url(); ?>" method="post" id="form_hgrc" name="form_hgrc">
+	<input type="hidden" name="form_action" id="form_action" value="" />
+	<tr>
+	  <td colspan="3" align="right">
+	  	<p>
+	  	<a href="<?php echo site_url('hgrepo/manage/'.the_name()); ?>" class="ui-state-default ui-corner-all dialog_link"><span class="ui-icon"></span><?php echo lang('hgphp_action_update_config'); ?></a>
+	  	</p>
+	  </td>
+	</tr>	
+	<tr>
+	  <td colspan="3">
+<div style="height:500px">
+<iframe src="/<?php the_name(); ?>" frameborder="0" border="0" cellspacing="0" style="display:block; width: 100%; height: 100%;">
+Your browser must support iframes to use this feature.
+</iframe>
+</div>	 
+	  </td>
+	</tr>	
+	<tr>
+	  <td colspan="3" align="right">
+	  	<p>
+	  	<a href="<?php echo site_url('hgrepo/manage/'.the_name()); ?>" class="ui-state-default ui-corner-all dialog_link"><span class="ui-icon"></span><?php echo lang('hgphp_action_update_config'); ?></a>
+	  	</p>
+	  </td>
+	</tr>
+</table>
+

File admin/themes/paper/repository.php

       <nobr>
       <?php if(item_is_boolean()):?>
       	<select name="hgrc[<?php echo section_name() ?>][<?php echo item_name(); ?>]">
-      		<option value="false" <?php if(restore_value(item_current_value(), $hgrc_form, section_name(), item_name()) === 'false'){echo 'selected="selected"';} ?>>false</option>
-      		<option value="true" <?php if(restore_value(item_current_value(), $hgrc_form, section_name(), item_name()) === 'true'){echo 'selected="selected"';} ?>>true</option>
+      		<option value="false" <?php if(item_dirty_value() == 'false'){echo 'selected="selected"';} ?>>false</option>
+      		<option value="true" <?php if(item_dirty_value() == 'true'){echo 'selected="selected"';} ?>>true</option>
       	</select>
       <?php else: ?>
-        <input type="text" name="hgrc[<?php echo section_name() ?>][<?php echo item_name(); ?>]" value="<?php echo restore_value(item_current_value(), $hgrc_form, section_name(), item_name()); ?>" style="width:70%"/>
+        <input type="text" name="hgrc[<?php echo section_name() ?>][<?php echo item_name(); ?>]" value="<?php echo item_dirty_value(); ?>" style="width:70%" size="200"/>
       <?php endif; ?> 
       	<?php if(lang('hgphp_tooltip_hgrc_' . section_name() . '_' . item_name()) != FALSE):?>
       	<a href="#" title="<?php echo htmlentities(lang('hgphp_tooltip_hgrc_' . section_name() . '_' . item_name())); ?>" class="ui-state-default ui-corner-all">&nbsp;&nbsp;?&nbsp;&nbsp;</a>

File admin/themes/paper/style.css

+body {
+  margin: 0;
+  padding: 0;
+  background: white;
+  font-family: sans-serif;
+}
+
+.container {
+  padding-left: 115px;
+}
+
+.main {
+  position: relative;
+  background: white;
+  padding: 2em 2em 2em 0;
+}
+
+#.main {
+  width: 98%;
+}
+
+.overflow {
+  width: 100%;
+  overflow: auto;
+}
+
+.menu {
+  width: 90px;
+  margin: 0;
+  font-size: 80%;
+  text-align: left;
+  position: absolute;
+  top: 20px;
+  left: 20px;
+  right: auto;
+}
+
+.menu ul {
+  list-style: none;
+  padding: 0;
+  margin: 10px 0 0 0;
+  border-left: 2px solid #999;
+}
+
+.menu li {
+  margin-bottom: 3px;
+  padding: 2px 4px;
+  background: white;
+  color: black;
+  font-weight: normal;
+}
+
+.menu li.active {
+  font-weight: bold;
+}
+
+.menu img {
+  width: 75px;
+  height: 90px;
+  border: 0;
+}
+
+.menu a { color: black; display: block; }
+
+.search {
+  position: absolute;
+  top: .7em;
+  right: 2em;
+}
+
+form.search div#hint {
+  display: none;
+  position: absolute;
+  top: 40px;
+  right: 0px;
+  width: 190px;
+  padding: 5px;
+  background: #ffc;
+  font-size: 70%;
+  border: 1px solid yellow;
+  -moz-border-radius: 5px; /* this works only in camino/firefox */
+  -webkit-border-radius: 5px; /* this is just for Safari */
+}
+
+form.search:hover div#hint { display: block; }
+
+a { text-decoration:none; }
+.age { white-space:nowrap; }
+.date { white-space:nowrap; }
+.indexlinks { white-space:nowrap; }
+.parity0 { background-color: #f0f0f0; }
+.parity1 { background-color: white; }
+.plusline { color: green; }
+.minusline { color: #dc143c; } /* crimson */
+.atline { color: purple; }
+
+.navigate {
+  text-align: right;
+  font-size: 60%;
+  margin: 1em 0;
+}
+
+.tag {
+  color: #999;
+  font-size: 70%;
+  font-weight: normal;
+  margin-left: .5em;
+  vertical-align: baseline;
+}
+
+.branchhead {
+  color: #000;
+  font-size: 80%;
+  font-weight: normal;
+  margin-left: .5em;
+  vertical-align: baseline;
+}
+
+ul#graphnodes .branchhead {
+  font-size: 75%;
+}
+
+.branchname {
+  color: #000;
+  font-size: 60%;
+  font-weight: normal;
+  margin-left: .5em;
+  vertical-align: baseline;
+}
+
+h3 .branchname {
+  font-size: 80%;
+}
+
+/* Common */
+pre { margin: 0; }
+
+h2 { font-size: 120%; border-bottom: 1px solid #999; }
+h2 a { color: #000; }
+h3 {
+  margin-top: -.7em;
+  font-size: 100%;
+}
+
+/* log and tags tables */
+.bigtable {
+  border-bottom: 1px solid #999;
+  border-collapse: collapse;
+  font-size: 90%;
+  width: 100%;
+  font-weight: normal;
+  text-align: left;
+}
+
+.bigtable td {
+  vertical-align: top;
+}
+
+.bigtable th {
+  padding: 1px 4px;
+  border-bottom: 1px solid #999;
+}
+.bigtable tr { border: none; }
+.bigtable .age { width: 7em; }
+.bigtable .author { width: 12em; }
+.bigtable .description { }
+.bigtable .node { width: 5em; font-family: monospace;}
+.bigtable .permissions { width: 8em; text-align: left;}
+.bigtable .size { width: 5em; text-align: right; }
+.bigtable .annotate { text-align: right; }
+.bigtable td.annotate { font-size: smaller; }
+.bigtable td.source { font-size: inherit; }
+
+.source, .sourcefirst, .sourcelast {
+  font-family: monospace;
+  white-space: pre;
+  padding: 1px 4px;
+  font-size: 90%;
+}
+.sourcefirst { border-bottom: 1px solid #999; font-weight: bold; }
+.sourcelast { border-top: 1px solid #999; }
+.source a { color: #999; font-size: smaller; font-family: monospace;}
+.bottomline { border-bottom: 1px solid #999; }
+
+.fileline { font-family: monospace; }
+.fileline img { border: 0; }
+
+.tagEntry .closed { color: #99f; }
+
+/* Changeset entry */
+#changesetEntry {
+  border-collapse: collapse;
+  font-size: 90%;
+  width: 100%;
+  margin-bottom: 1em;
+}
+
+#changesetEntry th {
+  padding: 1px 4px;
+  width: 4em;
+  text-align: right;
+  font-weight: normal;
+  color: #999;
+  margin-right: .5em;
+  vertical-align: top;
+}
+
+div.description {
+  border-left: 2px solid #999;
+  margin: 1em 0 1em 0;
+  padding: .3em;
+}
+
+/* Graph */
+div#wrapper {
+	position: relative;
+	border-top: 1px solid black;
+	border-bottom: 1px solid black;
+	margin: 0;
+	padding: 0;
+}
+
+canvas {
+	position: absolute;
+	z-index: 5;
+	top: -0.7em;
+	margin: 0;
+}
+
+ul#graphnodes {
+	position: absolute;
+	z-index: 10;
+	top: -1.0em;
+	list-style: none inside none;
+	padding: 0;
+}
+
+ul#nodebgs {
+	list-style: none inside none;
+	padding: 0;
+	margin: 0;
+	top: -0.7em;
+}
+
+ul#graphnodes li, ul#nodebgs li {
+	height: 39px;
+}
+
+ul#graphnodes li .info {
+	display: block;
+	font-size: 70%;
+	position: relative;
+	top: -3px;
+}