Example #1
0
/**
 * Gibt eine Url zu einem Artikel zurück.
 *
 * @param int|null $id
 * @param int|null $clang     SprachId des Artikels
 * @param array    $params    Array von Parametern
 * @param string   $separator
 *
 * @return string
 *
 * @package redaxo\structure
 */
function rex_getUrl($id = null, $clang = null, array $params = [], $separator = '&')
{
    $id = (int) $id;
    $clang = (int) $clang;
    // ----- get id
    if ($id == 0) {
        $id = rex::getProperty('article_id');
    }
    // ----- get clang
    // Wenn eine rexExtension vorhanden ist, immer die clang mitgeben!
    // Die rexExtension muss selbst entscheiden was sie damit macht
    if (!rex_clang::exists($clang) && (rex_clang::count() > 1 || rex_extension::isRegistered('URL_REWRITE'))) {
        $clang = rex_clang::getCurrentId();
    }
    // ----- EXTENSION POINT
    $url = rex_extension::registerPoint(new rex_extension_point('URL_REWRITE', '', ['id' => $id, 'clang' => $clang, 'params' => $params, 'separator' => $separator]));
    if ($url == '') {
        if (rex_clang::count() > 1) {
            $clang = $separator . 'clang=' . $clang;
        } else {
            $clang = '';
        }
        $params = rex_string::buildQuery($params, $separator);
        $params = $params ? $separator . $params : '';
        $url = rex_url::frontendController() . '?article_id=' . $id . $clang . $params;
    }
    return $url;
}
Example #2
0
 public function setClang($value)
 {
     if (!rex_clang::exists($value)) {
         $value = rex_clang::getCurrentId();
     }
     $this->clang = $value;
 }
Example #3
0
/**
 * Gibt eine Url zu einem Artikel zurück.
 *
 * @param string       $_id
 * @param int|string   $_clang  SprachId des Artikels
 * @param array|string $_params Array von Parametern
 * @param bool         $escape  Flag whether the argument separator "&" should be escaped (&)
 *
 * @return string
 *
 * @package redaxo\structure
 */
function rex_getUrl($_id = '', $_clang = '', $_params = '', $escape = true)
{
    $id = (int) $_id;
    $clang = (int) $_clang;
    // ----- get id
    if ($id == 0) {
        $id = rex::getProperty('article_id');
    }
    // ----- get clang
    // Wenn eine rexExtension vorhanden ist, immer die clang mitgeben!
    // Die rexExtension muss selbst entscheiden was sie damit macht
    if ($_clang === '' && (rex_clang::count() > 1 || rex_extension::isRegistered('URL_REWRITE'))) {
        $clang = rex_clang::getCurrentId();
    }
    // ----- get params
    $param_string = rex_param_string($_params, $escape ? '&' : '&');
    $name = 'NoName';
    if ($id != 0) {
        $ooa = rex_article::get($id, $clang);
        if ($ooa) {
            $name = rex_parse_article_name($ooa->getName());
        }
    }
    // ----- EXTENSION POINT
    $url = rex_extension::registerPoint(new rex_extension_point('URL_REWRITE', '', ['id' => $id, 'name' => $name, 'clang' => $clang, 'params' => $param_string, 'escape' => $escape]));
    if ($url == '') {
        $_clang = '';
        if (rex_clang::count() > 1) {
            $_clang .= ($escape ? '&' : '&') . 'clang=' . $clang;
        }
        $url = rex_url::frontendController() . '?article_id=' . $id . $_clang . $param_string;
    }
    return $url;
}
Example #4
0
 public static function getWidget($id, $name, $value, array $args = [])
 {
     $art_name = '';
     $art = rex_article::get($value);
     $category = 0;
     // Falls ein Artikel vorausgewählt ist, dessen Namen anzeigen und beim öffnen der Linkmap dessen Kategorie anzeigen
     if ($art instanceof rex_article) {
         $art_name = $art->getName();
         $category = $art->getCategoryId();
     }
     $open_params = '&clang=' . rex_clang::getCurrentId();
     if ($category || isset($args['category']) && ($category = (int) $args['category'])) {
         $open_params .= '&category_id=' . $category;
     }
     $class = ' rex-disabled';
     $open_func = '';
     $delete_func = '';
     if (rex::getUser()->getComplexPerm('structure')->hasStructurePerm()) {
         $class = '';
         $open_func = 'openLinkMap(\'REX_LINK_' . $id . '\', \'' . $open_params . '\');';
         $delete_func = 'deleteREXLink(' . $id . ');';
     }
     $e = [];
     $e['field'] = '<input class="form-control" type="text" name="REX_LINK_NAME[' . $id . ']" value="' . htmlspecialchars($art_name) . '" id="REX_LINK_' . $id . '_NAME" readonly="readonly" /><input type="hidden" name="' . $name . '" id="REX_LINK_' . $id . '" value="' . $value . '" />';
     $e['functionButtons'] = '
                     <a href="#" class="btn btn-popup' . $class . '" onclick="' . $open_func . 'return false;" title="' . rex_i18n::msg('var_link_open') . '"><i class="rex-icon rex-icon-open-linkmap"></i></a>
                     <a href="#" class="btn btn-popup' . $class . '" onclick="' . $delete_func . 'return false;" title="' . rex_i18n::msg('var_link_delete') . '"><i class="rex-icon rex-icon-delete-link"></i></a>';
     $fragment = new rex_fragment();
     $fragment->setVar('elements', [$e], false);
     $media = $fragment->parse('core/form/widget.php');
     return $media;
 }
