Changeset - 4b72fdabad4c
[Not reviewed]
default
0 4 0
Nathan Brink (binki) - 15 years ago 2011-03-27 00:52:56
ohnobinki@ohnopublishing.net
Let schools set their own CSS. Move cedarville's lab CSS into its custom CSS callback so that it doesn't mess up other schools such as calvin.
4 files changed with 69 insertions and 16 deletions:
0 comments (0 inline, 0 general)
inc/class.page.php
Show inline comments
 
@@ -209,26 +209,28 @@ class page
 
    else
 
      header('Content-Type: text/html; charset=utf-8');
 

	
 
    echo '<!DOCTYPE ' . $this->doctype . '>'. PHP_EOL .
 
	  '<html ' . $this->htmlargs . '>'. PHP_EOL .
 
	  '  <head>'. PHP_EOL .
 
	  '    <title>' . $this->pagetitle . ' - ' . $this->base_title . '</title>'. PHP_EOL .
 
          '    <link rel="stylesheet" href="styles/general.css" type="text/css" media="screen" charset="utf-8" />'.  PHP_EOL .
 
	  '    <link rel="stylesheet" type="text/css" media="print" href="styles/print.css" />'. PHP_EOL .
 
          '    <!--[if IE]>'. PHP_EOL .
 
          '      <link rel="stylesheet" type="text/css" media="screen" charset="utf-8" href="styles/ie.css" />'. PHP_EOL .
 
          '    <![endif]-->'. PHP_EOL .
 
          '    <link rel="shortcut icon" href="images/favicon.png" />'. PHP_EOL;
 

	
 
          '    <link rel="shortcut icon" href="images/favicon.png" />'. PHP_EOL
 
      . '    <style type="text/css">' . PHP_EOL
 
      . $this->cdata_wrap(school_page_css($this->school))
 
      . '    </style>' . PHP_EOL;
 
    // Write out all passed scripts
 
    foreach ($this->scripts as $i)
 
      echo '    ' . $this->headCode["$i"] . "\n";
 

	
 
    echo '  </head>' . PHP_EOL .
 
	 '  <body>'. PHP_EOL .
 
         '    <div id="page">'. PHP_EOL .
 
         '      <div id="header">'. PHP_EOL .
 
	 '        <div id="title">'. PHP_EOL .
 
         '          <h1><a href="index.php"><img src="images/slatepermutate-alpha.png" alt="SlatePermutate" class="noborder" /></a><br /></h1>'. PHP_EOL .
 
         '          <p>'. PHP_EOL .
 
         '            <span id="subtitle">'.$this->pagetitle.'</span>'. PHP_EOL .
 
