本文整理汇总了PHP中phpbb\controller\helper::message方法的典型用法代码示例。如果您正苦于以下问题:PHP helper::message方法的具体用法?PHP helper::message怎么用?PHP helper::message使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类phpbb\controller\helper
的用法示例。
在下文中一共展示了helper::message方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _data_processing
/**
* Routine
*
* @param int $link_id The link ID
* @param int $comment_id The comment ID
* @param string $mode new|edit
* @return \Symfony\Component\HttpFoundation\Response A Symfony Response object
*/
private function _data_processing($link_id, $comment_id = 0, $mode = 'new')
{
if (!check_form_key('dir_form_comment')) {
return $this->helper->message('FORM_INVALID');
}
$this->s_comment = $this->request->variable('message', '', true);
if (!function_exists('validate_data')) {
include $this->root_path . 'includes/functions_user.' . $this->php_ext;
}
$error = validate_data(array('reply' => $this->s_comment), array('reply' => array(array('string', false, 1, $this->config['dir_length_comments']))));
$error = preg_replace('#^([A-Z_]+)$#e', "(!empty(\$this->user->lang['\\1'])) ? \$this->user->lang['\\1'] : '\\1'", $error);
if (!$this->user->data['is_registered'] && $this->config['dir_visual_confirm']) {
$vc_response = $this->captcha->validate();
if ($vc_response !== false) {
$error[] = $vc_response;
}
if ($this->config['dir_visual_confirm_max_attempts'] && $this->captcha->get_attempt_count() > $this->config['dir_visual_confirm_max_attempts']) {
$error[] = $this->user->lang['TOO_MANY_ADDS'];
}
}
if (!$error) {
$uid = $bitfield = $flags = '';
generate_text_for_storage($this->s_comment, $uid, $bitfield, $flags, (bool) $this->config['dir_allow_bbcode'], (bool) $this->config['dir_allow_links'], (bool) $this->config['dir_allow_smilies']);
$data_edit = array('comment_text' => $this->s_comment, 'comment_uid' => $uid, 'comment_flags' => $flags, 'comment_bitfield' => $bitfield);
if ($mode == 'edit') {
$this->comment->edit($data_edit, $comment_id);
} else {
$data_add = array('comment_link_id' => (int) $link_id, 'comment_date' => time(), 'comment_user_id' => $this->user->data['user_id'], 'comment_user_ip' => $this->user->ip);
$data_add = array_merge($data_edit, $data_add);
$this->comment->add($data_add);
}
$meta_info = $this->helper->route('ernadoo_phpbbdirectory_comment_view_controller', array('link_id' => (int) $link_id));
meta_refresh(3, $meta_info);
$message = $this->user->lang['DIR_' . strtoupper($mode) . '_COMMENT_OK'];
$message = $message . '<br /><br />' . $this->user->lang('DIR_CLICK_RETURN_COMMENT', '<a href="' . $meta_info . '">', '</a>');
return $this->helper->message($message);
} else {
$this->template->assign_vars(array('ERROR' => sizeof($error) ? implode('<br />', $error) : ''));
return $this->view($link_id, $this->request->variable('page', 1), $mode);
}
}
示例2: view
/**
* View controller for display a category
*
* @param int $cat_id The category ID
* @param int $page Page number taken from the URL
* @param int $sort_days Specifies the maximum amount of days a link may be old
* @param string $sort_key is the key of $sort_by_sql for the selected sorting: a|t|r|s|v|p
* @param string $sort_dir is either a or d representing ASC and DESC (ascending|descending)
* @param string $mode watch|unwatch
* @return \Symfony\Component\HttpFoundation\Response A Symfony Response object
* @throws \phpbb\exception\http_exception
*/
public function view($cat_id, $page, $sort_days, $sort_key, $sort_dir, $mode = '')
{
if (false === $this->categorie->get($cat_id)) {
throw new \phpbb\exception\http_exception(404, 'DIR_ERROR_NO_CATS');
}
$start = ($page - 1) * $this->config['dir_show'];
$default_sort_days = 0;
$default_sort_key = (string) substr($this->config['dir_default_order'], 0, 1);
$default_sort_dir = (string) substr($this->config['dir_default_order'], 2);
$sort_days = !$sort_days ? $this->request->variable('st', $default_sort_days) : $sort_days;
$sort_key = !$sort_key ? $this->request->variable('sk', $default_sort_key) : $sort_key;
$sort_dir = !$sort_dir ? $this->request->variable('sd', $default_sort_dir) : $sort_dir;
$link_list = $rowset = array();
// Categorie ordering options
$limit_days = array(0 => $this->user->lang['SEE_ALL'], 1 => $this->user->lang['1_DAY'], 7 => $this->user->lang['7_DAYS'], 14 => $this->user->lang['2_WEEKS'], 30 => $this->user->lang['1_MONTH'], 90 => $this->user->lang['3_MONTHS'], 180 => $this->user->lang['6_MONTHS'], 365 => $this->user->lang['1_YEAR']);
$sort_by_text = array('a' => $this->user->lang['AUTHOR'], 't' => $this->user->lang['POST_TIME'], 'r' => $this->user->lang['DIR_COMMENTS_ORDER'], 's' => $this->user->lang['DIR_NAME_ORDER'], 'v' => $this->user->lang['DIR_NB_CLICKS_ORDER']);
$sort_by_sql = array('a' => 'u.username_clean', 't' => array('l.link_time', 'l.link_id'), 'r' => 'l.link_comment', 's' => 'LOWER(l.link_name)', 'v' => 'l.link_view');
if ($this->config['dir_activ_pagerank']) {
$sort_by_text['p'] = $this->user->lang['DIR_PR_ORDER'];
$sort_by_sql['p'] = 'l.link_pagerank';
}
$s_limit_days = $s_sort_key = $s_sort_dir = $u_sort_param = '';
gen_sort_selects($limit_days, $sort_by_text, $sort_days, $sort_key, $sort_dir, $s_limit_days, $s_sort_key, $s_sort_dir, $u_sort_param, $default_sort_days, $default_sort_key, $default_sort_dir);
$u_sort_param = $sort_days === $default_sort_days && $sort_key == $default_sort_key && $sort_dir == $default_sort_dir ? array() : array('sort_days' => $sort_days, 'sort_key' => $sort_key, 'sort_dir' => $sort_dir);
// Are we watching this categorie?
$s_watching_categorie = array('link' => '', 'link_toggle' => '', 'title' => '', 'title_toggle' => '', 'is_watching' => false);
if ($this->config['email_enable'] && $this->user->data['is_registered']) {
$notify_status = isset($this->categorie->data['notify_status']) ? $this->categorie->data['notify_status'] : null;
if ($message = $this->categorie->watch_categorie($mode, $s_watching_categorie, $this->user->data['user_id'], $cat_id, $notify_status)) {
return $this->helper->message($message);
}
}
// A deadline has been selected
if ($sort_days) {
$min_post_time = time() - $sort_days * 86400;
$sql = 'SELECT COUNT(link_id) AS nb_links
FROM ' . DIR_LINK_TABLE . '
WHERE link_cat = ' . (int) $cat_id . '
AND link_time >= ' . $min_post_time;
$result = $this->db->sql_query($sql);
$nb_links = (int) $this->db->sql_fetchfield('nb_links');
$this->db->sql_freeresult($result);
if ($this->request->is_set_post('sort')) {
$start = 0;
}
$sql_limit_time = " AND l.link_time >= {$min_post_time}";
} else {
$sql_limit_time = '';
$nb_links = (int) $this->categorie->data['cat_links'];
}
// Make sure $start is set to the last page if it exceeds the amount
$start = $this->pagination->validate_start($start, $this->config['dir_show'], $nb_links);
// Build navigation links
$this->categorie->generate_dir_nav($this->categorie->data);
// Jumpbox
$this->categorie->make_cat_jumpbox();
$base_url = array('routes' => 'ernadoo_phpbbdirectory_page_controller', 'params' => array_merge(array('cat_id' => $cat_id), $u_sort_param));
$this->pagination->generate_template_pagination($base_url, 'pagination', 'page', $nb_links, $this->config['dir_show'], $start);
$this->template->assign_vars(array('S_SELECT_SORT_DIR' => $s_sort_dir, 'S_SELECT_SORT_KEY' => $s_sort_key, 'S_SELECT_SORT_DAYS' => $s_limit_days, 'S_CATLIST' => $this->categorie->make_cat_select($cat_id), 'S_PAGE_ACTION' => $this->helper->route('ernadoo_phpbbdirectory_page_controller', array('cat_id' => $cat_id, 'page' => $page)), 'S_CAT_ID' => $cat_id, 'TOTAL_LINKS' => $this->user->lang('DIR_NB_LINKS', (int) $nb_links), 'U_NEW_SITE' => $this->helper->route('ernadoo_phpbbdirectory_new_controller', array('cat_id' => $cat_id)), 'U_WATCH_CAT' => $s_watching_categorie['link'], 'U_WATCH_CAT_TOGGLE' => $s_watching_categorie['link_toggle'], 'S_WATCH_CAT_TITLE' => $s_watching_categorie['title'], 'S_WATCH_CAT_TOGGLE' => $s_watching_categorie['title_toggle'], 'S_WATCHING_CAT' => $s_watching_categorie['is_watching']));
// If the user is trying to reach late pages, start searching from the end
$store_reverse = false;
$sql_limit = $this->config['dir_show'];
if ($start > $nb_links / 2) {
$store_reverse = true;
// Select the sort order
$direction = $sort_dir == 'd' ? 'ASC' : 'DESC';
$sql_limit = $this->pagination->reverse_limit($start, $sql_limit, $nb_links);
$sql_start = $this->pagination->reverse_start($start, $sql_limit, $nb_links);
} else {
// Select the sort order
$direction = $sort_dir == 'd' ? 'DESC' : 'ASC';
$sql_start = $start;
}
if (is_array($sort_by_sql[$sort_key])) {
$sql_sort_order = implode(' ' . $direction . ', ', $sort_by_sql[$sort_key]) . ' ' . $direction;
} else {
$sql_sort_order = $sort_by_sql[$sort_key] . ' ' . $direction;
}
// Grab just the sorted link ids
$sql_array = array('SELECT' => 'l.link_id', 'FROM' => array(DIR_LINK_TABLE => 'l'), 'LEFT_JOIN' => array(array('FROM' => array(USERS_TABLE => 'u'), 'ON' => 'l.link_user_id = u.user_id')), 'WHERE' => "l.link_cat = {$cat_id}\n\t\t\t\tAND l.link_active = 1\n\t\t\t\t\t{$sql_limit_time}", 'ORDER_BY' => $sql_sort_order);
$sql = $this->db->sql_build_query('SELECT', $sql_array);
$result = $this->db->sql_query_limit($sql, $sql_limit, $sql_start);
while ($row = $this->db->sql_fetchrow($result)) {
$link_list[] = (int) $row['link_id'];
}
$this->db->sql_freeresult($result);
if (sizeof($link_list)) {
// We get links, informations about poster, votes and number of comments
//.........这里部分代码省略.........
示例3: _data_processing
/**
* Routine
*
* @param int $cat_id The category ID
* @param int $link_id The link ID
* @param string $mode add|edit
* @return null|\Symfony\Component\HttpFoundation\Response A Symfony Response object
* @throws \phpbb\exception\http_exception
*/
private function _data_processing($cat_id, $link_id = 0, $mode = 'new')
{
if ($mode == 'edit' && !$this->auth->acl_get('m_edit_dir') && !$this->auth->acl_get('u_edit_dir') || $mode == 'new' && !$this->auth->acl_get('u_submit_dir')) {
throw new \phpbb\exception\http_exception(403, 'DIR_ERROR_NOT_AUTH');
}
if (!check_form_key('dir_form')) {
return $this->helper->message('FORM_INVALID');
}
$this->url = $this->request->variable('url', '');
$this->site_name = $this->request->variable('site_name', '', true);
$this->description = $this->request->variable('description', '', true);
$this->guest_email = $this->request->variable('guest_email', '');
$this->rss = $this->request->variable('rss', '');
$this->banner = $this->request->variable('banner', '');
$this->back = $this->request->variable('back', '');
$this->flag = $this->request->variable('flag', '');
if (!function_exists('validate_data')) {
include $this->root_path . 'includes/functions_user.' . $this->php_ext;
}
// We define variables to check
$data = array('email' => $this->guest_email, 'site_name' => $this->site_name, 'website' => $this->url, 'description' => $this->description, 'rss' => $this->rss, 'banner' => $this->banner, 'back' => $this->back, 'cat' => (int) $cat_id);
// We define verification type for each variable
$data2 = array('email' => array(array('string', $this->user->data['is_registered'], 6, 60), array('user_email', '')), 'site_name' => array(array('string', false, 1, 100)), 'website' => array(array('string', false, 12, 255), array('match', true, '#^http[s]?://(.*?\\.)*?[a-z0-9\\-]+\\.[a-z]{2,4}#i')), 'description' => array(array('string', !$this->categorie->data['cat_must_describe'], 1, $this->config['dir_length_describe'])), 'rss' => array(array('string', true, 12, 255), array('match', empty($this->rss), '#^http[s]?://(.*?\\.)*?[a-z0-9\\-]+\\.[a-z]{2,4}#i')), 'banner' => array(array('string', true, 5, 255)), 'back' => array(array('string', !$this->categorie->data['cat_link_back'], 12, 255), array(array($this->link, 'link_back'), true)), 'cat' => array(array('num', '', 1)));
$this->user->add_lang('ucp');
$error = validate_data($data, $data2);
$error = preg_replace('#^([A-Z_]+)$#e', "(!empty(\$this->user->lang['\\1'])) ? \$this->user->lang['\\1'] : '\\1'", $error);
// We check that url have good format
if (preg_match('/^(http|https):\\/\\//si', $this->url) && $this->config['dir_activ_checkurl'] && !$this->link->checkurl($this->url)) {
$error[] = $this->user->lang['DIR_ERROR_CHECK_URL'];
}
if (!$this->user->data['is_registered'] && $this->config['dir_visual_confirm']) {
$vc_response = $this->captcha->validate($data);
if ($vc_response !== false) {
$error[] = $vc_response;
}
if ($this->config['dir_visual_confirm_max_attempts'] && $this->captcha->get_attempt_count() > $this->config['dir_visual_confirm_max_attempts']) {
$error[] = $this->user->lang['TOO_MANY_ADDS'];
}
}
if (!$error) {
/**
* No errrors, we execute heavy tasks wich need a valid url
*/
// Banner
$this->link->banner_process($this->banner, $error);
// PageRank
$pagerank = $this->link->pagerank_process($this->url);
// Thumb ;)
$thumb = $this->link->thumb_process($this->url);
}
// Still no errors?? So let's go!
if (!$error) {
$uid = $bitfield = $flags = '';
generate_text_for_storage($this->description, $uid, $bitfield, $flags, (bool) $this->config['allow_bbcode'], (bool) $this->config['allow_post_links'], (bool) $this->config['allow_smilies']);
$this->banner = !$this->banner && !$this->request->is_set_post('delete_banner') ? $this->request->variable('old_banner', '') : $this->banner;
$this->url = $this->link->clean_url($this->url);
$data_edit = array('link_user_id' => $this->link_user_id, 'link_guest_email' => $this->guest_email, 'link_name' => $this->site_name, 'link_url' => $this->url, 'link_description' => $this->description, 'link_cat' => (int) $cat_id, 'link_rss' => $this->rss, 'link_banner' => $this->banner, 'link_back' => $this->back, 'link_uid' => $uid, 'link_flags' => $flags, 'link_flag' => $this->flag, 'link_bitfield' => $bitfield, 'link_pagerank' => (int) $pagerank, 'link_thumb' => $thumb);
$need_approval = $this->categorie->need_approval() && !$this->auth->acl_get('a_') && !$this->auth->acl_get('m_') ? true : false;
if ($mode == 'edit') {
$data_edit['link_cat_old'] = $this->request->variable('old_cat_id', 0);
$this->link->edit($data_edit, $link_id, $need_approval);
} else {
$data_add = array('link_time' => time(), 'link_view' => 0, 'link_active' => $need_approval ? false : true, 'link_user_id' => $this->user->data['user_id']);
$data_add = array_merge($data_edit, $data_add);
$this->link->add($data_add, $need_approval);
}
$meta_info = $this->helper->route('ernadoo_phpbbdirectory_page_controller', array('cat_id' => (int) $cat_id));
meta_refresh(3, $meta_info);
$message = $need_approval ? $this->user->lang['DIR_' . strtoupper($mode) . '_SITE_ACTIVE'] : $this->user->lang['DIR_' . strtoupper($mode) . '_SITE_OK'];
$message = $message . '<br /><br />' . $this->user->lang('DIR_CLICK_RETURN_DIR', '<a href="' . $this->helper->route('ernadoo_phpbbdirectory_base_controller') . '">', '</a>') . '<br /><br />' . $this->user->lang('DIR_CLICK_RETURN_CAT', '<a href="' . $this->helper->route('ernadoo_phpbbdirectory_page_controller', array('cat_id' => (int) $cat_id)) . '">', '</a>');
return $this->helper->message($message);
} else {
if ($mode == 'edit') {
$this->s_hidden_fields = array('old_cat_id' => $this->request->variable('old_cat_id', 0), 'old_banner' => $this->request->variable('old_banner', ''));
}
$this->template->assign_vars(array('ERROR' => isset($error) ? implode('<br />', $error) : ''));
}
}