Esempio n. 1
0
<?php

if ($w->Auth->user()->allowed("/inbox/send")) {
    echo Html::b($webroot . "/inbox/send", "Create Message");
}
$button = new \Html\button();
if (!empty($new)) {
    echo $button->text("Archive")->onclick("sendArch()")->__toString();
    // print "<button onclick='sendArch()'>Archive</button>";
    echo $button->text("Delete")->onclick("deleteMessage()")->__toString();
    // print "<button onclick='deleteMessage()'>Delete</button>";
}
if ($w->service('Inbox')->inboxCountMarker()) {
    echo Html::b($w->localUrl("/inbox/allread"), "Mark all read", "Are you sure to mark all messages as read?");
}
if (!empty($new)) {
    // Print table
    echo $new_table;
    $last_page = ceil($newtotal / 40);
    $minPage = $pgnum * 1 - 5;
    $minPage <= 0 ? $minPage = 1 : '';
    $maxPage = $pgnum * 1 + 5;
    $maxPage > $last_page ? $maxPage = $last_page : '';
    if ($last_page > 1) {
        print "<table style='margin:auto;'><tr id='nav'>";
        if ($pgnum > 1) {
            print "<td style='background-color:#eee;' id='link" . $i . " prevlink' class='link' onclick='switchPage(" . ($pgnum - 1) . ")'><a class='link'  href='#'>Prev</a></td>&nbsp";
        }
        for ($i = $minPage; $i <= $maxPage; $i++) {
            if ($pgnum == $i) {
                print "<td id='link" . $i . " ' class='link ispage' ><b>*" . $i . "*</b></td>&nbsp";
Esempio n. 2
0
 public function close($button_title = 'Save', $extrabuttons = null)
 {
     if (!empty($button_title)) {
         $button = new \Html\button();
         $button->type("submit")->text($button_title)->setClass('tiny button savebutton');
         $cancel_button = new \Html\button();
         $cancel_button->setClass('tiny button cancelbutton');
         $cancel_button->type("button")->text("Cancel")->js("if(\$('#cmfive-modal').is(':visible')){ \$('#cmfive-modal').foundation('reveal', 'close'); } else { window.history.back(); }");
         return "<div class='row small-12 columns'>{$button->__toString()}{$cancel_button->__toString()}{$extrabuttons}</div></form>";
     } else {
         return "</form>";
     }
 }
Esempio n. 3
0
<?php

if (!empty($del_table)) {
    $button = new \Html\button();
    echo $button->text("Delete Forever")->onclick("deleteMessage()")->__toString();
    // print "<button onclick='deleteMessage()'>Delete</button>";
    echo $del_table;
} else {
    echo "<br/>No deleted messages.";
}
$last_page = ceil($del_count / 40);
$minPage = $pgnum * 1 - 5;
$minPage <= 0 ? $minPage = 1 : '';
//print $minPage . "\n";
$maxPage = $pgnum * 1 + 5;
$maxPage > $last_page ? $maxPage = $last_page : '';
//print $maxPage . "\n";
//exit();
if ($last_page > 1) {
    print "<table style='margin:auto;'><tr id='nav'>";
    if ($pgnum > 1) {
        print "<td style='background-color:#eee;' id='link" . $i . " prevlink' class='link' onclick='switchPage(" . ($pgnum - 1) . ")'><a class='link'  href='#'>Prev</a></td>&nbsp";
    }
    for ($i = $minPage; $i <= $maxPage; $i++) {
        if ($pgnum == $i) {
            print "<td id='link" . $i . " ' class='link ispage' ><b>*" . $i . "*</b></td>&nbsp";
        } else {
            print "<td id='link" . $i . "' class='link' onclick='switchPage(" . $i . ")'><a class='link'  href='#'>" . $i . "</a></td>&nbsp";
        }
    }
    if ($pgnum < $last_page && $last_page !== 1) {
Esempio n. 4
0
 /**
  *  Filter function returns formatted form for declaring filters. Data is the same
  *  as how Html::form is used. Filter parameters can be retrieved with $w->request
  *  and it may be a good idea to prefix input names with 'filter_' to avoid naming
  *  collisions in requests 
  *
  *  @param String $legend
  *  @param Array $data
  *  @param String $action
  *  @param String $method
  *  @param String $submitTitle
  *  @param String $id
  *  @param String $class
  *
  *  @return String $buf
  */
 public static function filter($legend, $data, $action = null, $method = "POST", $submitTitle = "Filter", $id = null, $class = null, $validation = null)
 {
     // This will pretty much be a redesigned Html::form layout
     if (empty($data)) {
         return;
     }
     $form = new \Html\form();
     // If form tag is needed print it
     $form->id($id)->setClass($class)->method($method)->action($action);
     $buffer = "";
     $buffer .= $form->open();
     // Set up vars
     $hidden = "";
     $buffer .= "<fieldset style=\"padding: 0; padding-top: 10px; padding-left: 10px;\">\n";
     $buffer .= "<legend>" . $legend . "</legend>\n";
     // $buffer .= "<div class=\"row-fluid\">\n";
     $buffer .= "<ul id='filter-grid' class='small-block-grid-1 medium-block-grid-3 large-block-grid-4'>";
     $should_autosubmit = false;
     if (count($data) === 1 && $data[0][1] === "select") {
         $should_autosubmit = true;
     }
     // Loop through data
     foreach ($data as $row) {
         //            $buffer .= "<div class=\"small-12 medium-3 left\"><div class=\"row\">";
         $buffer .= "<li>";
         // Get row parameters
         $title = !empty($row[0]) ? $row[0] : null;
         $type = !empty($row[1]) ? $row[1] : null;
         $name = !empty($row[2]) ? $row[2] : null;
         $value = !empty($row[3]) ? $row[3] : null;
         $readonly = "";
         $required = null;
         if (!empty($validation[$name])) {
             if (in_array("required", $validation[$name])) {
                 $required = "required";
             }
         }
         // handle disabled fields
         if ($name[0] == '-') {
             $name = substr($name, 1);
             $readonly = " readonly='true' ";
         }
         // span entry fields that have no title
         if (!empty($title)) {
             $mediumCols = 9;
             if ($type == "checkbox") {
                 $mediumCols = 6;
             }
             $buffer .= "<div class='small-12 columns'><label>{$title}";
             // medium-" . (12 - $mediumCols) . "
             //                $buffer .= "<div class='small-12 medium-{$mediumCols} columns'>";
         } else {
             $buffer .= "<div class='small-12'>";
         }
         //            $buffer .= "<div class=\"small-12 medium-10 columns\">";
         $size = !empty($row[4]) ? $row[4] : null;
         // Get the input that we need
         switch ($type) {
             case "text":
             case "password":
                 $buffer .= '<input' . $readonly . ' style="width:100%;"  type="' . $type . '" name="' . $name . '" value="' . htmlspecialchars($value) . '" size="' . (!empty($row[4]) ? $row[4] : null) . '" id="' . $name . '"/>';
                 break;
             case "autocomplete":
                 $minlength = !empty($row[5]) ? $row[5] : null;
                 $buffer .= Html::autocomplete($name, $size, $value, null, "width: 100%;", !empty($minlength) ? $minlength : 1, $required);
                 break;
             case "date":
                 $buffer .= Html::datePicker($name, $value, $size, $required);
                 break;
             case "datetime":
                 $buffer .= Html::datetimePicker($name, $value, $size, $required);
                 break;
             case "time":
                 $buffer .= Html::timePicker($name, $value, $size, $required);
                 break;
             case "static":
                 $buffer .= $value;
                 break;
             case "textarea":
                 // Columns is the size variable
                 $cols = $size;
                 $rows = !empty($row[5]) ? $row[5] : null;
                 $buffer .= '<textarea name="' . $name . '" rows="' . $rows . '" cols="' . $cols . '" id="' . $name . '">' . $value . '</textarea>';
                 break;
             case "section":
                 $buffer .= htmlentities($title);
                 break;
             case "select":
                 $items = $size;
                 $class = !empty($row[5]) ? $row[5] : null;
                 $style = !empty($row[6]) ? $row[6] : null;
                 $allmsg = !empty($row[7]) ? $row[7] : "-- Select --";
                 // $name, $items, $value=null, $class=null, $style=null, $allmsg = "-- Select --", $required = null
                 if ($readonly == "") {
                     $buffer .= Html::select($name, $items, $value, $class, $style, $allmsg);
                 } else {
                     $buffer .= $value;
                 }
                 break;
             case "multiSelect":
                 $items = $size;
                 if ($readonly == "") {
                     $buffer .= Html::multiSelect($name, $items, $value, null, "width: 100%;");
                 } else {
                     $buffer .= $value;
                 }
                 break;
             case "checkbox":
                 $buffer .= Html::checkbox($name, $value, $value, $class);
                 break;
             case "radio":
                 $group = !empty($field[4]) ? $field[4] : null;
                 $defaultValue = !empty($field[5]) ? $field[5] : null;
                 $class = !empty($field[6]) ? $field[6] : null;
                 $buffer .= Html::radio($name, $group, $value, $defaultValue, $class) . "&nbsp;" . htmlentities($title);
                 break;
             case "hidden":
                 $hidden .= "<input type=\"hidden\" name=\"" . $name . "\" value=\"" . htmlspecialchars($value) . "\"/>\n";
                 break;
             case "file":
                 $buffer .= "<input style=\"width:100%;\" type=\"" . $type . "\" name=\"" . $name . "\" size=\"" . $size . "\" id=\"" . $name . "\"/>";
                 break;
         }
         $buffer .= "</label></div></li>";
         // </div>
     }
     // This is only true when the filter has one element and its a select field
     if ($should_autosubmit) {
         $buffer .= "<script>\$('form" . ($id ? "#" . $id : "") . ' select\').change(function(){this.form.submit()});</script>';
     }
     // Filter button (optional... though optional is pointless)
     if (!empty($action)) {
         $button = new \Html\button();
         $buffer .= "<li><div class='small-12 columns'><label>Actions<br/>";
         if ($submitTitle !== NULL && !$should_autosubmit) {
             $buffer .= $button->type("submit")->text($submitTitle)->__toString();
         }
         if (!empty($id)) {
             $buffer .= $button->text("Reset")->id("filter_reset_{$id}")->name("filter_reset_{$id}")->value("reset")->__toString() . "</label></div></li>";
         } else {
             $buffer .= $button->text("Reset")->name("reset")->value("reset")->__toString() . "</label></div></li>";
         }
     }
     $buffer .= "</ul>";
     // </div>
     $buffer .= "\n</fieldset>\n";
     $buffer .= $hidden . "</form>\n";
     return $buffer;
 }