Beispiel #1
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;
}
Beispiel #2
0
        echo $result->getTitle();
        ?>
</td>
          <td><?php 
        echo $result->getDescription();
        ?>
</td>
          <td>
            <?php 
        echo link_to_show('image', $result);
        ?>
            <?php 
        echo link_to_edit('image', $result);
        ?>
            <?php 
        echo link_to_delete('image', $result);
        ?>
          </td>
        </tr>
      <?php 
    }
    ?>
    <?php 
} else {
    ?>
      <tr>
        <td colspan="4">No results</td>
      </tr>
    <?php 
}
?>
			<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>";
    }
}
?>
			</tbody>
		</table>
	</div>
</div>