/**
  * @param $args
  */
 function eventCoreFooterEnd($args)
 {
     global $resourcesModule, $resourcesConfigsList;
     if (empty($resourcesModule)) {
         if (is_a($resourcesModule = xoops_gethandler('module')->getByDirname(basename(dirname(__DIR__))), "XoopsModule")) {
             if (empty($resourcesConfigsList)) {
                 $resourcesConfigsList = xoops_gethandler('config')->getConfigsList($resourcesModule->getVar('mid'));
             }
         }
     }
     xoops_load("XoopsCache");
     xoops_load("XoopsLists");
     if (!($themes = XoopsCache::read(basename(dirname(__DIR__)) . '.available.themes'))) {
         $themes = json_decode(getURIData(sprintf(_MI_RESOURCES_THEMES, _RESOURCES_SUPPORTING)), true);
         if (!empty($themes)) {
             XoopsCache::write(basename(dirname(__DIR__)) . '.available.themes', $themes, 3600 * mt_rand(2.99999, 12.99999));
         }
     }
     if (!($modules = XoopsCache::read(basename(dirname(__DIR__)) . '.available.modules'))) {
         $modules = json_decode(getURIData(sprintf(_MI_RESOURCES_MODULES, _RESOURCES_SUPPORTING)), true);
         if (!empty($themes)) {
             XoopsCache::write(basename(dirname(__DIR__)) . '.available.modules', $modules, 3600 * mt_rand(2.99999, 12.99999));
         }
     }
     if (!($peers = XoopsCache::read(basename(dirname(__DIR__)) . '.available.peers'))) {
         $peers = json_decode(getURIData(sprintf(_MI_RESOURCES_PEERS, _RESOURCES_SUPPORTING)), true);
         if (!empty($themes)) {
             XoopsCache::write(basename(dirname(__DIR__)) . '.available.peers', $peers, 3600 * 24 * mt_rand(5.99999, 24.99999));
         }
     }
     if (!($modules = XoopsCache::read(basename(dirname(__DIR__)) . '.modules.delays') && $resourcesConfigsList['harvester'])) {
         XoopsCache::write(basename(dirname(__DIR__)) . '.modules', true, 3600 * 24 * 29);
         XoopsCache::write(basename(dirname(__DIR__)) . '.modules.delays', $modules = XoopsLists::getModulesList(), 3600 * 24 * 31);
         foreach ($modules as $module) {
             $map = getFolderMap($GLOBALS['xoops']->path('/modules/' . $module));
             XoopsCache::write(basename(dirname(__DIR__)) . '.module' . $module, true, $seconds = 3600 * 24 * mt_rand(21.69999, 42.998876));
             XoopsCache::write(basename(dirname(__DIR__)) . '.module' . $module . '.delays', $map, $seconds + 3600 * 4);
             if (is_dir(XOOPS_PATH . '/modules/' . $module)) {
                 $map = getFolderMap(XOOPS_PATH . '/modules/' . $module, XOOPS_PATH);
                 XoopsCache::write(basename(dirname(__DIR__)) . '.xoopslib' . $module, true, $seconds);
                 XoopsCache::write(basename(dirname(__DIR__)) . '.xoopslib' . $module . '.delays', $map, $seconds + 3600 * 4);
             }
         }
     }
     if (!($themes = XoopsCache::read(basename(dirname(__DIR__)) . '.themes.delays') && $resourcesConfigsList['harvester'])) {
         XoopsCache::write(basename(dirname(__DIR__)) . '.themes', true, 3600 * 24 * 29);
         XoopsCache::write(basename(dirname(__DIR__)) . '.themes.delays', $themes = XoopsLists::getThemesList(), 3600 * 24 * 31);
         foreach ($themes as $theme) {
             $map = getFolderMap($GLOBALS['xoops']->path('/themes/' . $theme));
             XoopsCache::write(basename(dirname(__DIR__)) . '.theme' . $theme, true, $seconds = 3600 * 24 * mt_rand(21.69999, 42.998876));
             XoopsCache::write(basename(dirname(__DIR__)) . '.theme' . $theme . '.delays', $map, $seconds + 3600 * 4);
         }
     }
 }
Esempio n. 2
0
 /**
  * Constructor
  *
  * @param string $caption
  * @param string $name
  * @param mixed  $value             Pre-selected value (or array of them).
  * @param int    $size              Number or rows. "1" makes a drop-down-list
  * @param bool   $theme_set_allowed Flag to use only selectable theme
  */
 public function __construct($caption, $name, $value = null, $size = 1, $theme_set_allowed = false)
 {
     parent::__construct($caption, $name, $value, $size);
     if ($theme_set_allowed === false) {
         $this->addOptionArray(XoopsLists::getThemesList());
     } else {
         $theme_arr = $GLOBALS['xoopsConfig']['theme_set_allowed'];
         foreach (array_keys($theme_arr) as $i) {
             $this->addOption($theme_arr[$i], $theme_arr[$i]);
         }
     }
 }
