dmBridge PHP API
DMCPFeedSettingsForm.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 DMCPFeedSettingsForm extends DMAbstractForm {
00014 
00015    protected function init() {
00016       $f = new DMTextField('copyright');
00017       $f->addAttribute('id', 'copyright');
00018       $f->addAttribute('style', 'width:98%');
00019       $f->setMinLength(10);
00020       $f->setMaxLength(150);
00021       $f->setLabel('Copyright notice');
00022       $this->addField($f);
00023 
00024       $f = new DMSelectField('language');
00025       $f->addAttribute('id', 'language');
00026       foreach (DMLanguage::getAll() as $l) {
00027          $f->addOption(
00028             DMString::websafe($l->getISO6391Code()),
00029             DMString::websafe($l->getNativeName()));
00030       }
00031       $f->setLabel('Language');
00032       $this->addField($f);
00033 
00034       $f = new DMTextField('managing_editor_name');
00035       $f->addAttribute('id', 'managing_editor_name');
00036       $f->addAttribute('style', 'width:50%');
00037       $f->setMinLength(2);
00038       $f->setMaxLength(100);
00039       $f->setLabel('Managing editor name');
00040       $this->addField($f);
00041 
00042       $f = new DMTextField('managing_editor_email');
00043       $f->addAttribute('id', 'managing_editor_email');
00044       $f->addAttribute('style', 'width:50%');
00045       $f->setType(DMFormFieldType::EMAIL);
00046       $f->setLabel('Managing editor email address');
00047       $this->addField($f);
00048 
00049       $f = new DMTextField('webmaster_name');
00050       $f->addAttribute('id', 'webmaster_name');
00051       $f->addAttribute('style', 'width:50%');
00052       $f->setMinLength(2);
00053       $f->setMaxLength(100);
00054       $f->setLabel('Webmaster name');
00055       $this->addField($f);
00056 
00057       $f = new DMTextField('webmaster_email');
00058       $f->addAttribute('id', 'webmaster_email');
00059       $f->addAttribute('style', 'width:50%');
00060       $f->setType(DMFormFieldType::EMAIL);
00061       $f->setLabel('Webmaster email address');
00062       $this->addField($f);
00063 
00064       $f = new DMTextField('title');
00065       $f->addAttribute('id', 'title');
00066       $f->addAttribute('style', 'width:98%');
00067       $f->setMinLength(2);
00068       $f->setMaxLength(100);
00069       $f->setLabel('Feed title');
00070       $this->addField($f);
00071 
00072       $f = new DMTextField('subtitle');
00073       $f->addAttribute('id', 'subtitle');
00074       $f->addAttribute('style', 'width:98%');
00075       $f->setMinLength(2);
00076       $f->setMaxLength(100);
00077       $f->setLabel('Feed subtitle');
00078       $this->addField($f);
00079    }
00080 
00081    protected function loadFromDataStore() {
00082       $this->getFieldByName('copyright')->setValue(
00083          DMConfigXML::getInstance()->getFeedCopyright());
00084       $this->getFieldByName('language')->setValue(
00085          DMConfigXML::getInstance()->getFeedLanguage());
00086       $this->getFieldByName('managing_editor_name')->setValue(
00087          DMConfigXML::getInstance()->getFeedManagingEditorName());
00088       $this->getFieldByName('managing_editor_email')->setValue(
00089          DMConfigXML::getInstance()->getFeedManagingEditorEmail());
00090       $this->getFieldByName('webmaster_name')->setValue(
00091          DMConfigXML::getInstance()->getFeedWebmasterName());
00092       $this->getFieldByName('webmaster_email')->setValue(
00093          DMConfigXML::getInstance()->getFeedWebmasterEmail());
00094       $this->getFieldByName('title')->setValue(
00095          DMConfigXML::getInstance()->getFeedTitle());
00096       $this->getFieldByName('subtitle')->setValue(
00097          DMConfigXML::getInstance()->getFeedSubtitle());
00098    }
00099 
00100    public function doAction() {
00101       DMConfigXML::getInstance()->setFeedCopyright(
00102          $this->getFieldByName('copyright')->getValue());
00103       DMConfigXML::getInstance()->setFeedLanguage(
00104          $this->getFieldByName('language')->getValue());
00105       DMConfigXML::getInstance()->setFeedManagingEditorName(
00106          $this->getFieldByName('managing_editor_name')->getValue());
00107       DMConfigXML::getInstance()->setFeedManagingEditorEmail(
00108          $this->getFieldByName('managing_editor_email')->getValue());
00109       DMConfigXML::getInstance()->setFeedWebmasterName(
00110          $this->getFieldByName('webmaster_name')->getValue());
00111       DMConfigXML::getInstance()->setFeedWebmasterEmail(
00112          $this->getFieldByName('webmaster_email')->getValue());
00113       DMConfigXML::getInstance()->setFeedTitle(
00114          $this->getFieldByName('title')->getValue());
00115       DMConfigXML::getInstance()->setFeedSubtitle(
00116          $this->getFieldByName('subtitle')->getValue());
00117       DMConfigXML::getInstance()->save();
00118    }
00119 
00120 }
 All Data Structures Functions Variables