Example #5
0
 public static function getArticle($id, $ctype = -1, $clang = null)
 {
     if ($clang === null) {
         $clang = rex_clang::getCurrentId();
     }
     $article = new rex_article_content($id, $clang);
     return $article->getArticle($ctype);
 }
Example #6
0
 public static function getCategoryValue($id, $field, $clang = null)
 {
     if ($clang === null) {
         $clang = rex_clang::getCurrentId();
     }
     $cat = rex_category::get($id, $clang);
     if ($cat) {
         return htmlspecialchars($cat->getValue($field));
     }
 }
Example #7
0
 public function __construct($article_id = 0, $clang = null)
 {
     if ($article_id == 0) {
         $article_id = rex_article::getCurrentId();
     }
     if (is_null($clang)) {
         $clang = rex_clang::getCurrentId();
     }
     if ($article = rex_article::get($article_id, $clang)) {
         $this->article = $article;
         $this->domain = rex_yrewrite::getDomainByArticleId($article_id, $clang);
     }
 }
Example #8
0
 public static function getWidget($id, $name, $value, array $args = [])
 {
     $open_params = '&clang=' . rex_clang::getCurrentId();
     if (isset($args['category']) && ($category = (int) $args['category'])) {
         $open_params .= '&amp;category_id=' . $category;
     }
     $options = '';
     $linklistarray = explode(',', $value);
     if (is_array($linklistarray)) {
         foreach ($linklistarray as $link) {
             if ($link != '') {
                 if ($article = rex_article::get($link)) {
                     $options .= '<option value="' . $link . '">' . htmlspecialchars($article->getName()) . '</option>';
                 }
             }
         }
     }
     $disabled = ' disabled';
     $open_func = '';
     $delete_func = '';
     if (rex::getUser()->getComplexPerm('structure')->hasStructurePerm()) {
         $disabled = '';
         $open_func = 'openREXLinklist(' . $id . ', \'' . $open_params . '\');';
         $delete_func = 'deleteREXLinklist(' . $id . ');';
     }
     $e = [];
     $e['field'] = '
             <select class="form-control" name="REX_LINKLIST_SELECT[' . $id . ']" id="REX_LINKLIST_SELECT_' . $id . '" size="10">
                 ' . $options . '
             </select>
             <input type="hidden" name="' . $name . '" id="REX_LINKLIST_' . $id . '" value="' . $value . '" />';
     $e['moveButtons'] = '
                 <a href="#" class="btn btn-popup" onclick="moveREXLinklist(' . $id . ',\'top\');return false;" title="' . rex_i18n::msg('var_linklist_move_top') . '"><i class="rex-icon rex-icon-top"></i></a>
                 <a href="#" class="btn btn-popup" onclick="moveREXLinklist(' . $id . ',\'up\');return false;" title="' . rex_i18n::msg('var_linklist_move_up') . '"><i class="rex-icon rex-icon-up"></i></a>
                 <a href="#" class="btn btn-popup" onclick="moveREXLinklist(' . $id . ',\'down\');return false;" title="' . rex_i18n::msg('var_linklist_move_down') . '"><i class="rex-icon rex-icon-down"></i></a>
                 <a href="#" class="btn btn-popup" onclick="moveREXLinklist(' . $id . ',\'bottom\');return false;" title="' . rex_i18n::msg('var_linklist_move_bottom') . '"><i class="rex-icon rex-icon-bottom"></i></a>';
     $e['functionButtons'] = '
                 <a href="#" class="btn btn-popup" onclick="' . $open_func . 'return false;" title="' . rex_i18n::msg('var_link_open') . '"' . $disabled . '><i class="rex-icon rex-icon-open-linkmap"></i></a>
                 <a href="#" class="btn btn-popup" onclick="' . $delete_func . 'return false;" title="' . rex_i18n::msg('var_link_delete') . '"' . $disabled . '><i class="rex-icon rex-icon-delete-link"></i></a>';
     $fragment = new rex_fragment();
     $fragment->setVar('elements', [$e], false);
     $link = $fragment->parse('core/form/widget_list.php');
     return $link;
 }
