Ejemplo n.º 1
0
function get_db_results()
{
    // normally you would have an SQL query here,
    // for this example we fabricate a 100 item array
    // (emulating a table with 100 records)
    // and slice out our pagination range
    // (emulating a LIMIT X,Y MySQL clause)
    $_data = range(1, 100);
    SmartyPaginate::setTotal(count($_data));
    return array_slice($_data, SmartyPaginate::getCurrentIndex(), SmartyPaginate::getLimit());
}
function getSearchResults(&$dbcon, $searchSpec)
{
    $X = SmartyPaginate::getCurrentIndex();
    $Y = SmartyPaginate::getLimit();
    $searchSQL = "SELECT * FROM sionapros_news WHERE 1 {$searchSpec} ORDER BY pub_date DESC LIMIT {$X},{$Y}";
    $result = $dbcon->execute($searchSQL);
    foreach ($result as $row) {
        $data[] = $row;
    }
    // now we get the total number of records from the table
    $rowsSQL = "SELECT COUNT(*) FROM sionapros_news WHERE 1 {$searchSpec}";
    $dbcon->query($rowsSQL);
    SmartyPaginate::setTotal($dbcon->getValue());
    return $data;
}
function getSearchResults(&$dbcon)
{
    $X = SmartyPaginate::getCurrentIndex();
    $Y = SmartyPaginate::getLimit();
    $searchSQL = "SELECT * FROM sionapros_news WHERE 1 ORDER BY news_no DESC LIMIT {$X},{$Y}";
    $result = $dbcon->execute($searchSQL);
    foreach ($result as $row) {
        // collect each record into $_data
        $data[] = $row;
    }
    // now we get the total number of records from the table
    $rowsSQL = "SELECT COUNT(*) FROM sionapros_news WHERE 1";
    $dbcon->query($rowsSQL);
    #$rowNo = $rows[0];
    SmartyPaginate::setTotal($dbcon->getValue());
    $dbcon->free();
    return $data;
}
function getSearchResults(&$dbcon, $proj_no)
{
    $X = SmartyPaginate::getCurrentIndex();
    $Y = SmartyPaginate::getLimit();
    $searchSQL = "SELECT p.*,c.value FROM sionapros_pubs AS p INNER JOIN sionapros_categories AS c";
    $searchSQL .= " ON p.category = c.id WHERE 1 {$_SESSION['search']} ORDER BY id DESC LIMIT {$X},{$Y}";
    $result = $dbcon->execute($searchSQL);
    foreach ($result as $row) {
        // collect each record into $_data
        $data[] = $row;
    }
    // now we get the total number of records from the table
    $rowsSQL = "SELECT COUNT(*) FROM sionapros_pubs AS p WHERE 1 {$_SESSION['search']}";
    $dbcon->query($rowsSQL);
    #$rowNo = $rows[0];
    SmartyPaginate::setTotal($dbcon->getValue());
    $dbcon->free();
    return $data;
}
function getSearchResults(&$dbcon)
{
    $X = SmartyPaginate::getCurrentIndex();
    $Y = SmartyPaginate::getLimit();
    $searchSQL = "SELECT firstname,lastname,identifier FROM sionapros_users";
    $searchSQL .= " WHERE 1 {$_SESSION['search']} ORDER BY identifier ASC LIMIT {$X},{$Y}";
    $result = $dbcon->execute($searchSQL);
    foreach ($result as $row) {
        // collect each record into $_data
        $data[] = $row;
    }
    // now we get the total number of records from the table
    $rowsSQL = "SELECT COUNT(*) FROM sionapros_users WHERE 1 {$_SESSION['search']}";
    $dbcon->query($rowsSQL);
    #$rowNo = $rows[0];
    SmartyPaginate::setTotal($dbcon->getValue());
    $dbcon->free();
    return $data;
}
function getSearchResults(&$dbcon)
{
    $X = SmartyPaginate::getCurrentIndex();
    $Y = SmartyPaginate::getLimit();
    $searchSQL = "SELECT fq.*,C.value FROM sionapros_faqs AS fq INNER JOIN sionapros_categories";
    $searchSQL .= " AS C ON fq.category = C.id ORDER BY C.id,fq.id LIMIT {$X},{$Y}";
    $result = $dbcon->execute($searchSQL);
    echo $dbcon->error;
    foreach ($result as $row) {
        // collect each record into $_data
        $data[] = $row;
    }
    // now we get the total number of records from the table
    $rowsSQL = "SELECT COUNT(*) FROM sionapros_faqs WHERE 1";
    $dbcon->query($rowsSQL);
    #$rowNo = $rows[0];
    SmartyPaginate::setTotal($dbcon->getValue());
    $dbcon->free();
    return $data;
}
/**
 * Project:     SmartyPaginate: Pagination for the Smarty Template Engine
 * File:        function.paginate_last.php
 * Author:      Monte Ohrt <monte at newdigitalgroup dot com>
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library 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
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 *
 * @link http://www.phpinsider.com/php/code/SmartyPaginate/
 * @copyright 2001-2005 New Digital Group, Inc.
 * @author Monte Ohrt <monte at newdigitalgroup dot com>
 * @package SmartyPaginate
 * @version 1.6-dev
 */
