当前位置: 首页>>代码示例>>PHP>>正文


PHP template::set_file方法代码示例

本文整理汇总了PHP中template::set_file方法的典型用法代码示例。如果您正苦于以下问题:PHP template::set_file方法的具体用法?PHP template::set_file怎么用?PHP template::set_file使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在template的用法示例。


在下文中一共展示了template::set_file方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: dok_link_song_album

function dok_link_song_album($VARS, $update, $theme_path)
{
    if (!is_numeric($VARS['id']) || $VARS['id'] < 1) {
        $VARS['id'] = 0;
    }
    $res = mysql_query('select * from ' . dok_tn('song') . ' where id = ' . $VARS['id']);
    if (!mysql_numrows($res)) {
        $t = dok_error_template(MSG_ERR_SONG_NOT_FOUND);
        return array($t, MSG_TITLE_ADD_SONG_ALBUM);
    }
    $song = mysql_fetch_array($res);
    /**	$res = dok_oquery('select distinct(album_id) as aid from '.dok_tn('rel_song_album').' where song_id = '.$song['id']);
    	$current_albums = $res->fetch_col_array('aid');
    	$where = '';
    	if ( sizeof($current_albums) )	$where = ' where id not in('.implode(',',$current_albums).')';*/
    $where = '';
    $res = mysql_query('select id, name from ' . dok_tn('album') . $where . ' order by name');
    $a_select = '';
    while ($row = mysql_fetch_array($res)) {
        $a_select .= '<option value="' . $row['id'] . '"';
        if ($_SESSION['song_select_album'] == $row['id']) {
            $a_select .= ' selected';
        }
        $a_select .= '>' . $row['name'] . '</option>';
    }
    $t = new template($theme_path);
    $t->set_file('page', 'song_album_link.tpl');
    $t->set_var(dok_song_format($song));
    $t->set_var('ALBUM_SELECT', $a_select);
    $t->set_var('SONG_ID', $song['id']);
    return array($t, MSG_TITLE_ADD_SONG_ALBUM);
}
开发者ID:BackupTheBerlios,项目名称:diskotek,代码行数:32,代码来源:link_song_album.php

示例2: dok_box_ranked

function dok_box_ranked($display_module, $theme_path)
{
    if (DOK_USE_CACHE) {
        $fname = dok_c_box_filename('ranked', 'ignored');
        $cache = dok_c_get($fname);
        if ($cache) {
            return $cache;
        }
    }
    $res = mysql_query('select name, id from ' . dok_tn('song') . ' order by hits desc limit 10');
    echo mysql_error();
    if (!mysql_numrows($res)) {
        return;
    }
    $t = new template($theme_path);
    $t->set_file('page', 'box_default.tpl');
    $t->set_var('BOXTITLE', MSG_TITLE_BOX_RANKED_SONG);
    $t->set_block('page', 'boxlink', 'boxlinktag');
    $t->set_var('boxlinktag', '');
    if (!mysql_numrows($res)) {
        $t->set_var('BOXCONTENT', '');
    }
    while ($row = mysql_fetch_array($res)) {
        $t->set_var('LINK', $_SERVER['PHP_SELF'] . '?display=view_song&id=' . $row['id']);
        $t->set_var('LABEL', $row['name']);
        $t->parse('BOXCONTENT', 'boxlink', 'true');
    }
    $html = $t->parse('out', 'page');
    if (DOK_USE_CACHE) {
        dok_c_write($fname, $html);
    }
    return $html;
}
开发者ID:BackupTheBerlios,项目名称:diskotek,代码行数:33,代码来源:box_ranked.php

示例3: dok_homepage

function dok_homepage($vars, $update_mod, $theme_path)
{
    $t = new template($theme_path);
    $t->set_file('page', 'homepage.tpl');
    $t->set_var(array('TOTAL_SONGS' => dok_songs_nb(), 'TOTAL_ARTISTS' => dok_artists_nb(), 'TOTAL_ALBUMS' => dok_albums_nb()));
    return array($t, 'Homepage');
}
开发者ID:BackupTheBerlios,项目名称:diskotek,代码行数:7,代码来源:homepage.php

示例4: dok_list_users

