function errors($params) { $directory = scandir('./data/errors/'); $files = array(); foreach ($directory as $file) { if (!in_array($file, array('.', '..'))) { $files[$file] = filemtime('./data/errors/' . $file); } } arsort($files); $errors = array(); foreach ($files as $file => $mtime) { $file = explode(':', gzinflate(base64_decode(str_replace(array('-', '_'), array('/', '='), substr($file, 0, -4))))); $errors[] = array('time' => beautify_datetime($mtime), 'level' => $file[0], 'file' => $file[1], 'line' => $file[2]); } $data['errors'] = $errors; $data['html_head'] = array('title' => 'Errors: Admin Dashboard'); return $data; }
<li> <a href="<?php echo BASE_URL; ?> news/<?php echo $page; ?> /<?php echo $article['id']; ?> /<?php echo slugify($article['title']); ?> "> <small><?php echo beautify_datetime($article['published']); ?> </small> <h3><?php echo $article['title']; ?> </h3> <p><?php echo shorten_string($article['content'], 250); ?> </p> </a> </li> <?php } ?>
function render_table($schema, $data, $classname = false) { $found = false; ?> <table width="100%" class="table table-striped<?php echo $classname != false ? ' ' . $classname : ''; ?> "><thead><tr> <?php $cmd_opened = false; foreach ($schema as $col => $meta) { if (!isset($meta['table']) || $meta['table']) { if (isset($meta['cmd']) || isset($meta['onclick'])) { if (!$cmd_opened) { echo '<th width="120" class="action_btns">Actions'; $cmd_opened = true; } } else { ?> <th><?php echo $meta[0]; ?> </th><?php } } } if ($cmd_opened) { echo '</th>'; } ?> </tr></thead><tbody><?php $key = false; while ($row = mysql_fetch_assoc($data)) { foreach ($schema as $col => $meta) { if (isset($meta['key']) && $meta['key']) { $key = $row[$col]; } } ?> <tr onclick="return row_click(this);"<?php echo isset($key) ? 'data-key="' . $key . '"' : ''; ?> ><?php $cmd_opened = false; foreach ($schema as $col => $meta) { if (isset($meta['cmd']) || isset($meta['onclick'])) { if (!$cmd_opened) { echo '<td class="action_btns">'; $cmd_opened = true; } ?> <a class="<?php echo $col; echo isset($meta['default']) ? ' default' : ''; ?> " href=<?php if (isset($meta['cmd'])) { echo '"' . BASE_URL . str_replace('{key}', $key, $meta['cmd']) . '"' . (isset($meta['confirm']) ? ' onclick="if (confirm(\'Are you sure.?\')){return true;}else{event.stopPropagation(); return false;}"' : ''); } else { if (isset($meta['onclick'])) { echo '"javascript:void(0);" onclick="' . str_replace('{key}', $key, $meta['onclick']) . '"'; } } ?> ><?php echo $meta[0]; ?> </a><?php } else { if (!isset($meta['table']) || $meta['table']) { echo '<td>'; if (isset($meta['table-display'])) { if ($meta['table-display'] == 'enum') { //echo '<small>'.$row[$col].'</small>'; render_dropdown($col . '[' . $key . ']', $meta['enum'], $row[$col], $col, isset($meta['onchange']) ? $meta['onchange'] : false, true); } else { if ($meta['table-display'] == 'calendar') { echo '<input type="text" class="form-control ' . $col . '" name="' . $col . '[' . $key . ']" value="' . substr($row[$col], 0, 10) . '" ' . (isset($meta['onchange']) ? 'onchange="' . $meta['onchange'] . '"' : '') . 'onfocus="return ShowCalendar(this);" readonly="true" />'; } else { if ($meta['table-display'] == 'calendar,clock') { echo '<input type="text" class="form-control ' . $col . '" name="' . $col . '[' . $key . ']" value="' . $row[$col] . '" onfocus="return ShowCalendar(this, \'clock\');" readonly="true" />'; } else { if ($meta['table-display'] == 'small') { echo '<small>' . $row[$col] . '</small>'; } else { echo $row[$col]; } } } } } else { if (isset($meta['enum'])) { echo isset($meta['enum'][$row[$col]]) ? is_array($meta['enum'][$row[$col]]) ? $meta['enum'][$row[$col]][0] : $meta['enum'][$row[$col]] : '-'; } else { if (isset($meta['autofill'])) { echo isset($meta['autofill'][$row[$col]]) ? is_array($meta['autofill'][$row[$col]]) ? $meta['autofill'][$row[$col]][0] : $meta['autofill'][$row[$col]] : '-'; } else { if (isset($meta['display'])) { if ($meta['display'] == 'calendar' || $meta['display'] == 'calendar,clock') { echo beautify_datetime($row[$col]); } else { echo $row[$col]; } } else { echo isset($row[$col]) ? $row[$col] : '-'; } } } } echo '</td>'; } } } if ($cmd_opened) { echo '</td>'; } ?> </tr><?php $found = true; } if (!$found) { ?> <tr class="no-records"><td colspan="99"><i>No records to display</i></td></tr><?php } ?> </tbody></table><?php }
function render_row($row, $schema, &$found) { foreach ($schema as $col => $meta) { if (isset($meta['key']) && $meta['key']) { $key = $row[$col]; } } ?> <tr onclick="return row_click(this);"<?php echo isset($key) ? 'data-key="' . $key . '"' : ''; ?> ><?php $cmd_opened = false; foreach ($schema as $col => $meta) { if (isset($meta['link'])) { ?> <td><a class="<?php echo $col; echo isset($meta['default']) ? ' default' : ''; ?> " href=<?php echo '"' . BASE_URL . str_replace('{key}', $key, $meta['link']) . '"'; ?> ><?php echo $row[$col]; ?> </a></td><?php } else { if (isset($meta['cmd']) || isset($meta['onclick'])) { if (!$cmd_opened) { echo '<td class="action_btns">'; $cmd_opened = true; } ?> <a class="button <?php echo $col; echo isset($meta['default']) ? ' default' : ''; ?> " href=<?php if (isset($meta['cmd'])) { echo '"' . BASE_URL . str_replace('{key}', $key, $meta['cmd']) . '"' . (isset($meta['confirm']) ? ' onclick="if (confirm(\'Are you sure.?\')){return true;}else{event.stopPropagation(); return false;}"' : ''); } else { if (isset($meta['onclick'])) { echo '"javascript:void(0);" onclick="' . str_replace('{key}', $key, $meta['onclick']) . '"'; } } ?> ><?php echo $meta[0]; ?> </a><?php } else { if (!isset($meta['table']) || $meta['table']) { echo '<td' . (isset($meta['display']) && ($meta['display'] == 'numeric' || $meta['display'] == 'currency') ? ' align="right"' : '') . '>'; if (isset($meta['table-display'])) { if ($meta['table-display'] == 'enum') { //echo '<small>'.$row[$col].'</small>'; render_dropdown($col . '[' . $key . ']', $meta['enum'], $row[$col], $col, isset($meta['onchange']) ? $meta['onchange'] : false, true); } else { if ($meta['table-display'] == 'calendar') { echo '<input type="text" class="form-control ' . $col . '" name="' . $col . '[' . $key . ']" value="' . substr($row[$col], 0, 10) . '" ' . (isset($meta['onchange']) ? 'onchange="' . $meta['onchange'] . '"' : '') . 'onfocus="return ShowCalendar(this);" readonly="true" />'; } else { if ($meta['table-display'] == 'calendar+clock') { echo '<input type="text" class="form-control ' . $col . '" name="' . $col . '[' . $key . ']" value="' . $row[$col] . '" onfocus="return ShowCalendar(this, \'clock\');" readonly="true" />'; } else { if ($meta['table-display'] == 'small') { echo '<small>' . $row[$col] . '</small>'; } else { echo $row[$col]; } } } } } else { if (isset($meta['function'])) { echo $meta['function']($row); } else { if (isset($meta['enum'])) { echo isset($meta['enum'][$row[$col]]) ? is_array($meta['enum'][$row[$col]]) ? $meta['enum'][$row[$col]][0] : $meta['enum'][$row[$col]] : '-'; } else { if (isset($meta['autofill'])) { echo isset($meta['autofill'][$row[$col]]) ? is_array($meta['autofill'][$row[$col]]) ? $meta['autofill'][$row[$col]][0] : $meta['autofill'][$row[$col]] : '-'; } else { if (isset($meta['display'])) { if ($meta['display'] == 'calendar' || $meta['display'] == 'calendar+clock') { echo beautify_datetime($row[$col]); } else { echo $row[$col]; } } else { echo isset($row[$col]) ? $row[$col] : '-'; } } } } } echo '</td>'; } } } } if ($cmd_opened) { echo '</td>'; } ?> </tr><?php $found = true; }