Example #9
0
 /**
  * Returns the replaced content.
  *
  * @param string $content
  * @param int    $clang_id
  *
  * @return string
  */
 public static function replace($content, $clang_id = null)
 {
     if (trim($content) == '') {
         return $content;
     }
     if (!$clang_id) {
         $clang_id = \rex_clang::getCurrentId();
     }
     $sql = \rex_sql::factory();
     $sql->setQuery('SELECT `wildcard`, `replace` FROM ' . \rex::getTable('sprog_wildcard') . ' WHERE clang_id = "' . $clang_id . '"');
     $search = [];
     $replace = [];
     $rows = $sql->getRows();
     for ($i = 1; $i <= $rows; $i++, $sql->next()) {
         $search[] = self::getRegexp($sql->getValue('wildcard'));
         $replace[] = nl2br($sql->getValue('replace'));
     }
     return preg_replace($search, $replace, $content);
 }
Example #10
0
 /**
  * @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);
     });
 }
 $value = $values[$nummer];
 $zaehler = $zaehler + 1;
 $outback .= '<div class="bereichswrapper"><h2>Bereich ' . $zaehler . '</h2>' . PHP_EOL;
 /****
 *
 *     Link
 *
 ****/
 $link = '';
 $linkanfang = '';
 $linkende = '';
 $outback_link = '';
 if ($value['link_intern'] or $value['link_extern'] != '') {
     $outback_link .= '<h3>Link</h3>' . PHP_EOL;
     if ($value['link_intern'] != 0) {
         $linkanfang = '<a href="' . rex_geturl($value['link_intern'], rex_clang::getCurrentId()) . '">';
         $article = rex_article::get($value['link_intern']);
         $name = $article->getName();
         $outback_link .= '
     <div class="form-group">
      <label class="col-sm-3 control-label">Link intern</label>
      <div class="col-sm-9">
        <a href="index.php?page=content&article_id=' . $value['link_intern'] . '&mode=edit">' . $name . ' (ID = ' . $value['link_intern'] . ')</a>
      </div>
     </div>' . PHP_EOL;
     }
     if ($value['link_extern'] != '') {
         $linkanfang = '<a class="extern" href="' . $value['link_extern'] . '">';
         $outback_link .= '
     <div class="form-group">
       <label class="col-sm-3 control-label">Link extern</label>
Example #12
0
 Zu Ihrer Sicherheit wurde die IBAN anonymisiert. 

EOD;
    $form_notice_reload = "<br />Sie haben versucht die Seite neu zu laden. <br />Ihre Nachricht wurde bereits verschickt";
}
// Sprache 1 -- z.B. Englisch
if (rex_clang::getCurrentId() == 1) {
    $form_error = <<<EOD
Unfortunately we have been unable to process your request. <br/>
Please check the information you have provided.
EOD;
    $form_notice_reload = "<br />You have tried to reload this page. Your message has already been sent.";
}
// Sprache 2 -- z.B. Niederlande
if (rex_clang::getCurrentId() == 2) {
    $form_error = <<<EOD
We konden uw aanvraag helaas niet verwerken.<br/>
Controleer uw gegevens.
EOD;
    $form_notice_reload = "<br />You have tried to reload this page. Your message has been already sent.";
}
// E-Mail-HEADER
$form_template_html = '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="de" lang="de">
<head>
<meta http-equiv="Content-Type" content="text/html; charset="UTF-8" />
<title>NACHRICHTEN-ÜBERMITTLUNG</title>
<style type="text/css">
<!--
body {
Example #13
0
        if (rex_be_controller::getCurrentPagePart(1) == 'content') {
            rex_be_controller::getPageObject('structure')->setIsActive(true);
        }
    });
    if (rex_be_controller::getCurrentPagePart(1) == 'system') {
        rex_system_setting::register(new rex_system_setting_default_template_id());
    }
    rex_extension::register('CLANG_DELETED', function (rex_extension_point $ep) {
        $del = rex_sql::factory();
        $del->setQuery('delete from ' . rex::getTablePrefix() . "article_slice where clang_id='" . $ep->getParam('clang')->getId() . "'");
    });
} else {
    rex_extension::register('FE_OUTPUT', function (rex_extension_point $ep) {
        $content = $ep->getSubject();
        $article = new rex_article_content();
        $article->setCLang(rex_clang::getCurrentId());
        if ($article->setArticleId(rex_article::getCurrentId())) {
            $content .= $article->getArticleTemplate();
        } else {
            $content .= 'Kein Startartikel selektiert / No starting Article selected. Please click here to enter <a href="' . rex_url::backendController() . '">redaxo</a>';
            rex_response::sendPage($content);
            exit;
        }
        $art_id = $article->getArticleId();
        if ($art_id == rex_article::getNotfoundArticleId() && $art_id != rex_article::getSiteStartArticleId()) {
            rex_response::setStatus(rex_response::HTTP_NOT_FOUND);
        }
        // ----- inhalt ausgeben
        rex_response::sendPage($content, $article->getValue('updatedate'));
    });
}
Example #14
0
 /**
  * Return all slices for an article that have a certain
  * module type.
  *
  * @param int      $an_article_id
  * @param int      $a_moduletype_id
  * @param bool|int $clang
  * @param int      $revision
  *
  * @return self[]
  */
 public static function getSlicesForArticleOfType($an_article_id, $a_moduletype_id, $clang = false, $revision = 0)
 {
     if ($clang === false) {
         $clang = rex_clang::getCurrentId();
     }
     return self::getSlicesWhere('article_id=? AND clang_id=? AND module_id=? AND revision=?', [$an_article_id, $clang, $a_moduletype_id, $revision]);
 }
