Esempio n. 1
0
 function writeConfigFile(&$params)
 {
     global $_DOCMAN;
     $theme = strtolower(str_replace(" ", "_", $this->elementName()));
     $path = $_DOCMAN->getPath('themes', $theme);
     require $_DOCMAN->getPath('classes', 'config');
     $config = new DOCMAN_Config('themeConfig', $path . "themeConfig.php");
     $config->_config = $params;
     return $config->saveConfig();
 }
Esempio n. 2
0
function saveTheme()
{
    DOCMAN_token::check() or die('Invalid Token');
    global $_DOCMAN, $task;
    $database = JFactory::getDBO();
    $mainframe = JFactory::getApplication();
    $id = JRequest::getVar('id', '');
    $params = JRequest::getVar('params', array(), 'post', 'array');
    if (!file_exists($_DOCMAN->getPath('themes') . DS . $id)) {
        echo "<script> alert('Theme not found'); window.history.go(-1);</script>\n";
        exit;
    }
    if (!$id) {
        throw new Exception('Theme name not found');
    }
    $path = $_DOCMAN->getPath('themes', $id);
    require_once $_DOCMAN->getPath('classes', 'config');
    $config = new DOCMAN_Config("themeConfig", $path . "themeConfig.php");
    foreach ($params as $key => $value) {
        $config->setCfg($key, $value, true);
    }
    // (un)publish theme
    $published_theme = $_POST['published'] ? $id : 'default';
    $_DOCMAN->setCfg('icon_theme', $published_theme);
    $_DOCMAN->saveConfig();
    if ($config->saveConfig()) {
        if ($task == 'save') {
            $url = 'index.php?option=com_docman&section=themes';
        } else {
            // $task = 'apply'
            $url = 'index.php?option=com_docman&section=themes&task=edit&cid[0]=' . $id;
        }
        $mainframe->redirect($url, _DML_SAVED_CHANGES);
    } else {
        $mainframe->redirect("index.php?option=com_docman&section=themes", _DML_CONFIG_ERROR);
    }
}
Esempio n. 3
0
function saveTheme()
{
    DOCMAN_token::check() or die('Invalid Token');
    global $_DOCMAN, $database, $task;
    $id = mosGetParam($_POST, 'id', '');
    $params = mosGetParam($_POST, 'params', '');
    if (!file_exists($_DOCMAN->getPath('themes') . DS . $id)) {
        echo "<script> alert('Theme not found'); window.history.go(-1);</script>\n";
        exit;
    }
    $path = $_DOCMAN->getPath('themes', $id);
    require $_DOCMAN->getPath('classes', 'config');
    $config = new DOCMAN_Config("themeConfig", $path . "themeConfig.php");
    foreach ($params as $key => $value) {
        $config->setCfg($key, $value, true);
    }
    // (un)publish theme
    $published_theme = $_POST['published'] ? $id : 'default';
    $_DOCMAN->setCfg('icon_theme', $published_theme);
    $_DOCMAN->saveConfig();
    if ($config->saveConfig()) {
        if ($task == 'save') {
            $url = 'index2.php?option=com_docman&section=themes';
        } else {
            // $task = 'apply'
            $url = 'index2.php?option=com_docman&section=themes&task=edit&cid[0]=' . $id;
        }
        mosRedirect($url, _DML_SAVED_CHANGES);
    } else {
        mosRedirect("index2.php?option=com_docman&section=themes", _DML_CONFIG_ERROR);
    }
}