/** * Get Common Utilities Configurations */ public function configs($name = '') { static $rmc_configs; if (!isset($rmc_configs)) { $db = Database::getInstance(); $sql = "SELECT mid FROM " . $db->prefix("modules") . " WHERE dirname='rmcommon'"; list($id) = $db->fetchRow($db->query($sql)); include_once XOOPS_ROOT_PATH . '/kernel/object.php'; include_once XOOPS_ROOT_PATH . '/kernel/configitem.php'; include_once XOOPS_ROOT_PATH . '/class/criteria.php'; include_once XOOPS_ROOT_PATH . '/class/module.textsanitizer.php'; $ret = array(); $result = $db->query("SELECT * FROM " . $db->prefix("config") . " WHERE conf_modid='{$id}'"); while ($row = $db->fetchArray($result)) { $config = new XoopsConfigItem(); $config->assignVars($row); $rmc_configs[$config->getVar('conf_name')] = $config->getConfValueForOutput(); } } $name = trim($name); if ($name != '') { if (isset($rmc_configs[$name])) { return $rmc_configs[$name]; } } return $rmc_configs; }
/** * Get the current settings for Common Utilities * This method is a replace for deprecated RMSettings::cu_settings() method * * @param string $name * @return stdClass */ static function cu_settings($name = '') { global $cuSettings; if (!isset($cuSettings)) { $cuSettings = new stdClass(); $db = XoopsDatabaseFactory::getDatabaseConnection(); $sql = "SELECT mid FROM " . $db->prefix("modules") . " WHERE dirname='rmcommon'"; list($id) = $db->fetchRow($db->query($sql)); include_once XOOPS_ROOT_PATH . '/kernel/object.php'; include_once XOOPS_ROOT_PATH . '/kernel/configitem.php'; include_once XOOPS_ROOT_PATH . '/class/criteria.php'; include_once XOOPS_ROOT_PATH . '/class/module.textsanitizer.php'; $ret = array(); $result = $db->query("SELECT * FROM " . $db->prefix("config") . " WHERE conf_modid='{$id}'"); while ($row = $db->fetchArray($result)) { $config = new XoopsConfigItem(); $config->assignVars($row); $cuSettings->{$config->getVar('conf_name')} = $config->getConfValueForOutput(); } } $name = trim($name); if ($name != '') { if (isset($cuSettings->{$name})) { return $cuSettings->{$name}; } } return $cuSettings; }
/** * @param XoopsConfigItem $config * * @return Xoops\Form\ThemeForm[] */ function createThemeform(XoopsConfigItem $config) { $title = $config->getVar('conf_desc') == '' ? Xoops_Locale::translate($config->getVar('conf_title'), 'system') : Xoops_Locale::translate($config->getVar('conf_title'), 'system') . '<br /><br /><span>' . Xoops_Locale::translate($config->getVar('conf_desc'), 'system') . '</span>'; $form_theme_set = new Xoops\Form\Select('', $config->getVar('conf_name'), $config->getConfValueForOutput(), 1, false); $dirlist = XoopsLists::getThemesList(); if (!empty($dirlist)) { asort($dirlist); $form_theme_set->addOptionArray($dirlist); } $label_content = ""; // read ini file for each theme foreach ($dirlist as $theme) { // set default value $theme_ini = array('Name' => $theme, 'Description' => '', 'Version' => '', 'Format' => '', 'Author' => '', 'Demo' => '', 'Url' => '', 'Download' => '', 'W3C' => '', 'Licence' => '', 'thumbnail' => 'screenshot.gif', 'screenshot' => 'screenshot.png'); if ($theme == $config->getConfValueForOutput()) { $label_content .= "<div id='{$theme}' rel='theme' style='display:block;'>"; } else { $label_content .= "<div id='{$theme}' rel='theme' style='display:none;'>"; } if (file_exists(XOOPS_ROOT_PATH . "/themes/{$theme}/theme.ini")) { $theme_ini = parse_ini_file(XOOPS_ROOT_PATH . "/themes/{$theme}/theme.ini"); if ($theme_ini['screenshot'] == '') { $theme_ini['screenshot'] = 'screenshot.png'; $theme_ini['thumbnail'] = 'thumbnail.png'; } } if ($theme_ini['screenshot'] != '' && file_exists(XOOPS_ROOT_PATH . "/themes/{$theme}/" . $theme_ini['screenshot'])) { $label_content .= "<img src='" . XOOPS_URL . "/themes/" . $theme . "/" . $theme_ini['screenshot'] . "' alt='Screenshot' />"; } elseif ($theme_ini['thumbnail'] != '' && file_exists(XOOPS_ROOT_PATH . "/themes/{$theme}/" . $theme_ini['thumbnail'])) { $label_content .= "<img src='" . XOOPS_URL . "/themes/" . $theme . "/" . $theme_ini['thumbnail'] . "' alt='{$theme}' />"; } else { $label_content .= THEME_NO_SCREENSHOT; } $label_content .= "</div>"; } // read ini file for each theme $form_theme_set->setExtra("onchange='showThemeSelected(this)'"); $form = new Xoops\Form\ThemeForm($title, 'themes', 'index.php', 'post'); $form->addElement($form_theme_set); $form->addElement(new Xoops\Form\Label('', "<div id='screenshot'>" . $label_content . "</div>")); $form->addElement(new Xoops\Form\Hidden('conf_ids[]', $config->getVar('conf_id'))); return array($form); }