Example #1
0
 function view($file_name, $title = null, $data = null, $master = null, $module = null)
 {
     $this->title = $title ? $title : "";
     $master = _php($master ? $master : "master");
     //Handle data
     if (is_array($data) && is_multidimensional($data)) {
         foreach ($data as $array) {
             if (is_array($array)) {
                 extract($array);
             } else {
                 extract($data);
                 break;
             }
         }
     }
     include "app{$this->module}/v/" . $master;
 }
Example #2
0
 /**
  * Verify the input is of the correct
  * type. Additionally delegate to Collection if needed
  *
  * @param data: EnsureInput as listed above
  */
 public static function Input($data)
 {
     /** handle a multiple ensure **/
     $args = func_get_args();
     if (count($args) > 1) {
         return EnsureResource::InputTwo($args);
     }
     if ($data instanceof DataPacket || $data instanceof DataPacketCollection) {
         return $data;
     }
     /** empty if not set **/
     if (!isset($data) || $data == null) {
         return new DataPacket(array());
     }
     if ($data instanceof Parameters) {
         return new DataPacket($data->data);
     }
     if (isset($data[0]) && $data[0] instanceof Parameters) {
         return new DataPacket($data[0]->data);
     }
     if ($data instanceof CollectionObject || is_string($data) || $data instanceof BaML || $data instanceof BaMLAttribute || $data instanceof BaMLVerb) {
         return new DataPacket($data);
     }
     if (isset($data[0]) && isset($data[1]) && !is_array($data[0]) && is_array($data[1])) {
         return new DataPacket(array_merge(array($data[0]), $data[1]));
     }
     if (isset($data[0]) && is_array($data) && BaseUtilities::is_multidimensional($data) && is_array($data[0]) && sizeof($data) == 1) {
         return new DataPacket($data[0]);
     }
     if (!(is_array($data) || $data instanceof \stdClass)) {
         throw new \CatapultApiException(EXCEPTIONS::WRONG_PARAMETERS);
     }
     if (!($data instanceof DataPacket && is_multidimensional($data))) {
         return new DataPacket($data);
     }
     if (!$data instanceof DataPacketCollection) {
         return new DataPacketCollection($data);
     }
 }
 private function process_comment($column, $null, $selected = null)
 {
     $comment = $column['Comment'];
     $options = array();
     $form = "";
     //Comentário pede para o campo ser preenchido por uma função
     //2
     if (preg_match('/\\#/', $comment)) {
         $maxlength = substr($column['Type'], strpos($column['Type'], '(') + 1);
         $maxlength = " maxlength='" . substr($maxlength, 0, strlen($maxlength) - 1) . "' ";
         $comment = substr($comment, 1);
         $form .= "<input type='text' {$maxlength} name='" . $column['Field'] . "' {$null} placeholder='" . $this->field_name($column['Field']) . "' value='" . $comment() . "'>\n";
     } elseif (preg_match('/^\\_/', $comment)) {
         $where_add = "";
         $table_add = "";
         //Define uma instrução WHERE para a busca em um db
         //3
         if (preg_match('/\\=/', $comment)) {
             $pieces = preg_split('/\\=/', $comment);
             $where_add = " and " . $pieces[1] . "=" . $pieces[0] . ".id";
             $comment = $pieces[0];
             $pieces = preg_split('/\\./', $pieces[1]);
             $table_add = $pieces[0];
         }
         //Caso haja alguma referência a uma tabela de banco de dados
         call(substr($comment, 1), isset($this->module) ? $this->module : null);
         $model_options = new $comment();
         $second_word = $this->second_word($comment);
         $first_word = 'id';
         if (preg_match('/\\_/', $second_word) || $table_add) {
             $table_add = $table_add != "" ? $table_add : "_pessoas";
             $model_options = $model_options->Reads($table_add, "{$comment}.id_pessoas=_pessoas.id" . $where_add, "_pessoas.id, _pessoas.nome");
             $first_word = "_pessoas__id";
             $second_word = "_pessoas__nome";
         } else {
             $model_options = $model_options->Read("id, {$second_word}");
         }
         if (!empty($model_options)) {
             $model_options = is_multidimensional($model_options) ? $model_options : array($model_options);
             foreach ($model_options as $mo) {
                 array_push($options, $mo[$first_word] . "-" . $mo[$second_word]);
             }
         } else {
             return "O formulário depende de valores na tabela {$comment}. <br>form_create().";
         }
         $form .= "<select name='" . $column['Field'] . "' {$null} placeholder='" . $this->field_name($column['Field']) . "'>";
         $form .= "<option>Selecione sua opção</option>";
         foreach ($options as $option) {
             $o = preg_split('/\\-/', $option);
             if (count($o) > 1) {
                 $form .= "<option value='" . $o[0] . "'" . ($selected == $o[0] ? " selected " : "") . ">" . $o[1] . "</option>";
             } else {
                 $form .= "<option value='{$option}'" . ($selected == $option ? " selected " : "") . ">{$option}</option>";
             }
         }
         $form .= "</select>";
     } else {
         $options = preg_split('/\\,/', $comment);
         $form .= "<select name='" . $column['Field'] . "' {$null} placeholder='" . $this->field_name($column['Field']) . "'>";
         $form .= "<option>Selecione sua opção</option>";
         foreach ($options as $option) {
             $o = preg_split('/\\-/', $option);
             if (count($o) > 1) {
                 $form .= "<option value='" . $o[0] . "' " . ($selected == $o[0] ? " selected " : "") . ">" . $o[1] . "</option>";
             } else {
                 $form .= "<option value='{$option}' " . ($selected == $option ? " selected " : "") . ">{$option}</option>";
             }
         }
         $form .= "</select>";
     }
     return $form;
 }
