Пример #1
0
 /**
  * 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;
 }
Пример #2
0
 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'));
 }
Пример #3
0
 /**
  * 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;
 }
Пример #4
0
 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);
 }
Пример #5
0
 /**
  * Get configs from the database
  *
  * @param  object $criteria  {@link CriteriaElement}
  * @param  bool   $id_as_key return the config's id as key?
  * @return array  Array of {@link XoopsConfigItem} objects
  */
 function getObjects($criteria = null, $id_as_key = false)
 {
     $ret = array();
     $limit = $start = 0;
     $sql = 'SELECT * FROM ' . $this->db->prefix('config');
     if (isset($criteria) && is_subclass_of($criteria, 'criteriaelement')) {
         $sql .= ' ' . $criteria->renderWhere();
         $sql .= ' ORDER BY conf_order ASC';
         $limit = $criteria->getLimit();
         $start = $criteria->getStart();
     }
     $result = $this->db->query($sql, $limit, $start);
     if (!$result) {
         return false;
     }
     while ($myrow = $this->db->fetchArray($result)) {
         $config = new XoopsConfigItem();
         $config->assignVars($myrow);
         if (!$id_as_key) {
             $ret[] =& $config;
         } else {
             $ret[$myrow['conf_id']] =& $config;
         }
         unset($config);
     }
     return $ret;
 }
Пример #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);
}