Esempio n. 1
0
 public function execute()
 {
     global $I18N;
     $addonkey = rex_request('addonkey', 'string');
     $upload = rex_request('upload', array(array('upload_file', 'bool'), array('oldversion', 'string'), array('redaxo', 'array[string]'), array('description', 'string'), array('status', 'int'), array('replace_assets', 'bool'), array('ignore_tests', 'bool')));
     $file = array();
     $archive = null;
     $file['version'] = $upload['upload_file'] ? OOAddon::getVersion($addonkey) : $upload['oldversion'];
     $file['redaxo_versions'] = $upload['redaxo'];
     $file['description'] = stripslashes($upload['description']);
     $file['status'] = $upload['status'];
     if ($upload['upload_file']) {
         $archive = rex_path::addonCache('install', md5($addonkey . time()) . '.zip');
         $exclude = array();
         if ($upload['replace_assets']) {
             $exclude[] = 'files';
         }
         if ($upload['ignore_tests']) {
             $exclude[] = 'tests';
         }
         rex_install_archive::copyDirToArchive(rex_path::addon($addonkey), $archive, null, $exclude);
         if ($upload['replace_assets']) {
             rex_install_archive::copyDirToArchive(rex_path::addonAssets($addonkey), $archive, $addonkey . '/files');
         }
         $file['checksum'] = md5_file($archive);
     }
     rex_install_webservice::post(rex_install_packages::getPath('?package=' . $addonkey . '&file_id=' . rex_request('file', 'int', 0)), array('file' => $file), $archive);
     if ($archive) {
         rex_file::delete($archive);
     }
     unset($_REQUEST['addonkey']);
     unset($_REQUEST['file']);
     rex_install_packages::deleteCache();
     return $I18N->msg('install_info_addon_uploaded', $addonkey);
 }
Esempio n. 2
0
 public function getArticle($curctype = -1)
 {
     // bc
     if ($this->viasql) {
         return parent::getArticle($curctype);
     }
     $this->ctype = $curctype;
     if (!$this->getSlice && $this->article_id != 0) {
         // ----- start: article caching
         ob_start();
         ob_implicit_flush(0);
         $article_content_file = rex_path::addonCache('structure', $this->article_id . '.' . $this->clang . '.content');
         if (!file_exists($article_content_file)) {
             $generated = rex_content_service::generateArticleContent($this->article_id, $this->clang);
             if ($generated !== true) {
                 // fehlermeldung ausgeben
                 echo $generated;
             }
         }
         if (file_exists($article_content_file)) {
             require $article_content_file;
         }
         // ----- end: article caching
         $CONTENT = ob_get_contents();
         ob_end_clean();
     } else {
         // Inhalt ueber sql generierens
         $CONTENT = parent::getArticle($curctype);
     }
     $CONTENT = rex_extension::registerPoint(new rex_extension_point('ART_CONTENT', $CONTENT, ['ctype' => $curctype, 'article' => $this]));
     return $CONTENT;
 }
Esempio n. 3
0
 /**
  * Prepares a new stream.
  *
  * @param string $path    Virtual path which should describe the content (e.g. "template/1"), only relevant for error messages
  * @param string $content Content which will be included
  *
  * @throws InvalidArgumentException
  *
  * @return string Full path with protocol (e.g. "rex:///template/1")
  */
 public static function factory($path, $content)
 {
     if (!is_string($path) || empty($path)) {
         throw new InvalidArgumentException('Expecting $path to be a string and not empty!');
     }
     if (!is_string($content)) {
         throw new InvalidArgumentException('Expecting $content to be a string!');
     }
     if (null === self::$useRealFiles) {
         self::$useRealFiles = extension_loaded('suhosin') && !preg_match('/(?:^|,)rex(?::|,|$)/', ini_get('suhosin.executor.include.whitelist'));
     }
     if (self::$useRealFiles) {
         $hash = substr(sha1($content), 0, 7);
         $path = rex_path::coreCache('stream/' . $path . '/' . $hash);
         if (!file_exists($path)) {
             rex_file::put($path, $content);
         }
         return $path;
     }
     if (!self::$registered) {
         stream_wrapper_register('rex', __CLASS__);
         self::$registered = true;
     }
     // 3 slashes needed to sidestep some server url include protections
     // example: https://www.strato.de/faq/article/622/Warum-erhalte-ich-über-PHP-die-Fehlermeldung-%22Warning:-main()-…:-include(….).html
     $path = 'rex:///' . $path;
     self::$nextContent[$path] = $content;
     return $path;
 }
Esempio n. 4
0
 public function testAbsoluteConversion()
 {
     $path = rex_path::absolute('c:/abc/../def/./xy');
     $this->assertEquals($this->path('c:/def/xy'), $path, 'resolves .. and .');
     $path = rex_path::absolute('c:\\abc\\..\\def\\.\\xy');
     $this->assertEquals($this->path('c:\\def\\xy'), $path, 'resolves .. and .');
 }
Esempio n. 5
0
 /**
  * Prepares a new stream.
  *
  * @param string $path    Virtual path which should describe the content (e.g. "template/1"), only relevant for error messages
  * @param string $content Content which will be included
  *
  * @throws InvalidArgumentException
  *
  * @return string Full path with protocol (e.g. "rex://template/1")
  */
 public static function factory($path, $content)
 {
     if (!is_string($path) || empty($path)) {
         throw new InvalidArgumentException('Expecting $path to be a string and not empty!');
     }
     if (!is_string($content)) {
         throw new InvalidArgumentException('Expecting $content to be a string!');
     }
     if (null === self::$useRealFiles) {
         self::$useRealFiles = extension_loaded('suhosin') && !preg_match('/(?:^|,)rex(?::|,|$)/', ini_get('suhosin.executor.include.whitelist'));
     }
     if (self::$useRealFiles) {
         $hash = substr(sha1($content), 0, 7);
         $path = rex_path::coreCache('stream/' . $path . '/' . $hash);
         if (!file_exists($path)) {
             rex_file::put($path, $content);
         }
         return $path;
     }
     if (!self::$registered) {
         stream_wrapper_register('rex', __CLASS__);
         self::$registered = true;
     }
     $path = 'rex://' . $path;
     self::$nextContent[$path] = $content;
     return $path;
 }
Esempio n. 6
0
 public function execute()
 {
     if ($this->params['mediapath'] != '') {
         $media_path = rex_path::frontend($this->params['mediapath'] . '/' . rex_media_manager::getMediaFile());
         $this->media->setMediapath($media_path);
     }
 }