function dok_list_users($VARS, $up, $theme_path)
{
    $t = new template($theme_path);
    $t->set_file('page', 'user_list.tpl');
    $t->set_block('page', 'user', 'user_block');
    $t->set_block('page', 'next_page', 'next_page_block');
    if (!isset($VARS['alpha'])) {
        $VARS['alpha'] = '-';
    }
    if (!strlen($VARS['offset']) || $VARS['offset'] < 0) {
        $VARS['offset'] = '0';
    }
    $VARS['alpha'] = mysql_real_escape_string($VARS['alpha']);
    $query = 'select id, name, editor, admin, disabled, creation, last_login from ' . dok_tn('user') . ' where substring(name from 1 for 1) >= \'' . $VARS['alpha'] . '\' order by name limit ' . $VARS['offset'] . ', ' . DOK_LIST_EPP;
    $res = dok_oquery($query);
    if ($res->numrows()) {
        //$ids = $res->fetch_col_array('id');
        //$n_res = dok_oquery('select album_id, count(*) as c from '.dok_tn('rel_song_album').' where album_id in('.implode(',',$ids).') group by album_id');
        //$n_array = $n_res->fetch_col_array('c','album_id');
        while ($user = $res->fetch_array()) {
            if ($user['admin']) {
                $admin = MSG_YES;
            } else {
                $admin = MSG_NO;
            }
            if ($user['editor']) {
                $editor = MSG_YES;
            } else {
                $editor = MSG_NO;
            }
            if ($user['disabled']) {
                $disabled = MSG_YES;
            } else {
                $disabled = MSG_NO;
            }
            if ($user['last_login'] == 0) {
                $last_login = MSG_USER_NEVER_LOGGED;
            } else {
                $last_login = date($THEME_DATE, $user['last_login']);
            }
            $t->set_var('USER_LINK', $_SERVER['PHP_SELF'] . '?display=view_user&id=' . $user['id']);
            $t->set_var(array('USER_NAME' => $user['name'], 'USER_DB_CREATION' => date($THEME_DATE, $user['creation']), 'USER_LAST_LOGIN' => $last_login, 'USER_ADMIN' => $admin, 'USER_EDITOR' => $editor, 'USER_DISABLED' => $disabled));
            $t->parse('user_block', 'user', 'true');
        }
        $res = mysql_query('select count(*) as c from ' . dok_tn('user') . ' where substring(name from 1 for 1) >= \'' . $VARS['alpha'] . '\'');
        $total = mysql_result($res, 0, 'c');
        if ($total > $VARS['offset'] + DOK_LIST_EPP) {
            $t->set_var('NEXT_PAGE_LINK', $_SERVER['PHP_SELF'] . '?display=list_users&alpha=' . $VARS['alpha'] . '&offset=' . ($VARS['offset'] + DOK_LIST_EPP));
            $t->parse('next_page_block', 'next_page');
        } else {
            $t->set_var('next_page_block', '');
        }
    } else {
        $t->set_var('user_block', MSG_NO_USER);
        $t->set_var('next_page_block', '');
    }
    return array($t, MSG_TITLE_LIST_USER);
}
开发者ID:BackupTheBerlios,项目名称:diskotek,代码行数:58,代码来源:list_users.php

示例5: dok_ask_sound_artist

function dok_ask_sound_artist($VARS, $update, $theme_path)
{
    if (!is_array($VARS['soundex']) || !sizeof($VARS['soundex'])) {
        $t = dok_error_template(MSG_ERR_ARTIST_NOT_FOUND);
        return array($t, MSG_TITLE_SOUNDEX_TEST);
    }
    $t = new template($theme_path);
    $t->set_file('page', 'artist_soundex.tpl');
    $t->set_block('page', 'artists', 'artists_block');
    $t->set_var('NEW_ARTIST_NAME', $VARS['name']);
    $t->set_var('ARTIST_CREATE_FORM', '<form method="post" action="' . $_SERVER['PHP_SELF'] . '"><input type=hidden name="update" value="create_artist"><input type=hidden name="soundex_checked" value="1"><input type=hidden name="name" value="' . str_replace('"', '&quot;', $VARS['name']) . '">');
    foreach ($VARS['soundex'] as $id => $name) {
        $t->set_var('ARTIST_NAME', $name);
        $t->parse('artists_block', 'artists', 'true');
    }
    return array($t, MSG_TITLE_SOUNDEX_TEST);
}
开发者ID:BackupTheBerlios,项目名称:diskotek,代码行数:17,代码来源:ask_sound_artist.php

