Skip to content

Commit

Permalink
Remove duplicated functions from admin.
Browse files Browse the repository at this point in the history
  • Loading branch information
scottcwilson committed Jan 6, 2019
1 parent c0b2fea commit ca38006
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 225 deletions.
227 changes: 2 additions & 225 deletions admin/includes/functions/html_output.php
Original file line number Diff line number Diff line change
Expand Up @@ -266,231 +266,6 @@ function zen_catalog_href_link($page = '', $parameters = '', $connection = 'NONS

////
// The HTML image wrapper function
function zen_image($src, $alt = '', $width = '', $height = '', $params = '') {
$image = '<img src="' . $src . '" border="0" alt="' . $alt . '"';
if ($alt) {
$image .= ' title=" ' . $alt . ' "';
}
if ($width) {
$image .= ' width="' . $width . '"';
}
if ($height) {
$image .= ' height="' . $height . '"';
}
if ($params) {
$image .= ' ' . $params;
}
$image .= '>';

return $image;
}

////
// The HTML form submit button wrapper function
// Outputs a button in the selected language
function zen_image_submit($image, $alt = '', $parameters = '') {
global $language;

$image_submit = '<input type="image" src="' . zen_output_string(DIR_WS_LANGUAGES . $_SESSION['language'] . '/images/buttons/' . $image) . '" border="0" alt="' . zen_output_string($alt) . '"';

if (zen_not_null($alt)) $image_submit .= ' title=" ' . zen_output_string($alt) . ' "';

if (zen_not_null($parameters)) $image_submit .= ' ' . $parameters;

$image_submit .= '>';

return $image_submit;
}

////
// Draw a 1 pixel black line
function zen_black_line() {
return zen_image(DIR_WS_IMAGES . 'pixel_black.gif', '', '100%', '1');
}

////
// Output a separator either through whitespace, or with an image
function zen_draw_separator($image = 'pixel_black.gif', $width = '100%', $height = '1') {
return zen_image(DIR_WS_IMAGES . $image, '', $width, $height);
}

////
// Output a function button in the selected language
function zen_image_button($image, $alt = '', $params = '') {
global $language;

return zen_image(DIR_WS_LANGUAGES . $_SESSION['language'] . '/images/buttons/' . $image, $alt, '', '', $params);
}

////
// Output a form
function zen_draw_form($name, $action, $parameters = '', $method = 'post', $params = '', $usessl = 'false') {
$form = '<form name="' . zen_output_string($name) . '" action="';
if (zen_not_null($parameters)) {
$form .= zen_admin_href_link($action, $parameters);
} else {
$form .= zen_admin_href_link($action);
}
$form .= '" method="' . zen_output_string($method) . '"';
if (zen_not_null($params)) {
$form .= ' ' . $params;
}
$form .= '>';
if (strtolower($method) == 'post') $form .= '<input type="hidden" name="securityToken" value="' . $_SESSION['securityToken'] . '" />';
if (strtolower($method) == 'get') $form .= '<input type="hidden" name="cmd" value="' . $action . '" />';
return $form;
}

////
// Output a form input field
function zen_draw_input_field($name, $value = '~*~*#', $parameters = '', $required = false, $type = 'text', $reinsert_value = true) {
$field = '<input type="' . zen_output_string($type) . '" name="' . zen_output_string($name) . '"';

if ( $value == '~*~*#' && (isset($GLOBALS[$name]) && is_string($GLOBALS[$name])) && ($reinsert_value == true) ) {
$field .= ' value="' . zen_output_string(stripslashes($GLOBALS[$name])) . '"';
} elseif ($value != '~*~*#' && zen_not_null($value)) {
$field .= ' value="' . zen_output_string($value) . '"';
}

if (zen_not_null($parameters)) $field .= ' ' . $parameters;

$field .= ' />';

return $field;
}

////
// Output a form password field
function zen_draw_password_field($name, $value = '', $required = false, $parameters = '',$autocomplete = false) {
$parameters .= ' maxlength="40"';
if($autocomplete == false){
$parameters .= ' autocomplete="off"';
}
$field = zen_draw_input_field($name, $value, $parameters, $required, 'password', false);

return $field;
}

////
// Output a form filefield
function zen_draw_file_field($name, $required = false, $parameters = '') {
$field = zen_draw_input_field($name, '', ' size="50" ' . $parameters, $required, 'file');

return $field;
}

////
// Output a selection field - alias function for zen_draw_checkbox_field() and zen_draw_radio_field()
function zen_draw_selection_field($name, $type, $value = '', $checked = false, $compare = '', $parameters = '') {
$selection = '<input type="' . zen_output_string($type) . '" name="' . zen_output_string($name) . '"';

if (zen_not_null($value)) $selection .= ' value="' . zen_output_string($value) . '"';

if ( ($checked == true) || (isset($GLOBALS[$name]) && is_string($GLOBALS[$name]) && ($GLOBALS[$name] == 'on')) || (isset($value) && isset($GLOBALS[$name]) && is_string($GLOBALS[$name]) && (stripslashes($GLOBALS[$name]) == $value)) || (zen_not_null($value) && zen_not_null($compare) && ($value == $compare)) ) {
$selection .= ' checked="checked"';
}

if (zen_not_null($parameters)) $selection .= ' ' . $parameters;

$selection .= ' />';

return $selection;
}

////
// Output a form checkbox field
function zen_draw_checkbox_field($name, $value = '', $checked = false, $compare = '', $parameters = '') {
return zen_draw_selection_field($name, 'checkbox', $value, $checked, $compare, $parameters);
}

////
// Output a form radio field
function zen_draw_radio_field($name, $value = '', $checked = false, $compare = '', $parameters = '') {
return zen_draw_selection_field($name, 'radio', $value, $checked, $compare, $parameters);
}

////
// Output a form textarea field
function zen_draw_textarea_field($name, $wrap, $width, $height, $text = '~*~*#', $parameters = '', $reinsert_value = true) {
$field = '<textarea name="' . zen_output_string($name) . '" wrap="' . zen_output_string($wrap) . '" cols="' . zen_output_string($width) . '" rows="' . zen_output_string($height) . '"';

if (zen_not_null($parameters)) $field .= ' ' . $parameters;

$field .= '>';

if ($text == '~*~*#' && (isset($GLOBALS[$name]) && is_string($GLOBALS[$name])) && ($reinsert_value == true) ) {
$field .= stripslashes($GLOBALS[$name]);
$field = str_replace('&gt;', '>', $field);
} elseif ($text != '~*~*#' && zen_not_null($text)) {
$field = str_replace('&gt;', '>', $field);
$field .= $text;
}

$field .= '</textarea>';

return $field;
}

////
// Output a form hidden field
function zen_draw_hidden_field($name, $value = '~*~*#', $parameters = '') {
$field = '<input type="hidden" name="' . zen_output_string($name) . '"';

if (zen_not_null($value) && $value != '~*~*#') {
$field .= ' value="' . zen_output_string($value) . '"';
} elseif (isset($GLOBALS[$name]) && is_string($GLOBALS[$name])) {
$field .= ' value="' . zen_output_string(stripslashes($GLOBALS[$name])) . '"';
}

if (zen_not_null($parameters)) $field .= ' ' . $parameters;

$field .= ' />';

return $field;
}

////
// Output a form pull down menu
function zen_draw_pull_down_menu($name, $values, $default = '', $parameters = '', $required = false) {
// $field = '<select name="' . zen_output_string($name) . '"';
$field = '<select rel="dropdown" name="' . zen_output_string($name) . '"';

if (zen_not_null($parameters)) $field .= ' ' . $parameters;

$field .= '>' . "\n";

if (empty($default) && isset($GLOBALS[$name]) && is_string($GLOBALS[$name]) ) $default = stripslashes($GLOBALS[$name]);

for ($i=0, $n=sizeof($values); $i<$n; $i++) {
$field .= '<option value="' . zen_output_string($values[$i]['id']) . '"';
if ($default == $values[$i]['id']) {
$field .= ' selected="selected"';
}

$field .= '>' . zen_output_string($values[$i]['text'], array('"' => '&quot;', '\'' => '&#039;', '<' => '&lt;', '>' => '&gt;')) . '</option>' . "\n";
}
$field .= '</select>' . "\n";

if ($required == true) $field .= TEXT_FIELD_REQUIRED;

return $field;
}
////
// Hide form elements
function zen_hide_session_id() {
global $session_started;

if ( ($session_started == true) && defined('SID') && zen_not_null(SID) ) {
return zen_draw_hidden_field(zen_session_name(), zen_session_id());
}
}
////
// output label for input fields
function zen_draw_label($text, $for, $parameters = ''){
$label = '<label for="' . $for . '" ' . $parameters . '>' . $text . '</label>';
return $label;
}

/**
* @param string $page
* @param string $parameters
Expand All @@ -503,3 +278,5 @@ function zen_ajax_href_link($page = '', $parameters = '', $connection = 'NONSSL'
$link = str_replace('&amp;', '&', $link);
return $link;
}

require_once(DIR_FS_CATALOG . DIR_WS_FUNCTIONS . 'html_output.php');
2 changes: 2 additions & 0 deletions includes/functions/html_output.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@
*
* @return string
*/
if (!function_exists('zen_href_link')) {
function zen_href_link($page = '', $parameters = '', $connection = 'NONSSL', $add_session_id = true, $search_engine_safe = true, $static = false, $use_dir_ws_catalog = true) {
global $request_type, $session_started, $http_domain, $https_domain, $zco_notifier;

Expand Down Expand Up @@ -181,6 +182,7 @@ function zen_href_link($page = '', $parameters = '', $connection = 'NONSSL', $ad
$link = str_replace('&', '&amp;', $link);
return $link;
}
}

/*
* The HTML image wrapper function for non-proportional images
Expand Down

0 comments on commit ca38006

Please sign in to comment.