本文整理汇总了PHP中rex类的典型用法代码示例。如果您正苦于以下问题:PHP rex类的具体用法?PHP rex怎么用?PHP rex使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了rex类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: replaceVars
static function replaceVars($template, $er = array())
{
$r = rex_extension::registerPoint(new rex_extension_point('YFORM_EMAIL_BEFORE_REPLACEVARS', ['template' => $template, 'search_replace' => $er, 'status' => false]));
$template = $r['template'];
$er = $r['search_replace'];
$status = $r['status'];
if ($status) {
return true;
}
$er['REX_SERVER'] = rex::getServer();
$er['REX_ERROR_EMAIL'] = rex::getErrorEmail();
$er['REX_SERVERNAME'] = rex::getServerName();
$er['REX_NOTFOUND_ARTICLE_ID'] = rex_article::getNotfoundArticleId();
$er['REX_ARTICLE_ID'] = rex_article::getCurrentId();
$template['body'] = rex_var::parse($template['body'], '', 'yform_email_template', $er);
$template['body_html'] = rex_var::parse($template['body_html'], '', 'yform_email_template', $er);
// rex_vars bug: sonst wird der Zeilenumbruch entfernt - wenn DATA_VAR am Ende einer Zeile
if (rex_string::versionCompare(rex::getVersion(), '5.0.1', '<')) {
$template['body'] = str_replace("?>\r", "?>\r\n\r", $template['body']);
$template['body'] = str_replace("?>\n", "?>\n\r\n", $template['body']);
$template['body_html'] = str_replace("?>\r", "?>\r\n\r", $template['body_html']);
$template['body_html'] = str_replace("?>\n", "?>\n\r\n", $template['body_html']);
}
$template['body'] = rex_file::getOutput(rex_stream::factory('yform/email/template/' . $template['name'] . '/body', $template['body']));
$template['body_html'] = rex_file::getOutput(rex_stream::factory('yform/email/template/' . $template['name'] . '/body_html', $template['body_html']));
return $template;
}
示例2: factory
/**
* Factory method.
*
* @param string $host Host name
* @param int $port Port number
* @param bool $ssl SSL flag
*
* @return static Socket instance
*
* @see rex_socket::factoryUrl()
*/
public static function factory($host, $port = 80, $ssl = false)
{
if (get_called_class() === __CLASS__ && ($proxy = rex::getProperty('socket_proxy'))) {
return rex_socket_proxy::factoryUrl($proxy)->setDestination($host, $port, $ssl);
}
return new static($host, $port, $ssl);
}
示例3: rex_getUrl
/**
* 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;
}
示例4: getWidget
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;
}
示例5: copyContent
public static function copyContent($article_id, $clang, $from_revision_id, $to_revision_id)
{
if ($from_revision_id == $to_revision_id) {
return false;
}
// clear the revision to which we will later copy all slices
$dc = rex_sql::factory();
// $dc->setDebug();
$dc->setQuery('delete from ' . rex::getTablePrefix() . 'article_slice where article_id=' . $article_id . ' and clang_id=' . $clang . ' and revision=' . $to_revision_id);
$gc = rex_sql::factory();
$gc->setQuery('select * from ' . rex::getTablePrefix() . "article_slice where article_id='{$article_id}' and clang_id='{$clang}' and revision='{$from_revision_id}' ORDER by ctype_id, priority");
$cols = rex_sql::factory();
$cols->setquery('SHOW COLUMNS FROM ' . rex::getTablePrefix() . 'article_slice');
foreach ($gc as $slice) {
$ins = rex_sql::factory();
// $ins->setDebug();
$ins->setTable(rex::getTablePrefix() . 'article_slice');
foreach ($cols as $col) {
$colname = $col->getValue('Field');
$ins->setValue($colname, $slice->getValue($colname));
}
$ins->setValue('id', 0);
// trigger auto increment
$ins->setValue('revision', $to_revision_id);
$ins->addGlobalCreateFields();
$ins->addGlobalUpdateFields();
$ins->insert();
}
rex_article_cache::delete($article_id);
return true;
}
示例6: _getNavigation
/**
* @param rex_be_page[] $blockPages
*
* @return array
*/
private function _getNavigation(array $blockPages)
{
$navigation = [];
foreach ($blockPages as $page) {
if ($page->isHidden() || !$page->checkPermission(rex::getUser())) {
continue;
}
$n = [];
$n['linkClasses'] = [];
$n['itemClasses'] = [];
$n['linkAttr'] = [];
$n['itemAttr'] = [];
$n['itemClasses'][] = $page->getItemAttr('class');
$n['linkClasses'][] = $page->getItemAttr('class');
foreach ($page->getItemAttr(null) as $name => $value) {
$n['itemAttr'][$name] = trim($value);
}
foreach ($page->getLinkAttr(null) as $name => $value) {
$n['linkAttr'][$name] = trim($value);
}
$n['href'] = str_replace('&', '&', $page->getHref());
$n['title'] = $page->getTitle();
$n['active'] = $page->isActive();
$subpages = $page->getSubpages();
if (is_array($subpages) && !empty($subpages)) {
$n['children'] = $this->_getNavigation($subpages);
}
$navigation[] = $n;
}
return $navigation;
}
示例7: execute
public function execute()
{
if (!rex::getUser()->isAdmin()) {
throw new rex_api_exception('user has no permission for this operation!');
}
$type = rex_get('type', 'string');
switch ($type) {
case 'articles':
$prefix = 'art\\_%';
$defaultFields = [['translate:online_from', 'art_online_from', '1', '', '10', ''], ['translate:online_to', 'art_online_to', '2', '', '10', ''], ['translate:description', 'art_description', '3', '', '2', '']];
break;
case 'media':
$prefix = 'med\\_%';
$defaultFields = [['translate:pool_file_description', 'med_description', '1', '', '2', ''], ['translate:pool_file_copyright', 'med_copyright', '2', '', '1', '']];
break;
default:
throw new rex_api_exception(sprintf('metainfo type "%s" does not have default field.', $type));
}
$existing = rex_sql::factory()->getArray('SELECT name FROM ' . rex::getTable('metainfo_field') . ' WHERE name LIKE ?', [$prefix]);
$existing = array_column($existing, 'name', 'name');
foreach ($defaultFields as $field) {
if (!isset($existing[$field[1]])) {
$return = call_user_func_array('rex_metainfo_add_field', $field);
if (is_string($return)) {
throw new rex_api_exception($return);
}
}
}
return new rex_api_result(true, rex_i18n::msg('minfo_default_fields_created'));
}
示例8: rex_getUrl
/**
* 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;
}
示例9: tearDown
public function tearDown()
{
$deleteuser = rex_sql::factory();
$deleteuser->setQuery('DELETE FROM ' . rex::getTablePrefix() . "user WHERE login = '" . $this->login . "' LIMIT 1");
// make sure we don't mess up the global scope
session_destroy();
}
示例10: wildcardFormControlElement
public static function wildcardFormControlElement(\rex_extension_point $ep)
{
if (!\rex::getUser()->getComplexPerm('clang')->hasAll()) {
$subject = $ep->getSubject();
unset($subject['delete']);
$ep->setSubject($subject);
}
}
示例11: getEntriesByTimeline
public static function getEntriesByTimeline()
{
//Start - get all timelines from the database
$sql = rex_sql::factory();
$timelines = $sql->getArray('SELECT `user_id` FROM `' . rex::getTablePrefix() . 'socialhub_facebook_timeline`');
unset($sql);
if (empty($timelines)) {
return false;
}
//End - get all timelines from the database
//Start - get all accounts from the database
$sql = rex_sql::factory();
$accounts = $sql->getArray('SELECT * FROM `' . rex::getTablePrefix() . 'socialhub_facebook_account` ORDER BY `id` ASC');
unset($sql);
if (empty($accounts)) {
return false;
}
//End - get all accounts from the database
//Start - get entries by timeline from twitter
foreach ($timelines as $timeline) {
$fb = new Facebook\Facebook(['app_id' => $accounts[0]['app_id'], 'app_secret' => $accounts[0]['app_secret'], 'default_graph_version' => 'v2.5', 'default_access_token' => $accounts[0]['app_id'] . '|' . $accounts[0]['app_secret']]);
try {
$response = $fb->get('/' . $timeline['user_id'] . '/posts');
} catch (Facebook\Exceptions\FacebookResponseException $e) {
echo rex_view::error('Graph returned an error: ' . $e->getMessage());
} catch (Facebook\Exceptions\FacebookSDKException $e) {
echo rex_view::error('Facebook SDK returned an error: ' . $e->getMessage());
}
if (empty($response)) {
return;
}
$response = json_decode($response->getBody(), true);
foreach ($response['data'] as $post) {
list($userID, $postID) = explode('_', $post['id']);
$newPost = rex_sql::factory();
$newPost->setTable(rex::getTablePrefix() . 'socialhub_entry_timeline');
$newPost->setWhere(['post_id' => $postID]);
$newPost->select();
if ($newPost->getRows() === 0) {
$newPost->reset();
$newPost->setTable(rex::getTablePrefix() . 'socialhub_entry_timeline');
$newPost->setValue('source', 'facebook');
$newPost->setValue('post_id', $postID);
$newPost->setValue('message', $post['message']);
$newPost->setValue('author_id', $userID);
$newPost->setValue('created_time', date('Y-m-d H:i:s', strtotime($post['created_time'])));
$newPost->setValue('query', '/' . $timeline['user_id'] . '/posts');
try {
$newPost->insert();
} catch (rex_sql_exception $e) {
echo rex_view::warning($e->getMessage());
}
}
}
}
//End - get entries by timeline from twitter
}
示例12: executeAction
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;
}
示例13: isValid
public function isValid($value)
{
$sql = rex_sql::factory();
$sql->setQuery('SELECT * FROM ' . rex::getTablePrefix() . 'template WHERE id=' . $value . ' AND active=1');
if ($sql->getRows() != 1 && $value != 0) {
return rex_i18n::msg('system_setting_default_template_id_invalid');
}
return true;
}
示例14: getWidget
public static function getWidget($id, $name, $value, array $args = [])
{
$open_params = '';
if (isset($args['category']) && ($category = (int) $args['category'])) {
$open_params .= '&rex_file_category=' . $category;
}
foreach ($args as $aname => $avalue) {
$open_params .= '&args[' . $aname . ']=' . urlencode($avalue);
}
$wdgtClass = ' rex-js-widget-medialist';
if (isset($args['preview']) && $args['preview']) {
$wdgtClass .= ' rex-js-widget-preview';
if (rex_addon::get('media_manager')->isAvailable()) {
$wdgtClass .= ' rex-js-widget-preview-media-manager';
}
}
$options = '';
$medialistarray = explode(',', $value);
if (is_array($medialistarray)) {
foreach ($medialistarray as $file) {
if ($file != '') {
$options .= '<option value="' . $file . '">' . $file . '</option>';
}
}
}
$disabled = ' disabled';
$open_func = '';
$add_func = '';
$delete_func = '';
$view_func = '';
if (rex::getUser()->getComplexPerm('media')->hasMediaPerm()) {
$disabled = '';
$open_func = 'openREXMedialist(' . $id . ',\'' . $open_params . '\');';
$add_func = 'addREXMedialist(' . $id . ',\'' . $open_params . '\');';
$delete_func = 'deleteREXMedialist(' . $id . ');';
$view_func = 'viewREXMedialist(' . $id . ',\'' . $open_params . '\');';
}
$e = [];
$e['before'] = '<div class="rex-js-widget' . $wdgtClass . '">';
$e['field'] = '<select class="form-control" name="REX_MEDIALIST_SELECT[' . $id . ']" id="REX_MEDIALIST_SELECT_' . $id . '" size="8">' . $options . '</select><input type="hidden" name="' . $name . '" id="REX_MEDIALIST_' . $id . '" value="' . $value . '" />';
$e['moveButtons'] = '
<a href="#" class="btn btn-popup" onclick="moveREXMedialist(' . $id . ',\'top\');return false;" title="' . rex_i18n::msg('var_medialist_move_top') . '"><i class="rex-icon rex-icon-top"></i></a>
<a href="#" class="btn btn-popup" onclick="moveREXMedialist(' . $id . ',\'up\');return false;" title="' . rex_i18n::msg('var_medialist_move_up') . '"><i class="rex-icon rex-icon-up"></i></a>
<a href="#" class="btn btn-popup" onclick="moveREXMedialist(' . $id . ',\'down\');return false;" title="' . rex_i18n::msg('var_medialist_move_down') . '"><i class="rex-icon rex-icon-down"></i></a>
<a href="#" class="btn btn-popup" onclick="moveREXMedialist(' . $id . ',\'bottom\');return false;" title="' . rex_i18n::msg('var_medialist_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_media_open') . '"' . $disabled . '><i class="rex-icon rex-icon-open-mediapool"></i></a>
<a href="#" class="btn btn-popup" onclick="' . $add_func . 'return false;" title="' . rex_i18n::msg('var_media_new') . '"' . $disabled . '><i class="rex-icon rex-icon-add-media"></i></a>
<a href="#" class="btn btn-popup" onclick="' . $delete_func . 'return false;" title="' . rex_i18n::msg('var_media_remove') . '"' . $disabled . '><i class="rex-icon rex-icon-delete-media"></i></a>
<a href="#" class="btn btn-popup" onclick="' . $view_func . 'return false;" title="' . rex_i18n::msg('var_media_view') . '"' . $disabled . '><i class="rex-icon rex-icon-view-media"></i></a>';
$e['after'] = '<div class="rex-js-media-preview"></div></div>';
$fragment = new rex_fragment();
$fragment->setVar('elements', [$e], false);
$media = $fragment->parse('core/form/widget_list.php');
return $media;
}
示例15: checkTables
private static function checkTables()
{
$slices_table = rex_sql_table::get(rex::getTable('article_slice'));
$history_table = rex_sql_table::get(self::getTable());
foreach ($slices_table->getColumns() as $column) {
if (strtolower($column->getName()) != 'id') {
$history_table->ensureColumn($column)->alter();
}
}
}