Пример #1
0
function cpg_versioncheckCreateTextOnlyOutput($file_data_array)
{
    global $displayOption_array, $file_data_count, $lang_versioncheck_php, $maxLength_array, $imageFileExtensions_array, $LINEBREAK;
    // display formatted header data
    if ($displayOption_array['output'] == 'textarea') {
        echo <<<EOT
      <a href="javascript:HighlightAll('versioncheckdisplay.versioncheck_text')" class="admin_menu">
      {$lang_versioncheck_php['select_all']}
      </a><br />

EOT;
        print '<form name="versioncheckdisplay"><textarea name="versioncheck_text" rows="' . ($file_data_count + 5) . '" cols="60" class="textinput debug_text" style="width:98%;font-family:\'Courier New\',Courier,monospace;font-size:9px;">';
    }
    $loopCounter = 1;
    $textSeparator = '|';
    $caption = '';
    $underline = '';
    $output = '';
    if (strlen($file_data_count) > $maxLength_array['counter']) {
        $maxLength_array['counter'] = strlen($file_data_count);
    }
    // the caption for the table
    $caption .= cpg_fillArrayFieldWithSpaces($lang_versioncheck_php['counter'], $maxLength_array['counter']);
    $caption .= $textSeparator;
    $caption .= cpg_fillArrayFieldWithSpaces($lang_versioncheck_php['type'], $maxLength_array['folderfile']);
    $caption .= $textSeparator;
    $caption .= cpg_fillArrayFieldWithSpaces($lang_versioncheck_php['path'], $maxLength_array['fullpath']);
    $caption .= $textSeparator;
    $caption .= cpg_fillArrayFieldWithSpaces($lang_versioncheck_php['missing'], $maxLength_array['exist']);
    $caption .= $textSeparator;
    $caption .= cpg_fillArrayFieldWithSpaces($lang_versioncheck_php['permissions'], $maxLength_array['readwrite']);
    $caption .= $textSeparator;
    $caption .= cpg_fillArrayFieldWithSpaces($lang_versioncheck_php['version'], $maxLength_array['version']);
    $caption .= $textSeparator;
    $caption .= cpg_fillArrayFieldWithSpaces($lang_versioncheck_php['revision'], $maxLength_array['revision']);
    $caption .= $textSeparator;
    if ($displayOption_array['no_modification_check'] != 1) {
        $caption .= cpg_fillArrayFieldWithSpaces($lang_versioncheck_php['modified'], $maxLength_array['modified']);
        $caption .= $textSeparator;
    }
    $caption .= cpg_fillArrayFieldWithSpaces($lang_versioncheck_php['comment'], $maxLength_array['comment']);
    $caption .= $LINEBREAK;
    for ($i = 1; $i <= strlen($caption); $i++) {
        $underline .= '-';
    }
    $underline .= $LINEBREAK;
    // loop through all the elements in $file_data_array (which equals looping thorugh all folders and files) once more and create the textual output
    foreach ($file_data_array as $file_data_values) {
        if ($displayOption_array['errors_only'] == 0 || $displayOption_array['errors_only'] == 1 && $file_data_values['comment'] != '') {
            // only display if corrsponding option is not disabled --- start
            if ($displayOption_array['hide_images'] && in_array($file_data_values['extension'], $imageFileExtensions_array) == TRUE) {
                // Only display image if corresponding option is not enabled --- start
                // Do nothing
            } else {
                $output .= cpg_fillArrayFieldWithSpaces(ltrim($loopCounter), $maxLength_array['counter'], 'left');
                $output .= $textSeparator;
                $output .= cpg_fillArrayFieldWithSpaces($file_data_values['txt_folderfile'], $maxLength_array['folderfile']);
                $output .= $textSeparator;
                $output .= cpg_fillArrayFieldWithSpaces($file_data_values['fullpath'], $maxLength_array['fullpath']);
                $output .= $textSeparator;
                $output .= cpg_fillArrayFieldWithSpaces($file_data_values['txt_missing'], $maxLength_array['exist']);
                $output .= $textSeparator;
                $output .= cpg_fillArrayFieldWithSpaces($file_data_values['local_readwrite'] . $file_data_values['txt_readwrite'], $maxLength_array['readwrite']);
                $output .= $textSeparator;
                $output .= cpg_fillArrayFieldWithSpaces($file_data_values['local_version'] . $file_data_values['txt_version'], $maxLength_array['version']);
                $output .= $textSeparator;
                $output .= cpg_fillArrayFieldWithSpaces($file_data_values['local_revision'] . $file_data_values['txt_revision'], $maxLength_array['revision']);
                $output .= $textSeparator;
                if ($displayOption_array['no_modification_check'] != 1) {
                    $output .= cpg_fillArrayFieldWithSpaces($file_data_values['local_modified'] . $file_data_values['txt_modified'], $maxLength_array['modified']);
                    $output .= $textSeparator;
                }
                if ($file_data_values['comment'] != '') {
                    $output .= $lang_versioncheck_php['warning'];
                }
                $output .= $LINEBREAK;
                $loopCounter++;
            }
            // Only display image if corresponding option is not enabled --- end
        }
        // only display if corrsponding option is not disabled --- end
    }
    ob_start();
    print $caption;
    print $underline;
    print $output;
    // display formatted footer data
    if ($displayOption_array['output'] == 'textarea') {
        print <<<EOT
      </textarea>
      </form>
EOT;
    }
    $string = ob_get_contents();
    ob_end_clean();
    return $string;
}
/**
 * cpg_fill_string_array_with_spaces
 *
 * @param array $table (can be variable or array)
 * @param string $align alignment of the cells (left or right)
 * @param string $return_value desired return value (string or array)
 * @return array or string
 */
function cpg_fill_string_array_with_spaces($table, $separator = '|', $align = 'left', $return_value = 'string')
{
    global $CONFIG, $LINEBREAK;
    // Populate the needed function
    if (!function_exists('mb_strlen')) {
        require 'include/mb.inc.php';
    }
    // Sanitize the parameters
    if ($align == 'right') {
        $fillUpOn = 'left';
    } else {
        $fillUpOn = 'right';
    }
    if ($return_value != 'string' && $return_value != 'array') {
        $return_value = 'string';
    }
    // $table needs to be an associative array
    $max_string_length = array();
    // set default for return value
    if ($return_value == 'array') {
        $return = array();
    } else {
        $return = '';
    }
    // Find the longest string
    foreach ($table as $key) {
        if (is_array($key) != TRUE) {
            $key = array($key);
        }
        $loopCounter = 0;
        foreach ($key as $subkey) {
            $length = mb_strlen($subkey, $CONFIG['charset']);
            if (empty($max_string_length[$loopCounter]) || $length > $max_string_length[$loopCounter]) {
                $max_string_length[$loopCounter] = $length;
            }
            $loopCounter++;
        }
    }
    // Fill the $return array / var
    foreach ($table as $key => $value) {
        if (is_array($value) != TRUE) {
            $value = array($value);
        }
        $loopCounter = 0;
        $temp = '';
        foreach ($value as $subvalue) {
            if ($loopCounter != 0) {
                $temp .= $separator;
            }
            $temp .= cpg_fillArrayFieldWithSpaces($subvalue, $max_string_length[$loopCounter], $fillUpOn);
            $loopCounter++;
        }
        if ($return_value == 'array') {
            $return[$key] = $temp;
        } else {
            $return .= $temp . $LINEBREAK;
        }
    }
    return $return;
}