@@ -526,29 +528,47 @@ class page
 
   *   Format a chunk of javascript suitable for adding to headcode.
 
   *
 
   * Takes into account whether or not the code should be wrapped in
 
   * CDATA or not.
 
   *
 
   * \param $js
 
   *   The javascript to wrap up.
 
   * \param $type
 
   *   The type="" attribute of the <script/> element
 
   */
 
  public function script_wrap($js, $type = 'text/javascript')
 
  {
 
    return '<script type="' . $type . '">' . PHP_EOL
 
         . ($this->xhtml ? '<![CDATA[' : '') . PHP_EOL
 
         . $js . PHP_EOL
 
	 . ($this->xhtml ? ']]>' : '') . PHP_EOL
 
         . '// </script>';
 
    return ''
 
      . '<script type="' . $type . '">' . PHP_EOL
 
      . $this->cdata_wrap($js)
 
      . '// </script>';
 
  }
 

	
 
  /**
 
   * \brief
 
   *   Wrap something in CDATA or not wrap depending on if we're
 
   *   serving HTML.
 
   *
 
   * Lower-level than Page::script_wrap().
 
   * \param $content
 
   *   The stuff to wrap in CDATA.
 
   * \return
 
   *   The wrapped string.
 
   */
 
  public function cdata_wrap($content)
 
  {
 
    return ''
 
      . ($this->xhtml ? '<![CDATA[' : '') . PHP_EOL
 
      . $content . PHP_EOL
 
      . ($this->xhtml ? ']]>' : '') . PHP_EOL;
 
  }
 

	
 
  /**
 
   * \brief
 
   *   Add a trailing slash to a path if one does not already exist
 
   */
 
  private function add_trailing_slash($path){
 
    if($path[strlen($path)-1] != '/') {
 
      return $path . "/";
 
    }
 
    else {
 
      return $path;
inc/school.inc
Show inline comments
 
@@ -273,24 +273,47 @@ function school_instructions_html($schoo
 
      $school_instructions_html = 'default' . '_instructions_html';
 

	
 
      /* be 503-safe */
 
      if (!function_exists($school_instructions_html))
 
	return NULL;
 
    }
 

	
 
  return $school_instructions_html();
 
}
 

	
 
/**
 
 * \brief
 
 *   Get CSS specific to a school.
 
 *
 
 * For a school to get custom CSS into slate_permutate's <head />,
 
 * just create a <school_id>_page_css($school) function which returns
 
 * a string of CSS.
 
 *
 
 * \param $school
 
 *   The school from which to fetch CSS.
 
 * \return
 
 *   A string of valid CSS.
 
 */
 
function school_page_css(array $school)
 
{
 
  if (empty($school))
 
    return '';
 
  $school_page_css = $school['id'] . '_page_css';
 
  if (!function_exists($school_page_css))
 
    return '';
 
  return $school_page_css($school);
 
}
 

	
 
/**
 
 * \brief
 
 *   Return information about available semesters.
 
 *
 
 * \param $school
 
 *   The school.
 
 * \return
 
 *   An array with keys being semester IDs ordered by weights with
 
 *   lowest first and keys of 'id' (the semester's ID), 'name' (the
 
 *   friendly name), and 'weight' (lower numbers mean these semesters
 
 *   should be earlier, may be positive or negative). 'time_start',
 
 *   'time_end' are unix timestamps estimating the begin and end point
 
 *   of each semester.
 
 */
school.d/cedarville.inc
Show inline comments
 
@@ -56,12 +56,31 @@ EOF;
 
 * \return
 
 *   An array of Course objects.
 
 */
 

	
 
function cedarville_default_courses()
 
{
 
  $chapel = new Course('Chapel');
 
  $chapel->section_add(new Section('_', array(new SectionMeeting('mtwhf', '1000', '1045', '', 'chapel')),
 
				   '', '_'));
 

	
 
  return array($chapel);
 
}
 

	
 
/**
 
 * \brief
 
 *   Implement <school_id>_page_css().
 
 */
 
function cedarville_page_css($school)
 
{
 
  return <<<'CSS'
 
#container .lab .sectionIdentifier {
 
  background: none!important;
 
}
 
#container .lab .sectionIdentifier input {
 
  display: none;
 
}
 
#container .lab .deleteSection input {
 
  display: none;
 
}
 
CSS;
 
}
styles/general.css
Show inline comments
 
@@ -128,33 +128,24 @@ a:hover {
 
#container .section:nth-child(odd) td {
 
  background: #CCC;
 
}
 
#container .section.lab td {
 
  background: #96acc4;
 
}
 
#container .none {
 
  background: none!important; 
 
}
 
#container .emptyCell, .removeCell {
 
  background: none!important; 
 
}
 
#container .lab .sectionIdentifier {
 
  background: none!important;
 
}
 
#container .lab .sectionIdentifier input {
 
  display: none;
 
}
 
#container .lab .deleteSection input {
 
  display: none;
 
}
 
#container .lab .deleteSection:before {
 
  content: "LAB";
 
}
 

	
 
/* Input Formatting */
 

	
 
#container {
 
  margin-left: 2em;
 
}
 
.defaultText { 
 
  width: 300px;
 
}
0 comments (0 inline, 0 general)