Esempio n. 7
0
function focus_setup_metainfo()
{
    global $REX;
    if (!isset($REX['USER'])) {
        return;
    }
    $install_metas = array('med_focuspoint_data' => array('Focuspoint Data', 'med_focuspoint_data', 200, '', 1, '', '', '', ''), 'med_focuspoint_css' => array('Focuspoint CSS', 'med_focuspoint_css', 201, '', 1, '', '', '', ''));
    $db = new rex_sql();
    foreach ($db->getDbArray('SHOW COLUMNS FROM `rex_file` LIKE \'med_focuspoint_%\';') as $column) {
        unset($install_metas[$column['Field']]);
    }
    foreach ($install_metas as $k => $v) {
        $db->setQuery('SELECT `name` FROM `rex_62_params` WHERE `name`=\'' . $k . '\';');
        if ($db->getRows() > 0) {
            // FIELD KNOWN TO METAINFO BUT MISSING IN ARTICLE..
            $db->setQuery('ALTER TABLE `rex_file` ADD `' . $k . '` TEXT NOT NULL;');
            if ($REX['REDAXO']) {
                echo rex_info('Metainfo Feld ' . $k . ' wurde repariert.');
            }
        } else {
            if (!function_exists('a62_add_field')) {
                require_once $REX['INCLUDE_PATH'] . '/addons/metainfo/functions/function_metainfo.inc.php';
            }
            a62_add_field($v[0], $v[1], $v[2], $v[3], $v[4], $v[5], $v[6], $v[7], $v[8]);
            if ($REX['REDAXO']) {
                echo rex_info('Metainfo Feld ' . $k . ' wurde angelegt.');
            }
        }
    }
    rex_file::copy(rex_path::addon("focuspoint", "classes/class.rex_effect_focuspoint_resize.inc.php"), rex_path::addon("image_manager", "classes/effects/class.rex_effect_focuspoint_resize.inc.php"));
}
Esempio n. 8
0
 /**
  * checks permissions of all required filesystem resources.
  *
  * @return array An array of error messages
  */
 public static function checkFilesystem()
 {
     // -------------------------- SCHREIBRECHTE
     $writables = [rex_path::media(), rex_path::assets(), rex_path::cache(), rex_path::data(), rex_path::src()];
     $func = function ($dir) use(&$func) {
         if (!rex_dir::isWritable($dir)) {
             return ['setup_304' => [$dir]];
         }
         $res = [];
         foreach (rex_finder::factory($dir) as $path => $file) {
             if ($file->isDir()) {
                 $res = array_merge_recursive($res, $func($path));
             } elseif (!$file->isWritable()) {
                 $res['setup_305'][] = $path;
             }
         }
         return $res;
     };
     $res = [];
     foreach ($writables as $dir) {
         if (@is_dir($dir)) {
             $res = array_merge_recursive($res, $func($dir));
         } else {
             $res['setup_306'][] = $dir;
         }
     }
     return $res;
 }
 function rex_mailer()
 {
     global $REX;
     $this->From = '*****@*****.**';
     $this->FromName = 'Mailer';
     $this->ConfirmReadingTo = '';
     $this->AdminBcc = '';
     $this->Mailer = 'mail';
     $this->Host = 'localhost';
     $this->Port = 25;
     $this->CharSet = 'utf-8';
     $this->WordWrap = 120;
     $this->Encoding = '8bit';
     $this->Priority = 3;
     $this->SMTPSecure = '';
     $this->SMTPAuth = false;
     $this->Username = '';
     $this->Password = '';
     $settings = rex_path::addonData('phpmailer', 'settings.inc.php');
     if (file_exists($settings)) {
         include $settings;
     }
     $this->PluginDir = $REX['INCLUDE_PATH'] . '/addons/phpmailer/classes/';
     if ($this->AdminBcc !== '') {
         parent::AddBCC($this->AdminBcc);
     }
 }
Esempio n. 10
0
 public function __construct()
 {
     $this->root_dir = rex_path::addon('be_style');
     $this->scss_file = rex_path::addon('be_style', 'assets') . 'styles.scss';
     $this->css_file = rex_path::addon('be_style', 'assets') . 'styles.css';
     $this->formatter = 'scss_formatter_compressed';
     $this->strip_comments = true;
 }
 public function __construct($tableName, $fieldset, $whereCondition, $method = 'post', $debug = false)
 {
     parent::rex_form($tableName, $fieldset, $whereCondition, $method, $debug);
     if (OOAddon::isAvailable('metainfo')) {
         require_once rex_path::addon('metainfo', 'extensions/extension_art_metainfo.inc.php');
         $this->sqlFields = _rex_a62_metainfo_sqlfields(global_settings_metainfo::PREFIX, '');
     }
 }
Esempio n. 12
0
 protected function doAction()
 {
     if (($msg = $this->extractArchiveTo(rex_path::addon($this->addonkey))) !== true) {
         return $msg;
     }
     rex_package_manager::synchronizeWithFileSystem();
     rex_install_packages::addedPackage($this->addonkey);
 }
Esempio n. 13
0
 public function __construct($tableName, $fieldset, $whereCondition, $method = 'post', $debug = false)
 {
     parent::rex_form($tableName, $fieldset, $whereCondition, $method, $debug);
     if (OOAddon::isAvailable('metainfo')) {
         require_once rex_path::addon('metainfo', 'extensions/extension_art_metainfo.inc.php');
         $sqlCols = rex_asd_news_config::getConfig('sql');
         $this->sqlFields = _rex_a62_metainfo_sqlfields('asd_', 'AND (`p`.`restrictions` = "" OR p.`restrictions` LIKE "%|' . $this->getValue($sqlCols['category']) . '|%") ');
     }
 }
 function executeAction()
 {
     $template_name = $this->getElement(2);
     if ($etpl = rex_yform_email_template::getTemplate($template_name)) {
         $mail_to = rex::getErrorEmail();
         if ($this->getElement(3) != false && $this->getElement(3) != '') {
             foreach ($this->params['value_pool']['email'] as $key => $value) {
                 if ($this->getElement(3) == $key) {
                     $mail_to = $value;
                     break;
                 }
             }
         }
         // ---- fix mailto from definition
         if ($this->getElement(4) != false && $this->getElement(4) != '') {
             $mail_to = $this->getElement(4);
         }
         if ($this->params['debug']) {
             echo '<hr /><pre>';
             var_dump($etpl);
             echo '</pre><hr />';
         }
         $etpl = rex_yform_email_template::replaceVars($etpl, $this->params['value_pool']['email']);
         if ($this->params['debug']) {
             echo '<hr /><pre>';
             var_dump($etpl);
             echo '</pre><hr />';
         }
         $etpl['mail_to'] = $mail_to;
         $etpl['mail_to_name'] = $mail_to;
         if ($etpl['attachments'] != '') {
             $f = explode(',', $etpl['attachments']);
             $etpl['attachments'] = array();
             foreach ($f as $v) {
                 $etpl['attachments'][] = array('name' => $v, 'path' => rex_path::media($v));
             }
         } else {
             $etpl['attachments'] = array();
         }
         if (!rex_yform_email_template::sendMail($etpl, $template_name)) {
             if ($this->params['debug']) {
                 echo 'email could be sent';
             }
             return false;
         } else {
             if ($this->params['debug']) {
                 echo 'email sent';
             }
             return true;
         }
     } else {
         if ($this->params['debug']) {
             echo '<p>Template: "' . htmlspecialchars($template_name) . '" not found';
         }
     }
     return false;
 }
Esempio n. 15
0
 public static function defaultLocator()
 {
     $locator = new self();
     $locator->addTestFolder(rex_path::core(self::TESTS_FOLDER));
     foreach (rex_package::getAvailablePackages() as $package) {
         $locator->addTestFolder($package->getPath(self::TESTS_FOLDER));
     }
     return $locator;
 }
Esempio n. 16
0
/**
 * Deletes the cache.
 *
 * @package redaxo\core
 */
