2010-10-29 13:19:51 +00:00
|
|
|
|
<?php
|
|
|
|
|
// MyDMS. Document Management System
|
2013-02-28 13:54:37 +00:00
|
|
|
|
// Copyright (C) 2002-2005 Markus Westphal
|
2010-10-29 13:19:51 +00:00
|
|
|
|
// Copyright (C) 2006-2008 Malcolm Cowe
|
2013-02-28 13:54:37 +00:00
|
|
|
|
// Copyright (C) 2010-2013 Uwe Steinmann
|
2010-10-29 13:19:51 +00:00
|
|
|
|
//
|
|
|
|
|
// This program is free software; you can redistribute it and/or modify
|
|
|
|
|
// it under the terms of the GNU General Public License as published by
|
|
|
|
|
// the Free Software Foundation; either version 2 of the License, or
|
|
|
|
|
// (at your option) any later version.
|
|
|
|
|
//
|
|
|
|
|
// This program is distributed in the hope that it will be useful,
|
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
// GNU General Public License for more details.
|
|
|
|
|
//
|
|
|
|
|
// You should have received a copy of the GNU General Public License
|
|
|
|
|
// along with this program; if not, write to the Free Software
|
|
|
|
|
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
|
|
|
|
|
2013-05-24 15:31:22 +00:00
|
|
|
|
$LANG = array();
|
2014-04-08 08:41:19 +00:00
|
|
|
|
$MISSING_LANG = array();
|
2016-11-17 10:31:58 +00:00
|
|
|
|
$__languages = getLanguages();
|
|
|
|
|
if(!in_array($settings->_language, $__languages))
|
|
|
|
|
$__languages[] = $settings->_language;
|
|
|
|
|
foreach($__languages as $_lang) {
|
2013-02-28 13:54:37 +00:00
|
|
|
|
if(file_exists($settings->_rootDir . "languages/" . $_lang . "/lang.inc")) {
|
|
|
|
|
include $settings->_rootDir . "languages/" . $_lang . "/lang.inc";
|
|
|
|
|
$LANG[$_lang] = $text;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
unset($text);
|
|
|
|
|
|
2016-11-17 10:31:58 +00:00
|
|
|
|
function getAvailableLanguages() { /* {{{ */
|
|
|
|
|
global $settings;
|
|
|
|
|
|
2010-10-29 13:19:51 +00:00
|
|
|
|
$languages = array();
|
2016-11-17 10:31:58 +00:00
|
|
|
|
|
2010-10-29 13:19:51 +00:00
|
|
|
|
$path = $settings->_rootDir . "languages/";
|
|
|
|
|
$handle = opendir($path);
|
2016-11-17 10:31:58 +00:00
|
|
|
|
|
2010-10-29 13:19:51 +00:00
|
|
|
|
while ($entry = readdir($handle) )
|
|
|
|
|
{
|
|
|
|
|
if ($entry == ".." || $entry == ".")
|
|
|
|
|
continue;
|
|
|
|
|
else if (is_dir($path . $entry))
|
|
|
|
|
array_push($languages, $entry);
|
|
|
|
|
}
|
|
|
|
|
closedir($handle);
|
2013-01-24 08:02:58 +00:00
|
|
|
|
|
|
|
|
|
asort($languages);
|
2010-10-29 13:19:51 +00:00
|
|
|
|
return $languages;
|
2016-11-17 10:31:58 +00:00
|
|
|
|
} /* }}} */
|
|
|
|
|
|
|
|
|
|
function getLanguages() { /* {{{ */
|
|
|
|
|
global $settings;
|
|
|
|
|
|
|
|
|
|
if($settings->_availablelanguages) {
|
|
|
|
|
return $settings->_availablelanguages;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return getAvailableLanguages();
|
|
|
|
|
} /* }}} */
|
2010-10-29 13:19:51 +00:00
|
|
|
|
|
2013-02-28 13:54:37 +00:00
|
|
|
|
/**
|
|
|
|
|
* Get translation
|
|
|
|
|
*
|
|
|
|
|
* Returns the translation for a given key. It will replace markers
|
|
|
|
|
* in the form [xxx] with those elements from the array $replace.
|
|
|
|
|
* A default text can be gіven for the case, that there is no translation
|
|
|
|
|
* available. The fourth parameter can override the currently set language
|
|
|
|
|
* in the session or the default language from the configuration.
|
|
|
|
|
*
|
|
|
|
|
* @param string $key key of translation text
|
|
|
|
|
* @param array $replace list of values that replace markers in the text
|
|
|
|
|
* @param string $defaulttext text used if no translation can be found
|
|
|
|
|
* @param string $lang use this language instead of the currently set lang
|
|
|
|
|
*/
|
2018-02-07 18:01:28 +00:00
|
|
|
|
function getMLText($key, $replace = array(), $defaulttext = null, $lang="") { /* {{{ */
|
2014-04-08 08:41:19 +00:00
|
|
|
|
GLOBAL $settings, $LANG, $session, $MISSING_LANG;
|
2013-02-28 13:54:37 +00:00
|
|
|
|
|
2013-10-08 19:07:28 +00:00
|
|
|
|
$trantext = '';
|
|
|
|
|
if(0 && $settings->_otrance) {
|
|
|
|
|
$trantext = '<form style="display: inline-block;" accept-charset="UTF-8" action="http://translate.seeddms.org/connector/index" target="_blank" method="post"><input type="hidden" value="" name="oTranceKeys['.$key.']"><input type="submit" value="submit" class="btn btn-mini"/></form>';
|
|
|
|
|
}
|
|
|
|
|
|
2013-02-28 13:54:37 +00:00
|
|
|
|
if(!$lang) {
|
|
|
|
|
if($session)
|
|
|
|
|
$lang = $session->getLanguage();
|
|
|
|
|
else
|
|
|
|
|
$lang = $settings->_language;
|
|
|
|
|
}
|
|
|
|
|
|
2014-01-08 05:33:40 +00:00
|
|
|
|
if(!isset($LANG[$lang][$key]) || !$LANG[$lang][$key]) {
|
2018-02-07 18:01:28 +00:00
|
|
|
|
if ($defaulttext === null) {
|
2014-04-08 08:41:19 +00:00
|
|
|
|
$MISSING_LANG[$key] = $lang; //$_SERVER['SCRIPT_NAME'];
|
|
|
|
|
if(!empty($LANG[$settings->_language][$key])) {
|
2013-05-02 16:31:26 +00:00
|
|
|
|
$tmpText = $LANG[$settings->_language][$key];
|
2014-04-08 08:41:19 +00:00
|
|
|
|
} else {
|
|
|
|
|
$tmpText = '**'.$key.'**';
|
|
|
|
|
}
|
2013-03-27 08:45:06 +00:00
|
|
|
|
} else
|
2013-02-28 13:54:37 +00:00
|
|
|
|
$tmpText = $defaulttext;
|
|
|
|
|
} else
|
|
|
|
|
$tmpText = $LANG[$lang][$key];
|
|
|
|
|
|
2014-01-13 13:22:04 +00:00
|
|
|
|
if(0 && $settings->_otrance) {
|
2013-10-08 19:07:28 +00:00
|
|
|
|
$_GLOBALS['used_langs'][$key] = $tmpText;
|
|
|
|
|
}
|
|
|
|
|
|
2010-10-29 13:19:51 +00:00
|
|
|
|
if (count($replace) == 0)
|
2013-10-08 19:07:28 +00:00
|
|
|
|
return $tmpText.$trantext;
|
2010-10-29 13:19:51 +00:00
|
|
|
|
|
|
|
|
|
$keys = array_keys($replace);
|
|
|
|
|
foreach ($keys as $key)
|
|
|
|
|
$tmpText = str_replace("[".$key."]", $replace[$key], $tmpText);
|
2016-11-17 10:31:58 +00:00
|
|
|
|
|
2010-10-29 13:19:51 +00:00
|
|
|
|
return $tmpText;
|
2013-02-28 13:54:37 +00:00
|
|
|
|
} /* }}} */
|
2010-10-29 13:19:51 +00:00
|
|
|
|
|
2018-04-04 15:47:32 +00:00
|
|
|
|
function printMLText($key, $replace = array(), $defaulttext = null, $lang="") /* {{{ */
|
2010-10-29 13:19:51 +00:00
|
|
|
|
{
|
2013-02-28 13:54:37 +00:00
|
|
|
|
print getMLText($key, $replace, $defaulttext, $lang);
|
2010-10-29 13:19:51 +00:00
|
|
|
|
}
|
2013-02-28 13:54:37 +00:00
|
|
|
|
/* }}} */
|
2010-10-29 13:19:51 +00:00
|
|
|
|
|
2013-02-28 13:54:37 +00:00
|
|
|
|
function printReviewStatusText($status, $date=0) { /* {{{ */
|
2010-10-29 13:19:51 +00:00
|
|
|
|
if (is_null($status)) {
|
|
|
|
|
print getMLText("status_unknown");
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
switch ($status) {
|
|
|
|
|
case -2:
|
|
|
|
|
print getMLText("status_reviewer_removed");
|
|
|
|
|
break;
|
|
|
|
|
case -1:
|
|
|
|
|
print getMLText("status_reviewer_rejected").($date !=0 ? " ".$date : "");
|
|
|
|
|
break;
|
|
|
|
|
case 0:
|
|
|
|
|
print getMLText("status_not_reviewed");
|
|
|
|
|
break;
|
|
|
|
|
case 1:
|
|
|
|
|
print getMLText("status_reviewed").($date !=0 ? " ".$date : "");
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
print getMLText("status_unknown");
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
2013-02-28 13:54:37 +00:00
|
|
|
|
} /* }}} */
|
2010-10-29 13:19:51 +00:00
|
|
|
|
|
2013-02-28 13:54:37 +00:00
|
|
|
|
function getReviewStatusText($status, $date=0) { /* {{{ */
|
2010-10-29 13:19:51 +00:00
|
|
|
|
if (is_null($status)) {
|
|
|
|
|
return getMLText("status_unknown");
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
switch ($status) {
|
|
|
|
|
case -2:
|
|
|
|
|
return getMLText("status_reviewer_removed");
|
|
|
|
|
break;
|
|
|
|
|
case -1:
|
|
|
|
|
return getMLText("status_reviewer_rejected").($date !=0 ? " ".$date : "");
|
|
|
|
|
break;
|
|
|
|
|
case 0:
|
|
|
|
|
return getMLText("status_not_reviewed");
|
|
|
|
|
break;
|
|
|
|
|
case 1:
|
|
|
|
|
return getMLText("status_reviewed").($date !=0 ? " ".$date : "");
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
return getMLText("status_unknown");
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
2013-02-28 13:54:37 +00:00
|
|
|
|
} /* }}} */
|
2010-10-29 13:19:51 +00:00
|
|
|
|
|
2013-02-28 13:54:37 +00:00
|
|
|
|
function printApprovalStatusText($status, $date=0) { /* {{{ */
|
2010-10-29 13:19:51 +00:00
|
|
|
|
if (is_null($status)) {
|
|
|
|
|
print getMLText("status_unknown");
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
switch ($status) {
|
|
|
|
|
case -2:
|
|
|
|
|
print getMLText("status_approver_removed");
|
|
|
|
|
break;
|
|
|
|
|
case -1:
|
|
|
|
|
print getMLText("status_approval_rejected").($date !=0 ? " ".$date : "");
|
|
|
|
|
break;
|
|
|
|
|
case 0:
|
|
|
|
|
print getMLText("status_not_approved");
|
|
|
|
|
break;
|
|
|
|
|
case 1:
|
|
|
|
|
print getMLText("status_approved").($date !=0 ? " ".$date : "");
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
print getMLText("status_unknown");
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
2013-02-28 13:54:37 +00:00
|
|
|
|
} /* }}} */
|
2010-10-29 13:19:51 +00:00
|
|
|
|
|
2013-02-28 13:54:37 +00:00
|
|
|
|
function getApprovalStatusText($status, $date=0) { /* {{{ */
|
2010-10-29 13:19:51 +00:00
|
|
|
|
if (is_null($status)) {
|
|
|
|
|
return getMLText("status_unknown");
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
switch ($status) {
|
|
|
|
|
case -2:
|
|
|
|
|
return getMLText("status_approver_removed");
|
|
|
|
|
break;
|
|
|
|
|
case -1:
|
|
|
|
|
return getMLText("status_approval_rejected").($date !=0 ? " ".$date : "");
|
|
|
|
|
break;
|
|
|
|
|
case 0:
|
|
|
|
|
return getMLText("status_not_approved");
|
|
|
|
|
break;
|
|
|
|
|
case 1:
|
|
|
|
|
return getMLText("status_approved").($date !=0 ? " ".$date : "");
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
return getMLText("status_unknown");
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
2013-02-28 13:54:37 +00:00
|
|
|
|
} /* }}} */
|
2010-10-29 13:19:51 +00:00
|
|
|
|
|
2013-02-28 13:54:37 +00:00
|
|
|
|
function printOverallStatusText($status) { /* {{{ */
|
2013-01-24 08:02:58 +00:00
|
|
|
|
print getOverallStatusText($status);
|
2013-02-28 13:54:37 +00:00
|
|
|
|
} /* }}} */
|
2010-10-29 13:19:51 +00:00
|
|
|
|
|
2013-02-28 13:54:37 +00:00
|
|
|
|
function getOverallStatusText($status) { /* {{{ */
|
2010-10-29 13:19:51 +00:00
|
|
|
|
if (is_null($status)) {
|
|
|
|
|
return getMLText("assumed_released");
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
switch($status) {
|
2013-01-24 08:02:58 +00:00
|
|
|
|
case S_IN_WORKFLOW:
|
|
|
|
|
return getMLText("in_workflow");
|
|
|
|
|
break;
|
2010-10-29 13:19:51 +00:00
|
|
|
|
case S_DRAFT_REV:
|
|
|
|
|
return getMLText("draft_pending_review");
|
|
|
|
|
break;
|
|
|
|
|
case S_DRAFT_APP:
|
|
|
|
|
return getMLText("draft_pending_approval");
|
|
|
|
|
break;
|
|
|
|
|
case S_RELEASED:
|
|
|
|
|
return getMLText("released");
|
|
|
|
|
break;
|
|
|
|
|
case S_REJECTED:
|
|
|
|
|
return getMLText("rejected");
|
|
|
|
|
break;
|
|
|
|
|
case S_OBSOLETE:
|
|
|
|
|
return getMLText("obsolete");
|
|
|
|
|
break;
|
|
|
|
|
case S_EXPIRED:
|
|
|
|
|
return getMLText("expired");
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
return getMLText("status_unknown");
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
2013-02-28 13:54:37 +00:00
|
|
|
|
} /* }}} */
|
|
|
|
|
|
2023-01-26 19:55:42 +00:00
|
|
|
|
function getAttributeTypeText($attrdef) { /* {{{ */
|
|
|
|
|
switch($attrdef->getType()) {
|
|
|
|
|
case SeedDMS_Core_AttributeDefinition::type_int:
|
|
|
|
|
$t = getMLText("attrdef_type_int");
|
|
|
|
|
break;
|
|
|
|
|
case SeedDMS_Core_AttributeDefinition::type_float:
|
|
|
|
|
$t = getMLText("attrdef_type_float");
|
|
|
|
|
break;
|
|
|
|
|
case SeedDMS_Core_AttributeDefinition::type_string:
|
|
|
|
|
$t = getMLText("attrdef_type_string");
|
|
|
|
|
break;
|
|
|
|
|
case SeedDMS_Core_AttributeDefinition::type_boolean:
|
|
|
|
|
$t = getMLText("attrdef_type_boolean");
|
|
|
|
|
break;
|
|
|
|
|
case SeedDMS_Core_AttributeDefinition::type_date:
|
|
|
|
|
$t = getMLText("attrdef_type_date");
|
|
|
|
|
break;
|
|
|
|
|
case SeedDMS_Core_AttributeDefinition::type_email:
|
|
|
|
|
$t = getMLText("attrdef_type_email");
|
|
|
|
|
break;
|
|
|
|
|
case SeedDMS_Core_AttributeDefinition::type_url:
|
|
|
|
|
$t = getMLText("attrdef_type_url");
|
|
|
|
|
break;
|
|
|
|
|
case SeedDMS_Core_AttributeDefinition::type_boolean:
|
|
|
|
|
$t = getMLText("attrdef_type_boolean");
|
|
|
|
|
break;
|
|
|
|
|
case SeedDMS_Core_AttributeDefinition::type_folder:
|
|
|
|
|
$t = getMLText("attrdef_type_folder");
|
|
|
|
|
break;
|
|
|
|
|
case SeedDMS_Core_AttributeDefinition::type_document:
|
|
|
|
|
$t = getMLText("attrdef_type_document");
|
|
|
|
|
break;
|
|
|
|
|
case SeedDMS_Core_AttributeDefinition::type_user:
|
|
|
|
|
$t = getMLText("attrdef_type_user");
|
|
|
|
|
break;
|
|
|
|
|
case SeedDMS_Core_AttributeDefinition::type_group:
|
|
|
|
|
$t = getMLText("attrdef_type_group");
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
return $t;
|
|
|
|
|
} /* }}} */
|
|
|
|
|
|
|
|
|
|
function getAttributeObjectTypeText($attrdef) { /* {{{ */
|
|
|
|
|
switch($attrdef->getObjType()) {
|
|
|
|
|
case SeedDMS_Core_AttributeDefinition::objtype_all:
|
|
|
|
|
$ot = getMLText("all");
|
|
|
|
|
break;
|
|
|
|
|
case SeedDMS_Core_AttributeDefinition::objtype_folder:
|
|
|
|
|
$ot = getMLText("folder");
|
|
|
|
|
break;
|
|
|
|
|
case SeedDMS_Core_AttributeDefinition::objtype_document:
|
|
|
|
|
$ot = getMLText("document");
|
|
|
|
|
break;
|
|
|
|
|
case SeedDMS_Core_AttributeDefinition::objtype_documentcontent:
|
|
|
|
|
$ot = getMLText("documentcontent");
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
return $ot;
|
|
|
|
|
} /* }}} */
|
|
|
|
|
|
2017-07-21 14:54:17 +00:00
|
|
|
|
function getAttributeValidationText($error, $attrname='', $attrvalue='', $regex='') { /* {{{ */
|
2019-12-13 08:06:36 +00:00
|
|
|
|
$arr = getAttributeValidationError($error, $attrname, $attrvalue, $regex);
|
|
|
|
|
|
|
|
|
|
return getMLText($arr[0], $arr[1]);
|
|
|
|
|
} /* }}} */
|
|
|
|
|
|
|
|
|
|
function getAttributeValidationError($error, $attrname='', $attrvalue='', $regex='') { /* {{{ */
|
2016-10-27 07:18:45 +00:00
|
|
|
|
switch($error) {
|
|
|
|
|
case 10:
|
2019-12-13 08:06:36 +00:00
|
|
|
|
return array("attr_not_in_valueset", array('attrname'=>$attrname, 'value'=>$attrvalue));
|
2016-10-27 07:18:45 +00:00
|
|
|
|
break;
|
2021-05-15 05:37:21 +00:00
|
|
|
|
case 9:
|
2019-12-13 08:06:36 +00:00
|
|
|
|
return array("attr_malformed_date", array('attrname'=>$attrname, 'value'=>$attrvalue));
|
2016-10-27 07:18:45 +00:00
|
|
|
|
break;
|
|
|
|
|
case 8:
|
2019-12-13 08:06:36 +00:00
|
|
|
|
return array("attr_malformed_boolean", array('attrname'=>$attrname, 'value'=>$attrvalue));
|
2016-10-27 07:18:45 +00:00
|
|
|
|
break;
|
|
|
|
|
case 7:
|
2019-12-13 08:06:36 +00:00
|
|
|
|
return array("attr_malformed_float", array('attrname'=>$attrname, 'value'=>$attrvalue));
|
2016-10-27 07:18:45 +00:00
|
|
|
|
break;
|
|
|
|
|
case 6:
|
2019-12-13 08:06:36 +00:00
|
|
|
|
return array("attr_malformed_int", array('attrname'=>$attrname, 'value'=>$attrvalue));
|
2016-10-27 07:18:45 +00:00
|
|
|
|
break;
|
|
|
|
|
case 5:
|
2019-12-13 08:06:36 +00:00
|
|
|
|
return array("attr_malformed_email", array('attrname'=>$attrname, 'value'=>$attrvalue));
|
2016-10-27 07:18:45 +00:00
|
|
|
|
break;
|
|
|
|
|
case 4:
|
2019-12-13 08:06:36 +00:00
|
|
|
|
return array("attr_malformed_url", array('attrname'=>$attrname, 'value'=>$attrvalue));
|
2016-10-27 07:18:45 +00:00
|
|
|
|
break;
|
|
|
|
|
case 3:
|
2019-12-13 08:06:36 +00:00
|
|
|
|
return array("attr_no_regex_match", array('attrname'=>$attrname, 'value'=>$attrvalue, 'regex'=>$regex));
|
2016-10-27 07:18:45 +00:00
|
|
|
|
break;
|
|
|
|
|
case 2:
|
2019-12-13 08:06:36 +00:00
|
|
|
|
return array("attr_max_values", array('attrname'=>$attrname, 'value'=>$attrvalue));
|
2016-10-27 07:18:45 +00:00
|
|
|
|
break;
|
|
|
|
|
case 1:
|
2019-12-13 08:06:36 +00:00
|
|
|
|
return array("attr_min_values", array('attrname'=>$attrname, 'value'=>$attrvalue));
|
2016-10-27 07:18:45 +00:00
|
|
|
|
break;
|
|
|
|
|
default:
|
2019-12-13 08:06:36 +00:00
|
|
|
|
return array("attr_validation_error", array('attrname'=>$attrname, 'value'=>$attrvalue));
|
2016-10-27 07:18:45 +00:00
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
} /* }}} */
|
|
|
|
|
|