function smarty_function_paginate_last($params, &$smarty)
{
    $_id = 'default';
    $_attrs = array();
    if (!class_exists('SmartyPaginate')) {
        $smarty->trigger_error("paginate_last: missing SmartyPaginate class");
        return;
    }
    if (!isset($_SESSION['SmartyPaginate'])) {
        $smarty->trigger_error("paginate_last: SmartyPaginate is not initialized, use connect() first");
        return;
    }
    foreach ($params as $_key => $_val) {
        switch ($_key) {
            case 'id':
                if (!SmartyPaginate::isConnected($_val)) {
                    $smarty->trigger_error("paginate_last: unknown id '{$_val}'");
                    return;
                }
                $_id = $_val;
                break;
            default:
                $_attrs[] = $_key . '="' . $_val . '"';
                break;
        }
    }
    if (SmartyPaginate::getTotal($_id) === false) {
        $smarty->trigger_error("paginate_last: total was not set");
        return;
    }
    $_url = SmartyPaginate::getURL($_id);
    //$_url = full_url();
    $_total = SmartyPaginate::getTotal($_id);
    $_limit = SmartyPaginate::getLimit($_id);
    $_attrs = !empty($_attrs) ? ' ' . implode(' ', $_attrs) : '';
    $_text = isset($params['text']) ? $params['text'] : SmartyPaginate::getLastText($_id);
    $_url .= strpos($_url, '?') === false ? '?' : '&';
    $_url .= SmartyPaginate::getUrlVar($_id) . '=';
    $_url .= $_total % $_limit > 0 ? $_total - $_total % $_limit + 1 : $_total - $_limit + 1;
    return '<a href="' . str_replace('&', '&amp;', $_url) . '"' . $_attrs . '>' . $_text . '</a>';
}
function getSearchResults(&$dbcon)
{
    #$searchSQL = sprintf("SELECT * FROM ehmis_personnel_main WHERE 1 {$_SESSION['search']} ORDER BY identifier ASC LIMIT %d,%d",
    #    					SmartyPaginate::getCurrentIndex(), SmartyPaginate::getLimit());
    $X = SmartyPaginate::getCurrentIndex();
    $Y = SmartyPaginate::getLimit();
    $searchSQL = "SELECT n.*,c.value FROM sionapros_news AS n INNER JOIN sionapros_categories AS c ON";
    $searchSQL .= " n.category = c.id WHERE 1 {$_SESSION['search']} ORDER BY n.news_no DESC LIMIT {$X},{$Y}";
    $result = $dbcon->execute($searchSQL);
    foreach ($result as $row) {
        // collect each record into $_data
        $data[] = $row;
    }
    // now we get the total number of records from the table
    $rowsSQL = "SELECT COUNT(*) FROM sionapros_news AS n WHERE 1 {$_SESSION['search']}";
    $dbcon->query($rowsSQL);
    #$rowNo = $rows[0];
    SmartyPaginate::setTotal($dbcon->getValue());
    $dbcon->free();
    return $data;
}
Ejemplo n.º 9
0
 /**
  * Lists all the users in a project
  *
  * @param int $project Eindeutige Projektnummer
  * @param int $lim Maximum auszugebender Mitglieder
  * @return array $members Projektmitglieder
  */
 function getProjectMembers($project, $lim = 10, $paginate = true)
 {
     global $conn;
     $project = (int) $project;
     $lim = (int) $lim;
     $project = (int) $project;
     $lim = (int) $lim;
     $members = array();
     if ($paginate) {
         $num = $conn->query("SELECT COUNT(*) FROM projekte_assigned WHERE projekt = {$project}")->fetch();
         $num = $num[0];
         $lim = (int) $lim;
         SmartyPaginate::connect();
         // set items per page
         SmartyPaginate::setLimit($lim);
         SmartyPaginate::setTotal($num);
         $start = SmartyPaginate::getCurrentIndex();
         $lim = SmartyPaginate::getLimit();
     } else {
         $start = 0;
     }
     $sel1 = $conn->query("SELECT user FROM projekte_assigned WHERE projekt = {$project} LIMIT {$start},{$lim}");
     $usr = new user();
     while ($user = $sel1->fetch()) {
         $theuser = $usr->getProfile($user[0]);
         array_push($members, $theuser);
     }
     if (!empty($members)) {
         return $members;
     } else {
         return false;
     }
 }
Ejemplo n.º 10
0
 /**
  * assign $paginate var values
  *
  * @param obj &$smarty the smarty object reference
  * @param string $var the name of the assigned var
  * @param string $id the pagination id
  */
 public static function assign(&$smarty, $var = 'paginate', $id = 'default')
 {
     if (is_object($smarty) && (strtolower(get_class($smarty)) == 'smarty' || is_subclass_of($smarty, 'smarty'))) {
         $_paginate['total'] = SmartyPaginate::getTotal($id);
         $_paginate['first'] = SmartyPaginate::getCurrentItem($id);
         $_paginate['last'] = SmartyPaginate::getLastItem($id);
         $_paginate['page_current'] = ceil(SmartyPaginate::getLastItem($id) / SmartyPaginate::getLimit($id));
         $_paginate['page_total'] = ceil(SmartyPaginate::getTotal($id) / SmartyPaginate::getLimit($id));
         $_paginate['size'] = $_paginate['last'] - $_paginate['first'];
         $_paginate['url'] = SmartyPaginate::getUrl($id);
         $_paginate['urlvar'] = SmartyPaginate::getUrlVar($id);
         $_paginate['current_item'] = SmartyPaginate::getCurrentItem($id);
         $_paginate['prev_text'] = SmartyPaginate::getPrevText($id);
         $_paginate['next_text'] = SmartyPaginate::getNextText($id);
         $_paginate['limit'] = SmartyPaginate::getLimit($id);
         $_item = 1;
         $_page = 1;
         while ($_item <= $_paginate['total']) {
             $_paginate['page'][$_page]['number'] = $_page;
             $_paginate['page'][$_page]['item_start'] = $_item;
             $_paginate['page'][$_page]['item_end'] = $_item + $_paginate['limit'] - 1 <= $_paginate['total'] ? $_item + $_paginate['limit'] - 1 : $_paginate['total'];
             $_paginate['page'][$_page]['is_current'] = $_item == $_paginate['current_item'];
             $_item += $_paginate['limit'];
             $_page++;
         }
         $smarty->assign($var, $_paginate);
     } else {
         trigger_error("SmartyPaginate: [assign] I need a valid Smarty object.");
         return false;
     }
 }
Ejemplo n.º 11
0
 function getProjectLog($project, $lim = 10)
 {
     $project = (int) $project;
     $lim = (int) $lim;
     $sel = mysql_query("SELECT COUNT(*) FROM log WHERE project = {$project} ");
     $num = mysql_fetch_row($sel);
     $num = $num[0];
     if ($num > 200) {
         $num = 200;
     }
     SmartyPaginate::connect();
     // set items per page
     SmartyPaginate::setLimit($lim);
     SmartyPaginate::setTotal($num);
     $start = SmartyPaginate::getCurrentIndex();
     $lim = SmartyPaginate::getLimit();
     $sql = "SELECT * FROM log WHERE project = {$project} ORDER BY ID DESC LIMIT {$start},{$lim}";
     $sel2 = mysql_query($sql);
     $mylog = array();
     while ($log = mysql_fetch_array($sel2)) {
         if (!empty($log)) {
             $sel3 = mysql_query("SELECT name FROM projekte WHERE ID = {$log['project']}");
             $proname = mysql_fetch_array($sel3);
             $proname = $proname[0];
             $log["proname"] = $proname;
             $log["proname"] = stripslashes($log["proname"]);
             $log["username"] = stripslashes($log["username"]);
             $log["name"] = stripslashes($log["name"]);
             array_push($mylog, $log);
         }
     }
     if (!empty($mylog)) {
         return $mylog;
     } else {
         return false;
     }
 }
