function formAdaptor($oFieldset, $oDocument = null)
 {
     $widgets = array();
     $validators = array();
     $oVF =& KTValidationFactory::getSingleton();
     $oWF =& KTWidgetFactory::getSingleton();
     $fields =& $oFieldset->getFields();
     foreach ($fields as $oField) {
         // FIXME we probably want to use some form of factory here.
         $field_name = 'metadata_' . $oField->getId();
         if ($field->getHasLookup()) {
             // lookups
             if ($field->getHasLookupTree()) {
                 // tree
                 // FIXME we don't handle trees yet
                 continue;
                 /*
                 $fieldTree = new MDTree();
                                     $fieldTree->buildForField($field->getId());
                                     $fieldTree->setActiveItem($current_value);
                     	    		$fieldOptions['tree'] = $fieldTree->_evilTreeRenderer($fieldTree, $fieldName);
                                     $oField = new KTTreeWidget($fieldLabel, $fieldDescription, $fieldName, $fieldValue, $page, $fieldRequired, null, $fieldErrors, $fieldOptions);
                 */
             } else {
                 // normal
                 $widgets[] = $oWF->get('ktcore.widgets.entityselection', array('label' => $oField->getName(), 'name' => 'metadata_' . $oField->getId(), 'description' => $oField->getDescription(), 'vocab' => MetaData::getEnabledByDocumentField($oField), 'id_method' => 'getName', 'label_method' => 'getName', 'required' => $oField->getIsMandatory()));
                 if ($oField->getIsMandatory()) {
                     $validators[] = $oVF->get('ktcore.validators.required', array('test' => $field_name, 'basename' => 'metadata_'));
                 }
                 $validators[] = $oVF->get('ktcore.validators.membership', array('test' => $field_name, 'output' => $field_name, 'basename' => $field_name, 'vocab' => MetaData::getEnabledValuesForField($oField)));
             }
         } else {
             $widgets[] = $oWF->get('ktcore.widgets.string', array('label' => $oField->getName(), 'output' => $field_name));
             if ($oField->getIsMandatory()) {
                 $validators[] = $oVF->get('ktcore.validators.required', array('test' => $field_name, 'basename' => $field_name));
             }
         }
     }
     return array('widgets' => $widgets, 'validators' => $validators);
 }
