本文整理汇总了PHP中AppContext::get_request方法的典型用法代码示例。如果您正苦于以下问题:PHP AppContext::get_request方法的具体用法?PHP AppContext::get_request怎么用?PHP AppContext::get_request使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AppContext
的用法示例。
在下文中一共展示了AppContext::get_request方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: display_active_image
/**
* @desc This function required object Notation containing the module_name, id_in_module, user_id, note and notation_scale.
* @param object $notation Notation
*/
public static function display_active_image(Notation $notation)
{
$note_post = AppContext::get_request()->get_int('note', 0);
$id_post = AppContext::get_request()->get_int('id', 0);
if (!empty($note_post) && !empty($id_post)) {
$notation->set_id_in_module($id_post);
$notation->set_note($note_post);
self::register_notation($notation);
} else {
$template = new FileTemplate('framework/content/notation/notation.tpl');
$average_notes = $notation->get_average_notes();
$int = intval($average_notes);
$decimal = floatval('0.' . substr($average_notes, strpos($average_notes, '.') + 1));
for ($i = 1; $i <= $notation->get_notation_scale(); $i++) {
$star_full = false;
$star_half = false;
$star_empty = false;
if ($int >= $i || $int + 1 == $i && $decimal >= 0.75) {
$star_full = true;
} else {
if ($int + 1 == $i && $decimal > 0.25 && $decimal < 0.75) {
$star_half = true;
} else {
$star_empty = true;
}
}
$template->assign_block_vars('star', array('I' => $i, 'STAR_EMPTY' => $star_empty, 'STAR_HALF' => $star_half, 'STAR_FULL' => $star_full));
}
$count_notes = $notation->get_number_notes();
$template->put_all(array('C_JS_NOT_ALREADY_INCLUDED' => !self::$js_already_included, 'C_NOTES' => $count_notes > 0 ? true : false, 'C_MORE_1_NOTES' => $count_notes > 1 ? true : false, 'CURRENT_URL' => REWRITED_SCRIPT, 'ID_IN_MODULE' => $notation->get_id_in_module(), 'NOTATION_SCALE' => $notation->get_notation_scale(), 'NUMBER_NOTES' => $count_notes, 'AVERAGE_NOTES' => $average_notes, 'ALREADY_NOTE' => $notation->user_already_noted(), 'L_NO_NOTE' => LangLoader::get_message('no_note', 'common'), 'L_AUTH_ERROR' => LangLoader::get_message('error.auth', 'status-messages-common'), 'L_ALREADY_NOTE' => self::$lang['already_vote'], 'L_NOTES' => LangLoader::get_message('notes', 'common'), 'L_NOTE' => LangLoader::get_message('note', 'common'), 'L_VALID_NOTE' => LangLoader::get_message('add_note', 'common')));
self::$js_already_included = true;
return $template->render();
}
}
示例2: retrieve_value
public function retrieve_value()
{
$request = AppContext::get_request();
$config = ContactConfig::load();
$fields = $config->get_fields();
$recipients_field_id = $config->get_field_id_by_name('f_recipients');
$recipients_field = new ContactField();
$recipients_field->set_properties($fields[$recipients_field_id]);
$recipients = $recipients_field->get_possible_values();
$nb_recipients = count($recipients);
$recipients_keys = array_keys($recipients);
$values = array();
for ($i = 0; $i <= $this->max_input; $i++) {
$field_name = 'field_name_' . $this->get_html_id() . '_' . $i;
if ($request->has_postparameter($field_name)) {
$field_is_default = 'field_is_default_' . $this->get_html_id() . '_' . $i;
$field_title = 'field_name_' . $this->get_html_id() . '_' . $i;
$field_email = 'field_email_' . $this->get_html_id() . '_' . $i;
$email = $i > 0 ? $request->get_poststring($field_email) : true;
if ($request->get_poststring($field_title) && $email) {
$id = $i < $nb_recipients ? $recipients_keys[$i] : preg_replace('/\\s+/', '', $request->get_poststring($field_name));
$values[$id] = array('is_default' => $request->get_postint($field_is_default, 0), 'title' => addslashes($request->get_poststring($field_title)), 'email' => $request->get_poststring($field_email, ''));
}
}
}
$this->set_value($values);
}
示例3: build_form
private function build_form()
{
$mail_request = AppContext::get_request()->get_string('mail_newsletter', '');
if (AppContext::get_current_user()->check_level(User::MEMBER_LEVEL) && empty($mail_request)) {
$email = AppContext::get_current_user()->get_email();
} else {
$email = $mail_request;
}
$form = new HTMLForm(__CLASS__);
$fieldset = new FormFieldsetHTML('unsubscribe.newsletter', $this->lang['unsubscribe.newsletter']);
$form->add_fieldset($fieldset);
$fieldset->add_field(new FormFieldMailEditor('mail', $this->lang['subscribe.mail'], $email, array('required' => true)));
$fieldset->add_field(new FormFieldCheckbox('delete_all_streams', $this->lang['newsletter.delete_all_streams'], FormFieldCheckbox::UNCHECKED, array('events' => array('click' => '
if (HTMLForms.getField("delete_all_streams").getValue()) {
HTMLForms.getField("choice").disable();
} else {
HTMLForms.getField("choice").enable();
}'))));
$newsletter_subscribe = AppContext::get_current_user()->check_level(User::MEMBER_LEVEL) ? NewsletterService::get_member_id_streams(AppContext::get_current_user()->get_id()) : array();
$fieldset->add_field(new FormFieldMultipleCheckbox('choice', $this->lang['unsubscribe.newsletter_choice'], $newsletter_subscribe, $this->get_streams(), array('required' => true)));
$this->submit_button = new FormButtonDefaultSubmit();
$form->add_button($this->submit_button);
$form->add_button(new FormButtonReset());
$this->form = $form;
}
示例4: try_execute
private function try_execute()
{
$this->load_env();
$this->object_id = AppContext::get_request()->get_getint('menu_config_id');
$menu_config = MenuConfigurationDAO::instance()->find_by_id($this->object_id);
$this->view->put_all(array('NAME' => $menu_config->get_name(), 'MATCH_REGEX' => $menu_config->get_match_regex(), 'U_CONFIGURE' => MenuUrlBuilder::menu_configuration_configure($menu_config->get_id())->rel(), 'U_LIST' => MenuUrlBuilder::menu_configuration_list()->rel()));
}
示例5: __static
public static function __static()
{
$config = SessionsConfig::load();
self::$DATA_COOKIE_NAME = $config->get_cookie_name() . '_data';
self::$AUTOCONNECT_COOKIE_NAME = $config->get_cookie_name() . '_autoconnect';
self::$request = AppContext::get_request();
self::$response = AppContext::get_response();
}
示例6: get_last_comment_added
public static function get_last_comment_added($user_id)
{
if ($user_id !== '-1') {
return self::$db_querier->get_column_value(DB_TABLE_COMMENTS, 'MAX(timestamp)', 'WHERE user_id=:user_id', array('user_id' => $user_id));
} else {
return self::$db_querier->get_column_value(DB_TABLE_COMMENTS, 'MAX(timestamp)', 'WHERE user_ip=:user_ip', array('user_ip' => AppContext::get_request()->get_ip_address()));
}
}
示例7: Add_msg
function Add_msg($idtopic, $idcat, $contents, $title, $last_page, $last_page_rewrite, $new_topic = false)
{
global $LANG;
##### Insertion message #####
$last_timestamp = time();
$result = PersistenceContext::get_querier()->insert(PREFIX . 'forum_msg', array('idtopic' => $idtopic, 'user_id' => AppContext::get_current_user()->get_id(), 'contents' => FormatingHelper::strparse($contents), 'timestamp' => $last_timestamp, 'timestamp_edit' => 0, 'user_id_edit' => 0, 'user_ip' => AppContext::get_request()->get_ip_address()));
$last_msg_id = $result->get_last_inserted_id();
//Topic
PersistenceContext::get_querier()->inject("UPDATE " . PREFIX . "forum_topics SET " . ($new_topic ? '' : 'nbr_msg = nbr_msg + 1, ') . "last_user_id = '" . AppContext::get_current_user()->get_id() . "', last_msg_id = '" . $last_msg_id . "', last_timestamp = '" . $last_timestamp . "' WHERE id = '" . $idtopic . "'");
//On met à jour le last_topic_id dans la catégorie dans le lequel le message a été posté
PersistenceContext::get_querier()->update(ForumSetup::$forum_cats_table, array('last_topic_id' => $idtopic), 'WHERE id = :id', array('id' => $idcat));
//Mise à jour du nombre de messages du membre.
PersistenceContext::get_querier()->inject("UPDATE " . DB_TABLE_MEMBER . " SET posted_msg = posted_msg + 1 WHERE user_id = '" . AppContext::get_current_user()->get_id() . "'");
//On marque le topic comme lu.
mark_topic_as_read($idtopic, $last_msg_id, $last_timestamp);
##### Gestion suivi du sujet mp/mail #####
if (!$new_topic) {
//Message précédent ce nouveau message.
$previous_msg_id = 0;
try {
$previous_msg_id = PersistenceContext::get_querier()->get_column_value(PREFIX . "forum_msg", 'MAX(id)', 'WHERE idtopic = :idtopic AND id < :id', array('idtopic' => $idtopic, 'id' => $last_msg_id));
} catch (RowNotFoundException $e) {
}
$title_subject = TextHelper::html_entity_decode($title);
$title_subject_pm = $title_subject;
if (AppContext::get_current_user()->get_id() > 0) {
$pseudo = '';
try {
$pseudo = PersistenceContext::get_querier()->get_column_value(DB_TABLE_MEMBER, 'display_name', 'WHERE user_id = :id', array('id' => AppContext::get_current_user()->get_id()));
} catch (RowNotFoundException $e) {
}
$pseudo_pm = '<a href="' . UserUrlBuilder::profile(AppContext::get_current_user()->get_id())->rel() . '">' . $pseudo . '</a>';
} else {
$pseudo = $LANG['guest'];
$pseudo_pm = $LANG['guest'];
}
$next_msg_link = '/forum/topic' . url('.php?id=' . $idtopic . $last_page, '-' . $idtopic . $last_page_rewrite . '.php') . ($previous_msg_id ? '#m' . $previous_msg_id : '');
$preview_contents = substr($contents, 0, 300);
//Récupération des membres suivant le sujet.
$max_time = time() - SessionsConfig::load()->get_active_session_duration();
$result = PersistenceContext::get_querier()->select("SELECT m.user_id, m.display_name, m.email, tr.pm, tr.mail, v.last_view_id\n\t\t\tFROM " . PREFIX . "forum_track tr\n\t\t\tLEFT JOIN " . DB_TABLE_MEMBER . " m ON m.user_id = tr.user_id\n\t\t\tLEFT JOIN " . PREFIX . "forum_view v ON v.idtopic = :idtopic AND v.user_id = tr.user_id\n\t\t\tWHERE tr.idtopic = :idtopic AND v.last_view_id IS NOT NULL AND m.user_id != :user_id", array('idtopic' => $idtopic, 'user_id' => AppContext::get_current_user()->get_id()));
while ($row = $result->fetch()) {
//Envoi un Mail à ceux dont le last_view_id est le message précedent.
if ($row['last_view_id'] == $previous_msg_id && $row['mail'] == '1') {
AppContext::get_mail_service()->send_from_properties($row['email'], $LANG['forum_mail_title_new_post'], sprintf($LANG['forum_mail_new_post'], $row['display_name'], $title_subject, AppContext::get_current_user()->get_display_name(), $preview_contents, HOST . DIR . $next_msg_link, HOST . DIR . '/forum/action.php?ut=' . $idtopic . '&trt=1', 1));
}
//Envoi un MP à ceux dont le last_view_id est le message précedent.
if ($row['last_view_id'] == $previous_msg_id && $row['pm'] == '1') {
$content = sprintf($LANG['forum_mail_new_post'], $row['display_name'], $title_subject_pm, AppContext::get_current_user()->get_display_name(), $preview_contents, '<a href="' . $next_msg_link . '">' . $next_msg_link . '</a>', '<a href="/forum/action.php?ut=' . $idtopic . '&trt=2">/forum/action.php?ut=' . $idtopic . '&trt=2</a>');
PrivateMsg::start_conversation($row['user_id'], $LANG['forum_mail_title_new_post'], nl2br($content), '-1', PrivateMsg::SYSTEM_PM);
}
}
$result->dispose();
forum_generate_feeds();
//Regénération du flux rss.
}
return $last_msg_id;
}
示例8: retrieve_value
/**
* {@inheritdoc}
*/
public function retrieve_value()
{
$request = AppContext::get_request();
if ($request->has_parameter($this->get_html_id())) {
$this->set_value($request->get_value($this->get_html_id()) == 'on');
} else {
$this->set_value(false);
}
}
示例9: display
/**
* @desc This function display the comments
* @param class CommentsTopic $topic
* @return Template is a template object
*/
public static function display(CommentsTopic $topic)
{
$module_id = $topic->get_module_id();
$id_in_module = $topic->get_id_in_module();
$topic_identifier = $topic->get_topic_identifier();
$authorizations = $topic->get_authorizations();
if (!$authorizations->is_authorized_read()) {
self::$template->put('KEEP_MESSAGE', MessageHelper::display(self::$comments_lang['comments.not-authorized.read'], MessageHelper::NOTICE));
} else {
$edit_comment_id = AppContext::get_request()->get_getint('edit_comment', 0);
$delete_comment_id = AppContext::get_request()->get_getint('delete_comment', 0);
try {
$lock = AppContext::get_request()->get_getbool('lock');
if ($authorizations->is_authorized_moderation()) {
if ($lock) {
if (!CommentsTopicDAO::topic_exists($module_id, $id_in_module, $topic_identifier)) {
CommentsTopicDAO::create_topic($module_id, $id_in_module, $topic_identifier, $topic->get_path());
}
CommentsManager::lock_topic($module_id, $id_in_module, $topic_identifier);
} else {
CommentsManager::unlock_topic($module_id, $id_in_module, $topic_identifier);
}
}
AppContext::get_response()->redirect($topic->get_path());
} catch (UnexistingHTTPParameterException $e) {
}
if (!empty($delete_comment_id)) {
self::verificate_authorized_edit_or_delete_comment($authorizations, $delete_comment_id);
CommentsManager::delete_comment($delete_comment_id);
AppContext::get_response()->redirect($topic->get_path());
} elseif (!empty($edit_comment_id)) {
self::verificate_authorized_edit_or_delete_comment($authorizations, $edit_comment_id);
$edit_comment_form = EditCommentBuildForm::create($edit_comment_id, $topic->get_path());
self::$template->put_all(array('C_DISPLAY_FORM' => true, 'COMMENT_FORM' => $edit_comment_form->display()));
} else {
if ($authorizations->is_authorized_post() && $authorizations->is_authorized_access_module()) {
$comments_topic_locked = CommentsManager::comment_topic_locked($module_id, $id_in_module, $topic_identifier);
$user_read_only = self::$user->get_delay_readonly();
if (!$authorizations->is_authorized_moderation() && $comments_topic_locked) {
self::$template->put('KEEP_MESSAGE', MessageHelper::display(self::$comments_lang['comment.locked'], MessageHelper::NOTICE));
} elseif (!empty($user_read_only) && $user_read_only > time()) {
self::$template->put('KEEP_MESSAGE', MessageHelper::display(self::$comments_lang['comments.user.read-only'], MessageHelper::NOTICE));
} else {
$add_comment_form = AddCommentBuildForm::create($topic);
self::$template->put_all(array('C_DISPLAY_FORM' => true, 'COMMENT_FORM' => $add_comment_form->display()));
}
} else {
self::$template->put('KEEP_MESSAGE', MessageHelper::display(self::$comments_lang['comments.not-authorized.post'], MessageHelper::NOTICE));
}
}
$number_comments_display = $topic->get_number_comments_display();
$number_comments = self::$comments_cache->get_count_comments_by_module($module_id, $id_in_module, $topic_identifier);
self::$template->put_all(array('COMMENTS_LIST' => self::display_comments($module_id, $id_in_module, $topic_identifier, $number_comments_display, $authorizations), 'MODULE_ID' => $module_id, 'ID_IN_MODULE' => $id_in_module, 'TOPIC_IDENTIFIER' => $topic_identifier, 'C_DISPLAY_VIEW_ALL_COMMENTS' => $number_comments > $number_comments_display, 'C_MODERATE' => $authorizations->is_authorized_moderation(), 'C_IS_LOCKED' => CommentsManager::comment_topic_locked($module_id, $id_in_module, $topic_identifier), 'U_LOCK' => CommentsUrlBuilder::lock_and_unlock($topic->get_path(), true)->rel(), 'U_UNLOCK' => CommentsUrlBuilder::lock_and_unlock($topic->get_path(), false)->rel()));
}
return self::$template;
}
示例10: do_call
private function do_call()
{
$controller = new $this->classname();
if (!$controller instanceof Controller) {
throw new NoSuchControllerException($this->classname);
}
$controller_to_execute = $controller->get_right_controller_regarding_authorizations();
$response = $controller_to_execute->execute(AppContext::get_request());
$response->send();
}
示例11: retrieve_value
/**
* {@inheritdoc}
*/
public function retrieve_value()
{
parent::retrieve_value();
$request = AppContext::get_request();
$date = $this->get_value();
$date->set_minutes($request->get_int($this->get_html_id() . '_minutes', 0));
$date->set_hours($request->get_int($this->get_html_id() . '_hours', 0));
// TODO Add a range constraint for the hours and minutes
$this->set_value($date);
}
示例12: redirect
/**
* @desc Cleans the output buffer and execute the given controller before exiting
* @param Controller $controller the controller to execute
*/
public static function redirect(Controller $controller)
{
AppContext::get_response()->clean_output();
Environment::init_output_bufferization();
$request = AppContext::get_request();
$response = $controller->execute($request);
$response->send();
Environment::destroy();
exit;
}
示例13: retrieve_value
public function retrieve_value()
{
$request = AppContext::get_request();
$values = array();
for ($i = 0; $i < $this->max_input; $i++) {
$id = 'field_' . $this->get_html_id() . '_' . $i;
if ($request->has_postparameter($id)) {
$values[] = $request->get_poststring($id);
}
}
$this->set_value($values);
}
示例14: dispatch
/**
* @desc dispatch the current url argument to the first method matching
* in the <code>UrlControllerMapper</code> list of the controller object
* @throws NoUrlMatchException
*/
public function dispatch()
{
$url = AppContext::get_request()->get_getstring('url', '');
foreach ($this->url_controller_mappers as $url_controller_mapper) {
if ($url_controller_mapper->match($url)) {
$url_controller_mapper->call();
Environment::destroy();
return;
}
}
throw new NoUrlMatchException($url);
Environment::destroy();
}
示例15: is_valid
public function is_valid()
{
if (!$this->is_available() || AppContext::get_current_user()->check_level(User::MEMBER_LEVEL)) {
return true;
}
$answer = AppContext::get_request()->get_value($this->get_html_id(), '');
$question_id = AppContext::get_request()->get_int($this->get_html_id() . '_question_id', 0);
if (!empty($question_id)) {
$question = new QuestionCaptchaQuestion();
$question->set_properties(self::$questions[$question_id]);
return in_array(trim(strtolower($answer)), $question->get_formated_answers());
}
return false;
}