Skip to content

Commit

Permalink
Fixes some bugs and updates some tests
Browse files Browse the repository at this point in the history
  • Loading branch information
patrickmj committed May 15, 2012
1 parent a9d4ce3 commit 238d7db
Show file tree
Hide file tree
Showing 10 changed files with 32 additions and 45 deletions.
2 changes: 1 addition & 1 deletion functions.php
Expand Up @@ -27,7 +27,7 @@ function exhibit_builder_install()
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;");


$db->query("CREATE TABLE IF NOT EXISTS `{$db->prefix}exhibit_section_pages` (
$db->query("CREATE TABLE IF NOT EXISTS `{$db->prefix}exhibit_page_entries` (
`id` int(10) unsigned NOT NULL auto_increment,
`item_id` int(10) unsigned default NULL,
`page_id` int(10) unsigned NOT NULL,
Expand Down
2 changes: 1 addition & 1 deletion helpers/ExhibitFunctions.php
Expand Up @@ -68,7 +68,7 @@ function exhibit_builder_exhibit_uri($exhibit = null, $exhibitPage = null)
$exhibitSlug = ($exhibit instanceof Exhibit) ? $exhibit->slug : $exhibit;

//If there is no page slug available, we want to build a URL for the summary page
if (empty($exhibitPage)) {
if (!$exhibitPage) {
$uri = public_uri(array('slug'=>$exhibitSlug), 'exhibitSimple');
} else {
$pagesTrail = $exhibitPage->getAncestors();
Expand Down
1 change: 1 addition & 0 deletions helpers/ExhibitPageFunctions.php
Expand Up @@ -134,6 +134,7 @@ function exhibit_builder_page_nav($exhibitPage = null, $linkTextType = 'title')
$linkText = $page->order;
break;
case 'title':
case 'Title':
default:
$linkText = $page->title;
break;
Expand Down
4 changes: 2 additions & 2 deletions models/ExhibitPermissions.php
Expand Up @@ -30,8 +30,8 @@ public function __construct(Omeka_Db_Select $sql)
}

if(!$hasPermission)
{
$sql->where('e.public = 1');
{ $db = get_db();
$sql->where("exhibits.public = 1");
}
}
}
14 changes: 7 additions & 7 deletions models/ExhibitTable.php
Expand Up @@ -35,11 +35,11 @@ public function applySearchFilters($select, $params)
case 'sort':
switch($paramValue) {
case 'alpha':
$select->order("e.title ASC");
$select->order("exhibits.title ASC");
break;

case 'recent':
$select->order("e.id DESC");
$select->order("exhibits.id DESC");
break;
}
break;
Expand All @@ -61,8 +61,8 @@ public function findBySlug($slug)
{
$db = $this->getDb();
$select = new Omeka_Db_Select;
$select->from(array('e'=>$db->Exhibit), array('e.*'));
$select->where("e.slug = ?");
$select->from(array('exhibits'=>$db->Exhibit), array('exhibits.*'));
$select->where("exhibits.slug = ?");
$select->limit(1);
new ExhibitPermissions($select);
return $this->fetchObject($select, array($slug));
Expand All @@ -78,7 +78,7 @@ public function count($params = array())
$db = $this->getDb();

$select = new Omeka_Db_Select;
$select->from(array('e'=>$db->Exhibit), "COUNT(DISTINCT(e.id))");
$select->from(array('exhibits'=>$db->Exhibit), "COUNT(DISTINCT(exhibits.id))");
new ExhibitPermissions($select);

$this->applySearchFilters($select, $params);
Expand All @@ -91,8 +91,8 @@ public function find($id)
$db = $this->getDb();

$select = new Omeka_Db_Select;
$select->from(array('e'=>$db->Exhibit), array('e.*'));
$select->where("e.id = ?");
$select->from(array('exhibits'=>$db->Exhibit), array('exhibits.*'));
$select->where("exhibits.id = ?");

new ExhibitPermissions($select);

Expand Down
6 changes: 1 addition & 5 deletions routes.ini
Expand Up @@ -20,16 +20,12 @@ exhibitSimple.defaults.controller = exhibits
exhibitSimple.defaults.module = exhibit-builder
exhibitSimple.defaults.action = summary

exhibitShow.route = "exhibits/show/:slug/:page_slug_1/:page_slug_2/:page_slug_3/:page_slug_4/:page_slug_5/:page_slug_6"
exhibitShow.route = "exhibits/show/:slug/:page_slug_1/:page_slug_2/:page_slug_3"
exhibitShow.defaults.controller = exhibits
exhibitShow.defaults.action = show
exhibitShow.defaults.module = exhibit-builder
exhibitShow.defaults.page_slug_2 = ""
exhibitShow.defaults.page_slug_3 = ""
exhibitShow.defaults.page_slug_4 = ""
exhibitShow.defaults.page_slug_5 = ""
exhibitShow.defaults.page_slug_6 = ""


exhibitItem.route = "exhibits/show/:slug/item/:item_id"
exhibitItem.defaults.controller = exhibits
Expand Down
2 changes: 1 addition & 1 deletion tests/ExhibitBuilder_IntegrationHelper.php
Expand Up @@ -76,7 +76,7 @@ public function createNewExhibits($numberPublicNotFeatured = 5, $numberPublicFea
}


public function createNewExhibitPage($exhibit, $parentPage = null, $title, $slug = '', $order = 1, $layout = 'text')
public function createNewExhibitPage($exhibit, $parentPage = null, $title, $slug = '', $order = 1, $layout = 'text', $parentId = null)
{
$exhibitPage = new ExhibitPage;
$exhibitPage->exhibit_id = $exhibit->id;
Expand Down
22 changes: 12 additions & 10 deletions tests/cases/Globals/ExhibitBuilderPageNavTest.php
Expand Up @@ -16,12 +16,14 @@ public function setUp()
$this->assertTrue($this->exhibit->exists());

$maxPageCount = 4;
$parentId = null;
for($i = 1; $i <= $maxPageCount; $i++) {
$exhibitPage = $this->helper->createNewExhibitPage($this->exhibit, null, 'Exhibit Page Title ' . $i, 'exhibitpageslug' . $i, $i, 'text');
$exhibitPage = $this->helper->createNewExhibitPage($this->exhibit, null, 'Exhibit Page Title ' . $i, 'exhibitpageslug' . $i, 1, 'text', $parentId);
$this->assertTrue($exhibitPage->exists());
$parentId = $exhibitPage->id;
}

$this->dispatch('exhibits/show/exhibitslug/exhibitpageslug/exhibitpageslug2');
$this->dispatch('exhibits/show/exhibitslug/exhibitpageslug1/exhibitpageslug2');

$this->basePageUrl = public_uri('exhibits/show/exhibitslug/exhibitpageslug1/exhibitpageslug2');
}
Expand All @@ -39,19 +41,19 @@ public function testTitleOutput()
$html .= '<ul class="exhibit-page-nav">' . "\n";

$html .= '<li>';
$html .= '<a class="exhibit-page-title" href="' . $this->basePageUrl . '1' . '">Exhibit Page Title 1</a>';
$html .= '<a class="exhibit-page-title" href="' . $this->basePageUrl . '">Exhibit Page Title 1</a>';
$html .= '</li>' . "\n";

$html .= '<li class="current">';
$html .= '<a class="exhibit-page-title" href="' . $this->basePageUrl . '2' . '">Exhibit Page Title 2</a>';
$html .= '<a class="exhibit-page-title" href="' . $this->basePageUrl . '">Exhibit Page Title 2</a>';
$html .= '</li>' . "\n";

$html .= '<li>';
$html .= '<a class="exhibit-page-title" href="' . $this->basePageUrl . '3' . '">Exhibit Page Title 3</a>';
$html .= '<a class="exhibit-page-title" href="' . $this->basePageUrl . '">Exhibit Page Title 3</a>';
$html .= '</li>' . "\n";

$html .= '<li>';
$html .= '<a class="exhibit-page-title" href="' . $this->basePageUrl . '4' . '">Exhibit Page Title 4</a>';
$html .= '<a class="exhibit-page-title" href="' . $this->basePageUrl . '">Exhibit Page Title 4</a>';
$html .= '</li>' . "\n";

$html .= '</ul>' . "\n";
Expand All @@ -67,19 +69,19 @@ public function testOrderOutput()
$html .= '<ul class="exhibit-page-nav">' . "\n";

$html .= '<li>';
$html .= '<a class="exhibit-page-title" href="' . $this->basePageUrl . '1' . '">1</a>';
$html .= '<a class="exhibit-page-title" href="' . $this->basePageUrl . '">1</a>';
$html .= '</li>' . "\n";

$html .= '<li class="current">';
$html .= '<a class="exhibit-page-title" href="' . $this->basePageUrl . '2' . '">2</a>';
$html .= '<a class="exhibit-page-title" href="' . $this->basePageUrl . '">2</a>';
$html .= '</li>' . "\n";

$html .= '<li>';
$html .= '<a class="exhibit-page-title" href="' . $this->basePageUrl . '3' . '">3</a>';
$html .= '<a class="exhibit-page-title" href="' . $this->basePageUrl . '">3</a>';
$html .= '</li>' . "\n";

$html .= '<li>';
$html .= '<a class="exhibit-page-title" href="' . $this->basePageUrl . '4' . '">4</a>';
$html .= '<a class="exhibit-page-title" href="' . $this->basePageUrl . '">4</a>';
$html .= '</li>' . "\n";

$html .= '</ul>' . "\n";
Expand Down
10 changes: 6 additions & 4 deletions tests/cases/Globals/LinkToExhibitTest.php
Expand Up @@ -5,7 +5,7 @@
class LinkToExhibitTest extends Omeka_Test_AppTestCase
{
protected $_isAdminTest = false;

public function setUp()
{
parent::setUp();
Expand All @@ -24,12 +24,14 @@ public function testLinkToExhibit()
$this->dispatch('exhibits/show/exhibit-title');
$exhibitLink = link_to_exhibit('Wow');
$this->assertThat($exhibitLink, $this->stringContains('exhibits/show/exhibit-title" >Wow</a>'));

$exhibitLink = link_to_exhibit('Wow', array('class'=>'zany', 'id' => 'wowlink'));
$this->assertThat($exhibitLink, $this->stringContains('exhibits/show/exhibit-title" class="zany" id="wowlink">Wow</a>'));

$exhibit2 = $this->helper->createNewExhibit(1, 0, 'Exhibit Title 2', 'Exhibit Description 2', 'Jim Safley');
$exhibitLink = link_to_exhibit('Wow', array('class'=>'zany', 'id' => 'wowlink'), null, null, $exhibit2);

$this->assertEquals('exhibit-title-2', $exhibit2->slug);
$exhibitLink = link_to_exhibit('Wow', array('class'=>'zany', 'id' => 'wowlink'), null, $exhibit2);
$this->assertThat($exhibitLink, $this->stringContains('exhibits/show/exhibit-title-2" class="zany" id="wowlink">Wow</a>'));
}
}
14 changes: 0 additions & 14 deletions views/public/exhibits/show.php
@@ -1,20 +1,6 @@
<?php head(array('title' => html_escape(exhibit('title') . ' : '. exhibit_page('title')), 'bodyid'=>'exhibit','bodyclass'=>'show')); ?>
<div id="primary">

<?php

$request = Omeka_Context::getInstance()->getFrontController()->getRequest();
$exhibit_slug = $request->getParam('slug');
$section_slug = $request->getParam('section_slug');
$page_slug = $request->getParam('page_slug');

echo $exhibit_slug;
echo $section_slug;
echo $page_slug;


?>


<h1><?php echo link_to_exhibit(); ?></h1>
<div id="nav-container">
Expand Down

0 comments on commit 238d7db

Please sign in to comment.