web/wp-content/plugins/wptouch/include/icons.php
branchwordpress
changeset 123 561aa6d282f6
equal deleted inserted replaced
112:fb7cd02b9848 123:561aa6d282f6
       
     1 <?php
       
     2 
       
     3 	function bnc_get_icon_locations() {
       
     4       $locations = array( 
       
     5         		'default' => array( compat_get_plugin_dir( 'wptouch' ) . '/images/icon-pool', compat_get_plugin_url( 'wptouch' ) . '/images/icon-pool' ),      
       
     6 				'custom' => array( compat_get_upload_dir() . '/wptouch/custom-icons', compat_get_upload_url() . '/wptouch/custom-icons' )
       
     7 		);
       
     8 
       
     9       return $locations;
       
    10 	}
       
    11 	
       
    12 	function bnc_get_icon_list() {
       
    13 		$locations = bnc_get_icon_locations();     
       
    14 		$files = array();
       
    15 
       
    16 		foreach ( $locations as $key => $value ) {
       
    17 			$current_path = $value[0];	
       
    18 			$dir = @opendir( $current_path );
       
    19 			$files[ $key ] = array();
       
    20 		
       
    21 			if ( $dir ) {
       
    22 				while ( false !== ( $file = readdir( $dir ) ) ) { 
       
    23 					if ($file == '.' || $file == '..' || $file == '.svn' || $file == 'template.psd' || $file == '.DS_Store' || $file == 'more') {
       
    24 						continue;
       
    25 					}
       
    26 				
       
    27 					$icon = array();
       
    28 					$names = explode('.', $file);
       
    29 					$icon['friendly'] = ucfirst($names[0]);
       
    30 					$icon['name'] = $file;
       
    31 					$icon['url'] = $value[1] . "/" . $file;
       
    32 					$files[ $key ][ $icon['name'] ] = $icon;
       
    33 				}
       
    34 			}
       
    35 		}
       
    36 
       
    37 		ksort($files);
       
    38 		return $files;
       
    39 	}
       
    40 	
       
    41 	function bnc_show_icons() {
       
    42 		$icons = bnc_get_icon_list();
       
    43 		$locations = bnc_get_icon_locations();
       
    44 		
       
    45 		foreach ( $locations as $key => $value ) {
       
    46 			echo '<div class="new-icon-block ' . $key . '">';
       
    47 			foreach ( $icons[ $key ] as $icon ) {
       
    48 				echo '<ul class="wptouch-iconblock">';
       
    49 				echo '<li><img src="' . $icon['url'] . '" title="' . $icon['name'] . '" /><br />' . $icon['friendly'];
       
    50 				if ( $key == 'custom' ) {
       
    51 					echo ' <a href="' . $_SERVER['REQUEST_URI'] . '&amp;delete_icon=' . urlencode($icon['url']) . '">(x)</a>';	
       
    52 				}
       
    53 				echo '</li>';
       
    54 				echo '</ul>';
       
    55 			}	
       
    56 			echo '</div>';
       
    57 		}
       
    58 	}	
       
    59 	
       
    60 	function bnc_get_icon_drop_down_list( $selected_item ) {
       
    61 		$icons = bnc_get_icon_list();
       
    62 		$locations = bnc_get_icon_locations();
       
    63 		$files = array();
       
    64 		
       
    65 		foreach ( $locations as $key => $value ) {
       
    66 			foreach ( $icons[ $key ] as $icon ) {
       
    67 				$files[ $icon['name'] ] = $icon;
       
    68 			}	
       
    69 		}
       
    70 		
       
    71 		ksort( $files );
       
    72 		
       
    73 		foreach ( $files as $key => $file ) {
       
    74 			$is_selected = '';
       
    75 			if ( $selected_item == $file['name'] ) {
       
    76 				$is_selected = ' selected';
       
    77 			}
       
    78 			echo '<option' . $is_selected . ' value="' . $file['name'] . '">'. $file['friendly'] . '</option>';
       
    79 		}
       
    80 	}
       
    81 	
       
    82 	function bnc_get_pages_for_icons() {
       
    83 		global $table_prefix;
       
    84 		global $wpdb;
       
    85 		
       
    86 		$query = "select * from {$table_prefix}posts where post_type = 'page' and post_status = 'publish' order by post_title asc";
       
    87 		$results = $wpdb->get_results( $query );
       
    88 		if ( $results ) {
       
    89 			return $results;
       
    90 		}
       
    91 	}
       
    92 	
       
    93 	function bnc_get_master_icon_list() {
       
    94 	}
       
    95 ?>