public function getCopyrights() { $copyrights = new Copyrights(); $copy = $copyrights->getTypes(); $auth = Zend_Auth::getInstance(); $this->_auth = $auth; if ($this->_auth->hasIdentity()) { $user = $this->_auth->getIdentity(); if (is_null($user->fullname)) { $userCopyright = $user->forename . ' ' . $user->surname; } else { $userCopyright = $user->fullname; } } $personal = array($userCopyright => $userCopyright); return array_merge($copy, $personal); }
public function __construct($options = null) { $counties = new Counties(); $county_options = $counties->getCountyName2(); $periods = new Periods(); $period_options = $periods->getPeriodFrom(); $copyrights = new Copyrights(); $copy = $copyrights->getStyles(); $auth = Zend_Auth::getInstance(); $this->_auth = $auth; if ($this->_auth->hasIdentity()) { $user = $this->_auth->getIdentity(); $this->_copyright = $user->copyright; } else { $this->_copyright = 'The Portable Antiquities Scheme'; } parent::__construct($options); $this->setAttrib('enctype', 'multipart/form-data'); $this->setName('imagetofind'); $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'))); $image = new Zend_Form_Element_File('image'); $image->setLabel('Upload an image: ')->setRequired(true)->setAttrib('size', 20)->addValidator('Extension', false, 'jpeg,tif,jpg,png,gif,tiff,JPG,JPEG,GIF,PNG,TIFF,TIF')->addDecorator('Errors', array('placement' => 'prepend', 'class' => 'error', 'tag' => 'li'))->addDecorator('Label')->addDecorator('HtmlTag', array('tag' => 'li'))->addDecorator('file')->setDescription('Filename should not include spaces,commas,( or )')->addErrorMessage('You must upload a file with the correct file extension in this array - jpeg,tif,jpg,png,gif'); $imagelabel = new Zend_Form_Element_Text('label'); $imagelabel->setLabel('Image label: ')->setRequired(true)->setAttrib('size', 60)->addErrorMessage('You must enter a label')->setDescription('This must be descriptive text about the image - NOT THE FILE or FIND NUMBER/NAME')->setDecorators($decorators)->addFilters(array('StripTags', 'StringTrim')); $period = new Zend_Form_Element_Select('period'); $period->setLabel('Period: ')->setRequired(true)->setDecorators($decorators)->addErrorMessage('You must enter a period for the image')->addMultiOptions(array(NULL => 'Select a period', 'Valid periods' => $period_options))->addValidator('inArray', false, array(array_keys($period_options))); $county = new Zend_Form_Element_Select('county'); $county->setLabel('County: ')->setRequired(true)->setDecorators($decorators)->addErrorMessage('You must enter a county of origin')->addMultiOptions(array(NULL => 'Select a county of origin', 'Valid counties' => $county_options))->addValidator('inArray', false, array(array_keys($county_options))); $copyright = new Zend_Form_Element_Select('copyrighttext'); $copyright->setLabel('Image copyright: ')->setRequired(true)->addErrorMessage('You must enter a licence holder')->setDecorators($decorators)->addMultiOptions(array(NULL => 'Select a licence holder', 'Valid copyrights' => $copy))->setValue($this->_copyright); $type = new Zend_Form_Element_Select('type'); $type->setLabel('Image type: ')->setRequired(true)->addMultiOptions(array(NULL => 'Select the type of image', 'Image types' => array('digital' => 'Digital image', 'illustration' => 'Scanned illustration')))->setValue('digital')->setDecorators($decorators); $submit = new Zend_Form_Element_Submit('submit'); $submit->setAttrib('id', 'submitbutton')->removeDecorator('label')->removeDecorator('HtmlTag')->setAttrib('class', 'large')->removeDecorator('DtDdWrapper'); $this->addElements(array($image, $imagelabel, $county, $period, $copyright, $type, $submit)); $this->setMethod('post'); $this->addDisplayGroup(array('image', 'label', 'county', 'period', 'copyrighttext', 'type'), 'details')->removeDecorator('HtmlTag'); $this->details->addDecorators(array('FormElements', array('HtmlTag', array('tag' => 'ul')))); $this->details->removeDecorator('DtDdWrapper'); $this->details->removeDecorator('HtmlTag'); $this->addDisplayGroup(array('submit'), 'submit')->removeDecorator('HtmlTag'); $this->submit->removeDecorator('DtDdWrapper'); $this->submit->removeDecorator('HtmlTag'); $this->details->setLegend('Attach an image'); }
public function init() { $required = true; $copyrights = new Copyrights(); $copy = $copyrights->getStyles(); $this->setAction($this->_actionUrl)->setMethod('post')->setAttrib('id', 'accountform'); $this->clearDecorators(); $decorators = array(array('ViewHelper'), array('Description', array('placement' => 'append', 'class' => 'info')), array('Errors', array('placement' => 'prepend', 'class' => 'error', 'tag' => 'li')), array('Label', array('separator' => ' ', 'requiredSuffix' => ' *', 'class' => 'leftalign')), array('HtmlTag', array('tag' => 'li'))); $username = $this->addElement('text', 'username', array('label' => 'Username:'******'StringTrim', 'StripTags')); $firstName = $this->addElement('text', 'first_name', array('label' => 'First Name: ', 'size' => '30'))->first_name; $firstName->setRequired(true)->addFilters(array('StringTrim', 'StripTags'))->addErrorMessage('You must enter a firstname'); $firstName->setDecorators($decorators); $lastName = $this->addElement('text', 'last_name', array('label' => 'Last Name: ', 'size' => '30'))->last_name; $lastName->setRequired(true)->addFilters(array('StringTrim', 'StripTags'))->addErrorMessage('You must enter a surname'); $lastName->setDecorators($decorators); $fullname = $this->addElement('text', 'fullname', array('label' => 'Preferred Name: ', 'size' => '30'))->fullname; $fullname->setRequired(true)->addFilters(array('StringTrim', 'StripTags'))->addErrorMessage('You must enter your preferred name'); $fullname->setDecorators($decorators); $email = $this->addElement('text', 'email', array('label' => 'Email Address', 'size' => '30'))->email; $email->addValidator('emailAddress')->setRequired(true)->addErrorMessage('Please enter a valid address!')->addFilters(array('StringTrim', 'StripTags', 'StringToLower'))->addValidator('EmailAddress', false, array('mx' => true)); $email->setDecorators($decorators); $password = $this->addElement('password', 'password', array('label' => 'Change password: '******'size' => '30'))->password; $password->addFilters(array('StringTrim', 'StripTags'))->setRequired(false); $password->setDecorators($decorators); $copyright = $this->addElement('select', 'copyright', array('label' => 'Default copyright: '))->copyright; $copyright->setRequired(TRUE); $copyright->addMultiOptions(array(NULL => 'Select a licence holder', 'Valid copyrights' => $copy))->addValidator('InArray', false, array(array_keys($copy)))->setDecorators($decorators); $submit = new Zend_Form_Element_Submit('submit'); $submit->setLabel('Save details'); $submit->clearDecorators(); $submit->addDecorators(array(array('ViewHelper'), array('HtmlTag', array('tag' => 'div', 'class' => 'submit')))); $submit->setAttrib('class', 'large'); $this->addElement($submit); $this->addDisplayGroup(array('username', 'first_name', 'last_name', 'fullname', 'email', 'password', 'copyright'), 'userdetails'); $this->addDecorator('FormElements')->addDecorator(array('ListWrapper' => 'HtmlTag'), array('tag' => 'div'))->addDecorator('FieldSet')->addDecorator('Form'); $this->setLegend('Edit your account and profile details: '); $this->userdetails->removeDecorator('DtDdWrapper'); $this->userdetails->removeDecorator('HtmlTag'); $this->userdetails->removeDecorator('FieldSet'); $this->userdetails->addDecorator(array('DtDdWrapper' => 'HtmlTag'), array('tag' => 'ul')); $this->addDisplayGroup(array('submit'), 'submit'); }
/** Get the image copyrights for a user * @access public * @return array */ public function getCopyrights() { $copyrights = new Copyrights(); $copy = $copyrights->getTypes(); $auth = Zend_Auth::getInstance(); if ($auth->hasIdentity()) { $user = $auth->getIdentity(); if (!is_null($user->copyright)) { $this->_copyright = $user->copyright; } elseif (!is_null($user->fullname)) { $this->_copyright = $user->first_name . ' ' . $user->last_name; } else { $this->_copyright = $user->fullname; } if (!is_null($user->fullname)) { $copy[] = $user->first_name . ' ' . $user->last_name; } else { $copy[] = $user->fullname; } } $copyList = array_filter(array_merge(array($this->_copyright => $this->_copyright), $copy)); return $copyList; }
/** The initialisation function * @access public * @return void */ public function init() { $copyrights = new Copyrights(); $copy = $copyrights->getTypes(); $username = $this->addElement('text', 'username', array('label' => 'Username:'******'username'); $username->disabled = true; $username->addFilters(array('StringTrim', 'StripTags')); $firstName = $this->addElement('text', 'first_name', array('label' => 'First Name: ', 'size' => '30'))->first_name; $firstName = $this->getElement('first_name'); $firstName->setRequired(true)->addFilters(array('StringTrim', 'StripTags'))->addErrorMessage('You must enter a firstname'); $lastName = $this->addElement('text', 'last_name', array('label' => 'Last Name: ', 'size' => '30'))->last_name; $lastName = $this->getElement('last_name'); $lastName->setRequired(true)->addFilters(array('StringTrim', 'StripTags'))->addErrorMessage('You must enter a surname'); $fullname = $this->addElement('text', 'fullname', array('label' => 'Preferred Name: ', 'size' => '30'))->fullname; $fullname = $this->getElement('fullname'); $fullname->setRequired(true)->addFilters(array('StringTrim', 'StripTags'))->addErrorMessage('You must enter your preferred name'); $email = $this->addElement('text', 'email', array('label' => 'Email Address', 'size' => '30'))->email; $email = $this->getElement('email'); $email->setRequired(true)->addErrorMessage('Please enter a valid address!')->addFilters(array('StringTrim', 'StripTags', 'StringToLower'))->addValidator('EmailAddress', false, array('mx' => true)); $password = $this->addElement('password', 'password', array('label' => 'Change password: '******'size' => '30'))->password; $password = $this->getElement('password'); $password->addFilters(array('StringTrim', 'StripTags'))->setRequired(false); $copyright = $this->addElement('select', 'copyright', array('label' => 'Default copyright: '))->copyright; $copyright = $this->getElement('copyright'); $copyright->setRequired(true); $copyright->addMultiOptions(array(null => 'Select a licence holder', 'Valid copyrights' => $copy))->addValidator('InArray', false, array(array_keys($copy)))->setAttribs(array('class' => 'span8 selectpicker show-menu-arrow ')); $submit = new Zend_Form_Element_Submit('submit'); $submit->setLabel('Save details'); $hash = new Zend_Form_Element_Hash('csrf'); $hash->setValue($this->_salt)->setTimeout(4800); $this->addElements(array($hash, $submit)); $this->addDisplayGroup(array('username', 'first_name', 'last_name', 'fullname', 'email', 'password', 'copyright'), 'userdetails'); $this->setLegend('Edit your account and profile details: '); $this->addDisplayGroup(array('submit'), 'buttons'); parent::init(); }
/** The constructor * @access public * @param array $options * @return void */ public function __construct(array $options = null) { $counties = new OsCounties(); $county_options = $counties->getCountyNames(); $periods = new Periods(); $period_options = $periods->getPeriodFrom(); $copyrights = new Copyrights(); $copy = $copyrights->getTypes(); $licenses = new LicenseTypes(); $license = $licenses->getList(); if (array_key_exists('id', $options)) { $slides = new Slides(); $images = $slides->getSlides($options['id']); } $auth = Zend_Auth::getInstance(); $this->_auth = $auth; if ($this->_auth->hasIdentity()) { $user = $this->_auth->getIdentity(); if (!is_null($user->copyright)) { $this->_copyright = $user->copyright; } elseif (!is_null($user->fullname)) { $this->_copyright = $user->first_name . ' ' . $user->last_name; } else { $this->_copyright = $user->fullname; } if (!is_null($user->fullname)) { $copy[] = $user->first_name . ' ' . $user->last_name; } else { $copy[] = $user->fullname; } } $copyList = array_filter(array_merge(array($this->_copyright => $this->_copyright), $copy)); parent::__construct($options); $this->setName('imagetofind'); $period = new Zend_Form_Element_Select('period'); $period->setLabel('Period: ')->setRequired(true)->setAttrib('class', 'input-xxlarge selectpicker show-menu-arrow required')->addErrorMessage('You must enter a period for the image')->addMultiOptions(array(null => 'Select a period', 'Valid periods' => $period_options))->addValidator('inArray', false, array(array_keys($period_options))); $country = new Zend_Form_Element_Select('country'); $country->setLabel('Country: ')->setAttrib('class', 'input-xxlarge selectpicker show-menu-arrow required')->setRequired(true)->addErrorMessage('You must enter a country of origin')->addMultiOptions(array(null => 'Select a country of origin', 'Valid countries' => array('England' => 'England', 'Wales' => 'Wales')))->addValidator('inArray', false, array(array_keys($county_options))); $county = new Zend_Form_Element_Select('county'); $county->setLabel('County: ')->setAttrib('class', 'input-xxlarge selectpicker show-menu-arrow required')->setRequired(true)->addErrorMessage('You must enter a county of origin')->addMultiOptions(array(null => 'Select a county of origin', 'Valid counties' => $county_options))->addValidator('inArray', false, array(array_keys($county_options))); $copyright = new Zend_Form_Element_Select('imagerights'); $copyright->setLabel('Image copyright: ')->setAttrib('class', 'input-xxlarge selectpicker show-menu-arrow')->setRequired(true)->addErrorMessage('You must enter a licence holder')->addMultiOptions(array(null => 'Select a licence holder', 'Valid copyrights' => $copyList))->setDescription('You can set the copyright of your image here to your institution. If you are a public recorder, it should default to your full name. For institutions that do not appear contact head office to suggest its addition')->setValue($this->_copyright); $licenseField = new Zend_Form_Element_Select('ccLicense'); $licenseField->setDescription('Our philosophy is to make our content available openly, by default we set the license as use by attribution to gain the best public benefit. You can choose a different license if you wish.'); $licenseField->setRequired(true)->setAttrib('class', 'input-xxlarge selectpicker show-menu-arrow')->setLabel('Creative Commons license:')->addMultiOptions(array(null => 'Select a license', 'Available licenses' => $license))->setValue(4)->addValidator('Int'); $type = new Zend_Form_Element_Select('type'); $type->setLabel('Image type: ')->setAttrib('class', 'input-xxlarge selectpicker show-menu-arrow')->setRequired(true)->addMultiOptions(array(null => 'Select the type of image', 'Image types' => array('digital' => 'Digital image', 'illustration' => 'Scanned illustration')))->setValue('digital'); $submit = new Zend_Form_Element_Submit('submit'); $submit->setLabel('Add metadata for images'); $this->addElements(array($country, $county, $period, $copyright, $type, $licenseField, $submit)); $this->setMethod('post'); $this->addDisplayGroup(array('country', 'filename', 'county', 'period', 'imagerights', 'ccLicense', 'type'), 'details'); foreach ($images as $image) { $label = 'label' . $image['imageID']; $group = 'metadata' . $image['imageID']; echo '<img src="http://finds.org.uk/images/thumbnails/' . $image['imageID'] . '.jpg"/>'; $image['imageID'] = new Zend_Form_Element_Text($label); $image['imageID']->setLabel('Image label: ')->setRequired(true)->setAttribs(array('size' => 60, 'class' => 'span6 required'))->addErrorMessage('You must enter a label')->setDescription('This must be descriptive text about the image - NOT THE FILE or FIND NUMBER/NAME - and follow the conventions outlined below this form')->addFilters(array('StripTags', 'StringTrim')); $this->addElements(array($image['imageID'])); $this->addDisplayGroup(array($label), $group); } $this->addDisplayGroup(array('submit'), 'buttons')->removeDecorator('HtmlTag'); $this->details->setLegend('Attach an image'); parent::init(); }