Merge branch 'seeddms-4.3.x' into seeddms-5.0.x

This commit is contained in:
Uwe Steinmann 2016-10-25 10:01:00 +02:00
commit bf9e2fa0da
3 changed files with 109 additions and 8 deletions

View File

@ -922,7 +922,7 @@ class Settings { /* {{{ */
function searchConfigFilePath() { /* {{{ */
$configFilePath = null;
if($configDir = $this->getConfigDir()) {
if($configDir = Settings::getConfigDir()) {
if (file_exists($configDir."/settings.xml"))
return $configDir."/settings.xml";
}
@ -938,7 +938,7 @@ class Settings { /* {{{ */
* If none was found a final try will be made checking /etc/seeddms
* @return NULL|string config directory
*/
function getConfigDir() { /* {{{ */
static function getConfigDir() { /* {{{ */
$_tmp = dirname($_SERVER['SCRIPT_FILENAME']);
$_arr = preg_split('/\//', rtrim(str_replace('\\', '/', $_tmp)));
$configDir = null;

View File

@ -1129,13 +1129,13 @@ $('#acceptkeywords').click(function(ev) {
switch($attrdef->getType()) {
case SeedDMS_Core_AttributeDefinition::type_boolean:
echo "<input type=\"hidden\" name=\"".$fieldname."[".$attrdef->getId()."]\" value=\"0\" />";
echo "<input type=\"checkbox\" name=\"".$fieldname."[".$attrdef->getId()."]\" value=\"1\" ".(($attribute && $attribute->getValue()) ? 'checked' : '')." />";
echo "<input type=\"checkbox\" id=\"".$fieldname."_".$attrdef->getId()."\" name=\"".$fieldname."[".$attrdef->getId()."]\" value=\"1\" ".(($attribute && $attribute->getValue()) ? 'checked' : '')." />";
break;
case SeedDMS_Core_AttributeDefinition::type_date:
$objvalue = $attribute ? (is_object($attribute) ? $attribute->getValue() : $attribute) : '';
?>
<span class="input-append date datepicker" style="_display: inline;" data-date="<?php echo date('Y-m-d'); ?>" data-date-format="yyyy-mm-dd" data-date-language="<?php echo str_replace('_', '-', $this->params['session']->getLanguage()); ?>">
<input class="span4" size="16" name="<?php echo $fieldname ?>[<?php echo $attrdef->getId() ?>]" type="text" value="<?php if($objvalue) echo $objvalue; else echo "" /*date('Y-m-d')*/; ?>">
<input id="<?php echo $fieldname."_".$attrdef->getId();?>" class="span4" size="16" name="<?php echo $fieldname ?>[<?php echo $attrdef->getId() ?>]" type="text" value="<?php if($objvalue) echo $objvalue; else echo "" /*date('Y-m-d')*/; ?>">
<span class="add-on"><i class="icon-calendar"></i></span>
</span>
<?php
@ -1147,7 +1147,7 @@ $('#acceptkeywords').click(function(ev) {
default:
if($valueset = $attrdef->getValueSetAsArray()) {
echo "<input type=\"hidden\" name=\"".$fieldname."[".$attrdef->getId()."]\" value=\"\" />";
echo "<select name=\"".$fieldname."[".$attrdef->getId()."]";
echo "<select id=\"".$fieldname."_".$attrdef->getId()."\" name=\"".$fieldname."[".$attrdef->getId()."]";
if($attrdef->getMultipleValues()) {
echo "[]\" multiple";
} else {
@ -1172,9 +1172,9 @@ $('#acceptkeywords').click(function(ev) {
} else {
$objvalue = $attribute ? (is_object($attribute) ? $attribute->getValue() : $attribute) : '';
if(strlen($objvalue) > 80) {
echo "<textarea name=\"".$fieldname."[".$attrdef->getId()."]\"".((!$norequire && $attrdef->getMinValues() > 0) ? ' required' : '').">".htmlspecialchars($objvalue)."</textarea>";
echo "<textarea id=\"".$fieldname."_".$attrdef->getId()."\" class=\"input-xxlarge\" name=\"".$fieldname."[".$attrdef->getId()."]\"".((!$norequire && $attrdef->getMinValues() > 0) ? ' required' : '').">".htmlspecialchars($objvalue)."</textarea>";
} else {
echo "<input type=\"text\" name=\"".$fieldname."[".$attrdef->getId()."]\" value=\"".htmlspecialchars($objvalue)."\"".((!$norequire && $attrdef->getMinValues() > 0) ? ' required' : '').($attrdef->getType() == SeedDMS_Core_AttributeDefinition::type_int ? ' data-rule-digits="true"' : '')." />";
echo "<input type=\"text\" id=\"".$fieldname."_".$attrdef->getId()."\" name=\"".$fieldname."[".$attrdef->getId()."]\" value=\"".htmlspecialchars($objvalue)."\"".((!$norequire && $attrdef->getMinValues() > 0) ? ' required' : '').($attrdef->getType() == SeedDMS_Core_AttributeDefinition::type_int ? ' data-rule-digits="true"' : '')." />";
}
}
break;
@ -1763,6 +1763,89 @@ $(document).ready( function() {
<?php
} /* }}} */
/**
* Output left-arrow with link which takes over a string into
* a input field.
*
* Clicking on the button will preset the string
* in data-ref the value of the input field with name $name
*
* @param string $name id of select box
* @param string $text text
*/
function printInputPresetButtonHtml($name, $text, $sep='') { /* {{{ */
?>
<span id="<?php echo $name; ?>_btn" class="inputpreset_btn" style="cursor: pointer;" title="<?php printMLText("takeOverAttributeValue"); ?>" data-ref="<?php echo $name; ?>" data-text="<?php echo is_array($text) ? implode($sep, $text) : htmlspecialchars($text);?>"<?php if($sep) echo "data-sep=\"".$sep."\""; ?>><i class="icon-arrow-left"></i></span>
<?php
} /* }}} */
/**
* Javascript code for input preset button
* This code workѕ for input fields and single select fields
*/
function printInputPresetButtonJs() { /* {{{ */
?>
$(document).ready( function() {
$('.inputpreset_btn').click(function(ev){
ev.preventDefault();
if (typeof $(ev.currentTarget).data('text') != 'undefined') {
target = $(ev.currentTarget).data('ref');
value = $(ev.currentTarget).data('text');
sep = $(ev.currentTarget).data('sep');
if(sep) {
// Use attr() instead of data() because data() converts to int which cannot be split
arr = value.split(sep);
for(var i in arr) {
$("#"+target+" option[value='"+arr[i]+"']").attr("selected", "selected");
}
} else {
$("#"+target).val(value);
}
}
});
});
<?php
} /* }}} */
/**
* Output left-arrow with link which takes over a boolean value
* into a checkbox field.
*
* Clicking on the button will preset the checkbox
* in data-ref the value of the input field with name $name
*
* @param string $name id of select box
* @param string $text text
*/
function printCheckboxPresetButtonHtml($name, $text) { /* {{{ */
?>
<span id="<?php echo $name; ?>_btn" class="checkboxpreset_btn" style="cursor: pointer;" title="<?php printMLText("takeOverAttributeValue"); ?>" data-ref="<?php echo $name; ?>" data-text="<?php echo is_array($text) ? implode($sep, $text) : htmlspecialchars($text);?>"<?php if($sep) echo "data-sep=\"".$sep."\""; ?>><i class="icon-arrow-left"></i></span>
<?php
} /* }}} */
/**
* Javascript code for checkboxt preset button
* This code workѕ for checkboxes
*/
function printCheckboxPresetButtonJs() { /* {{{ */
?>
$(document).ready( function() {
$('.checkboxpreset_btn').click(function(ev){
ev.preventDefault();
if (typeof $(ev.currentTarget).data('text') != 'undefined') {
target = $(ev.currentTarget).data('ref');
value = $(ev.currentTarget).data('text');
if(value) {
$("#"+target).attr('checked', '');
} else {
$("#"+target).removeAttribute('checked');
}
}
});
});
<?php
} /* }}} */
/**
* Return HTML of a single row in the document list table
*

View File

@ -37,6 +37,8 @@ class SeedDMS_View_UpdateDocument extends SeedDMS_Bootstrap_Style {
header('Content-Type: application/javascript');
$this->printDropFolderChooserJs("form1");
$this->printSelectPresetButtonJs();
$this->printInputPresetButtonJs();
$this->printCheckboxPresetButtonJs();
?>
function checkForm()
{
@ -241,7 +243,23 @@ console.log(element);
?>
<tr>
<td><?php echo htmlspecialchars($attrdef->getName()); ?>:</td>
<td><?php $this->printAttributeEditField($attrdef, '') ?></td>
<td><?php $this->printAttributeEditField($attrdef, '') ?>
<?php
if($latestContent->getAttributeValue($attrdef)) {
switch($attrdef->getType()) {
case SeedDMS_Core_AttributeDefinition::type_string:
case SeedDMS_Core_AttributeDefinition::type_date:
case SeedDMS_Core_AttributeDefinition::type_int:
case SeedDMS_Core_AttributeDefinition::type_float:
$this->printInputPresetButtonHtml('attributes_'.$attrdef->getID(), $latestContent->getAttributeValue($attrdef), $attrdef->getValueSetSeparator());
break;
case SeedDMS_Core_AttributeDefinition::type_boolean:
$this->printCheckboxPresetButtonHtml('attributes_'.$attrdef->getID(), $latestContent->getAttributeValue($attrdef));
break;
}
// print_r($latestContent->getAttributeValue($attrdef));
}
?></td>
</tr>
<?php
}