Example #15
0
 public static function prepare()
 {
     $clang = rex_clang::getCurrentId();
     // call_by_article allowed
     if (self::$call_by_article_id == 'allowed' && rex_request('article_id', 'int') > 0) {
         $url = rex_getUrl(rex_request('article_id', 'int'));
     } else {
         if (!isset($_SERVER['REQUEST_URI'])) {
             $_SERVER['REQUEST_URI'] = substr($_SERVER['PHP_SELF'], 1);
             if (isset($_SERVER['QUERY_STRING'])) {
                 $_SERVER['REQUEST_URI'] .= '?' . $_SERVER['QUERY_STRING'];
             }
         }
         $url = urldecode($_SERVER['REQUEST_URI']);
     }
     // because of server differences
     if (substr($url, 0, 1) == '/') {
         $url = substr($url, 1);
     }
     // delete params
     if (($pos = strpos($url, '?')) !== false) {
         $url = substr($url, 0, $pos);
     }
     // delete anker
     if (($pos = strpos($url, '#')) !== false) {
         $url = substr($url, 0, $pos);
     }
     $host = self::getHost();
     $http = 'http://';
     if (self::isHttps()) {
         $http = 'https://';
     }
     if (isset(self::$paths['paths'][$host])) {
         $domain = self::$domainsByName[$host];
     } else {
         // check for aliases
         if (isset(self::$aliasDomains[$host])) {
             /** @var rex_yrewrite_domain $domain */
             $domain = self::$aliasDomains[$host]['domain'];
             if (!$url && isset(self::$paths['paths'][$domain->getName()][$domain->getStartId()][self::$aliasDomains[$host]['clang_start']])) {
                 $url = self::$paths['paths'][$domain->getName()][$domain->getStartId()][self::$aliasDomains[$host]['clang_start']];
             }
             // forward to original domain permanent move 301
             header('HTTP/1.1 301 Moved Permanently');
             header('Location: ' . $http . $domain->getName() . '/' . $url);
             exit;
             // no domain, no alias, domain with root mountpoint ?
         } elseif (isset(self::$domainsByMountId[0][$clang])) {
             $domain = self::$domainsByMountId[0][$clang];
             // no root domain -> undefined
         } else {
             $domain = self::$domainsByName['undefined'];
         }
     }
     rex::setProperty('domain_article_id', $domain->getMountId());
     rex::setProperty('start_article_id', $domain->getStartId());
     rex::setProperty('notfound_article_id', $domain->getNotfoundId());
     rex::setProperty('server', $http . $domain->getName());
     // if no path -> startarticle
     if ($url == '') {
         rex_addon::get('structure')->setProperty('article_id', $domain->getStartId());
         rex_clang::setCurrentId($domain->getStartClang());
         return true;
     }
     // normal exact check
     foreach (self::$paths['paths'][$domain->getName()] as $i_id => $i_cls) {
         foreach (rex_clang::getAllIds() as $clang_id) {
             if (isset($i_cls[$clang_id]) && ($i_cls[$clang_id] == $url || $i_cls[$clang_id] . '/' == $url)) {
                 rex_addon::get('structure')->setProperty('article_id', $i_id);
                 rex_clang::setCurrentId($clang_id);
                 return true;
             }
         }
     }
     $params = rex_extension::registerPoint(new rex_extension_point('YREWRITE_PREPARE', '', ['url' => $url, 'domain' => $domain, 'http' => $http]));
     if (isset($params['article_id']) && $params['article_id'] > 0) {
         if (isset($params['clang']) && $params['clang'] > -1) {
             $clang = $params['clang'];
         }
         if ($article = rex_article::get($params['article_id'], $clang)) {
             rex_addon::get('structure')->setProperty('article_id', $params['article_id']);
             rex_clang::setCurrentId($clang);
             return true;
         }
     }
     // no article found -> domain not found article
     rex_addon::get('structure')->setProperty('article_id', $domain->getNotfoundId());
     rex_clang::setCurrentId($domain->getStartClang());
     foreach (self::$paths['paths'][$domain->getName()][$domain->getStartId()] as $clang => $clangUrl) {
         if ($clang != $domain->getStartClang() && 0 === strpos($url, $clangUrl)) {
             rex_clang::setCurrentId($clang);
             break;
         }
     }
     return true;
 }
