Example #1
0
 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;
 }
 /**
  * Returns the Metadata Fieldsets for the given DocumentId
  * @return KTForm 
  *
  */
 function getTypeMetadataFieldsets($iDocumentTypeID)
 {
     //Creating the form
     $oForm = new KTForm();
     $oFReg =& KTFieldsetRegistry::getSingleton();
     $activesets = KTFieldset::getForDocumentType($iDocumentTypeID);
     foreach ($activesets 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));
     }
     $oForm->setWidgets($widgets);
     $oForm->setValidators($validators);
     return $oForm->renderWidgets();
 }
Example #3
0
 /**
  * Returns the main Bulk Upload Form
  * @return KTForm 
  *
  */
 function getBulkImportForm()
 {
     $this->oPage->setBreadcrumbDetails(_kt("bulk import"));
     //Adding the required Bulk Upload javascript includes
     $aJavascript[] = 'resources/js/taillog.js';
     $aJavascript[] = 'resources/js/conditional_usage.js';
     $aJavascript[] = 'resources/js/kt_bulkupload.js';
     //Loading the widget js libraries to support dynamic "Ajax Loaded" widget rendering
     //FIXME: The widgets can support this via dynamic call to place libs in the head if they aren't loaded
     //       jQuery can do this but need time to implement/test.
     $aJavascript[] = 'thirdpartyjs/jquery/jquery-1.3.2.js';
     $aJavascript[] = 'thirdpartyjs/tinymce/jscripts/tiny_mce/tiny_mce.js';
     $aJavascript[] = 'resources/js/kt_tinymce_init.js';
     $aJavascript[] = 'thirdpartyjs/tinymce/jscripts/tiny_mce/jquery.tinymce.js';
     $this->oPage->requireJSResources($aJavascript);
     $oForm = new KTForm();
     $oForm->setOptions(array('identifier' => 'ktcore.folder.bulkUpload', 'label' => _kt('Import from Server Location'), 'submit_label' => _kt('Import'), 'action' => 'import', 'fail_action' => 'main', 'encoding' => 'multipart/form-data', 'context' => &$this, 'extraargs' => $this->meldPersistQuery("", "", true), 'description' => _kt('The bulk import facility allows for a number of documents to be added to the document management system easily. Provide a path on the server, and all documents and folders within that path will be added to the document management system.')));
     $oWF =& KTWidgetFactory::getSingleton();
     $widgets = array();
     $validators = array();
     // Adding the File Upload Widget
     //Legacy kt3 widgets don't conform to ktcore type widgets by virtue of the 'name' attribute.
     //$widgets[] = new KTFileUploadWidget(_kt('Archive file'), , 'file', "", $this->oPage, true, "file");
     $widgets[] = $oWF->get('ktcore.widgets.string', array('label' => _kt('Path'), 'required' => true, 'name' => 'path', 'id' => 'path', 'value' => '', 'description' => _kt('The path containing the documents to be added to the document management system.')));
     $aVocab = array('' => _kt('- Please select a document type -'));
     foreach (DocumentType::getListForUserAndFolder($this->oUser, $this->oFolder) as $oDocumentType) {
         if (!$oDocumentType->getDisabled()) {
             $aVocab[$oDocumentType->getId()] = $oDocumentType->getName();
         }
     }
     //Adding document type lookup widget
     $widgets[] = $oWF->get('ktcore.widgets.selection', array('label' => _kt('Document Type'), 'id' => 'add-document-type', 'description' => _kt('Document Types, defined by the administrator, are used to categorise documents. Please select a Document Type from the list below.'), 'name' => 'fDocumentTypeId', 'required' => true, 'vocab' => $aVocab, 'id_method' => 'getId', 'label_method' => 'getName', 'simple_select' => false));
     //Adding the quick "add" button for when no meta data needs to be added.
     //FIXME: This widget should only display if there are any "required" fields for the given document type
     //       Default/general document field type must also be taken into consideration
     $widgets[] = $oWF->get('ktcore.widgets.button', array('value' => _kt('Add'), 'id' => 'quick_add', 'description' => _kt('If you do not need to modify any the metadata for this document (see below), then you can simply click "Add" here to finish the process and add the document.'), 'name' => 'btn_quick_submit'));
     $oFReg =& KTFieldsetRegistry::getSingleton();
     $activesets = KTFieldset::getGenericFieldsets();
     foreach ($activesets 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));
     }
     //Adding the type_metadata_fields layer to be updated via ajax for non generic metadata fieldsets
     $widgets[] = $oWF->get('ktcore.widgets.layer', array('value' => '', 'id' => 'type_metadata_fields'));
     $oForm->setWidgets($widgets);
     $oForm->setValidators($validators);
     // Implement an electronic signature for accessing the admin section, it will appear every 10 minutes
     global $default;
     $iFolderId = $this->oFolder->getId();
     if ($default->enableESignatures) {
         $sUrl = KTPluginUtil::getPluginPath('electronic.signatures.plugin', true);
         $heading = _kt('You are attempting to perform a bulk upload');
         $submit['type'] = 'button';
         $submit['onclick'] = "javascript: showSignatureForm('{$sUrl}', '{$heading}', 'ktcore.transactions.bulk_upload', 'bulk', 'bulk_upload_form', 'submit', {$iFolderId});";
     } else {
         $submit['type'] = 'submit';
         $submit['onclick'] = '';
     }
     return $oForm;
 }
Example #4
0
 function form_metadata($sess_key)
 {
     $oForm = new KTForm();
     $oForm->setOptions(array('identifier' => 'ktcore.document.add', 'label' => _kt('Specify Metadata'), 'submit_label' => _kt('Save Document'), 'action' => 'finalise', 'fail_action' => 'metadata', 'context' => &$this, 'extraargs' => $this->meldPersistQuery("", "", true)));
     $oFReg =& KTFieldsetRegistry::getSingleton();
     $doctypeid = $_SESSION['_add_data'][$sess_key]['document_type'];
     $widgets = array();
     $validators = array();
     $fieldsets = $this->getFieldsetsForType($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));
     }
     $oForm->setWidgets($widgets);
     $oForm->setValidators($validators);
     return $oForm;
 }
Example #5
0
 /**
  * Returns a JSON object containing a list of fields belonging to a generic fieldset 
  * for the given DocumentId
  * @return JSON Object
  *
  */
 function getNonGenericFields($iDocumentTypeID)
 {
     $oFReg =& KTFieldsetRegistry::getSingleton();
     $activesets = KTFieldset::getForDocumentType($iDocumentTypeID);
     $fields = array();
     foreach ($activesets as $oFieldset) {
         $fieldIds = kt_array_merge($fields, $oFReg->getGenericFields($oFieldset));
     }
     $jsOptions = '{ "htmlId" : {';
     foreach ($fieldIds as $fieldId) {
         $jsOptions .= "'{$fieldId}' : '{$fieldId}',";
     }
     $jsOptions = substr($jsOptions, 0, strlen($jsOptions) - 1);
     $jsOptions .= '}}';
     return $jsOptions;
 }