Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue #340: fix statically called non-static methods in Html class. #341

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions resources/admin/classes/common/Html.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public function humanize($str) {

public function label_tag($for, $name = null, $required = false) {
if ($name === null) {
$name = Html::humanize($for);
$name = (new Html())->humanize($for);
}

if ($required) {
Expand All @@ -53,33 +53,33 @@ public function label_tag($for, $name = null, $required = false) {
}

public function hidden_field_tag($name, $value, $options = array()) {
$default_id = Html::nameToID($name);
$default_id = (new Html())->nameToID($name);
$default_options = array('id' => $default_id);
$options = array_merge($default_options, $options);

return '<input type="hidden" id="'.htmlspecialchars($options['id']).'" name="'.htmlspecialchars($name).'" value="'.htmlspecialchars($value). '" />';
}

public function hidden_search_field_tag($name, $value, $options = array()) {
return Html::hidden_field_tag("search[".$name."]", $value, $options);
return (new Html())->hidden_field_tag("search[".$name."]", $value, $options);
}

public function text_field_tag($name, $value, $options = array()) {
$default_id = Html::nameToID($name);
$default_id = (new Html())->nameToID($name);
$default_options = array('width' => '180px', 'id' => $default_id, 'class' => 'changeInput');
$options = array_merge($default_options, $options);

return '<input type="text" id="'.htmlspecialchars($options['id']).'" name="'.htmlspecialchars($name).'" style="width:'.$options['width'].'" class="'.htmlspecialchars($options['class']).'" value="'.htmlspecialchars($value). '" /><span id="span_error_'.htmlspecialchars($options['id']).'" class="smallDarkRedText"></span>';
}

public function text_field($field, $object, $options = array()) {
return Html::text_field_tag($field, $object->$field, $options);
return (new Html())->text_field_tag($field, $object->$field, $options);
}

public function text_search_field_tag($name, $value, $options = array()) {
$default_options = array('width' => '145px', 'class' => '');
$options = array_merge($default_options, $options);
return Html::text_field_tag("search[".$name."]", $value, $options);
return (new Html())->text_field_tag("search[".$name."]", $value, $options);
}


Expand Down
18 changes: 9 additions & 9 deletions resources/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
<form method="get" action="ajax_htmldata.php?action=getSearchResources" id="resourceSearchForm">
<?php
foreach(array('orderBy','page','recordsPerPage','startWith') as $hidden) {
echo Html::hidden_search_field_tag($hidden, isset($search[$hidden]) ? $search[$hidden] : '' );
echo (new Html())->hidden_search_field_tag($hidden, isset($search[$hidden]) ? $search[$hidden] : '' );
}
?>

Expand All @@ -64,7 +64,7 @@
<tr>
<td class='searchRow'><label for='searchName'><b><?php echo _("Name (contains)");?></b></label>
<br />
<?php echo Html::text_search_field_tag('name', isset($search['name']) ? $search['name'] : '' ); ?>
<?php echo (new Html())->text_search_field_tag('name', isset($search['name']) ? $search['name'] : '' ); ?>
<br />
<div id='div_searchName' style='<?php if (!isset($search['name'])) echo "display:none;"; ?>margin-left:123px;'><input type='button' name='btn_searchName' value='<?php echo _("go!");?>' class='searchButton' /></div>
</td>
Expand All @@ -74,7 +74,7 @@
<tr>
<td class='searchRow'>
<label for='searchPublisher'><b><?php echo _("Publisher (contains)"); ?></b></label>
<?php echo Html::text_search_field_tag('publisher', isset($search['publisher']) ? $search['publisher'] : ''); ?>
<?php echo (new Html())->text_search_field_tag('publisher', isset($search['publisher']) ? $search['publisher'] : ''); ?>
<div id='div_searchPublisher' style='<?php echo (empty($search['publisher']) ? "display: none;" : ""); ?>'>
<input type='button' name='btn_searchPublisher' value='<?php echo _("go!");?>' class='searchButton' />
</div>
Expand All @@ -84,7 +84,7 @@
<tr>
<td class='searchRow'>
<label for='searchPlatform'><b><?php echo _("Platform (contains)"); ?></b></label>
<?php echo Html::text_search_field_tag('platform', isset($search['platform']) ? $search['platform'] : ''); ?>
<?php echo (new Html())->text_search_field_tag('platform', isset($search['platform']) ? $search['platform'] : ''); ?>
<div id='div_searchPlatform' style='<?php echo (empty($search['platform']) ? "display: none;" : ""); ?>'>
<input type='button' name='btn_searchPlatform' value='<?php echo _("go!");?>' class='searchButton' />
</div>
Expand All @@ -94,7 +94,7 @@
<tr>
<td class='searchRow'>
<label for='searchProvider'><b><?php echo _("Provider (contains)"); ?></b></label>
<?php echo Html::text_search_field_tag('provider', isset($search['provider']) ? $search['provider'] : ''); ?>
<?php echo (new Html())->text_search_field_tag('provider', isset($search['provider']) ? $search['provider'] : ''); ?>
<div id='div_searchProvider' style='<?php echo (empty($search['provider']) ? "display: none;" : ""); ?>'>
<input type='button' name='btn_searchProvider' value='<?php echo _("go!");?>' class='searchButton' />
</div>
Expand All @@ -106,7 +106,7 @@
<tr>
<td class='searchRow'><label for='searchResourceISBNOrISSN'><b><?php echo _("ISBN/ISSN");?></b></label>
<br />
<?php echo Html::text_search_field_tag('resourceISBNOrISSN', isset($search['resourceISBNOrISSN']) ? $search['resourceISBNOrISSN'] : ''); ?>
<?php echo (new Html())->text_search_field_tag('resourceISBNOrISSN', isset($search['resourceISBNOrISSN']) ? $search['resourceISBNOrISSN'] : ''); ?>
<br />
<div id='div_searchISBNOrISSN' style='<?php if (!isset($search['resourceISBNOrISSN'])) echo "display:none;"; ?>margin-left:123px;'><input type='button' name='btn_searchResourceISBNOrISSN' value='<?php echo _("go!");?>' class='searchButton' /></div>
</td>
Expand Down Expand Up @@ -410,7 +410,7 @@
<tr>
<td class='searchRow'><label for='searchResourceNote'><b><?php echo _("Note (contains)");?></b></label>
<br />
<?php echo Html::text_search_field_tag('resourceNote', isset($search['resourceNote']) ? $search['resourceNote'] : ''); ?>
<?php echo (new Html())->text_search_field_tag('resourceNote', isset($search['resourceNote']) ? $search['resourceNote'] : ''); ?>
<br />
<div id='div_searchResourceNote' style='<?php if (!isset($search['resourceNote'])) echo "display:none;"; ?>margin-left:123px;'><input type='button' name='btn_searchResourceNote' value='<?php echo _("go!");?>' class='searchButton' /></div>
</td>
Expand All @@ -421,13 +421,13 @@

<tr>
<td class='searchRow'><label for='createDate'><b><?php echo _("Date Created Between");?></b></label><br />
<?php echo Html::text_search_field_tag('createDateStart', isset($search['createDateStart']) ? $search['createDateStart'] : '', array('class' => 'date-pick', 'width' => '65px')); ?>
<?php echo (new Html())->text_search_field_tag('createDateStart', isset($search['createDateStart']) ? $search['createDateStart'] : '', array('class' => 'date-pick', 'width' => '65px')); ?>
&nbsp;&nbsp;<b><?php echo _("and");?></b>
</td>
</tr>
<tr>
<td style="border-top:0px;padding-top:0px;">
<?php echo Html::text_search_field_tag('createDateEnd', isset($search['createDateEnd']) ? $search['createDateEnd'] : '', array('class' => 'date-pick', 'width' => '65px')); ?>
<?php echo (new Html())->text_search_field_tag('createDateEnd', isset($search['createDateEnd']) ? $search['createDateEnd'] : '', array('class' => 'date-pick', 'width' => '65px')); ?>
<br />
<div id='div_searchCreateDate' style='display:none;'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type='button' class='searchButton' value='<?php echo _("go!");?>' /></div>
</td>
Expand Down