Ejemplo n.º 12
0
        /*	$tips = R::getAll(sprintf("select SQL_NO_CACHE SQL_CALC_FOUND_ROWS *, t.id as tid from tip t join category c on t.category_id = c.id where t.category_id = '".$c."' order by t.schedule_time LIMIT %d,%d",
           SmartyPaginate::getCurrentIndex(), SmartyPaginate::getLimit())); */
    }
    $_query = "select *, t.id as tid from tip t join category c on t.category_id = c.id where t.category_id = '" . $c . "' and t.schedule_time between {$start} and {$end}";
    /*$tips = R::getAll(sprintf("select SQL_NO_CACHE SQL_CALC_FOUND_ROWS *, t.id as tid from tip t join category c on t.category_id = c.id where t.category_id = '".$c."' and t.schedule_time between $start and $end LIMIT %d,%d",
      SmartyPaginate::getCurrentIndex(), SmartyPaginate::getLimit())); */
} else {
    $_query = "select *, t.id as tid from tip t join category c where c.id = t.category_id order by t.schedule_time desc";
    /*$tips = R::getAll(sprintf("select SQL_NO_CACHE SQL_CALC_FOUND_ROWS *, t.id as tid from tip t join category c where c.id = t.category_id order by t.schedule_time desc LIMIT %d,%d",
      SmartyPaginate::getCurrentIndex(), SmartyPaginate::getLimit())); */
}
$_SESSION['query'] = $_query;
$cherche = mysql_query($_SESSION['query'], $link);
while ($line = mysql_fetch_array($cherche, MYSQL_ASSOC)) {
    $tips[] = $line;
    //var_dump($tips); exit;
}
$_SESSION['count'] = mysql_num_rows(mysql_query($_SESSION['query']));
$view = $top;
$smarty->assign('title', 'mHealth::Living Healthy goes mobile');
$smarty->assign('topic', 'Manage Tips');
$smarty->assign('view', $view);
$smarty->assign('info', $info);
$smarty->assign('categorys', $categorys);
$start = SmartyPaginate::getCurrentIndex();
$limit = SmartyPaginate::getLimit();
$smarty->assign('tips', array_slice($tips, $start, $limit));
SmartyPaginate::setTotal($_SESSION['count']);
SmartyPaginate::assign($smarty);
$smarty->display('tips_user.tpl');
SmartyPaginate::reset();
Ejemplo n.º 13
0
 /**
  * List all files associated to a given project
  *
  * @param string $id Project ID
  * @param int $lim Limit
  * @param int $folder Folder
  * @return array $files Found files
  */
 function getProjectFiles($id, $lim = 25, $folder = "")
 {
     $id = (int) $id;
     $lim = (int) $lim;
     $folder = (int) $folder;
     if ($folder > 0) {
         $fold = "files/" . CL_CONFIG . "/{$id}/{$folder}/";
         $sel = mysql_query("SELECT COUNT(*) FROM files WHERE project = {$id} AND folder = {$folder} ORDER BY ID DESC");
     } else {
         $sel = mysql_query("SELECT COUNT(*) FROM files WHERE project = {$id} AND folder = 0 ORDER BY ID DESC");
     }
     $num = mysql_fetch_row($sel);
     $num = $num[0];
     SmartyPaginate::connect();
     // set items per page
     SmartyPaginate::setLimit($lim);
     SmartyPaginate::setTotal($num);
     $start = SmartyPaginate::getCurrentIndex();
     $lim = SmartyPaginate::getLimit();
     $files = array();
     if ($folder > 0) {
         $sql = "SELECT ID FROM files WHERE project = {$id} AND folder = {$folder} ORDER BY  ID DESC LIMIT {$start},{$lim}";
         $sel2 = mysql_query($sql);
     } else {
         $sel2 = mysql_query("SELECT ID FROM files WHERE project = {$id} AND folder = 0 ORDER BY  ID DESC LIMIT {$start},{$lim}");
     }
     while ($file = mysql_fetch_array($sel2)) {
         if (!empty($file)) {
             array_push($files, $this->getFile($file["ID"]));
         }
     }
     if (!empty($files)) {
         return $files;
     } else {
         return false;
     }
 }
Ejemplo n.º 14
0
 function getProjectLog($project, $lim = 25)
 {
     global $conn;
     $project = (int) $project;
     $lim = (int) $lim;
     $sel = $conn->prepare("SELECT COUNT(*) FROM log WHERE project = ? ");
     $sel->execute(array($project));
     $num = $sel->fetch();
     $num = $num[0];
     if ($num > 200) {
         $num = 200;
     }
     SmartyPaginate::connect();
     // set items per page
     SmartyPaginate::setLimit($lim);
     SmartyPaginate::setTotal($num);
     $start = SmartyPaginate::getCurrentIndex();
     $lim = SmartyPaginate::getLimit();
     $sql = "SELECT * FROM log WHERE project = ? ORDER BY ID DESC LIMIT {$start},{$lim}";
     $sel2 = $conn->prepare($sql);
     $sel2->execute(array($project));
     $mylog = array();
     while ($log = $sel2->fetch()) {
         if (!empty($log)) {
             $sel3 = $conn->query("SELECT name FROM projekte WHERE ID = {$log['project']}");
             $proname = $sel3->fetch();
             $proname = $proname[0];
             $log["proname"] = $proname;
             //$log["proname"] = stripslashes($log["proname"]);
             //$log["username"] = stripslashes($log["username"]);
             $log["name"] = stripslashes($log["name"]);
             array_push($mylog, $log);
         }
     }
     if (!empty($mylog)) {
         return $mylog;
     } else {
         return false;
     }
 }
Ejemplo n.º 15
0
 /**
  * Returns all users
  *
  * @param int $lim Limit
  * @return array $users Registrierte Mitglieder
  */
 function getAllUsers($lim = 10)
 {
     global $conn;
     $lim = (int) $lim;
     $num = $conn->query("SELECT COUNT(*) FROM `user`")->fetch();
     $num = $num[0];
     SmartyPaginate::connect();
     // set items per page
     SmartyPaginate::setLimit($lim);
     SmartyPaginate::setTotal($num);
     $start = SmartyPaginate::getCurrentIndex();
     $lim = SmartyPaginate::getLimit();
     $sel2 = $conn->query("SELECT ID FROM `user` ORDER BY ID DESC LIMIT {$start},{$lim}");
     $users = array();
     while ($user = $sel2->fetch()) {
         array_push($users, $this->getProfile($user["ID"]));
     }
     if (!empty($users)) {
         return $users;
     } else {
         return false;
     }
 }
Ejemplo n.º 16
0
/**
 * Project:     SmartyPaginate: Pagination for the Smarty Template Engine
 * File:        function.paginate_middle.php
 * Author:      Monte Ohrt <monte at newdigitalgroup dot com>
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library 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
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 *
 * @link http://www.phpinsider.com/php/code/SmartyPaginate/
 * @copyright 2001-2005 New Digital Group, Inc.
 * @author Monte Ohrt <monte at newdigitalgroup dot com>
 * @package SmartyPaginate
 * @version 1.6-dev
 */
function smarty_function_paginate_middle($params, &$smarty)
{
    $_id = 'default';
    $_prefix = '[';
    $_suffix = ']';
    $_link_prefix = '';
    $_link_suffix = '';
    $_page_limit = null;
    $_attrs = array();
    if (!class_exists('SmartyPaginate')) {
        $smarty->trigger_error("paginate_middle: missing SmartyPaginate class");
        return;
    }
    if (!isset($_SESSION['SmartyPaginate'])) {
        $smarty->trigger_error("paginate_middle: SmartyPaginate is not initialized, use connect() first");
        return;
    }
    foreach ($params as $_key => $_val) {
        switch ($_key) {
            case 'id':
                if (!SmartyPaginate::isConnected($_val)) {
                    $smarty->trigger_error("paginate_middle: unknown id '{$_val}'");
                    return;
                }
                $_id = $_val;
                break;
            case 'prefix':
                $_prefix = $_val;
                break;
            case 'suffix':
                $_suffix = $_val;
                break;
            case 'link_prefix':
                $_link_prefix = $_val;
                break;
            case 'link_suffix':
                $_link_suffix = $_val;
                break;
            case 'page_limit':
                $_page_limit = $_val;
                break;
            case 'format':
                break;
            default:
                $_attrs[] = $_key . '="' . $_val . '"';
                break;
        }
    }
    if (!isset($_SESSION['SmartyPaginate'][$_id]['item_total'])) {
        $smarty->trigger_error("paginate_middle: total was not set");
        return;
    }
    if (!isset($_page_limit) && isset($_SESSION['SmartyPaginate'][$_id]['page_limit'])) {
        $_page_limit = $_SESSION['SmartyPaginate'][$_id]['page_limit'];
    }
    $_url = $_SESSION['SmartyPaginate'][$_id]['url'];
    // $_url = full_url();
    $_total = SmartyPaginate::getTotal($_id);
    $_curr_item = SmartyPaginate::getCurrentItem($_id);
    $_limit = SmartyPaginate::getLimit($_id);
    $_item = 1;
    $_page = 1;
    $_display_pages = 0;
    $_ret = '';
    $_attrs = !empty($_attrs) ? ' ' . implode(' ', $_attrs) : '';
    if (isset($_page_limit)) {
        // find halfway point
        $_page_limit_half = floor($_page_limit / 2);
        // determine what item/page we start with
        $_item_start = $_curr_item - $_limit * $_page_limit_half;
        if (($_view = ceil(($_total - $_item_start) / $_limit)) < $_page_limit) {
            $_item_start -= $_limit * ($_page_limit - $_view);
        }
        $_item = $_item_start >= 1 ? $_item_start : 1;
        $_page = ceil($_item / $_limit);
    }
    while ($_item <= $_total) {
        if (isset($params['format']) && $params['format'] == 'page') {
            $_text = $_prefix . $_page . $_suffix;
        } else {
            //  $_text = $_prefix . $_item . '-';
            //  $_text .= ($_item + $_limit - 1 <= $_total) ? $_item + $_limit - 1 : $_total;
            //  $_text .= $_suffix;
            //$_text = $_prefix . $_page . $_suffix;
            $_text = $_page . " ";
        }
        if ($_item != $_curr_item) {
            $_this_url = $_url;
            $_this_url .= strpos($_url, '?') == false ? '?' : '&';
            $_this_url .= SmartyPaginate::getUrlVar($_id) . '=' . $_item;
            $_ret .= $_link_prefix . '<a href="' . str_replace('&', '&amp;', $_this_url) . '"' . $_attrs . '>' . $_text . '</a>' . $_link_suffix;
        } else {
            $_ret .= $_link_prefix . $_text . $_link_suffix;
        }
        $_item += $_limit;
        $_page++;
        $_display_pages++;
        if (isset($_page_limit) && $_display_pages == $_page_limit) {
            break;
        }
    }
    return $_ret;
}
Ejemplo n.º 17
0
    function getProjectTrack($project, $user = 0, $task = 0, $start = 0, $end = 0, $lim = 50)
    {
        $start = mysql_real_escape_string($start);
        $end = mysql_real_escape_string($end);
        $project = (int) $project;
        $user = (int) $user;
        $lim = (int) $lim;

        if ($user > 0)
        {
            $sql = "SELECT * FROM timetracker WHERE project = $project AND user = $user";
            $num = "SELECT COUNT(*) FROM timetracker WHERE project = $project AND user = $user";
            $order = " ORDER BY ended ASC";
        }
        else
        {
            $sql = "SELECT * FROM timetracker WHERE project = $project";
            $num = "SELECT COUNT(*) FROM timetracker WHERE project = $project";
            $order = " ORDER BY ended ASC";
        }

        if ($task > 0)
        {
            $sql .= " AND task = $task";
            $num .= " AND task = $task";
        }

        if ($start > 0 and $end > 0)
        {
            $start = strtotime($start);
            $end = strtotime($end . " +1 day");
            $end = $end - 1;
            $sql .= " AND ended >=$start AND ended<=$end ";
            $num .= " AND ended >=$start AND ended<=$end ";
        }

        if ($num)
        {
            $num = mysql_fetch_row(mysql_query($num));
            $num = $num[0];
        }
        else
        {
            $num = 0;
        }

        $sql = $sql . $order;
        SmartyPaginate::connect();
        SmartyPaginate::setLimit($lim);
        SmartyPaginate::setTotal($num);

        $start = SmartyPaginate::getCurrentIndex();
        $lim = SmartyPaginate::getLimit();

        $limi = " LIMIT $start,$lim ";
        $sql = $sql . $limi;

        $sel = mysql_query($sql);

        $track = array();
        $ttask = new task();

        if (isset($sel))
        {
            while ($data = @mysql_fetch_array($sel))
            {
                $endstring = date("H:i", $data["ended"]);
                $startstring = date("H:i", $data["started"]);
                $daystring = date("d.m.y", $data["ended"]);
                $tasks = $ttask->getTask($data["task"]);

                if (!empty($tasks))
                {
                    $tasks = $tasks["title"];
                    $data["tname"] = $tasks;
                }

                $pname = mysql_query("SELECT name FROM projekte WHERE ID = $data[project]");
                $pname = mysql_fetch_row($pname);
                $pname = stripslashes($pname[0]);

                $uname = mysql_query("SELECT name FROM user WHERE ID = $data[user]");
                $uname = mysql_fetch_row($uname);
                $uname = stripslashes($uname[0]);

                $data["endstring"] = $endstring;
                $data["startstring"] = $startstring;
                $data["daystring"] = $daystring;
                $data["uname"] = $uname;
                $data["pname"] = $pname;
                $data["comment"] = stripslashes($data["comment"]);
                $data["comment"] = nl2br($data["comment"]);
                array_push($track, $data);
            }
        }

        if (!empty($track))
        {
            return $track;
        }
        else
        {
            return false;
        }
    }
