?> </label> </th> <td> <input name="menuname" id="menuname" type="text" value="<?php echo attribute_escape($wpm_menu->name); ?> " size="10" /> </td> </tr> <tr id="select6" > <th scope="row" valign="top"> <label for="template"> <?php _e('Template:', 'wpm'); ?> </label> </th> <td> <?php wpm_template_dropdown(wpm_2to1($wpm_menu->selection, $wpm_menu->cssclass)); ?> <?php _e('(select a menu template and stylesheet)', 'wpm'); ?> </td> </tr> </table> <p class="submit"> <input type="submit" name="submit" value="<?php echo $submit_text; ?> " /> </p> </form> </div>
function wpm_template_dropdown($active_template, $echo = true) { global $wpm_options; $templates = array(); $root = $wpm_options->templates_dir; $folders = @dir($root); if ($folders) { while (($folder = $folders->read()) !== false) { if (substr($folder, 0, 1) == '.') { continue; } if (is_dir("{$root}/{$folder}")) { $found = 0; $cfiles = array(); $files = @dir("{$root}/{$folder}"); if ($files) { while (($file = $files->read()) !== false) { if (substr($file, 0, 1) == '.') { continue; } elseif ($file == $wpm_options->php_file) { $found = 1; } elseif (substr($file, -4) == '.css') { $cfiles[] = $file; } } } if ($found) { $templates[] = wpm_2to1($folder, ''); foreach ($cfiles as $cfile) { $templates[] = wpm_2to1($folder, $cfile); } } } } } if (count($templates) == 0) { return false; } sort($templates); $out = "<select name='template' >\n"; foreach ($templates as $template) { $selected = $template == $active_template ? 'selected' : ''; $out .= "<option value='" . $template . "' {$selected}> {$template} </option>\n"; } $out .= "</select>\n"; if ($echo) { echo $out; } return true; }