[Linpha-cvs] SF.net SVN: linpha: [4395] trunk/linpha2
Status: Inactive
Brought to you by:
bzrudi
From: <fan...@us...> - 2006-03-04 13:19:11
|
Revision: 4395 Author: fangehrn Date: 2006-03-04 05:18:41 -0800 (Sat, 04 Mar 2006) ViewCVS: http://svn.sourceforge.net/linpha/?rev=4395&view=rev Log Message: ----------- * implemented basic basket functions Modified Paths: -------------- trunk/linpha2/ChangeLog trunk/linpha2/index.php trunk/linpha2/lib/classes/linpha.imgview.class.php trunk/linpha2/lib/classes/linpha.other.php trunk/linpha2/lib/modules/module.albums.php trunk/linpha2/templates/main_html/view_basket.html.php Added Paths: ----------- trunk/linpha2/lib/modules/module.basket.php trunk/linpha2/templates/main_css/basket.css trunk/linpha2/templates/main_css/global.css trunk/linpha2/templates/main_css/view_basket.css trunk/linpha2/templates/main_css/view_img.css trunk/linpha2/templates/main_css/view_thumb.css trunk/linpha2/templates/main_css/view_thumbdetail.css trunk/linpha2/templates/main_html/basket.html.php Modified: trunk/linpha2/ChangeLog =================================================================== --- trunk/linpha2/ChangeLog 2006-03-04 10:43:35 UTC (rev 4394) +++ trunk/linpha2/ChangeLog 2006-03-04 13:18:41 UTC (rev 4395) @@ -1,7 +1,7 @@ 2006-03-04 flo * fixed some double declarations in installer - * working on basket + * implemented basic basket functions 2006-03-04 flo * testing svn Modified: trunk/linpha2/index.php =================================================================== --- trunk/linpha2/index.php 2006-03-04 10:43:35 UTC (rev 4394) +++ trunk/linpha2/index.php 2006-03-04 13:18:41 UTC (rev 4395) @@ -3,26 +3,41 @@ include_once(LINPHA_DIR.'/lib/include/common.php'); -if(!isset($_GET['cat'])) -{ - $_GET['cat'] = 'alb'; -} +/** + * some init stuff + * @todo where to place? + */ + if(!isset($_GET['cat'])) + { + $_GET['cat'] = 'alb'; + } + if( ! isset( $_SESSION['basket_ids'] ) ) + { + $_SESSION['basket_ids'] = Array(); + } + + $output['menu_main'] = Array( + 'home' => LINPHA_DIR . '/', + 'admin' => '#', /*LINPHA_DIR . '/?cat=admin'*/ + 'search' => '#', /*LINPHA_DIR . '/?cat=search'*/ + 'login' => '#' /*LINPHA_DIR . '/?cat=login'*/ + ); -$output['menu_main'] = Array( - 'home' => LINPHA_DIR . '/', - 'admin' => '#', /*LINPHA_DIR . '/?cat=admin'*/ - 'search' => '#', /*LINPHA_DIR . '/?cat=search'*/ - 'login' => '#' /*LINPHA_DIR . '/?cat=login'*/ -); +/** + * open modules + */ switch($_GET['cat']) { case 'alb': - include_once(LINPHA_DIR.'/lib/module.albums.php'); + include_once(LINPHA_DIR.'/lib/modules/module.albums.php'); break; case 'search': - include_once(LINPHA_DIR.'/lib/module.search.php'); + include_once(LINPHA_DIR.'/lib/modules/module.search.php'); break; +case 'basket': + include_once(LINPHA_DIR.'/lib/modules/module.basket.php'); + break; } ?> \ No newline at end of file Modified: trunk/linpha2/lib/classes/linpha.imgview.class.php =================================================================== --- trunk/linpha2/lib/classes/linpha.imgview.class.php 2006-03-04 10:43:35 UTC (rev 4394) +++ trunk/linpha2/lib/classes/linpha.imgview.class.php 2006-03-04 13:18:41 UTC (rev 4395) @@ -6,7 +6,7 @@ * config stuff * @todo ... */ -$show_subfolders_separate = 1; +$show_subfolders_separate = 0; $nr_prev_next_thumbs = 3; $nr_random_images = 4; $array_tn_sizes = Array(50,75,100,150,200,250,300,400,500); @@ -182,12 +182,15 @@ if($this->id_current != 0) { /** - * for double used menu entry 'view' + * more than one time used stuff */ foreach($GLOBALS['array_sort_orders'] AS $value) { $array_sort_orders_links[$value] = $this->link_url.'&id='.$this->id_current.'&order_by='.$value; } + + $open_basket_link = LINPHA_DIR.'?cat=basket&ref_id='.$this->id_current; + $edit_permission_link = LINPHA_DIR.'/admin/permissions.php?&cmd=edit&id='.$this->id_current; switch($this->view) { @@ -209,9 +212,10 @@ $GLOBALS['output']['menu_optional'] = Array( 'basket' => Array( - 'add all to basket' => '#', + 'add all to basket' => $open_basket_link.'&cmd=add_all', 'switch to basket view' => $this->link_url.'&id='.$this->id_current.'&view=basket', - 'open basket' => '#' + 'open basket' => $open_basket_link, + 'in basket: '.count($_SESSION['basket_ids']) => '#' ), 'view' => Array( 'sort' => $array_sort_orders_links, @@ -220,7 +224,7 @@ 'thumb_nr' => $array_nr_links ), 'edit' => Array( - 'set_permissions' => LINPHA_DIR.'/admin/permissions.php?&cmd=edit&id='.$this->id_current + 'set_permissions' => $edit_permission_link ) ); break; @@ -230,7 +234,8 @@ 'basket' => Array( 'add to basket' => '#', 'switch to basket view' => '#', - 'open basket' => '#' + 'open basket' => $open_basket_link, + 'in basket: '.count($_SESSION['basket_ids']) => '#' ), 'view' => Array( 'sort' => $array_sort_orders_links @@ -238,14 +243,13 @@ 'edit' => Array( 'rot_left' => '#', 'rot_right' => '#', - 'set_permissions' => LINPHA_DIR.'/admin/permissions.php?&cmd=edit&id='.$this->id_current + 'set_permissions' => $edit_permission_link ) ); break; case 'basket_view': $GLOBALS['output']['menu_sub'] = Array( - 'back to normal view' => $this->link_url.'&id='.$this->id_current.'&view=thumb', - 'open basket' => '#' + 'back to normal view' => $this->link_url.'&id='.$this->id_current.'&view=thumb' ); break; } @@ -511,9 +515,9 @@ function setSubFolders() { $this->output['folders'] = ''; + $nr_folders = 0; if($GLOBALS['show_subfolders_separate']) { - $nr_folders = 0; foreach($this->photos_filtered AS $key=>$value) { if($value['img_type'] == 0) Modified: trunk/linpha2/lib/classes/linpha.other.php =================================================================== --- trunk/linpha2/lib/classes/linpha.other.php 2006-03-04 10:43:35 UTC (rev 4394) +++ trunk/linpha2/lib/classes/linpha.other.php 2006-03-04 13:18:41 UTC (rev 4395) @@ -143,7 +143,23 @@ } } +function set_navigation_line( $id ) +{ + $array_files = $GLOBALS['linpha']->sql->getFullFilenameFromId( $id ); + $str = '<a href="'.LINPHA_DIR.'/?cat=alb&id=0">top</a> / '; + foreach($array_files AS $key=>$value) + { + if($value != "") + { + $str .= '<a href="'.LINPHA_DIR.'/?cat=alb&id='.$key.'">'.$value.'</a> / '; + } + } + + return $str; +} + + function linSysLog($str) { if( ! isset( $GLOBALS['output']['sys_log'] ) ) Modified: trunk/linpha2/lib/modules/module.albums.php =================================================================== --- trunk/linpha2/lib/modules/module.albums.php 2006-03-04 10:43:35 UTC (rev 4394) +++ trunk/linpha2/lib/modules/module.albums.php 2006-03-04 13:18:41 UTC (rev 4395) @@ -35,16 +35,7 @@ /** * set navigation line */ - $array_files = $GLOBALS['linpha']->sql->getFullFilenameFromId( $linpha->imgview->id_parent ); - $linpha->imgview->output['navigation'] = '<a href="'.LINPHA_DIR.'/?cat=alb&id=0">top</a> / '; - - foreach($array_files AS $key=>$value) - { - if($value != "") - { - $linpha->imgview->output['navigation'] .= '<a href="'.LINPHA_DIR.'/?cat=alb&id='.$key.'">'.$value.'</a> / '; - } - } + $linpha->imgview->output['navigation'] = set_navigation_line( $linpha->imgview->id_parent ); /** Added: trunk/linpha2/lib/modules/module.basket.php =================================================================== --- trunk/linpha2/lib/modules/module.basket.php (rev 0) +++ trunk/linpha2/lib/modules/module.basket.php 2006-03-04 13:18:41 UTC (rev 4395) @@ -0,0 +1,101 @@ +<?php +if(!defined('LINPHA_DIR')) { exit(1); } + +/** + * init + */ + include_once(LINPHA_DIR.'/lib/classes/linpha.class.php'); + $linpha = new linpha(); + $linpha->sql->startSession(); + +/** + * parse POST data and GET commands + */ + /** + * parse GET commands + */ + if( isset( $_GET['cmd'] ) ) + { + switch($_GET['cmd']) + { + + /** + * add all + */ + case 'add_all': + + if( isset( $_GET['ref_id'] ) ) + { + $query = $GLOBALS['linpha']->db->Execute("SELECT id FROM ".PREFIX."photos WHERE img_type <> '0' AND parent_id = '".linSql::linAddslashes($_GET['ref_id'])."'"); + while($data = $query->FetchRow()) + { + if($GLOBALS['linpha']->sql->photoIsAllowed($data[0])) + { + $_SESSION['basket_ids'][] = $data[0]; + } + } + $ref_id = $_GET['ref_id']; + } + else + { + $ref_id = 0; + } + + Header("Location: ".LINPHA_DIR."/?cat=alb&id=".$ref_id."&ref=imgids_added"); + exit(); + + + /** + * add ids to session if allowed + */ + case 'add_selected': + + if( isset( $_POST['img_id'] ) ) + { + foreach($_POST['img_id'] AS $value) + { + if($GLOBALS['linpha']->sql->photoIsAllowed($value)) + { + $_SESSION['basket_ids'][] = $value; + } + } + } + Header("Location: ".LINPHA_DIR."/?cat=alb&id=".$_GET['ref_id']."&ref=imgids_added"); + exit(); + + /** + * remove all + */ + case 'remove_all': + $_SESSION['basket_ids'] = Array(); + break; + + /** + * remove selected + */ + case 'remove_selected': + + if( isset( $_POST['img_id'] ) ) + { + foreach($_POST['img_id'] AS $value) + { + $key = array_search($value, $_SESSION['basket_ids']); + unset($_SESSION['basket_ids'][$key]); + } + } + + break; + } + } + + +/** + * build basket view + */ + + + +$linpha->template->setModuleName('basket'); +$linpha->template->UrlFull = LINPHA_DIR.'/?cat=basket&ref_id='.$_GET['ref_id']; +include_once(LINPHA_DIR.'/templates/'.$linpha->template->template_name.'_html/global.html.php'); +?> \ No newline at end of file Added: trunk/linpha2/templates/main_css/basket.css =================================================================== --- trunk/linpha2/templates/main_css/basket.css (rev 0) +++ trunk/linpha2/templates/main_css/basket.css 2006-03-04 13:18:41 UTC (rev 4395) @@ -0,0 +1,14 @@ +.imgdiv { + border: 1px #000000 solid; + margin: 3px; + text-align: center; + float: left; + width: 150px; + height: 150px; +} + +.img_thumbnail { + border: 0; + width: auto; + height: 130px; +} \ No newline at end of file Added: trunk/linpha2/templates/main_css/global.css =================================================================== --- trunk/linpha2/templates/main_css/global.css (rev 0) +++ trunk/linpha2/templates/main_css/global.css 2006-03-04 13:18:41 UTC (rev 4395) @@ -0,0 +1,152 @@ +<!-- +body { + font-family: arial, helvetica, sans-serif; + margin: 0px; +} + +.header { + background-color: #ffd5ee; + border: 1px solid #f09; + /*position: fixed; + top: 10px; + left: 10px; + right: 10px;*/ + margin: 10px; + z-index: 400; + padding: 5px; + + height: 70px; +} + +/** + * used if .header is position:fixed + */ +.header2 { + /*margin: 10px; + height: 80px;*/ + /*visibility: hidden;*/ +} + +.left { + position: absolute; + top: 100px; + left: 10px; + + width: 205px; + min-height: 400px; + + + padding: 5px; + margin: 0px; + + background-color: #ffd5ee; + + border: 1px solid #f09; +} + +.navigation { + background-color: #d5fcf4; + padding: 0; + border: 1px solid #0c9; + margin: 10px 10px 10px 237px; +} + +.main { + background-color: #d5eeff; + padding: 5px; + border: 1px solid #09f; + margin: 10px 10px 10px 237px; +} + + +/** + * menu + * view http://www.tanfa.co.uk/css/examples/menu/tutorial-h.asp + * the nicest one! + */ + #menu { + width: 100%; + float: left; + } + + #menu ul { + list-style: none; + margin: 0; + padding: 0; + width: 7em; + float: left; + white-space: nowrap; + } + + /** + * all elements + */ + #menu a, #menu span { + display: block; + border-width: 1px; + border-style: solid; + border-color: #ccc #888 #555 #bbb; + margin: 0; + padding: 2px 3px; + color: #fff; + background: #036; + text-decoration: none; + } + + /** + * only first level elements + */ + #menu ul a, #menu ul span { + text-align: center; + } + + /** + * only two or more level elements + */ + #menu ul ul a, #menu ul ul span { + text-align: left; + } + + #menu a:hover, #menu span:hover { + color: #fff; + background: #369; + } + + #menu li { + position: relative; + } + + #menu ul ul { + position: absolute; + z-index: 500; + font-size: 0.8em; + width: auto; + min-width: 7em; +/* white-space: nowrap;*/ + } + + #menu ul ul ul { + position: absolute; + top: 0; + left: 100%; + } + + div#menu ul ul { + display: none; + } + + div#menu ul ul, + div#menu ul li:hover ul ul, + div#menu ul ul li:hover ul ul + {display: none;} + + div#menu ul li:hover ul, + div#menu ul ul li:hover ul, + div#menu ul ul ul li:hover ul + {display: block;} + + #menu_switch a { + width: 1em; + float: left; + } +--> \ No newline at end of file Added: trunk/linpha2/templates/main_css/view_basket.css =================================================================== Added: trunk/linpha2/templates/main_css/view_img.css =================================================================== --- trunk/linpha2/templates/main_css/view_img.css (rev 0) +++ trunk/linpha2/templates/main_css/view_img.css 2006-03-04 13:18:41 UTC (rev 4395) @@ -0,0 +1,80 @@ + a:link { + color: #666666; + text-decoration: underline; + } + a:visited { + color:#666666; + text-decoration: underline; + } + a:hover { + color:#0080D0; + text-decoration: underline; + } + + .mainimage { + width: 350px; + height: auto; + } + + .main { + text-align: center; + } + + +/** + * navigation stuff + */ + .div_all_main { + position: relative; + + background-color: #d5fcf4; + border: 1px solid #0c9; + margin: 10px 10px 10px 237px; + height: 120px; + + text-align: center; + font-size: 0.5em; + + } + + .div_all_prevthumb { + position: absolute; + right: 50%; + margin-right: 50px; + } + + .div_all_nextthumb { + position: absolute; + left: 50%; + margin-left: 50px; + } + + .div_prevnextthumb { + /*border: 1px solid #000000;*/ + float: left; + width: 90px; + height: 90px; + margin: 2px; + } + + .div_currentthumb { + /*border: 1px solid #000000;*/ + position: absolute; + left: 50%; + margin: 2px; + + width: 80px; + margin-left: -40px; /* should be the half of 'width' */ + height: 80px; + } + + .img_prevnextthumb { + width: 75px; + height: auto; + border: 0px; + } + .img_currentthumb { + width: 50px; + height: auto; + border: 0px; + } \ No newline at end of file Added: trunk/linpha2/templates/main_css/view_thumb.css =================================================================== --- trunk/linpha2/templates/main_css/view_thumb.css (rev 0) +++ trunk/linpha2/templates/main_css/view_thumb.css 2006-03-04 13:18:41 UTC (rev 4395) @@ -0,0 +1,41 @@ +/** + * need this to calculate heigh of main div + * if you're gettings scrollbars, adjust the height! + */ +.spacer_height { + height: 220px; + position: absolute; + visibility: hidden; +} + +.imgdiv { + border: 1px #000000 solid; + margin: 3px; + text-align: center; + float: left; +} + +.img_thumbnail { + border: 0; + width: auto; +} + +.page_nr_main { + position: absolute; + right: 12px; + top: 100px; + width: 600px; +} +.page_nr { + float: right; + border: 1px #000000 solid; + margin: 5px;; + padding: 10px; + height: 25px; + width: 40px; + white-space: nowrap; +} + +.main { + min-height: 500px; /* @todo floated divs in thumb view without javascript doesnt count to the main div height */ +} \ No newline at end of file Added: trunk/linpha2/templates/main_css/view_thumbdetail.css =================================================================== --- trunk/linpha2/templates/main_css/view_thumbdetail.css (rev 0) +++ trunk/linpha2/templates/main_css/view_thumbdetail.css 2006-03-04 13:18:41 UTC (rev 4395) @@ -0,0 +1,62 @@ +h1 { + font-size: 18pt; + font-family: Verdana, Arial, Helvetica, sans-serif; +} + +h2 { + font-size: 14pt; + font-family: Verdana, Arial, Helvetica, sans-serif; + margin-top: 2px; + margin-bottom: 7px; +} + +hr { + clear: both; +} + +.div_random { + height: 200px; +} + +.div_random_img { + float: left; + margin-left: 40px; +} + +.img_random_thumbnail { + border: 0; + + max-width: 130px; + max-height: 130px; +} + +.div_folder { + position: relative; + margin: 2px; + margin-left: 15px; + margin-bottom: 15px; + padding: 5px; + + height: 151px; + width: 700px; + + background-color: #d5fcf4; + border: 1px solid #0c9; +} + +.div_folder_text { + margin-left: 180px; + height: 140px; + padding: 5px; +} + +.img_folder_thumbnail { + position: absolute; + top: 15px; + left: 20px; + + width: 130px; + height: auto; + + border: 0; +} \ No newline at end of file Added: trunk/linpha2/templates/main_html/basket.html.php =================================================================== --- trunk/linpha2/templates/main_html/basket.html.php (rev 0) +++ trunk/linpha2/templates/main_html/basket.html.php 2006-03-04 13:18:41 UTC (rev 4395) @@ -0,0 +1,97 @@ + +<form name="basket" action="<?php echo $GLOBALS['linpha']->template->UrlFull; ?>&cmd=remove_selected" method="POST"> +<div class='navigation'> +<a href="<?php echo LINPHA_DIR.'/?cat=alb&id='.$_GET['ref_id']; ?>">Go back</a> +<a href="<?php echo $GLOBALS['linpha']->template->UrlFull; ?>&cmd=remove_all">Remove all</a> +<input type="submit" name="submit" value="remove selected" /> +<br /><br /> +Images in basket: <?php echo count($_SESSION['basket_ids']); ?> +</div> + +<div id='maindiv' class='main'> + +<?php if( count($_SESSION['basket_ids']) > 0 ) { ?> + + +<?php + + /** + * get and save parent ids + */ + sort($_SESSION['basket_ids']); + foreach($_SESSION['basket_ids'] AS $value) + { + $data = $GLOBALS['linpha']->db->GetRow("SELECT parent_id FROM ".PREFIX."photos WHERE id = '". linSql::linAddslashes($value)."'" ); + $array_folder_ids[] = $data[0]; + + $array_folders[$data[0]][] = $value; // store all imgids in an array with parent_id as the key + } + + $array_folder_ids = array_unique($array_folder_ids); + + + + foreach($array_folder_ids AS $value) + { + echo set_navigation_line($value).'<br />'; + + $i = 1; + foreach($array_folders[$value] AS $sub_value) + { + ?> + <div class='imgdiv'> + <a href='javascript:void(0)' onclick='update_checkbox(<?php echo $i; ?>)'><img src='<?php echo LINPHA_DIR.'/get_thumb.php?id='.$sub_value; ?>' class='img_thumbnail' /></a> + <br /> + <input type='checkbox' id='<?php echo $i; ?>' name='img_id[]' value='<?php echo $sub_value; ?>'> + </div> + <?php + $i++; + } + + echo '<div style="clear: both;"></div><br /><br />'; + } + + + + + + + /* + echo '<pre>'; + print_r($_SESSION['basket_ids']); + + + foreach($array_path_ids AS $value) + { + print_r(linSql::getFullFilenameFromId($value)); + } + + echo '</pre>';*/ +?> + + + <script language="JavaScript" type='text/javascript'> + function update_checkbox(elem_id) + { + elem = document.getElementById(elem_id); + if(elem.checked==true) + { + elem.checked = false; + } + else + { + elem.checked = true; + } + } + </script> + + + + +<?php } else { ?> + + Basket is empty + +<?php } ?> +</div> +</form> \ No newline at end of file Modified: trunk/linpha2/templates/main_html/view_basket.html.php =================================================================== --- trunk/linpha2/templates/main_html/view_basket.html.php 2006-03-04 10:43:35 UTC (rev 4394) +++ trunk/linpha2/templates/main_html/view_basket.html.php 2006-03-04 13:18:41 UTC (rev 4395) @@ -9,9 +9,11 @@ <div class="navigation"> <?php echo $GLOBALS['linpha']->imgview->output['navigation']; ?> <br /><br /> + Images in basket: <?php echo count($_SESSION['basket_ids']); ?> + (<a href="<?php echo LINPHA_DIR.'?cat=basket&ref_id='.$GLOBALS['linpha']->imgview->id_current; ?>">open basket</a>) </div> -<form name='basket' action='#' method='POST'> +<form name='basket' action='<?php echo LINPHA_DIR.'/?cat=basket&cmd=add_selected&ref_id='.$GLOBALS['linpha']->imgview->id_current; ?>' method='POST'> <div id='maindiv' class='main'> <?php $i = 1; @@ -40,8 +42,9 @@ ?> <div style="clear: left;"></div> <br /><br /> - <input type='button' name='button_check_all' value='check all' onClick='this.value=check_all()'> + <input type='button' name='button_check_all' value='check all of this page' onClick='this.value=check_all()'> <input type='submit' value='add to basket'> + <a href="<?php echo LINPHA_DIR.'?cat=basket&ref_id='.$GLOBALS['linpha']->imgview->id_current.'&cmd=add_all'; ?>">add all of this folder to basket</a> <script language="JavaScript" type='text/javascript'> var checkflag = 0; function check_all() { @@ -53,7 +56,7 @@ else // clear all { checkflag = 0; - var return_value = "check all"; + var return_value = "check all of this page"; } for (var i = 0; i < document.forms[0].length; i++) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |