dmBridge PHP API
UNLVHighlightAddForm.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 UNLVHighlightAddForm extends DMAbstractForm {
00014 
00015    protected function init() {
00016       $f = new DMSelectField('alias');
00017       $f->addAttribute('id', 'alias');
00018       $f->addOption('', 'Choose a collection...');
00019       foreach (DMCollection::getAuthorized() as $c) {
00020          $f->addOption($c->getAlias(), DMString::truncate($c->getName(), 60));
00021       }
00022       $f->setLabel('Collection');
00023       $this->addField($f);
00024 
00025       $f = new DMTextField('ptr');
00026       $f->addAttribute('id', 'ptr');
00027       $f->addAttribute('size', '7');
00028       $f->setType(DMFormFieldType::INTEGER);
00029       $f->setMin(0);
00030       $f->setMax(1000000);
00031       $f->setLabel('Pointer');
00032       $this->addField($f);
00033 
00034       $f = new DMSelectField('year');
00035       $f->addAttribute('id', 'year');
00036       $f->setValue(date('Y'));
00037       $f->setLabel('Year');
00038       $min = date('Y');
00039       $max = date('Y', strtotime('+2 years'));
00040       $f->setMin($min);
00041       $f->setMax($max);
00042       foreach (range($min, $max) as $y) {
00043          $f->addOption($y, $y);
00044       }
00045       $this->addField($f);
00046 
00047       $f = new DMSelectField('month');
00048       $f->addAttribute('id', 'month');
00049       $f->setValue(date('n'));
00050       $f->setMin(1);
00051       $f->setMax(12);
00052       foreach (range(1, 12) as $m) {
00053          $f->addOption($m, date('F', mktime(0, 0, 0, $m, 2)));
00054       }
00055       $f->setLabel('Month');
00056       $this->addField($f);
00057 
00058       $f = new DMSelectField('day');
00059       $f->addAttribute('id', 'day');
00060       $f->setValue(date('j'));
00061       $f->setMin(1);
00062       $f->setMax(31);
00063       foreach (range(1, 31) as $d) {
00064          $f->addOption($d, $d);
00065       }
00066       $f->setLabel('Day');
00067       $this->addField($f);
00068    }
00069 
00070    protected function loadFromDataStore() {}
00071 
00072    public function doAction() {
00073       $col = DMCollectionFactory::getCollection(
00074             $this->getFieldByName('alias')->getValue());
00075       $object = DMObjectFactory::getObject($col,
00076             (int) $this->getFieldByName('ptr')->getValue());
00077       $date = new DMDateTime(
00078          sprintf("%d-%d-%d",
00079             $this->getFieldByName("year")->getValue(),
00080             $this->getFieldByName("month")->getValue(),
00081             $this->getFieldByName("day")->getValue()));
00082 
00083       $ds = UNLVHighlightDataStoreFactory::getDataStore();
00084       $ds->addHighlightedObject($object, $date);
00085    }
00086 
00087 }
 All Data Structures Functions Variables