Commit 72553ca7b0d1fded103c094c0246265313925e2a
1 parent
4ee87ecb
When doing a Bulk Upload the Large Text Field is not available as MCE.
Jira:KTC-810 Committed by: Charl Joseph Mert Reviewed by: Prince Mbekwa
Showing
6 changed files
with
439 additions
and
193 deletions
plugins/ktcore/KTCorePlugin.php
| ... | ... | @@ -195,13 +195,14 @@ class KTCorePlugin extends KTPlugin { |
| 195 | 195 | |
| 196 | 196 | $this->registerWidget('KTCoreTextAreaWidget', 'ktcore.widgets.textarea', 'KTWidgets.php'); |
| 197 | 197 | $this->registerWidget('KTCoreDateWidget', 'ktcore.widgets.date', 'KTWidgets.php'); |
| 198 | - | |
| 198 | + | |
| 199 | + $this->registerWidget('KTCoreButtonWidget', 'ktcore.widgets.button', 'KTWidgets.php'); | |
| 200 | + | |
| 199 | 201 | $this->registerWidget('KTCoreConditionalSelectionWidget', 'ktcore.widgets.conditionalselection', 'KTWidgets.php'); |
| 200 | 202 | |
| 201 | 203 | $this->registerPage('collection', 'KTCoreCollectionPage', 'KTWidgets.php'); |
| 202 | 204 | $this->registerPage('notifications', 'KTNotificationOverflowPage', 'KTMiscPages.php'); |
| 203 | 205 | |
| 204 | - | |
| 205 | 206 | // validators |
| 206 | 207 | $this->registerValidator('KTStringValidator', 'ktcore.validators.string', 'KTValidators.php'); |
| 207 | 208 | $this->registerValidator('KTIllegalCharValidator', 'ktcore.validators.illegal_char', 'KTValidators.php'); | ... | ... |
plugins/ktcore/KTWidgets.php
| ... | ... | @@ -948,6 +948,50 @@ class KTCoreTextAreaWidget extends KTWidget { |
| 948 | 948 | $this->aOptions['rows'] = KTUtil::arrayGet($aOptions, 'rows', 3); |
| 949 | 949 | $this->aOptions['field'] = KTUtil::arrayGet($aOptions, 'field'); |
| 950 | 950 | } |
| 951 | + | |
| 952 | + function render() { | |
| 953 | + // very simple, general purpose passthrough. Chances are this is sufficient, | |
| 954 | + // just override the template being used. | |
| 955 | + $bHasErrors = false; | |
| 956 | + if (count($this->aErrors) != 0) { $bHasErrors = true; } | |
| 957 | + //var_dump($this->aErrors); | |
| 958 | + $oTemplating =& KTTemplating::getSingleton(); | |
| 959 | + $oTemplate = $oTemplating->loadTemplate('ktcore/forms/widgets/base'); | |
| 960 | + | |
| 961 | + $this->aJavascript[] = 'thirdpartyjs/tinymce/jscripts/tiny_mce/tiny_mce.js'; | |
| 962 | + $this->aJavascript[] = 'resources/js/kt_tinymce_init.js'; | |
| 963 | + | |
| 964 | + if (!empty($this->aJavascript)) { | |
| 965 | + // grab our inner page. | |
| 966 | + $oPage =& $GLOBALS['main']; | |
| 967 | + $oPage->requireJSResources($this->aJavascript); | |
| 968 | + } | |
| 969 | + if (!empty($this->aCSS)) { | |
| 970 | + // grab our inner page. | |
| 971 | + $oPage =& $GLOBALS['main']; | |
| 972 | + $oPage->requireCSSResources($this->aCSS); | |
| 973 | + } | |
| 974 | + | |
| 975 | + $widget_content = $this->getWidget(); | |
| 976 | + | |
| 977 | + $aTemplateData = array( | |
| 978 | + "context" => $this, | |
| 979 | + "label" => $this->sLabel, | |
| 980 | + "description" => $this->sDescription, | |
| 981 | + "name" => $this->sName, | |
| 982 | + "required" => $this->bRequired, | |
| 983 | + "has_id" => ($this->sId !== null), | |
| 984 | + "id" => $this->sId, | |
| 985 | + "has_value" => ($this->value !== null), | |
| 986 | + "value" => $this->value, | |
| 987 | + "has_errors" => $bHasErrors, | |
| 988 | + "errors" => $this->aErrors, | |
| 989 | + "options" => $this->aOptions, | |
| 990 | + "widget" => $widget_content, | |
| 991 | + ); | |
| 992 | + return $oTemplate->render($aTemplateData); | |
| 993 | + } | |
| 994 | + | |
| 951 | 995 | } |
| 952 | 996 | |
| 953 | 997 | class KTCoreDateWidget extends KTWidget { |
| ... | ... | @@ -971,4 +1015,9 @@ class KTCoreDateWidget extends KTWidget { |
| 971 | 1015 | |
| 972 | 1016 | return $val; |
| 973 | 1017 | } |
| 974 | -} | |
| 975 | 1018 | \ No newline at end of file |
| 1019 | +} | |
| 1020 | + | |
| 1021 | +class KTCoreButtonWidget extends KTWidget { | |
| 1022 | + var $sNamespace = 'ktcore.widgets.button'; | |
| 1023 | + var $sTemplate = 'ktcore/forms/widgets/button'; | |
| 1024 | +} | ... | ... |
plugins/multiselect/BulkUpload.php
| ... | ... | @@ -46,170 +46,370 @@ require_once(KT_LIB_DIR . "/widgets/fieldsetDisplay.inc.php"); |
| 46 | 46 | |
| 47 | 47 | require_once(KT_LIB_DIR . "/validation/dispatchervalidation.inc.php"); |
| 48 | 48 | |
| 49 | +//CHARL TEST | |
| 50 | +require_once(KT_LIB_DIR . "/metadata/fieldsetregistry.inc.php"); | |
| 51 | +require_once(KT_LIB_DIR . "/widgets/widgetfactory.inc.php"); | |
| 52 | +require_once(KT_LIB_DIR . "/validation/validatorfactory.inc.php"); | |
| 53 | + | |
| 54 | + | |
| 49 | 55 | class InetBulkUploadFolderAction extends KTFolderAction { |
| 50 | - var $sName = 'inet.actions.folder.bulkUpload'; | |
| 51 | - | |
| 52 | - var $_sShowPermission = "ktcore.permissions.write"; | |
| 53 | - var $bAutomaticTransaction = false; | |
| 54 | - /** | |
| 55 | - * returns the string | |
| 56 | - * @return | |
| 57 | - * loads the necessary javascripts too. | |
| 58 | - * | |
| 59 | - * iNET Process | |
| 60 | - */ | |
| 61 | - function getDisplayName() { | |
| 62 | - if(!KTPluginUtil::pluginIsActive('inet.foldermetadata.plugin')) | |
| 63 | - { | |
| 64 | - $js = "<script src='plugins/multiselect/js/jquery-1.2.6.js' type='text/javascript'></script>"; | |
| 65 | - $js .= "<script src='plugins/multiselect/js/hidelink.js' type='text/javascript'></script>"; | |
| 66 | - return $js._kt('Bulk Upload'); | |
| 67 | - } | |
| 68 | - else | |
| 69 | - { | |
| 70 | - return null; | |
| 71 | - } | |
| 72 | - } | |
| 73 | - /** | |
| 74 | - * Checks for bulk uploads | |
| 75 | - * @return | |
| 76 | - * | |
| 77 | - * iNET Process | |
| 78 | - */ | |
| 79 | - function check() { | |
| 80 | - $res = parent::check(); | |
| 81 | - if (empty($res)) { | |
| 82 | - return $res; | |
| 83 | - } | |
| 84 | - $postExpected = KTUtil::arrayGet($_REQUEST, "postExpected"); | |
| 85 | - $postReceived = KTUtil::arrayGet($_REQUEST, "postReceived"); | |
| 86 | - if (!empty($postExpected)) { | |
| 87 | - $aErrorOptions = array( | |
| 56 | + var $sName = 'inet.actions.folder.bulkUpload'; | |
| 57 | + | |
| 58 | + var $_sShowPermission = "ktcore.permissions.write"; | |
| 59 | + var $bAutomaticTransaction = false; | |
| 60 | + /** | |
| 61 | + * returns the string | |
| 62 | + * @return | |
| 63 | + * loads the necessary javascripts too. | |
| 64 | + * | |
| 65 | + * iNET Process | |
| 66 | + */ | |
| 67 | + function getDisplayName() { | |
| 68 | + if(!KTPluginUtil::pluginIsActive('inet.foldermetadata.plugin')) | |
| 69 | + { | |
| 70 | + $js = "<script src='plugins/multiselect/js/jquery-1.2.6.js' type='text/javascript'></script>"; | |
| 71 | + $js .= "<script src='plugins/multiselect/js/hidelink.js' type='text/javascript'></script>"; | |
| 72 | + return $js._kt('Bulk Upload'); | |
| 73 | + } | |
| 74 | + else | |
| 75 | + { | |
| 76 | + return null; | |
| 77 | + } | |
| 78 | + } | |
| 79 | + | |
| 80 | + /** | |
| 81 | + * Checks for bulk uploads | |
| 82 | + * @return | |
| 83 | + * | |
| 84 | + * iNET Process | |
| 85 | + */ | |
| 86 | + function check() { | |
| 87 | + $res = parent::check(); | |
| 88 | + if (empty($res)) { | |
| 89 | + return $res; | |
| 90 | + } | |
| 91 | + $postExpected = KTUtil::arrayGet($_REQUEST, "postExpected"); | |
| 92 | + $postReceived = KTUtil::arrayGet($_REQUEST, "postReceived"); | |
| 93 | + if (!empty($postExpected)) { | |
| 94 | + $aErrorOptions = array( | |
| 88 | 95 | 'redirect_to' => array('main', sprintf('fFolderId=%d', $this->oFolder->getId())), |
| 89 | 96 | 'message' => _kt('Upload larger than maximum POST size (post_max_size variable in .htaccess or php.ini)'), |
| 90 | - ); | |
| 91 | - $this->oValidator->notEmpty($postReceived, $aErrorOptions); | |
| 92 | - } | |
| 93 | - return true; | |
| 94 | - } | |
| 95 | - /** | |
| 96 | - * default and basic function | |
| 97 | - * @return template | |
| 98 | - * @param. | |
| 99 | - * iNET Process | |
| 100 | - */ | |
| 101 | - function do_main() { | |
| 102 | - $this->oPage->setBreadcrumbDetails(_kt("bulk upload")); | |
| 103 | - $oTemplate =& $this->oValidator->validateTemplate('ktcore/folder/bulkUpload'); | |
| 104 | - $add_fields = array(); | |
| 105 | - $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"); | |
| 106 | - | |
| 107 | - $aVocab = array('' => _kt('- Please select a document type -')); | |
| 108 | - foreach (DocumentType::getListForUserAndFolder($this->oUser, $this->oFolder) as $oDocumentType) { | |
| 109 | - if(!$oDocumentType->getDisabled()) { | |
| 110 | - $aVocab[$oDocumentType->getId()] = $oDocumentType->getName(); | |
| 111 | - } | |
| 112 | - } | |
| 113 | - $fieldOptions = array("vocab" => $aVocab); | |
| 114 | - $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); | |
| 115 | - | |
| 116 | - $fieldsets = array(); | |
| 117 | - $fieldsetDisplayReg =& KTFieldsetDisplayRegistry::getSingleton(); | |
| 118 | - $activesets = KTFieldset::getGenericFieldsets(); | |
| 119 | - foreach ($activesets as $oFieldset) { | |
| 120 | - $displayClass = $fieldsetDisplayReg->getHandler($oFieldset->getNamespace()); | |
| 121 | - array_push($fieldsets, new $displayClass($oFieldset)); | |
| 122 | - } | |
| 97 | + ); | |
| 98 | + $this->oValidator->notEmpty($postReceived, $aErrorOptions); | |
| 99 | + } | |
| 100 | + return true; | |
| 101 | + } | |
| 123 | 102 | |
| 124 | - // Implement an electronic signature for accessing the admin section, it will appear every 10 minutes | |
| 125 | - global $default; | |
| 126 | - $iFolderId = $this->oFolder->getId(); | |
| 127 | - if($default->enableESignatures){ | |
| 128 | - $sUrl = KTPluginUtil::getPluginPath('electronic.signatures.plugin', true); | |
| 129 | - $heading = _kt('You are attempting to perform a bulk upload'); | |
| 130 | - $submit['type'] = 'button'; | |
| 131 | - $submit['onclick'] = "javascript: showSignatureForm('{$sUrl}', '{$heading}', 'ktcore.transactions.bulk_upload', 'bulk', 'bulk_upload_form', 'submit', {$iFolderId});"; | |
| 132 | - }else{ | |
| 133 | - $submit['type'] = 'submit'; | |
| 134 | - $submit['onclick'] = ''; | |
| 135 | - } | |
| 103 | + /** | |
| 104 | + * default and basic function | |
| 105 | + * @return template | |
| 106 | + * @param. | |
| 107 | + * iNET Process | |
| 108 | + * | |
| 109 | + */ | |
| 110 | + function do_main() { | |
| 111 | + $bulkUploadForm = $this->getBulkUploadForm(); | |
| 112 | + return $bulkUploadForm->render(); | |
| 113 | + } | |
| 114 | + | |
| 115 | + | |
| 116 | + /** | |
| 117 | + * Returns the main Bulk Upload Form | |
| 118 | + * @return KTForm | |
| 119 | + * | |
| 120 | + */ | |
| 121 | + | |
| 122 | + function getBulkUploadForm() { | |
| 123 | + $this->oPage->setBreadcrumbDetails(_kt("bulk upload")); | |
| 136 | 124 | |
| 137 | - $oTemplate->setData(array( | |
| 125 | + $oForm = new KTForm; | |
| 126 | + $oForm->setOptions(array( | |
| 127 | + 'identifier' => 'ktcore.folder.bulkUpload', | |
| 128 | + 'label' => _kt('Bulk Upload'), | |
| 129 | + 'submit_label' => _kt('Upload'), | |
| 130 | + 'action' => 'upload', | |
| 131 | + 'fail_action' => 'main', | |
| 132 | + 'encoding' => 'multipart/form-data', | |
| 133 | + // 'cancel_url' => KTBrowseUtil::getUrlForDocument($this->oDocument), | |
| 138 | 134 | 'context' => &$this, |
| 139 | - 'submit' => $submit, | |
| 140 | - 'add_fields' => $add_fields, | |
| 141 | - 'generic_fieldsets' => $fieldsets, | |
| 142 | - )); | |
| 143 | - return $oTemplate->render(); | |
| 144 | - } | |
| 145 | - /** | |
| 146 | - * make uploads | |
| 147 | - * @return | |
| 148 | - * | |
| 149 | - * iNET Process | |
| 150 | - */ | |
| 151 | - function do_upload() { | |
| 152 | - set_time_limit(0); | |
| 153 | - $aErrorOptions = array( | |
| 135 | + 'extraargs' => $this->meldPersistQuery("","",true), | |
| 136 | + 'description' => _kt('The bulk upload facility allows for a number of documents to be added to the document management system. Provide an archive (ZIP) file from your local computer, and all documents and folders within that archive will be added to the document management system.') | |
| 137 | + )); | |
| 138 | + | |
| 139 | + $oWF =& KTWidgetFactory::getSingleton(); | |
| 140 | + | |
| 141 | + $widgets = array(); | |
| 142 | + $validators = array(); | |
| 143 | + | |
| 144 | + // Adding the File Upload Widget | |
| 145 | + | |
| 146 | + //Legacy kt3 widgets don't conform to ktcore type widgets by virtue of the 'name' attribute. | |
| 147 | + //$widgets[] = new KTFileUploadWidget(_kt('Archive file'), , 'file', "", $this->oPage, true, "file"); | |
| 148 | + | |
| 149 | + $widgets[] = $oWF->get('ktcore.widgets.file', array( | |
| 150 | + 'label' => _kt('Archive file'), | |
| 151 | + 'required' => true, | |
| 152 | + 'name' => 'file', | |
| 153 | + 'id' => 'file', | |
| 154 | + 'value' => '', | |
| 155 | + 'description' => _kt('The archive file containing the documents you wish to add to the document management system.'), | |
| 156 | + )); | |
| 157 | + | |
| 158 | + $aTypes = array(); | |
| 159 | + foreach (DocumentType::getListForUserAndFolder($this->oUser, $this->oFolder) as $oDocumentType) { | |
| 160 | + if(!$oDocumentType->getDisabled()) { | |
| 161 | + $aTypes[] = $oDocumentType; | |
| 162 | + } | |
| 163 | + } | |
| 164 | + | |
| 165 | + //Adding document type lookup widget | |
| 166 | + $widgets[] = $oWF->get('ktcore.widgets.entityselection',array( | |
| 167 | + 'label' => _kt('Document Type'), | |
| 168 | + 'id' => 'add-document-type', | |
| 169 | + 'description' => _kt('Document Types, defined by the administrator, are used to categorise documents. Please select a Document Type from the list below.'), | |
| 170 | + 'name' => 'fDocumentTypeId', | |
| 171 | + 'required' => true, | |
| 172 | + 'vocab' => $aTypes, | |
| 173 | + 'initial_string' => _kt('- Please select a document type -'), | |
| 174 | + 'id_method' => 'getId', | |
| 175 | + 'label_method' => 'getName', | |
| 176 | + 'simple_select' => false, | |
| 177 | + )); | |
| 178 | + | |
| 179 | + //Adding the quick "add" button for when no meta data needs to be added. | |
| 180 | + //FIXME: This widget should only display if there are any "required" fields for the given document type | |
| 181 | + // Default/general document field type must also be taken into consideration | |
| 182 | + | |
| 183 | + $widgets[] = $oWF->get('ktcore.widgets.button',array( | |
| 184 | + 'value' => _kt('Add'), | |
| 185 | + 'id' => 'quick_add', | |
| 186 | + '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.'), | |
| 187 | + 'name' => 'btn_quick_submit', | |
| 188 | + )); | |
| 189 | + | |
| 190 | + $oFReg =& KTFieldsetRegistry::getSingleton(); | |
| 191 | + | |
| 192 | + $activesets = KTFieldset::getGenericFieldsets(); | |
| 193 | + foreach ($activesets as $oFieldset) { | |
| 194 | + $widgets = kt_array_merge($widgets, $oFReg->widgetsForFieldset($oFieldset, 'fieldset_' . $oFieldset->getId(), $this->oDocument)); | |
| 195 | + $validators = kt_array_merge($validators, $oFReg->validatorsForFieldset($oFieldset, 'fieldset_' . $oFieldset->getId(), $this->oDocument)); | |
| 196 | + } | |
| 197 | + | |
| 198 | + $oForm->setWidgets($widgets); | |
| 199 | + $oForm->setValidators($validators); | |
| 200 | + | |
| 201 | + // Implement an electronic signature for accessing the admin section, it will appear every 10 minutes | |
| 202 | + global $default; | |
| 203 | + $iFolderId = $this->oFolder->getId(); | |
| 204 | + if($default->enableESignatures){ | |
| 205 | + $sUrl = KTPluginUtil::getPluginPath('electronic.signatures.plugin', true); | |
| 206 | + $heading = _kt('You are attempting to perform a bulk upload'); | |
| 207 | + $submit['type'] = 'button'; | |
| 208 | + $submit['onclick'] = "javascript: showSignatureForm('{$sUrl}', '{$heading}', 'ktcore.transactions.bulk_upload', 'bulk', 'bulk_upload_form', 'submit', {$iFolderId});"; | |
| 209 | + }else{ | |
| 210 | + $submit['type'] = 'submit'; | |
| 211 | + $submit['onclick'] = ''; | |
| 212 | + } | |
| 213 | + | |
| 214 | + return $oForm; | |
| 215 | + } | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + /** | |
| 220 | + * default and basic function | |
| 221 | + * @return template | |
| 222 | + * @param. | |
| 223 | + * iNET Process | |
| 224 | + * | |
| 225 | + * Depricated : Using the new ktcore form above. | |
| 226 | + */ | |
| 227 | + /* | |
| 228 | + function do_main() { | |
| 229 | + $this->oPage->setBreadcrumbDetails(_kt("bulk upload")); | |
| 230 | + $oTemplate =& $this->oValidator->validateTemplate('ktcore/folder/bulkUpload'); | |
| 231 | + | |
| 232 | + $add_fields = array(); | |
| 233 | + $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"); | |
| 234 | + | |
| 235 | + $aVocab = array('' => _kt('- Please select a document type -')); | |
| 236 | + foreach (DocumentType::getListForUserAndFolder($this->oUser, $this->oFolder) as $oDocumentType) { | |
| 237 | + if(!$oDocumentType->getDisabled()) { | |
| 238 | + $aVocab[$oDocumentType->getId()] = $oDocumentType->getName(); | |
| 239 | + } | |
| 240 | + } | |
| 241 | + $fieldOptions = array("vocab" => $aVocab); | |
| 242 | + $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); | |
| 243 | + | |
| 244 | + $fieldsets = array(); | |
| 245 | + $validators = array(); | |
| 246 | + $fieldsetDisplayReg =& KTFieldsetDisplayRegistry::getSingleton(); | |
| 247 | + | |
| 248 | + $oFReg =& KTFieldsetRegistry::getSingleton(); | |
| 249 | + | |
| 250 | + $activesets = KTFieldset::getGenericFieldsets(); | |
| 251 | + foreach ($activesets as $oFieldset) { | |
| 252 | + $displayClass = $fieldsetDisplayReg->getHandler($oFieldset->getNamespace()); | |
| 253 | + array_push($fieldsets, new $displayClass($oFieldset)); | |
| 254 | + } | |
| 255 | + | |
| 256 | + // Implement an electronic signature for accessing the admin section, it will appear every 10 minutes | |
| 257 | + global $default; | |
| 258 | + $iFolderId = $this->oFolder->getId(); | |
| 259 | + if($default->enableESignatures){ | |
| 260 | + $sUrl = KTPluginUtil::getPluginPath('electronic.signatures.plugin', true); | |
| 261 | + $heading = _kt('You are attempting to perform a bulk upload'); | |
| 262 | + $submit['type'] = 'button'; | |
| 263 | + $submit['onclick'] = "javascript: showSignatureForm('{$sUrl}', '{$heading}', 'ktcore.transactions.bulk_upload', 'bulk', 'bulk_upload_form', 'submit', {$iFolderId});"; | |
| 264 | + }else{ | |
| 265 | + $submit['type'] = 'submit'; | |
| 266 | + $submit['onclick'] = ''; | |
| 267 | + } | |
| 268 | + | |
| 269 | + $oTemplate->setData(array( | |
| 270 | + 'context' => &$this, | |
| 271 | + 'submit' => $submit, | |
| 272 | + 'add_fields' => $add_fields, | |
| 273 | + 'generic_fieldsets' => $fieldsets, | |
| 274 | + )); | |
| 275 | + | |
| 276 | + return $oTemplate->render(); | |
| 277 | + } | |
| 278 | + */ | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + /** | |
| 283 | + * make uploads | |
| 284 | + * @return | |
| 285 | + * | |
| 286 | + * iNET Process | |
| 287 | + */ | |
| 288 | + function do_upload() { | |
| 289 | + set_time_limit(0); | |
| 290 | + $aErrorOptions = array( | |
| 154 | 291 | 'redirect_to' => array('main', sprintf('fFolderId=%d', $this->oFolder->getId())), |
| 155 | - ); | |
| 292 | + ); | |
| 293 | + | |
| 294 | + $aErrorOptions['message'] = _kt('Invalid document type provided'); | |
| 295 | + | |
| 296 | + $requestDocumentType = $_REQUEST['fDocumentTypeId']; //Backwards compatibility | |
| 297 | + if ($requestDocumentType == '' || $requestDocumentType == NULL) { | |
| 298 | + $requestDocumentType = $_REQUEST['data']; | |
| 299 | + $requestDocumentType = $requestDocumentType['fDocumentTypeId']; //New elements come through as arrays | |
| 300 | + } | |
| 301 | + | |
| 302 | + $oDocumentType = $this->oValidator->validateDocumentType($requestDocumentType, $aErrorOptions); | |
| 303 | + | |
| 304 | + unset($aErrorOptions['message']); | |
| 305 | + $fileName = $_FILES['file']; | |
| 306 | + if ($fileName == '' || $fileName == NULL){ | |
| 307 | + $fileName = $_FILES['_kt_attempt_unique_file'];//$_FILES['_kt_attempt_unique_file']; | |
| 308 | + } | |
| 309 | + | |
| 310 | + $aFile = $this->oValidator->validateFile($fileName, $aErrorOptions); | |
| 311 | + | |
| 312 | + $matches = array(); | |
| 313 | + $aFields = array(); | |
| 314 | + | |
| 315 | + // author: Charl Mert | |
| 316 | + // Older kt3 form field submission used name='metadata_9 etc and the aFields array contained them.' | |
| 317 | + // Should keep open here for backwards compatibility but will close it to "discover" the other | |
| 318 | + // old interfaces. | |
| 319 | + /* | |
| 320 | + foreach ($_REQUEST as $k => $v) { | |
| 321 | + if (preg_match('/^metadata_(\d+)$/', $k, $matches)) { | |
| 322 | + // multiselect change start | |
| 323 | + $oDocField = DocumentField::get($matches[1]); | |
| 324 | + | |
| 325 | + if(KTPluginUtil::pluginIsActive('inet.multiselect.lookupvalue.plugin') && $oDocField->getHasInetLookup() && is_array($v)) | |
| 326 | + { | |
| 327 | + $v = join(", ", $v); | |
| 328 | + } | |
| 329 | + $aFields[] = array($oDocField, $v); | |
| 156 | 330 | |
| 157 | - $aErrorOptions['message'] = _kt('Invalid document type provided'); | |
| 158 | - $oDocumentType = $this->oValidator->validateDocumentType($_REQUEST['fDocumentTypeId'], $aErrorOptions); | |
| 331 | + // previously it was just one line which is commented, just above line | |
| 332 | + // multiselect change end | |
| 333 | + } | |
| 334 | + } | |
| 335 | + */ | |
| 159 | 336 | |
| 160 | - unset($aErrorOptions['message']); | |
| 161 | - $aFile = $this->oValidator->validateFile($_FILES['file'], $aErrorOptions); | |
| 337 | + //Newer metadata form field catcher that works with ktcore form array type fields named like | |
| 338 | + //name='metadata[fieldset][metadata_9]' | |
| 339 | + | |
| 340 | + $aData = $_REQUEST['data']; | |
| 341 | + | |
| 342 | + $oForm = $this->getBulkUploadForm(); | |
| 343 | + $res = $oForm->validate(); | |
| 344 | + if (!empty($res['errors'])) { | |
| 345 | + return $oForm->handleError(); | |
| 346 | + } | |
| 347 | + $data = $res['results']; | |
| 348 | + | |
| 349 | + $doctypeid = $requestDocumentType; | |
| 350 | + $aGenericFieldsetIds = KTFieldset::getGenericFieldsets(array('ids' => false)); | |
| 351 | + $aSpecificFieldsetIds = KTFieldset::getForDocumentType($doctypeid, array('ids' => false)); | |
| 352 | + $fieldsets = kt_array_merge($aGenericFieldsetIds, $aSpecificFieldsetIds); | |
| 353 | + | |
| 354 | + $MDPack = array(); | |
| 355 | + foreach ($fieldsets as $oFieldset) { | |
| 356 | + $fields = $oFieldset->getFields(); | |
| 357 | + $values = (array) KTUtil::arrayGet($data, 'fieldset_' . $oFieldset->getId()); | |
| 162 | 358 | |
| 163 | - $matches = array(); | |
| 164 | - $aFields = array(); | |
| 165 | - foreach ($_REQUEST as $k => $v) { | |
| 166 | - if (preg_match('/^metadata_(\d+)$/', $k, $matches)) { | |
| 167 | - // multiselect change start | |
| 168 | - $oDocField = DocumentField::get($matches[1]); | |
| 169 | - if(KTPluginUtil::pluginIsActive('inet.multiselect.lookupvalue.plugin') && $oDocField->getHasInetLookup() && is_array($v)) | |
| 359 | + foreach ($fields as $oField) { | |
| 360 | + $val = KTUtil::arrayGet($values, 'metadata_' . $oField->getId()); | |
| 361 | + if ($oFieldset->getIsConditional()) | |
| 170 | 362 | { |
| 171 | - $v = join(", ", $v); | |
| 363 | + if ($val == _kt('No selection.')) | |
| 364 | + { | |
| 365 | + $val = null; | |
| 366 | + } | |
| 172 | 367 | } |
| 173 | - $aFields[] = array($oDocField, $v); | |
| 174 | - | |
| 175 | - // previously it was just one line which is commented, just above line | |
| 176 | - // multiselect change end | |
| 177 | - } | |
| 178 | - } | |
| 179 | 368 | |
| 180 | - $aOptions = array( | |
| 181 | - 'documenttype' => $oDocumentType, | |
| 182 | - 'metadata' => $aFields, | |
| 183 | - ); | |
| 184 | - | |
| 185 | - $fs =& new KTZipImportStorage('file'); | |
| 186 | - if(!$fs->CheckFormat()){ | |
| 187 | - $sFormats = $fs->getFormats(); | |
| 188 | - $this->addErrorMessage(_kt("Bulk Upload failed. Archive is not an accepted format. Accepted formats are: ".$sFormats)); | |
| 189 | - controllerRedirect("browse", 'fFolderId=' . $this->oFolder->getID()); | |
| 190 | - exit; | |
| 191 | - } | |
| 369 | + if (!is_null($val)) { | |
| 370 | + $MDPack[] = array( | |
| 371 | + $oField, | |
| 372 | + $val | |
| 373 | + ); | |
| 374 | + } | |
| 192 | 375 | |
| 193 | - if(KTPluginUtil::pluginIsActive('inet.foldermetadata.plugin')) | |
| 194 | - { | |
| 195 | - require_once(KT_DIR . "/plugins/foldermetadata/import/bulkimport.inc.php"); | |
| 196 | - $bm =& new KTINETBulkImportManager($this->oFolder, $fs, $this->oUser, $aOptions); | |
| 197 | - } | |
| 198 | - else | |
| 199 | - { | |
| 200 | - $bm =& new KTBulkImportManager($this->oFolder, $fs, $this->oUser, $aOptions); | |
| 201 | - } | |
| 376 | + } | |
| 377 | + } | |
| 202 | 378 | |
| 203 | - $this->startTransaction(); | |
| 204 | - $res = $bm->import(); | |
| 379 | + $aOptions = array( | |
| 380 | + 'documenttype' => $oDocumentType, | |
| 381 | + 'metadata' => $MDPack, | |
| 382 | + ); | |
| 383 | + | |
| 384 | + $fs =& new KTZipImportStorage('_kt_attempt_unique_file'); | |
| 385 | + if(!$fs->CheckFormat()){ | |
| 386 | + $sFormats = $fs->getFormats(); | |
| 387 | + $this->addErrorMessage(_kt("Bulk Upload failed. Archive is not an accepted format. Accepted formats are: ".$sFormats)); | |
| 388 | + controllerRedirect("browse", 'fFolderId=' . $this->oFolder->getID()); | |
| 389 | + exit; | |
| 390 | + } | |
| 391 | + | |
| 392 | + if(KTPluginUtil::pluginIsActive('inet.foldermetadata.plugin')) | |
| 393 | + { | |
| 394 | + require_once(KT_DIR . "/plugins/foldermetadata/import/bulkimport.inc.php"); | |
| 395 | + $bm =& new KTINETBulkImportManager($this->oFolder, $fs, $this->oUser, $aOptions); | |
| 396 | + } | |
| 397 | + else | |
| 398 | + { | |
| 399 | + $bm =& new KTBulkImportManager($this->oFolder, $fs, $this->oUser, $aOptions); | |
| 400 | + } | |
| 401 | + | |
| 402 | + $this->startTransaction(); | |
| 403 | + $res = $bm->import(); | |
| 404 | + | |
| 405 | + $aErrorOptions['message'] = _kt("Bulk Upload failed"); | |
| 406 | + $this->oValidator->notError($res, $aErrorOptions); | |
| 205 | 407 | |
| 206 | - $aErrorOptions['message'] = _kt("Bulk Upload failed"); | |
| 207 | - $this->oValidator->notError($res, $aErrorOptions); | |
| 408 | + $this->addInfoMessage(_kt("Bulk Upload successful")); | |
| 409 | + $this->commitTransaction(); | |
| 208 | 410 | |
| 209 | - $this->addInfoMessage(_kt("Bulk Upload successful")); | |
| 210 | - $this->commitTransaction(); | |
| 211 | - controllerRedirect("browse", 'fFolderId=' . $this->oFolder->getID()); | |
| 212 | - exit(0); | |
| 213 | - } | |
| 411 | + controllerRedirect("browse", 'fFolderId=' . $this->oFolder->getID()); | |
| 412 | + exit(0); | |
| 413 | + } | |
| 214 | 414 | } |
| 215 | 415 | ?> | ... | ... |
resources/js/kt_tinymce_init.js
0 → 100644
| 1 | +tinyMCE.init({ | |
| 2 | +// General options | |
| 3 | +mode : "textareas", | |
| 4 | +editor_selector : "mceEditor", | |
| 5 | +//mode : "exact", | |
| 6 | +//elements: "{/literal}{$name}{literal}", | |
| 7 | +theme : "advanced", | |
| 8 | +plugins : "safari,spellchecker,pagebreak,style,layer,table,save,advhr,advimage,advlink,emotions,iespell,inlinepopups,insertdatetime,preview,media,searchreplace,print,contextmenu,paste,directionality,fullscreen,noneditable,visualchars,nonbreaking,xhtmlxtras,template,imagemanager,filemanager", | |
| 9 | + | |
| 10 | +// Theme options | |
| 11 | +theme_advanced_buttons1 : "bold,italic,underline,strikethrough,|,justifyleft,justifycenter,justifyright,justifyfull,|,styleselect,formatselect,fontselect,fontsizeselect", | |
| 12 | +theme_advanced_buttons2 : "cut,copy,paste,pastetext,pasteword,|,search,replace,|,bullist,numlist,|,outdent,indent,blockquote,|,undo,redo,|,link,unlink,anchor,image,cleanup,help,code,|,insertdate,inserttime,preview,|,forecolor,backcolor", | |
| 13 | +theme_advanced_buttons3 : "tablecontrols,|,hr,removeformat,visualaid,|,sub,sup,|,charmap,emotions,iespell,media,advhr,|,print,|,ltr,rtl,|,fullscreen", | |
| 14 | +theme_advanced_buttons4 : "insertlayer,moveforward,movebackward,absolute,|,styleprops,spellchecker,|,cite,abbr,acronym,del,ins,attribs,|,visualchars,nonbreaking,template,blockquote,pagebreak,|,insertfile,insertimage", | |
| 15 | +theme_advanced_toolbar_location : "top", | |
| 16 | +theme_advanced_toolbar_align : "left", | |
| 17 | +theme_advanced_statusbar_location : "bottom", | |
| 18 | +theme_advanced_resizing : false, | |
| 19 | + | |
| 20 | +// Example content CSS (should be your site CSS) | |
| 21 | +content_css : "css/example.css", | |
| 22 | + | |
| 23 | +// Drop lists for link/image/media/template dialogs | |
| 24 | +template_external_list_url : "js/template_list.js", | |
| 25 | +external_link_list_url : "js/link_list.js", | |
| 26 | +external_image_list_url : "js/image_list.js", | |
| 27 | +media_external_list_url : "js/media_list.js", | |
| 28 | + | |
| 29 | +// Replace values for the template plugin | |
| 30 | +template_replace_values : { | |
| 31 | +username : "Some User", | |
| 32 | +staffid : "991234" | |
| 33 | +} | |
| 34 | +}); | ... | ... |
templates/ktcore/forms/widgets/button.smarty
0 → 100644
| 1 | +<input type="submit" {if $has_id}id="{$id}"{/if} name="{$name}" {if $has_value}value="{$value|sanitize_input}"{/if} /> | ... | ... |
templates/ktcore/forms/widgets/textarea.smarty
| 1 | 1 | <!-------------------------------------- |
| 2 | 2 | ---- Changes for Custom Fields ----- |
| 3 | - ------------------------------------ | |
| 4 | - Bold, italics, underline, hyperlink and colour. | |
| 5 | -Lists, ordered and unordered (<ul>, <ol>, <li>). | |
| 6 | -Paragraph and break tags. | |
| 7 | - --> | |
| 3 | + --------------------------------------> | |
| 8 | 4 | {if $options.field->getIsHTML()} |
| 9 | 5 | {literal} |
| 10 | -<script type="text/javascript" src="/thirdpartyjs/tinymce/jscripts/tiny_mce/tiny_mce.js"></script> | |
| 11 | -<script type="text/javascript"> | |
| 12 | -tinyMCE.init({ | |
| 13 | -// General options | |
| 14 | -mode : "textareas", | |
| 15 | -editor_selector : "mceEditor", | |
| 16 | -//mode : "exact", | |
| 17 | -//elements: "{/literal}{$name}{literal}", | |
| 18 | -theme : "advanced", | |
| 19 | -plugins : "safari,spellchecker,pagebreak,style,layer,table,save,advhr,advimage,advlink,emotions,iespell,inlinepopups,insertdatetime,preview,media,searchreplace,print,contextmenu,paste,directionality,fullscreen,noneditable,visualchars,nonbreaking,xhtmlxtras,template,imagemanager,filemanager", | |
| 20 | - | |
| 21 | -// Theme options | |
| 22 | -theme_advanced_buttons1 : "bold,italic,underline,|,forecolor,backcolor,|,bullist,numlist,|,link,unlink,anchor,|,pagebreak,|,insertdate,inserttime,preview,help", | |
| 23 | -theme_advanced_buttons2 : "cut,copy,paste,pastetext,pasteword,|,search,replace,|,undo,redo,|,cleanup,removeformat,print,fullscreen,spellchecker", | |
| 24 | -theme_advanced_buttons3 : "", | |
| 25 | -theme_advanced_toolbar_location : "top", | |
| 26 | -theme_advanced_toolbar_align : "left", | |
| 27 | -theme_advanced_statusbar_location : "bottom", | |
| 28 | -theme_advanced_resizing : false, | |
| 29 | - | |
| 30 | -// Example content CSS (should be your site CSS) | |
| 31 | -content_css : "css/example.css", | |
| 32 | - | |
| 33 | -// Drop lists for link/image/media/template dialogs | |
| 34 | -template_external_list_url : "js/template_list.js", | |
| 35 | -external_link_list_url : "js/link_list.js", | |
| 36 | -external_image_list_url : "js/image_list.js", | |
| 37 | -media_external_list_url : "js/media_list.js", | |
| 38 | - | |
| 39 | -// Replace values for the template plugin | |
| 40 | -template_replace_values : { | |
| 41 | -username : "Some User", | |
| 42 | -staffid : "991234" | |
| 43 | -} | |
| 44 | -}); | |
| 45 | -</script> | |
| 6 | + | |
| 46 | 7 | {/literal} |
| 47 | 8 | {/if} |
| 48 | 9 | |
| ... | ... | @@ -50,4 +11,4 @@ staffid : "991234" |
| 50 | 11 | {if $has_id} id="{$id}"{/if} |
| 51 | 12 | {if $options.rows} rows="{$options.rows}"{else} rows="7"{/if} |
| 52 | 13 | {if $options.cols} cols="{$options.cols}"{else} cols="45"{/if} |
| 53 | - >{if $has_value}{$value|sanitize_input}{/if}</textarea> | |
| 54 | 14 | \ No newline at end of file |
| 15 | + >{if $has_value}{$value|sanitize_input}{/if}</textarea> | ... | ... |