public function setValue($value)
 {
     $value = (int) $value;
     $article = rex_article::get($value);
     if (!$article instanceof rex_article) {
         return rex_i18n::msg('system_setting_' . $this->key . '_invalid');
     }
     rex_config::set('structure', $this->key, $value);
     return true;
 }
 public function setValue($value)
 {
     $value = (int) $value;
     $sql = rex_sql::factory();
     $sql->setQuery('SELECT * FROM ' . rex::getTablePrefix() . 'template WHERE id=' . $value . ' AND active=1');
     if ($sql->getRows() != 1 && $value != 0) {
         return rex_i18n::msg('system_setting_default_template_id_invalid');
     }
     rex_config::set('structure/content', 'default_template_id', $value);
     return true;
 }
Exemple #3
0
 public function testRemoveNamespace()
 {
     rex_config::set('test-ns', 'mykey1', 'myvalA');
     rex_config::set('test-ns', 'mykey2', 'myvalB');
     rex_config::removeNamespace('test-ns');
     $this->assertFalse(rex_config::has('test-ns'), 'removeNamespace() removes the whole namespace');
     $this->assertFalse(rex_config::has('test-ns', 'mykey1'), 'removeNamespace() all keys1');
     $this->assertFalse(rex_config::has('test-ns', 'mykey2'), 'removeNamespace() all keys2');
     $this->assertNull(rex_config::get('test-ns', 'mykey1'), 'removeNamespace() all keys1');
     $this->assertNull(rex_config::get('test-ns', 'mykey2'), 'removeNamespace() all keys2');
 }
Exemple #4
0
 public function asImage()
 {
     if ($this->asImage) {
         return;
     }
     $this->asImage = true;
     $this->image = [];
     $this->image['format'] = strtolower(rex_file::extension($this->getMediapath()));
     $this->image['src'] = false;
     // if mimetype detected and in imagemap -> change format
     if (class_exists('finfo') && ($finfo = new finfo(FILEINFO_MIME_TYPE))) {
         if ($ftype = @$finfo->file($this->image['filepath'])) {
             if (array_key_exists($ftype, $this->mimetypeMap)) {
                 $this->image['format'] = $this->mimetypeMap[$ftype];
             }
         }
     }
     if ($this->image['format'] == 'jpg' || $this->image['format'] == 'jpeg') {
         $this->image['format'] = 'jpeg';
         $this->image['quality'] = rex_config::get('media_manager', 'jpg_quality', 80);
         $this->image['src'] = @imagecreatefromjpeg($this->getMediapath());
     } elseif ($this->image['format'] == 'gif') {
         $this->image['src'] = @imagecreatefromgif($this->getMediapath());
     } elseif ($this->image['format'] == 'wbmp') {
         $this->image['src'] = @imagecreatefromwbmp($this->getMediapath());
     } else {
         $this->image['src'] = @imagecreatefrompng($this->getMediapath());
         imagealphablending($this->image['src'], false);
         imagesavealpha($this->img['src'], true);
         $this->image['format'] = 'png';
     }
     if (!$this->image['src']) {
         $this->setMediapath(rex_path::addon('media_manager', 'media/warning.jpg'));
         $this->asImage();
     } else {
         $this->refreshImageDimensions();
     }
 }
