Changeset 355
- Timestamp:
- Feb 8, 2004, 2:28:18 AM (20 years ago)
- Location:
- trunk
- Files:
-
- 2 added
- 2 deleted
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/comments.php
r354 r355 30 30 include_once( $phpwg_root_path.'include/common.inc.php' ); 31 31 32 //------------------------------------------------------------------- functions 33 function display_pictures( $mysql_result, $maxtime, $forbidden_cat_ids ) 32 //--------------------------------------------------- number of days to display 33 if ( isset( $_GET['last_days'] ) ) define( 'MAX_DAYS', $_GET['last_days'] ); 34 else define( 'MAX_DAYS', 0 ); 35 //----------------------------------------- non specific section initialization 36 $array_cat_directories = array(); 37 $array_cat_names = array(); 38 $array_cat_site_id = array(); 39 //------------------------------------------------------- last comments display 40 41 // 42 // Start output of page 43 // 44 $title= $lang['title_comments']; 45 include('include/page_header.php'); 46 47 $template->set_filenames( array('comments'=>'comments.tpl') ); 48 initialize_template(); 49 50 $template->assign_vars(array( 51 'L_TITLE' => $lang['title_comments'], 52 'L_STATS' => $lang['stats_last_days'], 53 'L_RETURN' => $lang['search_return_main_page'], 54 55 'U_HOME' => add_session_id( 'category.php' ) 56 ) 57 ); 58 59 foreach ( $conf['last_days'] as $option ) { 60 $url = './comments.php?last_days='.($option - 1); 61 $template->assign_block_vars('last_day_option', array ( 62 'OPTION'=>$option, 63 'T_STYLE'=>(( $option == MAX_DAYS + 1 )?'text-decoration:underline;':''), 64 'U_OPTION'=>add_session_id( $url ) 65 )); 66 } 67 68 // 1. retrieving picture ids which have comments recently added 69 $date = date( 'Y-m-d', time() - ( MAX_DAYS*24*60*60 ) ); 70 list($year,$month,$day) = explode( '-', $date); 71 $maxtime = mktime( 0,0,0,$month,$day,$year ); 72 $query = 'SELECT DISTINCT(ic.image_id) as image_id,'; 73 $query .= '(ic.category_id) as category_id'; 74 $query.= ' FROM '.PREFIX_TABLE.'comments AS c'; 75 $query.= ', '.PREFIX_TABLE.'image_category AS ic'; 76 $query.= ' WHERE c.image_id = ic.image_id'; 77 $query.= ' AND date > '.$maxtime; 78 $query.= " AND validated = 'true'"; 79 // we must not show pictures of a forbidden category 80 if ( $user['forbidden_categories'] != '' ) 34 81 { 35 global $vtp,$handle,$lang,$conf, 36 $array_cat_directories,$array_cat_site_id,$array_cat_names; 82 $query.= ' AND category_id NOT IN '; 83 $query.= '('.$user['forbidden_categories'].')'; 84 } 85 $query.= ' ORDER BY ic.image_id DESC'; 86 $query.= ';'; 87 $result = mysql_query( $query ); 37 88 38 while ( $row = mysql_fetch_array( $mysql_result ) )89 while ( $row = mysql_fetch_array( $result ) ) 39 90 { 40 $vtp->addSession( $handle, 'picture' ); 41 // 1. find a category wich is authorized for the user to display a 42 // category name. 43 $query = 'SELECT category_id'; 44 $query.= ' FROM '.PREFIX_TABLE.'image_category'; 45 $query.= ' WHERE image_id = '.$row['image_id']; 46 if ( count( $forbidden_cat_ids ) > 0 ) 47 { 48 $query.= ' AND category_id NOT IN ('; 49 foreach ( $forbidden_cat_ids as $i => $restricted_cat ) { 50 if ( $i > 0 ) $query.= ','; 51 $query.= $restricted_cat; 52 } 53 $query.= ')'; 54 } 55 $query.= ' ORDER BY RAND()'; 56 $query.= ';'; 57 $subrow = mysql_fetch_array( mysql_query( $query ) ); 58 $category_id = $subrow['category_id']; 91 $category_id=$row['category_id']; 59 92 60 if ( !isset($array_cat_directories[$category_id])) 61 { 62 $array_cat_directories[$category_id] = 63 get_complete_dir( $category_id ); 64 $cat_result = get_cat_info( $category_id ); 65 $array_cat_site_id[$category_id] = $cat_result['site_id']; 66 $array_cat_names[$category_id] = 67 get_cat_display_name( $cat_result['name'], ' > ', '' ); 68 } 69 70 // 2. for each picture, getting informations for displaying thumbnail and 71 // link to the full size picture 93 // for each picture, getting informations for displaying thumbnail and 94 // link to the full size picture 72 95 $query = 'SELECT name,file,storage_category_id as cat_id,tn_ext'; 73 $query.= ' FROM '. PREFIX_TABLE.'images';96 $query.= ' FROM '.IMAGES_TABLE; 74 97 $query.= ' WHERE id = '.$row['image_id']; 75 98 $query.= ';'; … … 77 100 $subrow = mysql_fetch_array( $subresult ); 78 101 79 if ( $array_cat_directories[$subrow['cat_id']] == '')102 if ( !isset($array_cat_directories[$subrow['cat_id']]) ) 80 103 { 81 104 $array_cat_directories[$subrow['cat_id']] = … … 93 116 else $name.= str_replace( '_', ' ', $file ); 94 117 $name.= ' [ '.$subrow['file'].' ]'; 95 $vtp->setVar( $handle, 'picture.title', $name ); 96 // source of the thumbnail picture 118 // source of the thumbnail picture 97 119 $src = $array_cat_directories[$subrow['cat_id']]; 98 120 $src.= 'thumbnail/'.$conf['prefix_thumbnail']; 99 121 $src.= $file.'.'.$subrow['tn_ext']; 100 $vtp->setVar( $handle, 'picture.thumb_src', $src ); 101 // link to the full size picture 122 // link to the full size picture 102 123 $url = './picture.php?cat='.$category_id; 103 124 $url.= '&image_id='.$row['image_id']; 104 $vtp->setVar( $handle, 'picture.thumb_url', add_session_id( $url ) ); 105 // 3. for each picture, retrieving all comments 125 126 $template->assign_block_vars('picture',array( 127 'TITLE_IMG'=>$name, 128 'I_THUMB'=>$src, 129 'U_THUMB'=>add_session_id( $url ) 130 )); 131 132 // for each picture, retrieving all comments 106 133 $query = 'SELECT id,date,author,content'; 107 $query.= ' FROM '. PREFIX_TABLE.'comments';134 $query.= ' FROM '.COMMENTS_TABLE; 108 135 $query.= ' WHERE image_id = '.$row['image_id']; 109 136 $query.= ' AND date > '.$maxtime; … … 114 141 while ( $subrow = mysql_fetch_array( $handleresult ) ) 115 142 { 116 $vtp->addSession( $handle, 'comment' );117 143 $author = $subrow['author']; 118 144 if ( $subrow['author'] == '' ) $author = $lang['guest']; 119 $vtp->setVar( $handle, 'comment.author', $author );120 $displayed_date = format_date( $subrow['date'], 'unix', true );121 $vtp->setVar( $handle, 'comment.date', $displayed_date );122 123 145 $content = nl2br( $subrow['content'] ); 124 146 … … 137 159 $replacement = '<span style="font-style:italic;">\1</span>'; 138 160 $content = preg_replace( $pattern, $replacement, $content ); 139 140 $vtp->setVar( $handle, 'comment.content', $content ); 141 $vtp->closeSession( $handle, 'comment' ); 161 $template->assign_block_vars('picture.comment',array( 162 'AUTHOR'=>$author, 163 'DATE'=>format_date( $subrow['date'], 'unix', true ), 164 'CONTENT'=>$content, 165 )); 142 166 } 143 $vtp->closeSession( $handle, 'picture' );144 167 } 145 }146 //----------------------------------------------------- template initialization147 //148 // Start output of page149 //150 $title= $lang['title_comments'];151 include('include/page_header.php');152 153 $handle = $vtp->Open( './template/'.$user['template'].'/comments.vtp' );154 initialize_template();155 $tpl = array( 'title_comments','stats_last_days','search_return_main_page' );156 templatize_array( $tpl, 'lang', $handle );157 //--------------------------------------------------- number of days to display158 if ( isset( $_GET['last_days'] ) ) define( 'MAX_DAYS', $_GET['last_days'] );159 else define( 'MAX_DAYS', 0 );160 //----------------------------------------- non specific section initialization161 $array_cat_directories = array();162 $array_cat_names = array();163 $array_cat_site_id = array();164 //------------------------------------------------------- last comments display165 foreach ( $conf['last_days'] as $option ) {166 $vtp->addSession( $handle, 'last_day_option' );167 $vtp->setVar( $handle, 'last_day_option.option', $option );168 $url = './comments.php';169 $url.= '?last_days='.($option - 1);170 $vtp->setVar( $handle, 'last_day_option.link', add_session_id( $url ) );171 $style = '';172 if ( $option == MAX_DAYS + 1 ) $style = 'text-decoration:underline;';173 $vtp->setVar( $handle, 'last_day_option.style', $style );174 $vtp->closeSession( $handle, 'last_day_option' );175 }176 $vtp->setVar( $handle, 'back_url', add_session_id( './category.php' ) );177 // 1. retrieving picture ids which have comments recently added178 $date = date( 'Y-m-d', time() - ( MAX_DAYS*24*60*60 ) );179 list($year,$month,$day) = explode( '-', $date);180 $maxtime = mktime( 0,0,0,$month,$day,$year );181 $query = 'SELECT DISTINCT(ic.image_id) as image_id';182 $query.= ' FROM '.PREFIX_TABLE.'comments AS c';183 $query.= ', '.PREFIX_TABLE.'image_category AS ic';184 $query.= ' WHERE c.image_id = ic.image_id';185 $query.= ' AND date > '.$maxtime;186 $query.= " AND validated = 'true'";187 // we must not show pictures of a forbidden category188 if ( $user['forbidden_categories'] != '' )189 {190 $query.= ' AND category_id NOT IN ';191 $query.= '('.$user['forbidden_categories'].')';192 }193 $query.= ' ORDER BY ic.image_id DESC';194 $query.= ';';195 $result = mysql_query( $query );196 display_pictures( $result, $maxtime, $user['restrictions'] );197 168 //----------------------------------------------------------- html code display 198 $code = $vtp->Display( $handle, 0 ); 199 echo $code; 169 $template->pparse('comments'); 200 170 include('include/page_tail.php'); 201 171 ?> -
trunk/search.php
r354 r355 69 69 include('include/page_header.php'); 70 70 71 $ handle = $vtp->Open( './template/'.$user['template'].'/search.vtp');71 $template->set_filenames( array('search'=>'search.tpl') ); 72 72 initialize_template(); 73 $tpl = array( 'search_title','search_return_main_page','submit', 74 'search_comments' ); 75 templatize_array( $tpl, 'lang', $handle ); 76 //----------------------------------------------------------------- form action 77 $vtp->setGlobalVar( $handle, 'form_action', add_session_id( './search.php' ) ); 73 74 $template->assign_vars(array( 75 'L_TITLE' => $lang['search_title'], 76 'L_COMMENTS' => $lang['search_comments'], 77 'L_RETURN' => $lang['search_return_main_page'], 78 'L_SUBMIT' => $lang['submit'], 79 'L_SEARCH'=>$lang['search_field_search'].' *', 80 'L_SEARCH_OR'=>$lang['search_mode_or'], 81 'L_SEARCH_AND'=>$lang['search_mode_and'], 82 83 'F_ACTION' => add_session_id( 'search.php' ), 84 'F_TEXT_VALUE' => isset($_POST['search'])?$_POST['search']:'', 85 86 'U_HOME' => add_session_id( 'category.php' ) 87 ) 88 ); 89 78 90 //-------------------------------------------------------------- errors display 79 91 if ( sizeof( $error ) != 0 ) 80 92 { 81 $ vtp->addSession( $handle, 'errors');93 $template->assign_block_vars('errors',array()); 82 94 for ( $i = 0; $i < sizeof( $error ); $i++ ) 83 95 { 84 $vtp->addSession( $handle, 'li' ); 85 $vtp->setVar( $handle, 'li.li', $error[$i] ); 86 $vtp->closeSession( $handle, 'li' ); 96 $template->assign_block_vars('errors.error',array('ERROR'=>$error[$i])); 87 97 } 88 $vtp->closeSession( $handle, 'errors' );89 98 } 90 //------------------------------------------------------------------------ form91 // search field92 $vtp->addSession( $handle, 'line' );93 $vtp->setVar( $handle, 'line.name', $lang['search_field_search'].' *' );94 $vtp->addSession( $handle, 'text' );95 $vtp->setVar( $handle, 'text.size', '40' );96 $vtp->setVar( $handle, 'text.name', 'search' );97 if (isset($_POST['search']))98 $vtp->setVar( $handle, 'text.value', $_POST['search'] );99 $vtp->closeSession( $handle, 'text' );100 $vtp->closeSession( $handle, 'line' );101 // mode of search : match all words or at least one of this words102 $vtp->addSession( $handle, 'line' );103 $vtp->addSession( $handle, 'group' );104 105 $vtp->addSession( $handle, 'radio' );106 $vtp->setVar( $handle, 'radio.name', 'mode' );107 $vtp->setVar( $handle, 'radio.value', 'OR' );108 $vtp->setVar( $handle, 'radio.option', $lang['search_mode_or'] );109 if (!isset($_POST['mode']) || $_POST['mode'] == 'OR' )110 {111 $vtp->setVar( $handle, 'radio.checked', ' checked="checked"' );112 }113 $vtp->closeSession( $handle, 'radio' );114 115 $vtp->addSession( $handle, 'radio' );116 $vtp->setVar( $handle, 'radio.name', 'mode' );117 $vtp->setVar( $handle, 'radio.value', 'AND' );118 $vtp->setVar( $handle, 'radio.option', $lang['search_mode_and'] );119 if ( isset($_POST['mode']) && $_POST['mode'] == 'AND' )120 {121 $vtp->setVar( $handle, 'radio.checked', ' checked="checked"' );122 }123 $vtp->closeSession( $handle, 'radio' );124 125 $vtp->closeSession( $handle, 'group' );126 $vtp->closeSession( $handle, 'line' );127 //---------------------------------------------------- return to main page link128 $vtp->setGlobalVar( $handle, 'back_url', add_session_id( './category.php' ) );129 //----------------------------------------------------------- html code display130 $code = $vtp->Display( $handle, 0 );131 echo $code;132 99 //------------------------------------------------------------ log informations 133 100 pwg_log( 'search', $title ); 134 101 mysql_close(); 102 $template->pparse('search'); 135 103 include('include/page_tail.php'); 136 104 ?> -
trunk/template/default/category.tpl
r351 r355 2 2 <tr> 3 3 <td valign="top" style="width:1%;padding:10px;"> 4 { F_START}100%{F_BEGIN}4 {T_START}100%{T_BEGIN} 5 5 <div class="titreMenu"> 6 6 <a href="{U_HOME}">{L_CATEGORIES}</a> … … 31 31 <br /> <img src="{T_COLLAPSED}" alt='' /> <a href="{U_RECENT}"><span title="{L_RECENT_HINT}" style="font-weight:bold;">{L_RECENT}</span></a> {T_SHORT} 32 32 </div> 33 { F_END}33 {T_END} 34 34 <div style="margin-bottom:5px;"> </div> 35 { F_START}100%{F_BEGIN}35 {T_START}100%{T_BEGIN} 36 36 <div class="titreMenu">{L_SUMMARY}</div> 37 37 <div class="menu"> … … 43 43 <!-- END upload --> 44 44 </div> 45 { F_END}45 {T_END} 46 46 </td> 47 47 <td style="padding:5px;width:99%;" valign="top"> … … 49 49 <tr> 50 50 <td align="center"> 51 { F_START}1%{F_BEGIN}51 {T_START}1%{T_BEGIN} 52 52 <div class="titrePage">{TITLE}</div> 53 { F_END}53 {T_END} 54 54 <div style="margin-bottom:5px;"> </div> 55 55 <!-- BEGIN thumbnails --> … … 95 95 <tr> 96 96 <td align="right"> 97 { F_START}1%{F_BEGIN}97 {T_START}1%{T_BEGIN} 98 98 <div class="info"> 99 99 {L_USER} {USERNAME}<br /> … … 104 104 {L_SEND_MAIL} <a href="mailto:{S_MAIL}?subject={L_TITLE_MAIL}"><span style="font-weight:bold;">{S_WEBMASTER}</span></a> 105 105 </div> 106 { F_END}106 {T_END} 107 107 </td> 108 108 </tr> -
trunk/template/default/htmlfunctions.inc.php
r351 r355 144 144 145 145 $template->assign_vars(array( 146 ' F_START' => get_frame_start(),147 ' F_BEGIN' => get_frame_begin(),148 ' F_END' => get_frame_end()146 'T_START' => get_frame_start(), 147 'T_BEGIN' => get_frame_begin(), 148 'T_END' => get_frame_end() 149 149 ) 150 150 );
Note: See TracChangeset
for help on using the changeset viewer.