本文整理汇总了PHP中FeatherBB\Core\Utils类的典型用法代码示例。如果您正苦于以下问题:PHP Utils类的具体用法?PHP Utils怎么用?PHP Utils使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Utils类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: display
public function display()
{
if ($this->user->g_search == '0') {
throw new Error(__('No search permission'), 403);
}
// Figure out what to do :-)
if ($this->request->get('action') || $this->request->get('search_id')) {
$search = $this->model->get_search_results();
// We have results to display
if (isset($search['is_result'])) {
$this->feather->template->setPageInfo(array('title' => array(Utils::escape($this->config['o_board_title']), __('Search results')), 'active_page' => 'search'));
$this->model->display_search_results($search, $this->feather);
$this->feather->template->setPageInfo(array('search' => $search));
$this->feather->template->addTemplate('search/header.php', 1);
if ($search['show_as'] == 'posts') {
$this->feather->template->addTemplate('search/posts.php', 5);
} else {
$this->feather->template->addTemplate('search/topics.php', 5);
}
$this->feather->template->addTemplate('search/footer.php', 10)->display();
} else {
Url::redirect($this->feather->urlFor('search'), __('No hits'));
}
} else {
$this->feather->template->setPageInfo(array('title' => array(Utils::escape($this->config['o_board_title']), __('Search')), 'active_page' => 'search', 'focus_element' => array('search', 'keywords'), 'is_indexed' => true, 'forums' => $this->model->get_list_forums()))->addTemplate('search/form.php')->display();
}
}
示例2: display
public function display($req, $res, $args)
{
Container::get('hooks')->fire('controller.search.display');
if (User::get()->g_search == '0') {
throw new Error(__('No search permission'), 403);
}
// Figure out what to do :-)
if (Input::query('action') || Input::query('search_id')) {
$search = $this->model->get_search_results();
// We have results to display
if (!is_object($search) && isset($search['is_result'])) {
View::setPageInfo(array('title' => array(Utils::escape(ForumSettings::get('o_board_title')), __('Search results')), 'active_page' => 'search', 'search' => $search, 'footer' => $search));
$display = $this->model->display_search_results($search);
View::setPageInfo(array('display' => $display));
View::addTemplate('search/header.php', 1);
if ($search['show_as'] == 'posts') {
View::addTemplate('search/posts.php', 5);
} else {
View::addTemplate('search/topics.php', 5);
}
View::addTemplate('search/footer.php', 10)->display();
} else {
return Router::redirect(Router::pathFor('search'), __('No hits'));
}
} else {
View::setPageInfo(array('title' => array(Utils::escape(ForumSettings::get('o_board_title')), __('Search')), 'active_page' => 'search', 'focus_element' => array('search', 'keywords'), 'is_indexed' => true, 'forums' => $this->model->get_list_forums()))->addTemplate('search/form.php')->display();
}
}
示例3: display
public function display($req, $res, $args)
{
Container::get('hooks')->fire('controller.admin.statistics.display');
AdminUtils::generateAdminMenu('index');
$total = $this->model->get_total_size();
return View::setPageInfo(array('title' => array(Utils::escape(ForumSettings::get('o_board_title')), __('Admin'), __('Server statistics')), 'active_page' => 'admin', 'admin_console' => true, 'server_load' => $this->model->get_server_load(), 'num_online' => $this->model->get_num_online(), 'total_size' => $total['size'], 'total_records' => $total['records'], 'php_accelerator' => $this->model->get_php_accelerator()))->addTemplate('admin/statistics.php')->display();
}
示例4: display
public function display($req, $res, $args)
{
Container::get('hooks')->fire('controller.admin.maintenance.display');
$action = '';
if (Input::post('action')) {
$action = Input::post('action');
} elseif (Input::query('action')) {
$action = Input::query('action');
}
if ($action == 'rebuild') {
$this->model->rebuild();
View::setPageInfo(array('page_title' => array(Utils::escape(ForumSettings::get('o_board_title')), __('Rebuilding search index')), 'query_str' => $this->model->get_query_str()))->addTemplate('admin/maintenance/rebuild.php')->display();
}
if ($action == 'prune') {
$prune_from = Utils::trim(Input::post('prune_from'));
$prune_sticky = intval(Input::post('prune_sticky'));
AdminUtils::generateAdminMenu('maintenance');
if (Input::post('prune_comply')) {
$this->model->prune_comply($prune_from, $prune_sticky);
}
View::setPageInfo(array('title' => array(Utils::escape(ForumSettings::get('o_board_title')), __('Admin'), __('Prune')), 'active_page' => 'admin', 'admin_console' => true, 'prune_sticky' => $prune_sticky, 'prune_from' => $prune_from, 'prune' => $this->model->get_info_prune($prune_sticky, $prune_from)))->addTemplate('admin/maintenance/prune.php')->display();
}
AdminUtils::generateAdminMenu('maintenance');
View::setPageInfo(array('title' => array(Utils::escape(ForumSettings::get('o_board_title')), __('Admin'), __('Maintenance')), 'active_page' => 'admin', 'admin_console' => true, 'first_id' => $this->model->get_first_id(), 'categories' => $this->model->get_categories()))->addTemplate('admin/maintenance/admin_maintenance.php')->display();
}
示例5: display
public function display($req, $res, $args)
{
Container::get('hooks')->fire('controller.userlist.display');
if (User::get()->g_view_users == '0') {
throw new Error(__('No permission'), 403);
}
// Determine if we are allowed to view post counts
$show_post_count = ForumSettings::get('o_show_post_count') == '1' || User::get()->is_admmod ? true : false;
$username = Input::query('username') && User::get()->g_search_users == '1' ? Utils::trim(Input::query('username')) : '';
$show_group = Input::query('show_group') ? intval(Input::query('show_group')) : -1;
$sort_by = Input::query('sort_by') && (in_array(Input::query('sort_by'), array('username', 'registered')) || Input::query('sort_by') == 'num_posts' && $show_post_count) ? Input::query('sort_by') : 'username';
$sort_dir = Input::query('sort_dir') && Input::query('sort_dir') == 'DESC' ? 'DESC' : 'ASC';
$num_users = $this->model->fetch_user_count($username, $show_group);
// Determine the user offset (based on $page)
$num_pages = ceil($num_users / 50);
$p = !Input::query('p') || $page <= 1 || $page > $num_pages ? 1 : intval($page);
$start_from = 50 * ($p - 1);
if (User::get()->g_search_users == '1') {
$focus_element = array('userlist', 'username');
} else {
$focus_element = array();
}
// Generate paging links
$paging_links = '<span class="pages-label">' . __('Pages') . ' </span>' . Url::paginate_old($num_pages, $p, '?username=' . urlencode($username) . '&show_group=' . $show_group . '&sort_by=' . $sort_by . '&sort_dir=' . $sort_dir);
View::setPageInfo(array('title' => array(Utils::escape(ForumSettings::get('o_board_title')), __('User list')), 'active_page' => 'userlist', 'page_number' => $p, 'paging_links' => $paging_links, 'focus_element' => $focus_element, 'is_indexed' => true, 'username' => $username, 'show_group' => $show_group, 'sort_by' => $sort_by, 'sort_dir' => $sort_dir, 'show_post_count' => $show_post_count, 'dropdown_menu' => $this->model->generate_dropdown_menu($show_group), 'userlist_data' => $this->model->print_users($username, $start_from, $sort_by, $sort_dir, $show_group)))->addTemplate('userlist.php')->display();
}
示例6: validate_search_word
public function validate_search_word($word, $idx)
{
static $stopwords;
// If the word is a keyword we don't want to index it, but we do want to be allowed to search it
if ($this->is_keyword($word)) {
return !$idx;
}
if (!isset($stopwords)) {
if (!$this->feather->cache->isCached('stopwords')) {
$this->feather->cache->store('stopwords', \FeatherBB\Model\Cache::get_config(), '+1 week');
}
$stopwords = $this->feather->cache->retrieve('stopwords');
}
// If it is a stopword it isn't valid
if (in_array($word, $stopwords)) {
return false;
}
// If the word is CJK we don't want to index it, but we do want to be allowed to search it
if ($this->is_cjk($word)) {
return !$idx;
}
// Exclude % and * when checking whether current word is valid
$word = str_replace(array('%', '*'), '', $word);
// Check the word is within the min/max length
$num_chars = Utils::strlen($word);
return $num_chars >= $this->feather->forum_env['FEATHER_SEARCH_MIN_WORD'] && $num_chars <= $this->feather->forum_env['FEATHER_SEARCH_MAX_WORD'];
}
示例7: rules
public function rules()
{
Container::get('hooks')->fire('controller.index.rules');
if (ForumSettings::get('o_rules') == '0' || User::get()->is_guest && User::get()->g_read_board == '0' && ForumSettings::get('o_regs_allow') == '0') {
throw new Error(__('Bad request'), 404);
}
View::setPageInfo(array('title' => array(Utils::escape(ForumSettings::get('o_board_title')), __('Forum rules')), 'active_page' => 'rules'))->addTemplate('misc/rules.php')->display();
}
示例8: display
public function display()
{
if ($this->feather->request->isPost()) {
$this->model->update_options();
}
AdminUtils::generateAdminMenu('options');
$this->feather->template->setPageInfo(array('title' => array(Utils::escape($this->config['o_board_title']), __('Admin'), __('Options')), 'active_page' => 'admin', 'admin_console' => true, 'languages' => $this->model->get_langs(), 'styles' => $this->model->get_styles(), 'times' => $this->model->get_times()))->addTemplate('admin/options.php')->display();
}
示例9: edit
public function edit($id)
{
if ($this->request->post('add_edit_ban')) {
$this->model->insert_ban();
}
AdminUtils::generateAdminMenu('bans');
$this->feather->template->setPageInfo(array('admin_console' => true, 'focus_element' => array('bans2', 'ban_user'), 'title' => array(Utils::escape($this->config['o_board_title']), __('Admin'), __('Bans')), 'ban' => $this->model->edit_ban_info($id)))->addTemplate('admin/bans/add_ban.php')->display();
}
示例10: get_info
public static function get_info()
{
$data = array('exec_time' => Utils::get_microtime() - Container::get('start'));
$data['nb_queries'] = isset(DB::get_query_log()[0]) ? count(DB::get_query_log()[0]) : 'N/A';
$data['mem_usage'] = function_exists('memory_get_usage') ? Utils::file_size(memory_get_usage()) : 'N/A';
$data['mem_peak_usage'] = function_exists('memory_get_peak_usage') ? Utils::file_size(memory_get_peak_usage()) : 'N/A';
return $data;
}
示例11: edit
public function edit($req, $res, $args)
{
Container::get('hooks')->fire('controller.admin.bans.edit');
if (Input::post('add_edit_ban')) {
return $this->model->insert_ban();
}
AdminUtils::generateAdminMenu('bans');
View::setPageInfo(array('admin_console' => true, 'focus_element' => array('bans2', 'ban_user'), 'title' => array(Utils::escape(ForumSettings::get('o_board_title')), __('Admin'), __('Bans')), 'ban' => $this->model->edit_ban_info($args['id'])))->addTemplate('admin/bans/add_ban.php')->display();
}
示例12: display
public function display()
{
// Update permissions
if ($this->feather->request->isPost()) {
$this->model->update_permissions();
}
AdminUtils::generateAdminMenu('permissions');
$this->feather->template->setPageInfo(array('title' => array(Utils::escape($this->config['o_board_title']), __('Admin'), __('Permissions')), 'active_page' => 'admin', 'admin_console' => true))->addTemplate('admin/permissions.php')->display();
}
示例13: display
public function display($req, $res, $args)
{
Container::get('hooks')->fire('controller.admin.options.display');
if (Request::isPost()) {
return $this->model->update_options();
}
AdminUtils::generateAdminMenu('options');
View::setPageInfo(array('title' => array(Utils::escape(ForumSettings::get('o_board_title')), __('Admin'), __('Options')), 'active_page' => 'admin', 'admin_console' => true, 'languages' => $this->model->get_langs(), 'styles' => $this->model->get_styles(), 'times' => $this->model->get_times()))->addTemplate('admin/options.php')->display();
}
示例14: get_info
public static function get_info()
{
self::$feather = \Slim\Slim::getInstance();
$data = array('exec_time' => Utils::get_microtime() - self::$feather->start);
$data['nb_queries'] = isset(DB::get_query_log()[0]) ? count(DB::get_query_log()[0]) : 'N/A';
$data['mem_usage'] = function_exists('memory_get_usage') ? Utils::file_size(memory_get_usage()) : 'N/A';
$data['mem_peak_usage'] = function_exists('memory_get_peak_usage') ? Utils::file_size(memory_get_peak_usage()) : 'N/A';
return $data;
}
示例15: getName
public function getName($items)
{
// Split name
$classNamespace = explode('\\', get_class($this));
$className = end($classNamespace);
// Prettify and return name of child class
preg_match_all('%[A-Z]*[a-z]+%m', $className, $result, PREG_PATTERN_ORDER);
$items[] = Utils::escape(implode(' ', $result[0]));
return $items;
}