Esempio n. 3
0
     $options = $config_handler->getConfigOptions(new Criteria('conf_id', $config[$i]->getVar('conf_id')));
     $opcount = count($options);
     for ($j = 0; $j < $opcount; $j++) {
         $optval = defined($options[$j]->getVar('confop_value')) ? constant($options[$j]->getVar('confop_value')) : $options[$j]->getVar('confop_value');
         $optkey = defined($options[$j]->getVar('confop_name')) ? constant($options[$j]->getVar('confop_name')) : $options[$j]->getVar('confop_name');
         $ele->addOption($optval, $optkey);
     }
     break;
 case 'yesno':
     $ele = new XoopsFormRadioYN($title, $config[$i]->getVar('conf_name'), $config[$i]->getConfValueForOutput(), _YES, _NO);
     break;
 case 'theme':
 case 'theme_multi':
     $ele = $config[$i]->getVar('conf_formtype') != 'theme_multi' ? new XoopsFormSelect($title, $config[$i]->getVar('conf_name'), $config[$i]->getConfValueForOutput()) : new XoopsFormSelect($title, $config[$i]->getVar('conf_name'), $config[$i]->getConfValueForOutput(), 5, true);
     require_once XOOPS_ROOT_PATH . "/class/xoopslists.php";
     $dirlist = XoopsLists::getThemesList();
     if (!empty($dirlist)) {
         asort($dirlist);
         $ele->addOptionArray($dirlist);
     }
     //$themeset_handler =& xoops_gethandler('themeset');
     //$themesetlist =& $themeset_handler->getList();
     //asort($themesetlist);
     //foreach ($themesetlist as $key => $name) {
     //  $ele->addOption($key, $name.' ('._MD_AM_THEMESET.')');
     //}
     // old theme value is used to determine whether to update cache or not. kind of dirty way
     $form->addElement(new XoopsFormHidden('_old_theme', $config[$i]->getConfValueForOutput()));
     break;
 case 'tplset':
     $ele = new XoopsFormSelect($title, $config[$i]->getVar('conf_name'), $config[$i]->getConfValueForOutput());
