mirror of
https://git.code.sf.net/p/seeddms/code
synced 2025-03-12 08:55:54 +00:00
Merge branch 'seeddms-5.1.x' into seeddms-6.0.x
This commit is contained in:
commit
11301f1955
|
@ -33,9 +33,11 @@ function formatted_size($size_bytes) { /* {{{ */
|
||||||
* dd for %d
|
* dd for %d
|
||||||
* This functions returns the converted format
|
* This functions returns the converted format
|
||||||
*/
|
*/
|
||||||
function getConvertDateFormat() { /* {{{ */
|
function getConvertDateFormat($dateformat) { /* {{{ */
|
||||||
global $settings;
|
global $settings;
|
||||||
if($settings->_dateformat) {
|
if(!$dateformat)
|
||||||
|
$dateformat = $settings->_dateformat;
|
||||||
|
if($dateformat) {
|
||||||
return str_replace(['y', 'Y', 'm', 'M', 'F', 'd', 'l', 'D'], ['yy', 'yyyy', 'mm', 'M', 'MM', 'dd', 'DD', 'D'], $settings->_dateformat);
|
return str_replace(['y', 'Y', 'm', 'M', 'F', 'd', 'l', 'D'], ['yy', 'yyyy', 'mm', 'M', 'MM', 'dd', 'DD', 'D'], $settings->_dateformat);
|
||||||
} else
|
} else
|
||||||
return 'yyyy-mm-dd';
|
return 'yyyy-mm-dd';
|
||||||
|
@ -166,6 +168,79 @@ function getReadableDurationArray($secs) { /* {{{ */
|
||||||
return $units;
|
return $units;
|
||||||
} /* }}} */
|
} /* }}} */
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return the timestamp after a period of time
|
||||||
|
*
|
||||||
|
* The period is relative to $start. $r sets if the returned
|
||||||
|
* time stamp is the start, end or current seconds of day.
|
||||||
|
* getTsByPeriod('today', 's') returns 00:00:00 of today
|
||||||
|
* getTsByPeriod('tomorrow', 'e') returns 23:59:59 of tommorrow
|
||||||
|
* The parameter $start can be any timestamp from where the
|
||||||
|
* period starts
|
||||||
|
* getTsByPeriod('today', 's', time()+7*86400) is equivalent to
|
||||||
|
* getTsByPeriod('1w', 's')
|
||||||
|
*/
|
||||||
|
function getTsByPeriod($period, $r='', $start=0) { /* {{{ */
|
||||||
|
if(!$start)
|
||||||
|
$start = time();
|
||||||
|
$sofd = time() - strtotime('today'); // seconds elapsed today
|
||||||
|
switch($r) {
|
||||||
|
case 's': // start of day
|
||||||
|
$o = $sofd;
|
||||||
|
break;
|
||||||
|
case 'e': // end of day
|
||||||
|
$o = $sofd-86400+1;
|
||||||
|
break;
|
||||||
|
default: // same sec as current time
|
||||||
|
$o = 0;
|
||||||
|
}
|
||||||
|
switch($period) {
|
||||||
|
case "never":
|
||||||
|
$expiration = 0;
|
||||||
|
break;
|
||||||
|
case "1h":
|
||||||
|
$expiration = $start+3600;
|
||||||
|
break;
|
||||||
|
case "2h":
|
||||||
|
$expiration = $start+7200;
|
||||||
|
break;
|
||||||
|
case "24h":
|
||||||
|
$expiration = $start+86400;
|
||||||
|
break;
|
||||||
|
case "today":
|
||||||
|
$expiration = $start - $o;
|
||||||
|
break;
|
||||||
|
case "1d":
|
||||||
|
$expiration = $start-$o+86400;
|
||||||
|
break;
|
||||||
|
case "tomorrow":
|
||||||
|
$expiration = $start - $o + 86400;
|
||||||
|
break;
|
||||||
|
case "1w":
|
||||||
|
$expiration = $start-$o+7*86400;
|
||||||
|
break;
|
||||||
|
case "1m":
|
||||||
|
$tmp = explode('-', date('Y-m-d', $start));
|
||||||
|
$expiration = mktime(0,0,0, $tmp[1]+1, $tmp[2], $tmp[0])+$sofd-$o;
|
||||||
|
break;
|
||||||
|
case "1y":
|
||||||
|
$tmp = explode('-', date('Y-m-d', $start));
|
||||||
|
$expiration = mktime(0,0,0, $tmp[1], $tmp[2], $tmp[0]+1)+$sofd-$o;
|
||||||
|
break;
|
||||||
|
case "2y":
|
||||||
|
$tmp = explode('-', date('Y-m-d', $start));
|
||||||
|
$expiration = mktime(0,0,0, $tmp[1], $tmp[2], $tmp[0]+2)+$sofd-$o;
|
||||||
|
break;
|
||||||
|
case "3y":
|
||||||
|
$tmp = explode('-', date('Y-m-d', $start));
|
||||||
|
$expiration = mktime(0,0,0, $tmp[1], $tmp[2], $tmp[0]+3)+$sofd-$o;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
$expiration = false;
|
||||||
|
}
|
||||||
|
return $expiration;
|
||||||
|
} /* }}} */
|
||||||
|
|
||||||
/* Deprecated, do not use anymore, but keep it for upgrading
|
/* Deprecated, do not use anymore, but keep it for upgrading
|
||||||
* older versions
|
* older versions
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -53,36 +53,20 @@ if (!isset($_POST["presetexpdate"]) || $_POST["presetexpdate"] == "") {
|
||||||
UI::exitError(getMLText("document_title", array("documentname" => $document->getName())),getMLText("invalid_expiration_date"));
|
UI::exitError(getMLText("document_title", array("documentname" => $document->getName())),getMLText("invalid_expiration_date"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($_POST["presetexpdate"] == 'date' && $_POST["expdate"] == "") {
|
||||||
|
UI::exitError(getMLText("document_title", array("documentname" => $document->getName())),getMLText("invalid_expiration_date"));
|
||||||
|
}
|
||||||
|
|
||||||
switch($_POST["presetexpdate"]) {
|
switch($_POST["presetexpdate"]) {
|
||||||
case "date":
|
case "date":
|
||||||
$expires = makeTsFromDate($_POST["expdate"]);
|
$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'));
|
|
||||||
$expires = mktime(0,0,0, $tmp[1], $tmp[2]+7, $tmp[0]);
|
|
||||||
break;
|
|
||||||
case "1m":
|
|
||||||
$tmp = explode('-', date('Y-m-d'));
|
|
||||||
$expires = mktime(0,0,0, $tmp[1]+1, $tmp[2], $tmp[0]);
|
|
||||||
break;
|
|
||||||
case "1y":
|
|
||||||
$tmp = explode('-', date('Y-m-d'));
|
|
||||||
$expires = mktime(0,0,0, $tmp[1], $tmp[2], $tmp[0]+1);
|
|
||||||
break;
|
|
||||||
case "2y":
|
|
||||||
$tmp = explode('-', date('Y-m-d'));
|
|
||||||
$expires = mktime(0,0,0, $tmp[1], $tmp[2], $tmp[0]+2);
|
|
||||||
break;
|
|
||||||
case "3y":
|
|
||||||
$tmp = explode('-', date('Y-m-d'));
|
|
||||||
$expires = mktime(0,0,0, $tmp[1], $tmp[2], $tmp[0]+3);
|
|
||||||
break;
|
break;
|
||||||
case "never":
|
case "never":
|
||||||
default:
|
|
||||||
$expires = null;
|
$expires = null;
|
||||||
break;
|
break;
|
||||||
|
default:
|
||||||
|
$expires = getTsByPeriod($_POST["presetexpdate"], 's');
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(isset($GLOBALS['SEEDDMS_HOOKS']['setExpires'])) {
|
if(isset($GLOBALS['SEEDDMS_HOOKS']['setExpires'])) {
|
||||||
|
|
|
@ -1658,11 +1658,11 @@ $(document).ready(function() {
|
||||||
|
|
||||||
function getDateChooser($defDate, $varName, $lang='', $dateformat='', $startdate='', $enddate='', $weekstart=null, $placeholder='', $nogroup=false) { /* {{{ */
|
function getDateChooser($defDate, $varName, $lang='', $dateformat='', $startdate='', $enddate='', $weekstart=null, $placeholder='', $nogroup=false) { /* {{{ */
|
||||||
if(!$dateformat)
|
if(!$dateformat)
|
||||||
$dateformat = getConvertDateFormat();
|
$dateformat = getConvertDateFormat($this->params['settings']->_dateformat);
|
||||||
$content = '';
|
$content = '';
|
||||||
$content = '
|
$content = '
|
||||||
<span class="input-append date span4 datepicker" id="'.$varName.'date" '.($weekstart == null ? '' : 'data-date-week-start="'.intval($weekstart).'" ').'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.'"' : '').'>
|
<span class="input-append date span4 datepicker" id="'.$varName.'date" data-date-calendar-weeks="true" '.($weekstart == null ? '' : 'data-date-week-start="'.intval($weekstart).'" ').'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="span12" size="16" name="'.$varName.'" id="'.$varName.'" type="text" placeholder="'.htmlspecialchars($placeholder).'" value="'.$defDate.'" autocomplete="off">
|
<input class="span12" size="16" name="'.$varName.'" autocomplete="off" id="'.$varName.'" type="text" placeholder="'.htmlspecialchars($placeholder).'" value="'.$defDate.'" autocomplete="off">
|
||||||
';
|
';
|
||||||
if(!$nogroup)
|
if(!$nogroup)
|
||||||
$content .= '
|
$content .= '
|
||||||
|
|
|
@ -1036,7 +1036,7 @@ $(document).ready(function() {
|
||||||
default:
|
default:
|
||||||
$option = array($v, $v);
|
$option = array($v, $v);
|
||||||
}
|
}
|
||||||
if(isset($attributes[$facetname]) && in_array($v, $attributes[$facetname]))
|
if(isset($attributes[$facetname]) && is_array($attributes[$facetname]) && in_array($v, $attributes[$facetname]))
|
||||||
$option[] = true;
|
$option[] = true;
|
||||||
else
|
else
|
||||||
$option[] = false;
|
$option[] = false;
|
||||||
|
@ -1144,6 +1144,7 @@ $(document).ready(function() {
|
||||||
} else {
|
} else {
|
||||||
$oldvalue = [$allparams['attributes'][$facetname]];
|
$oldvalue = [$allparams['attributes'][$facetname]];
|
||||||
}
|
}
|
||||||
|
if($oldvalue) {
|
||||||
unset($allparams['attributes'][$facetname]);
|
unset($allparams['attributes'][$facetname]);
|
||||||
$newrequest = Symfony\Component\HttpFoundation\Request::create($request->getBaseUrl(), 'GET', $allparams);
|
$newrequest = Symfony\Component\HttpFoundation\Request::create($request->getBaseUrl(), 'GET', $allparams);
|
||||||
$menuitems[] = array('label'=>'<i class="fa fa-remove"></i> '.$dispname.' = '.implode(', ', $oldvalue), 'link'=>$newrequest->getRequestUri(), 'attributes'=>[['title', 'Click to remove']], '_badge'=>'x');
|
$menuitems[] = array('label'=>'<i class="fa fa-remove"></i> '.$dispname.' = '.implode(', ', $oldvalue), 'link'=>$newrequest->getRequestUri(), 'attributes'=>[['title', 'Click to remove']], '_badge'=>'x');
|
||||||
|
@ -1152,6 +1153,7 @@ $(document).ready(function() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
/* Create a link to remove the filter */
|
/* Create a link to remove the filter */
|
||||||
$allparams = $request->query->all();
|
$allparams = $request->query->all();
|
||||||
|
@ -1220,14 +1222,14 @@ $(document).ready(function() {
|
||||||
$allparams = $request->query->all();
|
$allparams = $request->query->all();
|
||||||
if(isset($allparams['attributes'])) {
|
if(isset($allparams['attributes'])) {
|
||||||
foreach($allparams['attributes'] as $an=>$av) {
|
foreach($allparams['attributes'] as $an=>$av) {
|
||||||
if(is_string($av) && $av == '__notset__') {
|
if(is_string($av) && ($av == '__notset__')) {
|
||||||
$tmp = explode('_', $an);
|
$tmp = explode('_', $an);
|
||||||
if($attrdef = $dms->getAttributeDefinition($tmp[1])) {
|
if($attrdef = $dms->getAttributeDefinition($tmp[1])) {
|
||||||
$dispname = $attrdef->getName();
|
$dispname = $attrdef->getName();
|
||||||
unset($allparams['attributes'][$an]);
|
unset($allparams['attributes'][$an]);
|
||||||
$newrequest = Symfony\Component\HttpFoundation\Request::create($request->getBaseUrl(), 'GET', $allparams);
|
$newrequest = Symfony\Component\HttpFoundation\Request::create($request->getBaseUrl(), 'GET', $allparams);
|
||||||
$menuitems[] = array('label'=>'<i class="fa fa-remove"></i> '.$dispname.' is not set', 'link'=>$newrequest->getRequestUri(), 'attributes'=>[['title', 'Click to remove']], '_badge'=>'x');
|
$menuitems[] = array('label'=>'<i class="fa fa-remove"></i> '.$dispname.' is not set', 'link'=>$newrequest->getRequestUri(), 'attributes'=>[['title', 'Click to remove']], '_badge'=>'x');
|
||||||
echo '<input type="hidden" name="attributes['.$an.']" value="__notset__" />';
|
echo '<input type="hidden" name="attributes['.$an.']" value="'.$av.'" />';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1294,6 +1296,7 @@ $(document).ready(function() {
|
||||||
if($values && (count($values) > 1 || reset($values) < $total)) {
|
if($values && (count($values) > 1 || reset($values) < $total)) {
|
||||||
$menuitems = array();
|
$menuitems = array();
|
||||||
$menuitems[] = array('label'=>getMLText('no_value_set'), 'link'=>$newrequest->getRequestUri().'&attributes['.$facetname.']=__notset__');
|
$menuitems[] = array('label'=>getMLText('no_value_set'), 'link'=>$newrequest->getRequestUri().'&attributes['.$facetname.']=__notset__');
|
||||||
|
$menuitems[] = array('label'=>getMLText('any_value_set'), 'link'=>$newrequest->getRequestUri().'&attributes['.$facetname.']=__any__');
|
||||||
arsort($values);
|
arsort($values);
|
||||||
foreach($values as $v=>$c) {
|
foreach($values as $v=>$c) {
|
||||||
switch($attrdef->getType()) {
|
switch($attrdef->getType()) {
|
||||||
|
|
|
@ -68,14 +68,16 @@ $(document).ready( function() {
|
||||||
<?php echo createHiddenFieldWithKey('setexpires'); ?>
|
<?php echo createHiddenFieldWithKey('setexpires'); ?>
|
||||||
<?php
|
<?php
|
||||||
$this->contentContainerStart();
|
$this->contentContainerStart();
|
||||||
|
$df = !empty($settings->_datetimeformat) ? $settings->_datetimeformat : 'Y-m-d H:i:s';
|
||||||
$options = array();
|
$options = array();
|
||||||
$options[] = array('never', getMLText('does_not_expire'));
|
$options[] = array('never', getMLText('does_not_expire'));
|
||||||
$options[] = array('date', getMLText('expire_by_date'), $expdate != '');
|
$options[] = array('date', getMLText('expire_by_date'), $expdate != '');
|
||||||
$options[] = array('1w', getMLText('expire_in_1w'));
|
$options[] = array('tomorrow', getMLText('expire_tomorrow').' ('.date($df, getTsByPeriod('tomorrow', 's')).')');
|
||||||
$options[] = array('1m', getMLText('expire_in_1m'));
|
$options[] = array('1w', getMLText('expire_in_1w').' ('.date($df, getTsByPeriod('1w', 's')).')');
|
||||||
$options[] = array('1y', getMLText('expire_in_1y'));
|
$options[] = array('1m', getMLText('expire_in_1m').' ('.date($df, getTsByPeriod('1m', 's')).')');
|
||||||
$options[] = array('2y', getMLText('expire_in_2y'));
|
$options[] = array('1y', getMLText('expire_in_1y').' ('.date($df, getTsByPeriod('1y', 's')).')');
|
||||||
$options[] = array('3y', getMLText('expire_in_3y'));
|
$options[] = array('2y', getMLText('expire_in_2y').' ('.date($df, getTsByPeriod('2y', 's')).')');
|
||||||
|
$options[] = array('3y', getMLText('expire_in_3y').' ('.date($df, getTsByPeriod('3y', 's')).')');
|
||||||
$this->formField(
|
$this->formField(
|
||||||
getMLText("preset_expires"),
|
getMLText("preset_expires"),
|
||||||
array(
|
array(
|
||||||
|
@ -83,11 +85,14 @@ $(document).ready( function() {
|
||||||
'id'=>'presetexpdate',
|
'id'=>'presetexpdate',
|
||||||
'name'=>'presetexpdate',
|
'name'=>'presetexpdate',
|
||||||
'options'=>$options
|
'options'=>$options
|
||||||
|
),
|
||||||
|
array(
|
||||||
|
'help'=>getMLText('set_expiration_date_help')
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
$this->formField(
|
$this->formField(
|
||||||
getMLText("expires"),
|
getMLText("expires"),
|
||||||
$this->getDateChooser($expdate, "expdate", $this->params['session']->getLanguage())
|
$this->getDateChooser($expdate, "expdate", $this->params['session']->getLanguage(), '', '+1d')
|
||||||
);
|
);
|
||||||
$this->contentContainerEnd();
|
$this->contentContainerEnd();
|
||||||
$this->formSubmit("<i class=\"fa fa-save\"></i> ".getMLText('save'));
|
$this->formSubmit("<i class=\"fa fa-save\"></i> ".getMLText('save'));
|
||||||
|
|
|
@ -1610,11 +1610,11 @@ $(document).ready(function() {
|
||||||
|
|
||||||
function getDateChooser($defDate, $varName, $lang='', $dateformat='', $startdate='', $enddate='', $weekstart=null, $placeholder='', $nogroup=false) { /* {{{ */
|
function getDateChooser($defDate, $varName, $lang='', $dateformat='', $startdate='', $enddate='', $weekstart=null, $placeholder='', $nogroup=false) { /* {{{ */
|
||||||
if(!$dateformat)
|
if(!$dateformat)
|
||||||
$dateformat = getConvertDateFormat();
|
$dateformat = getConvertDateFormat($this->params['settings']->_dateformat);
|
||||||
$content = '';
|
$content = '';
|
||||||
if(!$nogroup)
|
if(!$nogroup)
|
||||||
$content .= '<div class="input-group date" id="'.$varName.'date">';
|
$content .= '<div class="input-group date" id="'.$varName.'date">';
|
||||||
$content .= '<input type="text" class="form-control datepicker" placeholder="'.htmlspecialchars($placeholder).'" name="'.$varName.'" id="'.$varName.'" value="'.$defDate. '" '.($weekstart == null ? '' : 'data-date-week-start="'.intval($weekstart).'" ').'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.'"' : '').' data-date-autoclose="true" data-provide="datepicker">';
|
$content .= '<input type="text" class="form-control datepicker" autocomplete="off" placeholder="'.htmlspecialchars($placeholder).'" name="'.$varName.'" id="'.$varName.'" value="'.$defDate. '" data-date-calendar-weeks="true" '.($weekstart == null ? '' : 'data-date-week-start="'.intval($weekstart).'" ').'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.'"' : '').' data-date-autoclose="true" data-provide="datepicker">';
|
||||||
if(!$nogroup) {
|
if(!$nogroup) {
|
||||||
$content .= '<div class="input-group-append">
|
$content .= '<div class="input-group-append">
|
||||||
<span class="input-group-text"><i class="fa fa-calendar"></i></span>
|
<span class="input-group-text"><i class="fa fa-calendar"></i></span>
|
||||||
|
@ -3416,6 +3416,12 @@ $('body').on('click', '[id^=\"table-row-folder\"] td:nth-child(2)', function(ev)
|
||||||
* @return string starting tr tag for a table
|
* @return string starting tr tag for a table
|
||||||
*/
|
*/
|
||||||
function folderListRowStart($folder, $class='') { /* {{{ */
|
function folderListRowStart($folder, $class='') { /* {{{ */
|
||||||
|
if($class) {
|
||||||
|
if($class == 'error')
|
||||||
|
$class = 'table-danger';
|
||||||
|
else
|
||||||
|
$class = 'table-'.$class;
|
||||||
|
}
|
||||||
return "<tr id=\"table-row-folder-".$folder->getID()."\" draggable=\"true\" data-droptarget=\"folder_".$folder->getID()."\" rel=\"folder_".$folder->getID()."\" class=\"folder table-row-folder droptarget".($class ? ' '.$class : '')."\" data-uploadformtoken=\"".createFormKey('')."\" formtoken=\"".createFormKey('')."\" data-name=\"".htmlspecialchars($folder->getName(), ENT_QUOTES)."\">";
|
return "<tr id=\"table-row-folder-".$folder->getID()."\" draggable=\"true\" data-droptarget=\"folder_".$folder->getID()."\" rel=\"folder_".$folder->getID()."\" class=\"folder table-row-folder droptarget".($class ? ' '.$class : '')."\" data-uploadformtoken=\"".createFormKey('')."\" formtoken=\"".createFormKey('')."\" data-name=\"".htmlspecialchars($folder->getName(), ENT_QUOTES)."\">";
|
||||||
} /* }}} */
|
} /* }}} */
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user