Ejemplo n.º 18
0
 function viewlist($parameter = null, $layout = true, $model = false)
 {
     $options = array();
     $assigns = array();
     $model = $model ? $model : $this->getDefaultModel();
     $this->page_title = Inflector::humanize($this->name);
     $this->auto_render = false;
     $this->base_dir = APP_DIR;
     $assigns['TITLE'] = Inflector::humanize($this->name);
     if ($model) {
         $this->get_search_field($model, $options);
         $this->get_viewlist_options($model, $options);
         $this->get_sort_options($model, $options);
         $this->set_pagination($model);
         $model->find($options);
         $page_content =& NController::singleton('page_content');
         $page_content_model =& $page_content->getDefaultModel();
         $pk = $model->primaryKey();
         $models = array();
         $headline = $model->getHeadline() ? $model->getHeadline() : 'cms_headline';
         $i = 0;
         while ($model->fetch()) {
             $arr = $model->toArray();
             $arr['_headline'] = isset($arr['cms_headline']) && $arr['cms_headline'] ? $arr['cms_headline'] : $model->makeHeadline();
             $arr['_remove_delete'] = $page_content_model->isWorkflowContent($this->name, $arr[$pk]) ? 1 : 0;
             // Remove delete for models that have specified this.
             $arr['_remove_delete'] = isset($model->remove_delete) && $model->remove_delete == true ? 1 : 0;
             $models[] = $arr;
             unset($arr);
         }
         // Override standard paging limit if chosen in the model file.
         $paging = isset($model->paging) ? $model->paging : $this->paging;
         // If paging is not disabled in the model AND the records are > than the paging size AND not searching.
         if ($paging > 0 && count($models) > $paging && !$options['is_search']) {
             SmartyPaginate::connect($this->name);
             SmartyPaginate::setLimit($paging, $this->name);
             SmartyPaginate::setTotal(count($models), $this->name);
             $view =& NView::singleton($this);
             SmartyPaginate::assign($view, 'paginate', $this->name);
             // TODO: Could be more efficient and only get records it needs to.
             $models = array_slice($models, SmartyPaginate::getCurrentIndex($this->name), SmartyPaginate::getLimit($this->name));
             $this->set('paging', true);
         }
         $this->set(array('rows' => $models, 'asset' => $this->name, 'asset_name' => $this->page_title));
         unset($models);
     }
     $this->render(array('layout' => 'default'));
 }
Ejemplo n.º 19
0
 function getProjectTrack($project, $user = 0, $task = 0, $start = 0, $end = 0, $lim = 50)
 {
     global $conn;
     $project = (int) $project;
     $user = (int) $user;
     $lim = (int) $lim;
     // make sure task is an array - this needs to be refactored
     if (!is_array($task)) {
         $task = array($task);
     }
     // make sure all the fields are ints
     for ($index = 0; $index < count($task); $index++) {
         $task[$index] = (int) $task[$index];
     }
     $task = join(',', $task);
     // $start = (int) $start; // those are strings, not numbers
     // $end = (int) $end; // those are strings, not numbers
     if ($user > 0) {
         $sql = "SELECT * FROM timetracker WHERE project = {$project} AND user = {$user}";
         $num = "SELECT COUNT(*) FROM timetracker WHERE project = {$project} AND user = {$user}";
         $order = " ORDER BY ended ASC";
     } else {
         $sql = "SELECT * FROM timetracker WHERE project = {$project}";
         $num = "SELECT COUNT(*) FROM timetracker WHERE project = {$project}";
         $order = " ORDER BY ended ASC";
     }
     if ($task > 0) {
         $sql .= " AND task in ({$task})";
         $num .= " AND task in ({$task})";
     }
     if ($start > 0 and $end > 0) {
         $start = strtotime($start);
         $end = strtotime($end . " +1 day");
         $end = $end - 1;
         $sql .= " AND ended >={$start} AND ended<={$end} ";
         $num .= " AND ended >={$start} AND ended<={$end} ";
     }
     if ($num) {
         $num = $conn->query($num)->fetch();
         $num = $num[0];
     } else {
         $num = 0;
     }
     $sql = $sql . $order;
     // needs to be refactored
     if ($lim > 0) {
         SmartyPaginate::connect();
         SmartyPaginate::setLimit($lim);
         SmartyPaginate::setTotal($num);
         $start = SmartyPaginate::getCurrentIndex();
         $lim = SmartyPaginate::getLimit();
         $limi = " LIMIT {$start},{$lim} ";
         $sql = $sql . $limi;
     }
     $sel = $conn->query($sql);
     $track = array();
     $ttask = new task();
     if (isset($sel)) {
         while ($data = @$sel->fetch()) {
             $endstring = date("H:i", $data["ended"]);
             $startstring = date("H:i", $data["started"]);
             $daystring = date(CL_DATEFORMAT, $data["ended"]);
             $tasks = $ttask->getTask($data["task"]);
             if (!empty($tasks)) {
                 $tasks = $tasks["title"];
                 $data["tname"] = $tasks;
             }
             $pname = $conn->query("SELECT name FROM projekte WHERE ID = {$data['project']}")->fetch();
             $pname = stripslashes($pname[0]);
             $uname = $conn->query("SELECT name FROM user WHERE ID = {$data['user']}")->fetch();
             $uname = stripslashes($uname[0]);
             $data["endstring"] = $endstring;
             $data["startstring"] = $startstring;
             $data["daystring"] = $daystring;
             $data["uname"] = $uname;
             $data["pname"] = $pname;
             $data["comment"] = stripslashes($data["comment"]);
             $data["comment"] = nl2br($data["comment"]);
             array_push($track, $data);
         }
     }
     if (!empty($track)) {
         return $track;
     } else {
         return false;
     }
 }