Example #16
0
                $select .= '<option value="' . $version['history_date'] . '">' . $version['history_date'] . '</option>';
            }
            $content1select = '<select id="content-history-select-date-1" class="content-history-select" data-iframe="content-history-iframe-1" style="">' . $select . '</select>';
            $content1iframe = '<iframe id="content-history-iframe-1" class="history-iframe"></iframe>';
            $content2select = '<select id="content-history-select-date-2" class="content-history-select" data-iframe="content-history-iframe-2">' . $select . '</select>';
            $content2iframe = '<iframe id="content-history-iframe-2" class="history-iframe"></iframe>';
            $button_restore = '<a class="btn btn-apply" href="javascript:rex_history_snapVersion(\'content-history-select-date-2\');">' . $this->i18n('snapshot_reactivate') . '</a>';
            // fragment holen und ausgeben
            $fragment = new rex_fragment();
            $fragment->setVar('title', $this->i18n('overview_versions'));
            $fragment->setVar('info', $info, false);
            $fragment->setVar('content1select', $content1select, false);
            $fragment->setVar('content1iframe', $content1iframe, false);
            $fragment->setVar('content2select', $content2select, false);
            $fragment->setVar('content2iframe', $content2iframe, false);
            $fragment->setVar('button_restore', $button_restore, false);
            echo $fragment->parse('history/layer.php');
            exit;
    }
    rex_extension::register('STRUCTURE_CONTENT_HEADER', function (rex_extension_point $ep) {
        if ($ep->getParam('page') == 'content/edit') {
            echo '<script>
                    var history_article_id = ' . rex_article::getCurrentId() . ';
                    var history_clang_id = ' . rex_clang::getCurrentId() . ';
                    var history_ctype_id = ' . rex_request('ctype', 'int', 0) . ';
                    var history_revision = ' . rex_request('rex_set_version', 'int', 0) . ';
                    var history_article_link = "' . rex_getUrl(rex_article::getCurrentId(), rex_clang::getCurrentId(), ['history_revision' => rex_request('rex_set_version', 'int', 0)], '&') . '";
                    </script>';
        }
    });
}
Example #17
0
 public function setRedaxoVars($aid = '', $clang = '', $params = [])
 {
     if ($clang == '') {
         $clang = rex_clang::getCurrentId();
     }
     if ($aid == '') {
         $aid = rex_article::getCurrentId();
     }
     $this->setObjectparams('form_action', rex_getUrl($aid, $clang, $params));
 }