Пример #1
0
function file_array($content, $filename = false)
{
    $header = false;
    $rows = "";
    foreach ($content as $line) {
        $rows .= "<tr>";
        if (!$header) {
            $hreturn = array();
        }
        foreach ($line as $key => $value) {
            if (!$header) {
                $hreturn[] = "<td>" . format_text_human($key) . "</td>";
            }
            $rows .= "<td>" . $value . "</td>";
        }
        if (!$header) {
            $header = '<tr style="background-color:#fafade; font-weight:bold;">' . implode("", $hreturn) . '</tr>';
        }
        $rows .= "</tr>";
    }
    $content = '<table border="1" style="font-family:Verdana; font-size:9px;">' . $header . $rows . '</table>';
    if ($filename) {
        return file_download($content, $filename, "xls");
    }
    return $content;
}
Пример #2
0
function draw_array($array, $nice = false)
{
    global $_josh;
    if (!is_array($array)) {
        return false;
    }
    $return = '<table cellspacing="1" style="background-color:#ccc;color:#333;border:0px;">';
    //if (!$nice) ksort($array);
    foreach ($array as $key => $value) {
        $key = urldecode($key);
        if ($nice && strToLower($key) == 'j') {
            continue;
        }
        //$value = format_quotes($value);
        if (strToLower($key) == 'email') {
            $value = '<a href="mailto:' . $value . '">' . $value . '</a>';
        }
        if (is_array($value)) {
            $value = draw_array($value, $nice);
        }
        $return .= '<tr><td style="background-color:#eee;"><b>';
        $return .= $nice ? format_text_human($key) : $key;
        $return .= '&nbsp;</b></td><td style="background-color:#fff;">';
        $return .= is_object($value) ? 'object value' : $value;
        $return .= '</td></tr>';
    }
    $return .= '</table>';
    return $return;
}
Пример #3
0
 function addField($array)
 {
     //defaults
     $type = $value = $class = $name = $label = $required = $append = $sql = $action = $additional = $maxlength = $options_table = $options = $linking_table = false;
     //load inputs
     if (!is_array($array)) {
         return error_handle("array not set");
     }
     extract($array);
     //type is required
     if (!$type) {
         return error_handle("type not set");
     }
     if ($type == "text" && !isset($array["additional"]) && $required) {
         $additional = "(Required)";
     }
     error_debug("adding field " . $label);
     if (!$name) {
         $name = format_text_code($label);
     }
     if (!$label) {
         $label = format_text_human($name);
     }
     if (!$value) {
         $value = isset($this->values[$name]) ? $this->values[$name] : false;
     }
     if (!$class) {
         $class = $type;
     }
     if ($type == "checkbox") {
         $additional = $label;
         $label = false;
     }
     //package and save
     $this->fields[] = compact("name", "type", "label", "value", "append", "required", "sql", "class", "action", "additional", "options_table", "options", "linking_table", "maxlength");
 }
Пример #4
0
function drawHeaderRow($name = false, $colspan = 1, $link1text = false, $link1link = false, $link2text = false, $link2link = false)
{
    global $_josh, $location, $modules, $page;
    error_debug("drawing header row");
    if (!$name) {
        $name = $page["name"];
    }
    //urls are absolute because it could be used in an email
    $header = '<tr>
				<td class="head ' . $location . '" colspan="' . $colspan . '">
					<div class="head-left">
					';
    if ($location != "login") {
        $header .= '<a  href="http://' . $_josh["request"]["host"] . '/' . $_josh["request"]["folder"] . '/">' . $modules[$page["moduleID"]]["name"] . '</a>';
    }
    if ($name) {
        $header .= ' &gt; ';
        if ($_josh["request"]["subfolder"]) {
            $header .= '<a href="http://' . $_josh["request"]["host"] . '/' . $_josh["request"]["folder"] . '/' . $_josh["request"]["subfolder"] . '/">' . format_text_human($_josh["request"]["subfolder"]) . '</a> &gt; ';
        }
        $header .= $name;
    }
    $header .= "</div>";
    if ($link2link && $link2text) {
        $header .= '<a class="right" href="' . $link2link . '">' . $link2text . '</a>';
    }
    if ($link1link && $link1text) {
        $header .= '<a class="right" href="' . $link1link . '">' . $link1text . '</a>';
    }
    $header .= '</td></tr>';
    return $header;
}