示例6: dok_edit_album

function dok_edit_album($VARS, $update_module, $theme_path)
{
    if (!$VARS['id'] || !is_numeric($VARS['id']) || $VARS['id'] < 1) {
        $t = dok_error_template(MSG_ERR_ALBUM_NOT_FOUND);
        return array($t, sprintf(MSG_TITLE_EDIT_ALBUM, MSG_UNKNOWN));
    }
    $res = mysql_query('select * from ' . dok_tn('album') . ' where id = ' . $VARS['id']);
    if (!mysql_numrows($res)) {
        $t = dok_error_template(MSG_ERR_ALBUM_NOT_FOUND);
        return array($t, sprintf(MSG_TITLE_EDIT_ALBUM, MSG_UNKNOWN));
    }
    $row = mysql_fetch_array($res);
    $t = new template($theme_path);
    $t->set_file('page', 'album_edit.tpl');
    $t->set_var(array('ALBUM_ID' => $row['id'], 'ALBUM_NAME' => $row['name'], 'ALBUM_NAME_TF' => str_replace('"', '&quot;', $row['name'])));
    return array($t, sprintf(MSG_TITLE_EDIT_ALBUM, $row['name']));
}
开发者ID:BackupTheBerlios,项目名称:diskotek,代码行数:17,代码来源:edit_album.php

示例7: dok_view_user

function dok_view_user($VARS, $update, $theme_path)
{
    global $USER, $THEME_DATE;
    if (!isset($VARS['id']) || !is_numeric($VARS['id']) || $VARS['id'] < 1) {
        $t = dok_error_template(MSG_ERR_USER_DISPLAY);
        return array($t, sprintf(MSG_TITLE_DISLAY_USER, ''));
    }
    $res = mysql_query('select * from ' . dok_tn('user') . ' where id = ' . $VARS['id']);
    if (!mysql_numrows($res)) {
        $t = dok_error_template(MSG_ERR_USER_DISPLAY);
        return array($t, sprintf(MSG_TITLE_DISPLAY_USER, ''));
    }
    $user = mysql_fetch_array($res);
    $t = new template($theme_path);
    $t->set_file('page', 'user_display.tpl');
    $t->set_block('page', 'if_could_edit', 'if_could_edit_block');
    if (DOK_ENABLE_USER && ($USER->admin || $USER->id == $user['id']) || !DOK_ENABLE_USER) {
        $t->parse('if_could_edit_block', 'if_could_edit');
    } else {
        $t->set_var('if_could_edit_block', '');
    }
    if ($user['admin']) {
        $admin = MSG_YES;
    } else {
        $admin = MSG_NO;
    }
    if ($user['editor']) {
        $editor = MSG_YES;
    } else {
        $editor = MSG_NO;
    }
    if ($user['disabled']) {
        $disabled = MSG_YES;
    } else {
        $disabled = MSG_NO;
    }
    if ($user['last_login'] == 0) {
        $last_login = MSG_USER_NEVER_LOGGED;
    } else {
        $last_login = date($THEME_DATE, $user['last_login']);
    }
    $t->set_var(array('USER_NAME' => $user['name'], 'USER_DB_CREATION' => date($THEME_DATE, $user['creation']), 'USER_LAST_LOGIN' => $last_login, 'USER_ADMIN' => $admin, 'USER_EDITOR' => $editor, 'USER_DISABLED' => $disabled, 'USER_EDIT_LINK' => $_SERVER['PHP_SELF'] . '?display=edit_user&id=' . $user['id']));
    return array($t, sprintf(MSG_TITLE_DISPLAY_USER, $user['name']));
}
开发者ID:BackupTheBerlios,项目名称:diskotek,代码行数:44,代码来源:view_user.php

示例8: dok_view_album

function dok_view_album($VARS, $update_module, $tpl_path)
{
    global $THEME_DATE, $ARTIST_SONG_LINKS, $USER;
    if (!isset($VARS['id']) || !is_numeric($VARS['id']) || $VARS['id'] < 1) {
        $t = dok_error_template(MSG_ERR_ALBUM_DISPLAY);
        return array($t, sprintf(MSG_TITLE_DISPLAY_ALBUM, ''));
    }
    $res = mysql_query('select name, creation from ' . dok_tn('album') . ' where id = ' . $VARS['id']);
    if (!mysql_numrows($res)) {
        $t = dok_error_template(MSG_ERR_ALBUM_DISPLAY);
        return array($t, sprintf(MSG_TITLE_DISPLAY_ALBUM, ''));
    }
    $row = mysql_fetch_assoc($res);
    $t = new template($tpl_path);
    $t->set_file('page', 'album_display.tpl');
    $t->set_block('page', 'if_albumeditor', 'editor_block');
    $t->set_block('page', 'album_songs', 'songs_block');
    $t->set_var(array('ALBUM_NAME' => $row['name'], 'ALBUM_DB_CREATION' => date($THEME_DATE, $row['creation'])));
    if (DOK_ENABLE_USER && !$USER->editor && !$USER->admin) {
        $t->set_var('editor_block', '');
    } else {
        $t->set_var('ALBUM_EDIT_LINK', $_SERVER['PHP_SELF'] . '?display=edit_album&id=' . $VARS['id']);
        $t->parse('editor_block', 'if_albumeditor');
    }
    $query = 'select s.id, s.name, s.creation, s.length, s.release, s.comment, r.track from ' . dok_tn('rel_song_album') . ' as r left join ' . dok_tn('song') . ' as s on r.song_id = s.id where r.album_id = ' . $VARS['id'] . ' order by r.track';
    $songs = dok_oquery($query);
    $album_length = 0;
    if (!$songs->numrows()) {
        $t->set_var('songs_block', MSG_NO_SONG);
    } else {
        $pager_data = array('related' => 'album', 'related_id' => $VARS['id']);
        while ($song = $songs->fetch_array()) {
            $song_data = dok_song_format($song, $pager_data);
            $song_data['SONG_ARTIST'] = preg_replace('/^' . $ARTIST_SONG_LINKS[0] . '/', '', $song_data['SONG_ARTIST']);
            $t->set_var($song_data);
            $t->set_var('SONG_TRACK', $song['track']);
            $t->parse('songs_block', 'album_songs', 'true');
            $album_length += $song['length'];
        }
    }
    $t->set_var('ALBUM_LENGTH', dok_sec2str($album_length));
    $t->set_var('ALBUM_SONGS', $songs->numrows());
    return array($t, sprintf(MSG_TITLE_DISPLAY_ALBUM, $row['name']));
}
开发者ID:BackupTheBerlios,项目名称:diskotek,代码行数:44,代码来源:view_album.php

示例9: dok_edit_user

function dok_edit_user($VARS, $update_module, $theme_path)
{
    global $USER;
    if (!$VARS['id'] || !is_numeric($VARS['id']) || $VARS['id'] < 1) {
        $t = dok_error_template(MSG_ERR_USER_NOT_FOUND);
        return array($t, sprintf(MSG_TITLE_EDIT_USER, MSG_UNKNOWN));
    }
    $res = mysql_query('select * from ' . dok_tn('user') . ' where id = ' . $VARS['id']);
    if (!mysql_numrows($res)) {
        $t = dok_error_template(MSG_ERR_USER_NOT_FOUND);
        return array($t, sprintf(MSG_TITLE_EDIT_USER, MSG_UNKNOWN));
    }
    $row = mysql_fetch_array($res);
    if (DOK_ENABLE_USER && (!$USER->admin && $USER->id != $row['id'])) {
        $t = dok_error_template(MSG_ERR_USER_EDITION_NOT_ALLOWED);
        return array($t, sprintf(MSG_TITLE_EDIT_USER, MSG_UNKNOWN));
    }
    $t = new template($theme_path);
    $editor_cb = '<input type="checkbox" name="editor" value="1"';
    if ($row['editor']) {
        $editor_cb .= ' CHECKED';
    }
    $editor_cb .= '>';
    $admin_cb = '<input type="checkbox" name="admin" value="1"';
    if ($row['admin']) {
        $admin_cb .= ' CHECKED';
    }
    $admin_cb .= '>';
    $disabled_cb = '<input type="checkbox" name="disabled" value="1"';
    if ($row['disabled']) {
        $disabled_cb .= ' CHECKED';
    }
    $disabled_cb .= '>';
    $t->set_file('page', 'user_edit.tpl');
    $t->set_block('page', 'if_admin', 'if_admin_block');
    if (!DOK_ENABLE_USER || $USER->admin) {
        $t->parse('if_admin_block', 'if_admin');
    } else {
        $t->set_var('if_admin_block', '');
    }
    $t->set_var(array('USER_ID' => $row['id'], 'USER_NAME' => $row['name'], 'USER_NAME_TF' => str_replace('"', '&quot;', $row['name']), 'USER_EDITOR_CB' => $editor_cb, 'USER_DISABLED_CB' => $disabled_cb, 'USER_ADMIN_CB' => $admin_cb));
    return array($t, sprintf(MSG_TITLE_EDIT_USER, $row['name']));
}
开发者ID:BackupTheBerlios,项目名称:diskotek,代码行数:43,代码来源:edit_user.php

示例10: dok_error_template

/**
*returns a template object filled with the default error page
*
*@param string $error_message the message to display on the error page
*@return template error template
*/
function dok_error_template($error_message)
{
    global $DOK_THEME_PATH;
    $t = new template($DOK_THEME_PATH);
    $t->set_file('page', 'error.tpl');
    $t->set_var('ERROR_MESSAGE', $error_message);
    return $t;
}
开发者ID:BackupTheBerlios,项目名称:diskotek,代码行数:14,代码来源:utils.php

示例11: dok_login

function dok_login($a, $b, $theme_path)
{
    $t = new template($theme_path);
    $t->set_file('page', 'login.tpl');
    return array($t, MSG_TITLE_LOGIN);
}
开发者ID:BackupTheBerlios,项目名称:diskotek,代码行数:6,代码来源:login.php

示例12: dok_list_artists

function dok_list_artists($VARS, $up, $theme_path)
{
    $orders = array('count', 'length', 'albums');
    $t = new template($theme_path);
    $t->set_file('page', 'artist_list.tpl');
    $t->set_block('page', 'artist', 'artist_block');
    $t->set_block('page', 'next_page', 'next_page_block');
    if (!isset($VARS['alpha'])) {
        $VARS['alpha'] = '-';
    }
    $VARS['alpha'] = mysql_real_escape_string($VARS['alpha']);
    if (isset($VARS['sort']) && !in_array($VARS['sort'], $orders)) {
        unset($VARS['sort']);
    }
    if (!strlen($VARS['offset']) || $VARS['offset'] < 0) {
        $VARS['offset'] = '0';
    }
    $display = array();
    // here we do 2 queries: it's better than 1 for mysql
    if (isset($VARS['sort'])) {
        $my_display = array();
        $query = "select r.artist_id as id, count(distinct r.song_id) as count, sum(s.length) as length, count(distinct al.album_id) as albums from " . dok_tn("rel_song_artist") . ' as r left join ' . dok_tn('song') . ' as s on r.song_id=s.id left join ' . dok_tn('rel_song_album') . ' as al on r.song_id=al.song_id group by r.artist_id order by ' . $VARS['sort'] . ' desc limit ' . $VARS['offset'] . ', ' . DOK_LIST_EPP;
        //echo $query;
        $res = dok_oquery($query);
        while ($row = $res->fetch_array()) {
            $my_display[$row['id']] = array('id' => $row['id'], 'count' => $row['count'], 'length' => $row['length'], 'albums' => $row['albums']);
        }
        if (sizeof($my_display)) {
            $query = 'select name,id from ' . dok_tn('artist') . ' where id in(' . implode(', ', array_keys($my_display)) . ')';
            $res = dok_oquery($query);
            while ($row = $res->fetch_array()) {
                $my_display[$row['id']]['name'] = $row['name'];
            }
            foreach ($my_display as $one) {
                $display[] = $one;
            }
        }
    } else {
        $my_display = array();
        $query = 'select name,id from ' . dok_tn('artist') . ' where LEFT(name,1) >= \'' . $VARS['alpha'] . '\' order by name limit ' . $VARS['offset'] . ', ' . DOK_LIST_EPP;
        $res = dok_oquery($query);
        while ($row = $res->fetch_array()) {
            $my_display[$row['id']] = array('name' => $row['name'], 'id' => $row['id']);
        }
        if (sizeof($my_display)) {
            $query = "select r.artist_id as id, count(DISTINCT r.song_id) as count, sum(s.length) as length, count(distinct al.album_id) as albums  from " . dok_tn("rel_song_artist") . ' as r left join ' . dok_tn('song') . ' as s on r.song_id=s.id left join ' . dok_tn('rel_song_album') . ' as al on r.song_id=al.song_id where r.artist_id in(' . implode(', ', array_keys($my_display)) . ') group by r.artist_id';
            $res = dok_oquery($query);
            while ($row = $res->fetch_array()) {
                $my_display[$row['id']]['count'] = $row['count'];
                $my_display[$row['id']]['length'] = $row['length'];
                $my_display[$row['id']]['albums'] = $row['albums'];
            }
            foreach ($my_display as $one) {
                $display[] = $one;
            }
        }
    }
    if (sizeof($display)) {
        $display_first = $VARS['offset'] + 1;
        $display_last = $display_first - 1;
        foreach ($display as $row) {
            $t->set_var('ARTIST_LINK', $_SERVER['PHP_SELF'] . '?display=view_artist&id=' . $row['id']);
            $t->set_var('ARTIST_NAME', $row['name']);
            $t->set_var('ARTIST_SONGS', $row['count']);
            $t->set_var('ARTIST_ALBUMS', $row['albums']);
            $t->set_var('ARTIST_LENGTH', dok_sec2str($row['length']));
            $t->parse('artist_block', 'artist', 'true');
            $display_last++;
        }
        if (isset($VARS['sort'])) {
            $t_query = 'select count(*) as c from ' . dok_tn('rel_song_artist') . ' as r group by r.artist_id';
        } else {
            $t_query = 'select id from ' . dok_tn('artist') . ' where LEFT(name,1) >= \'' . $VARS['alpha'] . '\'';
            //$t_query='select count(*) as c from '.dok_tn('rel_song_artist').' as r left join '.dok_tn('artist').' as a on r.artist_id = a.id where substring(a.name from 1 for 1) >= \''.$VARS['alpha'].'\' group by r.artist_id';
            //echo $t_query;
        }
        $res = mysql_query($t_query);
        $total = mysql_numrows($res);
        if ($total > $VARS['offset'] + DOK_LIST_EPP) {
            $t->set_var('NEXT_PAGE_LINK', $_SERVER['PHP_SELF'] . '?display=list_artists&alpha=' . $VARS['alpha'] . '&offset=' . ($VARS['offset'] + DOK_LIST_EPP) . '&sort=' . $VARS['sort']);
            $t->parse('next_page_block', 'next_page');
        } else {
            $t->set_var('next_page_block', '');
        }
    } else {
        $t->set_var('artist_block', MSG_NO_ARTIST);
        $t->set_var('next_page_block', '');
    }
    return array($t, MSG_TITLE_LIST_ARTIST);
}
开发者ID:BackupTheBerlios,项目名称:diskotek,代码行数:90,代码来源:list_artists.php

示例13: dok_new_album

function dok_new_album($VARS, $update_module, $theme_path)
{
    $t = new template($theme_path);
    $t->set_file('page', 'album_new.tpl');
    return array($t, MSG_TITLE_NEW_ALBUM);
}
开发者ID:BackupTheBerlios,项目名称:diskotek,代码行数:6,代码来源:new_album.php

示例14: dok_new_song

function dok_new_song($VARS, $update_module, $theme_path)
{
    global $SONGS_LABELS;
    $albums = dok_albums_list();
    if (!sizeof($albums)) {
        $t = dok_error_template(MSG_ERR_NO_ALBUM);
        return array($t, MSG_TITLE_NEW_SONG);
    }
    $artists = dok_artists_list();
    if (!sizeof($artists)) {
        $t = dok_error_template(MSG_ERR_NO_ARTIST);
        return array($t, MSG_TITLE_NEW_SONG);
    }
    $album_select = '';
    foreach ($albums as $id => $vars) {
        $album_select .= '<option value="' . $id . '"';
        if ($_SESSION['song_select_album'] == $id) {
            $album_select .= ' selected';
        }
        $album_select .= '>' . $vars['name'] . '</option>' . "\n";
    }
    $artist_select = '';
    if (!DOK_USE_HTML4) {
        foreach ($artists as $id => $vars) {
            $artist_select .= '<option value="' . $id . '"';
            if ($_SESSION['song_select_artist'] == $id) {
                $artist_select .= ' selected';
            }
            $artist_select .= '>' . $vars['name'] . '</option>' . "\n";
        }
    } else {
        $current_letter = '';
        foreach ($artists as $id => $vars) {
            $c_letter = substr($vars['name'], 0, 1);
            if ($c_letter != $current_letter) {
                if (strlen($current_letter)) {
                    $artist_select .= '</optgroup>';
                }
                $artist_select .= '<OPTGROUP label="' . $c_letter . '">';
                $current_letter = $c_letter;
            }
            $artist_select .= '<option value="' . $id . '"';
            if ($_SESSION['song_select_artist'] == $id) {
                $artist_select .= ' selected';
            }
            $artist_select .= '>' . $vars['name'] . '</option>' . "\n";
        }
        if (strlen($current_letter)) {
            $artist_select .= '</optgroup>';
        }
    }
    if (isset($_SESSION['song_select_genre']) && is_numeric($_SESSION['song_select_genre']) && $_SESSION['song_select_genre'] >= 0) {
        $genre_select = dok_get_genre_select('genre', $_SESSION['song_select_genre']);
    } else {
        $genre_select = dok_get_genre_select('genre');
    }
    $next_radio = '<input type=radio name="album_track" value="next"';
    if ($_SESSION['album_track'] != 'text') {
        $next_radio .= 'checked';
    }
    $next_radio .= '>';
    $text_radio = '<input type=radio name="album_track" value="text"';
    if ($_SESSION['album_track'] == 'text') {
        $text_radio .= 'checked';
    }
    $text_radio .= '>';
    $label_select = '<option value="" SELECTED>' . MSG_LABEL_NONE . '</option>';
    foreach ($SONGS_LABELS as $key => $val) {
        if (is_numeric($key) && $key > 0) {
            $label_select .= '<option value="' . $key . '">' . $val['label'] . '</option>' . "\n";
        }
    }
    $t = new template($theme_path);
    $t->set_file('page', 'song_new.tpl');
    $t->set_var(array('ARTISTS_SELECT' => $artist_select, 'ALBUMS_SELECT' => $album_select, 'GENRES_SELECT' => $genre_select, 'LABELS_SELECT' => $label_select, 'TRACK_NEXT_RADIO' => $next_radio, 'TRACK_TEXT_RADIO' => $text_radio));
    return array($t, MSG_TITLE_NEW_SONG);
}
开发者ID:BackupTheBerlios,项目名称:diskotek,代码行数:77,代码来源:new_song.php

示例15: dok_list_full

function dok_list_full($VARS, $up, $theme_path)
{
    global $THEME_FULL_LIST_COLUMN;
    $t = new template($theme_path);
    $t->set_file('page', 'full_list.tpl');
    $t->set_block('page', 'element_letter', 'element_letter_block');
    $t->set_block('page', 'element', 'element_block');
    $t->set_block('page', 'next_block', 'next_block_block');
    $t->set_var('element_letter_block', '');
    $t->set_var('next_block_block', '');
    if (!isset($VARS['element']) || !in_array($VARS['element'], array('artist', 'song', 'album', 'user'))) {
        $VARS['element'] = 'song';
    }
    if ($VARS['element'] == 'album') {
        $msg = MSG_NO_ALBUM;
        $element_name = MSG_ALBUMS;
    } elseif ($VARS['element'] == 'artist') {
        $msg = MSG_NO_ARTIST;
        $element_name = MSG_ARTISTS;
    } elseif ($VARS['element'] == 'user') {
        $msg = MSG_NO_USER;
        $element_name = MSG_USERS;
    } else {
        $msg = MSG_NO_SONG;
        $element_name = MSG_SONGS;
    }
    $t->set_var('LIST_ELEMENT_NAME', $element_name);
    $where = '';
    if (($VARS['element'] == 'album' || $VARS['element'] == 'song') && isset($VARS['artist_id']) && is_numeric($VARS['artist_id']) && $VARS['artist_id'] > 0) {
        $res = mysql_query('select name from ' . dok_tn('artist') . ' where id = ' . $VARS['artist_id']);
        if (mysql_numrows($res)) {
            $row = mysql_fetch_array($res);
            $t->set_var('ARTIST_NAME', $row['name']);
            $t->set_var('ARTIST_LINK', $_SERVER['PHP_SELF'] . '?display=view_artist&id=' . $VARS['artist_id']);
            if ($VARS['element'] == 'song') {
                $where = 'left join ' . dok_tn('rel_song_artist') . ' as r on a.id=r.song_id where r.artist_id = ' . $VARS['artist_id'];
            } else {
                $where = 'left join ' . dok_tn('rel_song_album') . ' as r on a.id=r.album_id left join ' . dok_tn('rel_song_artist') . ' as r2 on r.song_id=r2.song_id  where r2.artist_id = ' . $VARS['artist_id'] . ' group by a.id';
            }
        }
    } else {
        $t->set_var('ARTIST_NAME', '');
        $t->set_var('ARTIST_LINK', $_SERVER['PHP_SELF']);
    }
    $query = 'select a.id, a.name, substring(a.name from 1 for 1) as letter from ' . dok_tn($VARS['element']) . ' as a ' . $where . ' order by a.name';
    //echo $query.'<BR>';
    $res = dok_oquery($query);
    //echo mysql_error();
    if ($res->numrows()) {
        $letter = false;
        $count = -1;
        $div = 1;
        if ($res->numrows() <= reset($THEME_FULL_LIST_COLUMN)) {
            $el_per_block = $res->numrows();
            $div = 1;
        } elseif ($res->numrows() >= end($THEME_FULL_LIST_COLUMN)) {
            $div = key($THEME_FULL_LIST_COLUMN);
            $el_per_block = ceil($res->numrows() / $div);
        } else {
            $ak = array_keys($THEME_FULL_LIST_COLUMN);
            $i = 1;
            foreach ($THEME_FULL_LIST_COLUMN as $key => $val) {
                if ($res->numrows() >= $val && $res->numrows() <= $THEME_FULL_LIST_COLUMN[$ak[$i]]) {
                    $div = $key;
                    $el_per_block = ceil($res->numrows() / $key);
                    break;
                }
                $i++;
            }
        }
        $t->set_var('BLOCK_PERCENT', (int) (100 / $div));
        //if ( $res->numrows() < $THEME_FULL_LIST_COLUMN[0] && $res->numrows() < $THEME_FULL_LIST_COLUMN[0]
        //$el_per_block = ceil($res->numrows() /3);
        while ($row = $res->fetch_array()) {
            $count++;
            if ($count && !($count % $el_per_block)) {
                $t->parse('element_block', 'next_block', 'true');
            }
            if (!$letter || $letter != $row['letter']) {
                $letter = $row['letter'];
                $t->set_var('LIST_LETTER', strtoupper($letter));
                $t->parse('element_block', 'element_letter', 'true');
            }
            $t->set_var('LIST_LINK', $_SERVER['PHP_SELF'] . '?display=view_' . $VARS['element'] . '&id=' . $row['id']);
            $t->set_var('LIST_NAME', $row['name']);
            $t->parse('element_block', 'element', 'true');
        }
    } else {
        $t->set_var('element_block', $msg);
    }
    return array($t, $element_name . MSG_TITLE_LIST_FULL);
}
开发者ID:BackupTheBerlios,项目名称:diskotek,代码行数:92,代码来源:list_full.php


注:本文中的template::set_file方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。