本文整理汇总了PHP中rex_extension类的典型用法代码示例。如果您正苦于以下问题:PHP rex_extension类的具体用法?PHP rex_extension怎么用?PHP rex_extension使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了rex_extension类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: factory
static function factory($query, $rowsPerPage = 30, $listName = null, $debug = false, $class = null)
{
if (!$class) {
$class = rex_extension::registerPoint(new rex_extension_point('REX_LIST_CLASSNAME', 'rex_yform_list', ['query' => $query, 'rowsPerPage' => $rowsPerPage, 'listName' => $listName, 'debug' => $debug]));
}
return new $class($query, $rowsPerPage, $listName, $debug);
}
示例2: 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;
}
示例3: 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;
}
示例4: rex_delete_cache
/**
* 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')));
}
示例5: __construct
public function __construct($tag = '', rex_form $table = null, array $attributes = [])
{
parent::__construct('', $table, $attributes);
$this->labelField = '';
$this->whereCondition = '';
$this->primaryKey = 'id';
$this->firstOptionMsg = 'form_field_first_priority';
$this->optionMsg = 'form_field_after_priority';
$this->select->setSize(1);
rex_extension::register('REX_FORM_SAVED', [$this, 'organizePriorities']);
}
示例6: registerPoint
/**
* Extends rex_extension::registerPoint() with FirePHP logging.
*/
public static function registerPoint(rex_extension_point $extensionPoint)
{
$coreTimer = rex::getProperty('timer');
$absDur = $coreTimer->getFormattedDelta();
// start timer for this extensionPoint
$timer = new rex_timer();
$res = parent::registerPoint($extensionPoint);
$epDur = $timer->getFormattedDelta();
$memory = rex_formatter::bytes(memory_get_usage(true), [3]);
self::$log[] = ['type' => 'EP', 'ep' => $extensionPoint->getName(), 'started' => $absDur, 'duration' => $epDur, 'memory' => $memory, 'subject' => $extensionPoint->getSubject(), 'params' => $extensionPoint->getParams(), 'read_only' => $extensionPoint->isReadonly(), 'result' => $res, 'timer' => $epDur];
return $res;
}
示例7: executeAction
function executeAction()
{
$sql = rex_sql::factory();
if ($this->params['debug']) {
$sql->debugsql = true;
}
$main_table = '';
if (!($main_table = $this->getElement(2))) {
$main_table = $this->params['main_table'];
}
if ($main_table == '') {
$this->params['form_show'] = true;
$this->params['hasWarnings'] = true;
$this->params['warning_messages'][] = $this->params['Error-Code-InsertQueryError'];
return false;
}
$sql->setTable($main_table);
$where = '';
if ($where = $this->getElement(3)) {
if ($where == 'main_where') {
$where = $this->params['main_where'];
}
}
foreach ($this->params['value_pool']['sql'] as $key => $value) {
$sql->setValue($key, $value);
if ($where != '') {
$where = str_replace('###' . $key . '###', addslashes($value), $where);
}
}
try {
if ($where != '') {
$sql->setWhere($where);
$saved = $sql->update();
$flag = 'update';
} else {
$saved = $sql->insert();
$flag = 'insert';
$id = $sql->getLastId();
$this->params['main_id'] = $id;
$this->params['value_pool']['email']['ID'] = $id;
// $this->params["value_pool"]["sql"]["ID"] = $id;
}
} catch (Exception $sql) {
$this->params['form_show'] = true;
$this->params['hasWarnings'] = true;
$this->params['warning_messages'][] = $this->params['Error-Code-InsertQueryError'];
echo $sql->getMessage();
}
rex_extension::registerPoint(new rex_extension_point('REX_YFORM_SAVED'), $sql, array('form' => $this, 'sql' => $sql, 'yform' => true));
}
示例8: deleteCLang
/**
* Löscht eine Clang.
*
* @param int $id Zu löschende ClangId
*
* @throws rex_exception
*/
public static function deleteCLang($id)
{
$startClang = rex_clang::getStartId();
if ($id == $startClang) {
throw new rex_functional_exception(rex_i18n::msg('clang_error_startidcanotbedeleted', $startClang));
}
if (!rex_clang::exists($id)) {
throw new rex_functional_exception(rex_i18n::msg('clang_error_idcanotbedeleted', $id));
}
$clang = rex_clang::get($id);
$del = rex_sql::factory();
$del->setQuery('delete from ' . rex::getTablePrefix() . 'clang where id=?', [$id]);
rex_sql_util::organizePriorities(rex::getTable('clang'), 'priority', '', 'priority');
rex_delete_cache();
// ----- EXTENSION POINT
rex_extension::registerPoint(new rex_extension_point('CLANG_DELETED', '', ['id' => $clang->getId(), 'name' => $clang->getName(), 'clang' => $clang]));
}
示例9: testRegister
public function testRegister()
{
$EP = 'TEST_EP_LEVELS';
$callback = function ($str) {
return function (rex_extension_point $ep) use($str) {
return $ep->getSubject() . $str . ' ';
};
};
rex_extension::register($EP, $callback('late1'), rex_extension::LATE);
rex_extension::register($EP, $callback('normal1'));
rex_extension::register($EP, $callback('early1'), rex_extension::EARLY);
rex_extension::register($EP, $callback('late2'), rex_extension::LATE);
rex_extension::register($EP, $callback('normal2'), rex_extension::NORMAL);
rex_extension::register($EP, $callback('early2'), rex_extension::EARLY);
$expected = 'early1 early2 normal1 normal2 late1 late2 ';
$actual = rex_extension::registerPoint(new rex_extension_point($EP, ''));
$this->assertEquals($expected, $actual);
}
示例10: applyEffects
protected function applyEffects($type)
{
$this->type = $type;
if (!$this->isCached($type)) {
$set = $this->effectsFromType($type);
$set = rex_extension::registerPoint(new rex_extension_point('MEDIA_MANAGER_FILTERSET', $set, ['rex_media_type' => $type]));
if (count($set) == 0) {
return $this->media;
}
// execute effects on image
foreach ($set as $effect_params) {
$effect_class = 'rex_effect_' . $effect_params['effect'];
$effect = new $effect_class();
$effect->setMedia($this->media);
$effect->setParams($effect_params['params']);
$effect->execute();
}
}
}
示例11: handleSave
protected function handleSave(array $params, rex_sql $sqlFields)
{
// Nur speichern wenn auch das MetaForm ausgefüllt wurde
// z.b. nicht speichern wenn über be_search select navigiert wurde
if (!rex_post('savemeta', 'boolean')) {
return $params;
}
$article = rex_sql::factory();
// $article->setDebug();
$article->setTable(rex::getTablePrefix() . 'article');
$article->setWhere('id=:id AND clang_id=:clang', ['id' => $params['id'], 'clang' => $params['clang']]);
$article->setValue('name', rex_post('meta_article_name', 'string'));
parent::fetchRequestValues($params, $article, $sqlFields);
// do the save only when metafields are defined
if ($article->hasValues()) {
$article->update();
}
rex_article_cache::deleteMeta($params['id'], $params['clang']);
rex_extension::registerPoint(new rex_extension_point('ART_META_UPDATED', '', $params));
return $params;
}
示例12: show_counter
public function show_counter()
{
$counter = 0;
$current_user = rex::getUser()->getId();
$sql_counter = rex_sql::factory();
//$sql_counter->setDebug();
$sql_counter->setQuery('SELECT counter FROM rex_aufgaben_user_settings WHERE user = ' . $current_user);
if ($sql_counter->getRows() > 0) {
$ersetzen = '</i> Aufgaben <span class="label label-default">' . $counter . '</span></a>';
$counter = $sql_counter->getValue('counter');
if ($counter > 0) {
$ersetzen = '</i> Aufgaben <span class="label label-danger">' . $counter . '</span></a>';
} else {
$ersetzen = '</i> Aufgaben <span class="label label-default">' . $counter . '</span></a>';
}
rex_extension::register('OUTPUT_FILTER', function (rex_extension_point $ep) use($ersetzen) {
$suchmuster = '</i> Aufgaben';
$ersetzen = $ersetzen;
$ep->setSubject(str_replace($suchmuster, $ersetzen, $ep->getSubject()));
});
}
}
示例13: sendMail
static function sendMail($template, $template_name = '')
{
$r = rex_extension::registerPoint(new rex_extension_point('YFORM_EMAIL_BEFORE_SEND', ['template' => $template, 'template_name' => $template_name, 'status' => false]));
$template = $r['template'];
$template_name = $r['template_name'];
$status = $r['status'];
if ($status) {
return true;
}
$mail = new rex_mailer();
$mail->AddAddress($template['mail_to'], $template['mail_to_name']);
$mail->SetFrom($template['mail_from'], $template['mail_from_name']);
$mail->Subject = $template['subject'];
$mail->Body = $template['body'];
if ($template['body_html'] != '') {
$mail->AltBody = $template['body'];
$mail->MsgHTML($template['body_html']);
} else {
$mail->Body = strip_tags($template['body']);
}
if (is_array($template['attachments'])) {
foreach ($template['attachments'] as $f) {
$mail->AddAttachment($f['path'], $f['name']);
}
}
if ($mail->Send()) {
$template['email_subject'] = $template['subject'];
rex_extension::registerPoint(new rex_extension_point('YFORM_EMAIL_SENT', $template_name, $template, true));
// read only
return true;
} else {
$template['email_subject'] = $template['subject'];
rex_extension::registerPoint(new rex_extension_point('YFORM_EMAIL_SENT_FAILED', $template_name, $template, true));
// read only
return false;
}
}
示例14: init
public function init()
{
// ----- EXTENSION POINT
// IDs aller Feldtypen bei denen das Parameter-Feld eingeblendet werden soll
$typeFields = rex_extension::registerPoint(new rex_extension_point('METAINFO_TYPE_FIELDS', [REX_METAINFO_FIELD_SELECT, REX_METAINFO_FIELD_RADIO, REX_METAINFO_FIELD_CHECKBOX, REX_METAINFO_FIELD_REX_MEDIA_WIDGET, REX_METAINFO_FIELD_REX_MEDIALIST_WIDGET, REX_METAINFO_FIELD_REX_LINK_WIDGET, REX_METAINFO_FIELD_REX_LINKLIST_WIDGET]));
$field = $this->addReadOnlyField('prefix', $this->metaPrefix);
$field->setLabel(rex_i18n::msg('minfo_field_label_prefix'));
$field = $this->addTextField('name');
$field->setLabel(rex_i18n::msg('minfo_field_label_name'));
$field = $this->addSelectField('priority');
$field->setLabel(rex_i18n::msg('minfo_field_label_priority'));
$select = $field->getSelect();
$select->setSize(1);
$select->addOption(rex_i18n::msg('minfo_field_first_priority'), 1);
// Im Edit Mode das Feld selbst nicht als Position einf�gen
$qry = 'SELECT name,priority FROM ' . $this->tableName . ' WHERE `name` LIKE "' . $this->metaPrefix . '%"';
if ($this->isEditMode()) {
$qry .= ' AND id != ' . $this->getParam('field_id');
}
$qry .= ' ORDER BY priority';
$sql = rex_sql::factory();
$sql->setQuery($qry);
$value = 1;
for ($i = 0; $i < $sql->getRows(); ++$i) {
$value = $sql->getValue('priority') + 1;
$select->addOption(rex_i18n::rawMsg('minfo_field_after_priority', $sql->getValue('name')), $value);
$sql->next();
}
if (!$this->isEditMode()) {
$select->setSelected($value);
}
$field = $this->addTextField('title');
$field->setLabel(rex_i18n::msg('minfo_field_label_title'));
$field->setNotice(rex_i18n::msg('minfo_field_notice_title'));
$gq = rex_sql::factory();
$gq->setQuery('SELECT dbtype,id FROM ' . rex::getTablePrefix() . 'metainfo_type');
$textFields = [];
foreach ($gq->getArray() as $f) {
if ($f['dbtype'] == 'text') {
$textFields[$f['id']] = $f['id'];
}
}
$field = $this->addSelectField('type_id');
$field->setLabel(rex_i18n::msg('minfo_field_label_type'));
$field->setAttribute('onchange', 'meta_checkConditionalFields(this, new Array(' . implode(',', $typeFields) . '), new Array(' . implode(',', $textFields) . '));');
$select = $field->getSelect();
$select->setSize(1);
$qry = 'SELECT label,id FROM ' . rex::getTablePrefix() . 'metainfo_type';
$select->addSqlOptions($qry);
$notices = '';
for ($i = 1; $i < REX_METAINFO_FIELD_COUNT; ++$i) {
if (rex_i18n::hasMsg('minfo_field_params_notice_' . $i)) {
$notices .= '<span id="metainfo-field-params-notice-' . $i . '" style="display:none">' . rex_i18n::msg('minfo_field_params_notice_' . $i) . '</span>' . "\n";
}
}
$notices .= '
<script type="text/javascript">
var needle = new getObj("' . $field->getAttribute('id') . '");
meta_checkConditionalFields(needle.obj, new Array(' . implode(',', $typeFields) . '), new Array(' . implode(',', $textFields) . '));
</script>';
$field = $this->addTextAreaField('params');
$field->setLabel(rex_i18n::msg('minfo_field_label_params'));
$field->setNotice($notices);
$field = $this->addTextAreaField('attributes');
$field->setLabel(rex_i18n::msg('minfo_field_label_attributes'));
$notice = rex_i18n::msg('minfo_field_attributes_notice') . "\n";
$field->setNotice($notice);
$field = $this->addTextAreaField('callback');
$field->setLabel(rex_i18n::msg('minfo_field_label_callback'));
$notice = rex_i18n::msg('minfo_field_label_notice') . "\n";
$field->setNotice($notice);
$field = $this->addTextField('default');
$field->setLabel(rex_i18n::msg('minfo_field_label_default'));
if ('clang_' !== $this->metaPrefix) {
$attributes = [];
$attributes['internal::fieldClass'] = 'rex_form_restrictons_element';
$field = $this->addField('', 'restrictions', null, $attributes);
$field->setLabel(rex_i18n::msg('minfo_field_label_restrictions'));
$field->setAttribute('size', 10);
$field->setAttribute('class', 'form-control');
}
parent::init();
}
示例15: rex_fragment
$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>';
}
});
}