public function test___construct() { $myId = 'Id'; $parentId = 'parentId'; $rootId = 'rootId'; $item1 = new XoopsConfigItem(); $item1->initVar('Id', XOBJ_DTYPE_INT, 71); $item1->initVar('parentId', XOBJ_DTYPE_INT); $item1->initVar('rootId', XOBJ_DTYPE_INT); $item2 = new XoopsConfigItem(); $item2->initVar('Id', XOBJ_DTYPE_INT, 72); $item2->initVar('parentId', XOBJ_DTYPE_INT, 71); $item2->initVar('rootId', XOBJ_DTYPE_INT); $item3 = new XoopsConfigItem(); $item3->initVar('Id', XOBJ_DTYPE_INT, 73); $item3->initVar('parentId', XOBJ_DTYPE_INT, 72); $item3->initVar('rootId', XOBJ_DTYPE_INT); $objectArr = array($item1, $item2, $item3); $instance = new XoopsObjectTree($objectArr, $myId, $parentId); $this->assertInstanceOf('XoopsObjectTree', $instance); $tree = $instance->getTree(); $this->assertTrue(is_array($tree)); $ret = $instance->getByKey(72); $this->assertEquals(72, $ret->getVar('Id')); }
public function test_deleteConfig() { $instance = new $this->myclass(); $item = new XoopsConfigItem(); $item->setDirty(); $item->setNew(); $item->setVar('conf_title', 'CONFTITLE_DUMMY_FOR_TESTS'); $value = $instance->insertConfig($item); $this->assertTrue(intval($value) > 0); $ret = $instance->deleteConfig($item); $this->assertSame(true, $ret); }
/** * @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); }