Ejemplo n.º 20
0
 function getUsers()
 {
     global $db, $conf;
     $query = "SELECT SQL_CALC_FOUND_ROWS\n\t\t\t\t u.id, u.name, u.mail, u.level, u.joined, u.download, u.upload, g.group FROM " . $this->prefix_db . "users AS u";
     $query .= " INNER JOIN users_group AS g ON u.level=g.id";
     $query .= " ORDER BY u.id DESC";
     $query .= " LIMIT %d,%d";
     $_query = sprintf($query, SmartyPaginate::getCurrentIndex(), SmartyPaginate::getLimit());
     $items = $db->get_results($_query);
     $_row = $db->get_row("SELECT FOUND_ROWS() as total");
     SmartyPaginate::setTotal($_row->total);
     foreach ($items as $obj) {
         $array[$obj->id]['id'] = $obj->id;
         $array[$obj->id]['name'] = $this->Fuckxss($obj->name);
         $array[$obj->id]['mail'] = $this->Fuckxss($obj->mail);
         $array[$obj->id]['level'] = $this->Fuckxss($obj->level);
         $array[$obj->id]['group'] = $obj->group;
         $array[$obj->id]['joined'] = $obj->joined;
         $array[$obj->id]['Hupload'] = $obj->upload;
         $array[$obj->id]['Hdownload'] = $obj->download;
         $array[$obj->id]['upload'] = $this->bytesToSize($obj->upload);
         $array[$obj->id]['download'] = $this->bytesToSize($obj->download);
         $array[$obj->id]['gravatarS'] = $this->get_gravatar($obj->mail, '50');
         $array[$obj->id]['gravatarL'] = $this->get_gravatar($obj->mail, '100');
         $array[$obj->id]['unameUrl'] = $conf['baseurl'] . '/' . $this->makeUrl(array('page' => 'user', 'act' => $obj->name)) . '/';
     }
     return $array;
 }
Ejemplo n.º 21
0
 /**
  * Returns all users
  *
  * @param int $lim Limit
  * @return array $users Registrierte Mitglieder
  */
 function getAllUsers($lim = 10)
 {
     $lim = (int) $lim;
     $sel = mysql_query("SELECT COUNT(*) FROM `user`");
     $num = mysql_fetch_row($sel);
     $num = $num[0];
     SmartyPaginate::connect();
     // set items per page
     SmartyPaginate::setLimit($lim);
     SmartyPaginate::setTotal($num);
     $start = SmartyPaginate::getCurrentIndex();
     $lim = SmartyPaginate::getLimit();
     $sel2 = mysql_query("SELECT * FROM `user` ORDER BY ID DESC LIMIT {$start},{$lim}");
     $users = array();
     while ($user = mysql_fetch_array($sel2)) {
         $user["name"] = stripslashes($user["name"]);
         $user["company"] = stripslashes($user["company"]);
         $user["adress"] = stripslashes($user["adress"]);
         $user["adress2"] = stripslashes($user["adress2"]);
         $user["state"] = stripslashes($user["state"]);
         $user["country"] = stripslashes($user["country"]);
         array_push($users, $user);
     }
     if (!empty($users)) {
         return $users;
     } else {
         return false;
     }
 }
function getSearchResults(&$dbcon, $searchSpec)
{
    $X = SmartyPaginate::getCurrentIndex();
    $Y = SmartyPaginate::getLimit();
    $searchSQL = "SELECT * FROM sionapros_pubs WHERE 1 {$searchSpec} ORDER BY pub_date DESC LIMIT {$X},{$Y}";
    $result = $dbcon->execute($searchSQL);
    $i = 0;
    foreach ($result as $row) {
        #$path = './admin'.substr($row['doc'], 1, strlen($row['doc']));
        $data[$i] = $row;
        #$data[$i]['path'] = $path;
        $i++;
    }
    // now we get the total number of records from the table
    $rowsSQL = "SELECT COUNT(*) FROM sionapros_pubs WHERE 1 {$searchSpec}";
    $dbcon->query($rowsSQL);
    #$rowNo = $rows[0];
    SmartyPaginate::setTotal($dbcon->getValue());
    return $data;
}
Ejemplo n.º 23
0
 /**
  * List all files associated to a given project
  *
  * @param string $id Project ID
  * @param int $lim Limit
  * @param int $folder Folder
  * @return array $files Found files
  */
 function getProjectFiles($id, $lim = 5000, $folder = "")
 {
     global $conn;
     $id = (int) $id;
     $lim = (int) $lim;
     $folder = (int) $folder;
     // If folder is given, return files from this folder, otherwise return files from root folder
     if ($folder > 0) {
         $fold = "files/" . CL_CONFIG . "/{$id}/{$folder}/";
         $sel = $conn->query("SELECT COUNT(*) FROM files WHERE project = {$id} AND folder = {$folder} ORDER BY ID DESC");
     } else {
         $sel = $conn->query("SELECT COUNT(*) FROM files WHERE project = {$id} AND folder = 0 ORDER BY ID DESC");
     }
     $num = $sel->fetch();
     $num = $num[0];
     // Set items per page
     SmartyPaginate::connect();
     SmartyPaginate::setLimit($lim);
     SmartyPaginate::setTotal($num);
     $start = SmartyPaginate::getCurrentIndex();
     $lim = SmartyPaginate::getLimit();
     $files = array();
     if ($folder > 0) {
         $sql = "SELECT ID FROM files WHERE project = {$id} AND folder = {$folder} ORDER BY  ID DESC LIMIT {$start},{$lim}";
         $sel2 = $conn->query($sql);
     } else {
         $sel2 = $conn->query("SELECT ID FROM files WHERE project = {$id} AND folder = 0 ORDER BY  ID DESC LIMIT {$start},{$lim}");
     }
     while ($file = $sel2->fetch()) {
         if (!empty($file)) {
             array_push($files, $this->getFile($file["ID"]));
         }
     }
     if (!empty($files)) {
         return $files;
     } else {
         return false;
     }
 }
Ejemplo n.º 24
0
/**
 * Project:     SmartyPaginate: Pagination for the Smarty Template Engine
 * File:        function.paginate_last.php
 * Author:      Monte Ohrt <monte at newdigitalgroup dot com>
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library 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
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 *
 * @link http://www.phpinsider.com/php/code/SmartyPaginate/
 * @copyright 2001-2005 New Digital Group, Inc.
 * @author Monte Ohrt <monte at newdigitalgroup dot com>
 * @package SmartyPaginate
 * @version 1.6-dev
 */
