Changeset - d7044a583ccc
[Not reviewed]
default
0 2 0
Nathan Brink (binki) - 14 years ago 2012-02-11 19:57:37
ohnobinki@ohnopublishing.net
Add the name of the chosen university/school to <title/> for SEO.
2 files changed with 9 insertions and 6 deletions:
0 comments (0 inline, 0 general)
inc/class.page.php
Show inline comments
 
@@ -48,49 +48,49 @@ set_include_path(get_include_path() . PA
 
$use_captcha = FALSE;
 
$admin_enable_purge = FALSE;
 
$qtips_always = FALSE;
 
$input_warning_banner = FALSE;
 
$feedback_disk_log = FALSE;
 

	
 
$config_inc = dirname(__FILE__) . DIRECTORY_SEPARATOR . 'config.inc';
 
if (file_exists($config_inc)) {
 
  require_once($config_inc);
 
}
 

	
 

	
 
/**
 
 * \brief
 
 *   Produces XHTML output for the user and helps with other browser
 
 *   interaction.
 
 *
 
 * Supports styled XHTML pages, modular script inclusion, and other
 
 * various features.
 
 */
 
class page
 
{
 

	
 
  /* Site-wide configuration options */
 
  private $base_title = 'SlatePermutate - Find the schedule that works for you!';
 
  private $base_title = array('SlatePermutate', 'Find the schedule that works for you!');
 
  private $doctype = 'html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"';
 
  private $htmlargs = 'xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"';
 

	
 
  private $pageGenTime = 0;
 

	
 
  private $xhtml = FALSE;
 

	
 
  /* Scripts and styles */
 
  private $headCode = array();
 

	
 
  private $trackingcode = ''; // Tracking code
 
  private $ga_conversions_code = ''; // Conversion tracking code
 
  private $pagetitle = ''; // Title of page
 
  private $scripts = array(); // Scripts to include on page
 
  private $meta;
 

	
 
  /* the current school. See get_school(). */
 
  private $school;
 

	
 
  private $semester;
 

	
 
  /*
 
   * Whether or not the user should be presented with the option to
 
   * change the school profile or semester.
 
@@ -162,48 +162,51 @@ class page
 
       $this->trackingcode = '<script type="text/javascript" src="' . $ga_www . 'google-analytics.com/ga.js" />' . "\n"
 
	 . $this->trackingcode
 
	 . '  <script type="text/javascript">' . "\n"
 
	 . '  ' . ($this->xhtml ? '<![CDATA[' : '') . "\n"
 
	 . "     var mytrackers = new Array();";
 

	
 
       $i = 0;
 
       foreach ($ga_trackers as $ga_tracker)
 
	 {
 
	   $this->trackingcode .= "\n"
 
	     . '      mytrackers[' . $i . '] = _gat._getTracker(\'' . $ga_tracker . "');\n"
 
	     . '      mytrackers[' . $i . "]._trackPageview();\n";
 
	 }
 

	
 
       $this->trackingcode .= '  ' . ($this->xhtml ? ']]>'       : '') . "\n"
 
	 . "  </script>\n";
 
     }
 

	
 
    self::session_start();
 
    /* everything that needs sessions started to work: */
 

	
 
    if (empty($options['school']))
 
      $options['school'] = school_load_guess();
 
    $this->school = $options['school'];
 
    if ($this->school['id'] != 'default')
 
      /* If we have a non-generic school, put it into base_title */
 
      array_unshift($this->base_title, $this->school['name']);
 

	
 
    if (empty($options['semester']))
 
      $options['semester'] = school_semester_guess($this->school);
 
    $this->semester = $options['semester'];
 

	
 
    if (!isset($options['school_semester_constant']))
 
      $options['school_semester_constant'] = TRUE;
 
    $this->school_semester_constant = (bool)$options['school_semester_constant'];
 

	
 
    if($immediate
 
       && $ntitle != "NOHEAD")
 
      $this->head();
 
 }
 

	
 
  /**
 
   * \brief
 
   *   Instantiate a new page for the caller.
 
   *
 
   * The caller must explicitly call the page::head() function upon
 
   * the value that is returned. No implicit actions are supported
 
   * anymore.
 
   *
 
   * \param $title
 
   *   The title of the page. Must be completely UTF-8 (will be
 
@@ -349,49 +352,49 @@ class page
 

	
 
    /* Mention that this is a canonical URI with <link rel="canonical"/> */
 
    $this->headcode_add('link_rel_canonical', '<link rel="canonical" href="'
 
			. htmlentities(self::uri_resolve($uri_full), ENT_QUOTES) . '"'
 
			. ($this->xhtml ? '/>' : '></link>'),
 
			TRUE);
 
  }
 

	
 
  /**
 
   * \brief
 
   *   Output the HTML header for a page, including <!DOCTYPE>, <head />, and opening structure
 
   */
 
  public function head()
 
  {
 
    if ($this->xhtml) {
 
       header('Content-Type: application/xhtml+xml; charset=utf-8');
 
      echo '<?xml version="1.0" encoding="utf-8"?>' . PHP_EOL;
 
    }
 
    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 .
 
	  '    <title>' . $this->pagetitle . ' - ' . $this->base_title[0] . ' - ' . $this->base_title[1] . '</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
 
      . '    <style type="text/css">' . PHP_EOL
 
      . $this->cdata_wrap(school_page_css($this->school))
 
      . '    </style>' . PHP_EOL;
 

	
 
    foreach ($this->meta as $key => $value)
 
      echo '    <meta name="' . htmlentities($key, ENT_QUOTES)
 
      . '" content="' . htmlentities($value, ENT_QUOTES)
 
      . '" ' . ($this->xhtml ? '/' : '') .  '>' . PHP_EOL;
 

	
 
    // Write out all passed scripts
 
    foreach ($this->scripts as $i)
 
      echo '    ' . $this->headCode["$i"] . "\n";
 

	
 
    /*
 
     * Perhaps we should have a separate array for javascript library
 
     * initialization snippets.
 
     */
 
    $javascript_init = '';
input.php
Show inline comments
 
@@ -90,49 +90,49 @@ elseif (!empty($_REQUEST['e']))
 

	
 
    if (!empty($postData['school']))
 
      {
 
	$school = school_load($postData['school']);
 
	if (!empty($school))
 
	  $inputPage_options['school'] = $school;
 
      }
 

	
 
    if (!empty($school) && !empty($postData['semester']))
 
      {
 
	$semesters = school_semesters($school);
 
	if (!empty($semesters[$postData['semester']]))
 
	  $inputPage_options['semester'] = $semester;
 
      }
 

	
 
    $creating_new_schedule = FALSE;
 
  }
 

	
 
