本文整理汇总了PHP中rex::isBackend方法的典型用法代码示例。如果您正苦于以下问题:PHP rex::isBackend方法的具体用法?PHP rex::isBackend怎么用?PHP rex::isBackend使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类rex
的用法示例。
在下文中一共展示了rex::isBackend方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: isActive
public static function isActive(rex_extension_point $ep)
{
$sql = rex_sql::factory();
$sql->setTable(rex::getTablePrefix() . 'article_slice');
$sql->setWhere(array('id' => $ep->getParam('slice_id')));
$sql->select();
if ($sql->getValue('active') == 1 || rex::isBackend()) {
return $ep->content;
}
return '';
}
示例2: log
private 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);
}
示例3: handleException
/**
* Handles the given Exception.
*
* @param Throwable|Exception $exception The Exception to handle
* @param bool $showTrace
*/
public static function handleException($exception, $showTrace = true)
{
rex_logger::logException($exception);
while (ob_get_level()) {
ob_end_clean();
}
$status = rex_response::HTTP_INTERNAL_ERROR;
if ($exception instanceof rex_http_exception && $exception->getHttpCode()) {
$status = $exception->getHttpCode();
}
rex_response::setStatus($status);
if (rex::isSetup() || rex::isDebugMode() || ($user = rex_backend_login::createUser()) && $user->isAdmin()) {
// TODO add a beautiful error page with usefull debugging info
$buf = '';
$buf .= '<pre>';
$buf .= '"' . get_class($exception) . '" thrown in ' . $exception->getFile() . ' on line ' . $exception->getLine() . "\n";
if ($exception->getMessage()) {
$buf .= '<b>' . ($exception instanceof ErrorException ? self::getErrorType($exception->getSeverity()) . ': ' : '') . $exception->getMessage() . "</b>\n";
}
$cause = $exception->getPrevious();
while ($cause) {
$buf .= "\n";
$buf .= 'caused by ' . get_class($cause) . ' in ' . $cause->getFile() . ' on line ' . $cause->getLine() . "\n";
if ($cause->getMessage()) {
$buf .= '<b>' . ($cause instanceof ErrorException ? self::getErrorType($cause->getSeverity()) . ': ' : '') . $cause->getMessage() . "</b>\n";
}
$cause = $cause->getPrevious();
}
if ($showTrace) {
$buf .= "\n";
$buf .= $exception->getTraceAsString();
}
if (!rex::isSetup() && rex::isBackend() && !rex::isSafeMode()) {
$buf .= "\n\n";
$buf .= '<a href="' . rex_url::backendPage('packages', ['safemode' => 1]) . '">activate safe mode</a>';
}
$buf .= '</pre>';
} else {
// TODO small error page, without debug infos
$buf = 'Oooops, an internal error occured!';
}
rex_response::sendContent($buf);
exit;
}
示例4: init
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();
}
示例5:
<?php
/**
* REDAXO customizer.
*
* Codemirror by : http://codemirror.net/
* Marijn Haverbeke <marijnh@gmail.com>
*/
if (rex::isBackend() && rex::getUser()) {
$config = $this->getConfig();
rex_view::addCssFile($this->getAssetsUrl('css/styles.css'));
if ($config['codemirror']) {
rex_view::addCssFile($this->getAssetsUrl('vendor/codemirror/codemirror.css'));
rex_view::addCssFile($this->getAssetsUrl('vendor/codemirror/theme/' . $config['codemirror_theme'] . '.css'));
if ($config['codemirror_theme'] != '') {
rex_view::setJsProperty('customizer_codemirror_defaulttheme', $config['codemirror_theme']);
}
rex_view::addJsFile($this->getAssetsUrl('vendor/codemirror/codemirror-compressed.js'));
}
if ($config['labelcolor'] != '') {
rex_view::setJsProperty('customizer_labelcolor', $config['labelcolor']);
}
if ($config['showlink']) {
rex_view::setJsProperty('customizer_showlink', '<h1 class="be-style-customizer-title"><a href="' . rex::getServer() . '" target="_blank">' . rex::getServerName() . '</a><i class="fa fa-external-link"></i></h1>');
}
rex_view::addJsFile($this->getAssetsUrl('js/main.js'));
}
示例6: sendContent
/**
* Sends content to the client.
*
* @param string $content Content
* @param string $contentType Content type
* @param int $lastModified HTTP Last-Modified Timestamp
* @param string $etag HTTP Cachekey to identify the cache
*/
public static function sendContent($content, $contentType = null, $lastModified = null, $etag = null)
{
if (!self::$sentContentType) {
self::sendContentType($contentType);
}
if (!self::$sentCacheControl) {
self::sendCacheControl();
}
$environment = rex::isBackend() ? 'backend' : 'frontend';
if (self::$httpStatus == self::HTTP_OK && (false === strpos($_SERVER['HTTP_USER_AGENT'], 'Safari') || false !== strpos($_SERVER['HTTP_USER_AGENT'], 'Chrome'))) {
// ----- Last-Modified
if (!self::$sentLastModified && (rex::getProperty('use_last_modified') === true || rex::getProperty('use_last_modified') === $environment)) {
self::sendLastModified($lastModified);
}
// ----- ETAG
if (!self::$sentEtag && (rex::getProperty('use_etag') === true || rex::getProperty('use_etag') === $environment)) {
self::sendEtag($etag ?: self::md5($content));
}
}
// ----- GZIP
if (rex::getProperty('use_gzip') === true || rex::getProperty('use_gzip') === $environment) {
$content = self::sendGzip($content);
}
self::cleanOutputBuffers();
header('HTTP/1.1 ' . self::$httpStatus);
// content length schicken, damit der browser einen ladebalken anzeigen kann
header('Content-Length: ' . rex_string::size($content));
echo $content;
if (function_exists('fastcgi_finish_request')) {
fastcgi_finish_request();
}
}
示例7: testIsBackend
public function testIsBackend()
{
$this->assertTrue(rex::isBackend(), 'test run in the backend');
// TODO find more appropriate tests
}
示例8: enterObject
function enterObject()
{
$error = array();
$rfile = 'file_' . md5($this->getFieldName('file'));
$err_msgs = $this->getElement('messages');
// min_err,max_err,type_err,empty_err
if (!is_array($err_msgs)) {
$err_msgs = explode(',', $err_msgs);
}
$err_msgs['min_error'] = $err_msgs[0];
$err_msgs['max_error'] = isset($err_msgs[1]) ? rex_i18n::translate($err_msgs[1]) : 'max_error';
$err_msgs['type_error'] = isset($err_msgs[2]) ? rex_i18n::translate($err_msgs[2]) : 'type_error';
$err_msgs['empty_error'] = isset($err_msgs[3]) ? rex_i18n::translate($err_msgs[3]) : 'empty_error';
$err_msgs['delete_file'] = isset($err_msgs[4]) ? rex_i18n::translate($err_msgs[4]) : 'delete ';
$this->tmp_messages = $err_msgs;
$value = $this->getValue();
if ($value == "") {
$value = $this->getElement('default_file');
}
$this->setValue('');
$value_email = '';
$value_sql = '';
if (!is_string($value) && $value["delete"] == 1) {
$value = '';
}
// SIZE CHECK
$sizes = explode(',', $this->getElement('max_size'));
$minsize = count($sizes) > 1 ? (int) ($sizes[0] * 1024) : 0;
$maxsize = count($sizes) > 1 ? (int) ($sizes[1] * 1024) : (int) ($sizes[0] * 1024);
if ($this->params['send'] && isset($_FILES[$rfile]) && $_FILES[$rfile]['name'] != '' && ($_FILES[$rfile]['size'] > $maxsize || $_FILES[$rfile]['size'] < $minsize)) {
if ($_FILES[$rfile]['size'] < $minsize) {
$error[] = $err_msgs['min_error'];
}
if ($_FILES[$rfile]['size'] > $maxsize) {
$error[] = $err_msgs['max_error'];
}
unset($_FILES[$rfile]);
}
$database_filename_field = $this->getElement('database_filename_field');
if ($database_filename_field != "") {
$value = $this->params['value_pool']['sql'][$database_filename_field];
}
$prefix = md5(mt_rand() . microtime(true)) . '_';
if ($this->getElement('file_prefix')) {
$prefix .= $this->getElement('file_prefix') . '_';
}
$upload_folder = $this->getElement('upload_folder');
if ($upload_folder == "") {
$upload_folder = rex_path::addonData('yform', 'uploads');
rex_dir::create($upload_folder);
}
if ($value != "") {
if (rex::isBackend()) {
$value = explode("_", $value, 2);
$value = $value[0];
}
$search_path = $upload_folder . '/' . $value . '_' . $this->getElement('file_prefix');
$files = glob(preg_replace('/(\\*|\\?|\\[)/', '[$1]', $search_path) . '*');
if (count($files) == 1) {
$value = basename($files[0]);
if (rex_request("rex_upload_downloadfile") == $value) {
$file = $upload_folder . '/' . $value;
if (file_exists($file)) {
ob_end_clean();
$filename = explode("_", basename($file), 2);
$filename = $filename[1];
header('Content-Description: File Transfer');
header('Content-Type: application/octet-stream');
header('Content-Disposition: attachment; filename=' . $filename);
header('Expires: 0');
header('Cache-Control: must-revalidate');
header('Pragma: public');
header('Content-Length: ' . filesize($file));
readfile($file);
exit;
}
}
} else {
$value = "";
}
}
if ($this->params['send']) {
if (isset($_FILES[$rfile]) && $_FILES[$rfile]['name'] != '') {
$FILE['size'] = $_FILES[$rfile]['size'];
$FILE['name'] = $_FILES[$rfile]['name'];
$FILE['type'] = $_FILES[$rfile]['type'];
$FILE['tmp_name'] = $_FILES[$rfile]['tmp_name'];
$FILE['error'] = $_FILES[$rfile]['error'];
$FILE['name_normed'] = strtolower(preg_replace('/[^a-zA-Z0-9.\\-\\$\\+]/', '_', $FILE['name']));
$extensions_array = explode(',', $this->getElement('types'));
$ext = '.' . pathinfo($FILE['name'], PATHINFO_EXTENSION);
if (!in_array(strtolower($ext), $extensions_array) && !in_array(strtoupper($ext), $extensions_array)) {
$error[] = $err_msgs['type_error'];
$value = '';
} else {
$file_normed = $FILE['name_normed'];
$file_normed_new = $prefix . $file_normed;
if (file_exists($upload_folder . '/' . $file_normed_new)) {
for ($cf = 1; $cf < 1000; $cf++) {
$file_normed_new = $prefix . $cf . '_' . $file_normed;
//.........这里部分代码省略.........
示例9: getUrl
/**
* Gibt eine Formular-Url zurück.
*
* @param array $params
* @param bool $escape
*
* @return string
*/
public function getUrl(array $params = [], $escape = true)
{
$params = array_merge($this->getParams(), $params);
$params['form'] = $this->getName();
$url = rex::isBackend() ? rex_url::backendController($params, $escape) : rex_url::frontendController($params, $escape);
return $url;
}
示例10: function
$escapeSql = rex_sql::factory();
$sliceDate = ' AND ' . rex::getTablePrefix() . 'article_slice.history_date = ' . $escapeSql->escape($history_date);
return 'SELECT ' . rex::getTablePrefix() . 'module.id, ' . rex::getTablePrefix() . 'module.name, ' . rex::getTablePrefix() . 'module.output, ' . rex::getTablePrefix() . 'module.input, ' . rex::getTablePrefix() . 'article_slice.*, ' . rex::getTablePrefix() . 'article.parent_id
FROM
' . rex_article_slice_history::getTable() . ' as ' . rex::getTablePrefix() . 'article_slice
LEFT JOIN ' . rex::getTablePrefix() . 'module ON ' . rex::getTablePrefix() . 'article_slice.module_id=' . rex::getTablePrefix() . 'module.id
LEFT JOIN ' . rex::getTablePrefix() . 'article ON ' . rex::getTablePrefix() . 'article_slice.article_id=' . rex::getTablePrefix() . 'article.id
WHERE
' . rex::getTablePrefix() . "article_slice.clang_id='" . $article->getClang() . "' AND\n " . rex::getTablePrefix() . "article.clang_id='" . $article->getClang() . "' AND\n " . rex::getTablePrefix() . "article_slice.revision='" . $history_revision . "'\n " . $articleLimit . '
' . $sliceLimit . '
' . $sliceDate . '
ORDER BY ' . rex::getTablePrefix() . 'article_slice.priority';
}
});
}
if (rex::isBackend() && rex::getUser() && rex::getUser()->hasPerm('history[article_rollback]')) {
rex_extension::register(['ART_SLICES_COPY', 'SLICE_ADD', 'SLICE_UPDATE', 'SLICE_MOVE', 'SLICE_DELETE'], function (rex_extension_point $ep) {
switch ($ep->getName()) {
case 'ART_SLICES_COPY':
$type = 'slices_copy';
break;
case 'SLICE_MOVE':
$type = 'slice_' . $ep->getParam('direction');
break;
default:
$type = strtolower($ep->getName());
}
$article_id = $ep->getParam('article_id');
$clang_id = $ep->getParam('clang_id');
$slice_revision = $ep->getParam('slice_revision');
rex_article_slice_history::makeSnapshot($article_id, $clang_id, $type, $slice_revision);
示例11: isActive
public static function isActive(rex_extension_point $ep)
{
$sql = rex_sql::factory();
$sql->setTable(rex::getTablePrefix() . 'article_slice');
$sql->setWhere(array('id' => $ep->getParam('slice_id')));
$sql->select();
$online_from = $sql->getValue('online_from');
$online_to = $sql->getValue('online_to');
if (rex::isBackend() || $sql->getValue('active') == 1 && (empty($online_from) || !empty($online_from) && $online_from < time()) && (empty($online_to) || !empty($online_to) && $online_to >= time())) {
$Subject = $ep->getSubject();
if ($sql->getValue('active') != 1 || !empty($online_from) && $online_from > time() || !empty($online_to) && $online_to <= time()) {
$Subject = str_replace('rex-slice-output', 'rex-slice-output inactive', $Subject);
}
if ($_SESSION['slice_ui']['slice_id'] == $ep->getParam('slice_id')) {
$Subject = str_replace('rex-slice-output', 'rex-slice-output copied', $Subject);
}
return $Subject;
}
return '';
}
示例12: getClassVars
/**
* Returns an Array containing article field names.
*
* @return string[]
*/
public static function getClassVars()
{
if (empty(self::$classVars)) {
self::$classVars = [];
$startId = rex::getProperty('start_article_id');
$file = rex_path::addonCache('structure', $startId . '.1.article');
if (!rex::isBackend() && file_exists($file)) {
// da getClassVars() eine statische Methode ist, können wir hier nicht mit $this->getId() arbeiten!
$genVars = rex_file::getCache($file);
unset($genVars['last_update_stamp']);
foreach ($genVars as $name => $value) {
self::$classVars[] = $name;
}
} else {
// Im Backend die Spalten aus der DB auslesen / via EP holen
$sql = rex_sql::factory();
$sql->setQuery('SELECT * FROM ' . rex::getTablePrefix() . 'article LIMIT 0');
foreach ($sql->getFieldnames() as $field) {
self::$classVars[] = $field;
}
}
}
return self::$classVars;
}
示例13: moveArticle
/**
* Verschieben eines Artikels von einer Kategorie in eine Andere.
*
* @param int $id ArtikelId des zu verschiebenden Artikels
* @param int $from_cat_id KategorieId des Artikels, der Verschoben wird
* @param int $to_cat_id KategorieId in die der Artikel verschoben werden soll
*
* @return bool TRUE bei Erfolg, sonst FALSE
*/
public static function moveArticle($id, $from_cat_id, $to_cat_id)
{
$id = (int) $id;
$to_cat_id = (int) $to_cat_id;
$from_cat_id = (int) $from_cat_id;
if ($from_cat_id == $to_cat_id) {
return false;
}
// Artikel in jeder Sprache verschieben
foreach (rex_clang::getAllIds() as $clang) {
// validierung der id & from_cat_id
$from_sql = rex_sql::factory();
$from_sql->setQuery('select * from ' . rex::getTablePrefix() . 'article where clang_id="' . $clang . '" and startarticle<>1 and id="' . $id . '" and parent_id="' . $from_cat_id . '"');
if ($from_sql->getRows() == 1) {
// validierung der to_cat_id
$to_sql = rex_sql::factory();
$to_sql->setQuery('select * from ' . rex::getTablePrefix() . 'article where clang_id="' . $clang . '" and startarticle=1 and id="' . $to_cat_id . '"');
if ($to_sql->getRows() == 1 || $to_cat_id == 0) {
if ($to_sql->getRows() == 1) {
$parent_id = $to_sql->getValue('id');
$path = $to_sql->getValue('path') . $to_sql->getValue('id') . '|';
$catname = $to_sql->getValue('catname');
} else {
// In RootEbene
$parent_id = 0;
$path = '|';
$catname = $from_sql->getValue('name');
}
$art_sql = rex_sql::factory();
//$art_sql->setDebug();
$art_sql->setTable(rex::getTablePrefix() . 'article');
$art_sql->setValue('parent_id', $parent_id);
$art_sql->setValue('path', $path);
$art_sql->setValue('catname', $catname);
// Artikel als letzten Artikel in die neue Kat einfügen
$art_sql->setValue('priority', '99999');
// Kopierter Artikel offline setzen
$art_sql->setValue('status', $from_sql->getValue('status'));
$art_sql->addGlobalUpdateFields(rex::isBackend() ? null : 'frontend');
$art_sql->setWhere('clang_id="' . $clang . '" and startarticle<>1 and id="' . $id . '" and parent_id="' . $from_cat_id . '"');
$art_sql->update();
// Prios neu berechnen
self::newArtPrio($to_cat_id, $clang, 1, 0);
self::newArtPrio($from_cat_id, $clang, 1, 0);
} else {
return false;
}
} else {
return false;
}
}
// Caches des Artikels löschen, in allen Sprachen
rex_article_cache::delete($id);
// Caches der Kategorien löschen, da sich derin befindliche Artikel geändert haben
rex_article_cache::delete($from_cat_id);
rex_article_cache::delete($to_cat_id);
return true;
}
示例14: loadProperties
/**
* Loads the properties of package.yml.
*/
public function loadProperties()
{
static $cache = null;
if (is_null($cache)) {
$cache = rex_file::getCache(rex_path::coreCache('packages.cache'));
}
$id = $this->getPackageId();
$file = $this->getPath(self::FILE_PACKAGE);
if (!file_exists($file)) {
$this->propertiesLoaded = true;
return;
}
if (isset($cache[$id]) && (!rex::isBackend() || !($user = rex::getUser()) || !$user->isAdmin() || $cache[$id]['timestamp'] >= filemtime($file))) {
$properties = $cache[$id]['data'];
} else {
try {
$properties = rex_file::getConfig($file);
$cache[$id]['timestamp'] = filemtime($file);
$cache[$id]['data'] = $properties;
static $registeredShutdown = false;
if (!$registeredShutdown) {
$registeredShutdown = true;
register_shutdown_function(function () use(&$cache) {
foreach ($cache as $package => $_) {
if (!rex_package::exists($package)) {
unset($cache[$package]);
}
}
rex_file::putCache(rex_path::coreCache('packages.cache'), $cache);
});
}
} catch (rex_yaml_parse_exception $exception) {
if ($this->isInstalled()) {
throw $exception;
}
$properties = [];
}
}
$this->properties = array_intersect_key($this->properties, ['install' => null, 'status' => null]);
if ($properties) {
foreach ($properties as $key => $value) {
if (isset($this->properties[$key])) {
continue;
}
if ('supportpage' !== $key) {
$value = rex_i18n::translateArray($value, false, [$this, 'i18n']);
} elseif (!preg_match('@^https?://@i', $value)) {
$value = 'http://' . $value;
}
$this->properties[$key] = $value;
}
}
$this->propertiesLoaded = true;
}
示例15: tryExecute
public function tryExecute($id, $log = true)
{
$sql = rex_sql::factory();
$sql->setQuery('
SELECT id, name, type, parameters, `interval`
FROM ' . REX_CRONJOB_TABLE . '
WHERE id = ? AND environment LIKE ?
LIMIT 1
', [$id, '%|' . (int) rex::isBackend() . '|%']);
if ($sql->getRows() != 1) {
$this->getManager()->setMessage('Cronjob not found in database');
$this->saveNextTime();
return false;
}
return $this->tryExecuteSql($sql, $log);
}