mirror of
https://git.code.sf.net/p/seeddms/code
synced 2025-02-06 07:04:57 +00:00
Merge branch 'seeddms-5.1.x' into seeddms-6.0.x
This commit is contained in:
commit
77a59e008b
|
@ -60,6 +60,11 @@ class SeedDMS_Controller_AddDocument extends SeedDMS_Controller_Common {
|
|||
if($attrdef = $dms->getAttributeDefinition($attrdefid)) {
|
||||
if(null === ($ret = $this->callHook('validateAttribute', $attrdef, $attribute))) {
|
||||
if($attribute) {
|
||||
switch($attrdef->getType()) {
|
||||
case SeedDMS_Core_AttributeDefinition::type_date:
|
||||
$attribute = date('Y-m-d', makeTsFromDate($attribute));
|
||||
break;
|
||||
}
|
||||
if(!$attrdef->validate($attribute)) {
|
||||
$this->errormsg = getAttributeValidationError($attrdef->getValidationError(), $attrdef->getName(), $attribute);
|
||||
return false;
|
||||
|
@ -79,6 +84,11 @@ class SeedDMS_Controller_AddDocument extends SeedDMS_Controller_Common {
|
|||
if($attrdef = $dms->getAttributeDefinition($attrdefid)) {
|
||||
if(null === ($ret = $this->callHook('validateAttribute', $attrdef, $attribute))) {
|
||||
if($attribute) {
|
||||
switch($attrdef->getType()) {
|
||||
case SeedDMS_Core_AttributeDefinition::type_date:
|
||||
$attribute = date('Y-m-d', makeTsFromDate($attribute));
|
||||
break;
|
||||
}
|
||||
if(!$attrdef->validate($attribute)) {
|
||||
$this->errormsg = getAttributeValidationError($attrdef->getValidationError(), $attrdef->getName(), $attribute);
|
||||
return false;
|
||||
|
|
|
@ -120,6 +120,11 @@ class SeedDMS_Controller_EditDocument extends SeedDMS_Controller_Common {
|
|||
if($attrdef = $dms->getAttributeDefinition($attrdefid)) {
|
||||
if(null === ($ret = $this->callHook('validateAttribute', $attrdef, $attribute))) {
|
||||
if($attribute) {
|
||||
switch($attrdef->getType()) {
|
||||
case SeedDMS_Core_AttributeDefinition::type_date:
|
||||
$attribute = date('Y-m-d', makeTsFromDate($attribute));
|
||||
break;
|
||||
}
|
||||
if(!$attrdef->validate($attribute, $document, true)) {
|
||||
$this->errormsg = getAttributeValidationError($attrdef->getValidationError(), $attrdef->getName(), $attribute);
|
||||
return false;
|
||||
|
|
|
@ -26,9 +26,26 @@ function formatted_size($size_bytes) { /* {{{ */
|
|||
return number_format($size_bytes,0,"","")." Bytes";
|
||||
} /* }}} */
|
||||
|
||||
function getReadableDate($timestamp) { /* {{{ */
|
||||
/* Date picker needs a different syntax for date formats using
|
||||
* yyyy for %Y
|
||||
* yy for %y
|
||||
* mm for %m
|
||||
* dd for %d
|
||||
* This functions returns the converted format
|
||||
*/
|
||||
function getConvertDateFormat() {
|
||||
global $settings;
|
||||
if(!is_numeric($timestamp))
|
||||
if($settings->_dateformat) {
|
||||
return str_replace(['y', 'Y', 'm', 'M', 'F', 'd', 'l', 'D'], ['yy', 'yyyy', 'mm', 'M', 'MM', 'dd', 'DD', 'D'], $settings->_dateformat);
|
||||
} else
|
||||
return 'yyyy-mm-dd';
|
||||
}
|
||||
|
||||
function getReadableDate($timestamp=0) { /* {{{ */
|
||||
global $settings;
|
||||
if(!$timestamp)
|
||||
$timestamp = time();
|
||||
elseif(!is_numeric($timestamp))
|
||||
$timestamp = strtotime($timestamp);
|
||||
if($settings->_dateformat)
|
||||
return date($settings->_dateformat, $timestamp);
|
||||
|
@ -69,6 +86,16 @@ function getPeriodOfTime($timestamp) { /* {{{ */
|
|||
}
|
||||
} /* }}} */
|
||||
|
||||
/*
|
||||
* Converts a date string into a timestamp
|
||||
*
|
||||
* @param $date string date in format understood by strftime
|
||||
* @return integer/boolean unix timestamp or false in case of an error
|
||||
*/
|
||||
function makeTsFromDate($date) { /* {{{ */
|
||||
return strtotime($date);
|
||||
} /* }}} */
|
||||
|
||||
/*
|
||||
* Converts a date/time string into a timestamp
|
||||
*
|
||||
|
@ -76,6 +103,7 @@ function getPeriodOfTime($timestamp) { /* {{{ */
|
|||
* @return integer/boolean unix timestamp or false in case of an error
|
||||
*/
|
||||
function makeTsFromLongDate($date) { /* {{{ */
|
||||
return strtotime($date);
|
||||
$tmp = explode(' ', $date);
|
||||
if(count($tmp) != 2)
|
||||
return false;
|
||||
|
|
|
@ -136,10 +136,11 @@ if (!is_numeric($sequence)) {
|
|||
|
||||
switch($_POST["presetexpdate"]) {
|
||||
case "date":
|
||||
$tmp = explode('-', $_POST["expdate"]);
|
||||
if(count($tmp) != 3)
|
||||
UI::exitError(getMLText("folder_title", array("foldername" => $folder->getName())),getMLText("malformed_expiration_date"));
|
||||
$expires = mktime(0,0,0, $tmp[1], $tmp[2], $tmp[0]);
|
||||
$expires = makeTsFromDate($_POST["expdate"]);
|
||||
// $tmp = explode('-', $_POST["expdate"]);
|
||||
// if(count($tmp) != 3)
|
||||
// UI::exitError(getMLText("folder_title", array("foldername" => $folder->getName())),getMLText("malformed_expiration_date"));
|
||||
// $expires = mktime(0,0,0, $tmp[1], $tmp[2], $tmp[0]);
|
||||
break;
|
||||
case "1w":
|
||||
$tmp = explode('-', date('Y-m-d'));
|
||||
|
|
|
@ -49,14 +49,16 @@ if (!isset($_POST["name"]) || !isset($_POST["comment"]) ) {
|
|||
$name = $_POST["name"];
|
||||
$comment = $_POST["comment"];
|
||||
if(isset($_POST["from"])) {
|
||||
$tmp = explode('-', $_POST["from"]);
|
||||
$from = mktime(0,0,0, $tmp[1], $tmp[2], $tmp[0]);
|
||||
$from = makeTsFromDate($_POST["from"]);
|
||||
// $tmp = explode('-', $_POST["from"]);
|
||||
// $from = mktime(0,0,0, $tmp[1], $tmp[2], $tmp[0]);
|
||||
} else {
|
||||
$from = mktime(0,0,0, intval($_POST["frommonth"]), intval($_POST["fromday"]), intval($_POST["fromyear"]));
|
||||
}
|
||||
if(isset($_POST["to"])) {
|
||||
$tmp = explode('-', $_POST["to"]);
|
||||
$to = mktime(23,59,59, $tmp[1], $tmp[2], $tmp[0]);
|
||||
$to = makeTsFromDate($_POST["to"])+86400;
|
||||
// $tmp = explode('-', $_POST["to"]);
|
||||
// $to = mktime(23,59,59, $tmp[1], $tmp[2], $tmp[0]);
|
||||
} else {
|
||||
$to = mktime(23,59,59, intval($_POST["tomonth"]), intval($_POST["today"]), intval($_POST["toyear"]));
|
||||
}
|
||||
|
|
|
@ -71,6 +71,11 @@ if($attributes) {
|
|||
foreach($attributes as $attrdefid=>$attribute) {
|
||||
$attrdef = $dms->getAttributeDefinition($attrdefid);
|
||||
if($attribute) {
|
||||
switch($attrdef->getType()) {
|
||||
case SeedDMS_Core_AttributeDefinition::type_date:
|
||||
$attribute = date('Y-m-d', makeTsFromDate($attribute));
|
||||
break;
|
||||
}
|
||||
if(!$attrdef->validate($attribute, $version, true)) {
|
||||
$errmsg = getAttributeValidationText($attrdef->getValidationError(), $attrdef->getName(), $attribute);
|
||||
UI::exitError(getMLText("document_title", array("documentname" => $document->getName())), $errmsg);
|
||||
|
|
|
@ -79,8 +79,9 @@ else
|
|||
if(isset($_POST['presetexpdate'])) {
|
||||
switch($_POST["presetexpdate"]) {
|
||||
case "date":
|
||||
$tmp = explode('-', $_POST["expdate"]);
|
||||
$expires = mktime(0,0,0, $tmp[1], $tmp[2], $tmp[0]);
|
||||
$expires = makeTsFromDate($_POST["expdate"]);
|
||||
// $tmp = explode('-', $_POST["expdate"]);
|
||||
// $expires = mktime(0,0,0, $tmp[1], $tmp[2], $tmp[0]);
|
||||
break;
|
||||
case "1w":
|
||||
$tmp = explode('-', date('Y-m-d'));
|
||||
|
|
|
@ -61,15 +61,17 @@ else
|
|||
$comment = $_POST["comment"];
|
||||
|
||||
if(isset($_POST["from"])) {
|
||||
$from = explode('T', $_POST["from"]);
|
||||
$tmp = explode('-', $from[0]);
|
||||
$from = mktime(0,0,0, $tmp[1], $tmp[2], $tmp[0]);
|
||||
$from = makeTsFromDate($_POST["from"]);
|
||||
// $from = explode('T', $_POST["from"]);
|
||||
// $tmp = explode('-', $from[0]);
|
||||
// $from = mktime(0,0,0, $tmp[1], $tmp[2], $tmp[0]);
|
||||
} else {
|
||||
UI::exitError(getMLText("edit_event"),getMLText("error_occured"));
|
||||
}
|
||||
if(isset($_POST["to"])) {
|
||||
$tmp = explode('-', $_POST["to"]);
|
||||
$to = mktime(23,59,59, $tmp[1], $tmp[2], $tmp[0]);
|
||||
$to = makeTsFromDate($_POST["to"])+86400;
|
||||
// $tmp = explode('-', $_POST["to"]);
|
||||
// $to = mktime(23,59,59, $tmp[1], $tmp[2], $tmp[0]);
|
||||
} else {
|
||||
$to = $event['stop'] - $event['start'] + $from;;
|
||||
}
|
||||
|
|
|
@ -49,8 +49,9 @@ if (!isset($_POST["presetexpdate"]) || $_POST["presetexpdate"] == "") {
|
|||
|
||||
switch($_POST["presetexpdate"]) {
|
||||
case "date":
|
||||
$tmp = explode('-', $_POST["expdate"]);
|
||||
$expires = mktime(0,0,0, $tmp[1], $tmp[2], $tmp[0]);
|
||||
$expires = makeTsFromDate($_POST["expdate"]);
|
||||
// $tmp = explode('-', $_POST["expdate"]);
|
||||
// $expires = mktime(0,0,0, $tmp[1], $tmp[2], $tmp[0]);
|
||||
break;
|
||||
case "1w":
|
||||
$tmp = explode('-', date('Y-m-d'));
|
||||
|
@ -88,6 +89,11 @@ if(isset($GLOBALS['SEEDDMS_HOOKS']['setExpires'])) {
|
|||
|
||||
if (!$document->setExpires($expires)){
|
||||
UI::exitError(getMLText("document_title", array("documentname" => $document->getName())),getMLText("error_occured"));
|
||||
} else {
|
||||
if($expires)
|
||||
$session->setSplashMsg(array('type'=>'success', 'msg'=>getMLText('splash_expiration_date_set', array('date'=>getReadableDate($expires)))));
|
||||
else
|
||||
$session->setSplashMsg(array('type'=>'success', 'msg'=>getMLText('splash_expiration_date_cleared')));
|
||||
}
|
||||
|
||||
$document->verifyLastestContentExpriry();
|
||||
|
|
|
@ -141,8 +141,9 @@ else
|
|||
$oldexpires = $document->getExpires();
|
||||
switch($_POST["presetexpdate"]) {
|
||||
case "date":
|
||||
$tmp = explode('-', $_POST["expdate"]);
|
||||
$expires = mktime(0,0,0, $tmp[1], $tmp[2], $tmp[0]);
|
||||
$expires = makeTsFromDate($_POST["expdate"]);
|
||||
// $tmp = explode('-', $_POST["expdate"]);
|
||||
// $expires = mktime(0,0,0, $tmp[1], $tmp[2], $tmp[0]);
|
||||
break;
|
||||
case "1w":
|
||||
$tmp = explode('-', date('Y-m-d'));
|
||||
|
@ -328,6 +329,11 @@ default:
|
|||
foreach($attributes as $attrdefid=>$attribute) {
|
||||
$attrdef = $dms->getAttributeDefinition($attrdefid);
|
||||
if($attribute) {
|
||||
switch($attrdef->getType()) {
|
||||
case SeedDMS_Core_AttributeDefinition::type_date:
|
||||
$attribute = date('Y-m-d', makeTsFromDate($attribute));
|
||||
break;
|
||||
}
|
||||
if(!$attrdef->validate($attribute)) {
|
||||
$errmsg = getAttributeValidationText($attrdef->getValidationError(), $attrdef->getName(), $attribute);
|
||||
UI::exitError(getMLText("document_title", array("documentname" => $document->getName())), $errmsg);
|
||||
|
|
|
@ -63,7 +63,7 @@ $(document).ready( function() {
|
|||
|
||||
$('body').on('touchstart.dropdown', '.dropdown-menu', function (e) { e.stopPropagation(); });
|
||||
|
||||
$('.datepicker, #expirationdate, #fromdate, #todate, #createstartdate, #createenddate, #expirationstartdate, #expirationenddate, #revisionstartdate')
|
||||
$('.datepicker, #expirationdate, #createstartdate, #createenddate, #expirationstartdate, #expirationenddate, #revisionstartdate')
|
||||
.datepicker({todayHighlight: true, toggleActive: true})
|
||||
.on('changeDate', function(ev){
|
||||
if(ev.date && $(ev.target).data('selectmenu')) {
|
||||
|
|
|
@ -300,7 +300,7 @@ $(document).ready(function() {
|
|||
);
|
||||
$this->formField(
|
||||
getMLText("expires"),
|
||||
$this->getDateChooser(($expts ? date('Y-m-d', $expts) : ''), "expdate", $this->params['session']->getLanguage())
|
||||
$this->getDateChooser(($expts ? getReadableDate($expts) : ''), "expdate", $this->params['session']->getLanguage())
|
||||
);
|
||||
}
|
||||
if($accessop->check_controller_access('AddDocument', array('action'=>'setOwner'))) {
|
||||
|
|
|
@ -80,7 +80,7 @@ $(document).ready(function() {
|
|||
$this->contentHeading(getMLText("add_event"));
|
||||
$this->contentContainerStart();
|
||||
|
||||
$expdate = date('Y-m-d');
|
||||
$expdate = getReadableDate();
|
||||
?>
|
||||
|
||||
<form class="form-horizontal" action="../op/op.AddEvent.php" id="form1" name="form1" method="post">
|
||||
|
|
|
@ -1377,11 +1377,13 @@ $(document).ready(function() {
|
|||
echo self::getFileChooserHtml($varname, $multiple, $accept);
|
||||
} /* }}} */
|
||||
|
||||
function printDateChooser($defDate = '', $varName, $lang='', $dateformat='yyyy-mm-dd', $startdate='', $enddate='') { /* {{{ */
|
||||
function printDateChooser($defDate = '', $varName, $lang='', $dateformat='', $startdate='', $enddate='') { /* {{{ */
|
||||
echo self::getDateChooser($defDate, $varName, $lang, $dateformat, $startdate, $enddate);
|
||||
} /* }}} */
|
||||
|
||||
function getDateChooser($defDate = '', $varName, $lang='', $dateformat='yyyy-mm-dd', $startdate='', $enddate='') { /* {{{ */
|
||||
function getDateChooser($defDate = '', $varName, $lang='', $dateformat='', $startdate='', $enddate='') { /* {{{ */
|
||||
if(!$dateformat)
|
||||
$dateformat = getConvertDateFormat();
|
||||
$content = '
|
||||
<span class="input-append date span12 datepicker" id="'.$varName.'date" data-date="'.$defDate.'" data-selectmenu="presetexpdate" data-date-format="'.$dateformat.'"'.($lang ? ' data-date-language="'.str_replace('_', '-', $lang).'"' : '').($startdate ? ' data-date-start-date="'.$startdate.'"' : '').($enddate ? ' data-date-end-date="'.$enddate.'"' : '').'>
|
||||
<input class="span6" size="16" name="'.$varName.'" id="'.$varName.'" type="text" value="'.$defDate.'" autocomplete="off">
|
||||
|
@ -1746,7 +1748,9 @@ $(document).ready(function() {
|
|||
break;
|
||||
case SeedDMS_Core_AttributeDefinition::type_date:
|
||||
$objvalue = $attribute ? (is_object($attribute) ? $attribute->getValue() : $attribute) : '';
|
||||
$content .= '<span class="input-append date datepicker" data-date="'.date('Y-m-d').'" data-date-format="yyyy-mm-dd" data-date-language="'.str_replace('_', '-', $this->params['session']->getLanguage()).'">
|
||||
if(!$dateformat)
|
||||
$dateformat = getConvertDateFormat();
|
||||
$content .= '<span class="input-append date datepicker" data-date="'.getReadableDate().'" data-date-format="'.$dateformat.'" data-date-language="'.str_replace('_', '-', $this->params['session']->getLanguage()).'">
|
||||
<input id="'.$fieldname.'_'.$attrdef->getId().'" class="span9" size="16" name="'.$fieldname.'['.$attrdef->getId().']" type="text" value="'.($objvalue ? $objvalue : '').'">
|
||||
<span class="add-on"><i class="fa fa-calendar"></i></span>
|
||||
</span>';
|
||||
|
|
|
@ -74,11 +74,11 @@ class SeedDMS_View_Calendar extends SeedDMS_Bootstrap_Style {
|
|||
<?php
|
||||
$this->formField(
|
||||
getMLText("from"),
|
||||
$this->getDateChooser(date('Y-m-d', $event["start"]), "from")
|
||||
$this->getDateChooser(getReadableDate($event["start"]), "from")
|
||||
);
|
||||
$this->formField(
|
||||
getMLText("to"),
|
||||
$this->getDateChooser(date('Y-m-d', $event["stop"]), "to")
|
||||
$this->getDateChooser(getReadableDate($event["stop"]-86400), "to")
|
||||
);
|
||||
$this->formField(
|
||||
getMLText("name"),
|
||||
|
|
|
@ -85,7 +85,7 @@ $(document).ready( function() {
|
|||
$this->contentContainerStart();
|
||||
|
||||
if($document->expires())
|
||||
$expdate = date('Y-m-d', $document->getExpires());
|
||||
$expdate = getReadableDate($document->getExpires());
|
||||
else
|
||||
$expdate = '';
|
||||
?>
|
||||
|
|
|
@ -59,7 +59,7 @@ $(document).ready( function() {
|
|||
$this->contentContainerStart();
|
||||
|
||||
if($document->expires())
|
||||
$expdate = date('Y-m-d', $document->getExpires());
|
||||
$expdate = getReadableDate($document->getExpires());
|
||||
else
|
||||
$expdate = '';
|
||||
?>
|
||||
|
|
|
@ -239,28 +239,13 @@ div.timeline-event-selected {
|
|||
?>
|
||||
<form action="../out/out.Timeline.php" class="form form-inline" name="form1" id="form1">
|
||||
<?php
|
||||
/*
|
||||
$html = '
|
||||
<span class="input-append date" style="display: inline;" id="fromdate" data-date="'.date('Y-m-d', $from).'" data-date-format="yyyy-mm-dd" data-date-language="'.str_replace('_', '-', $this->params['session']->getLanguage()).'">
|
||||
<input type="text" class="input-small" name="fromdate" value="'.date('Y-m-d', $from).'"/>
|
||||
<span class="add-on"><i class="fa fa-calendar"></i></span>
|
||||
</span> -
|
||||
<span class="input-append date" style="display: inline;" id="todate" data-date="'.date('Y-m-d', $to).'" data-date-format="yyyy-mm-dd" data-date-language="'.str_replace('_', '-', $this->params['session']->getLanguage()).'">
|
||||
<input type="text" class="input-small" name="todate" value="'.date('Y-m-d', $to).'"/>
|
||||
<span class="add-on"><i class="fa fa-calendar"></i></span>
|
||||
</span>';
|
||||
$this->formField(
|
||||
getMLText("date"),
|
||||
$html
|
||||
);
|
||||
*/
|
||||
$this->formField(
|
||||
getMLText("from"),
|
||||
$this->getDateChooser(date('Y-m-d', $from), 'fromdate', $this->params['session']->getLanguage())
|
||||
$this->getDateChooser(getReadableDate($from), 'fromdate', $this->params['session']->getLanguage())
|
||||
);
|
||||
$this->formField(
|
||||
getMLText("to"),
|
||||
$this->getDateChooser(date('Y-m-d', $to), 'todate', $this->params['session']->getLanguage())
|
||||
$this->getDateChooser(getReadableDate($to), 'todate', $this->params['session']->getLanguage())
|
||||
);
|
||||
$html = '
|
||||
<input type="checkbox" name="skip[]" value="add_file" '.(($skip && in_array('add_file', $skip)) ? 'checked' : '').'> '.getMLText('timeline_skip_add_file').'<br />
|
||||
|
|
|
@ -282,7 +282,7 @@ console.log(element);
|
|||
);
|
||||
$this->formField(
|
||||
getMLText("expires"),
|
||||
$this->getDateChooser(($expts ? date('Y-m-d', $expts) : ''), "expdate", $this->params['session']->getLanguage())
|
||||
$this->getDateChooser(($expts ? getReadableDate($expts) : ''), "expdate", $this->params['session']->getLanguage())
|
||||
);
|
||||
}
|
||||
$attrdefs = $dms->getAllAttributeDefinitions(array(SeedDMS_Core_AttributeDefinition::objtype_documentcontent, SeedDMS_Core_AttributeDefinition::objtype_all));
|
||||
|
|
Loading…
Reference in New Issue
Block a user