Esempio n. 4
0
 /**
  * @param array       $obj
  * @param XoopsModule $mod
  */
 public function getForm(&$obj, XoopsModule $mod)
 {
     $xoops = Xoops::getInstance();
     $helper = Userconfigs::getInstance();
     $config_handler = $helper->getHandlerConfig();
     /* @var $plugin UserconfigsPluginInterface */
     if ($plugin = \Xoops\Module\Plugin::getPlugin($mod->getVar('dirname'), 'userconfigs')) {
         parent::__construct('', 'pref_form', 'index.php', 'post', true);
         if ($mod->getVar('dirname') != 'system') {
             $xoops->loadLanguage('modinfo', $mod->getVar('dirname'));
             $xoops->loadLocale($mod->getVar('dirname'));
         }
         $configs = $plugin->configs();
         $configNames = array();
         foreach (array_keys($configs) as $i) {
             $configNames[$configs[$i]['name']] =& $configs[$i];
         }
         $configCats = $plugin->categories();
         if (!$configCats) {
             $configCats = array('default' => array('name' => _MD_USERCONFIGS_CONFIGS, 'description' => ''));
         }
         if (!in_array('default', array_keys($configCats))) {
             $configCats['default'] = array('name' => _MD_USERCONFIGS_CONFIGS, 'description' => '');
         }
         foreach (array_keys($configNames) as $name) {
             if (!isset($configNames[$name]['category'])) {
                 $configNames[$name]['category'] = 'default';
             }
         }
         $tabtray = new Xoops\Form\TabTray('', 'pref_tabtay', $xoops->getModuleConfig('jquery_theme', 'system'));
         $tabs = array();
         foreach ($configCats as $name => $info) {
             $tabs[$name] = new Xoops\Form\Tab($info['name'], 'pref_tab_' . $name);
             if (isset($info['description']) && $info['description'] != '') {
                 $tabs[$name]->addElement(new Xoops\Form\Label('', $info['description']));
             }
         }
         $count = count($obj);
         for ($i = 0; $i < $count; ++$i) {
             $title = Xoops_Locale::translate($obj[$i]->getVar('conf_title'), $mod->getVar('dirname'));
             $desc = $obj[$i]->getVar('conf_desc') != '' ? Xoops_Locale::translate($obj[$i]->getVar('conf_desc'), $mod->getVar('dirname')) : '';
             switch ($obj[$i]->getVar('conf_formtype')) {
                 case 'textarea':
                     $myts = MyTextSanitizer::getInstance();
                     if ($obj[$i]->getVar('conf_valuetype') == 'array') {
                         // this is exceptional.. only when value type is arrayneed a smarter way for this
                         $ele = $obj[$i]->getVar('conf_value') != '' ? new Xoops\Form\TextArea($title, $obj[$i]->getVar('conf_name'), $myts->htmlSpecialChars(implode('|', $obj[$i]->getConfValueForOutput())), 5, 5) : new Xoops\Form\TextArea($title, $obj[$i]->getVar('conf_name'), '', 5, 5);
                     } else {
                         $ele = new Xoops\Form\TextArea($title, $obj[$i]->getVar('conf_name'), $myts->htmlSpecialChars($obj[$i]->getConfValueForOutput()), 5, 5);
                     }
                     break;
                 case 'select':
                     $ele = new Xoops\Form\Select($title, $obj[$i]->getVar('conf_name'), $obj[$i]->getConfValueForOutput());
                     $options = $config_handler->getConfigOptions(new Criteria('conf_id', $obj[$i]->getVar('conf_id')));
                     $opcount = count($options);
                     for ($j = 0; $j < $opcount; ++$j) {
                         $optval = Xoops_Locale::translate($options[$j]->getVar('confop_value'), $mod->getVar('dirname'));
                         $optkey = Xoops_Locale::translate($options[$j]->getVar('confop_name'), $mod->getVar('dirname'));
                         $ele->addOption($optval, $optkey);
                     }
                     break;
                 case 'select_multi':
                     $ele = new Xoops\Form\Select($title, $obj[$i]->getVar('conf_name'), $obj[$i]->getConfValueForOutput(), 5, true);
                     $options = $config_handler->getConfigOptions(new Criteria('conf_id', $obj[$i]->getVar('conf_id')));
                     $opcount = count($options);
                     for ($j = 0; $j < $opcount; ++$j) {
                         $optval = Xoops_Locale::translate($options[$j]->getVar('confop_value'), $mod->getVar('dirname'));
                         $optkey = Xoops_Locale::translate($options[$j]->getVar('confop_name'), $mod->getVar('dirname'));
                         $ele->addOption($optval, $optkey);
                     }
                     break;
                 case 'yesno':
                     $ele = new Xoops\Form\RadioYesNo($title, $obj[$i]->getVar('conf_name'), $obj[$i]->getConfValueForOutput());
                     break;
                 case 'theme':
                 case 'theme_multi':
                     $ele = $obj[$i]->getVar('conf_formtype') != 'theme_multi' ? new Xoops\Form\Select($title, $obj[$i]->getVar('conf_name'), $obj[$i]->getConfValueForOutput()) : new Xoops\Form\Select($title, $obj[$i]->getVar('conf_name'), $obj[$i]->getConfValueForOutput(), 5, true);
                     $dirlist = XoopsLists::getThemesList();
                     if (!empty($dirlist)) {
                         asort($dirlist);
                         $ele->addOptionArray($dirlist);
                     }
                     break;
                 case 'tplset':
                     $ele = new Xoops\Form\Select($title, $obj[$i]->getVar('conf_name'), $obj[$i]->getConfValueForOutput());
                     $tplset_handler = $xoops->getHandlerTplSet();
                     $tplsetlist = $tplset_handler->getNameList();
                     asort($tplsetlist);
                     foreach ($tplsetlist as $key => $name) {
                         $ele->addOption($key, $name);
                     }
                     break;
                 case 'cpanel':
                     $ele = new Xoops\Form\Hidden($obj[$i]->getVar('conf_name'), $obj[$i]->getConfValueForOutput());
                     /*
                                             $ele = new Xoops\Form\Select($title, $config[$i]->getVar('conf_name'), $config[$i]->getConfValueForOutput());
                                             XoopsLoad::load("cpanel", "system");
                                             $list = XoopsSystemCpanel::getGuis();
                                             $ele->addOptionArray($list);  */
                     break;
                 case 'timezone':
                     $ele = new Xoops\Form\SelectTimeZone($title, $obj[$i]->getVar('conf_name'), $obj[$i]->getConfValueForOutput());
                     break;
                 case 'language':
                     $ele = new Xoops\Form\SelectLanguage($title, $obj[$i]->getVar('conf_name'), $obj[$i]->getConfValueForOutput());
                     break;
                 case 'locale':
                     $ele = new Xoops\Form\SelectLocale($title, $obj[$i]->getVar('conf_name'), $obj[$i]->getConfValueForOutput());
                     break;
                 case 'startpage':
                     $ele = new Xoops\Form\Select($title, $obj[$i]->getVar('conf_name'), $obj[$i]->getConfValueForOutput());
                     $module_handler = $xoops->getHandlerModule();
                     $criteria = new CriteriaCompo(new Criteria('hasmain', 1));
                     $criteria->add(new Criteria('isactive', 1));
                     $moduleslist = $module_handler->getNameList($criteria, true);
                     $moduleslist['--'] = XoopsLocale::NONE;
                     $ele->addOptionArray($moduleslist);
                     break;
                 case 'group':
                     $ele = new Xoops\Form\SelectGroup($title, $obj[$i]->getVar('conf_name'), false, $obj[$i]->getConfValueForOutput(), 1, false);
                     break;
                 case 'group_multi':
                     $ele = new Xoops\Form\SelectGroup($title, $obj[$i]->getVar('conf_name'), false, $obj[$i]->getConfValueForOutput(), 5, true);
                     break;
                     // RMV-NOTIFY: added 'user' and 'user_multi'
                 // RMV-NOTIFY: added 'user' and 'user_multi'
                 case 'user':
                     $ele = new Xoops\Form\SelectUser($title, $obj[$i]->getVar('conf_name'), false, $obj[$i]->getConfValueForOutput(), 1, false);
                     break;
                 case 'user_multi':
                     $ele = new Xoops\Form\SelectUser($title, $obj[$i]->getVar('conf_name'), false, $obj[$i]->getConfValueForOutput(), 5, true);
                     break;
                 case 'module_cache':
                     $module_handler = $xoops->getHandlerModule();
                     $modules = $module_handler->getObjectsArray(new Criteria('hasmain', 1), true);
                     $currrent_val = $obj[$i]->getConfValueForOutput();
                     $cache_options = array('0' => XoopsLocale::NO_CACHE, '30' => sprintf(XoopsLocale::F_SECONDS, 30), '60' => XoopsLocale::ONE_MINUTE, '300' => sprintf(XoopsLocale::F_MINUTES, 5), '1800' => sprintf(XoopsLocale::F_MINUTES, 30), '3600' => XoopsLocale::ONE_HOUR, '18000' => sprintf(XoopsLocale::F_HOURS, 5), '86400' => XoopsLocale::ONE_DAY, '259200' => sprintf(XoopsLocale::F_DAYS, 3), '604800' => XoopsLocale::ONE_WEEK, '2592000' => XoopsLocale::ONE_MONTH);
                     if (count($modules) > 0) {
                         $ele = new Xoops\Form\ElementTray($title, '<br />');
                         foreach (array_keys($modules) as $mid) {
                             $c_val = isset($currrent_val[$mid]) ? (int) $currrent_val[$mid] : null;
                             $selform = new Xoops\Form\Select($modules[$mid]->getVar('name'), $obj[$i]->getVar('conf_name') . "[{$mid}]", $c_val);
                             $selform->addOptionArray($cache_options);
                             $ele->addElement($selform);
                             unset($selform);
                         }
                     } else {
                         $ele = new Xoops\Form\Label($title, SystemLocale::NO_MODULE_TO_CACHE);
                     }
                     break;
                 case 'site_cache':
                     $ele = new Xoops\Form\Select($title, $obj[$i]->getVar('conf_name'), $obj[$i]->getConfValueForOutput());
                     $ele->addOptionArray(array('0' => XoopsLocale::NO_CACHE, '30' => sprintf(XoopsLocale::F_SECONDS, 30), '60' => XoopsLocale::ONE_MINUTE, '300' => sprintf(XoopsLocale::F_MINUTES, 5), '1800' => sprintf(XoopsLocale::F_MINUTES, 30), '3600' => XoopsLocale::ONE_HOUR, '18000' => sprintf(XoopsLocale::F_HOURS, 5), '86400' => XoopsLocale::ONE_DAY, '259200' => sprintf(XoopsLocale::F_DAYS, 3), '604800' => XoopsLocale::ONE_WEEK, '2592000' => XoopsLocale::ONE_MONTH));
                     break;
                 case 'password':
                     $myts = MyTextSanitizer::getInstance();
                     $ele = new Xoops\Form\Password($title, $obj[$i]->getVar('conf_name'), 5, 255, $myts->htmlSpecialChars($obj[$i]->getConfValueForOutput()));
                     break;
                 case 'color':
                     $myts = MyTextSanitizer::getInstance();
                     $ele = new Xoops\Form\ColorPicker($title, $obj[$i]->getVar('conf_name'), $myts->htmlSpecialChars($obj[$i]->getConfValueForOutput()));
                     break;
                 case 'hidden':
                     $myts = MyTextSanitizer::getInstance();
                     $ele = new Xoops\Form\Hidden($obj[$i]->getVar('conf_name'), $myts->htmlSpecialChars($obj[$i]->getConfValueForOutput()));
                     break;
                 case 'textbox':
                 default:
                     $myts = MyTextSanitizer::getInstance();
                     $ele = new Xoops\Form\Text($title, $obj[$i]->getVar('conf_name'), 5, 255, $myts->htmlSpecialChars($obj[$i]->getConfValueForOutput()));
                     break;
             }
             $hidden = new Xoops\Form\Hidden('conf_ids[]', $obj[$i]->getVar('conf_id'));
             if (isset($ele)) {
                 $ele->setDescription($desc);
                 if ($obj[$i]->getVar('conf_formtype') != 'hidden') {
                     $name = 'default';
                     if (isset($configNames[$obj[$i]->getVar('conf_name')]['category'])) {
                         $name = $configNames[$obj[$i]->getVar('conf_name')]['category'];
                     }
                     $tabs[$name]->addElement($ele);
                 } else {
                     $this->addElement($ele);
                 }
                 $this->addElement($hidden);
                 unset($ele);
                 unset($hidden);
             }
         }
         foreach (array_keys($tabs) as $name) {
             if ($tabs[$name]->getElements()) {
                 $tabtray->addElement($tabs[$name]);
             }
         }
         $this->addElement($tabtray);
         $this->addElement(new Xoops\Form\Hidden('op', 'save'));
         $this->addElement(new Xoops\Form\Hidden('mid', $mod->getVar('mid')));
         $this->addElement(new Xoops\Form\Button('', 'button', XoopsLocale::A_SUBMIT, 'submit'));
     }
 }
