mirror of
				https://git.code.sf.net/p/seeddms/code
				synced 2025-10-31 13:18:06 +00:00 
			
		
		
		
	edit and show new attribute types, major overhaul of folder tree to make several trees on a page possible
This commit is contained in:
		
							parent
							
								
									4539c4a461
								
							
						
					
					
						commit
						d58100c678
					
				|  | @ -1186,15 +1186,22 @@ $(document).ready(function() { | |||
| 		return $content; | ||||
| 	} /* }}} */ | ||||
| 
 | ||||
| 	function getDocumentChooserHtml($formName) { /* {{{ */ | ||||
| 	function getDocumentChooserHtml($form, $default=false, $formname='', $skiptree=false) { /* {{{ */ | ||||
| 		if(!$formname) | ||||
| 			$formname = "docid"; | ||||
| 		$formid = md5($formname.$form); | ||||
| 
 | ||||
| 		$content = ''; | ||||
| 		$content .= "<input type=\"hidden\" id=\"docid".$formName."\" name=\"docid\" value=\"\">"; | ||||
| 		$content .= "<input type=\"hidden\" id=\"docid".$formid."\" name=\"".$formname."\" value=\"". (($default) ? $default->getID() : "") ."\">"; | ||||
| 		$content .= "<div class=\"input-append\">\n"; | ||||
| 		$content .= "<input type=\"text\" id=\"choosedocsearch".$formName."\" data-target=\"docid".$formName."\" data-provide=\"typeahead\" name=\"docname".$formName."\" placeholder=\"".getMLText('type_to_search')."\" autocomplete=\"off\" />"; | ||||
| 		$content .= "<a data-target=\"#docChooser".$formName."\" href=\"../out/out.DocumentChooser.php?form=".$formName."&folderid=".$this->params['rootfolderid']."\" role=\"button\" class=\"btn\" data-toggle=\"modal\">".getMLText("document")."…</a>\n"; | ||||
| 		$content .= "<input type=\"text\" id=\"choosedocsearch".$formid."\" data-target=\"".$formid."\" data-provide=\"typeahead\" name=\"docname".$formid."\" placeholder=\"".getMLText('type_to_search')."\" autocomplete=\"off\" value=\"" . (($default) ? htmlspecialchars($default->getName()) : "") ."\"/>"; | ||||
| 		$content .= "<button type=\"button\" class=\"btn\" id=\"cleardocument".$form."\" data-target=\"".$formid."\"><i class=\"fa fa-remove\"></i></button>"; | ||||
| 		if(!$skiptree) | ||||
| 			$content .= "<a data-target=\"#docChooser".$formid."\" href=\"../out/out.DocumentChooser.php?form=".$formid."&folderid=".$this->params['rootfolderid']."\" role=\"button\" class=\"btn\" data-toggle=\"modal\">".getMLText("document")."…</a>\n"; | ||||
| 		$content .= "</div>\n"; | ||||
| 		$content .= ' | ||||
| <div class="modal hide" id="docChooser'.$formName.'" tabindex="-1" role="dialog" aria-labelledby="docChooserLabel" aria-hidden="true"> | ||||
| 		if(!$skiptree) | ||||
| 			$content .= ' | ||||
| <div class="modal hide" id="docChooser'.$formid.'" tabindex="-1" role="dialog" aria-labelledby="docChooserLabel" aria-hidden="true"> | ||||
|   <div class="modal-header"> | ||||
|     <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button> | ||||
|     <h3 id="docChooserLabel">'.getMLText("choose_target_document").'</h3> | ||||
|  | @ -1214,45 +1221,56 @@ $(document).ready(function() { | |||
| 		echo self::getDocumentChooserHtml($formName); | ||||
| 	} /* }}} */ | ||||
| 
 | ||||
| 	function printDocumentChooserJs($formName) { /* {{{ */ | ||||
| 	/** | ||||
| 	 * This function is deprecated. Don't use it anymore. There is a generic | ||||
| 	 * folderSelected and documentSelected function in application.js | ||||
| 	 * If you extra functions to be called then define them in your own js code | ||||
| 	 */ | ||||
| 	function printDocumentChooserJs($form, $formname='') { /* {{{ */ | ||||
| 		if(!$formname) | ||||
| 			$formname = "docid"; | ||||
| 		$formid = md5($formname.$form); | ||||
| ?>
 | ||||
| function documentSelected<?php echo $formName ?>(id, name) {
 | ||||
| 	$('#docid<?php echo $formName ?>').val(id); | ||||
| 	$('#choosedocsearch<?php echo $formName ?>').val(name); | ||||
| 	$('#docChooser<?php echo $formName ?>').modal('hide'); | ||||
| function documentSelected<?php echo $formid ?>(id, name) {
 | ||||
| 	$('#docid<?php echo $formid ?>').val(id); | ||||
| 	$('#choosedocsearch<?php echo $formid ?>').val(name); | ||||
| 	$('#docChooser<?php echo $formid ?>').modal('hide'); | ||||
| } | ||||
| function folderSelected<?php echo $formName ?>(id, name) {
 | ||||
| function folderSelected<?php echo $formid ?>(id, name) {
 | ||||
| } | ||||
| <?php | ||||
| 	} /* }}} */ | ||||
| 
 | ||||
| 	function printDocumentChooser($formName) { /* {{{ */ | ||||
| 		$this->printDocumentChooserHtml($formName); | ||||
| 	function printDocumentChooser($form) { /* {{{ */ | ||||
| 		$this->printDocumentChooserHtml($form); | ||||
| ?>
 | ||||
| 		<script language="JavaScript"> | ||||
| <?php | ||||
| 		$this->printDocumentChooserJs($formName); | ||||
| 		$this->printDocumentChooserJs($form); | ||||
| ?>
 | ||||
| 		</script> | ||||
| <?php | ||||
| 	} /* }}} */ | ||||
| 
 | ||||
| 	function getFolderChooserHtml($form, $accessMode, $exclude = -1, $default = false, $formname = '') { /* {{{ */ | ||||
| 	function getFolderChooserHtml($form, $accessMode, $exclude = -1, $default = false, $formname = '', $skiptree = false) { /* {{{ */ | ||||
| 		if(!$formname) | ||||
| 			$formname = "targetid"; | ||||
| 		$formid = md5($formname.$form); | ||||
| 		$content = ''; | ||||
| 		$content .= "<input type=\"hidden\" id=\"".$formid."\" name=\"".$formname."\" value=\"". (($default) ? $default->getID() : "") ."\">"; | ||||
| 		$content .= "<input type=\"hidden\" id=\"targetid".$formid."\" name=\"".$formname."\" value=\"". (($default) ? $default->getID() : "") ."\">"; | ||||
| 		$content .= "<div class=\"input-append\">\n"; | ||||
| 		$content .= "<input type=\"text\" id=\"choosefoldersearch".$form."\" data-target=\"".$formid."\" data-provide=\"typeahead\"  name=\"targetname".$form."\" value=\"". (($default) ? htmlspecialchars($default->getName()) : "") ."\" placeholder=\"".getMLText('type_to_search')."\" autocomplete=\"off\" target=\"".$formid."\"/>"; | ||||
| 		$content .= "<button type=\"button\" class=\"btn\" id=\"clearfolder".$form."\"><i class=\"fa fa-remove\"></i></button>"; | ||||
| 		$content .= "<a data-target=\"#folderChooser".$form."\" href=\"../out/out.FolderChooser.php?form=".$form."&mode=".$accessMode."&exclude=".$exclude."\" role=\"button\" class=\"btn\" data-toggle=\"modal\">".getMLText("folder")."…</a>\n"; | ||||
| 		$content .= "<input type=\"text\" id=\"choosefoldersearch".$formid."\" data-target=\"".$formid."\" data-provide=\"typeahead\" name=\"targetname".$formid."\" value=\"". (($default) ? htmlspecialchars($default->getName()) : "") ."\" placeholder=\"".getMLText('type_to_search')."\" autocomplete=\"off\" target=\"".$formid."\"/>"; | ||||
| 		$content .= "<button type=\"button\" class=\"btn\" id=\"clearfolder".$formid."\" data-target=\"".$formid."\"><i class=\"fa fa-remove\"></i></button>"; | ||||
| 		if(!$skiptree) { | ||||
| 			$content .= "<a data-target=\"#folderChooser".$formid."\" href=\"../out/out.FolderChooser.php?form=".$formid."&mode=".$accessMode."&exclude=".$exclude."\" role=\"button\" class=\"btn\" data-toggle=\"modal\">".getMLText("folder")."…</a>\n"; | ||||
| 		} | ||||
| 		$content .= "</div>\n"; | ||||
| 		$content .= ' | ||||
| <div class="modal hide" id="folderChooser'.$form.'" tabindex="-1" role="dialog" aria-labelledby="folderChooser'.$form.'Label" aria-hidden="true"> | ||||
| 		if(!$skiptree) { | ||||
| 			$content .= ' | ||||
| <div class="modal hide" id="folderChooser'.$formid.'" tabindex="-1" role="dialog" aria-labelledby="folderChooser'.$formid.'Label" aria-hidden="true"> | ||||
|   <div class="modal-header"> | ||||
|     <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button> | ||||
|     <h3 id="folderChooser'.$form.'Label">'.getMLText("choose_target_folder").'</h3> | ||||
|     <h3 id="folderChooser'.$formid.'Label">'.getMLText("choose_target_folder").'</h3> | ||||
|   </div> | ||||
|   <div class="modal-body"> | ||||
| 		<p>'.getMLText('tree_loading').'</p> | ||||
|  | @ -1262,6 +1280,7 @@ function folderSelected<?php echo $formName ?>(id, name) { | |||
|   </div> | ||||
| </div> | ||||
| '; | ||||
| 		} | ||||
| 		return $content; | ||||
| 	} /* }}} */ | ||||
| 
 | ||||
|  | @ -1269,22 +1288,29 @@ function folderSelected<?php echo $formName ?>(id, name) { | |||
| 		echo self::getFolderChooserHtml($form, $accessMode, $exclude, $default, $formname); | ||||
| 	} /* }}} */ | ||||
| 
 | ||||
| 	/** | ||||
| 	 * This function is deprecated. Don't use it anymore. There is a generic | ||||
| 	 * folderSelected and documentSelected function in application.js | ||||
| 	 * If you extra functions to be called then define them in your own js code | ||||
| 	 */ | ||||
| 	function printFolderChooserJs($form, $formname='') { /* {{{ */ | ||||
| 		if(!$formname) | ||||
| 			$formname = "targetid"; | ||||
| 		$formid = md5($formname.$form); | ||||
| ?>
 | ||||
| function folderSelected<?php echo $form ?>(id, name) {
 | ||||
| 	$('#<?php echo $formid ?>').val(id); | ||||
| 	$('#choosefoldersearch<?php echo $form ?>').val(name); | ||||
| 	$('#folderChooser<?php echo $form ?>').modal('hide'); | ||||
| function folderSelected<?php echo $formid ?>(id, name) {
 | ||||
| 	$('#targetid<?php echo $formid ?>').val(id); | ||||
| 	$('#choosefoldersearch<?php echo $formid ?>').val(name); | ||||
| 	$('#folderChooser<?php echo $formid ?>').modal('hide'); | ||||
| } | ||||
| /* | ||||
| $(document).ready(function() { | ||||
| 	$('#clearfolder<?php print $form ?>').click(function(ev) { | ||||
| 		$('#choosefoldersearch<?php echo $form ?>').val(''); | ||||
| 		$('#<?php echo $formid ?>').val(''); | ||||
| 	$('#clearfolder<?php print $formid ?>').click(function(ev) { | ||||
| 		$('#choosefoldersearch<?php echo $formid ?>').val(''); | ||||
| 		$('#targetid<?php echo $formid ?>').val(''); | ||||
| 	}); | ||||
| }); | ||||
| */ | ||||
| <?php | ||||
| 	} /* }}} */ | ||||
| 
 | ||||
|  | @ -1403,11 +1429,77 @@ $(document).ready(function() { | |||
| <?php | ||||
| 	} /* }}} */ | ||||
| 
 | ||||
| 	function printAttributeValue($attribute) { /* {{{ */ | ||||
| 		echo self::getAttributeValue($attribute); | ||||
| 	} /* }}} */ | ||||
| 
 | ||||
| 	function getAttributeValue($attribute) { /* {{{ */ | ||||
| 		$dms = $this->params['dms']; | ||||
| 		$attrdef = $attribute->getAttributeDefinition(); | ||||
| 		switch($attrdef->getType()) { | ||||
| 		case SeedDMS_Core_AttributeDefinition::type_url: | ||||
| 			$attrs = $attribute->getValueAsArray(); | ||||
| 			$tmp = array(); | ||||
| 			foreach($attrs as $attr) { | ||||
| 				$tmp[] = '<a href="'.htmlspecialchars($attr).'">'.htmlspecialchars($attr).'</a>'; | ||||
| 			} | ||||
| 			return implode('<br />', $tmp); | ||||
| 			break; | ||||
| 		case SeedDMS_Core_AttributeDefinition::type_email: | ||||
| 			$attrs = $attribute->getValueAsArray(); | ||||
| 			$tmp = array(); | ||||
| 			foreach($attrs as $attr) { | ||||
| 				$tmp[] = '<a mailto="'.htmlspecialchars($attr).'">'.htmlspecialchars($attr).'</a>'; | ||||
| 			} | ||||
| 			return implode('<br />', $tmp); | ||||
| 			break; | ||||
| 		case SeedDMS_Core_AttributeDefinition::type_folder: | ||||
| 			$attrs = $attribute->getValueAsArray(); | ||||
| 			$tmp = array(); | ||||
| 			foreach($attrs as $attr) { | ||||
| 				if($targetfolder = $dms->getFolder(intval($attr))) | ||||
| 					$tmp[] = '<a href="../out/out.ViewFolder.php?folderid='.$targetfolder->getId().'">'.htmlspecialchars($targetfolder->getName()).'</a>'; | ||||
| 			} | ||||
| 			return implode('<br />', $tmp); | ||||
| 			break; | ||||
| 		case SeedDMS_Core_AttributeDefinition::type_document: | ||||
| 			$attrs = $attribute->getValueAsArray(); | ||||
| 			$tmp = array(); | ||||
| 			foreach($attrs as $attr) { | ||||
| 				if($targetdoc = $dms->getDocument(intval($attr))) | ||||
| 					$tmp[] = '<a href="../out/out.ViewDocument.php?documentid='.$targetdoc->getId().'">'.htmlspecialchars($targetdoc->getName()).'</a>'; | ||||
| 			} | ||||
| 			return implode('<br />', $tmp); | ||||
| 			break; | ||||
| 		case SeedDMS_Core_AttributeDefinition::type_user: | ||||
| 			$attrs = $attribute->getValueAsArray(); | ||||
| 			$tmp = array(); | ||||
| 			foreach($attrs as $attr) { | ||||
| 				$curuser = $dms->getUser((int) $attr); | ||||
| 				$tmp[] = $curuser->getFullname()." (".$curuser->getLogin().")"; | ||||
| 			} | ||||
| 			return implode('<br />', $tmp); | ||||
| 			break; | ||||
| 		case SeedDMS_Core_AttributeDefinition::type_group: | ||||
| 			$attrs = $attribute->getValueAsArray(); | ||||
| 			$tmp = array(); | ||||
| 			foreach($attrs as $attr) { | ||||
| 				$curgroup = $dms->getGroup((int) $attr); | ||||
| 				$tmp[] = $curgroup->getName(); | ||||
| 			} | ||||
| 			return implode('<br />', $tmp); | ||||
| 			break; | ||||
| 		default: | ||||
| 			return htmlspecialchars(implode(', ', $attribute->getValueAsArray())); | ||||
| 		} | ||||
| 	} /* }}} */ | ||||
| 
 | ||||
| 	function printAttributeEditField($attrdef, $attribute, $fieldname='attributes', $norequire=false) { /* {{{ */ | ||||
| 		echo self::getAttributeEditField($attrdef, $attribute, $fieldname, $norequire); | ||||
| 	} /* }}} */ | ||||
| 
 | ||||
| 	function getAttributeEditField($attrdef, $attribute, $fieldname='attributes', $norequire=false) { /* {{{ */ | ||||
| 		$dms = $this->params['dms']; | ||||
| 		$content = ''; | ||||
| 		switch($attrdef->getType()) { | ||||
| 		case SeedDMS_Core_AttributeDefinition::type_boolean: | ||||
|  | @ -1429,6 +1521,58 @@ $(document).ready(function() { | |||
| 			$objvalue = $attribute ? (is_object($attribute) ? $attribute->getValue() : $attribute) : ''; | ||||
| 			$content .= "<input type=\"text\" id=\"".$fieldname."_".$attrdef->getId()."\" name=\"".$fieldname."[".$attrdef->getId()."]\" value=\"".htmlspecialchars($objvalue)."\"".((!$norequire && $attrdef->getMinValues() > 0) ? ' required' : '')." data-rule-number=\"true\"/>"; | ||||
| 			break; | ||||
| 		case SeedDMS_Core_AttributeDefinition::type_folder: | ||||
| 			$objvalue = $attribute ? (is_object($attribute) ? (int) $attribute->getValue() : (int) $attribute) : 0; | ||||
| 			if($objvalue) | ||||
| 				$target = $dms->getFolder($objvalue); | ||||
| 			else | ||||
| 				$target = null; | ||||
| 			$content .= $this->getFolderChooserHtml("attr".$attrdef->getId(), M_READWRITE, -1, $target, $fieldname."[".$attrdef->getId()."]", false); | ||||
| 			break; | ||||
| 		case SeedDMS_Core_AttributeDefinition::type_document: | ||||
| 			$objvalue = $attribute ? (is_object($attribute) ? (int) $attribute->getValue() : (int) $attribute) : 0; | ||||
| 			if($objvalue) | ||||
| 				$target = $dms->getDocument($objvalue); | ||||
| 			else | ||||
| 				$target = null; | ||||
| 			$content .= $this->getDocumentChooserHtml("attr".$attrdef->getId(), $target, $fieldname."[".$attrdef->getId()."]"); | ||||
| 			break; | ||||
| 		case SeedDMS_Core_AttributeDefinition::type_user: | ||||
| 			$objvalue = $attribute ? (is_object($attribute) ? $attribute->getValueAsArray() : $attribute) : array(); | ||||
| 			$users = $dms->getAllUsers(); | ||||
| 			if($users) { | ||||
| 				$allowempty = $attrdef->getMinValues() == 0; | ||||
| 				$allowmultiple = $attrdef->getMultipleValues(); | ||||
| 				$content .= "<select class=\"chzn-select\"".($allowempty ? " data-allow-clear=\"true\"" : "")."\" name=\"".$fieldname."[".$attrdef->getId()."]".($allowmultiple ? '[]' : '')."\"".($allowmultiple ? " multiple" : "")." data-placeholder=\"".getMLText("select_user")."\">"; | ||||
| 				if($allowempty) | ||||
| 					$content .= "<option value=\"\"></option>"; | ||||
| 				foreach($users as $curuser) { | ||||
| 					$content .= "<option value=\"".$curuser->getID()."\""; | ||||
| 					if(in_array($curuser->getID(), $objvalue)) | ||||
| 						$content .= " selected"; | ||||
| 					$content .= ">".htmlspecialchars($curuser->getLogin()." - ".$curuser->getFullName())."</option>"; | ||||
| 				} | ||||
| 				$content .= "</select>"; | ||||
| 			} | ||||
| 			break; | ||||
| 		case SeedDMS_Core_AttributeDefinition::type_group: | ||||
| 			$objvalue = $attribute ? (is_object($attribute) ? $attribute->getValueAsArray() : $attribute) : array(); | ||||
| 			$groups = $dms->getAllGroups(); | ||||
| 			if($groups) { | ||||
| 				$allowempty = $attrdef->getMinValues() == 0; | ||||
| 				$allowmultiple = $attrdef->getMultipleValues(); | ||||
| 				$content .= "<select class=\"chzn-select\"".($allowempty ? " data-allow-clear=\"true\"" : "")."\" name=\"".$fieldname."[".$attrdef->getId()."]".($allowmultiple ? '[]' : '')."\"".($allowmultiple ? " multiple" : "")." data-placeholder=\"".getMLText("select_group")."\">"; | ||||
| 				if($allowempty) | ||||
| 					$content .= "<option value=\"\"></option>"; | ||||
| 				foreach($groups as $curgroup) { | ||||
| 					$content .= "<option value=\"".$curgroup->getID()."\""; | ||||
| 					if(in_array($curgroup->getID(), $objvalue)) | ||||
| 						$content .= " selected"; | ||||
| 					$content .= ">".htmlspecialchars($curgroup->getName())."</option>"; | ||||
| 				} | ||||
| 				$content .= "</select>"; | ||||
| 			} | ||||
| 			break; | ||||
| 		default: | ||||
| 			if($valueset = $attrdef->getValueSetAsArray()) { | ||||
| 				$content .= "<input type=\"hidden\" name=\"".$fieldname."[".$attrdef->getId()."]\" value=\"\"/>"; | ||||
|  | @ -1735,12 +1879,17 @@ $(function() { | |||
| 		saveState: 'jqtree<?php echo $formid; ?>', | ||||
| 		openedIcon: $('<i class="fa fa-minus-circle"></i>'), | ||||
| 		closedIcon: $('<i class="fa fa-plus-circle"></i>'), | ||||
| /* | ||||
| 		_onCanSelectNode: function(node) { | ||||
| 			if(node.is_folder) { | ||||
| 				folderSelected<?php echo $formid ?>(node.id, node.name);
 | ||||
| 			} else | ||||
| 				documentSelected<?php echo $formid ?>(node.id, node.name);
 | ||||
| 				folderSelected<?= $formid ?>(node.id, node.name);
 | ||||
| 				treeFolderSelected('<?= $formid ?>', node.id, node.name); | ||||
| 			} else { | ||||
| 				documentSelected<?= $formid ?>(node.id, node.name);
 | ||||
| 				treeDocumentSelected('<?= $formid ?>', node.id, node.name); | ||||
| 			} | ||||
| 		}, | ||||
| */ | ||||
| 		autoOpen: false, | ||||
| 		drapAndDrop: true, | ||||
|     onCreateLi: function(node, $li) { | ||||
|  | @ -1759,18 +1908,32 @@ $(function() { | |||
| 			var node = event.node; | ||||
| 			if(!node) | ||||
| 				return; | ||||
| 			$('#jqtree<?php echo $formid ?>').tree('openNode', node); | ||||
| //			event.preventDefault();
 | ||||
| 			if(node.is_folder) { | ||||
| <?php if($showdocs) { ?>
 | ||||
| 				$('#jqtree<?php echo $formid ?>').tree('openNode', node); | ||||
| //			event.preventDefault();
 | ||||
| 				if(typeof node.fetched == 'undefined') { | ||||
| 					node.fetched = true; | ||||
| 					$(this).tree('loadDataFromUrl', node, function () { | ||||
| 						$(this).tree('openNode', node); | ||||
| 					}); | ||||
| 				} | ||||
| 				folderSelected<?php echo $formid ?>(node.id, node.name);
 | ||||
| 			} else | ||||
| 				documentSelected<?php echo $formid ?>(node.id, node.name);
 | ||||
| <?php } ?>
 | ||||
| 				/* folderSelectedXXXX() can still be set, e.g. for the main tree | ||||
| 				 * to update the folder list. | ||||
| 				 */ | ||||
| 				if (typeof folderSelected<?= $formid ?> === 'function') { 
 | ||||
| 					folderSelected<?= $formid ?>(node.id, node.name);
 | ||||
| 				} | ||||
| 				treeFolderSelected('<?= $formid ?>', node.id, node.name); | ||||
| 			} else { | ||||
| <?php if($showdocs) { ?>
 | ||||
| 				if (typeof documentSelected<?= $formid ?> === 'function') { 
 | ||||
| 					documentSelected<?= $formid ?>(node.id, node.name);
 | ||||
| 				} | ||||
| 				treeDocumentSelected('<?= $formid ?>', node.id, node.name); | ||||
| <?php } ?>
 | ||||
| 			} | ||||
| 		} | ||||
| 	); | ||||
| 	$('#jqtree<?php echo $formid ?>').on( | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue
	
	Block a user
	 Uwe Steinmann
						Uwe Steinmann