Exemple #5
0
 public static function checkPermissions($ep)
 {
     $AddonPerm = rex_config::get('slice_ui');
     $article = rex_sql::factory();
     // $article->setDebug();
     $articleTable = rex::getTablePrefix() . 'article';
     $article->setTable($articleTable);
     // $article->setDebug();
     $article->setQuery('
   SELECT article.*, template.attributes as template_attributes
   FROM ' . rex::getTablePrefix() . 'article as article
   LEFT JOIN ' . rex::getTablePrefix() . 'template as template ON template.id=article.template_id
   WHERE article.id = ? AND clang_id = ?', array($ep['article_id'], $ep['clang']));
     $ctype = 1;
     if ($c = rex_request('ctype')) {
         $ctype = $c;
     }
     $template_attributes = json_decode($article->getValue('template_attributes'), 1);
     if ($template_attributes === null) {
         $template_attributes = array();
     }
     $AddonPerm['ctypes'] = $AddonPerm['ctypes'][$article->getValue('template_id')];
     if (!rex_template::hasModule($template_attributes, $ep['ctype'], $ep['module_id'])) {
         return false;
     } elseif (!(rex::getUser()->isAdmin() || rex::getUser()->hasPerm('module[' . $ep['module_id'] . ']') || rex::getUser()->hasPerm('module[0]'))) {
         return false;
     }
     if (strpos(rex_get('page', 'string'), 'content/paste') === false) {
         if (!empty($AddonPerm['modules']) && !in_array('all', $AddonPerm['modules']) && !in_array($ep['module_id'], $AddonPerm['modules']) || !empty($AddonPerm['ctypes']) && !in_array('all', $AddonPerm['ctypes']) && !in_array($ep['ctype'], $AddonPerm['ctypes'])) {
             return false;
         }
     }
     return true;
 }
Exemple #6
0
 public static function getDefaultId()
 {
     return rex_config::get('structure/content', 'default_template_id', 1);
 }
Exemple #7
0
 */
use Sprog\Wildcard;
class_alias('\\Sprog\\Wildcard', 'Wildcard');
rex_perm::register('sprog[wildcard]', null, rex_perm::OPTIONS);
if (!rex::isBackend()) {
    \rex_extension::register('OUTPUT_FILTER', '\\Sprog\\Extension::replaceWildcards');
}
if (rex::isBackend() && rex::getUser()) {
    \rex_extension::register('CLANG_ADDED', '\\Sprog\\Extension::clangAdded');
    \rex_extension::register('CLANG_DELETED', '\\Sprog\\Extension::clangDeleted');
    rex_extension::register('PAGES_PREPARED', function () {
        if (rex::getUser()->isAdmin()) {
            if (\rex_be_controller::getCurrentPage() == 'sprog/settings') {
                $func = rex_request('func', 'string');
                if ($func == 'update') {
                    \rex_config::set('sprog', 'wildcard_clang_switch', rex_request('clang_switch', 'bool'));
                }
            }
        }
        if (rex::getUser()->isAdmin() || rex::getUser()->hasPerm('sprog[wildcard]')) {
            $page = \rex_be_controller::getPageObject('sprog/wildcard');
            if (Wildcard::isClangSwitchMode()) {
                $clang_id = str_replace('clang', '', rex_be_controller::getCurrentPagePart(3));
                $page->setSubPath(rex_path::addon('sprog', 'pages/wildcard.clang_switch.php'));
                foreach (\rex_clang::getAll() as $id => $clang) {
                    if (rex::getUser()->getComplexPerm('clang')->hasPerm($id)) {
                        $page->addSubpage((new rex_be_page('clang' . $id, $clang->getName()))->setSubPath(rex_path::addon('sprog', 'pages/wildcard.clang_switch.php'))->setIsActive($id == $clang_id));
                    }
                }
            } else {
                $page->setSubPath(rex_path::addon('sprog', 'pages/wildcard.clang_all.php'));
Exemple #8
0
 /**
  * persists the config-data and truncates the file-cache.
  */
 public static function save()
 {
     // save cache only if changes happened
     if (!self::$changed) {
         return;
     }
     // after all no data needs to be deleted or update, so skip save
     if (empty(self::$deletedData) && empty(self::$changedData)) {
         return;
     }
     // delete cache-file; will be regenerated on next request
     rex_file::delete(REX_CONFIG_FILE_CACHE);
     // save all data to the db
     self::saveToDb();
     self::$changed = false;
 }
Exemple #9
0
 public static function isClangSwitchMode()
 {
     return \rex_config::get('sprog', 'wildcard_clang_switch', '1') == 1 ? true : false;
 }
Exemple #10
0
 /**
  * @see rex_config::remove()
  */
 public static function removeConfig($key)
 {
     return rex_config::remove(self::CONFIG_NAMESPACE, $key);
 }
Exemple #11
0
 public function saveNextTime($nexttime = null)
 {
     if ($nexttime === null) {
         $nexttime = $this->getMinNextTime();
     }
     if ($nexttime === null) {
         $nexttime = 0;
     } else {
         $nexttime = max(1, $nexttime);
     }
     rex_config::set('cronjob', 'nexttime', $nexttime);
     return true;
 }
Exemple #12
0
<?php

$Config = rex_config::get('slice_ui');
if (empty($_SESSION['slice_ui'])) {
    slice_ui::emptyClipboard(1);
}
rex_extension::register('PAGE_BODY_ATTR', function ($ep) {
    $Subject = $ep->getSubject();
    if ($_SESSION['slice_ui']['slice_id'] != 0) {
        $Subject['class'][] = 'copy';
    }
    return $Subject;
});
if (rex::isBackend() && is_object(rex::getUser())) {
    rex_perm::register('copy[]');
    rex_perm::register('slice_ui[]', null, rex_perm::OPTIONS);
    rex_perm::register('slice_ui[settings]', null, rex_perm::OPTIONS);
}
if (rex::isBackend()) {
    rex_view::addCssFile($this->getAssetsUrl('slice_ui.css'));
    rex_view::addCssFile($this->getAssetsUrl('jquery-ui.datepicker.css'));
    rex_view::addJsFile($this->getAssetsUrl('slice_ui.js'));
    rex_view::addJsFile($this->getAssetsUrl('jquery-ui.datepicker.js'));
}
if (rex_post('update_slice_status') != 1 && rex_get('function') == '') {
    rex_extension::register('SLICE_SHOW', 'slice_ui::extendBackendSlices');
}
rex_extension::register('SLICE_SHOW', 'slice_ui::isActive');
if (strpos(rex_request('page'), 'content/emptyclipboard') !== false) {
    slice_ui::emptyClipboard();
}
Exemple #13
0
<?php

/** @var rex_addon $this */
if (rex_string::versionCompare($this->getVersion(), '2.0.1', '<') && rex_config::has('install')) {
    rex_file::putCache($this->getDataPath('config.json'), rex_config::get('install'));
    rex_config::removeNamespace('install');
}
Exemple #14
0
 * This file is part of the Sprog package.
 *
 * @author (c) Thomas Blum <*****@*****.**>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */
namespace Sprog;

$content = '';
$func = rex_request('func', 'string');
if ($func == 'update') {
    // clang_switch wird in der boot.php neu gesetzt
    echo \rex_view::info($this->i18n('settings_config_saved'));
    \rex_config::set('sprog', 'wildcard_open_tag', rex_request('open_tag', 'string'));
    \rex_config::set('sprog', 'wildcard_close_tag', rex_request('close_tag', 'string'));
}
$content .= '
    <fieldset>
        <input type="hidden" name="func" value="update" />
';
$formElements = [];
$n = [];
$n['label'] = '<label for="wildcard-open-tag">' . $this->i18n('settings_wildcard_open_tag') . '</label>';
$n['field'] = '<input class="form-control" type="text" id="wildcard-open-tag" name="open_tag" value="' . htmlspecialchars(Wildcard::getOpenTag()) . '" />';
$formElements[] = $n;
$n = [];
$n['label'] = '<label for="wildcard-close-tag">' . $this->i18n('settings_wildcard_close_tag') . '</label>';
$n['field'] = '<input class="form-control" type="text" id="wildcard-close-tag" name="close_tag" value="' . htmlspecialchars(Wildcard::getCloseTag()) . '" />';
$formElements[] = $n;
$fragment = new \rex_fragment();
Exemple #15
0
 /**
  * Uninstalls a package.
  *
  * @param bool $installDump When TRUE, the sql dump will be importet
  *
  * @throws rex_functional_exception
  *
  * @return bool TRUE on success, FALSE on error
  */
 public function uninstall($installDump = true)
 {
     $isActivated = $this->package->isAvailable();
     if ($isActivated && !$this->deactivate()) {
         return false;
     }
     try {
         $this->package->setProperty('install', false);
         // include uninstall.php
         if (is_readable($this->package->getPath(rex_package::FILE_UNINSTALL))) {
             if (!$isActivated) {
                 rex_i18n::addDirectory($this->package->getPath('lang'));
             }
             $this->package->includeFile(rex_package::FILE_UNINSTALL);
             if (($instmsg = $this->package->getProperty('installmsg', '')) != '') {
                 throw new rex_functional_exception($instmsg);
             }
             if ($this->package->isInstalled()) {
                 throw new rex_functional_exception($this->i18n('no_reason'));
             }
         }
         // import uninstall.sql
         $uninstallSql = $this->package->getPath(rex_package::FILE_UNINSTALL_SQL);
         if ($installDump === true && is_readable($uninstallSql)) {
             rex_sql_util::importDump($uninstallSql);
         }
         // delete assets
         $assets = $this->package->getAssetsPath();
         if (is_dir($assets) && !rex_dir::delete($assets)) {
             throw new rex_functional_exception($this->i18n('install_cant_delete_files'));
         }
         rex_config::removeNamespace($this->package->getPackageId());
         $this->saveConfig();
         $this->message = $this->i18n('uninstalled', $this->package->getName());
         return true;
     } catch (rex_functional_exception $e) {
         $this->message = $e->getMessage();
     } catch (rex_sql_exception $e) {
         $this->message = 'SQL error: ' . $e->getMessage();
     }
     $this->package->setProperty('install', true);
     if ($isActivated) {
         $this->package->setProperty('status', true);
     }
     $this->saveConfig();
     $this->message = $this->i18n('no_uninstall', $this->package->getName()) . '<br />' . $this->message;
     return false;
 }
Exemple #16
0
 /**
  * {@inheritdoc}
  */
 public function removeConfig($key)
 {
     return rex_config::remove($this->getPackageId(), $key);
 }
Exemple #17
0
 protected function getImageSource()
 {
     ob_start();
     if ($this->image['format'] == 'jpg' || $this->image['format'] == 'jpeg') {
         $this->image['quality'] = rex_config::get('media_manager', 'jpg_quality', 80);
         imagejpeg($this->image['src'], null, $this->image['quality']);
     } elseif ($this->image['format'] == 'png') {
         imagepng($this->image['src']);
     } elseif ($this->image['format'] == 'gif') {
         imagegif($this->image['src']);
     } elseif ($this->image['format'] == 'wbmp') {
         imagewbmp($this->image['src']);
     }
     $src = ob_get_contents();
     ob_end_clean();
     return $src;
 }