function smarty_function_paginate_last($params, &$smarty)
{
    global $startUp, $conf, $cat_id;
    $_id = 'default';
    $_attrs = array();
    if (!class_exists('SmartyPaginate')) {
        $smarty->trigger_error("paginate_last: missing SmartyPaginate class");
        return;
    }
    if (!isset($_SESSION['SmartyPaginate'])) {
        $smarty->trigger_error("paginate_last: SmartyPaginate is not initialized, use connect() first");
        return;
    }
    foreach ($params as $_key => $_val) {
        switch ($_key) {
            case 'id':
                if (!SmartyPaginate::isConnected($_val)) {
                    $smarty->trigger_error("paginate_last: unknown id '{$_val}'");
                    return;
                }
                $_id = $_val;
                break;
            default:
                $_attrs[] = $_key . '="' . $_val . '"';
                break;
        }
    }
    if (SmartyPaginate::getTotal($_id) === false) {
        $smarty->trigger_error("paginate_last: total was not set");
        return;
    }
    $_url = SmartyPaginate::getURL($_id);
    $_total = SmartyPaginate::getTotal($_id);
    $_limit = SmartyPaginate::getLimit($_id);
    $_attrs = !empty($_attrs) ? ' ' . implode(' ', $_attrs) : '';
    $_text = isset($params['text']) ? $params['text'] : SmartyPaginate::getLastText($_id);
    $_url .= strpos($_url, '?') === false ? '?' : '&';
    $_url .= SmartyPaginate::getUrlVar($_id) . '=';
    $_url .= $_total % $_limit > 0 ? $_total - $_total % $_limit + 1 : $_total - $_limit + 1;
    $lastId = $_total % $_limit > 0 ? $_total - $_total % $_limit + 1 : $_total - $_limit + 1;
    if ($cat_id != 'NULL') {
        if (!empty($_GET["sortedBy"]) || !empty($_GET["axis"])) {
            $final_url = $startUp->makeUrl(array('page' => $startUp->paginatePage, 'gost' => 'cat', 'catid' => $cat_id, 'next' => $lastId, 'sortedBy' => $_GET["sortedBy"], 'axis' => $_GET["axis"]));
        } else {
            $final_url = $startUp->makeUrl(array('page' => $startUp->paginatePage, 'gost' => 'cat', 'catid' => $cat_id, 'next' => $lastId));
        }
    } elseif ($_GET['page'] === "admincp") {
        $final_url = $startUp->makeUrl(array('page' => $startUp->paginatePage, 'next' => $lastId)) . '?tokenAdmin=' . $_COOKIE['tokenAdmin'];
    } else {
        if (!empty($_GET["sortedBy"]) || !empty($_GET["axis"])) {
            $final_url = $startUp->makeUrl(array('page' => $startUp->paginatePage, 'next' => $lastId, 'sortedBy' => $_GET["sortedBy"], 'axis' => $_GET["axis"]));
        } else {
            $final_url = $startUp->makeUrl(array('page' => $startUp->paginatePage, 'next' => $lastId));
        }
    }
    /* if ($cat_id!='NULL') 
    $final_url = $startUp->makeUrl(array('page'=>$startUp->paginatePage,'catid'=>$cat_id,'next'=>$lastId)); 
    else
    $final_url = $startUp->makeUrl(array('page'=>$startUp->paginatePage,'next'=>$lastId)); */
    return '<a href="' . $conf['baseurl'] . '/' . $final_url . '"' . $_attrs . '>' . $_text . '</a>';
    // return '<a href="' . str_replace('&','&amp;', $_url) . '"' . $_attrs . '>' . $_text . '</a>';
}
/**
 * Project:     SmartyPaginate: Pagination for the Smarty Template Engine
 * File:        function.paginate_last.php
 * Author:      Monte Ohrt <monte at newdigitalgroup dot com>
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library 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
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 *
 * @link http://www.phpinsider.com/php/code/SmartyPaginate/
 * @copyright 2001-2005 New Digital Group, Inc.
 * @author Monte Ohrt <monte at newdigitalgroup dot com>
 * @package SmartyPaginate
 * @version 1.6-dev
 */

function smarty_function_paginate_last($params, &$smarty) {

    $_id = 'default';
    $_attrs = array();

    if (!class_exists('SmartyPaginate')) {
        $smarty->trigger_error("paginate_last: missing SmartyPaginate class");
        return;
    }
    if (!isset($_SESSION['SmartyPaginate'])) {
        $smarty->trigger_error("paginate_last: SmartyPaginate is not initialized, use connect() first");
        return;
    }

    foreach($params as $_key => $_val) {
        switch($_key) {
            case 'id':
                if (!SmartyPaginate::isConnected($_val)) {
                    $smarty->trigger_error("paginate_last: unknown id '$_val'");
                    return;
                }
                $_id = $_val;
                break;
            default:
                $_attrs[] = $_key . '="' . $_val . '"';
                break;
        }
    }

    if (SmartyPaginate::getTotal($_id) === false) {
        $smarty->trigger_error("paginate_last: total was not set");
        return;
    }

    $_url = $_SERVER['REQUEST_URI'];
    $url = explode("?", $_url);
    $aurl = $url[0];
    $url = $url[1];
    $url = explode("&", $url);
    $_url = "";
    $i = 0;
    foreach($url as $uri)
    {
        if (!strstr($uri, "next"))
        {
            if ($i > 0)
            {
                $_url .= "&" . $uri;
            }
            else
            {
                $_url .= $uri;
            }
        }
        $i = $i + 1;
    }
    $_url = $aurl . "?" . $_url;

    $_total = SmartyPaginate::getTotal($_id);
    $_limit = SmartyPaginate::getLimit($_id);

    $_attrs = !empty($_attrs) ? ' ' . implode(' ', $_attrs) : '';

    $_text = isset($params['text']) ? $params['text'] : SmartyPaginate::getLastText($_id);
    $_url .= (strpos($_url, '?') === false) ? '?' : '&';
    $_url .= SmartyPaginate::getUrlVar($_id) . '=';
    $_url .= ($_total % $_limit > 0) ? $_total - ( $_total % $_limit ) + 1 : $_total - $_limit + 1;

   // return '<a class = "next" href="' . str_replace('&','&amp;', $_url) . '"' . $_attrs . '>' . $_text . '</a>';
  return '<a  href="' . str_replace('&','&amp;', $_url) . '"' . $_attrs . '><img src = "templates/' . $smarty->tname . '/images/paging_next.png" alt = ""  /></a>';
}
Ejemplo n.º 26
0
    /**
     * Returns all users
     *
     * @param int $lim Limit
     * @return array $users Registrierte Mitglieder
     */
    function getAllUsers($lim = 10)
    {
        $lim = (int) $lim;

        $sel = mysql_query("SELECT COUNT(*) FROM `user`");
        $num = mysql_fetch_row($sel);
        $num = $num[0];
        SmartyPaginate::connect();
        // set items per page
        SmartyPaginate::setLimit($lim);
        SmartyPaginate::setTotal($num);

        $start = SmartyPaginate::getCurrentIndex();
        $lim = SmartyPaginate::getLimit();

       $sel2 = mysql_query("SELECT ID FROM `user` ORDER BY ID DESC LIMIT $start,$lim");

        $users = array();
        while ($user = mysql_fetch_array($sel2))
        {
            array_push($users, $this->getProfile($user["ID"]));
        }

        if (!empty($users))
        {
            return $users;
        }
        else
        {
            return false;
        }
    }
Ejemplo n.º 27
0
/**
 * Project:     SmartyPaginate: Pagination for the Smarty Template Engine
 * File:        function.paginate_middle.php
 * Author:      Monte Ohrt <monte at newdigitalgroup dot com>
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library 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
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 *
 * @link http://www.phpinsider.com/php/code/SmartyPaginate/
 * @copyright 2001-2005 New Digital Group, Inc.
 * @author Monte Ohrt <monte at newdigitalgroup dot com>
 * @package SmartyPaginate
 * @version 1.6-dev
 */
function smarty_function_paginate_middle($params, &$smarty)
{
    global $startUp, $conf, $cat_id;
    $_id = 'default';
    $_prefix = '[';
    $_suffix = ']';
    $_link_prefix = '';
    $_link_suffix = '';
    $_page_limit = null;
    $_attrs = array();
    if (!class_exists('SmartyPaginate')) {
        $smarty->trigger_error("paginate_middle: missing SmartyPaginate class");
        return;
    }
    if (!isset($_SESSION['SmartyPaginate'])) {
        $smarty->trigger_error("paginate_middle: SmartyPaginate is not initialized, use connect() first");
        return;
    }
    foreach ($params as $_key => $_val) {
        switch ($_key) {
            case 'id':
                if (!SmartyPaginate::isConnected($_val)) {
                    $smarty->trigger_error("paginate_middle: unknown id '{$_val}'");
                    return;
                }
                $_id = $_val;
                break;
            case 'prefix':
                $_prefix = $_val;
                break;
            case 'suffix':
                $_suffix = $_val;
                break;
            case 'link_prefix':
                $_link_prefix = $_val;
                break;
            case 'link_suffix':
                $_link_suffix = $_val;
                break;
            case 'page_limit':
                $_page_limit = $_val;
                break;
            case 'format':
                break;
            default:
                $_attrs[] = $_key . '="' . $_val . '"';
                break;
        }
    }
    if (!isset($_SESSION['SmartyPaginate'][$_id]['item_total'])) {
        $smarty->trigger_error("paginate_middle: total was not set");
        return;
    }
    if (!isset($_page_limit) && isset($_SESSION['SmartyPaginate'][$_id]['page_limit'])) {
        $_page_limit = $_SESSION['SmartyPaginate'][$_id]['page_limit'];
    }
    $_url = $_SESSION['SmartyPaginate'][$_id]['url'];
    $_total = SmartyPaginate::getTotal($_id);
    $_curr_item = SmartyPaginate::getCurrentItem($_id);
    $_limit = SmartyPaginate::getLimit($_id);
    $_item = 1;
    $_page = 1;
    $_display_pages = 0;
    $_ret = '';
    $_attrs = !empty($_attrs) ? ' ' . implode(' ', $_attrs) : '';
    if (isset($_page_limit)) {
        // find halfway point
        $_page_limit_half = floor($_page_limit / 2);
        // determine what item/page we start with
        $_item_start = $_curr_item - $_limit * $_page_limit_half;
        if (($_view = ceil(($_total - $_item_start) / $_limit)) < $_page_limit) {
            $_item_start -= $_limit * ($_page_limit - $_view);
        }
        $_item = $_item_start >= 1 ? $_item_start : 1;
        $_page = ceil($_item / $_limit);
    }
    while ($_item <= $_total) {
        if (isset($params['format']) && $params['format'] == 'page') {
            $_text = $_prefix . $_page . $_suffix;
        } else {
            $_text = $_prefix . $_item . '-';
            $_text .= $_item + $_limit - 1 <= $_total ? $_item + $_limit - 1 : $_total;
            $_text .= $_suffix;
        }
        if ($_item != $_curr_item) {
            if ($cat_id != 'NULL') {
                if (!empty($_GET["sortedBy"]) || !empty($_GET["axis"])) {
                    $final_url = $startUp->makeUrl(array('page' => $startUp->paginatePage, 'gost' => 'cat', 'catid' => $cat_id, 'next' => $_item, 'sortedBy' => $_GET["sortedBy"], 'axis' => $_GET["axis"]));
                } else {
                    $final_url = $startUp->makeUrl(array('page' => $startUp->paginatePage, 'gost' => 'cat', 'catid' => $cat_id, 'next' => $_item));
                }
            } elseif ($_GET['page'] === "admincp") {
                $final_url = $startUp->makeUrl(array('page' => $startUp->paginatePage, 'next' => $_item)) . '?tokenAdmin=' . $_COOKIE['tokenAdmin'];
            } else {
                if (!empty($_GET["sortedBy"]) || !empty($_GET["axis"])) {
                    $final_url = $startUp->makeUrl(array('page' => $startUp->paginatePage, 'next' => $_item, 'sortedBy' => $_GET["sortedBy"], 'axis' => $_GET["axis"]));
                } else {
                    $final_url = $startUp->makeUrl(array('page' => $startUp->paginatePage, 'next' => $_item));
                }
            }
            $_this_url = $_url;
            $_this_url .= strpos($_url, '?') === false ? '?' : '&';
            $_this_url .= SmartyPaginate::getUrlVar($_id) . '=' . $_item;
            $_ret .= $_link_prefix . '<li><a href="' . $conf['baseurl'] . '/' . $final_url . '"' . $_attrs . '>' . $_text . '</a></li>' . $_link_suffix;
            // $_ret .= $_link_prefix . '<li><a href="' . str_replace('&', '&amp;', $_this_url) . '"' . $_attrs . '>' . $_text . '</a></li>' . $_link_suffix;
        } else {
            $_ret .= '<li class="disabled"><a>' . $_link_prefix . $_text . $_link_suffix . '</a></li>';
        }
        $_item += $_limit;
        $_page++;
        $_display_pages++;
        if (isset($_page_limit) && $_display_pages == $_page_limit) {
            break;
        }
    }
    return $_ret;
}