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); }
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; }
/** * @param string $name * * @return null|self */ public static function get($name) { if (!$name) { return null; } return self::getInstance($name, function ($name) { $media_path = rex_path::addonCache('mediapool', $name . '.media'); if (!file_exists($media_path)) { rex_media_cache::generate($name); } if (file_exists($media_path)) { $cache = rex_file::getCache($media_path); $aliasMap = ['filename' => 'name', 'filetype' => 'type', 'filesize' => 'size']; $media = new self(); foreach ($cache as $key => $value) { if (array_key_exists($key, $aliasMap)) { $var_name = $aliasMap[$key]; } else { $var_name = $key; } $media->{$var_name} = $value; } $media->category = null; return $media; } return null; }); }
public static function init() { self::$domainsByMountId = []; self::$domainsByName = []; self::$aliasDomains = []; self::$paths = []; self::addDomain(new rex_yrewrite_domain('undefined', 0, rex_article::getSiteStartArticleId(), rex_article::getNotfoundArticleId())); self::$pathfile = rex_path::addonCache('yrewrite', 'pathlist.php'); self::$configfile = rex_path::addonCache('yrewrite', 'config.php'); self::readConfig(); self::readPathFile(); }
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); }
public static function init() { if (null === self::$scheme) { self::setScheme(new rex_yrewrite_scheme()); } self::$domainsByMountId = []; self::$domainsByName = []; self::$aliasDomains = []; self::$paths = []; $path = dirname($_SERVER['SCRIPT_NAME']); if (rex::isBackend()) { $path = dirname($path); } $path = rtrim($path, '/') . '/'; self::addDomain(new rex_yrewrite_domain('default', null, $path, 0, rex_article::getSiteStartArticleId(), rex_article::getNotfoundArticleId())); self::$pathfile = rex_path::addonCache('yrewrite', 'pathlist.php'); self::$configfile = rex_path::addonCache('yrewrite', 'config.php'); self::readConfig(); self::readPathFile(); }
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)); }
/** * @param int $parentId * @param string $listType * @param bool $ignoreOfflines * @param int $clang * * @return static[] */ protected static function getChildElements($parentId, $listType, $ignoreOfflines = false, $clang = null) { $parentId = (int) $parentId; // for $parentId=0 root elements will be returned, so abort here for $parentId<0 only if (0 > $parentId) { return []; } if (!$clang) { $clang = rex_clang::getCurrentId(); } $class = get_called_class(); return static::getInstanceList([$parentId, $listType], function ($id) use($class, $ignoreOfflines, $clang) { if ($instance = $class::get($id, $clang)) { return !$ignoreOfflines || $instance->isOnline() ? $instance : null; } return null; }, function ($parentId, $listType) { $listFile = rex_path::addonCache('structure', $parentId . '.' . $listType); if (!file_exists($listFile)) { rex_article_cache::generateLists($parentId); } return rex_file::getCache($listFile); }); }
/** * {@inheritdoc} */ public function getCachePath($file = '') { return rex_path::addonCache($this->getName(), $file); }
$template_id = $TPL->getLastId(); $success = rex_i18n::msg('template_added'); } catch (rex_sql_exception $e) { $error = $e->getMessage(); } } else { $TPL->setWhere(['id' => $template_id]); $TPL->addGlobalUpdateFields(); try { $TPL->update(); $success = rex_i18n::msg('template_updated'); } catch (rex_sql_exception $e) { $error = $e->getMessage(); } } rex_dir::delete(rex_path::addonCache('templates'), false); if ($goon != '') { $function = 'edit'; $save = 'nein'; } else { $function = ''; } } if (!isset($save) or $save != 'ja') { // Ctype Handling $ctypes = isset($attributes['ctype']) ? $attributes['ctype'] : []; $modules = isset($attributes['modules']) ? $attributes['modules'] : []; $categories = isset($attributes['categories']) ? $attributes['categories'] : []; if (!is_array($modules)) { $modules = []; }
private static function setCache($path, $data) { self::$cache[$path]['stamp'] = time(); self::$cache[$path]['data'] = $data; rex_file::putCache(rex_path::addonCache('install', 'webservice.cache'), self::$cache); }
/** * Generiert eine Liste mit den Kindkategorien einer Kategorie. * * @param int $category_id Id der Kategorie * * @return bool TRUE bei Erfolg, sonst FALSE */ public static function generateCategoryList($category_id) { // sanity check if ($category_id < 0) { return false; } $query = 'SELECT id, cast( name AS SIGNED ) AS sort FROM ' . rex::getTable('media_category') . ' WHERE parent_id = ' . $category_id . ' ORDER BY sort, name'; $sql = rex_sql::factory(); //$sql->setDebug(); $sql->setQuery($query); $cacheArray = []; for ($i = 0; $i < $sql->getRows(); ++$i) { $cacheArray[] = $sql->getValue('id'); $sql->next(); } $list_file = rex_path::addonCache('mediapool', $category_id . '.mclist'); if (rex_file::putCache($list_file, $cacheArray)) { return true; } return false; }
/** * Generiert den Artikel-Cache des Artikelinhalts. * * @param int $article_id Id des zu generierenden Artikels * @param int $clang ClangId des Artikels * * @return bool TRUE bei Erfolg, FALSE wenn eine ungütlige article_id übergeben wird, sonst eine Fehlermeldung */ public static function generateArticleContent($article_id, $clang = null) { foreach (rex_clang::getAllIds() as $_clang) { if ($clang !== null && $clang != $_clang) { continue; } $CONT = new rex_article_content_base(); $CONT->setCLang($_clang); $CONT->setEval(false); // Content nicht ausführen, damit in Cachedatei gespeichert werden kann if (!$CONT->setArticleId($article_id)) { return false; } // --------------------------------------------------- Artikelcontent speichern $article_content_file = rex_path::addonCache('structure', "{$article_id}.{$_clang}.content"); $article_content = $CONT->getArticle(); // ----- EXTENSION POINT $article_content = rex_extension::registerPoint(new rex_extension_point('GENERATE_FILTER', $article_content, ['id' => $article_id, 'clang' => $_clang, 'article' => $CONT])); if (rex_file::put($article_content_file, $article_content) === false) { return rex_i18n::msg('article_could_not_be_generated') . ' ' . rex_i18n::msg('check_rights_in_directory') . rex_path::addonCache('structure'); } } return true; }
public static function getTemplatesDir() { return rex_path::addonCache('templates'); }
/** * Generiert alle *.alist u. *.clist Dateien einer Kategorie/eines Artikels. * * @param int $parent_id KategorieId oder ArtikelId, die erneuert werden soll * * @return bool TRUE wenn der Artikel gelöscht wurde, sonst eine Fehlermeldung */ public static function generateLists($parent_id) { // sanity check if ($parent_id < 0) { return false; } // --------------------------------------- ARTICLE LIST $GC = rex_sql::factory(); // $GC->setDebug(); $GC->setQuery('select * from ' . rex::getTablePrefix() . 'article where clang_id=:clang AND ((parent_id=:id and startarticle=0) OR (id=:id and startarticle=1)) order by priority,name', ['id' => $parent_id, 'clang' => rex_clang::getStartId()]); $cacheArray = []; foreach ($GC as $row) { $cacheArray[] = (int) $row->getValue('id'); } $article_list_file = rex_path::addonCache('structure', $parent_id . '.alist'); if (rex_file::putCache($article_list_file, $cacheArray) === false) { return rex_i18n::msg('article_could_not_be_generated') . ' ' . rex_i18n::msg('check_rights_in_directory') . rex_path::addonCache('structure'); } // --------------------------------------- CAT LIST $GC = rex_sql::factory(); $GC->setQuery('select * from ' . rex::getTablePrefix() . 'article where parent_id=:id and clang_id=:clang and startarticle=1 order by catpriority,name', ['id' => $parent_id, 'clang' => rex_clang::getStartId()]); $cacheArray = []; foreach ($GC as $row) { $cacheArray[] = (int) $row->getValue('id'); } $article_categories_file = rex_path::addonCache('structure', $parent_id . '.clist'); if (rex_file::putCache($article_categories_file, $cacheArray) === false) { return rex_i18n::msg('article_could_not_be_generated') . ' ' . rex_i18n::msg('check_rights_in_directory') . rex_path::addonCache('structure'); } return true; }
public static function init() { //--- handle image request $rex_media_manager_file = self::getMediaFile(); $rex_media_manager_type = self::getMediaType(); if ($rex_media_manager_file != '' && $rex_media_manager_type != '') { $media_path = rex_path::media($rex_media_manager_file); $cache_path = rex_path::addonCache('media_manager'); $media = new rex_managed_media($media_path); $media_manager = new self($media); $media_manager->setCachePath($cache_path); $media_manager->applyEffects($rex_media_manager_type); $media_manager->sendMedia(); exit; } }
public static function init() { self::$pathfile = rex_path::addonCache('yrewrite', 'forward_pathlist.php'); self::readPathFile(); }
/** * @return rex_media[] */ public function getMedia() { return self::getInstanceList([$this->getId(), 'media'], 'rex_media::get', function ($id) { $list_path = rex_path::addonCache('mediapool', $id . '.mlist'); if (!file_exists($list_path)) { rex_media_cache::generateList($id); } return rex_file::getCache($list_path); }); }