/*
 
 * We cannot initialize the page object nor guess the school before
 
 * figuring loading a saved schedule because we'll default to that
 
 * saved_schedule's school/semester.
 
 */
 
$scripts = array('jQuery', 'jQueryUI', 'qTip2', 'schedInput');
 
$inputPage = page::page_create('Scheduler', $scripts, $inputPage_options);
 
$inputPage = page::page_create('Enter Courses', $scripts, $inputPage_options);
 
$school = $inputPage->get_school();
 
$semester = $inputPage->semester_get();
 

	
 
$my_hc = 'var slate_permutate_example_course_id = ' . json_encode(school_example_course_id($school)) . ';
 

	
 
jQuery(document).ready(
 
  function()
 
  {
 
    var class_last = 0;
 

	
 
';
 
if ($sch)
 
{
 
  foreach ($sch->courses_get() as $course)
 
    {
 
      $my_hc .= input_course_js($course, '    ');
 
    }
 
}
 
elseif ($errors_fix)
 
  {
 
    foreach ($_POST['postData'] as $course)
 
      if (is_array($course))
 
	{
 
	  $title = '';
 
@@ -160,55 +160,55 @@ elseif ($errors_fix)
 
  }
 
else
 
  {
 
    $default_courses = school_default_courses($school);
 
    foreach ($default_courses as $default_class)
 
      $my_hc .= input_course_js($default_class, '    ');
 
  }
 
$my_hc .= '    class_last = add_class();' . PHP_EOL;
 
if ($qtips_always || !isset($_SESSION['saw_qtips']))
 
  {
 
    $my_hc .= '    addTips();' . PHP_EOL;
 
    $_SESSION['saw_qtips'] = TRUE;
 
  }
 
$my_hc .= '  });
 
';
 

	
 
$inputPage->headcode_add('scheduleInput', $inputPage->script_wrap($my_hc), TRUE);
 

	
 
if ($school['id'] != 'default'
 
    && empty($_REQUEST['selectschool'])
 
    && empty($_REQUEST['selectsemester']))
 
  {
 
    /*
 
     * If we have chosen a school, set the canonical URL so that it
 
     * contains the school and semester.
 
     * contains the school and, optionall, the specified
 
     * schedule. This way, when Google caches the input.php page, the
 
     * <title/> it sees will reflect the selected school.
 
     */
 
    $query = array('school' => $school['id']);
 
    if ($sch)
 
      $query['s'] = $sch->id_get();
 
    if (!empty($semester))
 
      $query['semester'] = $semester['id'];
 
    $inputPage->canonize('input.php', $query);
 
  }
 

	
 
$inputPage->head();
 

	
 
/*
 
 * Force a student to choose a school or declare he's a generic
 
 * student before displaying the input form. To do this, we need
 
 * another variable in $_SESSION: $_SESSION['school_chosen'].
 
 */
 
if (!empty($_REQUEST['school']) && !empty($_SESSION['school']) && !strcmp($_REQUEST['school'], $_SESSION['school']))
 
  $_SESSION['school_chosen'] = TRUE;
 
if (!empty($_REQUEST['selectschool'])
 
    || empty($school) || $school['id'] == 'default' && empty($_SESSION['school_chosen']))
 
  {
 
    $next_page = 'input.php?';
 
    if (isset($_GET['s']))
 
      $next_page .= 's=' . (int)$_GET['s'] . '&';
 
    if (isset($_GET['semester']))
 
      $next_page .= 'semester=' . htmlentities($$_GET['semester']) . '&';
 
?>
 
<h2>School Selection</h2>
 
<p>
 
  Choose the school you attend from the list below. <strong>If you cannot
0 comments (0 inline, 0 general)