Esempio n. 1
0
/**
 * Print category rows for admin panel
 */
function ig_caticons_rows($parent = 0, $level = 0, $categories = 0) {
	global $wpdb, $class, $user_level;
	if (!$categories)
		$categories = $wpdb->get_results("SELECT * FROM $wpdb->categories ORDER BY cat_name");

	if ($categories) {
		foreach ($categories as $category) {
			if ($category->category_parent == $parent) {
				list($icon, $small_icon) = ig_caticons_get_icons($category->cat_ID);
				$icon_cell = '';
				if (''!=$icon) {
					list($width, $height, $type, $attr) = getimagesize(ig_caticons_path()."/$icon");
					list($w, $h) = ig_fit_rect($width, $height, 100, 100);
					$icon_cell = '<img src="'.ig_caticons_url()."/$icon\" width=\"$w\" height=\"$h\"/> <br />$icon ($width x $height)";
				}
				$small_icon_cell = '';
				if (''!=$small_icon) {
					list($width, $height, $type, $attr) = getimagesize(ig_caticons_path()."/$small_icon");
					list($w, $h) = ig_fit_rect($width, $height, 100, 100);
					$small_icon_cell = '<img src="'.ig_caticons_url()."/$small_icon\" width=\"$w\" height=\"$h\" /> <br />$small_icon ($width x $height)";
				}
				$category->cat_name = wp_specialchars($category->cat_name);
				$count = $wpdb->get_var("SELECT COUNT(post_id) FROM $wpdb->post2cat WHERE category_id = $category->cat_ID");
				$pad = str_repeat('&#8212; ', $level);
				if ( $user_level > 3 )
					$edit = "<a href='".IG_ADMIN_SELF."&ig_module=caticons&ig_tab=manage&action=select&cat_ID=$category->cat_ID' class='edit'>" . __('Select') . "</a></td><td><a href='".IG_ADMIN_SELF."&ig_module=caticons&ig_tab=manage&action=change&cat_ID=$category->cat_ID' onclick=\"return confirm('".  sprintf(__("You are about to remove the category \'%s\' icons.\\n  \'OK\' to remove, \'Cancel\' to stop."), addslashes($category->cat_name)) . "')\" class='delete'>" .  __('Remove') . "</a>";
				else
					$edit = '';
				
				$class = ('alternate' == $class) ? '' : 'alternate';
				echo "<tr class='$class'><th scope='row'>$category->cat_ID</th><td>$pad $category->cat_name</td>
				<td align=\"center\">$icon_cell</td>
				<td align=\"center\">$small_icon_cell</td>
				<td>$edit</td>
				</tr>";
				ig_caticons_rows($category->cat_ID, $level + 1, $categories);
			}
		}
	} else {
		return false;
	}
}
/**
 * Display the Options tab
 * @author Brahim Machkouri
 */
function bm_caticons_adminoptions()
{
    list($def_path, $def_url) = ig_caticons_defupload();
    ?>
<div class="form-wrap">
	<form method="post" action="" name="caticons-form3">
	<?php 
    wp_nonce_field('caticons-nonce');
    ?>
	<input type="hidden" name="ig_module" value="caticons"/>
	<input type="hidden" name="ig_tab" value="options"/>
    <div class="col-container">
        <div id="col-right">
        	<div class="metabox-holder">	
                <div class="postbox">
                    <h3 class="hndle"><span><?php 
    _e('Template Tags', 'category_icons');
    ?>
</span></h3>
                    <div class="inside">
                        <label class="selectit"><input type="checkbox" name="igcaticons_templatecode_patch" id="templatecode_patch" value="1" <?php 
    checked('1', get_option('igcaticons_templatecode_patch'));
    ?>
 />
                        <?php 
    _e('Patch the files if possible (check for true)', 'category_icons');
    ?>
</label>
                        <label class="selectit"><input type="checkbox" name="igcaticons_templatecode_sidebar" id="templatecode_sidebar" value="1" <?php 
    checked('1', get_option('igcaticons_templatecode_sidebar'));
    ?>
 />
                        <?php 
    _e('Process the list of categories (usually used in sidebar) ?', 'category_icons');
    ?>
</label>
                    </div>
                </div>
            </div>
            <div class="metabox-holder">	
                <div class="postbox">
                <h3 class="hndle"><span><?php 
    _e('Position of the category icon in the sidebar', 'category_icons');
    ?>
</span></h3>
            <div class="inside">
                <label><input type="radio" name="igcaticons_before_name" id="before_name_left" value="true" <?php 
    checked('true', get_option('igcaticons_before_name'));
    ?>
/>&nbsp;<?php 
    _e('Left', 'category_icons');
    ?>
</label>
                <label><input type="radio" name="igcaticons_before_name" id="before_name_right" value="false" <?php 
    checked('false', get_option('igcaticons_before_name'));
    ?>
/>&nbsp;<?php 
    _e('Right', 'category_icons');
    ?>
</label>
                <p><?php 
    _e("Select 'Left' if you want to put the category icon in front of the category name in the sidebar, or 'Right' if you want to put it after. <b>Remember that you must use the put_cat_icons() function to display icons in the sidebar, unless you use the <a href='widgets.php'>widget</a></b>.", 'category_icons');
    ?>
</p>
            </div>
            </div>
            </div>
                <label><input type="checkbox" name="igcaticons_rssfeeds" id="rssfeeds" value="1" <?php 
    checked('1', get_option('igcaticons_rssfeeds'));
    ?>
 />&nbsp;<?php 
    _e('Display category icons in RSS feeds', 'category_icons');
    ?>
</label>
                <label><input type="checkbox" name="igcaticons_iconcatpage" id="iconcatpage" value="1" <?php 
    checked('1', get_option('igcaticons_iconcatpage'));
    ?>
 />&nbsp;<?php 
    _e('Display only the icon of the selected category in the category page', 'category_icons');
    ?>
</label>
                
            <?php 
    if (function_exists('seo_friendly_images')) {
        ?>
                <label><input type="checkbox" name="igcaticons_useseo_plugin" id="useseofriendlyimages" value="1" <?php 
        checked('1', get_option('igcaticons_useseo_plugin'));
        ?>
 />
            <?php 
        _e('Use SEO Friendly Images plugin', 'category_icons');
        ?>
</label>
            <?php 
    }
    ?>
         
        </div>
        <div id="col-left">
            <div class="form-field">
                <label><?php 
    _e('Local Path to Icons', 'category_icons');
    ?>
</label>
                <input type="text" name="igcaticons_path" size="50" value="<?php 
    echo htmlspecialchars(get_option('igcaticons_path'));
    ?>
" />
                <p><?php 
    _e('Leave blank to use default upload path', 'category_icons');
    ?>
.</p>
				 <p><?php 
    echo __('Your local path to icons is set to ', 'category_icons') . trailingslashit(ig_caticons_path());
    ?>
</p>
            </div>
            <div class="form-field">
                <label><?php 
    _e('URL to Icons', 'category_icons');
    ?>
</label>
                <input type="text" name="igcaticons_url" size="50" value="<?php 
    echo htmlspecialchars(get_option('igcaticons_url'));
    ?>
" />
                <p><?php 
    _e('Leave blank to use default upload url', 'category_icons');
    ?>
.</p>
				<p><?php 
    echo __('Your URL to icons is set to ', 'category_icons') . trailingslashit(ig_caticons_url());
    ?>
</p>
            </div>
            <div class="form-field">
                <label><?php 
    _e('Image File Types', 'category_icons');
    ?>
</label>
                <input type="text" name="igcaticons_filetypes" size="50" value="<?php 
    echo htmlspecialchars(get_option('igcaticons_filetypes'));
    ?>
" />
                <p><?php 
    _e("Separate by space or comma. E.g. 'jpg gif jpeg png'", 'category_icons');
    ?>
</p>
            </div>
            <div class="form-field">
                <label><?php 
    _e('Maximum icon width', 'category_icons');
    ?>
</label>
                <input type="text" name="igcaticons_max_width" size="3" value="<?php 
    echo htmlspecialchars(get_option('igcaticons_max_width'));
    ?>
" />
                <p><?php 
    _e('Enter the maximum width of an icon.', 'category_icons');
    ?>
</p>
            </div>	
            <div class="form-field">
                <label><?php 
    _e('Maximum icon height', 'category_icons');
    ?>
</label>
                <input type="text" name="igcaticons_max_height" size="3" value="<?php 
    echo htmlspecialchars(get_option('igcaticons_max_height'));
    ?>
" />
                <p><?php 
    _e('Enter the maximum height of an icon.', 'category_icons');
    ?>
</p>
            </div>
            <div class="form-field">
                <label><?php 
    _e('Maximum number of icons', 'category_icons');
    ?>
</label>
                <input type="text" name="igcaticons_max_icons" size="3" value="<?php 
    echo htmlspecialchars(get_option('igcaticons_max_icons'));
    ?>
" />
                <p><?php 
    _e('Enter the maximum number of icons to display in front of the posts titles.', 'category_icons');
    ?>
</p>
            </div>
            <div class="submit">
            	<input type="submit" name="info_update" value="<?php 
    _e('Update Options', 'category_icons');
    ?>
 &raquo;" />
            </div>	
        </div>
    </div>
    </form>
</div>
<?php 
}