Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding twig template engine #28

Open
wants to merge 14 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
6 changes: 2 additions & 4 deletions about.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
// | about.php |
// +------------------------------------------------------------------------+
require_once('include/initialize.inc.php');
require_once('getid3/getid3/getid3.php'); // for version info
//require_once('include/header.inc.php');

$cfg['menu'] = 'about';
Expand All @@ -51,13 +50,12 @@ function versionCheck($ttl) {
global $cfg, $db;

if ($cfg['latest_version_idle_time'] < time() - $ttl) {
$cfg['latest_version'] = 'Unresolved';
if ($cfg['latest_version'] = @file_get_contents('http://www.ompd.pl/version.txt')) {
$cfg['latest_version_idle_time'] = time();
mysqli_query($db,'UPDATE server SET value = "' . mysqli_real_escape_string($db,$cfg['latest_version']) . '" WHERE name = "latest_version"');
mysqli_query($db,'UPDATE server SET value = "' . (int) $cfg['latest_version_idle_time'] . '" WHERE name = "latest_version_idle_time"');
}
else
$cfg['latest_version'] = 'Unresolved';
}
if (version_compare(NJB_VERSION, $cfg['latest_version'], '<') || $cfg['latest_version'] == 'Unresolved') return false;
else return true;
Expand Down Expand Up @@ -277,7 +275,7 @@ function about() {
</tr>
<tr class="<?php echo ($i++ & 1) ? 'even' : 'odd'; ?>">
<td></td>
<td>getID3() <?php $getID3 = new getID3; echo $getID3->version(); ?></td>
<td>getID3() <?php $getID3 = new \getID3; echo $getID3->version(); ?></td>
<td></td>
<td><a href="http://www.getid3.org" target="_new">http://www.getid3.org</a></td>
<td></td>
Expand Down
13 changes: 13 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"minimum-stability": "dev",
"require": {
"james-heinrich/getid3": "dev-master",
"components/jquery": "1.11.*",
"twig/twig": "^1.29"
},
"repositories": [
],
"config" : {
"component-dir": "vendor/components"
}
}
160 changes: 160 additions & 0 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file added composer.phar
Binary file not shown.
165 changes: 165 additions & 0 deletions controller/view1.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,165 @@
<?php
// +------------------------------------------------------------------------+
// | O!MPD, Copyright © 2015-2016 Artur Sierzant |
// | http://www.ompd.pl |
// | |
// | |
// | netjukebox, Copyright © 2001-2012 Willem Bartels |
// | |
// | http://www.netjukebox.nl |
// | http://forum.netjukebox.nl |
// | |
// | This program is free software: you can redistribute it and/or modify |
// | it under the terms of the GNU General Public License as published by |
// | the Free Software Foundation, either version 3 of the License, or |
// | (at your option) any later version. |
// | |
// | This program is distributed in the hope that it will be useful, |
// | but WITHOUT ANY WARRANTY; without even the implied warranty of |
// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
// | GNU General Public License for more details. |
// | |
// | You should have received a copy of the GNU General Public License |
// | along with this program. If not, see <http://www.gnu.org/licenses/>. |
// +------------------------------------------------------------------------+



// +------------------------------------------------------------------------+
// | View 1 |
// +------------------------------------------------------------------------+
function view1() {
global $cfg, $db, $nav;
authenticate('access_media');

$artist = get('artist');
$genre_id = get('genre_id');
$filter = get('filter');
require_once('include/header.inc.php');


if ($genre_id) {
if (substr($genre_id, -1) == '~') {
$query = mysqli_query($db, 'SELECT artist_alphabetic
FROM album
WHERE genre_id = "' . mysqli_real_escape_string($db,substr($genre_id, 0, -1)) . '"
GROUP BY artist_alphabetic
ORDER BY artist_alphabetic');
}
else {
$query = mysqli_query($db, 'SELECT artist_alphabetic
FROM album
WHERE genre_id LIKE "' . mysqli_real_escape_like($genre_id) . '%"
GROUP BY artist_alphabetic
ORDER BY artist_alphabetic');
}

if (mysqli_num_rows($query) == 1) {
view2();
exit();
}

// require_once('include/header.inc.php');
genreNavigator($genre_id);

$list_url = 'index.php?action=view2&amp;thumbnail=0&amp;genre_id=' . rawurlencode($genre_id) . '&amp;order=artist';
$thumbnail_url = 'index.php?action=view2&amp;thumbnail=1&amp;genre_id=' . rawurlencode($genre_id) . '&amp;order=artist';
}
else {
/* if ($filter == '' || $artist == '') {
$artist = 'All album artists';
$filter = 'all';
} */
$query = '';
if ($filter == 'all') $query = mysqli_query($db, 'SELECT artist FROM track WHERE 1 GROUP BY artist ORDER BY artist');
elseif ($filter == 'exact') $query = mysqli_query($db, 'SELECT artist FROM track WHERE artist = "' . mysqli_real_escape_string($db,$artist) . '" OR artist = "' . mysqli_real_escape_string($db,$artist) . '" GROUP BY artist ORDER BY artist');
elseif ($filter == 'smart') $query = mysqli_query($db, 'SELECT artist FROM track WHERE artist LIKE "%' . mysqli_real_escape_like($artist) . '%" OR artist LIKE "%' . mysqli_real_escape_like($artist) . '%" OR artist SOUNDS LIKE "' . mysqli_real_escape_string($db,$artist) . '" GROUP BY artist ORDER BY artist');
elseif ($filter == 'start') $query = mysqli_query($db, 'SELECT artist FROM track WHERE artist LIKE "' . mysqli_real_escape_like($artist) . '%" GROUP BY artist ORDER BY artist');
elseif ($filter == 'symbol') $query = mysqli_query($db, 'SELECT artist FROM track WHERE artist REGEXP "^[^a-z]" GROUP BY artist ORDER BY artist');
else message(__FILE__, __LINE__, 'error', '[b]Unsupported input value for[/b][br]filter');

if (mysqli_num_rows($query) == 1) {
$album = mysqli_fetch_assoc($query);
$_GET['artist'] = $album['artist'];
$_GET['filter'] = 'exact';
view2();
exit();
}

// formattedNavigator
$nav = array();
$nav['name'][] = 'Library';
$nav['url'][] = 'index.php';
if ($artist != '') $nav['name'][] = 'Artist: ' . $artist;
elseif ($filter == 'symbol') $nav['name'][] = 'Artist: #';
elseif ($filter == 'all') $nav['name'][] = 'All artists';


$list_url = 'index.php?action=view2&amp;thumbnail=0&amp;artist=' . rawurlencode($artist) . '&amp;filter=' . $filter . '&amp;order=artist';
$thumbnail_url = 'index.php?action=view2&amp;thumbnail=1&amp;artist=' . rawurlencode($artist) . '&amp;filter=' . $filter . '&amp;order=artist';
}

if (count($nav['name']) == 1 ) echo '<span class="nav_home"></span>' . "\n";
else {
echo '<span class="nav_tree">' . "\n";
for ($i=0; $i < count($nav['name']); $i++) {
if ($i > 0) echo '<span class="nav_seperation">></span>' . "\n";
if (empty($nav['url'][$i]) == false) echo '<a href="' . $nav['url'][$i] . '">' . html($nav['name'][$i]) . '</a>' . "\n";
else echo html($nav['name'][$i]) . "\n";
}
echo '</span>' . "\n";
}
?>
<table cellspacing="0" cellpadding="0" class="border">
<tr class="header">
<td class="space left"></td>
<td>Artist</td>
<td align="right" class="right">
<?php
$c = mysqli_num_rows($query);
$a = ($c > 1) ? 'artists' : 'artist';
echo ('(' . $c . ' ' . $a . ' found)');
?>
<!--
<a href="<?php echo $list_url; ?>"><img src="<?php echo $cfg['img']; ?>small_header_list.png" alt="" class="small"></a>
-->
&nbsp;
</td>
</tr>

<?php
$i = 0;
while ($album = mysqli_fetch_assoc($query)) {
?>
<tr class="artist_list">
<td></td>
<td>
<?php
$artist = '';
$exploded = multiexplode($cfg['artist_separator'],$album['artist']);
$l = count($exploded);
if ($l > 1) {
for ($j=0; $j<$l; $j++) {
$artist = $artist . '<a href="index.php?action=view2&amp;artist=' . rawurlencode($exploded[$j]) . '">' . html($exploded[$j]) . '</a>';
if ($j != $l - 1) $artist = $artist . '<a href="index.php?action=view2&amp;artist=' . rawurlencode($album['artist']) . '&amp;order=year"><span class="artist_all">&</span></a>';
}
echo $artist;
}
else {
echo '<a href="index.php?action=view2&amp;artist=' . rawurlencode($album['artist']) . '&amp;order=year">' . html($album['artist']) . '</a>';
}
?>

<!--
<a href="index.php?action=view2&amp;artist=<?php echo rawurlencode($album['artist']); ?>"><?php echo html($album['artist']); ?></a>
-->

</td>
<td></td>
</tr>
<?php
}
echo '</table>' . "\n";
require_once('include/footer.inc.php');
}

Loading