Skip to content

Commit

Permalink
API CHANGE: first commit
Browse files Browse the repository at this point in the history
  • Loading branch information
fb3rasp committed Sep 5, 2011
0 parents commit f28287b
Show file tree
Hide file tree
Showing 92 changed files with 12,487 additions and 0 deletions.
20 changes: 20 additions & 0 deletions _config.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?php

/*
Requires XSLT-Processor, i.e.
>> sudo apt-get install php5-xsl
*/

// Change this field to anything except 'setup' do set the configuration fields
// to read-only.
CataloguePage::set_site_status('setup');

Director::addRules(100, array(
'admin/metadata' => "MetadataAdmin",
));


// Add model admin for the metadata entries.
CMSMenu::add_menu_item("metadata", 'Metadata', 'admin/metadata', "MetadataAdmin" );
63 changes: 63 additions & 0 deletions code/BrowsePage.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
<?php
/**
* This file defines the implementation of the Browse - Page type.
*
* @author Rainer Spittel (rainer at silverstripe dot com)
* @package geocatalog
*/

/**
* BrowsePage implements the page type to browse GeoNetwork records.
*
* This page type is used to browse GeoNetwork data and visualise the results.
*/
class BrowsePage extends CataloguePage {

/**
* Overwrites {@link SiteTree::getCMSFields}.
*
* Appends a GeoNetwork JavaScript validator the the CMS backend.
*
* @return FieldSet
*/
function getCMSFields() {
Requirements::javascript('geocatalog/javascript/GeonetworkUrlValidator.js');

$fields = parent::getCMSFields();
return $fields;
}
}

/**
* Controller Class for BrowsePage
*
* Page controller class for Browse-Page {@link BrowsePage}. The controller
* class handles the requests and delegates the requests to the page instance
* as well as to the available GeoNetwork node.
*/
class BrowsePage_Controller extends CataloguePage_Controller {

/**
* Validate HTTP-Request parameter.
*
* BrowsePage customise the search capabilities and allows the 'empty' search.
*
* @param array $params http-request parameter
*/
protected function validateRequest($params) {
}

/**
* Action: index
*
* Browse Page perform a empty search to populate the all results on the
* Browse Page.
*/
public function index($data) {
// perform a standard search, but the validation has been disabled to
// enable an empty search on the metadata repository.

$params = array();
return $this->dogetrecords($params);
}
}
118 changes: 118 additions & 0 deletions code/CatalogueHomePage.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
<?php
/**
* @author Rainer Spittel (rainer at silverstripe dot com)
* @package geocatalog
* @subpackage code
*/

/**
* General catalogue page
*/
class CatalogueHomePage extends Page {

public static $db = array(
'SearchPageName' => "Varchar", // Name of the searchpage (Type CataloguePage) to redirect the search to
'BrowsePageName' => "Varchar", // Name of the searchpage (Type BrowsePage) to redirect the search to
'SubmitDataPageName' => "Varchar", // Name of the searchpage (Type CataloguePage) to redirect the search to
);

/**
* Provide an array of instances of subclasses for a given classname. The
* array can be used to populate values into drop down lists to select
* redirect pages.
*
* @param string $classname Name of the parent class
*
* @return array
*/
static function get_page_subclasses($classname) {

$classes = ClassInfo::subclassesFor($classname);
$pages = array();
foreach($classes as $class) {
$dataObjectSet = DataObject::get($class);

if ($dataObjectSet) {
$iter = $dataObjectSet->getIterator();
$item = $iter->current();

while ($item) {
$pages[$item->URLSegment] = $item->Title ." (url: ".$item->URLSegment.")";
$item =$iter->next();
}
}
}
return $pages;
}

/**
* This method returns the standard form for the metadata search.
*
* To enable the submission into a different controller, I choose the
* work around to define the Form Object Link method in this controller
* to point to the url-segment of the selected catalogue page {@link FormObjectLink).
*
* @return Form
*/
function Form() {
// create the search form
$searchForm = CataloguePage_Controller::get_search_form_name();
$form = new $searchForm($this,'dogetrecords');
return $form;
}

/**
* Overwrites the controller - link handling for form submissions.
* This method defines the form submission action for the search form, which
* sends its request to the catalogue page controller class.
*
* @return string URL segment and action name for the search form.
*/
function FormObjectLink() {
return $this->SearchPageName."/dogetrecords";
}

/**
* Populate the additional field.
* @return Fieldset
*/
function getCMSFields() {
$fields = parent::getCMSFields();

$pagesSearch = CatalogueHomePage::get_page_subclasses('CataloguePage');
$pagesBrowse = CatalogueHomePage::get_page_subclasses('BrowsePage');
$pagesRegister = CatalogueHomePage::get_page_subclasses('RegisterDataPage');

$fields->addFieldsToTab('Root.Content.Catalogue',
array(
new DropdownField('SearchPageName','Use this page as search page (must be of type "Catalogue Page")',$pagesSearch), // drop down
new DropdownField('BrowsePageName','Use this page as browse page (must be of type "Browse Page")',$pagesBrowse), // drop down
new DropdownField('SubmitDataPageName','Use this page as submit data page (must be of type "Register Data Page")',$pagesRegister), // drop down
));

if (CataloguePage::get_site_status() != 'setup') {
$fields->makeFieldReadonly('SearchPageName');
$fields->makeFieldReadonly('BrowsePageName');
$fields->makeFieldReadonly('SubmitDataPageName');
}

return $fields;
}
}

/**
* Customised controller class
*/
class CatalogueHomePage_Controller extends Page_Controller {


/**
* Initialisation function that is run before any action on the controller is called.
*/
public function init() {
parent::init();
$this->extend('extendInit');
}
}

?>
Loading

0 comments on commit f28287b

Please sign in to comment.