use new methods getModalBoxLink() and getModalBox(), remove printCategoryChooser()

This commit is contained in:
Uwe Steinmann 2020-10-22 17:19:47 +02:00
parent 196ea676be
commit 80453c7e2e

View File

@ -1133,7 +1133,7 @@ background-image: linear-gradient(to bottom, #882222, #111111);;
';
if($config['buttons']) {
foreach($config['buttons'] as $button)
$content .= '<button class="btn" '.(!empty($button['id']) ? 'id="'.$button['id'].'"': '').'data-dismiss="modal" aria-hidden="true">'.$button['title'].'</button>';
$content .= '<button class="btn'.(!empty($button['id']) ? ' btn-primary" id="'.$button['id'].'"': '" ').'data-dismiss="modal" aria-hidden="true">'.$button['title'].'</button>';
}
$content .= '
</div>
@ -1282,23 +1282,22 @@ $(document).ready(function() {
$content .= "<input type=\"text\" id=\"choosedocsearch".$formid."\" data-target=\"".$formid."\" data-provide=\"typeahead\" name=\"docname".$formid."\"value=\"" . (($default) ? htmlspecialchars($default->getName()) : "") ."\" placeholder=\"".getMLText('type_to_search')."\" autocomplete=\"off\" />";
$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 .= $this->getModalBoxLink(
array(
'target' => 'docChooser'.$formid,
'remote' => "../out/out.DocumentChooser.php?form=".$formid."&folderid=".$this->params['rootfolderid'],
'title' => getMLText('document')
));
$content .= "</div>\n";
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>
</div>
<div class="modal-body">
<p>'.getMLText('tree_loading').'</p>
</div>
<div class="modal-footer">
<button class="btn" data-dismiss="modal" aria-hidden="true">'.getMLText("close").'</button>
</div>
</div>
';
$content .= $this->getModalBox(
array(
'id' => 'docChooser'.$formid,
'title' => getMLText('choose_target_document'),
'buttons' => array(
array('title'=>getMLText('close'))
)
));
return $content;
} /* }}} */
@ -1347,24 +1346,23 @@ function folderSelected<?php echo $formid ?>(id, name) {
$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 .= $this->getModalBoxLink(
array(
'target' => 'folderChooser'.$formid,
'remote' => "../out/out.FolderChooser.php?form=".$formid."&mode=".$accessMode."&exclude=".$exclude,
'title' => getMLText('folder')
));
}
$content .= "</div>\n";
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'.$formid.'Label">'.getMLText("choose_target_folder").'</h3>
</div>
<div class="modal-body">
<p>'.getMLText('tree_loading').'</p>
</div>
<div class="modal-footer">
<button class="btn" data-dismiss="modal" aria-hidden="true">'.getMLText("close").'</button>
</div>
</div>
';
$content .= $this->getModalBox(
array(
'id' => 'folderChooser'.$formid,
'title' => getMLText('choose_target_folder'),
'buttons' => array(
array('title'=>getMLText('close'))
)
));
}
return $content;
} /* }}} */
@ -1410,61 +1408,6 @@ $(document).ready(function() {
<?php
} /* }}} */
/**
* Do not use anymore. Was previously used to show the category
* chooser. It has been replaced by a select box
*/
function printCategoryChooser($formName, $categories=array()) { /* {{{ */
?>
<script language="JavaScript">
function clearCategory<?php print $formName ?>() {
document.<?php echo $formName ?>.categoryid<?php echo $formName ?>.value = '';
document.<?php echo $formName ?>.categoryname<?php echo $formName ?>.value = '';
}
function acceptCategories() {
var targetName = document.<?php echo $formName?>.categoryname<?php print $formName ?>;
var targetID = document.<?php echo $formName?>.categoryid<?php print $formName ?>;
var value = '';
$('#keywordta option:selected').each(function(){
value += ' ' + $(this).text();
});
targetName.value = value;
targetID.value = $('#keywordta').val();
return true;
}
</script>
<?php
$ids = $names = array();
if($categories) {
foreach($categories as $cat) {
$ids[] = $cat->getId();
$names[] = htmlspecialchars($cat->getName());
}
}
print "<input type=\"hidden\" name=\"categoryid".$formName."\" value=\"".implode(',', $ids)."\">";
print "<div class=\"input-append\">\n";
print "<input type=\"text\" disabled name=\"categoryname".$formName."\" value=\"".implode(' ', $names)."\">";
print "<button type=\"button\" class=\"btn\" onclick=\"javascript:clearCategory".$formName."();\"><i class=\"fa fa-remove\"></i></button>";
print "<a data-target=\"#categoryChooser\" href=\"../out/out.CategoryChooser.php?form=form1&cats=".implode(',', $ids)."\" role=\"button\" class=\"btn\" data-toggle=\"modal\">".getMLText("category")."…</a>\n";
print "</div>\n";
?>
<div class="modal hide" id="categoryChooser" tabindex="-1" role="dialog" aria-labelledby="categoryChooserLabel" aria-hidden="true">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
<h3 id="categoryChooserLabel"><?php printMLText("choose_target_category") ?></h3>
</div>
<div class="modal-body">
<p><?php printMLText('categories_loading') ?></p>
</div>
<div class="modal-footer">
<button class="btn" data-dismiss="modal" aria-hidden="true"><?php printMLText("close") ?></button>
<button class="btn btn-primary" data-dismiss="modal" aria-hidden="true" onClick="acceptCategories();"><i class="fa fa-save"></i> <?php printMLText("save") ?></button>
</div>
</div>
<?php
} /* }}} */
function printKeywordChooserHtml($formName, $keywords='', $fieldname='keywords') { /* {{{ */
echo self::getKeywordChooserHtml($formName, $keywords, $fieldname);
} /* }}} */
@ -1474,22 +1417,25 @@ $(document).ready(function() {
$content = '';
$content .= '
<div class="input-append">
<input type="text" name="'.$fieldname.'" id="'.$fieldname.'" value="'.htmlspecialchars($keywords).'"'.($strictformcheck ? ' required' : '').' />
<a data-target="#keywordChooser" role="button" class="btn" data-toggle="modal" href="../out/out.KeywordChooser.php?target='.$formName.'">'.getMLText("keywords").'</a>
</div>
<div class="modal hide" id="keywordChooser" tabindex="-1" role="dialog" aria-labelledby="keywordChooserLabel" aria-hidden="true">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
<h3 id="keywordChooserLabel">'.getMLText("use_default_keywords").'</h3>
</div>
<div class="modal-body">
<p>'.getMLText('keywords_loading').'</p>
</div>
<div class="modal-footer">
<button class="btn" data-dismiss="modal" aria-hidden="true">'. getMLText("close").'</button>
<button class="btn btn-primary" data-dismiss="modal" aria-hidden="true" id="acceptkeywords"><i class="fa fa-save"></i> '.getMLText("save").'</button>
</div>
</div>';
<input type="text" name="'.$fieldname.'" id="'.$fieldname.'" value="'.htmlspecialchars($keywords).'"'.($strictformcheck ? ' required' : '').' />';
$content .= $this->getModalBoxLink(
array(
'target' => 'keywordChooser',
'remote' => "../out/out.KeywordChooser.php?target=".$formName,
'title' => getMLText('keywords')
));
$content .= '
</div>
';
$content .= $this->getModalBox(
array(
'id' => 'keywordChooser',
'title' => getMLText('use_default_keywords'),
'buttons' => array(
array('id'=>'acceptkeywords', 'title'=>getMLText('save')),
array('title'=>getMLText('close')),
)
));
return $content;
} /* }}} */
@ -1714,22 +1660,21 @@ $(document).ready(function() {
$content = "<div class=\"input-append\">\n";
$content .= "<input readonly type=\"text\" id=\"dropfolderfile".$formName."\" name=\"dropfolderfile".$formName."\" value=\"".$dropfolderfile."\">";
$content .= "<button type=\"button\" class=\"btn\" id=\"clearfilename".$formName."\"><i class=\"fa fa-remove\"></i></button>";
$content .= "<a data-target=\"#dropfolderChooser\" href=\"../out/out.DropFolderChooser.php?form=".$formName."&dropfolderfile=".urlencode($dropfolderfile)."&showfolders=".$showfolders."\" role=\"button\" class=\"btn\" data-toggle=\"modal\">".($showfolders ? getMLText("choose_target_folder"): getMLText("choose_target_file"))."…</a>\n";
$content .= $this->getModalBoxLink(
array(
'target' => 'dropfolderChooser',
'remote' => "../out/out.DropFolderChooser.php?form=".$formName."&dropfolderfile=".urlencode($dropfolderfile)."&showfolders=".$showfolders,
'title' => ($showfolders ? getMLText("choose_target_folder"): getMLText("choose_target_file"))
));
$content .= "</div>\n";
$content .= '
<div class="modal hide" id="dropfolderChooser" tabindex="-1" role="dialog" aria-labelledby="dropfolderChooserLabel" aria-hidden="true">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
<h3 id="dropfolderChooserLabel">'.($showfolders ? getMLText("choose_target_folder"): getMLText("choose_target_file")).'</h3>
</div>
<div class="modal-body">
<p>'.getMLText('files_loading').'</p>
</div>
<div class="modal-footer">
<button class="btn" data-dismiss="modal" aria-hidden="true">'.getMLText("close").'</button>
</div>
</div>
';
$content .= $this->getModalBox(
array(
'id' => 'dropfolderChooser',
'title' => ($showfolders ? getMLText("choose_target_folder"): getMLText("choose_target_file")),
'buttons' => array(
array('title'=>getMLText('close')),
)
));
return $content;
} /* }}} */