Пример #1
0
 public function __construct($options = null)
 {
     $refs = new Coinclassifications();
     $ref_list = $refs->getClass();
     parent::__construct($options);
     $this->setName('addcoinreference');
     $decorators = array(array('ViewHelper'), array('Description', array('placement' => 'append', 'class' => 'info')), array('Errors', array('placement' => 'append', 'class' => 'error', 'tag' => 'li')), array('Label'), array('HtmlTag', array('tag' => 'li')));
     $classID = new Zend_Form_Element_Select('classID');
     $classID->setLabel('Publication title: ')->setRequired(true)->addMultiOptions(array(NULL => 'Choose reference', 'Valid choices' => $ref_list))->addValidator('InArray', false, array(array_keys($ref_list)))->addFilters(array('StripTags', 'StringTrim'))->addErrorMessage('You must enter a title')->setDecorators($decorators);
     $volume = new Zend_Form_Element_Text('vol_no');
     $volume->setLabel('Volume number: ')->setDecorators($decorators)->addFilters(array('StripTags', 'StringTrim'))->setAttrib('size', 9)->addValidator('Alnum', false, array('allowWhiteSpace' => true));
     $reference = new Zend_Form_Element_Text('reference');
     $reference->setLabel('Reference number: ')->setDecorators($decorators)->addFilters(array('StripTags', 'StringTrim'))->setAttrib('size', 15)->addValidator('Alnum', false, array('allowWhiteSpace' => true));
     //Submit button
     $submit = new Zend_Form_Element_Submit('submit');
     $submit->setAttrib('id', 'submitbutton')->removeDecorator('HtmlTag')->removeDecorator('DtDdWrapper')->setAttrib('class', 'large');
     $this->addElements(array($classID, $volume, $reference, $submit));
     $hash = new Zend_Form_Element_Hash('csrf');
     $hash->setValue($this->_config->form->salt)->removeDecorator('DtDdWrapper')->removeDecorator('HtmlTag')->removeDecorator('label')->setTimeout(4800);
     $this->addElement($hash);
     $this->addDisplayGroup(array('classID', 'vol_no', 'reference'), 'details')->removeDecorator('HtmlTag');
     $this->details->addDecorators(array('FormElements', array('HtmlTag', array('tag' => 'ul'))));
     $this->details->removeDecorator('DtDdWrapper');
     $this->details->removeDecorator('HtmlTag');
     $this->details->setLegend('Add a new reference');
     $this->addDisplayGroup(array('submit'), 'submit');
 }
Пример #2
0
 /** Display individual record
  * @todo move comment functionality to a model
  */
 public function recordAction()
 {
     if ($this->_getParam('id', false)) {
         $this->view->recordID = $this->_getParam('id');
         $id = $this->_getParam('id');
         $findsdata = $this->_finds->getIndividualFind($id, $this->getRole());
         if ($findsdata) {
             $this->view->finds = $findsdata;
         } else {
             throw new Pas_Exception_NotAuthorised('You are not authorised to view this record');
         }
         $contexts = array('xml', 'rss', 'json', 'atom', 'kml', 'georss', 'ics', 'rdf', 'xcs', 'vcf', 'csv', 'pdf');
         if (!in_array($this->_cs->getCurrentContext(), $contexts)) {
             $this->view->findsdata = $this->_finds->getFindData($id);
             $this->view->findsmaterial = $this->_finds->getFindMaterials($id);
             $this->view->temporals = $this->_finds->getFindTemporalData($id);
             $this->view->nexts = $this->_finds->getNextObject($id);
             $this->view->recordsprior = $this->_finds->getPreviousObject($id);
             $this->view->peoples = $this->_finds->getPersonalData($id);
             $this->view->findotherrefs = $this->_finds->getFindOtherRefs($id);
             $findspotsdata = new Findspots();
             $this->view->findspots = $findspotsdata->getFindSpotData($id);
             $rallyfind = new Rallies();
             $this->view->rallyfind = $rallyfind->getFindToRallyNames($id);
             $coins = new Coins();
             $this->view->coins = $coins->getCoinData($id);
             $coinrefs = new Coinclassifications();
             $this->view->coinrefs = $coinrefs->getAllClasses($id);
             $thumbs = new Slides();
             $this->view->thumbs = $thumbs->getThumbnails($id);
             $refs = new Publications();
             $this->view->refs = $refs->getReferences($id);
             $comments = new Comments();
             $this->view->comments = $comments->getFindComments($id);
             $response = $this->getResponse();
             if (in_array($this->getRole(), $this->_higherLevel) && !in_array($this->_cs->getCurrentContext(), array('xml', 'json', 'qrcode'))) {
                 $wform = new WorkflowStageForm();
                 $wform->id->setValue($id);
                 $wform->submit->setLabel('Change workflow');
                 $this->view->wform = $wform;
                 $response->insert('workflow', $this->view->render('structure/workflow.phtml'));
             } else {
                 $findspotsdata = new Findspots();
                 $this->view->findspots = $findspotsdata->getFindSpotData($id);
             }
             $form = new CommentFindForm();
             $form->submit->setLabel('Add a new comment');
             $this->view->form = $form;
             if ($this->getRequest()->isPost() && $form->isValid($this->_request->getPost())) {
                 if ($form->isValid($form->getValues())) {
                     $data = $form->getValues();
                     if ($this->getHelper->getAkismet()->isSpam($data)) {
                         $data['comment_approved'] = 'spam';
                     } else {
                         $data['comment_approved'] = 'moderation';
                     }
                     $comments = new Comments();
                     $insert = $comments->insert($data);
                     $this->_flashMessenger->addMessage('Your comment has been entered and will appear shortly!');
                     $this->_redirect(self::REDIRECT . 'record/id/' . $this->_getParam('id'));
                     $this->_request->setMethod('GET');
                 } else {
                     $this->_flashMessenger->addMessage('There are problems with your comment submission');
                     $form->populate($formData);
                 }
             }
         } else {
             $this->_helper->layout->disableLayout();
             //disable layout
             $record = $this->_finds->getAllData($id);
             if ($this->_auth->hasIdentity()) {
                 $user = $this->_auth->getIdentity();
                 if (in_array($user->role, $this->_restricted)) {
                     $record['0']['gridref'] = NULL;
                     $record['0']['easting'] = NULL;
                     $record['0']['northing'] = NULL;
                     $record['0']['lat'] = NULL;
                     $record['0']['lon'] = NULL;
                     $record['0']['finder'] = NULL;
                     $record['0']['address'] = NULL;
                     $record['0']['postcode'] = NULL;
                     $record['0']['findspotdescription'] = NULL;
                 }
             } else {
                 $record['0']['gridref'] = NULL;
                 $record['0']['easting'] = NULL;
                 $record['0']['northing'] = NULL;
                 $record['0']['lat'] = NULL;
                 $record['0']['lon'] = NULL;
                 $record['0']['finder'] = NULL;
                 $record['0']['address'] = NULL;
                 $record['0']['postcode'] = NULL;
                 $record['0']['findspotdescription'] = NULL;
                 if (!is_null($record['0']['knownas'])) {
                     $record['0']['parish'] = NULL;
                     $record['0']['fourFigure'] = NULL;
                 }
             }
             $this->view->record = $record;
         }
     } else {
         throw new Pas_Exception_Param($this->_missingParameter);
     }
 }