function rex_delete_cache()
{
    // close logger, so the logfile can also be deleted
    rex_logger::close();
    $finder = rex_finder::factory(rex_path::cache())->recursive()->childFirst()->ignoreFiles(['.htaccess', '.redaxo'], false)->ignoreSystemStuff(false);
    rex_dir::deleteIterator($finder);
    rex_clang::reset();
    // ----- EXTENSION POINT
    return rex_extension::registerPoint(new rex_extension_point('CACHE_DELETED', rex_i18n::msg('delete_cache_message')));
}
Esempio n. 17
0
 public function execute()
 {
     $config = rex_plugin::get('cronjob', 'article_status')->getProperty('config');
     $from = $config['from'];
     $to = $config['to'];
     $from['before'] = (array) $from['before'];
     $to['before'] = (array) $to['before'];
     $sql = rex_sql::factory();
     // $sql->setDebug();
     $sql->setQuery('
         SELECT  name
         FROM    ' . rex::getTablePrefix() . 'metainfo_field
         WHERE   name="' . $from['field'] . '" OR name="' . $to['field'] . '"
     ');
     $rows = $sql->getRows();
     if ($rows < 2) {
         if ($rows == 0) {
             $msg = 'Metainfo fields "' . $from['field'] . '" and "' . $to['field'] . '" not found';
         } else {
             $field = $sql->getValue('name') == $from['field'] ? $to['field'] : $from['field'];
             $msg = 'Metainfo field "' . $field . '" not found';
         }
         $this->setMessage($msg);
         return false;
     }
     $time = time();
     $sql->setQuery('
         SELECT  id, clang_id, status
         FROM    ' . rex::getTablePrefix() . 'article
         WHERE
             (     ' . $from['field'] . ' > 0
             AND   ' . $from['field'] . ' < ' . $time . '
             AND   status IN (' . implode(',', $from['before']) . ')
             AND   (' . $to['field'] . ' > ' . $time . ' OR ' . $to['field'] . ' = 0 OR ' . $to['field'] . ' = "")
             )
         OR
             (     ' . $to['field'] . ' > 0
             AND   ' . $to['field'] . ' < ' . $time . '
             AND   status IN (' . implode(',', $to['before']) . ')
             )
     ');
     $rows = $sql->getRows();
     include_once rex_path::addon('structure', 'functions/function_rex_structure.php');
     for ($i = 0; $i < $rows; ++$i) {
         if (in_array($sql->getValue('status'), $from['before'])) {
             $status = $from['after'];
         } else {
             $status = $to['after'];
         }
         rex_article_service::articleStatus($sql->getValue('id'), $sql->getValue('clang_id'), $status);
         $sql->next();
     }
     $this->setMessage('Updated articles: ' . $rows);
     return true;
 }
Esempio n. 18
0
 function readFolder($dir)
 {
     if (!is_dir($dir)) {
         rex_dir::copy(rex_path::addon('import_export', 'backup'), rex_path::addonData('import_export', 'backups'));
     }
     $hdl = opendir($dir);
     $folder = array();
     while (false !== ($file = readdir($hdl))) {
         $folder[] = $file;
     }
     return $folder;
 }
Esempio n. 19
0
 public static function getMyPackages()
 {
     if (is_array(self::$myPackages)) {
         return self::$myPackages;
     }
     self::$myPackages = self::getPackages('?only_my=1');
     foreach (self::$myPackages as $key => $addon) {
         if (!is_dir(rex_path::addon($key))) {
             unset(self::$myPackages[$key]);
         }
     }
     return self::$myPackages;
 }
Esempio n. 20
0
 public function log($success, $message)
 {
     $name = $this->name;
     if (!$name) {
         if ($this->cronjob instanceof rex_cronjob) {
             $name = rex::isBackend() ? $this->cronjob->getTypeName() : $this->cronjob->getType();
         } else {
             $name = '[no name]';
         }
     }
     $log = new rex_log_file(rex_path::addonData('cronjob', 'cronjob.log'), 2000000);
     $data = [$success ? 'SUCCESS' : 'ERROR', $this->id ?: '--', $name, strip_tags($message)];
     $log->add($data);
 }
Esempio n. 21
0
 private function backup()
 {
     $content = '<!-- ' . PHP_EOL . date('d.m.Y H:i:s') . PHP_EOL;
     $content .= 'From : ' . $this->From . PHP_EOL;
     $content .= 'To : ' . implode(', ', array_column($this->getToAddresses(), 0)) . PHP_EOL;
     $content .= 'Subject : ' . $this->Subject . PHP_EOL;
     $content .= ' -->' . PHP_EOL;
     $content .= $this->Body;
     $dir = rex_path::addonData('phpmailer', 'mail_backup/' . date('Y') . '/' . date('m'));
     $count = 1;
     $backupFile = $dir . '/' . date('Y-m-d_H_i_s') . '.html';
     while (file_exists($backupFile)) {
         $backupFile = $dir . '/' . date('Y-m-d_H_i_s') . '_' . ++$count . '.html';
     }
     rex_file::put($backupFile, $content);
 }
Esempio n. 22
0
 /**
  * Register rex_autoload in spl autoloader.
  */
 public static function register()
 {
     if (self::$registered) {
         return;
     }
     ini_set('unserialize_callback_func', 'spl_autoload_call');
     if (!self::$composerLoader) {
         self::$composerLoader = (require rex_path::core('vendor/autoload.php'));
         // Unregister Composer Autoloader because we call self::$composerLoader->loadClass() manually
         self::$composerLoader->unregister();
     }
     if (false === spl_autoload_register([__CLASS__, 'autoload'])) {
         throw new Exception(sprintf('Unable to register %s::autoload as an autoloading method.', __CLASS__));
     }
     self::$cacheFile = rex_path::cache('autoload.cache');
     self::loadCache();
     register_shutdown_function([__CLASS__, 'saveCache']);
     self::$registered = true;
 }
Esempio n. 23
0
 public function execute()
 {
     // error_reporting(E_ALL);ini_set("display_errors",1);
     if (!isset(self::$convert_to[$this->params['convert_to']])) {
         $convert_to = self::$convert_to[self::$convert_to_default];
     } else {
         $convert_to = self::$convert_to[$this->params['convert_to']];
     }
     $density = (int) $this->params['density'];
     if (!in_array($density, self::$densities)) {
         $density = self::$density_default;
     }
     $from_path = realpath($this->media->getMediapath());
     $ext = rex_file::extension($from_path);
     if (!$ext) {
         return;
     }
     if (!in_array(strtolower($ext), self::$convert_types)) {
         return;
     }
     $convert_path = self::getConvertPath();
     if ($convert_path == '') {
         return;
     }
     $filename = $this->media->getMediaFilename();
     $filename_wo_ext = substr($filename, 0, strlen($filename) - strlen($ext));
     $to_path = rex_path::addonCache('media_manager', 'media_manager__convert2img_' . md5($this->media->getMediapath()) . '_' . $filename_wo_ext . $convert_to['ext']);
     $cmd = $convert_path . ' -density ' . $density . ' "' . $from_path . '[0]" -colorspace RGB "' . $to_path . '"';
     exec($cmd, $out, $ret);
     if ($ret != 0) {
         return false;
     }
     $image_src = call_user_func($convert_to['createfunc'], $to_path);
     if (!$image_src) {
         return;
     }
     $this->media->setImage($image_src);
     $this->media->refreshImageDimensions();
     $this->media->setFormat($convert_to['ext']);
     $this->media->setMediaFilename($filename);
     $this->media->setHeader('Content-Type', $convert_to['content-type']);
     unlink($to_path);
 }
Esempio n. 24
0
 public function execute()
 {
     include_once rex_path::addon('import_export', 'functions/function_import_export.php');
     include_once rex_path::addon('import_export', 'functions/function_import_folder.php');
     $filename = $this->getParam('filename', self::DEFAULT_FILENAME);
     $filename = str_replace('%REX_SERVER', parse_url(rex::getServer(), PHP_URL_HOST), $filename);
     $filename = str_replace('%REX_VERSION', rex::getVersion(), $filename);
     $filename = strftime($filename);
     $file = $filename;
     $dir = getImportDir() . '/';
     $ext = '.sql';
     if (file_exists($dir . $file . $ext)) {
         $i = 1;
         while (file_exists($dir . $file . '_' . $i . $ext)) {
             ++$i;
         }
         $file = $file . '_' . $i;
     }
     if (rex_a1_export_db($dir . $file . $ext)) {
         $message = $file . $ext . ' created';
         if ($this->sendmail) {
             if (!rex_addon::get('phpmailer')->isAvailable()) {
                 $this->setMessage($message . ', mail not sent (addon "phpmailer" isn\'t activated)');
                 return false;
             }
             $mail = new rex_mailer();
             $mail->AddAddress($this->mailaddress);
             $mail->Subject = rex_i18n::msg('im_export_mail_subject');
             $mail->Body = rex_i18n::msg('im_export_mail_body', rex::getServerName());
             $mail->AddAttachment($dir . $file . $ext, $filename . $ext);
             if ($mail->Send()) {
                 $this->setMessage($message . ', mail sent');
                 return true;
             }
             $this->setMessage($message . ', mail not sent');
             return false;
         }
         $this->setMessage($message);
         return true;
     }
     $this->setMessage($file . $ext . ' not created');
     return false;
 }
Esempio n. 25
0
 public function execute()
 {
     if (!rex::getUser()->isAdmin()) {
         throw new rex_api_exception('You do not have the permission!');
     }
     $addonkey = rex_request('addonkey', 'string');
     $upload = rex_request('upload', [['upload_file', 'bool'], ['oldversion', 'string'], ['redaxo', 'array[string]'], ['description', 'string'], ['status', 'int'], ['replace_assets', 'bool'], ['ignore_tests', 'bool']]);
     $file = [];
     $archive = null;
     $file['version'] = $upload['upload_file'] ? rex_addon::get($addonkey)->getVersion() : $upload['oldversion'];
     $file['redaxo_versions'] = $upload['redaxo'];
     $file['description'] = $upload['description'];
     $file['status'] = $upload['status'];
     try {
         if ($upload['upload_file']) {
             $archive = rex_path::addonCache('install', md5($addonkey . time()) . '.zip');
             $exclude = [];
             if ($upload['replace_assets']) {
                 $exclude[] = 'assets';
             }
             if ($upload['ignore_tests']) {
                 $exclude[] = 'tests';
             }
             rex_install_archive::copyDirToArchive(rex_path::addon($addonkey), $archive, null, $exclude);
             if ($upload['replace_assets']) {
                 rex_install_archive::copyDirToArchive(rex_url::addonAssets($addonkey), $archive, $addonkey . '/assets');
             }
             $file['checksum'] = md5_file($archive);
         }
         rex_install_webservice::post(rex_install_packages::getPath('?package=' . $addonkey . '&file_id=' . rex_request('file', 'int', 0)), ['file' => $file], $archive);
     } catch (rex_functional_exception $e) {
         throw new rex_api_exception($e->getMessage());
     }
     if ($archive) {
         rex_file::delete($archive);
     }
     unset($_REQUEST['addonkey']);
     unset($_REQUEST['file']);
     rex_install_packages::deleteCache();
     return new rex_api_result(true, rex_i18n::msg('install_info_addon_uploaded', $addonkey));
 }
Esempio n. 26
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['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());
         if ($this->image['src']) {
             imagealphablending($this->image['src'], false);
             imagesavealpha($this->image['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();
     }
 }
Esempio n. 27
0
<?php

/**
 * rex5_multiupload Addon.
 * @author Friends Of REDAXO
 * @package redaxo
 * @var rex_addon $this
 */
$addon = rex_addon::get('rex5_multiupload');
$addon->getProperty("php_debug");
if ($addon->getProperty("php_debug")) {
    ini_set('error_reporting', E_ALL);
    ini_set('display_errors', 1);
}
require_once rex_path::addon("rex5_multiupload", "fragments/action.upload.php");
Esempio n. 28
0
 /**
  * Initializes the class.
  *
  * @param mixed $pathprovider A path provider.
  */
 public static function init($pathprovider)
 {
     self::$pathprovider = $pathprovider;
 }
Esempio n. 29
0
 public function getDataPage()
 {
     rex_extension::registerPoint(new rex_extension_point('YFORM_MANAGER_DATA_PAGE', $this));
     // ********************************************* DATA ADD/EDIT/LIST
     $func = rex_request('func', 'string', '');
     $data_id = rex_request('data_id', 'int', '');
     $show_list = true;
     // -------------- rex_yform_manager_filter and sets
     $rex_yform_filter = rex_request('rex_yform_filter', 'array');
     $rex_yform_set = rex_request('rex_yform_set', 'array');
     // -------------- opener - popup for selection
     $popup = false;
     $rex_yform_manager_opener = rex_request('rex_yform_manager_opener', 'array');
     if (count($rex_yform_manager_opener) > 0) {
         if (isset($rex_yform_manager_opener['id']) && $rex_yform_manager_opener['id'] != '') {
             $popup = true;
             // id, field, multiple
         }
     }
     // -------------- filter - popup for selection
     if (count($rex_yform_filter) > 0) {
         $popup = true;
     }
     if (is_bool($p = rex_request('popup', 'bool', null))) {
         $popup = $p;
         $this->setLinkVars(array('popup' => $p ? 1 : 0));
     }
     // SearchObject
     $searchObject = new rex_yform_manager_search($this->table);
     $searchObject->setLinkVars(array("list" => rex_request('list', 'string', '')));
     $searchObject->setLinkVars(array("start" => rex_request('start', 'string', '')));
     $searchObject->setLinkVars(array("sort" => rex_request('sort', 'string', '')));
     $searchObject->setLinkVars(array("sorttype" => rex_request('sorttype', 'string', '')));
     $searchObject->setLinkVars($this->getLinkVars());
     if (count($rex_yform_filter) > 0) {
         foreach ($rex_yform_filter as $k => $v) {
             if (is_array($v)) {
                 foreach ($v as $k2 => $v2) {
                     $searchObject->setLinkVars(array('rex_yform_filter[' . $k . '][' . $k2 . ']' => $v2));
                 }
             } else {
                 $searchObject->setLinkVars(array('rex_yform_filter[' . $k . ']' => $v));
             }
         }
     }
     if (count($rex_yform_set) > 0) {
         foreach ($rex_yform_set as $k => $v) {
             if (is_array($v)) {
                 foreach ($v as $k2 => $v2) {
                     $searchObject->setLinkVars(array('rex_yform_set[' . $k . '][' . $k2 . ']' => $v2));
                 }
             } else {
                 $searchObject->setLinkVars(array('rex_yform_set[' . $k . ']' => $v));
             }
         }
     }
     if (count($rex_yform_manager_opener) > 0) {
         foreach ($rex_yform_manager_opener as $k => $v) {
             $searchObject->setLinkVars(array('rex_yform_manager_opener[' . $k . ']' => $v));
         }
     }
     $searchform = '';
     if ($this->hasDataPageFunction('search')) {
         $searchform = '<div class="rex-addon-output">
                          <h3 class="rex-hl2">' . rex_i18n::msg('yform_manager_search') . '</h3>
                          <div class="rex-addon-content">
                         <div class="yform" id="rex-yform">' . $searchObject->getForm() . '</div>
                       </div>
                       </div>';
     }
     // -------------- DEFAULT - LISTE AUSGEBEN
     $link_vars = '';
     foreach ($this->getLinkVars() as $k => $v) {
         $link_vars .= '&' . urlencode($k) . '=' . urlencode($v);
     }
     echo rex_view::title(rex_i18n::msg('yform_table') . ': ' . rex_i18n::translate($this->table->getName()) . ' <small>[' . $this->table->getTablename() . ']</small>', '');
     echo rex_extension::registerPoint(new rex_extension_point('YFORM_MANAGER_REX_INFO', ''));
     $show_editpage = true;
     $show_editpage = rex_extension::registerPoint(new rex_extension_point('YFORM_MANAGER_DATA_EDIT_FUNC', $show_editpage, ['table' => $this->table, 'link_vars' => $this->getLinkVars()]));
     if ($show_editpage) {
         // -------------- DB FELDER HOLEN
         $field_names = array();
         foreach ($this->table->getValueFields() as $field) {
             $field_names[] = $field->getName();
         }
         // -------------- DB DATA HOLEN
         $data = array();
         if ($data_id != '') {
             $gd = rex_sql::factory();
             $gd->setQuery('select * from ' . $this->table->getTableName() . ' where id=' . $data_id);
             if ($gd->getRows() == 1) {
                 $datas = $gd->getArray();
                 $data = current($datas);
             } else {
                 $data_id = '';
             }
         }
         // -------------- Opener
         foreach ($rex_yform_manager_opener as $k => $v) {
             $link_vars .= '&rex_yform_manager_opener[' . $k . ']=' . urlencode($v);
         }
         // -------------- Searchfields / Searchtext
         $link_vars .= '&' . http_build_query($searchObject->getSearchVars());
         // -------------- FILTER UND SETS PR†FEN
         $em_url_filter = '';
         if (count($rex_yform_filter) > 0) {
             foreach ($rex_yform_filter as $k => $v) {
                 if (!in_array($k, $field_names)) {
                     unset($rex_yform_filter[$k]);
                 }
             }
             $em_url_filter .= '&' . http_build_query(compact('rex_yform_filter'));
         }
         $em_url_set = '';
         if (count($rex_yform_set) > 0) {
             foreach ($rex_yform_set as $k => $v) {
                 if (!in_array($k, $field_names)) {
                     unset($rex_yform_set[$k]);
                 }
             }
             $em_url_filter .= '&' . http_build_query(compact('rex_yform_set'));
         }
         $em_url = $em_url_filter . $em_url_set;
         $em_rex_list = '';
         $em_rex_list .= '&list=' . urlencode(rex_request('list', 'string'));
         $em_rex_list .= '&sort=' . urlencode(rex_request('sort', 'string'));
         $em_rex_list .= '&sorttype=' . urlencode(rex_request('sorttype', 'string'));
         $em_rex_list .= '&start=' . urlencode(rex_request('start', 'string'));
         // ---------- Popup - no menue, header ...
         if ($popup) {
             echo '<link rel="stylesheet" type="text/css" href="' . rex_plugin::get('yform', 'manager')->getAssetsUrl('popup.css') . '" />';
         }
         // -------------- Import
         if (!$popup && $func == 'import' && $this->hasDataPageFunction('import')) {
             include rex_path::plugin('yform', 'manager', 'pages/data_import.php');
             echo rex_view::info('<a href="index.php?' . $link_vars . $em_url . $em_rex_list . '"><b>&laquo; ' . rex_i18n::msg('yform_back_to_overview') . '</b></a>');
         }
         // -------------- delete entry
         if ($func == 'delete' && $data_id != '' && $this->hasDataPageFunction('delete')) {
             $delete = true;
             if (rex_extension::registerPoint(new rex_extension_point('YFORM_DATA_DELETE', $delete, array('id' => $data_id, 'value' => $data, 'table' => $this->table)))) {
                 $query = 'delete from ' . $this->table->getTablename() . ' where id=' . $data_id;
                 $delsql = rex_sql::factory();
                 $delsql->debugsql = self::$debug;
                 $delsql->setQuery($query);
                 echo rex_view::success(rex_i18n::msg('yform_datadeleted'));
                 $func = '';
                 $this->table->removeRelationTableRelicts();
                 rex_extension::registerPoint(new rex_extension_point('YFORM_DATA_DELETED', '', array('id' => $data_id, 'value' => $data, 'table' => $this->table)));
             }
         }
         // -------------- delete dataset
         if ($func == 'dataset_delete' && $this->hasDataPageFunction('truncate_table')) {
             $delete = true;
             $query = 'delete from `' . $this->table->getTablename() . '` ' . $this->getDataListQueryWhere($rex_yform_filter, $searchObject);
             if (rex_extension::registerPoint(new rex_extension_point('YFORM_DATA_DATASET_DELETE', $delete, array('table' => $this->table, 'query' => &$query)))) {
                 $delsql = rex_sql::factory();
                 $delsql->debugsql = self::$debug;
                 $delsql->setQuery($query);
                 echo rex_view::success(rex_i18n::msg('yform_dataset_deleted'));
                 $func = '';
                 $this->table->removeRelationTableRelicts();
                 rex_extension::registerPoint(new rex_extension_point('YFORM_DATA_DATASET_DELETED', '', array('table' => $this->table)));
             }
         }
         // -------------- truncate table
         if ($func == 'truncate_table' && $this->hasDataPageFunction('truncate_table')) {
             $truncate = true;
             if (rex_extension::registerPoint(new rex_extension_point('YFORM_DATA_TABLE_TRUNCATE', $truncate, array('table' => $this->table)))) {
                 $query = 'truncate table ' . $this->table->getTablename();
                 $trunsql = rex_sql::factory();
                 $trunsql->setQuery($query);
                 echo rex_view::info(rex_i18n::msg('yform_table_truncated'));
                 $func = '';
                 $this->table->removeRelationTableRelicts();
                 rex_extension::registerPoint(new rex_extension_point('YFORM_DATA_TABLE_TRUNCATED', '', array('table' => $this->table)));
             }
         }
         // -------------- export dataset
         if ($func == 'dataset_export' && $this->hasDataPageFunction('export')) {
             ob_end_clean();
             $sql = $this->getDataListQuery($rex_yform_filter, $searchObject);
             $data = '';
             $fields = array();
             $g = rex_sql::factory();
             $g->setQuery($sql);
             $array = rex_extension::registerPoint(new rex_extension_point('YFORM_DATA_TABLE_EXPORT', $g->getArray(), array('table' => $this->table)));
             foreach ($array as $d) {
                 if ($data == '') {
                     foreach ($d as $a => $b) {
                         $fields[] = '"' . $a . '"';
                     }
                     $data = implode(';', $fields);
                 }
                 foreach ($d as $a => $b) {
                     $d[$a] = '"' . str_replace('"', '""', $b) . '"';
                 }
                 $data .= "\n" . implode(';', $d);
             }
             // ----- download - save as
             $filename = 'export_data_' . date('YmdHis') . '.csv';
             $filesize = strlen($data);
             $filetype = 'application/octetstream';
             $expires = 'Mon, 01 Jan 2000 01:01:01 GMT';
             $last_modified = 'Mon, 01 Jan 2000 01:01:01 GMT';
             header('Expires: ' . $expires);
             // Date in the past
             header('Last-Modified: ' . $last_modified);
             // always modified
             header('Cache-Control: no-store, no-cache, must-revalidate');
             // HTTP/1.1
             header('Cache-Control: post-check=0, pre-check=0', false);
             header('Pragma: no-cache');
             header('Pragma: private');
             header('Cache-control: private, must-revalidate');
             header('Content-Type: ' . $filetype . '; name="' . $filename . '"');
             header('Content-Disposition: attachment; filename="' . $filename . '"');
             header('Content-Description: "' . $filename . '"');
             header('Content-Length: ' . $filesize);
             echo $data;
             exit;
         }
         // -------------- form
         if ($func == 'add' && $this->hasDataPageFunction('add') || $func == 'edit') {
             $back = rex_view::info('<a href="index.php?' . $link_vars . $em_url . $em_rex_list . '"><b>&laquo; ' . rex_i18n::msg('yform_back_to_overview') . '</b></a>');
             $yform = new rex_yform();
             $yform->setDebug(self::$debug);
             foreach ($this->getLinkVars() as $k => $v) {
                 $yform->setHiddenField($k, $v);
             }
             if (count($rex_yform_manager_opener) > 0) {
                 foreach ($rex_yform_manager_opener as $k => $v) {
                     $yform->setHiddenField('rex_yform_manager_opener[' . $k . ']', $v);
                 }
             }
             if (count($rex_yform_filter) > 0) {
                 foreach ($rex_yform_filter as $k => $v) {
                     if (is_array($v)) {
                         foreach ($v as $k2 => $v2) {
                             $yform->setHiddenField('rex_yform_filter[' . $k . '][' . $k2 . ']', $v2);
                         }
                     } else {
                         $yform->setHiddenField('rex_yform_filter[' . $k . ']', $v);
                     }
                 }
             }
             if (count($rex_yform_set) > 0) {
                 foreach ($rex_yform_set as $k => $v) {
                     if (is_array($v)) {
                         foreach ($v as $k2 => $v2) {
                             $yform->setHiddenField('rex_yform_set[' . $k . '][' . $k2 . ']', $v2);
                         }
                     } else {
                         $yform->setHiddenField('rex_yform_set[' . $k . ']', $v);
                     }
                 }
             }
             foreach ($searchObject->getSearchVars() as $s_var => $values) {
                 foreach ($values as $k => $v) {
                     $yform->setHiddenField($s_var . '[' . $k . ']', $v);
                 }
             }
             // for rexlist
             $yform->setHiddenField('list', rex_request('list', 'string'));
             $yform->setHiddenField('sort', rex_request('sort', 'string'));
             $yform->setHiddenField('sorttype', rex_request('sorttype', 'string'));
             $yform->setHiddenField('start', rex_request('start', 'string'));
             foreach ($this->table->getFields() as $field) {
                 $class = 'rex_yform_' . $field->getType() . '_' . $field->getTypeName();
                 $cl = new $class();
                 $definitions = $cl->getDefinitions();
                 $values = array();
                 $i = 1;
                 foreach ($definitions['values'] as $key => $_) {
                     $key = $this->getFieldName($key, $field->getType());
                     /*if ($field->getElement($key)) {
                           $values[] = $field->getElement($key);
                       } elseif ($field->getElement('f' . $i)) {
                           $values[] = $field->getElement('f' . $i);
                       } else {
                           $values[] = '';
                       }*/
                     $values[] = $field->getElement($key);
                     $i++;
                 }
                 if ($field->getType() == 'value') {
                     if (in_array($values[1], $this->getFilterFields())) {
                         // Feld vorhanden -> ignorieren -> hidden feld machen
                         // TODO: Feld trotzdem noch aufnehmen, damit validierungen etc noch funktionieren
                     } else {
                         $yform->setValueField($field->getTypeName(), $values);
                     }
                 } elseif ($field->getType() == 'validate') {
                     $yform->setValidateField($field->getTypeName(), $values);
                 } elseif ($field->getType() == 'action') {
                     $yform->setActionField($field->getTypeName(), $values);
                 }
             }
             if (rex_request('rex_yform_show_formularblock', 'string') != '') {
                 // Optional .. kann auch geloescht werden. Dient nur zu Hilfe beim Aufbau
                 // von yform-Formularen über php
                 // Textblock gibt den formalarblock als text aus, um diesen in das yform modul einsetzen zu können.
                 //  rex_yform_show_formularblock=1
                 $text_block = '';
                 foreach ($this->table->getFields() as $field) {
                     $class = 'rex_yform_' . $field->getType() . '_' . $field->getTypeName();
                     $cl = new $class();
                     $definitions = $cl->getDefinitions();
                     $values = array();
                     $i = 1;
                     foreach ($definitions['values'] as $key => $_) {
                         $key = $this->getFieldName($key, $field->getType());
                         if (isset($field[$key])) {
                             $values[] = $field[$key];
                         } elseif (isset($field['f' . $i])) {
                             $values[] = $field['f' . $i];
                         } else {
                             $values[] = '';
                         }
                         $i++;
                     }
                     if ($field->getType() == 'value') {
                         $text_block .= "\n" . '$yform->setValueField("' . $field->getTypeName() . '",array("' . implode('","', $values) . '"));';
                     } else {
                         if ($field->getType() == 'validate') {
                             $text_block .= "\n" . '$yform->setValidateField("' . $field->getTypeName() . '",array("' . implode('","', $values) . '"));';
                         } else {
                             if ($field->getType() == 'action') {
                                 $text_block .= "\n" . '$yform->setActionField("' . $field->getTypeName() . '",array("' . implode('","', $values) . '"));';
                             }
                         }
                     }
                     // $text_block .= "\n".$field["type_name"].'|'.implode("|",$values);
                 }
                 echo '<pre>' . $text_block . '</pre>';
             }
             $yform->setObjectparams('main_table', $this->table->getTablename());
             // für db speicherungen und unique abfragen
             $yform->setObjectparams('rex_yform_set', $rex_yform_set);
             $yform_clone = clone $yform;
             $yform->setHiddenField('func', $func);
             // damit es neu im clone gesetzt werden kann
             if ($func == 'edit') {
                 $yform->setHiddenField('data_id', $data_id);
                 $yform->setActionField('db', array($this->table->getTablename(), "id={$data_id}"));
                 $yform->setObjectparams('main_id', $data_id);
                 $yform->setObjectparams('main_where', "id={$data_id}");
                 $yform->setObjectparams('getdata', true);
                 $yform->setValueField('submits', array("name" => "submit", "labels" => rex_i18n::msg('yform_save') . "," . rex_i18n::msg('yform_save_apply'), "values" => "1,2", "no_db" => true, "css_classes" => "btn-save,btn-apply"));
             } elseif ($func == 'add') {
                 $yform->setActionField('db', array($this->table->getTablename()));
                 $yform->setValueField('submits', array("name" => "submit", "labels" => rex_i18n::msg('yform_add') . "," . rex_i18n::msg('yform_add_apply'), "values" => "1,2", "no_db" => true, "css_classes" => "btn-save,btn-apply"));
             }
             if ($func == 'edit') {
                 $yform = rex_extension::registerPoint(new rex_extension_point('YFORM_DATA_UPDATE', $yform, array('table' => $this->table, 'data_id' => $data_id, 'data' => $data)));
             } elseif ($func == 'add') {
                 $yform = rex_extension::registerPoint(new rex_extension_point('YFORM_DATA_ADD', $yform, array('table' => $this->table)));
             }
             $yform->executeFields();
             $submit_type = 1;
             // normal, 2=apply
             foreach ($yform->objparams["values"] as $f) {
                 if ($f->getName() == "submit") {
                     if ($f->getValue() == 2) {
                         // apply
                         $yform->setObjectparams('form_showformafterupdate', 1);
                         $yform->executeFields();
                         $submit_type = 2;
                     }
                 }
             }
             $form = $yform->executeActions();
             if ($yform->objparams['actions_executed']) {
                 if ($func == 'edit') {
                     echo rex_view::info(rex_i18n::msg('yform_thankyouforupdate'));
                     $yform = rex_extension::registerPoint(new rex_extension_point('YFORM_DATA_UPDATED', $yform, array('table' => $this->table, 'data_id' => $data_id, 'data' => $data)));
                 } elseif ($func == 'add') {
                     echo rex_view::info(rex_i18n::msg('yform_thankyouforentry'));
                     $yform = rex_extension::registerPoint(new rex_extension_point('YFORM_DATA_ADDED', $yform, array('table' => $this->table)));
                     if ($submit_type == 2) {
                         $data_id = $yform->objparams['main_id'];
                         $func = "edit";
                         $yform = $yform_clone;
                         $yform->setHiddenField('func', $func);
                         $yform->setHiddenField('data_id', $data_id);
                         $yform->setActionField('db', array($this->table->getTablename(), "id={$data_id}"));
                         $yform->setObjectparams('main_id', $data_id);
                         $yform->setObjectparams('main_where', "id={$data_id}");
                         $yform->setObjectparams('getdata', true);
                         $yform->setValueField('submits', array("name" => "submit", "labels" => rex_i18n::msg('yform_save') . "," . rex_i18n::msg('yform_save_apply'), "values" => "1,2", "no_db" => true, "css_classes" => "btn-save,btn-apply"));
                         $yform->setObjectparams('form_showformafterupdate', 1);
                         $yform->executeFields();
                         $form = $yform->executeActions();
                     }
                 }
             }
             if ($yform->objparams['form_show'] || $yform->objparams['form_showformafterupdate']) {
                 if ($func == 'add') {
                     $title = rex_i18n::msg('yform_adddata');
                 } else {
                     $title = rex_i18n::msg('yform_editdata');
                 }
                 $fragment = new rex_fragment();
                 $fragment->setVar('class', 'edit', false);
                 $fragment->setVar('title', $title);
                 $fragment->setVar('body', $form, false);
                 // $fragment->setVar('buttons', $buttons, false);
                 $form = $fragment->parse('core/page/section.php');
                 echo $form;
                 echo rex_extension::registerPoint(new rex_extension_point('YFORM_DATA_FORM', '', array('form' => $form, 'func' => $func, 'this' => $this, 'table' => $this->table)));
                 echo $back;
                 $show_list = false;
             }
         }
         // ********************************************* LIST
         if ($show_list) {
             $sql = $this->getDataListQuery($rex_yform_filter, $searchObject);
             // ---------- LISTE AUSGEBEN
             /** @type rex_list $list */
             $list = rex_list::factory($sql, $this->table->getListAmount());
             if ($this->hasDataPageFunction('add')) {
                 $tdIcon = '<i class="rex-icon rex-icon-table"></i>';
                 $thIcon = '<a href="index.php?' . $link_vars . '&func=add&' . $em_url . $em_rex_list . '"' . rex::getAccesskey(rex_i18n::msg('add'), 'add') . '><i class="rex-icon rex-icon-add"></i></a>';
                 $list->addColumn($thIcon, $tdIcon, 0, ['<th class="rex-table-icon">###VALUE###</th>', '<td class="rex-table-icon">###VALUE###</td>']);
                 if (!isset($rex_yform_manager_opener['id'])) {
                     $list->setColumnParams($thIcon, ['data_id' => '###id###', 'func' => 'edit', 'start' => rex_request('start', 'string'), 'sort' => rex_request('sort', 'string'), 'sorttype' => rex_request('sorttype', 'string'), 'list' => rex_request('list', 'string')]);
                 }
             }
             // $list->setColumnFormat('id', 'Id');
             foreach ($this->getLinkVars() as $k => $v) {
                 $list->addParam($k, $v);
             }
             $list->addParam('table_name', $this->table->getTablename());
             if (count($rex_yform_filter) > 0) {
                 foreach ($rex_yform_filter as $k => $v) {
                     if (is_array($v)) {
                         foreach ($v as $k2 => $v2) {
                             $list->addParam('rex_yform_filter[' . $k . '][' . $k2 . ']', $v2);
                         }
                     } else {
                         $list->addParam('rex_yform_filter[' . $k . ']', $v);
                     }
                 }
             }
             if (count($rex_yform_set) > 0) {
                 foreach ($rex_yform_set as $k => $v) {
                     if (is_array($v)) {
                         foreach ($v as $k2 => $v2) {
                             $list->addParam('rex_yform_set[' . $k . '][' . $k2 . ']', $v2);
                         }
                     } else {
                         $list->addParam('rex_yform_set[' . $k . ']', $v);
                     }
                 }
             }
             if (count($rex_yform_manager_opener) > 0) {
                 foreach ($rex_yform_manager_opener as $k => $v) {
                     $list->addParam('rex_yform_manager_opener[' . $k . ']', $v);
                 }
             }
             foreach ($searchObject->getSearchVars() as $s_var => $values) {
                 foreach ($values as $k => $v) {
                     $list->addParam($s_var . '[' . $k . ']', $v);
                 }
             }
             $list->setColumnLabel('id', rex_i18n::msg('yform_id'));
             $list->setColumnLayout('id', ['<th class="rex-table-id">###VALUE###</th>', '<td class="rex-table-id" data-title="' . rex_i18n::msg('id') . '">###VALUE###</td>']);
             $list->setColumnParams('id', array('data_id' => '###id###', 'func' => 'edit'));
             $list->setColumnSortable('id');
             foreach ($this->table->getFields() as $field) {
                 if (!$field->isHiddenInList() && $field->getTypeName()) {
                     if (method_exists('rex_yform_value_' . $field->getTypeName(), 'getListValue')) {
                         $list->setColumnFormat($field->getName(), 'custom', array('rex_yform_value_' . $field->getTypeName(), 'getListValue'), array('field' => $field->toArray(), 'fields' => $this->table->getFields()));
                     }
                 }
                 if ($field->getType() == 'value') {
                     if ($field->isHiddenInList()) {
                         $list->removeColumn($field->getName());
                     } else {
                         $list->setColumnSortable($field->getName());
                         $list->setColumnLabel($field->getName(), $field->getLabel());
                     }
                 }
             }
             if (isset($rex_yform_manager_opener['id'])) {
                 $list->addColumn(rex_i18n::msg('yform_data_select'), '');
                 $list->setColumnFormat(rex_i18n::msg('yform_data_select'), 'custom', function ($params) {
                     $value = '';
                     list($table_name, $field_name) = explode(".", $params["params"]["opener_field"]);
                     $table = rex_yform_manager_table::get($table_name);
                     if ($table) {
                         $fields = $table->getValueFields(array("name" => $field_name));
                         if (isset($fields[$field_name])) {
                             $target_table = $fields[$field_name]->getElement('table');
                             $target_field = $fields[$field_name]->getElement('field');
                             $values = rex_yform_value_be_manager_relation::getListValues($target_table, $target_field);
                             $value = $values[$params['list']->getValue('id')];
                         }
                     }
                     return '<a href="javascript:yform_manager_setData(' . $params["params"]["opener_id"] . ',###id###,\'' . htmlspecialchars($value) . ' [id=###id###]\',' . $params["params"]["opener_multiple"] . ')">' . rex_i18n::msg('yform_data_select') . '</a>';
                 }, array("opener_id" => $rex_yform_manager_opener["id"], "opener_field" => $rex_yform_manager_opener["field"], "opener_multiple" => $rex_yform_manager_opener["multiple"]));
             } else {
                 $list->addColumn(rex_i18n::msg('yform_function'), '<i class="rex-icon rex-icon-edit"></i> ' . rex_i18n::msg('yform_edit'));
                 $list->setColumnLayout(rex_i18n::msg('yform_function'), ['<th class="rex-table-action">###VALUE###</th>', '<td class="rex-table-action">###VALUE###</td>']);
                 $list->setColumnParams(rex_i18n::msg('yform_function'), array('data_id' => '###id###', 'func' => 'edit', 'start' => rex_request('start', 'string'), 'sort' => rex_request('sort', 'string'), 'sorttype' => rex_request('sorttype', 'string'), 'list' => rex_request('list', 'string')));
                 if ($this->hasDataPageFunction('delete')) {
                     // Column layout fuer edit neu setzen
                     $list->setColumnLayout(rex_i18n::msg('yform_function'), ['<th class="rex-table-action" colspan="2">###VALUE###</th>', '<td class="rex-table-action">###VALUE###</td>']);
                     $list->addColumn(rex_i18n::msg('yform_delete'), '<i class="rex-icon rex-icon-delete"></i> ' . rex_i18n::msg('yform_delete'));
                     $list->setColumnLayout(rex_i18n::msg('yform_delete'), ['', '<td class="rex-table-action">###VALUE###</td>']);
                     $list->setColumnParams(rex_i18n::msg('yform_delete'), array('data_id' => '###id###', 'func' => 'delete', 'start' => rex_request('start', 'string'), 'sort' => rex_request('sort', 'string'), 'sorttype' => rex_request('sorttype', 'string'), 'list' => rex_request('list', 'string')));
                     $list->addLinkAttribute(rex_i18n::msg('yform_delete'), 'onclick', 'return confirm(\' id=###id### ' . rex_i18n::msg('yform_delete') . ' ?\')');
                 }
             }
             // *********************************************
             $list = rex_extension::registerPoint(new rex_extension_point('YFORM_DATA_LIST', $list, array('table' => $this->table)));
             if ($rex_yform_filter) {
                 $filter = array();
                 $getFilter = function (rex_yform_manager_field $field, $value) {
                     if ('be_manager_relation' == $field->getTypeName()) {
                         $listValues = rex_yform_value_be_manager_relation::getListValues($field->getElement('table'), $field->getElement('field'), array('id' => $value));
                         if (isset($listValues[$value])) {
                             $value = $listValues[$value];
                         }
                     }
                     return '<b>' . rex_i18n::translate($field->getLabel()) . ':</b> ' . $value;
                 };
                 foreach ($rex_yform_filter as $key => $value) {
                     if (is_array($value)) {
                         $relTable = rex_yform_manager_table::get($this->table->getValueField($key)->getElement('table'));
                         foreach ($value as $k => $v) {
                             $filter[] = $getFilter($relTable->getValueField($k), $v);
                         }
                     } else {
                         $filter[] = $getFilter($this->table->getValueField($key), $value);
                     }
                 }
                 echo rex_view::info(implode('<br>', $filter));
             }
             $panel_options = '';
             $data_links = [];
             if ($this->table->isSearchable() && $this->hasDataPageFunction('search')) {
                 $item = [];
                 $item['label'] = rex_i18n::msg('yform_search');
                 $item['attributes']['class'][] = 'btn-search';
                 $item['attributes']['id'] = 'searchtoggler';
                 $data_links[] = $item;
             }
             if (count($data_links) > 0) {
                 $fragment = new rex_fragment();
                 $fragment->setVar('size', 'xs', false);
                 $fragment->setVar('buttons', $data_links, false);
                 $panel_options .= '<small class="rex-panel-option-title">' . rex_i18n::msg('yform_data') . '</small> ' . $fragment->parse('core/buttons/button_group.php');
             }
             // INFO LINK
             $dataset_links = [];
             if ($this->table->isExportable() == 1 && $this->hasDataPageFunction('export')) {
                 $item = [];
                 $item['label'] = rex_i18n::msg('yform_export');
                 $item['url'] = 'index.php?' . $link_vars . '&func=dataset_export&' . $em_url . $em_rex_list;
                 $item['attributes']['class'][] = 'btn-default';
                 $dataset_links[] = $item;
             }
             if ($this->hasDataPageFunction('truncate_table')) {
                 $item = [];
                 $item['label'] = rex_i18n::msg('yform_delete');
                 $item['url'] = 'index.php?' . $link_vars . '&func=dataset_delete&' . $em_url . $em_rex_list;
                 $item['attributes']['class'][] = 'btn-delete';
                 $item['attributes']['id'] = 'dataset-delete';
                 $item['attributes']['onclick'][] = 'return confirm(\'' . rex_i18n::msg('yform_dataset_delete_confirm') . '\');';
                 $dataset_links[] = $item;
             }
             if (count($dataset_links) > 0) {
                 $fragment = new rex_fragment();
                 $fragment->setVar('size', 'xs', false);
                 $fragment->setVar('buttons', $dataset_links, false);
                 $panel_options .= '<small class="rex-panel-option-title">' . rex_i18n::msg('yform_dataset') . '</small> ' . $fragment->parse('core/buttons/button_group.php');
             }
             $table_links = array();
             if (!$popup && $this->table->isImportable() && $this->hasDataPageFunction('import')) {
                 $item = [];
                 $item['label'] = rex_i18n::msg('yform_import');
                 $item['url'] = 'index.php?' . htmlspecialchars($link_vars) . '&amp;func=import';
                 $item['attributes']['class'][] = 'btn-default';
                 $table_links[] = $item;
             }
             if (rex::getUser()->isAdmin()) {
                 $item = [];
                 $item['label'] = rex_i18n::msg('yform_edit');
                 $item['url'] = 'index.php?page=yform/manager&table_id=' . $this->table->getId() . '&func=edit';
                 $item['attributes']['class'][] = 'btn-default';
                 $table_links[] = $item;
             }
             if ($this->hasDataPageFunction('truncate_table')) {
                 $item = [];
                 $item['label'] = rex_i18n::msg('yform_truncate_table');
                 $item['url'] = 'index.php?' . $link_vars . '&func=truncate_table&' . $em_url . $em_rex_list;
                 $item['attributes']['class'][] = 'btn-delete';
                 $item['attributes']['id'] = 'truncate-table';
                 $item['attributes']['onclick'][] = 'return confirm(\'' . rex_i18n::msg('yform_truncate_table_confirm') . '\');';
                 $table_links[] = $item;
             }
             if (count($table_links) > 0) {
                 $fragment = new rex_fragment();
                 $fragment->setVar('size', 'xs', false);
                 $fragment->setVar('buttons', $table_links, false);
                 $panel_options .= '<small class="rex-panel-option-title">' . rex_i18n::msg('yform_table') . '</small> ' . $fragment->parse('core/buttons/button_group.php');
             }
             $field_links = array();
             if (rex::getUser()->isAdmin()) {
                 $item = [];
                 $item['label'] = rex_i18n::msg('yform_edit');
                 $item['url'] = 'index.php?page=yform/manager/table_field&table_name=' . $this->table->getTableName();
                 $item['attributes']['class'][] = 'btn-default';
                 $field_links[] = $item;
             }
             if (count($field_links) > 0) {
                 $fragment = new rex_fragment();
                 $fragment->setVar('size', 'xs', false);
                 $fragment->setVar('buttons', $field_links, false);
                 $panel_options .= '<small class="rex-panel-option-title">' . rex_i18n::msg('yform_manager_fields') . '</small> ' . $fragment->parse('core/buttons/button_group.php');
             }
             // SEARCHBLOCK
             $searchVars = $searchObject->getSearchVars();
             $display = count($searchVars["rex_yform_searchvars"]) > 0 ? 'block' : 'none';
             echo '<div id="searchblock" style="display:' . $display . ';">' . $searchform . '</div>';
             $content = $list->get();
             $fragment = new rex_fragment();
             $fragment->setVar('title', rex_i18n::msg('yform_tabledata_overview'));
             $fragment->setVar('options', $panel_options, false);
             $fragment->setVar('content', $content, false);
             $content = $fragment->parse('core/page/section.php');
             $content .= '
              <script type="text/javascript">/* <![CDATA[ */
                  jQuery("#searchtoggler").click(function(){jQuery("#searchblock").slideToggle("fast");});
                  jQuery("#yform_help_empty_toggler").click(function(){jQuery("#yform_help_empty").slideToggle("fast");});
                  jQuery("#yform_search_reset").click(function(){window.location.href = "index.php?page=yform/manager/data_edit&table_name=' . $this->table->getTableName() . '";});
                  jQuery("#truncate-table").click(function(){if(confirm("' . rex_i18n::msg('yform_truncate_table_confirm') . '")){return true;} else {return false;}});
                  jQuery("#dataset-delete").click(function(){if(confirm("' . rex_i18n::msg('yform_dataset_delete_confirm') . '")){return true;} else {return false;}});
              /* ]]> */</script>';
             echo $content;
         }
     }
     // end: $show_editpage
 }
Esempio n. 30
0
 private static function import($import_sql, $import_archiv = null)
 {
     $err_msg = '';
     if (!is_dir(rex_path::addon('backup'))) {
         $err_msg .= rex_i18n::msg('setup_510') . '<br />';
     } else {
         if (file_exists($import_sql) && ($import_archiv === null || $import_archiv !== null && file_exists($import_archiv))) {
             rex_i18n::addDirectory(rex_path::addon('backup', 'lang/'));
             // DB Import
             $state_db = rex_backup::importDb($import_sql);
             if ($state_db['state'] === false) {
                 $err_msg .= nl2br($state_db['message']) . '<br />';
             }
             // Archiv optional importieren
             if ($state_db['state'] === true && $import_archiv !== null) {
                 $state_archiv = rex_backup::importFiles($import_archiv);
                 if ($state_archiv['state'] === false) {
                     $err_msg .= $state_archiv['message'] . '<br />';
                 }
             }
         } else {
             $err_msg .= rex_i18n::msg('setup_509') . '<br />';
         }
     }
     return $err_msg;
 }