示例#2
0
    function do_addUnit2()
    {
        $this->oPage->setBreadcrumbDetails(_kt('Add a new unit'));
        $this->oPage->setTitle(_kt("Add a new unit"));
        $aOptions = array('redirect_to' => array('addUnit'), 'message' => _kt('No name given'));
        $sName = $this->oValidator->validateString($_REQUEST['unit_name'], $aOptions);
        $aOptions['message'] = _kt('A unit with that name already exists.');
        $sName = $this->oValidator->validateDuplicateName('Unit', $sName, $aOptions);
        $iFolderId = KTUtil::arrayGet($_REQUEST, 'fFolderId', 1);
        $_REQUEST['fFolderId'] = $iFolderId;
        $oFolder = $this->oValidator->validateFolder($_REQUEST['fFolderId']);
        // Setup the collection for move display.
        $collection = new AdvancedCollection();
        $oCR =& KTColumnRegistry::getSingleton();
        $col = $oCR->getColumn('ktcore.columns.title');
        $col->setOptions(array('qs_params' => array('fFolderId' => $oFolder->getId())));
        $collection->addColumn($col);
        $qObj = new FolderBrowseQuery($oFolder->getId());
        $collection->setQueryObject($qObj);
        $collection->empty_message = _kt('No folders available in this location.');
        $aOptions = $collection->getEnvironOptions();
        $collection->setOptions($aOptions);
        $oWF =& KTWidgetFactory::getSingleton();
        $oWidget = $oWF->get('ktcore.widgets.collection', array('label' => _kt('Target Folder'), 'description' => _kt('<p>The folder given below is where the unit folder will be created. Use the folder collection and path below to browse to the folder you wish to create the unit folder into.</p><p>The unit administrators have additional rights within that portion of the document management system.
</p>'), 'required' => true, 'name' => 'browse', 'folder_id' => $oFolder->getId(), 'collection' => $collection));
        $add_fields = array();
        $add_fields[] = new KTStaticTextWidget(_kt('Unit Name'), _kt('A short name for the unit.  e.g. <strong>Accounting</strong>.'), 'unit_name', $sName, $this->oPage, true);
        $add_fields[] = $oWidget;
        $oTemplating =& KTTemplating::getSingleton();
        $oTemplate = $oTemplating->loadTemplate("ktcore/principals/addunit2");
        $aTemplateData = array("context" => $this, "add_fields" => $add_fields, "unit_name" => $sName, "folder" => $oFolder, "name" => $sName);
        return $oTemplate->render($aTemplateData);
    }
示例#3
0
 /**
  * Original load function for the plugins
  * @deprecated
  */
 function load2()
 {
     if (!$this->isRegistered()) {
         return;
     }
     $this->setup();
     require_once KT_LIB_DIR . '/actions/actionregistry.inc.php';
     require_once KT_LIB_DIR . '/actions/portletregistry.inc.php';
     require_once KT_LIB_DIR . '/triggers/triggerregistry.inc.php';
     require_once KT_LIB_DIR . '/plugins/pageregistry.inc.php';
     require_once KT_LIB_DIR . '/authentication/authenticationproviderregistry.inc.php';
     require_once KT_LIB_DIR . "/plugins/KTAdminNavigation.php";
     require_once KT_LIB_DIR . "/dashboard/dashletregistry.inc.php";
     require_once KT_LIB_DIR . "/i18n/i18nregistry.inc.php";
     require_once KT_LIB_DIR . "/help/help.inc.php";
     require_once KT_LIB_DIR . "/workflow/workflowutil.inc.php";
     require_once KT_LIB_DIR . "/widgets/widgetfactory.inc.php";
     require_once KT_LIB_DIR . "/validation/validatorfactory.inc.php";
     require_once KT_LIB_DIR . "/browse/columnregistry.inc.php";
     require_once KT_LIB_DIR . "/browse/criteriaregistry.php";
     require_once KT_LIB_DIR . "/authentication/interceptorregistry.inc.php";
     $oPRegistry =& KTPortletRegistry::getSingleton();
     $oTRegistry =& KTTriggerRegistry::getSingleton();
     $oARegistry =& KTActionRegistry::getSingleton();
     $oPageRegistry =& KTPageRegistry::getSingleton();
     $oAPRegistry =& KTAuthenticationProviderRegistry::getSingleton();
     $oAdminRegistry =& KTAdminNavigationRegistry::getSingleton();
     $oDashletRegistry =& KTDashletRegistry::getSingleton();
     $oi18nRegistry =& KTi18nRegistry::getSingleton();
     $oKTHelpRegistry =& KTHelpRegistry::getSingleton();
     $oWFTriggerRegistry =& KTWorkflowTriggerRegistry::getSingleton();
     $oColumnRegistry =& KTColumnRegistry::getSingleton();
     $oNotificationHandlerRegistry =& KTNotificationRegistry::getSingleton();
     $oTemplating =& KTTemplating::getSingleton();
     $oWidgetFactory =& KTWidgetFactory::getSingleton();
     $oValidatorFactory =& KTValidatorFactory::getSingleton();
     $oCriteriaRegistry =& KTCriteriaRegistry::getSingleton();
     $oInterceptorRegistry =& KTInterceptorRegistry::getSingleton();
     foreach ($this->_aPortlets as $k => $v) {
         call_user_func_array(array(&$oPRegistry, 'registerPortlet'), $v);
     }
     foreach ($this->_aTriggers as $k => $v) {
         call_user_func_array(array(&$oTRegistry, 'registerTrigger'), $v);
     }
     foreach ($this->_aActions as $k => $v) {
         call_user_func_array(array(&$oARegistry, 'registerAction'), $v);
     }
     foreach ($this->_aPages as $k => $v) {
         call_user_func_array(array(&$oPageRegistry, 'registerPage'), $v);
     }
     foreach ($this->_aAuthenticationProviders as $k => $v) {
         call_user_func_array(array(&$oAPRegistry, 'registerAuthenticationProvider'), $v);
     }
     foreach ($this->_aAdminCategories as $k => $v) {
         call_user_func_array(array(&$oAdminRegistry, 'registerCategory'), $v);
     }
     foreach ($this->_aAdminPages as $k => $v) {
         call_user_func_array(array(&$oAdminRegistry, 'registerLocation'), $v);
     }
     foreach ($this->_aDashlets as $k => $v) {
         call_user_func_array(array(&$oDashletRegistry, 'registerDashlet'), $v);
     }
     foreach ($this->_ai18n as $k => $v) {
         call_user_func_array(array(&$oi18nRegistry, 'registeri18n'), $v);
     }
     foreach ($this->_ai18nLang as $k => $v) {
         call_user_func_array(array(&$oi18nRegistry, 'registeri18nLang'), $v);
     }
     foreach ($this->_aLanguage as $k => $v) {
         call_user_func_array(array(&$oi18nRegistry, 'registerLanguage'), $v);
     }
     foreach ($this->_aHelpLanguage as $k => $v) {
         call_user_func_array(array(&$oKTHelpRegistry, 'registerHelp'), $v);
     }
     foreach ($this->_aWFTriggers as $k => $v) {
         call_user_func_array(array(&$oWFTriggerRegistry, 'registerWorkflowTrigger'), $v);
     }
     foreach ($this->_aColumns as $k => $v) {
         call_user_func_array(array(&$oColumnRegistry, 'registerColumn'), $v);
     }
     foreach ($this->_aViews as $k => $v) {
         call_user_func_array(array(&$oColumnRegistry, 'registerView'), $v);
     }
     foreach ($this->_aNotificationHandlers as $k => $v) {
         call_user_func_array(array(&$oNotificationHandlerRegistry, 'registerNotificationHandler'), $v);
     }
     foreach ($this->_aTemplateLocations as $k => $v) {
         call_user_func_array(array(&$oTemplating, 'addLocation'), $v);
     }
     foreach ($this->_aCriteria as $k => $v) {
         call_user_func_array(array(&$oCriteriaRegistry, 'registerCriterion'), $v);
     }
     foreach ($this->_aWidgets as $k => $v) {
         call_user_func_array(array(&$oWidgetFactory, 'registerWidget'), $v);
     }
     foreach ($this->_aValidators as $k => $v) {
         call_user_func_array(array(&$oValidatorFactory, 'registerValidator'), $v);
     }
     foreach ($this->_aInterceptors as $k => $v) {
         call_user_func_array(array(&$oInterceptorRegistry, 'registerInterceptor'), $v);
     }
 }
示例#4
0
 function configure($aOptions)
 {
     // do NOT use parent.
     $this->sLabel = KTUtil::arrayGet($aOptions, 'label');
     $this->sDescription = KTUtil::arrayGet($aOptions, 'description');
     $this->sName = KTUtil::arrayGet($aOptions, 'name');
     $this->sBasename = $this->sName;
     $aWidgets = (array) KTUtil::arrayGet($aOptions, 'widgets');
     // very similar to the one in forms.inc.php
     if (is_null($this->_oWF)) {
         $this->_oWF =& KTWidgetFactory::getSingleton();
     }
     $this->_widgets = array();
     // we don't want to expose the factory stuff to the user - its an
     // arbitrary distinction to the user.  Good point from NBM ;)
     foreach ($aWidgets as $aInfo) {
         if (is_null($aInfo)) {
             continue;
         } else {
             if (is_object($aInfo)) {
                 // assume this is a fully configured object
                 $this->_widgets[] = $aInfo;
             } else {
                 $namespaceOrObject = $aInfo[0];
                 $config = (array) $aInfo[1];
                 $this->_widgets[] = $this->_oWF->get($namespaceOrObject, $config);
             }
         }
     }
 }
示例#5
0
 /**
  * Load the plugins into the global space
  *
  * @param array $aPlugins
  */
 function load($aPlugins)
 {
     require_once KT_LIB_DIR . '/actions/actionregistry.inc.php';
     require_once KT_LIB_DIR . '/actions/portletregistry.inc.php';
     require_once KT_LIB_DIR . '/triggers/triggerregistry.inc.php';
     require_once KT_LIB_DIR . '/plugins/pageregistry.inc.php';
     require_once KT_LIB_DIR . '/authentication/authenticationproviderregistry.inc.php';
     require_once KT_LIB_DIR . "/plugins/KTAdminNavigation.php";
     require_once KT_LIB_DIR . "/dashboard/dashletregistry.inc.php";
     require_once KT_LIB_DIR . "/i18n/i18nregistry.inc.php";
     require_once KT_LIB_DIR . "/help/help.inc.php";
     require_once KT_LIB_DIR . "/workflow/workflowutil.inc.php";
     require_once KT_LIB_DIR . "/widgets/widgetfactory.inc.php";
     require_once KT_LIB_DIR . "/validation/validatorfactory.inc.php";
     require_once KT_LIB_DIR . "/browse/columnregistry.inc.php";
     require_once KT_LIB_DIR . "/browse/criteriaregistry.php";
     require_once KT_LIB_DIR . "/authentication/interceptorregistry.inc.php";
     $oPRegistry =& KTPortletRegistry::getSingleton();
     $oTRegistry =& KTTriggerRegistry::getSingleton();
     $oARegistry =& KTActionRegistry::getSingleton();
     $oPageRegistry =& KTPageRegistry::getSingleton();
     $oAPRegistry =& KTAuthenticationProviderRegistry::getSingleton();
     $oAdminRegistry =& KTAdminNavigationRegistry::getSingleton();
     $oDashletRegistry =& KTDashletRegistry::getSingleton();
     $oi18nRegistry =& KTi18nRegistry::getSingleton();
     $oKTHelpRegistry =& KTHelpRegistry::getSingleton();
     $oWFTriggerRegistry =& KTWorkflowTriggerRegistry::getSingleton();
     $oColumnRegistry =& KTColumnRegistry::getSingleton();
     $oNotificationHandlerRegistry =& KTNotificationRegistry::getSingleton();
     $oTemplating =& KTTemplating::getSingleton();
     $oWidgetFactory =& KTWidgetFactory::getSingleton();
     $oValidatorFactory =& KTValidatorFactory::getSingleton();
     $oCriteriaRegistry =& KTCriteriaRegistry::getSingleton();
     $oInterceptorRegistry =& KTInterceptorRegistry::getSingleton();
     $oKTPluginRegistry =& KTPluginRegistry::getSingleton();
     // Loop through the loaded plugins and register them for access
     foreach ($aPlugins as $plugin) {
         $sName = $plugin['namespace'];
         $sParams = $plugin['object'];
         $aParams = explode('|', $sParams);
         $sClassType = $plugin['classtype'];
         switch ($sClassType) {
             case 'portlet':
                 $aLocation = unserialize($aParams[0]);
                 if ($aLocation != false) {
                     $aParams[0] = $aLocation;
                 }
                 if (isset($aParams[3])) {
                     $aParams[3] = KTPluginUtil::getFullPath($aParams[3]);
                 }
                 call_user_func_array(array(&$oPRegistry, 'registerPortlet'), $aParams);
                 break;
             case 'trigger':
                 if (isset($aParams[4])) {
                     $aParams[4] = KTPluginUtil::getFullPath($aParams[4]);
                 }
                 call_user_func_array(array(&$oTRegistry, 'registerTrigger'), $aParams);
                 break;
             case 'action':
                 if (isset($aParams[3])) {
                     $aParams[3] = KTPluginUtil::getFullPath($aParams[3]);
                 }
                 call_user_func_array(array(&$oARegistry, 'registerAction'), $aParams);
                 break;
             case 'page':
                 if (isset($aParams[2])) {
                     $aParams[2] = KTPluginUtil::getFullPath($aParams[2]);
                 }
                 call_user_func_array(array(&$oPageRegistry, 'registerPage'), $aParams);
                 break;
             case 'authentication_provider':
                 if (isset($aParams[3])) {
                     $aParams[3] = KTPluginUtil::getFullPath($aParams[3]);
                 }
                 $aParams[0] = _kt($aParams[0]);
                 call_user_func_array(array(&$oAPRegistry, 'registerAuthenticationProvider'), $aParams);
                 break;
             case 'admin_category':
                 $aParams[1] = _kt($aParams[1]);
                 $aParams[2] = _kt($aParams[2]);
                 call_user_func_array(array(&$oAdminRegistry, 'registerCategory'), $aParams);
                 break;
             case 'admin_page':
                 if (isset($aParams[5])) {
                     $aParams[5] = KTPluginUtil::getFullPath($aParams[5]);
                 }
                 $aParams[3] = _kt($aParams[3]);
                 $aParams[4] = _kt($aParams[4]);
                 call_user_func_array(array(&$oAdminRegistry, 'registerLocation'), $aParams);
                 break;
             case 'dashlet':
                 if (isset($aParams[2])) {
                     $aParams[2] = KTPluginUtil::getFullPath($aParams[2]);
                 }
                 call_user_func_array(array(&$oDashletRegistry, 'registerDashlet'), $aParams);
                 break;
             case 'i18nlang':
                 if (isset($aParams[2]) && $aParams[2] != 'default') {
                     $aParams[2] = KTPluginUtil::getFullPath($aParams[2]);
                 }
                 call_user_func_array(array(&$oi18nRegistry, 'registeri18nLang'), $aParams);
             case 'i18n':
                 if (isset($aParams[2])) {
                     $aParams[1] = $aParams[2];
                     unset($aParams[2]);
                 } else {
                     $aParams[1] = KTPluginUtil::getFullPath($aParams[1]);
                 }
                 call_user_func_array(array(&$oi18nRegistry, 'registeri18n'), $aParams);
                 break;
             case 'language':
                 call_user_func_array(array(&$oi18nRegistry, 'registerLanguage'), $aParams);
                 break;
             case 'help_language':
                 if (isset($aParams[2])) {
                     $aParams[2] = KTPluginUtil::getFullPath($aParams[2]);
                 }
                 call_user_func_array(array(&$oKTHelpRegistry, 'registerHelp'), $aParams);
                 break;
             case 'workflow_trigger':
                 if (isset($aParams[2])) {
                     $aParams[2] = KTPluginUtil::getFullPath($aParams[2]);
                 }
                 call_user_func_array(array(&$oWFTriggerRegistry, 'registerWorkflowTrigger'), $aParams);
                 break;
             case 'column':
                 if (isset($aParams[3])) {
                     $aParams[3] = KTPluginUtil::getFullPath($aParams[3]);
                 }
                 $aParams[0] = _kt($aParams[0]);
                 call_user_func_array(array(&$oColumnRegistry, 'registerColumn'), $aParams);
                 break;
             case 'view':
                 $aParams[0] = _kt($aParams[0]);
                 call_user_func_array(array(&$oColumnRegistry, 'registerView'), $aParams);
                 break;
             case 'notification_handler':
                 if (isset($aParams[2])) {
                     $aParams[2] = KTPluginUtil::getFullPath($aParams[2]);
                 }
                 call_user_func_array(array(&$oNotificationHandlerRegistry, 'registerNotificationHandler'), $aParams);
                 break;
             case 'template_location':
                 if (isset($aParams[1])) {
                     $aParams[1] = KTPluginUtil::getFullPath($aParams[1]);
                 }
                 call_user_func_array(array(&$oTemplating, 'addLocation2'), $aParams);
                 break;
             case 'criterion':
                 $aInit = unserialize($aParams[3]);
                 if ($aInit != false) {
                     $aParams[3] = $aInit;
                 }
                 if (isset($aParams[2])) {
                     $aParams[2] = KTPluginUtil::getFullPath($aParams[2]);
                 }
                 call_user_func_array(array(&$oCriteriaRegistry, 'registerCriterion'), $aParams);
                 break;
             case 'widget':
                 if (isset($aParams[2])) {
                     $aParams[2] = KTPluginUtil::getFullPath($aParams[2]);
                 }
                 call_user_func_array(array(&$oWidgetFactory, 'registerWidget'), $aParams);
                 break;
             case 'validator':
                 if (isset($aParams[2])) {
                     $aParams[2] = KTPluginUtil::getFullPath($aParams[2]);
                 }
                 call_user_func_array(array(&$oValidatorFactory, 'registerValidator'), $aParams);
                 break;
             case 'interceptor':
                 if (isset($aParams[2])) {
                     $aParams[2] = KTPluginUtil::getFullPath($aParams[2]);
                 }
                 call_user_func_array(array(&$oInterceptorRegistry, 'registerInterceptor'), $aParams);
                 break;
             case 'plugin':
                 if (isset($aParams[2])) {
                     $aParams[2] = KTPluginUtil::getFullPath($aParams[2]);
                 }
                 $oKTPluginRegistry->_aPluginDetails[$sName] = $aParams;
                 break;
         }
     }
 }
示例#6
0
 function form_collectinfo()
 {
     $cancelUrl = $this->getReturnUrl();
     $oForm = new KTForm();
     $oForm->setOptions(array('identifier' => 'ktcore.actions.bulk.copy.form', 'label' => _kt('Copy Items'), 'submit_label' => _kt('Copy'), 'action' => 'performaction', 'fail_action' => 'collectinfo', 'cancel_url' => $cancelUrl, 'context' => $this));
     // Setup the collection for move display.
     require_once KT_LIB_DIR . '/browse/DocumentCollection.inc.php';
     $collection = new AdvancedCollection();
     $oCR =& KTColumnRegistry::getSingleton();
     $col = $oCR->getColumn('ktcore.columns.title');
     //$col->setOptions(array('qs_params'=>array('fMoveCode'=>$sMoveCode,
     //                                          'fFolderId'=>$oFolder->getId(),
     //                                          'action'=>'startMove')));
     $collection->addColumn($col);
     $qObj = new FolderBrowseQuery($this->oFolder->iId);
     $exclude = array();
     foreach ($this->oEntityList->aFolderIds as $folderid) {
         $exclude[] = $folderid + 0;
     }
     $qObj->exclude_folders = $exclude;
     $collection->setQueryObject($qObj);
     $aOptions = $collection->getEnvironOptions();
     $aOptions['result_url'] = KTUtil::addQueryString($_SERVER['PHP_SELF'], array('fFolderId' => $this->oFolder->iId, 'action' => 'collectinfo'));
     $collection->setOptions($aOptions);
     $oWF =& KTWidgetFactory::getSingleton();
     $oWidget = $oWF->get('ktcore.widgets.collection', 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' => 'fFolderId', 'broken_name' => true, 'folder_id' => $this->oFolder->iId, 'collection' => $collection));
     $oForm->addInitializedWidget($oWidget);
     // 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('name' => 'reason', 'label' => _kt('Reason'), 'description' => _kt('The reason for copying these documents and folders, for historical purposes.'), 'value' => null, 'required' => true)));
     $oForm->setValidators(array(array('ktcore.validators.string', array('test' => 'reason', 'output' => 'reason'))));
     if ($default->enableESignatures) {
         $oForm->addValidator(array('electonic.signatures.validators.authenticate', array('object_id' => $this->oFolder->getID(), 'type' => 'bulk', 'action' => 'ktcore.transactions.bulk_copy', 'test' => 'info', 'output' => 'info')));
     }
     return $oForm;
 }
示例#7
0
 function setWidgets($aWidgets)
 {
     $this->_widgets = array();
     if (is_null($this->_oWF)) {
         $this->_oWF =& KTWidgetFactory::getSingleton();
     }
     $this->addWidgets($aWidgets);
 }
 function widgetsForFieldset($fieldsetOrType, $sContainerName, $oDocument = null)
 {
     // this is likely to be called repeatedly.
     if (is_null($this->oWF)) {
         $this->oWF =& KTWidgetFactory::getSingleton();
     }
     // we're going to create one of two things, here:
     //   - conditional fieldset widget
     //   - a "Fieldset" widget
     // FIXME delegate.
     $oFieldset =& $fieldsetOrType;
     $widgets = array();
     $fields = $oFieldset->getFields();
     if ($oFieldset->getIsConditional()) {
         $iMasterId = $oFieldset->getMasterFieldId();
         $oMasterField = DocumentField::get($iMasterId);
         $newfields = array();
         $newfields[] = $oMasterField;
         foreach ($fields as $oField) {
             if ($oField->getId() != $iMasterId) {
                 $newfields[] = $oField;
             }
         }
         foreach ($newfields as $oField) {
             $fname = 'metadata_' . $oField->getId();
             $value = null;
             if (!is_null($oDocument)) {
                 $oFL = DocumentFieldLink::getByDocumentAndField($oDocument, $oField);
                 if (!is_null($oFL) && !PEAR::isError($oFL)) {
                     $value = $oFL->getValue();
                 }
             }
             $widgets[] = $this->oWF->get('ktcore.widgets.conditionalselection', array('label' => $oField->getName(), 'required' => $oField->getIsMandatory(), 'name' => $fname, 'value' => $value, 'description' => $oField->getDescription(), 'vocab' => MetaData::getEnabledByDocumentField($oField), 'id_method' => 'getName', 'label_method' => 'getName', 'unselected_label' => _kt("No selection."), 'simple_select' => false, 'master' => $oField->getId() == $iMasterId, 'masterid' => $iMasterId, 'fieldset' => $oFieldset->getId(), 'field' => $oField->getId()));
         }
     } else {
         foreach ($fields as $oField) {
             $fname = 'metadata_' . $oField->getId();
             $value = null;
             // check if we had an old value
             if (!is_null($oDocument)) {
                 $oFL = DocumentFieldLink::getByDocumentAndField($oDocument, $oField);
                 if (!is_null($oFL) && !PEAR::isError($oFL)) {
                     $value = $oFL->getValue();
                 }
             }
             // we have to hack in support for the hardcoded types of fields
             // handled by the "generic" widget.
             //
             // we try to make this a little more "sane"
             $type = '';
             if ($oField->getHasLookup()) {
                 if ($oField->getHasLookupTree()) {
                     $type = 'ktcore.fields.tree';
                 } else {
                     $type = 'ktcore.fields.lookup';
                 }
             } else {
                 $type = 'ktcore.fields.string';
             }
             if ($type == 'ktcore.fields.string') {
                 $widgets[] = $this->oWF->get('ktcore.widgets.string', array('label' => $oField->getName(), 'required' => $oField->getIsMandatory(), 'name' => $fname, 'value' => $value, 'description' => $oField->getDescription()));
             } else {
                 if ($type == 'ktcore.fields.lookup') {
                     $widgets[] = $this->oWF->get('ktcore.widgets.entityselection', array('label' => $oField->getName(), 'required' => $oField->getIsMandatory(), 'name' => $fname, 'value' => $value, 'description' => $oField->getDescription(), 'vocab' => MetaData::getEnabledByDocumentField($oField), 'id_method' => 'getName', 'label_method' => 'getName', 'unselected_label' => _kt("No selection."), 'simple_select' => false));
                 } else {
                     if ($type == 'ktcore.fields.tree') {
                         $widgets[] = $this->oWF->get('ktcore.widgets.treemetadata', array('label' => $oField->getName(), 'required' => $oField->getIsMandatory(), 'name' => $fname, 'value' => $value, 'description' => $oField->getDescription(), 'vocab' => MetaData::getEnabledByDocumentField($oField), 'field_id' => $oField->getId()));
                     }
                 }
             }
         }
     }
     return array($this->oWF->get('ktcore.widgets.fieldset', array('label' => $oFieldset->getName(), 'description' => $oFieldset->getDescription(), 'name' => $sContainerName, 'widgets' => $widgets)));
 }
示例#9
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;
 }