コード例 #1
0
ファイル: Admin.php プロジェクト: ming-hai/XoopsCore
 /**
  * Render about page
  *
  * @param bool $logo_xoops show logo
  *
  * @return bool|mixed|string
  */
 public function renderAbout($logo_xoops = true)
 {
     $xoops = \Xoops::getInstance();
     $date = explode('/', $this->module->getInfo('release_date'));
     $author = explode(',', $this->module->getInfo('author'));
     $nickname = explode(',', $this->module->getInfo('nickname'));
     $release_date = \XoopsLocale::formatTimestamp(mktime(0, 0, 0, $date[1], $date[2], $date[0]), 's');
     $author_list = '';
     foreach (array_keys($author) as $i) {
         $author_list .= $author[$i];
         if (isset($nickname[$i]) && $nickname[$i] != '') {
             $author_list .= " (" . $nickname[$i] . "), ";
         } else {
             $author_list .= ", ";
         }
     }
     $changelog = '';
     $language = $xoops->getConfig('locale');
     if (!is_file(\XoopsBaseConfig::get('root-path') . "/modules/" . $this->module->getVar("dirname") . "/locale/" . $language . "/changelog.txt")) {
         $language = 'en_US';
     }
     $file = \XoopsBaseConfig::get('root-path') . "/modules/" . $this->module->getVar("dirname") . "/locale/" . $language . "/changelog.txt";
     if (is_readable($file)) {
         $changelog = utf8_encode(implode("<br />", file($file))) . "\n";
     } else {
         $file = \XoopsBaseConfig::get('root-path') . "/modules/" . $this->module->getVar("dirname") . "/docs/changelog.txt";
         if (is_readable($file)) {
             $changelog = utf8_encode(implode("<br />", file($file))) . "\n";
         }
     }
     $author_list = substr($author_list, 0, -2);
     $this->module->setInfo('release_date', $release_date);
     $this->module->setInfo('author_list', $author_list);
     if (is_array($this->module->getInfo('paypal'))) {
         $this->module->setInfo('paypal', $this->module->getInfo('paypal'));
     }
     $this->module->setInfo('changelog', $changelog);
     $xoops->tpl()->assign('module', $this->module);
     $this->addInfoBox(\XoopsLocale::MODULE_INFORMATION, 'info', 'id="xo-about"');
     $this->addInfoBoxLine(\XoopsLocale::C_DESCRIPTION . ' ' . $this->module->getInfo("description"), 'info');
     $this->addInfoBoxLine(\XoopsLocale::C_UPDATE_DATE . ' <span class="bold">' . \XoopsLocale::formatTimestamp($this->module->getVar("last_update"), "m") . '</span>', 'info');
     $this->addInfoBoxLine(\XoopsLocale::C_WEBSITE . ' <a class="xo-tooltip" href="http://' . $this->module->getInfo("module_website_url") . '" rel="external" title="' . $this->module->getInfo("module_website_name") . ' - ' . $this->module->getInfo("module_website_url") . '">' . $this->module->getInfo("module_website_name") . '</a>', 'info');
     $xoops->tpl()->assign('xoops_logo', $logo_xoops);
     $xoops->tpl()->assign('xo_admin_box', $this->itemInfoBox);
     return $xoops->tpl()->fetch($this->getTplPath('about'));
 }
コード例 #2
0
ファイル: module.php プロジェクト: redmexico/XoopsCore
 /**
  * installconfigs
  *
  * @param XoopsModule $module module being installed
  *
  * @return void
  */
 public function installConfigs(XoopsModule $module)
 {
     $xoops = Xoops::getInstance();
     // now reinsert them with the new settings
     $configs = $module->getInfo('config');
     if (!is_array($configs)) {
         $configs = array();
     }
     XoopsPreload::getInstance()->triggerEvent('onModuleUpdateConfigs', array($module, &$configs));
     if (is_array($configs) && count($configs) > 0) {
         $this->trace[] = SystemLocale::MANAGING_PREFERENCES;
         $config_handler = $xoops->getHandlerConfig();
         $order = 0;
         foreach ($configs as $config) {
             // only insert ones that have been deleted previously with success
             if (!in_array($config['name'], $this->config_delng)) {
                 $confobj = $config_handler->createConfig();
                 $confobj->setVar('conf_modid', $module->getVar('mid'));
                 $confobj->setVar('conf_catid', 0);
                 $confobj->setVar('conf_name', $config['name']);
                 $confobj->setVar('conf_title', $config['title']);
                 $confobj->setVar('conf_desc', $config['description']);
                 $confobj->setVar('conf_formtype', $config['formtype']);
                 $confobj->setVar('conf_valuetype', $config['valuetype']);
                 if (isset($this->config_old[$config['name']]['value']) && $this->config_old[$config['name']]['formtype'] == $config['formtype'] && $this->config_old[$config['name']]['valuetype'] == $config['valuetype']) {
                     // preserver the old value if any
                     // form type and value type must be the same
                     $confobj->setVar('conf_value', $this->config_old[$config['name']]['value']);
                 } else {
                     $confobj->setConfValueForInput($config['default']);
                     //$confobj->setVar('conf_value', $config['default']);
                 }
                 $confobj->setVar('conf_order', $order);
                 $confop_msgs = '';
                 if (isset($config['options']) && is_array($config['options'])) {
                     foreach ($config['options'] as $key => $value) {
                         $confop = $config_handler->createConfigOption();
                         $confop->setVar('confop_name', $key);
                         $confop->setVar('confop_value', $value);
                         $confobj->setConfOptions($confop);
                         $confop_msgs .= '<br />&nbsp;&nbsp;&nbsp;&nbsp;';
                         $confop_msgs .= SystemLocale::S_CONFIG_OPTION_ADDED;
                         $confop_msgs .= '&nbsp;';
                         $confop_msgs .= XoopsLocale::C_NAME;
                         $confop_msgs .= ' <strong>' . Xoops_Locale::translate($key, $module->getVar('dirname')) . '</strong> ';
                         $confop_msgs .= XoopsLocale::C_VALUE . ' <strong>' . $value . '</strong> ';
                         unset($confop);
                     }
                 }
                 ++$order;
                 if (false != $config_handler->insertConfig($confobj)) {
                     $this->trace[]['sub'] = sprintf(SystemLocale::SF_CONFIG_ADDED, "<strong>" . $config['name'] . "</strong>") . $confop_msgs;
                 } else {
                     $this->trace[]['sub'] = '<span class="red">' . sprintf(SystemLocale::EF_CONFIG_NOT_ADDED, "<strong>" . $config['name'] . "</strong>") . '</span>';
                 }
                 unset($confobj);
             }
         }
         unset($configs);
     }
 }
