/** * New Admin Navigation Routine. */ function sc_admin_navigation($parm) { if (!ADMIN) { return ''; } // global $admin_cat, $array_functions, $array_sub_functions, $pref; $pref = e107::getPref(); $admin_cat = e107::getNav()->adminCats(); $array_functions = e107::getNav()->adminLinks('legacy'); $array_sub_functions = e107::getNav()->adminLinks('sub'); $tp = e107::getParser(); $e107 = e107::getInstance(); $sql = e107::getDb('sqlp'); parse_str($parm, $parms); $tmpl = strtoupper(varset($parms['tmpl'], 'E_ADMIN_NAVIGATION')); global ${$tmpl}; if ($parm == 'home' || $parm == 'logout' || $parm == 'language' || $parm == 'pm') { $menu_vars = $this->getOtherNav($parm); return e107::getNav()->admin('', '', $menu_vars, ${$tmpl}, FALSE, FALSE); } // MAIN LINK if ($parm != 'no-main') { $menu_vars = array(); $menu_vars['adminhome']['text'] = ADLAN_151; $menu_vars['adminhome']['link'] = e_ADMIN_ABS . 'admin.php'; $menu_vars['adminhome']['image'] = "<img src='" . E_16_NAV_MAIN . "' alt='" . ADLAN_151 . "' class='icon S16' />"; $menu_vars['adminhome']['image_src'] = ADLAN_151; $menu_vars['adminhome']['perm'] = ''; } //ALL OTHER ROOT LINKS - temporary data transformation - data structure will be changed in the future and this block will be removed foreach ($admin_cat['id'] as $i => $cat) { $id = $admin_cat['id'][$i]; $menu_vars[$id]['text'] = $admin_cat['title'][$i]; $menu_vars[$id]['description'] = $admin_cat['title'][$i]; $menu_vars[$id]['link'] = '#'; $menu_vars[$id]['image'] = "<img src='" . $admin_cat['img'][$i] . "' alt='" . $admin_cat['title'][$i] . "' class='icon S16' />"; $menu_vars[$id]['image_large'] = "<img src='" . $admin_cat['lrg_img'][$i] . "' alt='" . $admin_cat['title'][$i] . "' class='icon S32' />"; $menu_vars[$id]['image_src'] = $admin_cat['img'][$i]; $menu_vars[$id]['image_large_src'] = $admin_cat['lrg_img'][$i]; // FIX - 'perm' should not be set or navigation->admin() will be broken (bad permissions) for non main administrators //$menu_vars[$id]['perm'] = ''; $menu_vars[$id]['sort'] = $admin_cat['sort'][$i]; } //CORE SUBLINKS foreach ($array_functions as $key => $subitem) { if (!empty($subitem[3]) && !getperms($subitem[3])) { continue; } $catid = $admin_cat['id'][$subitem[4]]; $tmp = array(); $tmp['text'] = $subitem[1]; $tmp['description'] = $subitem[2]; $tmp['link'] = $subitem[0]; $tmp['image'] = $subitem[5]; $tmp['image_large'] = $subitem[6]; $tmp['image_src'] = ''; $tmp['image_large_src'] = ''; $tmp['perm'] = $subitem[3]; $tmp['sub_class'] = ''; $tmp['sort'] = false; if (vartrue($pref['admin_slidedown_subs']) && vartrue($array_sub_functions[$key])) { $tmp['sub_class'] = 'sub'; foreach ($array_sub_functions[$key] as $subkey => $subsubitem) { $subid = $key . '_' . $subkey; $tmp['sub'][$subid]['text'] = $subsubitem[1]; $tmp['sub'][$subid]['description'] = $subsubitem[2]; $tmp['sub'][$subid]['link'] = $subsubitem[0]; $tmp['sub'][$subid]['image'] = $subsubitem[5]; $tmp['sub'][$subid]['image_large'] = $subsubitem[6]; $tmp['sub'][$subid]['image_src'] = ''; $tmp['sub'][$subid]['image_large_src'] = ''; $tmp['sub'][$subid]['perm'] = $subsubitem[3]; } } if ($tmp) { $menu_vars[$catid]['sub'][$key] = $tmp; } } //PLUGINS require_once e_HANDLER . 'plugin_class.php'; $plug = new e107plugin(); $tmp = array(); if ($sql->select("plugin", "*", "plugin_installflag =1 ORDER BY plugin_path")) { while ($row = $sql->fetch()) { if ($plug->parse_plugin($row['plugin_path'])) { $plug_vars = $plug->plug_vars; if ($row['plugin_path'] == 'calendar_menu') { // print_a($plug_vars); } // moved to boot.php // e107::loadLanFiles($row['plugin_path'], 'admin'); if (varset($plug_vars['adminLinks']['link'])) { if (!empty($row['plugin_category']) && $row['plugin_category'] == 'menu' || !vartrue($plug_vars['adminLinks']['link'][0]['@attributes']['url'])) { continue; } $plugpath = varset($plug_vars['plugin_php']) ? e_PLUGIN_ABS : e_PLUGIN_ABS . $row['plugin_path'] . '/'; $icon_src = varset($plug_vars['administration']['iconSmall']) ? $plugpath . $plug_vars['administration']['iconSmall'] : ''; $icon_src_lrg = varset($plug_vars['administration']['icon']) ? $plugpath . $plug_vars['administration']['iconSmall'] : ''; $id = 'plugnav-' . $row['plugin_path']; if (!getperms('P' . $row['plugin_id'])) { continue; } $tmp[$id]['text'] = e107::getParser()->toHTML($plug_vars['@attributes']['name'], FALSE, "LINKTEXT"); $tmp[$id]['description'] = vartrue($plug_vars['description']['@value']); $tmp[$id]['link'] = e_PLUGIN_ABS . $row['plugin_path'] . '/' . $plug_vars['administration']['configFile']; $tmp[$id]['image'] = $icon_src ? "<img src='{$icon_src}' alt=\"" . varset($tmp[$id]['text']) . "\" class='icon S16' />" : E_16_PLUGIN; $tmp[$id]['image_large'] = $icon_src_lrg ? "<img src='{$icon_src_lrg}' alt=\"" . varset($tmp[$id]['text']) . "\" class='icon S32' />" : $icon_src_lrg; $tmp[$id]['image_src'] = $icon_src; $tmp[$id]['image_large_src'] = $icon_src_lrg; $tmp[$id]['perm'] = 'P' . $row['plugin_id']; $tmp[$id]['sub_class'] = ''; $tmp[$id]['sort'] = 2; $tmp[$id]['category'] = varset($row['plugin_category']); if ($pref['admin_slidedown_subs'] && vartrue($plug_vars['adminLinks']['link'])) { $tmp[$id]['sub_class'] = 'sub'; $tmp[$id]['sort'] = false; foreach ($plug_vars['adminLinks']['link'] as $subkey => $plugsub) { $subid = $id . '-' . $subkey; $predef_icons = array('add', 'manage', 'settings'); $title = vartrue($plugsub['@value']); $plugsub = $plugsub['@attributes']; if (varset($plugsub['primary']) == 'true') { continue; } $icon_src = in_array($plugsub['icon'], $predef_icons) ? e_IMAGE_ABS . "admin_images/{$plugsub['icon']}_16.png" : ($plugsub['icon'] ? $plugpath . $plugsub['icon'] : ''); $tmp[$id]['sub'][$subid]['text'] = e107::getParser()->toHTML($title, FALSE, 'LINKTEXT'); $tmp[$id]['sub'][$subid]['description'] = vartrue($plug_vars['description']['@value']) ? e107::getParser()->toHTML($plug_vars['description']['@value']) : ""; $tmp[$id]['sub'][$subid]['link'] = e_PLUGIN_ABS . $row['plugin_path'] . '/' . $plugsub['url']; $tmp[$id]['sub'][$subid]['image'] = $icon_src ? "<img src='{$icon_src}' alt=\"" . varset($tmp[$id]['sub'][$subid]['text']) . "\" class='icon S16' />" : ""; $tmp[$id]['sub'][$subid]['image_large'] = ''; $tmp[$id]['sub'][$subid]['image_src'] = $icon_src; $tmp[$id]['sub'][$subid]['image_large_src'] = ''; $tmp[$id]['sub'][$subid]['perm'] = varset($plugsub['perm']) ? $plugsub['perm'] : 'P' . $row['plugin_id']; $tmp[$id]['sub'][$subid]['sub_class'] = ''; } } } } } $menu_vars['plugMenu']['sub'] = multiarray_sort($tmp, 'text'); } // ---------------- Cameron's Bit --------------------------------- if (!vartrue($pref['admin_separate_plugins'])) { // Convert Plugin Categories to Core Categories. $convert = array('settings' => array(1, 'setMenu'), 'users' => array(2, 'userMenu'), 'content' => array(3, 'contMenu'), 'tools' => array(4, 'toolMenu'), 'manage' => array(6, 'managMenu'), 'misc' => array(7, 'miscMenu'), 'help' => array(20, 'helpMenu')); foreach ($tmp as $pg) { if (!empty($pg['category'])) { $id = $convert[$pg['category']][1]; $menu_vars[$id]['sub'][] = $pg; } } unset($menu_vars['plugMenu']); // Clean up - remove empty main sections foreach ($menu_vars as $_m => $_d) { if (!isset($_d['sub']) || empty($_d['sub'])) { unset($menu_vars[$_m]); } } } // ------------------------------------------------------------------ //added option to disable leave/logout (ll) - more flexibility for theme developers if (!vartrue($parms['disable_ll'])) { // $menu_vars += $this->getOtherNav('home'); } // print_a($menu_vars); return e107::getNav()->admin('', e_PAGE, $menu_vars, ${$tmpl}, FALSE, FALSE); //return e_admin_men/u('', e_PAGE, $menu_vars, $$tmpl, FALSE, FALSE); }
function adminLinks($mode = false) { if ($mode == 'plugin') { return $this->pluginLinks(E_16_PLUGMANAGER, "array"); } $this->setIconArray(); if ($mode == 'sub') { //FIXME array structure suitable for e_admin_menu - see shortcodes/admin_navigation.php /* * Info about sublinks array structure * * key = $array_functions key * attribute 1 = link * attribute 2 = title * attribute 3 = description * attribute 4 = perms * attribute 5 = category * attribute 6 = 16 x 16 image * attribute 7 = 32 x 32 image * */ $array_sub_functions = array(); $array_sub_functions[17][] = array(e_ADMIN . 'newspost.php', LAN_MANAGE, ADLAN_3, 'H', 3, E_16_MANAGE, E_32_MANAGE); $array_sub_functions[17][] = array(e_ADMIN . 'newspost.php?create', LAN_CREATE, ADLAN_2, 'H', 3, E_16_CREATE, E_32_CREATE); $array_sub_functions[17][] = array(e_ADMIN . 'newspost.php?pref', LAN_PREFS, LAN_PREFS, 'H', 3, E_16_SETTINGS, E_32_SETTINGS); return $array_sub_functions; } //FIXME array structure suitable for e_admin_menu (NOW admin() below) - see shortcodes/admin_navigation.php //TODO find out where is used $array_functions elsewhere, refactor it //XXX DO NOT EDIT without first checking perms in user_handler.php !!!! $array_functions = array(0 => array(e_ADMIN_ABS . 'administrator.php', ADLAN_8, ADLAN_9, '3', 2, E_16_ADMIN, E_32_ADMIN), 1 => array(e_ADMIN_ABS . 'updateadmin.php', ADLAN_10, ADLAN_11, '', 2, E_16_ADPASS, E_32_ADPASS), 2 => array(e_ADMIN_ABS . 'banlist.php', ADLAN_34, ADLAN_35, '4', 2, E_16_BANLIST, E_32_BANLIST), 4 => array(e_ADMIN_ABS . 'cache.php', ADLAN_74, ADLAN_75, 'C', 1, E_16_CACHE, E_32_CACHE), 5 => array(e_ADMIN_ABS . 'cpage.php', ADLAN_42, ADLAN_43, '5|J', 3, E_16_CUST, E_32_CUST), 6 => array(e_ADMIN_ABS . 'db.php', ADLAN_44, ADLAN_45, '0', 4, E_16_DATAB, E_32_DATAB), 8 => array(e_ADMIN_ABS . 'emoticon.php', ADLAN_58, ADLAN_59, 'F', 1, E_16_EMOTE, E_32_EMOTE), 10 => array(e_ADMIN_ABS . 'frontpage.php', ADLAN_60, ADLAN_61, 'G', 1, E_16_FRONT, E_32_FRONT), 11 => array(e_ADMIN_ABS . 'image.php', LAN_MEDIAMANAGER, LAN_MEDIAMANAGER, 'A', 5, E_16_IMAGES, E_32_IMAGES), 12 => array(e_ADMIN_ABS . 'links.php', ADLAN_138, ADLAN_139, 'I', 1, E_16_LINKS, E_32_LINKS), 13 => array(e_ADMIN_ABS . 'wmessage.php', ADLAN_28, ADLAN_29, 'M', 3, E_16_WELCOME, E_32_WELCOME), 14 => array(e_ADMIN_ABS . 'ugflag.php', ADLAN_40, ADLAN_41, '9', 4, E_16_MAINTAIN, E_32_MAINTAIN), 15 => array(e_ADMIN_ABS . 'menus.php', ADLAN_6, ADLAN_7, '2', 5, E_16_MENUS, E_32_MENUS), 16 => array(e_ADMIN_ABS . 'meta.php', ADLAN_66, ADLAN_67, 'T', 1, E_16_META, E_32_META), 17 => array(e_ADMIN_ABS . 'newspost.php', ADLAN_0, ADLAN_1, 'H|N|7|H0|H1|H2|H3|H4|H5', 3, E_16_NEWS, E_32_NEWS), 18 => array(e_ADMIN_ABS . 'phpinfo.php', ADLAN_68, ADLAN_69, '0', 20, E_16_PHP, E_32_PHP), 19 => array(e_ADMIN_ABS . 'prefs.php', LAN_PREFS, ADLAN_5, '1', 1, E_16_PREFS, E_32_PREFS), 20 => array(e_ADMIN_ABS . 'search.php', LAN_SEARCH, ADLAN_143, 'X', 1, E_16_SEARCH, E_32_SEARCH), 21 => array(e_ADMIN_ABS . 'admin_log.php', ADLAN_155, ADLAN_156, 'S', 4, E_16_ADMINLOG, E_32_ADMINLOG), 22 => array(e_ADMIN_ABS . 'theme.php', ADLAN_140, ADLAN_141, '1', 5, E_16_THEMEMANAGER, E_32_THEMEMANAGER), 23 => array(e_ADMIN_ABS . 'upload.php', ADLAN_72, ADLAN_73, 'V', 3, E_16_UPLOADS, E_32_UPLOADS), 24 => array(e_ADMIN_ABS . 'users.php', ADLAN_36, ADLAN_37, '4|U0|U1|U2|U3', 2, E_16_USER, E_32_USER), 25 => array(e_ADMIN_ABS . 'userclass2.php', ADLAN_38, ADLAN_39, '4', 2, E_16_USERCLASS, E_32_USERCLASS), 26 => array(e_ADMIN_ABS . 'language.php', ADLAN_132, ADLAN_133, 'L', 1, E_16_LANGUAGE, E_32_LANGUAGE), 27 => array(e_ADMIN_ABS . 'mailout.php', ADLAN_136, ADLAN_137, 'W', 2, E_16_MAIL, E_32_MAIL), 28 => array(e_ADMIN_ABS . 'users_extended.php', ADLAN_78, ADLAN_79, '4', 2, E_16_USER_EXTENDED, E_32_USER_EXTENDED), 29 => array(e_ADMIN_ABS . 'fileinspector.php', ADLAN_147, ADLAN_148, 'Y', 4, E_16_INSPECT, E_32_INSPECT), 30 => array(e_ADMIN_ABS . 'notify.php', ADLAN_149, ADLAN_150, 'O', 4, E_16_NOTIFY, E_32_NOTIFY), 31 => array(e_ADMIN_ABS . 'cron.php', ADLAN_157, ADLAN_158, 'U', 4, E_16_CRON, E_32_CRON), 32 => array(e_ADMIN_ABS . 'eurl.php', ADLAN_159, ADLAN_160, 'K', 1, E_16_EURL, E_32_EURL), 33 => array(e_ADMIN_ABS . 'plugin.php', ADLAN_98, ADLAN_99, 'Z', 5, E_16_PLUGMANAGER, E_32_PLUGMANAGER), 34 => array(e_ADMIN_ABS . 'docs.php', ADLAN_12, ADLAN_13, '', 20, E_16_DOCS, E_32_DOCS), 36 => array(e_ADMIN_ABS . 'credits.php', LAN_CREDITS, LAN_CREDITS, '', 20, E_16_E107, E_32_E107), 38 => array(e_ADMIN_ABS . 'comment.php', LAN_COMMENTMAN, LAN_COMMENTMAN, 'B', 5, E_16_COMMENT, E_32_COMMENT)); if ($mode == 'legacy') { return $array_functions; // Old BC format. } $newarray = asortbyindex($array_functions, 1); $array_functions_assoc = $this->convert_core_icons($newarray); if ($mode == 'core') { return $array_functions_assoc; } $merged = array_merge($array_functions_assoc, $this->pluginLinks(E_16_PLUGMANAGER, "array")); $sorted = multiarray_sort($merged, 'title'); // this deleted the e-xxxx and p-xxxxx keys. return $this->restoreKeys($sorted); // we restore the keys with this. }
function __construct() { global $mySQLdefaultdb; $this->_utf8_exclude = array(MPREFIX . "core"); $this->_options = array("db_update" => array('diz' => DBLAN_15, 'label' => DBLAN_16), "verify_sql" => array('diz' => DBLAN_4, 'label' => DBLAN_5), 'optimize_sql' => array('diz' => DBLAN_6, 'label' => DBLAN_7), 'plugin_scan' => array('diz' => DBLAN_28, 'label' => DBLAN_29), 'pref_editor' => array('diz' => DBLAN_19, 'label' => DBLAN_20), 'importForm' => array('diz' => DBLAN_59, 'label' => DBLAN_59), 'exportForm' => array('diz' => DBLAN_58, 'label' => DBLAN_58), 'sc_override_scan' => array('diz' => DBLAN_55, 'label' => DBLAN_56), 'convert_to_utf8' => array('diz' => DBLAN_64, 'label' => DBLAN_65), 'correct_perms' => array('diz' => DBLAN_66, 'label' => DBLAN_67), 'backup' => array('diz' => DBLAN_68, 'label' => DBLAN_69)); if (deftrue('e_DEVELOPER')) { $this->_options['multisite'] = array('diz' => "<span class='label label-warning'>Developer Mode Only</span>", 'label' => 'Multi-Site'); $this->_options['github'] = array('diz' => "<span class='label label-warning'>Developer Mode Only</span> Overwrite local files with the latest from github.", 'label' => 'Sync with Github'); } $this->_options = multiarray_sort($this->_options, 'label'); if (isset($_POST['delplug'])) { $this->delete_plugin_entry($_POST['pref_type']); } if (isset($_POST['upload'])) { $this->importXmlFile(); } if (isset($_POST['delpref']) || isset($_POST['delpref_checked']) && isset($_POST['delpref2'])) { $this->del_pref_val($_POST['pref_type']); } if (isset($_POST['verify_sql']) || varset($_GET['mode']) == 'verify_sql') { require_once e_HANDLER . "db_verify_class.php"; $dbv = new db_verify(); $dbv->backUrl = e_SELF . "?mode=verify_sql"; $dbv->verify(); return; } // ----------------- Processes ------------------ // if(isset($_POST['verify_sql_record']) || varset($_GET['mode'])=='verify_sql_record' || isset($_POST['check_verify_sql_record']) || isset($_POST['delete_verify_sql_record'])) // { //$this->verify_sql_record(); // - currently performed in db_verify_class.php // } if (isset($_POST['importForm']) || $_GET['mode'] == 'importForm') { $this->importForm(); } if (isset($_POST['db_update']) || varset($_GET['mode']) == 'db_update') { // header("location: ".e_ADMIN."e107_update.php"); require_once e_ADMIN . "update_routines.php"; new e107Update($dbupdate); return; } if (isset($_POST['convert_to_utf8']) || $_GET['mode'] == 'convert_to_utf8') { $this->convertUTF8Form(); } if (isset($_POST['exportForm']) || $_GET['mode'] == 'exportForm') { $this->exportXmlForm(); } if (isset($_POST['optimize_sql']) || $_GET['mode'] == 'optimize_sql') { $this->optimizesql($mySQLdefaultdb); } if (isset($_POST['pref_editor']) || $_GET['mode'] == 'pref_editor' || isset($_POST['delpref']) || isset($_POST['delpref_checked'])) { $type = isset($_GET['type']) ? $_GET['type'] : "core"; $this->pref_editor($type); } if (isset($_POST['sc_override_scan']) || $_GET['mode'] == 'sc_override_scan') { $this->scan_override(); } if (isset($_POST['plugin_scan']) || e_QUERY == "plugin" || isset($_POST['delplug']) || $_GET['mode'] == 'plugin_scan') { $this->plugin_viewscan('refresh'); } if (!empty($_POST['create_multisite'])) { $this->multiSiteProcess(); } if (!empty($_POST['perform_utf8_convert'])) { $this->perform_utf8_convert(); return; } if (!empty($_POST['githubSyncProcess'])) { $this->githubSyncProcess(); return; } // --------------------- Modes --------------------------------. if (varset($_GET['mode']) == 'correct_perms') { $this->correct_perms(); return; } if (varset($_GET['mode']) == 'multisite') { $this->multiSite(); return; } if (varset($_GET['mode']) == 'github') { $this->githubSync(); } if (varset($_GET['mode']) == 'backup') { $this->backup(); return; } if (!vartrue($_GET['mode']) && !isset($_POST['db_execute'])) { $this->render_options(); } }
function imageselector_shortcode($parm = '', $mod = '') { $sql = e107::getDb('imageselector.sc'); $tp = e107::getParser(); if (strstr($parm, "=")) { // query style parms. parse_str($parm, $parms); extract($parms); } else { // comma separated parms. list($name, $path, $default, $width, $height, $multiple, $label, $subdirs, $filter, $fullpath, $click_target, $click_prefix, $click_postfix, $tabindex, $class) = explode(",", $parm); } $paths = explode("|", $path); if (trim($default[0]) == "{") { $pvw_default = $tp->replaceConstants($default, 'abs'); $path = ""; // remove the default path if a constant is used. } $scaction = vartrue($scaction, 'all'); $text = ''; $name_id = e107::getForm()->name2id($name); $imagelist = array(); //Get Select Box Only! if ($scaction == 'select' || $scaction == 'all') { // Media manager support if (vartrue($parms['media'])) { $qry = "SELECT * FROM `#core_media` WHERE media_userclass IN (" . USERCLASS_LIST . ") "; $qry .= vartrue($parms['media']) && $parms['media'] !== 'all' ? " AND media_category='" . $tp->toDB($parms['media']) . "' " : " AND `media_category` NOT REGEXP '_icon_16|_icon_32|_icon_48|_icon_64' "; $qry .= " AND media_url REGEXP '\\.jpg\$|\\.png\$|\\.gif\$|\\.jpeg\$|\\.svn\$|\\.JPG\$|\\.PNG\$|\\.GIF\$|\\.jpeg\$|\\.SVN\$' ORDER BY media_name"; // FIXME - media_type=image? if ($sql->db_Select_gen($qry)) { while ($row = $sql->db_Fetch()) { //$imagelist[$row['media_category']][$row['media_url']] = $row['media_name']. " (".$row['media_dimensions'].") "; $imagelist[$row['media_category']][] = array('path' => $row['media_url'], 'fname' => $row['media_name'] . " (" . $row['media_dimensions'] . ") "); } asort($opts); } } else { //require_once(e_HANDLER."file_class.php"); $fl = e107::getFile(false); $recurse = $subdirs ? $subdirs : 0; foreach ($paths as $pths) { $imagelist[$tp->createConstants($pths, 'mix')] = $fl->get_files($pths, '\\.jpg|\\.gif|\\.png|\\.JPG|\\.GIF|\\.PNG|\\.jpeg|\\.JPEG|\\.svn|\\.SVN', 'standard', $recurse); } if (!$fullpath && count($paths) > 1) { $fullpath = TRUE; } } $multi = $multiple == "TRUE" || $multiple == "1" ? " multiple='multiple' style='height:{$height}'" : ""; //style='float:left' $width = vartrue($width) ? $width : "0"; $height = vartrue($height) ? $height : "0"; $label = $label ? $label : " -- -- "; $tabindex = varset($tabindex) ? " tabindex='{$tabindex}'" : ''; $class = varset($class) ? " class='{$class}'" : " class='tbox imgselector'"; if (!e_AJAX_REQUEST) { $text .= '<div id="' . $name_id . '_cont">'; } $text .= "\n<select{$multi}{$tabindex}{$class} name='{$name}' id='{$name_id}' onchange=\"replaceSC('imagepreview={$name}|{$width}|{$height}',this.form,'{$name_id}_prev'); \">\n\t\t<option value=''>" . $label . "</option>\n"; foreach ($imagelist as $imagedirlabel => $icons) { if (!vartrue($parms['media'])) { $imagedirlabel = str_replace('../', '', $tp->replaceConstants($imagedirlabel)); } $text .= "<optgroup label='" . $imagedirlabel . "'>\n"; if (empty($icons)) { $text .= "<option value=''>Empty</option>\n"; } else { $icons = multiarray_sort($icons, 'fname'); foreach ($icons as $icon) { $dir = str_replace($paths, "", $icon['path']); // echo "dir=".$icon['path']; if (!$filter || $filter && preg_match('~' . $filter . '~', $dir . $icon['fname'])) { $pth = $dir; if (!vartrue($parms['media'])) { $pth = $tp->createConstants($icon['path'], 'rel'); $_value = $pth . $icon['fname']; $_label = $dir . $icon['fname']; $selected = $default == $_value || $pth . $default == $_value ? " selected='selected'" : ""; } else { // convert e.g. {e_MEDIA}images/ to {e_MEDIA_IMAGES} $pth = $tp->createConstants($tp->replaceConstants($icon['path']), 'rel'); $_value = $pth; $_label = $icon['fname']; $selected = $default == $_value ? " selected='selected'" : ""; } $text .= "<option value='{$_value}'{$selected}> {$_label}</option>\n"; } } } $text .= "</optgroup>\n"; } $text .= "</select>"; $text .= "<a href='#' onclick=\"replaceSC('imageselector=" . rawurlencode($parm) . "&saction=select',\$('{$name_id}').up('form'),'{$name_id}_cont'); return false;\">refresh</a>"; if (!e_AJAX_REQUEST) { $text .= '</div>'; } if ($scaction == 'select') { return $text; } } $hide = ''; if (!$pvw_default) { if ($default) { $test = pathinfo($default); if ('.' == $test['dirname']) { // file only, add absolute path $path = $tp->createConstants($path, 1); $path = $tp->replaceConstants($path, 'abs'); $pvw_default = $path . $default; } else { // path, convert to absolute path $pvw_default = $tp->createConstants($default, 1); $pvw_default = $tp->replaceConstants($pvw_default, 'abs'); } } else { $pvw_default = e_IMAGE_ABS . "generic/blank.gif"; $hide = ' style="display: none;"'; } } $text .= "<div class='imgselector-container' id='{$name_id}_prev'>"; if (varset($click_target)) { $pre = varset($click_prefix); $post = varset($click_postfix); $text .= "<a href='#'{$hide} title='Select' onclick='addtext(\"{$pre}\"+document.getElementById(\"{$name_id}\").value+\"{$post}\", true);document.getElementById(\"{$name_id}\").selectedIndex = -1;return false;'>"; } else { $text .= "<a href='{$pvw_default}'{$hide} rel='external shadowbox' title='Preview {$pvw_default}' class='e-image-preview'>"; } if (vartrue($height)) { $height = intval($height); } if (vartrue($width)) { $width = intval($width); } $thpath = isset($parms['nothumb']) || $hide ? $pvw_default : $tp->thumbUrl($pvw_default, 'w=' . $width . '&h=' . $height, true); $text .= "<img src='{$thpath}' alt='{$pvw_default}' class='image-selector' /></a>"; $text .= "</div>\n"; return "\n\n<!-- Start Image Selector [{$scaction}] -->\n\n" . $text . "\n\n<!-- End Image Selector [{$scaction}] -->\n\n"; }