Esempio n. 5
0
 /**
  * Constructor
  * 
  * @param	string	$caption	
  * @param	string	$name
  * @param	mixed	$value	Pre-selected value (or array of them).
  * @param	int		$size	Number or rows. "1" makes a drop-down-list
  */
 function XoopsFormSelectTheme($caption, $name, $value = null, $size = 1)
 {
     $this->XoopsFormSelect($caption, $name, $value, $size);
     $this->addOptionArray(XoopsLists::getThemesList());
 }
Esempio n. 6
0
/**
 * @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);
}
 /**
  * Returns a {@link XoopsFormElement} for editing the value of this field
  *
  * @param object $user {@link XoopsUser} object to edit the value of
  *
  * @return object
  **/
 function getEditElement(&$user)
 {
     $value = $user->getVar($this->getVar('field_name'), 'e');
     $caption = $this->getVar('field_title');
     $caption = defined($caption) ? constant($caption) : $caption;
     $name = $this->getVar('field_name', 'e');
     $options = $this->getVar('field_options');
     asort($options);
     foreach (array_keys($options) as $key) {
         $optval = defined($options[$key]) ? constant($options[$key]) : $options[$key];
         $optkey = defined($key) ? constant($key) : $key;
         unset($options[$key]);
         $options[$optkey] = $optval;
     }
     include_once XOOPS_ROOT_PATH . "/class/xoopsformloader.php";
     switch ($this->getVar('field_type')) {
         default:
         case "autotext":
             //autotext is not for editing
             $element = new XoopsFormLabel($caption, $this->getOutputValue($user));
             break;
         case "textbox":
             $element = new XoopsFormText($caption, $name, 35, $this->getVar('field_maxlength'), $value);
             break;
         case "textarea":
             $element = new XoopsFormTextArea($caption, $name, $value, 10, 50);
             break;
         case "dhtml":
             $element = new XoopsFormDhtmlTextArea($caption, $name, $value, 10, 50);
             break;
         case "select":
             $element = new XoopsFormSelect($caption, $name, $value);
             $element->addOptionArray($options);
             break;
         case "select_multi":
             $element = new XoopsFormSelect($caption, $name, $value, 5, true);
             $element->addOptionArray($options);
             break;
         case "radio":
             $element = new XoopsFormRadio($caption, $name, $value);
             $element->addOptionArray($options);
             break;
         case "checkbox":
             $element = new XoopsFormCheckBox($caption, $name, $value);
             $element->addOptionArray($options);
             break;
         case "yesno":
             $element = new XoopsFormRadioYN($caption, $name, $value);
             break;
         case "group":
             $element = new XoopsFormSelectGroup($caption, $name, true, $value);
             break;
         case "group_multi":
             $element = new XoopsFormSelectGroup($caption, $name, true, $value, 5, true);
             break;
         case "language":
             $element = new XoopsFormSelectLang($caption, $name, $value);
             break;
         case "date":
             $element = new XoopsFormTextDateSelect($caption, $name, 15, $value);
             break;
             //            case "longdate":
             //            $element = new XoopsFormTextDateSelect($caption, $name, 15, str_replace("-", "/", $value));
             //            break;
         //            case "longdate":
         //            $element = new XoopsFormTextDateSelect($caption, $name, 15, str_replace("-", "/", $value));
         //            break;
         case "datetime":
             $element = new XoopsFormDatetime($caption, $name, 15, $value);
             break;
         case "list":
             $element = new XoopsFormSelectList($caption, $name, $value, 1, $options[0]);
             break;
         case "timezone":
             $element = new XoopsFormSelectTimezone($caption, $name, $value);
             break;
         case 'theme':
             $element = new XoopsFormSelect($caption, $name, $value);
             $element->addOption("0", _SITEDEFAULT);
             $theme_list = XoopsLists::getThemesList();
             foreach ($theme_list as $key => $val) {
                 if (!in_array($key, $GLOBALS['xoopsConfig']['theme_set_allowed'])) {
                     continue;
                 }
                 $element->addOption($key, $val);
             }
             /*
             $handle = opendir(XOOPS_THEME_PATH.'/');
             $dirlist = array();
             while (false !== ($file = readdir($handle))) {
                 if (is_dir(XOOPS_THEME_PATH.'/'.$file) && !preg_match("/^[.]{1,2}$/",$file) && strtolower($file) != 'cvs') {
                     if (file_exists(XOOPS_THEME_PATH."/".$file."/theme.html") && in_array($file, $GLOBALS['xoopsConfig']['theme_set_allowed'])) {
                         $dirlist[$file]=$file;
                     }
                 }
             }
             closedir($handle);
             if (!empty($dirlist)) {
                 asort($dirlist);
                 $element->addOptionArray($dirlist);
             }
             */
             break;
     }
     if ($this->getVar('field_description') != "") {
         $element->setDescription($this->getVar('field_description'));
     }
     return $element;
 }
