[PC-BSD Commits] r1404 - in websites/pbidir.com/bibivu: bin etc lib slib tpl tpl/css tpl/js tpl/pbidir/admin
svn at pcbsd.org
svn at pcbsd.org
Mon Feb 18 21:26:26 PST 2008
Author: fabry
Date: 2008-02-18 21:26:25 -0800 (Mon, 18 Feb 2008)
New Revision: 1404
Added:
websites/pbidir.com/bibivu/tpl/js/functions.js
websites/pbidir.com/bibivu/tpl/pbidir/admin/search.php
Removed:
websites/pbidir.com/bibivu/tpl/functions.js
websites/pbidir.com/bibivu/tpl/js/jquery.tablesorter.pack.js
websites/pbidir.com/bibivu/tpl/js/jquery.tablesorter.pager.js
Modified:
websites/pbidir.com/bibivu/bin/admin.php
websites/pbidir.com/bibivu/bin/start.php
websites/pbidir.com/bibivu/etc/display.conf.php
websites/pbidir.com/bibivu/lib/category.php
websites/pbidir.com/bibivu/lib/pbi.php
websites/pbidir.com/bibivu/lib/user.php
websites/pbidir.com/bibivu/slib/table_prototype.php
websites/pbidir.com/bibivu/tpl/css/pbidir.css
websites/pbidir.com/bibivu/tpl/pbidir/admin/list.php
Log:
- pagination and modification on how the tables are ordered.
- added a parameter that will allow to specify how big the image should show. This parameter will be used to resize the images.
Modified: websites/pbidir.com/bibivu/bin/admin.php
===================================================================
--- websites/pbidir.com/bibivu/bin/admin.php 2008-02-19 01:07:52 UTC (rev 1403)
+++ websites/pbidir.com/bibivu/bin/admin.php 2008-02-19 05:26:25 UTC (rev 1404)
@@ -3,6 +3,7 @@
class admin extends bibivu{
public $ajax = false;
+ private $limitpp = 50; //how many per page
/**
* Initialize the default class
*
@@ -217,25 +218,76 @@
} else {
$no_access = true;
}
+ }elseif(!is_null($this->uri->get('search',NULL))){
+ $form_field = trim(htmlentities($_POST['ff'], ENT_COMPAT, 'UTF-8'));
+ $search_field = trim(htmlentities($_POST['sf'], ENT_COMPAT, 'UTF-8'));
+ $search_value = trim(htmlentities($_POST['sv'], ENT_COMPAT, 'UTF-8'));
+ if($search_value!=''){
+ $filters = array();
+ $filters[] = array('field'=>$search_field, 'operator'=>'like', 'value'=>$search_value);
+ $records = $this->$what->get_all($filters, array(), array(), 1);
+ } else {
+ $records = array();
+ }
+ $this->display->assign('records',$records);
+ $this->display->assign('ff',$from_field);
+ $this->display->assign('sf',$search_field);
+ $this->display->assign('sv',$search_value);
+ $this->display('admin/search', !$this->ajax);
} else {
$where = array();
+ $order = array();
+ $group = array();
+ $limit = '';
$array_add_uri = array('add'=>'', 'ajax'=>'');
- if(isset($_POST) && is_array($_POST) && !empty($_POST)){
+ if((isset($_POST) && is_array($_POST) && !empty($_POST)) || $this->uri->get('order','')!=''){
$fields = $this->$what->get_fields();
- $str = '^('.implode('|', array_keys($fields)).').?(ASC|DESC)?$';
+ $str = '^('.implode('|', array_keys($fields)).')( (ASC|DESC))?$';
foreach($_POST as $key=>$value){
if(eregi($str,$key)){
$where[] = array('field'=>$key, 'operator'=>'=', 'value'=>$value);
$array_add_uri[$key] = $value;
+ $this->uri->auto_add($key,$value);
}
}
+ if(eregi($str,$this->uri->get('order',''))){
+ if($this->uri->get('dir','ASC')=='DESC'){
+ $order[] = $this->uri->get('order','').' DESC';
+ } else {
+ $order[] = $this->uri->get('order','').' ASC';
+ $this->uri->set('dir','ASC');
+ }
+ } else {
+ $this->uri->set('order','');
+ }
}
+ if(!$this->ajax){
+ $this->uri->set('page',(int)$this->uri->get('page',0));
+ $limit = ($this->limitpp*$this->uri->get('page',0)).','.$this->limitpp;
+
+ $this->uri->auto_add('page',$this->uri->get('page',0));
+ $this->uri->auto_add('order',$this->uri->get('order'));
+ $this->uri->auto_add('dir',$this->uri->get('dir'));
+ }
+
$this->display->assign('can_read',$this->_check_can($what, 'read'));
$this->display->assign('can_write',$this->_check_can($what, 'write'));
$this->display->assign('can_delete',$this->_check_can($what, 'delete'));
$this->display->assign('add_uri',$this->uri->create_uri($array_add_uri));
- $this->display->assign('records',$this->$what->get_all($where, array($this->uri->get('order',''))));
- $this->display->assign('page_name','administration - '.$what);
+ $this->display->assign('records',$this->$what->get_all($where, $order, $group, $limit));
+ $tot = count($this->display->get('records'));
+ if(!$this->ajax){
+ if($tot>=$this->limitpp || $this->uri->get('page',0)>0){
+ //need to get a total count, so I can display the pagination
+ $tot = $this->$what->get_count($where, $group);
+ }
+ } else {
+ $this->limitpp = $tot;
+ }
+
+ $this->display->assign('total_records',$tot);
+ $this->display->assign('total_per_page',$this->limitpp);
+ $this->display->assign('page_name','administration - '.$what);//.' - page '.($this->uri->get('page',0)+1));
$this->display('admin/'.$this->uri->get('how','list'), !$this->ajax);
}
if($no_access){
Modified: websites/pbidir.com/bibivu/bin/start.php
===================================================================
--- websites/pbidir.com/bibivu/bin/start.php 2008-02-19 01:07:52 UTC (rev 1403)
+++ websites/pbidir.com/bibivu/bin/start.php 2008-02-19 05:26:25 UTC (rev 1404)
@@ -53,7 +53,7 @@
$this->display->assign('task','home');
$this->web_home();
} else {
- $this->display->assign('search_text',trim(str_replace('/',' ',implode(' ',$this->uri->get_GETnum()))));
+ $this->display->assign('search_text',trim(str_replace('/',' ', at implode(' ', $this->uri->get_GETnum()))));
$this->display->assign('task','search');
$this->web_search();
}
Modified: websites/pbidir.com/bibivu/etc/display.conf.php
===================================================================
--- websites/pbidir.com/bibivu/etc/display.conf.php 2008-02-19 01:07:52 UTC (rev 1403)
+++ websites/pbidir.com/bibivu/etc/display.conf.php 2008-02-19 05:26:25 UTC (rev 1404)
@@ -18,20 +18,31 @@
$display['meta'][0]['http-equiv'] = 'Content-type';
$display['meta'][0]['content'] = 'text/html; charset=iso-8859-1';
+
$display['meta'][1]['name'] = 'Author';
$display['meta'][1]['content'] = 'Fabrizio Parrella';
-$display['meta'][2]['name'] = 'Identifier-URL';
-$display['meta'][2]['content'] = 'http://www.pbidir.com';
+
+//$display['meta'][2]['name'] = 'Identifier-URL';
+//$display['meta'][2]['content'] = 'http://www.pbidir.com';
+$display['meta'][2]['name'] = 'keywords';
+$display['meta'][2]['content'] = 'pbi, pbidir, software, pcbsd, pc-bsd, freebsd, free, open-source, desktop, operating system, bsd, open source';
+
$display['meta'][3]['name'] = 'Copyright';
$display['meta'][3]['content'] = 'Fabrizio Parrella';
+
$display['meta'][4]['name'] = 'Revisit-after';
$display['meta'][4]['content'] = '1 day';
+
$display['meta'][5]['name'] = 'Robots';
-$display['meta'][5]['content'] = 'all';
+$display['meta'][5]['content'] = 'index, follow';
+
$display['meta'][6]['http-equiv'] = 'imagetoolbar';
$display['meta'][6]['content'] = 'no';
+$display['meta'][7]['name'] = 'description';
+$display['meta'][7]['content'] = 'pbi Directory, where you can find software for your PC-BSD operating system';
+
$display['link'][1]['type'] = 'text/css';
$display['link'][1]['rel'] = 'stylesheet';
$display['link'][1]['title'] = 'default';
@@ -43,9 +54,11 @@
$display['script'][0]['src'] = TPLWEBPATH.'js/jquery-1.2.1.pack.js';
//$display['script'][0]['src'] = 'http://code.jquery.com/nightlies/jquery-nightly.pack.js';
+/*
$display['script'][1]['type'] = 'text/javascript';
$display['script'][1]['language'] = 'javascript';
$display['script'][1]['src'] = TPLWEBPATH.'js/jquery.tablesorter.pack.js';
+*/
/*
$display['script'][2]['type'] = 'text/javascript';
@@ -55,6 +68,6 @@
$display['script'][99]['type'] = 'text/javascript';
$display['script'][99]['language'] = 'javascript';
-$display['script'][99]['src'] = TPLWEBPATH.'functions.js';
+$display['script'][99]['src'] = TPLWEBPATH.'js/functions.js';
?>
\ No newline at end of file
Modified: websites/pbidir.com/bibivu/lib/category.php
===================================================================
--- websites/pbidir.com/bibivu/lib/category.php 2008-02-19 01:07:52 UTC (rev 1403)
+++ websites/pbidir.com/bibivu/lib/category.php 2008-02-19 05:26:25 UTC (rev 1404)
@@ -108,6 +108,8 @@
'post' => true,
'default' => NULL,
'image' => true,
+ 'image_width' => 40,
+ 'image_heigth' => NULL,
);
$this->fields = $fields;
}
Modified: websites/pbidir.com/bibivu/lib/pbi.php
===================================================================
--- websites/pbidir.com/bibivu/lib/pbi.php 2008-02-19 01:07:52 UTC (rev 1403)
+++ websites/pbidir.com/bibivu/lib/pbi.php 2008-02-19 05:26:25 UTC (rev 1404)
@@ -297,6 +297,8 @@
'post' => true,
'default' => NULL,
'image' => true,
+ 'image_width' => 40,
+ 'image_heigth' => NULL,
);
$this->fields = $fields;
}
Modified: websites/pbidir.com/bibivu/lib/user.php
===================================================================
--- websites/pbidir.com/bibivu/lib/user.php 2008-02-19 01:07:52 UTC (rev 1403)
+++ websites/pbidir.com/bibivu/lib/user.php 2008-02-19 05:26:25 UTC (rev 1404)
@@ -32,7 +32,7 @@
'main_field' => 'pbi_id',
'show' => 'list', //field, list
'name' => 'Subscriptions',
- 'autoopen' => true,
+ 'autoopen' => false,
'relation_table'=> array(
'table' => 'subscriptions',
'field' => 'user_id',
Modified: websites/pbidir.com/bibivu/slib/table_prototype.php
===================================================================
--- websites/pbidir.com/bibivu/slib/table_prototype.php 2008-02-19 01:07:52 UTC (rev 1403)
+++ websites/pbidir.com/bibivu/slib/table_prototype.php 2008-02-19 05:26:25 UTC (rev 1404)
@@ -262,6 +262,18 @@
}
return $records;
}
+
+ /*
+ * this function returns every records
+ * and pass it throu the get_info function
+ */
+ public function get_count($where=array(), $group=array(), $from='', $join = array()){
+ $records = array();
+ $this->select()->fields('COUNT(*) tot')->from($from)->where($where)->group($group)->limit(1)->do_db();
+ $tmps = $this->last_result;
+ $record = $this->db->fetch_array($tmps);
+ return $record['tot']+0;
+ }
/*
* this function returns ONLY what is in the records
Modified: websites/pbidir.com/bibivu/tpl/css/pbidir.css
===================================================================
--- websites/pbidir.com/bibivu/tpl/css/pbidir.css 2008-02-19 01:07:52 UTC (rev 1403)
+++ websites/pbidir.com/bibivu/tpl/css/pbidir.css 2008-02-19 05:26:25 UTC (rev 1404)
@@ -600,7 +600,15 @@
th.headerSortUp a, th.headerSortDown a{
color:#FFFFFF;
text-decoration:none;
+ padding-left: 10px;
}
+th.headerSortDown a{
+ background: url(/bibivu/tpl/pbidir/images/decr.gif) 0 65% no-repeat;
+}
+
+th.headerSortUp a{
+ background: url(/bibivu/tpl/pbidir/images/cres.gif) 0 65% no-repeat;
+}
.form{
padding:10px;
border:1px double #EBEBEB;
Deleted: websites/pbidir.com/bibivu/tpl/functions.js
Added: websites/pbidir.com/bibivu/tpl/js/functions.js
Deleted: websites/pbidir.com/bibivu/tpl/js/jquery.tablesorter.pack.js
Deleted: websites/pbidir.com/bibivu/tpl/js/jquery.tablesorter.pager.js
Modified: websites/pbidir.com/bibivu/tpl/pbidir/admin/list.php
===================================================================
--- websites/pbidir.com/bibivu/tpl/pbidir/admin/list.php 2008-02-19 01:07:52 UTC (rev 1403)
+++ websites/pbidir.com/bibivu/tpl/pbidir/admin/list.php 2008-02-19 05:26:25 UTC (rev 1404)
@@ -9,13 +9,40 @@
?><a href="<?=$add_uri?>/id/0" title="Add New" class="divBox" id="add_new">Add New</a> <?php
}
if(isset($records) && is_array($records) && count($records)>0){
+ $tot_columns = 0; //number of columns in this table
+/*
if(!$ajax){
- ?><label for="filter">Filters:</label> <input type="text" id="filter" value="" size="50" />(press enter to search)<br /><br /><?php
- } ?>
- <table class="sortable list" cellspacing="0"><thead class="head"><tr class="row"><?php
+ ?> <label for="filter">Filters:</label> <input type="text" id="filter" value="" size="50" />(press enter to search)<br /><br /><?php
+ }
+*/
+ $params = array('order'=>load_class('uri')->get('order'), 'dir'=>load_class('uri')->get('dir'));
+ $current_page = load_class('uri')->get('page',0);
+ $tot_pages = ceil($total_records/$total_per_page);
+ if($tot_pages>1){
+ if(load_class('uri')->get('page',0)>0){
+ //need to allow the user to go to the previous page
+ ?>[<a href="<?=load_class('uri')->create_uri(array_merge($params, array('page'=>0)))?>"><< first</a>] [<a href="<?=load_class('uri')->create_uri(array_merge($params, array('page'=>(load_class('uri')->get('page',0)-1))))?>">< previous</a>]<?php
+ } else {
+ ?>[<< first] [< previous]<?php
+ }
+ ?> Page <?=($current_page+1)?>/<?=$tot_pages?> <?php
+ if(($current_page+1)<$tot_pages){
+ //need to allow the user to go to the previous page
+ ?>[<a href="<?=load_class('uri')->create_uri(array_merge($params, array('page'=>(load_class('uri')->get('page',0)+1))))?>">next ></a>] [<a href="<?=load_class('uri')->create_uri(array_merge($params, array('page'=>$tot_pages)))?>">last >></a>]<?php
+ } else {
+ ?>[next >] [last >>]<?php
+ }
+ }
+ ?><br /><br /><table class="sortable list" cellspacing="0"><thead class="head"><tr class="row"><?php
foreach($fields as $key=>$value){
if($value['show']===true || $value['show']=='list' || (is_array($value['show']) && in_array('list',$value['show']))){
- ?><th class="field"><?=$value['text']?></th><?php
+ $tot_columns++;
+ ?><th class="field <?=load_class('uri')->get('order')==$key?(load_class('uri')->get('dir')=='ASC'?'headerSortUp':'headerSortDown'):''?>"><?php
+ if($ajax){
+ ?><a href="javascript:void(0);" onclick="show_related_table('<?=load_class('uri')->create_uri(array('order'=>$key, 'dir'=>(load_class('uri')->get('order')==$key && load_class('uri')->get('dir')=='ASC'?'DESC':'ASC')))?>', '<?=$_POST['_srt_field_to']?>', '<?=$_POST['_srt_field_from']?>', '<?=$_POST['_srt_div']?>', '')"><?=$value['text']?></a><?php
+ } else {
+ ?><a href="<?=load_class('uri')->create_uri(array('order'=>$key, 'dir'=>(load_class('uri')->get('order')==$key && load_class('uri')->get('dir')=='ASC'?'DESC':'ASC')))?>"><?=$value['text']?></a><?php
+ } ?></th><?php
}
}
?></tr></thead><tbody><?php
@@ -45,7 +72,14 @@
?><a href="<?=$value['view_link']?>/id/<?=$record['id']?>" title="Edit Record <?=$record['id']?>" class="divBox field_edit"><?php
}
if($value['image']!==false && $record[$key]!=''){
- ?><img border="0" src="<?=$record[$key]?>" title="<?=$record[$key]?>" alt="<?=$record[$key]?>" /><?php
+ ?><img border="0" src="<?=$record[$key]?>" title="<?=$record[$key]?>" alt="<?=$record[$key]?>"<?php
+ if(isset($value['image_width']) && $value['image_width']>0){
+ ?> width="<?=$value['image_width']?>"<?php
+ }
+ if(isset($value['image_heigth']) && $value['image_heigth']>0){
+ ?> heigth="<?=$value['image_heigth']?>"<?php
+ }
+ ?>/><?php
} else {
?><?=$rec_value?> <?php
}
@@ -57,18 +91,34 @@
}
?></tr><?php
}
- ?></tbody>
-<?php
-/*
- <tfoot>
- <tr class="row foot">
- <td class="field">field TOTALS</td>
- <td class="field">field TOTALS</td>
- <td class="field">field TOTALS</td>
- </tr>
- </tfoot>
-*/
-?></table><?php
+ ?></tbody><tfoot><tr class="row foot"><?php
+ foreach($fields as $key=>$value){
+ if($value['show']===true || $value['show']=='list' || (is_array($value['show']) && in_array('list',$value['show']))){
+ //in the future this will contain the columns that will need to have a total
+ ?><td class="field"> </td><?php
+ }
+ }
+
+ ?></tr></tfoot></table>Displaying <?=($current_page*$total_per_page)+1?> to <?=$total_records>(($current_page+1)*$total_per_page)?(($current_page+1)*$total_per_page):$total_records?> of <?=$total_records?><br /><br /><?php
+ if($tot_pages>1){
+ if(load_class('uri')->get('page',0)>0){
+ //need to allow the user to go to the previous page
+ ?>[<a href="<?=load_class('uri')->create_uri($params)?>"><< first</a>] [<a href="<?=load_class('uri')->create_uri(array_merge($params, array('page'=>(load_class('uri')->get('page',0)-1))))?>">< previous</a>]<?php
+ } else {
+ ?>[<< first] [< previous]<?php
+ }
+ ?> Page <?=($current_page+1)?>/<?=$tot_pages?> <?php
+ if(($current_page+1)<$tot_pages){
+ //need to allow the user to go to the previous page
+ ?>[<a href="<?=load_class('uri')->create_uri(array_merge($params, array('page'=>(load_class('uri')->get('page',0)+1))))?>">next ></a>] [<a href="<?=load_class('uri')->create_uri(array_merge($params, array('page'=>$tot_pages)))?>">last >></a>]<?php
+ } else {
+ ?>[next >] [last >>]<?php
+ }
+ ?> --- Go to Page: <?php
+ for($i=1; $i<=$tot_pages; $i++){
+ ?><a href="<?=load_class('uri')->create_uri(array_merge($params, array('page'=>$i-1)))?>"><?=$i?></a> <?php
+ }
+ }
} else {
?><br />No Records To Show !<?php
}
Added: websites/pbidir.com/bibivu/tpl/pbidir/admin/search.php
More information about the Commits
mailing list