Skip to content
Snippets Groups Projects
Commit 77cf3b21 authored by Brett Bieber's avatar Brett Bieber
Browse files

Remove static archive generation

parent 0a19abb3
No related branches found
No related tags found
No related merge requests found
......@@ -39,12 +39,6 @@ Maintenance Tasks:
Log In to Database:
SSH to ucommsrv, run mysql -u ...
Create a static version:
Static version is generated nightly, and is available at http://bulletin.unl.edu/archive.html
Open http://bulletin.unl.edu/archive.html in Safari.
Use Print to PDF.
Add a Subject Code:
......
<?php
require_once dirname(__FILE__).'/Archive/Page.php';
class UNL_Catalog_Archive
{
public $layout = array();
public $file;
function __construct()
{
$this->layout[] = 'Index';
$this->layout[] = 'Colleges';
$this->file = '/tmp/unl_catalog'.md5(time());
$this->file = '/tmp/unl_catalog.html';
}
function buildLayout()
{
$f = fopen($this->file, 'w');
foreach ($this->layout as $section) {
require_once dirname(__FILE__).'/Archive/Section/'.$section.'.php';
$section = 'UNL_Catalog_Archive_Section_'.$section;
$section = new $section();
$this->buildSection($section, $f);
}
fclose($f);
}
function buildSection(UNL_Catalog_Archive_Section $section, $f)
{
foreach ($section->getPages() as $url) {
$page = new UNL_Catalog_Archive_Page($url);
fwrite($f, str_replace(
array('<div id="coursestab" style="display:none;">',
'<div id="dept_faculty" style="display:none;">'),
array('<div id="coursestab">',
'<div id="dept_faculty"'),
$page->getContent()));
}
}
function __toString()
{
$c = new UNL_Catalog();
$c->run();
$c->p->maincontentarea = file_get_contents($this->file);
return $c->toHtml();
}
}
?>
\ No newline at end of file
<?php
require_once 'UNL/Templates/Scanner.php';
class UNL_Catalog_Archive_Page
{
protected $url;
/**
* scanned template file
*
* @var UNL_Templates_Scanner
*/
protected $page;
function __construct($url)
{
$this->url = $url;
if ($p = file_get_contents($url)) {
$this->page = new UNL_Templates_Scanner($p);
} else {
throw new Exception('Could not get '.$url);
}
}
/**
* get the content of the page
*
* @return string
*/
public function getContent()
{
return $this->page->maincontentarea;
}
public function getURL()
{
return $this->url;
}
}
?>
\ No newline at end of file
<?php
interface UNL_Catalog_Archive_Section
{
public function getPages();
public function getTitle();
}
<?php
require_once dirname(__FILE__).'/../Section.php';
class UNL_Catalog_Archive_Section_Colleges implements UNL_Catalog_Archive_Section
{
protected $title = 'Academic Colleges';
function getTitle()
{
return $this->title;
}
function getPages()
{
return array('http://bulletin.unl.edu/graduate/Academic_Colleges',
'http://bulletin.unl.edu/graduate/College_of_Agricultural_Sciences_and_Natural_Resources',
'http://bulletin.unl.edu/graduate/College_of_Architecture',
'http://bulletin.unl.edu/graduate/College_of_Arts_and_Sciences',
'http://bulletin.unl.edu/graduate/College_of_Business_Administration',
'http://bulletin.unl.edu/graduate/College_of_Education_and_Human_Sciences',
'http://bulletin.unl.edu/graduate/College_of_Engineering',
'http://bulletin.unl.edu/graduate/Hixson-Lied_College_of_Fine_and_Performing_Arts',
'http://bulletin.unl.edu/graduate/College_of_Journalism_and_Mass_Communications',
'http://bulletin.unl.edu/graduate/College_of_Law');
}
}
<?php
require_once dirname(__FILE__).'/../Section.php';
class UNL_Catalog_Archive_Section_Index implements UNL_Catalog_Archive_Section
{
protected $title = '2012-2013 Graduate Bulletin';
function getTitle()
{
return $this->title;
}
function getPages()
{
return array('http://bulletin.unl.edu/');
}
}
<?php
require_once dirname(__FILE__).'/../config.inc.php';
require_once 'UNL/Catalog/Archive.php';
$archive = new UNL_Catalog_Archive();
$archive->buildLayout();
file_put_contents(dirname(__FILE__).'/archive.html', $archive->__toString());
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment