本文整理汇总了PHP中pagination::currentPage方法的典型用法代码示例。如果您正苦于以下问题:PHP pagination::currentPage方法的具体用法?PHP pagination::currentPage怎么用?PHP pagination::currentPage使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pagination
的用法示例。
在下文中一共展示了pagination::currentPage方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: pagination
public function pagination()
{
$string = $_SERVER["REQUEST_URI"];
$pattern = "/(&page=[0-9]+)/i";
$replacement = "";
$target = preg_replace("/([&?]+page=[0-9]+)/i", "", $_SERVER["REQUEST_URI"]);
$this->load->library("pagination");
$page = new pagination();
$page->target($target);
@$page->limit($this->paged->page_size);
@$page->currentPage($this->paged->current_page);
@$page->Items($this->paged->total_rows);
return $page->show();
}
示例2: pagination
function pagination()
{
$string = $_SERVER['REQUEST_URI'];
$pattern = '/(&page=[0-9]+)/i';
$replacement = '';
$target = preg_replace('/([&?]+page=[0-9]+)/i', '', $_SERVER['REQUEST_URI']);
$this->load->library('pagination');
$page = new pagination();
$page->target($target);
$page->limit($this->paged->page_size);
@$page->currentPage($this->paged->current_page);
$page->Items($this->paged->total_rows);
return $page->show();
}
示例3: WassUp
//.........这里部分代码省略.........
<li><span><?php echo @number_format(($pagestot/$itemstot), 2); ?></span> <small><?php _e('Pages/Visits','wassup'); ?></small></li>
<?php // Print spam usage only if enabled
if ($wassup_options->wassup_spamcheck == 1) { ?>
<li><span><a href="#TB_inline?height=180&width=300&inlineId=hiddenspam" class="thickbox"><?php echo $spamtot; ?></a></span> <span>(<?php echo @number_format(($spamtot*100/$pagestot), 2); ?>%)</span> <small><?php _e('Spams','wassup'); ?></small></li>
<?php } ?>
</ul>
<?php
// Print the Google chart!
if ($pagestot > 20) {
echo $Tot->TheChart($last, $res, "125", $search, $wassup_options->wassup_chart_type, "bg,s,ffffff")."";
} else {
echo '<div id="placeholder" align="center"><p style="padding-top:50px;">'.__('Too few records to print chart','wassup').'...</p></div>';
} ?>
</div>
</div>
<?php } //end if wassup_chart == 1
if (!isset($_GET['limit']) OR $_GET['limit'] == 10 OR $_GET['limit'] == 20) {
$expcol = '
<table width="100%"><tr>
<td align="left" class="legend"><a href="#" class="toggle-all">'.__('Expand All','wassup').'</a></td>
<td align="right" class="legend"><a href="#" class="toggle-allcrono">'.__('Collapse Chronology','wassup').'</a></td>
</tr></table><br />';
}
// MAIN QUERY
$main = $Tot->calc_tot("main", $search);
if ($itemstot > 0) {
$p=new pagination();
$p->items($itemstot);
$p->limit($items);
$p->currentPage($pages);
$p->target("admin.php?page=".WASSUPFOLDER."&limit=$items&type=$type&last=$last&search=$search");
$p->calculate();
$p->adjacents(5);
}
// hidden spam options
?>
<div id="hiddenspam" style="display:none;">
<h2><?php _e('Spam Options','wassup'); ?></h2>
<form action="" method="post">
<p><input type="checkbox" name="wassup_spamcheck" value="1" <?php if($wassup_options->wassup_spamcheck == 1 ) print "CHECKED"; ?> /> <strong><?php _e('Enable/Disable Spam Check on Records','wassup'); ?></strong></p>
<p style="padding-left:30px;"><input type="checkbox" name="wassup_spam" value="1" <?php if($wassup_options->wassup_spam == 1) print "CHECKED"; ?> /> <?php _e('Record Akismet comment spam attempts','wassup'); ?></p>
<p style="padding-left:30px;"><input type="checkbox" name="wassup_refspam" value="1" <?php if($wassup_options->wassup_refspam == 1) print "CHECKED"; ?> /> <?php _e('Record referrer spam attempts','wassup'); ?></p>
<p style="padding-left:0;"><input type="submit" name="submit-spam" value="<?php _e('Save Settings','wassup'); ?>" /></p>
</form>
</div>
<table width="100%">
<tr>
<td align="left" class="legend">
<?php
// Marked items - Refresh
if ($wassup_options->wmark == 1) echo '<a href="?'.$_SERVER['QUERY_STRING'].'&search='.$wassup_options->wip.'" title="'.__('Filter by marked IP','wassup').'"><strong>'.$markedtot.'</strong> '.__('show marked items','wassup').'</a> - ';
if (!empty($search)) print "<strong>$searchtot</strong> ".__('Searched for','wassup').": <strong>$search</strong> - ";
echo __('Auto refresh in','wassup').' <span id="CountDownPanel"></span> '.__('seconds','wassup'); ?>
</td>
<td align="right" class="legend"><a href="<?php echo $wpurl.'/wp-content/plugins/'.WASSUPFOLDER.'/lib/action.php?action=topten&whash='.$whash.'&from_date='.$from_date.'&to_date='.$to_date.'&width='.$res.'&height=400'; ?>" class="thickbox" title="Wassup <?php _e('Top Ten','wassup'); ?>"><?php _e('Show Top Ten','wassup'); ?></a> - <a href="#" class='show-search'><?php _e('Search','wassup'); ?></a></td>
</tr>
</table>
<div class="search-ip" style="display: none;">
<table border=0 width="100%">
<tr valign="top">
<td align="right">
示例4: get
function get($sql = FALSE, $noSplitPage = FALSE)
{
$sql = $sql ? $sql : 'select ' . $this->select . ' from ' . $this->table . ' ' . $this->join . ' ' . $this->where . ' ' . $this->sort . ' ' . $this->order;
//$sql = iconv('UTF-8','TIS-620',$sql);
if ($noSplitPage == FALSE) {
$this->load->library('pagination');
$page = new pagination();
$page->target($this->target);
$page->limit($this->limit);
@$page->currentPage($this->current_page);
$rs = $this->db->PageExecute($sql, $page->limit, $page->page);
$page->Items($rs->_maxRecordCount);
$this->pagination = $page->show();
} else {
$rs = $this->db->Execute($sql);
}
$this->free_result();
$data = $rs->GetArray();
///array_walk($data,'dbConvert');
return $data;
}
示例5: url
//.........这里部分代码省略.........
</div>
</div>
<p class="submit">
<input type="submit" name="Submit" class="button-primary" value="<?php
esc_attr_e('Save Changes', 'woocommerce-ac');
?>
" />
</p>
</form>
</div>
<?php
} elseif ($action == 'listcart' || $action == '') {
?>
<p> <?php
_e('The list below shows all Abandoned Carts which have remained in cart for a time higher than the "Cart abandoned cut-off time" setting.', 'woocommerce-ac');
?>
</p>
<?php
//echo plugins_url();
include_once "pagination.class.php";
/* Find the number of rows returned from a query; Note: Do NOT use a LIMIT clause in this query */
$wpdb->get_results("SELECT wpac . * , wpu.user_login, wpu.user_email \n\t\t\t\t\t FROM `" . $wpdb->prefix . "ac_abandoned_cart_history` AS wpac \n\t\t\t\t\t LEFT JOIN " . $wpdb->prefix . "users AS wpu ON wpac.user_id = wpu.id\n\t\t\t\t\t WHERE recovered_cart='0' AND unsubscribe_link='0' ");
$count = $wpdb->num_rows;
if ($count > 0) {
$p = new pagination();
$p->items($count);
$p->limit(10);
// Limit entries per page
$p->target("admin.php?page=woocommerce_ac_page&action=listcart");
if (isset($p->paging)) {
if (isset($_GET[$p->paging])) {
$p->currentPage($_GET[$p->paging]);
}
// Gets and validates the current page
}
$p->calculate();
// Calculates what to show
$p->parameterName('paging');
$p->adjacents(1);
//No. of page away from the current page
$p->showCounter(true);
if (!isset($_GET['paging'])) {
$p->page = 1;
} else {
$p->page = $_GET['paging'];
}
//Query for limit paging
$limit = "LIMIT " . ($p->page - 1) * $p->limit . ", " . $p->limit;
} else {
$limit = "";
}
?>
<div class="tablenav">
<div class='tablenav-pages'>
<?php
if ($count > 0) {
echo $p->show();
}
// Echo out the list of paging.
?>
</div>
</div>
示例6: managetestimonial
function managetestimonial()
{
$x = 0;
$data = get_option('testimonials_manager');
if ($_GET['action'] == 'delete') {
$id = $_GET['testimonial_id'];
$data = get_option('testimonials_manager');
unset($data['data'][$id]);
$data['data'] = array_values($data['data']);
update_option('testimonials_manager', $data);
echo "Testimonial Deleted<br/>";
}
$testimonialboxcount = count($data['data']);
$p = new pagination();
$p->items($testimonialboxcount);
$p->limit(25);
if (empty($_GET['pg'])) {
$page = 1;
} else {
$page = $_GET['pg'];
}
$p->currentPage($page);
$p->target('admin.php?page=testimonials_manage');
?>
<div class="tablenav">
<div class='tablenav-pages'>
<?php
echo $p->show();
// Echo out the list of paging.
?>
</div>
<div class = "alignleft actions" > <select name = "act" > <option value = "-1" selected = "selected" > Bulk Actions</option > <option value = "trash" > Delete</option >
</select > <input type = "submit" name = "doaction" id = "doaction" value = "Apply" class = "button-secondary apply" / >
</div><br class = "clear" / >
</div >
<?php
// print_r($data);
if ($testimonialboxcount > 25) {
$testimonialboxcount = 25;
// now to make the array smaller
$newarray = array_slice($data['data'], ($page - 1) * 25, 25);
$data['data'] = $newarray;
$testimonialboxcount = count($newarray);
}
?>
<table class="widefat" cellspacing="0">
<thead>
<tr>
<th scope="col" id="cb" class="manage-column column-cb check-column" style=""><input type="checkbox" class="checkall"/></th>
<th scope="col" width="250px">Name</th>
<th scope="col">Testimonial</th>
</tr>
</thead>
<tfoot>
<tr>
<th scope="col" id="cb" class="manage-column column-cb check-column" style=""><input type="checkbox" class="checkall" /></th>
<th scope="col">Name</th>
<th scope="col">Testimonial</th>
</tr>
</tfoot>
<tbody>
<?php
if ($testimonialboxcount == 0) {
?>
<tr style="background:#eeeeee;">
<td colspan="3" align="center"><strong>No testimonial yet, add one below.</strong></td>
</tr>
<?php
} else {
while ($x < $testimonialboxcount) {
$num = $x;
$num = $num + 1 + ($page - 1) * 25;
$url = $data['data'][$x]['url'];
if (substr($url, 0, 7) != 'http://') {
$url = 'http://' . $url;
}
if ($data['data'][$x]['avatar']) {
if ($data['data'][$x]['avatar'] == "gravatar") {
$av = get_avatar($data['data'][$x]['email'], 48);
} else {
$av = '<img src="' . $data['data'][$x]['own_avatar'] . '" class="avatar" alt="avatar" width="48" height="48" />';
}
}
?>
<tr>
<td align="center" valign="top"><input type='checkbox' name='delete_comments[]' class="tobedeleted" value='<?php
echo $num - 1;
?>
' /></td>
<td class="author column-author">
<strong><?php
echo $av;
?>
<?php
echo $data['data'][$x]['name'];
?>
</strong><br>
<?php
echo $data['data'][$x]['company'];
?>
//.........这里部分代码省略.........
示例7: pagination
//постраничная разбивка
$page_href = $mod_page;
if ($search_username) {
$page_href .= "&search_username=" . $search_username;
}
if ($search_status) {
$page_href .= "&search_status=" . $search_status;
}
if ($search_date) {
$page_href .= "&search_date=" . $search_date;
}
$pg = new pagination();
$pg->Items($total);
$pg->limit($pnum);
$pg->target($page_href);
$pg->currentPage($page);
$pg->nextT = ' <a href="[+link+]">' . $langTxt['next'] . '</a> ';
$pg->prevT = ' <a href="[+link+]">' . $langTxt['prev'] . '</a> ';
$pager = $pg->getOutput();
//Данные заказов
$data_query = $modx->db->query("SELECT shk.id, shk.short_txt, shk.price, shk.currency, shk.note, shk.status, shk.userid, DATE_FORMAT(shk.date,'%d.%m.%Y %k:%i') AS date, DATE_FORMAT(shk.sentdate,'%d.%m.%Y %k:%i') AS sentdate " . $data_q . $orderby_q);
//$data_query = $modx->db->select("id, short_txt, price, currency, note, status, userid, DATE_FORMAT(date,'%d.%m.%Y %k:%i') AS date, DATE_FORMAT(sentdate,'%d.%m.%Y %k:%i') AS sentdate", $shkm->mod_table, "", "id DESC", "$start,$pnum");
//Данные пользователей
$userData_query = $modx->db->select("DISTINCT wu.id, wu.username", $dbprefix . "web_users wu, {$shkm->mod_table} shk", "wu.id = shk.userid", "", "");
$users_id_list = "0";
while ($userData = mysql_fetch_row($userData_query)) {
$userName[$userData[0]] = $userData[1];
$users_id_list .= "," . $userData[0];
}
//Число заказов пользователя
$users_all_purchase = array();
示例8: pagination
}
if ($items > 0) {
if ($filtrar_por == 'todos') {
$filtrar_por = false;
}
if ($ordenar_por) {
$ordenar_query = "&ordenar_por=" . $ordenar_por;
}
if ($filtrar_por) {
$filtrar_query = "&filtrar_por=" . $filtrar_por;
}
$p = new pagination();
$p->items($items);
$p->limit(30);
// Limit entries per page
$p->currentPage($_GET[$p->paging]);
// Gets and validates the current page
// Calculates what to show
$p->parameterName('paging');
$p->adjacents(1);
//No. of page away from the current page
$p->target("tools.php?page=" . plugin_basename(dirname(__FILE__)) . "/modulo-vendas.php" . $ordenar_query . $filtrar_query);
if (!isset($_GET['paging'])) {
$p->page = 1;
} else {
$p->page = $_GET['paging'];
}
$p->calculate();
//Query for limit paging
$limit = "LIMIT " . ($p->page - 1) * $p->limit . ", " . $p->limit;
if ($ordenar_por) {
示例9: count
$pagination_count = count($buildings_total);
$building_count = $pagination_count;
}
}
if ($pagination_count > 0) {
//Records per page and items per row
$per_page = getPerPageCount($pagination_count);
//Total Page
$total_page = ceil($pagination_count / $per_page);
//initiate the pagination variable
$pag = new pagination();
//Set the pagination variable values
$pag->Items($pagination_count);
$pag->limit($per_page);
$pag->target($current_url);
$pag->currentPage($this_page);
//Done with the pagination
//Now get the entries
//But before that a little anomaly checking
$list_start = ($this_page - 1) * $per_page;
if ($list_start >= $pagination_count) {
//Start of the list should be less than pagination count
$list_start = $pagination_count - $per_page;
}
if ($list_start < 0) {
//list start cannot be negative
$list_start = 0;
}
$list_end = $this_page * $per_page - 1;
//Get the data from the database
if ($_SERVER["REQUEST_METHOD"] == "POST") {
示例10: create_paginator
function create_paginator($currentpage, $nb_items, $path)
{
require_once ROOT_DIR . '/' . INC_DIR . '/paginator-digg/pagination.php';
$p = new pagination();
$p->items($nb_items);
$p->currentPage($currentpage);
$p->limit(1);
$p->urlFriendly();
$p->target(URL . "/{$path}/page/%");
if ("" === $path) {
$p->target(URL . "/page/%");
}
$p->adjacents(1);
if (!$p->calculate) {
if ($p->calculate()) {
return "<div class=\"{$p->className}\">{$p->pagination}</div>";
}
}
}
示例11: pagination
function detail_page($detail)
{
$page = 0;
if (@$_GET["page"]) {
$page = $_GET["page"] - 1;
}
$foo = @split("<!-- pagebreak -->", $detail);
$target = preg_replace("/([&?]+page=[0-9]+)/i", "", $_SERVER["REQUEST_URI"]);
$pagination = new pagination();
$pagination->target($target);
$pagination->limit(1);
@$pagination->currentPage($_GET["page"]);
$pagination->Items(count($foo));
return @$foo[$page] . $pagination->show();
}
示例12: DataGrid
$numRecords = $modx->db->getRecordCount($items_result);
if ($numRecords) {
$grd = new DataGrid('', $items_result);
$grd->noRecordMsg = 'Нет заявок.';
$grd->pageSize = $page_num;
$grd->pagerLocation = 'bottom-left';
$grd->cssClass = "grid";
$grd->columnHeaderClass = "gridHeader";
$grd->itemClass = "gridItem";
$grd->altItemClass = "gridAltItem";
$grd->columns = "ID,Наименование,Цена,Действия";
$grd->colTypes = '
||template:<br /><a href="index.php?a=27&update=[+id+]&id=[+parent+]&pid=[+parent+]&to_shk=1" onclick="$.fn.colorbox.init();$.fn.colorbox($.extend(colorBoxOpt,{href:\'index.php?a=27&update=[+id+]&id=[+parent+]&pid=[+parent+]&to_shk=1\'})); return false;">[+pagetitle+]</a>
||template:<input type="hidden" name="prod_id[]" value="[+id+]" /> <input type="text" name="price[]" size="12" value="[+price+]" />
||template:<a href="#" title="' . $langTxt['delete'] . '" onclick="if(confirm(\'' . $langTxt['confirm'] . '\')){postForm(\'delete_item\',\'[+id+]\',null);}return false;"><img src="' . SHOPKEEPER_PATH . 'style/default/img/m_delete.gif" /></a>
';
$grd->colWidths = "10%,50%,20%,20%";
$grd->fields = "id,pagetitle,price";
$data_table = $grd->render();
//pagination
$p = new pagination();
$p->Items($total);
$p->limit($page_num);
$p->target($catalog_mod_page);
$p->currentPage($curPage);
$p->nextT = ' <a href="[+link+]">' . $langTxt['next'] . '</a> ';
$p->prevT = ' <a href="[+link+]">' . $langTxt['prev'] . '</a> ';
$pagination = $p->getOutput();
}
}
include "templates/catalog.tpl.php";
示例13: list_voucher_display_settings
function list_voucher_display_settings()
{
global $wpdb;
$sql = 'SELECT COUNT(*) FROM wp_voucher_post';
$items = $wpdb->get_var($sql);
// $items = mysql_num_rows(mysql_query("SELECT * FROM wp_voucher_post")); // number of total rows in the database
if ($items > 0) {
$p = new pagination();
$p->items($items);
$p->limit(500);
// Limit entries per page
$p->target("admin.php?page=list_voucher_settings");
$p->currentPage($_GET[$p->paging]);
// Gets and validates the current page
$p->calculate();
// Calculates what to show
$p->parameterName('paging');
$p->adjacents(1);
//No. of page away from the current page
if (!isset($_GET['paging'])) {
$p->page = 1;
} else {
$p->page = $_GET['paging'];
}
//Query for limit paging
$limit = "LIMIT " . ($p->page - 1) * $p->limit . ", " . $p->limit;
} else {
echo "No Record Found";
}
echo '<div class="wrap">
<h2>List of Records</h2>
<div class="tablenav">
<div class="tablenav-pages">';
echo $p->show();
echo '</div>
</div>
<table class="widefat">
<thead>
<tr>
<th><strong>ID</strong></th>
<th><strong>Người nhận</strong></th>
<th><strong>Email</strong></th>
<th><strong>Điện thoại</strong></th>
<th><strong>Tên voucher</strong></th>
<th><strong>Số lượng</strong></th>
</tr>
</thead>
<tbody>';
$sql = "SELECT * FROM wp_voucher_post, wp_posts where wp_voucher_post.post_id = wp_posts.id ORDER BY wp_voucher_post.id DESC {$limit}";
$result = $wpdb->get_results($sql) or die('Error, query failed');
foreach ($result as $value) {
echo '<tr>
<td>' . $value->post_id . '</td>
<td>' . $value->fullname . '</td>
<td>' . $value->email . '</td>
<td>' . $value->phone . '</td>
<td>' . $value->post_title . '</td>
<td>' . $value->total . '</td>
</tr>';
}
echo '</tbody>
</table>
</div>';
}
示例14: showTestimonial
function showTestimonial()
{
$x = 0;
$data = get_option('testimonials_manager');
$testimonialboxcount = count($data['data']);
switch ($data['dorder']) {
case 'random':
shuffle($data['data']);
break;
case 'desc':
$data['data'] = array_reverse($data['data']);
ksort($data['data']);
break;
default:
}
echo <<<EOF
<style>
.clearfloat {
clear: both;
}
</style>
EOF;
$p = new pagination();
$p->items($testimonialboxcount);
$p->limit($data['items']);
if (empty($_GET['pg'])) {
$page = 1;
} else {
$page = $_GET['pg'];
}
$p->currentPage($page);
$p->target(get_permalink());
$result = $p->getOutput();
// print_r($data);
if ($testimonialboxcount > $data['items']) {
$testimonialboxcount = $data['items'];
// now to make the array smaller
$newarray = array_slice($data['data'], ($page - 1) * $data['items'], $data['items']);
$data['data'] = $newarray;
$testimonialboxcount = count($newarray);
}
if ($testimonialboxcount == 0) {
$result .= '<div class="testimonial" style="text-align:center;">';
$result .= '<strong>There are no testimonial yet</strong>';
$result .= '</div>';
} else {
while ($x < $testimonialboxcount) {
$url = $data['data'][$x]['url'];
if (substr($url, 0, 7) != 'http://') {
$url = 'http://' . $url;
}
$result .= '<div class="testimonial">';
if ($data['data'][$x]['avatar']) {
if ($data['data'][$x]['avatar'] == "gravatar") {
$result .= get_avatar($data['data'][$x]['email'], $size = $data['imagex']);
} else {
$result .= '<img src="' . $data['data'][$x]['own_avatar'] . '" class="avatar" alt="avatar" width="' . $data['imagex'] . '" height="' . $data['imagey'] . '" />';
}
}
$result .= stripslashes(nl2br($data['data'][$x]['text']));
$result .= '<cite>' . stripslashes($data['data'][$x]['name']);
if ($data['data'][$x]['title']) {
$result .= ', ' . stripslashes($data['data'][$x]['title']);
}
if ($data['data'][$x]['company_name']) {
$result .= '<em>' . stripslashes($data['data'][$x]['company_name']) . '</em>';
}
$result .= '</cite>';
if ($data['data'][$x]['url']) {
$result .= '<a href="' . stripslashes($url) . '">';
}
if ($data['data'][$x]['company']) {
$result .= stripslashes($data['data'][$x]['company']);
}
if ($data['data'][$x]['url']) {
$result .= '</a>';
}
$result .= '<div class="clearfloat"></div></div>';
$x++;
}
}
/*
$s= <<<EOF
<style>
.copyyy,.copyyy a {
font-size: 10px !important;
font-family; veranda !important;
color: #666666 !important;
}
</style>
EOF;
*
*/
$result .= $p->getOutput();
$result .= '<div class="testimonial" style="background: transparent; border:none; margin:0 0 20px 0; text-align:right;size:10px">Powered by the <a href="http://www.profitplugs.com/testimonials-manager-wordpress/" title="Testimonial Manager">Testimonial Manager Plugin for Wordpress.</a></div>';
return $result;
}
示例15: sc_render_manager_page
//.........这里部分代码省略.........
}
break;
case 'upload':
?>
<form action="" enctype="multipart/form-data" method="post" id ="add_track">
<table class="form-table">
<tr valign="top">
<th scope="row"><label for="track_title">Track title:</label></th>
<td><input type="text" name="track_title" size="30" class="regular-text code"></td>
</tr>
<tr valign="top">
<th scope="row"><label for="track_file">Please specify a track:</label></th>
<td><input type="file" name="track_file" id="track_file" size="40" accept="audio/*" class="regular-text code"></td>
</tr>
<tr valign="top">
<th scope="row"><label for="track_art">Please specify track artwork:</label></th>
<td><input type="file" name="track_art" id="track_art" size="40" accept="image/*" class="regular-text code"></td>
</tr>
<tr valign="top">
<th scope="row"><label for="tag">Track tags:</label></th>
<td><input type="text" name="tag" id="tag" size="30"><input type="button" id="add_tag" name="add_tag" class="button" value="Add Tag" />
<br><ul id="tags"></ul></td>
</tr>
<tr valign="top">
<th scope="row"><label for="sharing">Track privacy:</label></th>
<td><select name="sharing">
<option value="public">Public</option>
<option value="private">Private</option>
</select></td>
</tr>
</table>
<p class="submit"><input type="submit" value="Upload" class="button-primary"></p>
</form>
<?php
try {
$tmp_file = '/tmp/' . stripslashes($_FILES['track_file']['name']);
$tmp_art_file = '/tmp/' . stripslashes($_FILES['track_art']['name']);
if (move_uploaded_file($_FILES['track_file']['tmp_name'], $tmp_file) && move_uploaded_file($_FILES['track_art']['tmp_name'], $tmp_art_file)) {
// upload audio file
$track = json_decode($client->post('tracks', array('track[title]' => $_POST['track_title'], 'track[asset_data]' => '@' . $tmp_file, 'track[artwork_data]' => '@' . $tmp_art_file, 'track[tags]' => strlen($_POST['tags']) ? $_POST['tags'] : null, 'track[sharing]' => $_POST['sharing'])));
unlink(realpath($tmp_file));
unlink(realpath($tmp_art_file));
}
} catch (Services_Soundcloud_Invalid_Http_Response_Code_Exception $e) {
var_dump($e->getMessage());
exit;
}
break;
case 'tracks':
try {
echo '</br>';
$page_size = 5;
// Pagination code
$p = new pagination();
$p->items($me['track_count']);
$p->limit($page_size);
// Limit entries per page
$p->target("admin.php?page=soundcloud-manager&tab=tracks");
$p->currentPage($_GET[$p->paging]);
// Gets and validates the current page
$p->calculate();
// Calculates what to show
$p->parameterName('paging');
$p->adjacents(1);
//No. of page away from the current page
if (!isset($_GET['paging'])) {
$p->page = 1;
} else {
$p->page = $_GET['paging'];
}
if ($p->page == 1) {
// get first page of tracks
$tracks = json_decode($client->get('users/' . $me['id'] . '/tracks', array('order' => 'created_at', 'limit' => $page_size)));
} else {
// get additional pages of tracks
$tracks = json_decode($client->get('users/' . $me['id'] . '/tracks', array('order' => 'created_at', 'limit' => $page_size, 'offset' => $page_size * $page)));
}
?>
<div class="tablenav">
<div class='tablenav-pages'>
<?php
echo $p->show();
?>
</div>
</div>
<?php
foreach ($tracks as $track) {
$client->setCurlOptions(array(CURLOPT_FOLLOWLOCATION => 1));
$embed_info = json_decode($client->get('oembed', array('url' => $track->permalink_url)));
// render the html for the player widget
echo $embed_info->html . '</br></br>';
}
} catch (Services_Soundcloud_Invalid_Http_Response_Code_Exception $e) {
var_dump($e->getMessage());
exit;
}
break;
}
}