コード例 #3
0
ファイル: preferences.php プロジェクト: ming-hai/XoopsCore
 /**
  * getForm
  *
  * @param array       &$obj array of config objects
  * @param XoopsModule $mod module
  *
  * @return void
  */
 public function getForm(&$obj, XoopsModule $mod)
 {
     $xoops = Xoops::getInstance();
     $config_handler = $xoops->getHandlerConfig();
     parent::__construct('', 'pref_form', 'admin.php?fct=preferences', 'post', true);
     if ($mod->getVar('dirname') !== 'system') {
         $xoops->loadLanguage('modinfo', $mod->getVar('dirname'));
     }
     $xoops->loadLocale($mod->getVar('dirname'));
     $configs = $mod->getInfo('config');
     $configNames = array();
     foreach (array_keys($configs) as $i) {
         $configNames[$configs[$i]['name']] =& $configs[$i];
     }
     $configCats = $mod->getInfo('configcat');
     if (!$configCats) {
         $configCats = array('default' => array('name' => SystemLocale::OTHER_SETTINGS, 'description' => ''));
     }
     if (!in_array('default', array_keys($configCats))) {
         $configCats['default'] = array('name' => SystemLocale::OTHER_SETTINGS, 'description' => '');
     }
     foreach (array_keys($configNames) as $name) {
         if (!isset($configNames[$name]['category'])) {
             $configNames[$name]['category'] = 'default';
         }
     }
     $tabTray = new Xoops\Form\TabTray('', 'pref_tabtay');
     $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']));
         }
     }
     $xoops->preload()->triggerEvent('onSystemPreferencesForm', array($mod));
     if (!empty($_REQUEST["redirect"])) {
         $myts = \Xoops\Core\Text\Sanitizer::getInstance();
         $this->addElement(new Xoops\Form\Hidden('redirect', $myts->htmlSpecialChars($_REQUEST["redirect"])));
     } elseif ($mod->getInfo('adminindex')) {
         $this->addElement(new Xoops\Form\Hidden('redirect', \XoopsBaseConfig::get('url') . '/modules/' . $mod->getVar('dirname') . '/' . $mod->getInfo('adminindex')));
     }
     $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 = \Xoops\Core\Text\Sanitizer::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_editor':
                 $ele = new Xoops\Form\Select($title, $obj[$i]->getVar('conf_name'), $obj[$i]->getConfValueForOutput());
                 \Xoops\Core\Lists\Editor::setOptionsArray($ele);
                 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 = \Xoops\Core\Text\Sanitizer::getInstance();
                 $ele = new Xoops\Form\Password($title, $obj[$i]->getVar('conf_name'), 32, 255, $myts->htmlSpecialChars($obj[$i]->getConfValueForOutput()));
                 break;
             case 'color':
                 $myts = \Xoops\Core\Text\Sanitizer::getInstance();
                 $ele = new Xoops\Form\ColorPicker($title, $obj[$i]->getVar('conf_name'), $myts->htmlSpecialChars($obj[$i]->getConfValueForOutput()));
                 break;
             case 'hidden':
                 $myts = \Xoops\Core\Text\Sanitizer::getInstance();
                 $ele = new Xoops\Form\Hidden($obj[$i]->getVar('conf_name'), $myts->htmlSpecialChars($obj[$i]->getConfValueForOutput()));
                 break;
             case 'textbox':
             default:
                 $myts = \Xoops\Core\Text\Sanitizer::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\Button('', 'button', XoopsLocale::A_SUBMIT, 'submit'));
 }