Refactor PHP. Switch to explicit string literals where possible.

This commit is contained in:
Lars Jung 2015-05-11 13:00:10 +02:00
parent cb9b8c6244
commit d07850b6ef
2 changed files with 23 additions and 23 deletions

View file

@ -33,36 +33,36 @@ class Fallback {
$items = $folder->get_content($cache); $items = $folder->get_content($cache);
uasort($items, ['Item', 'cmp']); uasort($items, ['Item', 'cmp']);
$html = "<table>"; $html = '<table>';
$html .= "<tr>"; $html .= '<tr>';
$html .= "<th class='fb-i'></th>"; $html .= '<th class="fb-i"></th>';
$html .= "<th class='fb-n'><span>Name</span></th>"; $html .= '<th class="fb-n"><span>Name</span></th>';
$html .= "<th class='fb-d'><span>Last modified</span></th>"; $html .= '<th class="fb-d"><span>Last modified</span></th>';
$html .= "<th class='fb-s'><span>Size</span></th>"; $html .= '<th class="fb-s"><span>Size</span></th>';
$html .= "</tr>"; $html .= '</tr>';
if ($folder->get_parent($cache)) { if ($folder->get_parent($cache)) {
$html .= "<tr>"; $html .= '<tr>';
$html .= "<td class='fb-i'><img src='${app_href}client/images/fallback/folder-parent.png' alt='folder-parent'/></td>"; $html .= '<td class="fb-i"><img src="' . $app_href . 'client/images/fallback/folder-parent.png" alt="folder-parent"/></td>';
$html .= "<td class='fb-n'><a href='..'>Parent Directory</a></td>"; $html .= '<td class="fb-n"><a href="..">Parent Directory</a></td>';
$html .= "<td class='fb-d'></td>"; $html .= '<td class="fb-d"></td>';
$html .= "<td class='fb-s'></td>"; $html .= '<td class="fb-s"></td>';
$html .= "</tr>"; $html .= '</tr>';
} }
foreach ($items as $item) { foreach ($items as $item) {
$type = $item->is_folder ? 'folder' : 'file'; $type = $item->is_folder ? 'folder' : 'file';
$html .= "<tr>"; $html .= '<tr>';
$html .= "<td class='fb-i'><img src='${app_href}client/images/fallback/${type}.png' alt='${type}'/></td>"; $html .= '<td class="fb-i"><img src="' . $app_href . 'client/images/fallback/' . $type . '.png" alt="' . $type . '"/></td>';
$html .= "<td class='fb-n'><a href='" . $item->href . "'>" . basename($item->path) . "</a></td>"; $html .= '<td class="fb-n"><a href="' . $item->href . '">' . basename($item->path) . '</a></td>';
$html .= "<td class='fb-d'>" . date('Y-m-d H:i', $item->date) . "</td>"; $html .= '<td class="fb-d">' . date('Y-m-d H:i', $item->date) . '</td>';
$html .= "<td class='fb-s'>" . ($item->size !== null ? intval($item->size / 1000) . ' KB' : '' ) . "</td>"; $html .= '<td class="fb-s">' . ($item->size !== null ? intval($item->size / 1000) . ' KB' : '' ) . '</td>';
$html .= "</tr>"; $html .= '</tr>';
} }
$html .= "</table>"; $html .= '</table>';
return $html; return $html;
} }

View file

@ -1,7 +1,7 @@
- var app_href = "<?= APP_HREF; ?>" - var app_href = '<?= APP_HREF; ?>'
- var fallback = "<?= FALLBACK; ?>" - var fallback = '<?= FALLBACK; ?>'
<?php header("Content-type: text/html;charset=utf-8"); ?> <?php header('Content-type: text/html;charset=utf-8'); ?>
doctype html doctype html
<!--[if lt IE 10]><html class="no-js no-browser" lang="en"><![endif]--> <!--[if lt IE 10]><html class="no-js no-browser" lang="en"><![endif]-->
<!--[if gt IE 9]><!--><html class="no-js browser" lang="en"><!--<![endif]--> <!--[if gt IE 9]><!--><html class="no-js browser" lang="en"><!--<![endif]-->