function form_main() { $oForm = new KTForm(); $oForm->setOptions(array('context' => &$this, 'identifier' => 'ktcore.preferences.main', 'action' => 'updatePreferences', 'fail_action' => 'main', 'label' => _kt('Your Details'), 'submit_label' => _kt('Update Preferences'), 'extraargs' => $this->meldPersistQuery("", "", true))); // widgets $oForm->setWidgets(array(array('ktcore.widgets.string', array('label' => _kt('Name'), 'description' => _kt('Your full name. This is shown in reports and listings. e.g. <strong>John Smith</strong>'), 'required' => true, 'name' => 'name', 'value' => sanitizeForHTML($this->oUser->getName()), 'autocomplete' => false)), array('ktcore.widgets.string', array('label' => _kt('Email Address'), 'description' => _kt('Your email address. Notifications and alerts are mailed to this address if <strong>email notifications</strong> is set below. e.g. <strong>jsmith@acme.com</strong>'), 'required' => false, 'name' => 'email_address', 'value' => sanitizeForHTML($this->oUser->getEmail()), 'autocomplete' => false)), array('ktcore.widgets.boolean', array('label' => _kt('Email Notifications'), 'description' => _kt('If this is specified then the you will receive certain notifications. If it is not set, then you will only see notifications on the <strong>Dashboard</strong>'), 'required' => false, 'name' => 'email_notifications', 'value' => $this->oUser->getEmailNotification(), 'autocomplete' => false)))); $oForm->setValidators(array(array('ktcore.validators.string', array('test' => 'name', 'output' => 'name')), array('ktcore.validators.emailaddress', array('test' => 'email_address', 'output' => 'email_address')), array('ktcore.validators.boolean', array('test' => 'email_notifications', 'output' => 'email_notifications')))); return $oForm; }
function form_copyselection() { $oForm = new KTForm(); $oForm->setOptions(array('label' => _kt('Copy Document'), 'submit_label' => _kt('Copy'), 'identifier' => 'ktcore.actions.copydoc', 'action' => 'copy', 'cancel_url' => KTBrowseUtil::getUrlForDocument($this->oDocument), 'fail_action' => 'main', 'context' => $this)); /* * This is somewhat more complex than most forms, since the "filename" * and title shouldn't appear unless there's a clash. * * This is still not the most elegant solution. */ $widgets = array(); $widgets[] = array('ktcore.widgets.foldercollection', array('label' => _kt('Target Folder'), 'description' => _kt('Use the folder collection and path below to browse to the folder you wish to copy the documents into.'), 'required' => true, 'name' => 'browse', 'folder_id' => $this->oDocument->getFolderID())); // Electronic Signature if enabled global $default; if ($default->enableESignatures) { $widgets[] = array('ktcore.widgets.info', array('label' => _kt('This action requires authentication'), 'description' => _kt('Please provide your user credentials as confirmation of this action.'), 'name' => 'info')); $widgets[] = array('ktcore.widgets.string', array('label' => _kt('Username'), 'name' => 'sign_username', 'required' => true)); $widgets[] = array('ktcore.widgets.password', array('label' => _kt('Password'), 'name' => 'sign_password', 'required' => true)); } $widgets[] = array('ktcore.widgets.reason', array('label' => _kt('Reason'), 'description' => _kt('Please specify why you are copying this document. Bear in mind that you can use a maximum of <strong>250</strong> characters.'), 'name' => 'reason')); $oForm->setWidgets($widgets); $validators = array(); $validators[] = array('ktcore.validators.string', array('test' => 'reason', 'min_length' => 1, 'max_length' => 250, 'output' => 'reason')); $validators[] = array('ktcore.validators.entity', array('class' => 'Folder', 'test' => 'browse', 'output' => 'browse')); if ($default->enableESignatures) { $validators[] = array('electonic.signatures.validators.authenticate', array('object_id' => $this->oDocument->iId, 'type' => 'document', 'action' => 'ktcore.transactions.copy', 'test' => 'info', 'output' => 'info')); } $oForm->setValidators($validators); // here's the ugly bit. $err = $oForm->getErrors(); if (!empty($err['name']) || !empty($err['filename'])) { $oForm->addWidget(array('ktcore.widgets.string', array('label' => _kt('Document Title'), 'value' => sanitizeForHTML($this->oDocument->getName()), 'important_description' => _kt('Please indicate a new title to use to resolve any title conflicts.'), 'name' => 'name', 'required' => true))); $oForm->addValidator(array('ktcore.validators.string', array('output' => 'name', 'test' => 'name'))); $oForm->addWidget(array('ktcore.widgets.string', array('label' => _kt('Filename'), 'value' => sanitizeForHTML($this->oDocument->getFilename()), 'important_description' => _kt('Please indicate a new filename to use to resolve any conflicts.'), 'name' => 'filename', 'required' => true))); $oForm->addValidator(array('ktcore.validators.string', array('output' => 'filename', 'test' => 'filename'))); } return $oForm; }
function do_edit() { $this->aBreadcrumbs[] = array('url' => $_SERVER['PHP_SELF'], 'name' => _kt('Document Type Management')); $oTemplating =& KTTemplating::getSingleton(); $oTemplate = $oTemplating->loadTemplate('ktcore/documenttypes/edit'); $oDocumentType =& DocumentType::get($_REQUEST['fDocumentTypeId']); $aCurrentFieldsets =& KTFieldset::getForDocumentType($oDocumentType); $aCurrentFieldsetIds = array_map(array("KTUtil", "getId"), $aCurrentFieldsets); $aAvailableFieldsets =& KTFieldset::getNonGenericFieldsets(); $aAvailableFieldsetIds =& array_map(array("KTUtil", "getId"), $aAvailableFieldsets); $aAvailableFieldsetIds = array_diff($aAvailableFieldsetIds, $aCurrentFieldsetIds); $vocab = array(); foreach ($aAvailableFieldsetIds as $iFieldsetId) { $oFieldset = KTFieldset::get($iFieldsetId); $vocab[$oFieldset->getId()] = $oFieldset->getName(); } $aOptions = array(); $aOptions['vocab'] = $vocab; $aOptions['multi'] = true; $aOptions['size'] = 5; $availableTypesWidget =& new KTLookupWidget(_kt('Available Fieldsets'), _kt('Select the fieldsets which you wish to associate with this document type'), 'fieldsetid[]', null, $this->oPage, true, null, null, $aOptions); $this->aBreadcrumbs[] = array('name' => $oDocumentType->getName()); $this->oPage->setBreadcrumbDetails(_kt('edit')); $oTemplate->setData(array('context' => $this, 'oDocumentType' => $oDocumentType, 'sDocTypeName' => sanitizeForHTML($oDocumentType->getName()), 'aCurrentFieldsets' => $aCurrentFieldsets, 'bAnyFieldsets' => count($aAvailableFieldsets) > 0, 'bAvailableFieldsets' => count($vocab) > 0, 'availableWidget' => $availableTypesWidget)); return $oTemplate; }
function form_edit() { $oForm = new KTForm(); $oForm->setOptions(array('label' => _kt('Edit Metadata'), 'submit_label' => _kt('Update Document'), 'action' => 'update', 'fail_action' => 'main', 'cancel_url' => KTBrowseUtil::getUrlForDocument($this->oDocument), 'context' => &$this, 'extraargs' => $this->meldPersistQuery("", "", true))); $oFReg =& KTFieldsetRegistry::getSingleton(); $doctypeid = $this->oDocument->getDocumentTypeID(); if ($_REQUEST['new_type']) { $oTestType = DocumentType::get($_REQUEST['new_type']); if (!PEAR::isError($oTestType)) { $doctypeid = $oTestType->getId(); } } $widgets = array(array('ktcore.widgets.string', array('label' => _kt("Document Title"), 'description' => sprintf(_kt("The document title is used as the main name of a document throughout %s."), APP_NAME), 'name' => 'document_title', 'required' => true, 'value' => sanitizeForHTML($this->oDocument->getName())))); $validators = array(array('ktcore.validators.string', array('test' => 'document_title', 'output' => 'document_title'))); $fieldsets = (array) KTMetadataUtil::fieldsetsForDocument($this->oDocument, $doctypeid); foreach ($fieldsets as $oFieldset) { $widgets = kt_array_merge($widgets, $oFReg->widgetsForFieldset($oFieldset, 'fieldset_' . $oFieldset->getId(), $this->oDocument)); $validators = kt_array_merge($validators, $oFReg->validatorsForFieldset($oFieldset, 'fieldset_' . $oFieldset->getId(), $this->oDocument)); } // Electronic Signature if enabled global $default; if ($default->enableESignatures) { $widgets[] = array('ktcore.widgets.info', array('label' => _kt('This action requires authentication'), 'description' => _kt('Please provide your user credentials as confirmation of this action.'), 'name' => 'info')); $widgets[] = array('ktcore.widgets.string', array('label' => _kt('Username'), 'name' => 'sign_username', 'required' => true)); $widgets[] = array('ktcore.widgets.password', array('label' => _kt('Password'), 'name' => 'sign_password', 'required' => true)); $widgets[] = array('ktcore.widgets.reason', array('label' => _kt('Reason'), 'name' => 'reason', 'required' => true)); $validators[] = array('electonic.signatures.validators.authenticate', array('object_id' => $this->oDocument->iId, 'type' => 'document', 'action' => 'ktcore.transactions.edit_metadata', 'test' => 'info', 'output' => 'info')); } $oForm->setWidgets($widgets); $oForm->setValidators($validators); return $oForm; }
function form_edit() { $oForm = new KTForm(); $oForm->setOptions(array('identifier' => 'ktcore.fieldsets.edit', 'label' => _kt("Change Fieldset Details"), 'submit_label' => _kt('Update Fieldset'), 'cancel_action' => 'edit', 'fail_action' => 'editfieldset', 'action' => 'savefieldset', 'context' => $this)); // construct the widget set. // we use a slight variation here, because "type" is only present in certain circumstances. $widgets = array(array('ktcore.widgets.string', array('label' => _kt("Fieldset Name"), 'name' => 'name', 'required' => true, 'description' => _kt("Each fieldset needs a unique name."), 'value' => sanitizeForHTML($this->oFieldset->getName()))), array('ktcore.widgets.text', array('label' => _kt("Description"), 'name' => 'description', 'required' => true, 'description' => _kt("In order to ensure that the data that users enter is useful, it is essential that you provide a good example."), 'value' => sanitizeForHTML($this->oFieldset->getDescription())))); $widgets[] = array('ktcore.widgets.boolean', array('label' => _kt("Generic"), 'name' => 'generic', 'description' => _kt("A generic fieldset is one that is available for every document by default. These fieldsets will be available for users to edit and add for every document in the document management system."), 'value' => $this->oFieldset->getIsGeneric())); $oForm->setWidgets($widgets); // similarly, we construct validators here. $validators = array(array('ktcore.validators.string', array('test' => 'name', 'output' => 'name')), array('ktcore.validators.string', array('test' => 'description', 'output' => 'description')), array('ktcore.validators.boolean', array('test' => 'generic', 'output' => 'generic'))); $oForm->setValidators($validators); return $oForm; }
function form_editfield($oField) { $oForm = new KTForm(); $oForm->setOptions(array('identifier' => 'ktcore.fieldsets.basic.field.edit', 'label' => _kt("Edit Field"), 'submit_label' => _kt('Update Field'), 'cancel_url' => $this->sParentUrl, 'fail_action' => 'managefield', 'action' => 'updatefield', 'context' => $this)); $oForm->setWidgets(array(array('ktcore.widgets.string', array('label' => _kt("Field Name"), 'name' => 'name', 'value' => sanitizeForHTML($oField->getName()), 'required' => true, 'description' => _kt("Within a given fieldset, each field needs a unique name."))), array('ktcore.widgets.text', array('label' => _kt("Description"), 'name' => 'description', 'value' => sanitizeForHTML($oField->getDescription()), 'required' => true, 'description' => _kt("A good description can be the difference between useful metadata and poor metadata. At the same time, overly long descriptions are far less valuable than concise ones."))), array('ktcore.widgets.boolean', array('label' => _kt("Required"), 'value' => $oField->getIsMandatory(), 'name' => 'required', 'description' => _kt("Required fields must be filled in, or the adding process will be rejected."))))); $oForm->setValidators(array(array('ktcore.validators.string', array('test' => 'name', 'output' => 'name')), array('ktcore.validators.string', array('test' => 'description', 'output' => 'description')), array('ktcore.validators.boolean', array('test' => 'required', 'output' => 'required')))); return $oForm; }
function form_edittransition($oTransition) { $oForm = new KTForm(); $oForm->setOptions(array('context' => $this, 'label' => _kt('Edit Transition'), 'submit_label' => _kt('Update Transition'), 'action' => 'savetransition', 'fail_action' => 'edittransition', 'cancel_action' => 'basic')); $oForm->setWidgets(array(array('ktcore.widgets.string', array('name' => 'name', 'label' => _kt('Transition Name'), 'description' => _kt('In order to move between states, users will cause "transitions" to occur. These transitions represent processes followed, e.g. "review document", "distribute invoice" or "publish". Transition names must be unique within the workflow (e.g. within this workflow, you can only have one transition called "publish")'), 'required' => true, 'value' => sanitizeForHTML($oTransition->getName()))))); $oForm->setValidators(array(array('ktcore.validators.string', array('test' => 'name', 'output' => 'name')))); return $oForm; }
function renderPage($sTitle = null, $sDescription = null) { if ($sTitle == null) { $sTitle = $this->sLabel; } $pageval = $this->render(); $sHelpText = ''; if (!is_null($sDescription)) { $sHelpText = sprintf('<p class="descriptiveText">%s</p>', $sDescription); } return sprintf('<h2>%s</h2> %s %s', sanitizeForHTML($sTitle), $sHelpText, $pageval); }