Example #4
0
/**
 * Retorna uma string com o código HTML formatado para a array em questão
 * @param  array $array
 * @param  string $title
 * @param  boolean $buttons
 * @return string
 */
function show_one($array, $keys = null, $new_keys = null, $buttons = null)
{
    if (is_array($array)) {
        if (empty($array)) {
            return "<h4>Não existem dados a serem mostrados. <i class='ion-happy-outline'></i></h4>";
        } elseif (is_multidimensional($array)) {
            $array = $array[0];
        }
    } else {
        return $array;
    }
    $r = "<table><thead><td width='200'>Dados</td><td>Valores</td></thead>";
    $id = 0;
    $bs = "";
    $id = $_GET['id'];
    $k = array_keys($array);
    if ($buttons) {
        if (!is_multidimensional($buttons)) {
            $buttons = array($buttons);
        }
        foreach ($buttons as $b) {
            $bs .= link_to(ctrl() . $b[1] . "-" . $id, $b[0] . ' <i class="icon-' . $b[2] . '"></i>', "button");
        }
    }
    if ($buttons) {
        if ($buttons != "ro") {
            if (!is_multidimensional($buttons)) {
                $buttons = array($buttons);
            }
            foreach ($buttons as $b) {
                $bs .= link_to(ctrl() . $b[1] . "-" . $id, $b[0] . ' <i class="icon-' . $b[2] . '"></i>', "button");
            }
            $bs = "<div class='group-button'>" . link_to_update($id, null, "button") . link_to_delete($id, null, "button deletar") . $bs . "</div>";
        } else {
            $bs = "Este item está marcado como <strong>somente leitura</strong>";
        }
    } else {
        $bs = "<div class='group-button'>" . link_to_update($id, null, "button") . link_to_delete($id, null, "button deletar") . "</div>";
    }
    if ($keys) {
        $nk = $keys;
        if (isset($new_keys)) {
            $nk = $new_keys;
        }
        for ($i = 0; $i < sizeof($array); $i++) {
            if (in_array($k[$i], $keys)) {
                $r .= sprintf("<tr><td><strong>%s</strong></td><td>%s</td></tr>", array_shift($nk), is_image($array[$k[$i]]) ? "<img src='" . $array[$k[$i]] . "' class='normal'>" : $array[$k[$i]]);
            }
        }
    } else {
        foreach ($array as $a) {
            $current_key = array_shift($k);
            if ($current_key == "gallery" && $a == 1) {
                $current_value = "Tem galeria aqui";
            } else {
                $current_value = is_image($a) ? "<img src='" . $a . "' class='normal'>" : $a;
            }
            $r .= sprintf("<tr><td><strong>%s</strong></td><td>%s</td></tr>", $current_key, $current_value);
        }
    }
    $r .= "</table><hr>";
    $r .= $bs;
    return $r;
}
	</div>
</div>
<div class="row">
	<div class="xs-12">
		<table class="center">
			<thead>
				<tr>
					<th>ID</th>
					<th>USUÁRIO</th>
					<th>ÚLTIMO LOGIN</th>
					<th>AÇÕES</th>
				</tr>
			</thead>
			<tbody>
		<?php 
if (!is_multidimensional($dados)) {
    $dados = array($dados);
}
foreach ($dados as $usuario) {
    extract($usuario);
    if ($level != 0) {
        echo "<tr><td>" . $id . "</td><td>" . $usuario . "</td><td>" . get_date_hour($lastlogin, true) . "</td><td>";
        if ($level > 1) {
            echo link_to_update($id);
            echo link_to_delete($id);
        } else {
            echo "Usuário Master. Nenhuma ação permitida";
        }
        echo "</td></tr>";
    }
}