dmBridge PHP API
DMCPCollectionController.php
00001 <?php
00002 #
00003 # dmBridge: a data access framework for CONTENTdm(R)
00004 #
00005 # Copyright © 2009, 2010, 2011 Board of Regents of the Nevada System of Higher
00006 # Education, on behalf of the University of Nevada, Las Vegas
00007 #
00008 
00013 class DMCPCollectionController extends DMCPAdminController {
00014 
00015    public function edit($alias) {
00016       $this->preFlightCheck();
00017 
00018       $alias = DMCollection::getSanitizedAlias($alias);
00019       $collection = DMCollectionFactory::getCollection($alias);
00020 
00021       $form = new DMCPEditCollectionForm($collection);
00022       $this->setForm($form);
00023 
00024       if (DMHTTPRequest::getCurrent()->getMethod() == DMHTTPMethod::POST) {
00025          $this->handleForm(DMLocalizedString::getString("COLLECTION_UPDATED"),
00026                "admin/collections");
00027       }
00028 
00029       try {
00030          $this->tpl_vars['collection'] = $collection;
00031          // overview page
00032          $this->tpl_vars['overview_page_url'] = $form
00033                ->getFieldByName("overview_page_url")->getHTMLTag();
00034          // image url
00035          $this->tpl_vars['image_url_512'] = $form
00036                ->getFieldByName("image_url_512")->getHTMLTag();
00037          // description
00038          $this->tpl_vars['description'] = $form
00039                ->getFieldByName("description")->getHTMLTag();
00040 
00041          // template set
00042          $this->tpl_vars['template_set'] = $form
00043                ->getFieldByName("template_set")->getHTMLTag();
00044 
00045          // inheritances
00046          foreach ($form->getFieldsByName("inherit_template_set") as $field) {
00047             $this->tpl_vars['inherit_template_set'][] = $field->getHTMLTag();
00048          }
00049          foreach ($form->getFieldsByName("inherit_object_view") as $field) {
00050             $this->tpl_vars['inherit_object_view'][] = $field->getHTMLTag();
00051          }
00052          foreach ($form->getFieldsByName("inherit_results_view") as $field) {
00053             $this->tpl_vars['inherit_results_view'][] = $field->getHTMLTag();
00054          }
00055          foreach ($form->getFieldsByName("inherit_search_view") as $field) {
00056             $this->tpl_vars['inherit_search_view'][] = $field->getHTMLTag();
00057          }
00058 
00059          // object viewers
00060          foreach ($form->getFieldsByName("mime") as $field) {
00061             $this->tpl_vars['mime'][] = $field->getHTMLTag();
00062          }
00063          foreach ($form->getFieldsByName("class") as $field) {
00064             $this->tpl_vars['class'][] = $field->getHTMLTag();
00065          }
00066          foreach ($form->getFieldsByName("width") as $field) {
00067             $this->tpl_vars['width'][] = $field->getHTMLTag();
00068          }
00069          foreach ($form->getFieldsByName("height") as $field) {
00070             $this->tpl_vars['height'][] = $field->getHTMLTag();
00071          }
00072          foreach ($form->getFieldsByName("max_file_size_k") as $field) {
00073             $this->tpl_vars['max_file_size_k'][] = $field->getHTMLTag();
00074          }
00075 
00076          // results view
00077          foreach ($form->getFieldsByName("field_nicks") as $field) {
00078             $this->tpl_vars['field_nicks'][] = $field->getHTMLTag();
00079          }
00080          foreach ($form->getFieldsByName("field_nicks_sortable") as $field) {
00081             $this->tpl_vars['field_nicks_sortable'][] = $field->getHTMLTag();
00082          }
00083          foreach ($form->getFieldsByName("field_nicks_default_sort") as $field) {
00084             $this->tpl_vars['field_nicks_default_sort'][] = $field->getHTMLTag();
00085          }
00086          foreach ($form->getFieldsByName("field_nicks_max_words") as $field) {
00087             $this->tpl_vars['field_nicks_max_words'][] = $field->getHTMLTag();
00088          }
00089 
00090          // grid/list view
00091          foreach ($form->getFieldsByName("grid_fields") as $field) {
00092             $this->tpl_vars['grid_fields'][] = $field->getHTMLTag();
00093          }
00094 
00095          // facets
00096          foreach ($form->getFieldsByName("facet_fields") as $field) {
00097             $this->tpl_vars['facet_fields'][] = $field->getHTMLTag();
00098          }
00099 
00100          // search view
00101          $this->tpl_vars['begin_year'] = $form
00102                ->getFieldByName("begin_year")->getHTMLTag();
00103          $this->tpl_vars['end_year'] = $form
00104                ->getFieldByName("end_year")->getHTMLTag();
00105       } catch (DMException $e) {
00106          DMHTTPRequest::getCurrent()->getSession()->setFlash(
00107                new DMFlash($e->getMessage(), false));
00108       }
00109 
00110       $this->renderTemplate("/templates/collection/edit.html.php");
00111       die;
00112    }
00113 
00114    public function index() {
00115       $this->preFlightCheck();
00116 
00117       if (DMHTTPRequest::getCurrent()->getMethod() == DMHTTPMethod::POST) {
00118          $this->delete();
00119       }
00120 
00121       $this->renderTemplate("/templates/collection/index.html.php");
00122       die;
00123    }
00124 
00125 }
 All Data Structures Functions Variables