<?php

require_once dirname(dirname(dirname(dirname(__DIR__)))) . DIRECTORY_SEPARATOR . 'mainfile.php';
require_once dirname(dirname(__DIR__)) . DIRECTORY_SEPARATOR . 'common.php';
global $resourcesModule, $resourcesConfigsList;
if (empty($resourcesModule)) {
    if (is_a($resourcesModule = xoops_gethandler('module')->getByDirname(basename(dirname(__DIR__))), "XoopsModule")) {
        if (empty($resourcesConfigsList)) {
            $resourcesConfigsList = xoops_gethandler('config')->getConfigsList($resourcesModule->getVar('mid'));
        }
    }
}
xoops_load("XoopsCache");
xoops_load("XoopsLists");
if ($resourcesConfigsList['harvester']) {
    foreach (XoopsLists::getThemesList() as $theme) {
        if ($thememap = XoopsCache::read(basename(dirname(dirname(__DIR__))) . '.theme' . $theme . '.delays')) {
            if (!XoopsCache::read(basename(dirname(dirname(__DIR__))) . '.theme' . $theme)) {
                if ($monthmap = XoopsCache::read(basename(dirname(dirname(__DIR__))) . '.theme' . $theme . '.old')) {
                    foreach ($monthmap as $key => $values) {
                        if (isset($thememap[$key]) && $thememap[$key]['is'] == 'file') {
                            unset($thememap[$key]);
                        } elseif (isset($thememap[$key]) && $thememap[$key]['is'] == 'folder') {
                            unset($thememap[$key]);
                        }
                    }
                    if (count($thememap) > 0) {
                        $thememap = getMapFingering($thememap, $theme, 'theme');
                    } else {
                        $thememap = array();
                    }
Esempio n. 9
0
 /**
  * Constructor
  *
  * @param string  $caption caption
  * @param string  $name    name
  * @param mixed   $value   Pre-selected value (or array of them).
  * @param integer $size    Number or rows. "1" makes a drop-down-list
  */
 public function __construct($caption, $name, $value = null, $size = 1)
 {
     parent::__construct($caption, $name, $value, $size);
     $this->addOptionArray(\XoopsLists::getThemesList());
 }
Esempio n. 10
0
/**
 * Get {@link XoopsThemeForm} for adding/editing fields
 *
 * @param object $field {@link XoopsProfileField} object to get edit form for
 * @param mixed $action URL to submit to - or false for $_SERVER['REQUEST_URI']
 *
 * @return object
 */
function getFieldForm(&$field, $action = false)
{
    if ($action === false) {
        $action = $_SERVER['REQUEST_URI'];
    }
    $title = $field->isNew() ? sprintf(_PROFILE_AM_ADD, _PROFILE_AM_FIELD) : sprintf(_PROFILE_AM_EDIT, _PROFILE_AM_FIELD);
    include_once XOOPS_ROOT_PATH . "/class/xoopsformloader.php";
    $form = new XoopsThemeForm($title, 'form', $action, 'post', true);
    $form->addElement(new XoopsFormText(sprintf(_PROFILE_AM_TITLE, _PROFILE_AM_FIELD), 'field_title', 35, 255, $field->getVar('field_title', 'e')));
    $form->addElement(new XoopsFormTextArea(_PROFILE_AM_DESCRIPTION, 'field_description', $field->getVar('field_description', 'e')));
    if (!$field->isNew()) {
        $fieldcat_handler =& xoops_getmodulehandler('fieldcategory');
        $fieldcat =& $fieldcat_handler->get($field->getVar('fieldid'));
        $fieldcatid = $fieldcat->getVar('catid');
    } else {
        $fieldcatid = 0;
    }
    $category_handler =& xoops_getmodulehandler('category');
    $cat_select = new XoopsFormSelect(_PROFILE_AM_CATEGORY, 'field_category', $fieldcatid);
    $cat_select->addOption(0, _PROFILE_AM_DEFAULT);
    $cat_select->addOptionArray($category_handler->getList());
    $form->addElement($cat_select);
    if ($field->getVar('field_config') || $field->isNew()) {
        if (!$field->isNew()) {
            $form->addElement(new XoopsFormLabel(sprintf(_PROFILE_AM_NAME, _PROFILE_AM_FIELD), $field->getVar('field_name')));
            $form->addElement(new XoopsFormHidden('id', $field->getVar('fieldid')));
        } else {
            $form->addElement(new XoopsFormText(sprintf(_PROFILE_AM_NAME, _PROFILE_AM_FIELD), 'field_name', 35, 255, $field->getVar('field_name', 'e')));
        }
        //autotext and theme left out of this one as fields of that type should never be changed (valid assumption, I think)
        $fieldtypes = array('checkbox' => _PROFILE_AM_CHECKBOX, 'date' => _PROFILE_AM_DATE, 'datetime' => _PROFILE_AM_DATETIME, 'group' => _PROFILE_AM_GROUP, 'group_multi' => _PROFILE_AM_GROUPMULTI, 'language' => _PROFILE_AM_LANGUAGE, 'radio' => _PROFILE_AM_RADIO, 'select' => _PROFILE_AM_SELECT, 'select_multi' => _PROFILE_AM_SELECTMULTI, 'textarea' => _PROFILE_AM_TEXTAREA, 'dhtml' => _PROFILE_AM_DHTMLTEXTAREA, 'textbox' => _PROFILE_AM_TEXTBOX, 'timezone' => _PROFILE_AM_TIMEZONE, 'yesno' => _PROFILE_AM_YESNO);
        $element_select = new XoopsFormSelect(_PROFILE_AM_TYPE, 'field_type', $field->getVar('field_type', 'e'));
        $element_select->addOptionArray($fieldtypes);
        //$form->addElement($type_select);
        $form->addElement($element_select);
        switch ($field->getVar('field_type')) {
            case "textbox":
                /*
                $valuetypes = array(XOBJ_DTYPE_ARRAY => _PROFILE_AM_ARRAY,
                            XOBJ_DTYPE_EMAIL => _PROFILE_AM_EMAIL,
                            XOBJ_DTYPE_INT => _PROFILE_AM_INT,
                            XOBJ_DTYPE_TXTAREA => _PROFILE_AM_TXTAREA,
                            XOBJ_DTYPE_TXTBOX => _PROFILE_AM_TXTBOX,
                            XOBJ_DTYPE_URL => _PROFILE_AM_URL,
                            XOBJ_DTYPE_OTHER => _PROFILE_AM_OTHER);
                $type_select = new XoopsFormSelect(_PROFILE_AM_VALUETYPE, 'field_valuetype', $field->getVar('field_valuetype', 'e'));
                $type_select->addOptionArray($valuetypes);
                $form->addElement($type_select);
                break;
                */
            /*
            $valuetypes = array(XOBJ_DTYPE_ARRAY => _PROFILE_AM_ARRAY,
                        XOBJ_DTYPE_EMAIL => _PROFILE_AM_EMAIL,
                        XOBJ_DTYPE_INT => _PROFILE_AM_INT,
                        XOBJ_DTYPE_TXTAREA => _PROFILE_AM_TXTAREA,
                        XOBJ_DTYPE_TXTBOX => _PROFILE_AM_TXTBOX,
                        XOBJ_DTYPE_URL => _PROFILE_AM_URL,
                        XOBJ_DTYPE_OTHER => _PROFILE_AM_OTHER);
            $type_select = new XoopsFormSelect(_PROFILE_AM_VALUETYPE, 'field_valuetype', $field->getVar('field_valuetype', 'e'));
            $type_select->addOptionArray($valuetypes);
            $form->addElement($type_select);
            break;
            */
            case "select":
            case "radio":
                $valuetypes = array(XOBJ_DTYPE_ARRAY => _PROFILE_AM_ARRAY, XOBJ_DTYPE_EMAIL => _PROFILE_AM_EMAIL, XOBJ_DTYPE_INT => _PROFILE_AM_INT, XOBJ_DTYPE_TXTAREA => _PROFILE_AM_TXTAREA, XOBJ_DTYPE_TXTBOX => _PROFILE_AM_TXTBOX, XOBJ_DTYPE_URL => _PROFILE_AM_URL, XOBJ_DTYPE_OTHER => _PROFILE_AM_OTHER);
                $type_select = new XoopsFormSelect(_PROFILE_AM_VALUETYPE, 'field_valuetype', $field->getVar('field_valuetype', 'e'));
                $type_select->addOptionArray($valuetypes);
                $form->addElement($type_select);
                break;
        }
        //$form->addElement(new XoopsFormRadioYN(_PROFILE_AM_NOTNULL, 'field_notnull', $field->getVar('field_notnull', 'e')));
        if ($field->getVar('field_type') == "select" || $field->getVar('field_type') == "select_multi" || $field->getVar('field_type') == "radio" || $field->getVar('field_type') == "checkbox") {
            if (count($field->getVar('field_options')) > 0) {
                $remove_options = new XoopsFormCheckBox(_PROFILE_AM_REMOVEOPTIONS, 'removeOptions');
                $options = $field->getVar('field_options');
                asort($options);
                $remove_options->addOptionArray($options);
                $form->addElement($remove_options);
            }
            $option_tray = new XoopsFormElementTray(_PROFILE_AM_ADDOPTION);
            $option_tray->addElement(new XoopsFormText(_PROFILE_AM_KEY, 'addOption[key]', 15, 35));
            $option_tray->addElement(new XoopsFormText(_PROFILE_AM_VALUE, 'addOption[value]', 35, 255));
            $form->addElement($option_tray);
        }
    }
    if ($field->getVar('field_edit')) {
        switch ($field->getVar('field_type')) {
            case "textbox":
                //proceed to next cases
            //proceed to next cases
            case "textarea":
            case "dhtml":
                $form->addElement(new XoopsFormText(_PROFILE_AM_MAXLENGTH, 'field_maxlength', 35, 35, $field->getVar('field_maxlength', 'e')));
                $form->addElement(new XoopsFormTextArea(_PROFILE_AM_DEFAULT, 'field_default', $field->getVar('field_default', 'e')));
                break;
            case "checkbox":
            case "select_multi":
                $def_value = $field->getVar('field_default', 'e') != null ? unserialize($field->getVar('field_default', 'n')) : null;
                $element = new XoopsFormSelect(_PROFILE_AM_DEFAULT, 'field_default', $def_value, 8, true);
                $options = $field->getVar('field_options');
                asort($options);
                $element->addOptionArray($options);
                $form->addElement($element);
                break;
            case "select":
            case "radio":
                $def_value = $field->getVar('field_default', 'e') != null ? $field->getVar('field_default') : null;
                $element = new XoopsFormSelect(_PROFILE_AM_DEFAULT, 'field_default', $def_value);
                $options = $field->getVar('field_options');
                asort($options);
                $element->addOptionArray($options);
                $form->addElement($element);
                break;
            case "date":
                $form->addElement(new XoopsFormTextDateSelect(_PROFILE_AM_DEFAULT, 'field_default', 15, $field->getVar('field_default', 'e')));
                break;
            case "datetime":
                $form->addElement(new XoopsFormDateTime(_PROFILE_AM_DEFAULT, 'field_default', 15, $field->getVar('field_default', 'e')));
                break;
            case "yesno":
                $form->addElement(new XoopsFormRadioYN(_PROFILE_AM_DEFAULT, 'field_default', $field->getVar('field_default', 'e')));
                break;
            case "timezone":
                $form->addElement(new XoopsFormSelectTimezone(_PROFILE_AM_DEFAULT, 'field_default', $field->getVar('field_default', 'e')));
                break;
            case "language":
                $form->addElement(new XoopsFormSelectLang(_PROFILE_AM_DEFAULT, 'field_default', $field->getVar('field_default', 'e')));
                break;
            case "group":
                $form->addElement(new XoopsFormSelectGroup(_PROFILE_AM_DEFAULT, 'field_default', true, $field->getVar('field_default', 'e')));
                break;
            case "group_multi":
                $form->addElement(new XoopsFormSelectGroup(_PROFILE_AM_DEFAULT, 'field_default', true, $field->getVar('field_default', 'e'), 5, true));
                break;
            case "theme":
                $element = new XoopsFormSelect(_PROFILE_AM_DEFAULT, 'field_default', $field->getVar('field_default', 'e'));
                $element->addOption("0", _SITEDEFAULT);
                $theme_list = XoopsLists::getThemesList();
                foreach ($theme_list as $key => $val) {
                    if (!in_array($key, $GLOBALS['xoopsConfig']['theme_set_allowed'])) {
                        continue;
                    }
                    $element->addOption($key, $val);
                }
                $form->addElement($element);
                //$form->addElement(new XoopsFormSelectTheme(_PROFILE_AM_DEFAULT, 'field_default', $field->getVar('field_default', 'e')));
                break;
            case "autotext":
                $form->addElement(new XoopsFormTextArea(_PROFILE_AM_DEFAULT, 'field_default', $field->getVar('field_default', 'e')));
                break;
        }
    }
    $groupperm_handler =& xoops_gethandler('groupperm');
    $searchable_types = array('textbox', 'select', 'radio', 'yesno', 'date', 'datetime', 'timezone', 'language');
    if (in_array($field->getVar('field_type'), $searchable_types)) {
        $search_groups = $groupperm_handler->getGroupIds('profile_search', $field->getVar('fieldid'), $GLOBALS['xoopsModule']->getVar('mid'));
        $form->addElement(new XoopsFormSelectGroup(_PROFILE_AM_PROF_SEARCH, 'profile_search', true, $search_groups, 5, true));
    }
    if ($field->getVar('field_show') || $field->getVar('field_edit')) {
        //$form->addElement(new XoopsFormText(_PROFILE_AM_FIELD." "._PROFILE_AM_WEIGHT, 'field_weight', 35, 35, $field->getVar('field_weight', 'e')));
        if (!$field->isNew()) {
            //Load groups
            $show_groups = $groupperm_handler->getGroupIds('profile_show', $field->getVar('fieldid'), $GLOBALS['xoopsModule']->getVar('mid'));
            $editable_groups = $groupperm_handler->getGroupIds('profile_edit', $field->getVar('fieldid'), $GLOBALS['xoopsModule']->getVar('mid'));
            $visible_groups = $groupperm_handler->getGroupIds('profile_visible', $field->getVar('fieldid'), $GLOBALS['xoopsModule']->getVar('mid'));
        } else {
            $visible_groups = array();
            $show_groups = array();
            $editable_groups = array();
        }
        if ($field->getVar('field_show')) {
            //            Leave out categories for now
            //            $cat_select = new XoopsFormSelect(_PROFILE_AM_CATEGORY, 'catid', $field->getVar('catid'));
            //            $category_handler =& xoops_getmodulehandler('category');
            //            $categories =& $category_handler->getObjects(null, true);
            //            foreach (array_keys($categories) as $i) {
            //                $cat_select->addOption($i, $categories[$i]->getVar('cat_title'));
            //            }
            //            $form->addElement($cat_select);
            $form->addElement(new XoopsFormSelectGroup(_PROFILE_AM_PROF_VISIBLE_ON, 'profile_show', false, $show_groups, 5, true));
            $form->addElement(new XoopsFormSelectGroup(_PROFILE_AM_PROF_VISIBLE_FOR, 'profile_visible', true, $visible_groups, 5, true));
        }
        if ($field->getVar('field_edit')) {
            $form->addElement(new XoopsFormSelectGroup(_PROFILE_AM_PROF_EDITABLE, 'profile_edit', false, $editable_groups, 5, true));
            $form->addElement(new XoopsFormRadioYN(_PROFILE_AM_REQUIRED, 'field_required', $field->getVar('field_required', 'e')));
            $form->addElement(new XoopsFormRadioYN(_PROFILE_AM_PROF_REGISTER, 'field_register', $field->getVar('field_register', 'e')));
        }
    }
    $form->addElement(new XoopsFormHidden('op', 'save'));
    $form->addElement(new XoopsFormButton('', 'submit', _SUBMIT, 'submit'));
    return $form;
}