示例#1
0
 function form_initialdata()
 {
     $oForm = new KTForm();
     $oForm->setOptions(array('label' => _kt("Add a document"), 'action' => 'processInitialData', 'actionparams' => 'postExpected=1&fFolderId=' . $this->oFolder->getId(), 'fail_action' => 'main', 'context' => &$this, 'extraargs' => $this->meldPersistQuery("", "", true), 'submit_label' => _kt("Add"), 'file_upload' => true));
     $aTypes = array();
     foreach (DocumentType::getListForUserAndFolder($this->oUser, $this->oFolder) as $oDocumentType) {
         if (!$oDocumentType->getDisabled()) {
             $aTypes[] = $oDocumentType;
         }
     }
     // Onchange gets the name of the file and inserts it as the document title.
     $sFileOnchange = "javascript:\n            var doc = document.getElementById('document_name');\n            if(doc.value == ''){\n                var arrPath=this.value.split('/');\n                if(arrPath.length == 1){\n                    var arrPath=this.value.split('\\\\');\n                }\n                var name=arrPath[arrPath.length-1];\n                var name=name.split('.');\n                var len = name.length;\n                if(len > 1){\n                    if(name[len-1].length <= 4){\n                        name.pop();\n                    }\n                }\n                var title=name.join('.');\n                doc.value=title;\n            }";
     $oForm->setWidgets(array(array('ktcore.widgets.file', array('label' => _kt('File'), 'description' => _kt('The contents of the document to be added to the document management system.'), 'name' => 'file', 'required' => true, 'onchange' => $sFileOnchange)), 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_name', 'required' => true, 'id' => 'document_name')), array('ktcore.widgets.entityselection', array('label' => _kt('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' => 'document_type', 'required' => true, 'vocab' => $aTypes, 'initial_string' => _kt('- Please select a document type -'), 'id_method' => 'getId', 'label_method' => 'getName', 'simple_select' => false))));
     // Electronic Signature if enabled
     global $default;
     if ($default->enableESignatures) {
         $oForm->addWidget(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')));
         $oForm->addWidget(array('ktcore.widgets.string', array('label' => _kt('Username'), 'name' => 'sign_username', 'required' => true)));
         $oForm->addWidget(array('ktcore.widgets.password', array('label' => _kt('Password'), 'name' => 'sign_password', 'required' => true)));
         $oForm->addWidget(array('ktcore.widgets.reason', array('label' => _kt('Reason'), 'description' => _kt('Please specify why you are checking out this document.  It will assist other users in understanding why you have locked this file.  Please bear in mind that you can use a maximum of <strong>250</strong> characters.'), 'name' => 'reason')));
     }
     $oForm->setValidators(array(array('ktcore.validators.file', array('test' => 'file', 'output' => 'file')), array('ktcore.validators.fileillegalchar', array('test' => 'file', 'output' => 'file')), array('ktcore.validators.string', array('test' => 'document_name', 'output' => 'document_name')), array('ktcore.validators.entity', array('test' => 'document_type', 'output' => 'document_type', 'class' => 'DocumentType', 'ids' => true))));
     if ($default->enableESignatures) {
         $oForm->addValidator(array('electonic.signatures.validators.authenticate', array('object_id' => $this->oFolder->getId(), 'type' => 'folder', 'action' => 'ktcore.transactions.add_document', 'test' => 'info', 'output' => 'info')));
     }
     return $oForm;
 }
示例#2
0
 function do_main()
 {
     $this->oPage->setBreadcrumbDetails(_kt("bulk upload"));
     $oTemplate =& $this->oValidator->validateTemplate('ktcore/folder/bulkUpload');
     $add_fields = array();
     $add_fields[] = new KTFileUploadWidget(_kt('Archive file'), _kt('The archive file containing the documents you wish to add to the document management system.'), 'file', "", $this->oPage, true, "file");
     $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();
         }
     }
     $fieldOptions = array("vocab" => $aVocab);
     $add_fields[] = new KTLookupWidget(_kt('Document Type'), _kt('Document Types, defined by the administrator, are used to categorise documents. Please select a Document Type from the list below.'), 'fDocumentTypeId', null, $this->oPage, true, "add-document-type", $fieldErrors, $fieldOptions);
     $fieldsets = array();
     $fieldsetDisplayReg =& KTFieldsetDisplayRegistry::getSingleton();
     $activesets = KTFieldset::getGenericFieldsets();
     foreach ($activesets as $oFieldset) {
         $displayClass = $fieldsetDisplayReg->getHandler($oFieldset->getNamespace());
         array_push($fieldsets, new $displayClass($oFieldset));
     }
     // 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'] = '';
     }
     $oTemplate->setData(array('context' => &$this, 'submit' => $submit, 'add_fields' => $add_fields, 'generic_fieldsets' => $fieldsets));
     return $oTemplate->render();
 }
示例#3
0
 function form_changetype()
 {
     $oForm = new KTForm();
     $oForm->setOptions(array('label' => _kt("Change Document Type"), 'description' => _kt("Changing the document type will allow different metadata to be associated with it."), 'identifier' => 'ktcore.doc.edit.typechange', 'submit_label' => _kt("Update Document"), 'context' => $this, 'cancel_action' => 'main', 'action' => 'trytype'));
     $type = DocumentType::get($this->oDocument->getDocumentTypeId());
     $current_type_name = $type->getName();
     $oFolder = Folder::get($this->oDocument->getFolderID());
     $oForm->setWidgets(array(array('ktcore.widgets.entityselection', array('label' => _kt("New Document Type"), 'description' => _kt("Please select the new type for this document."), 'important_description' => sprintf(_kt("The document is currently of type \"%s\"."), $current_type_name), 'value' => $type->getId(), 'label_method' => 'getName', 'vocab' => DocumentType::getListForUserAndFolder($this->oUser, $oFolder), 'simple_select' => false, 'required' => true, 'name' => 'type'))));
     $oForm->setValidators(array(array('ktcore.validators.entity', array('test' => 'type', 'output' => 'type', 'class' => 'DocumentType'))));
     return $oForm;
 }
示例#4
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;
 }