public function _edit($team_id, $name, $title, $image_id, $icon_id, $description, $game_id) { $users = $this->db->select('u.user_id', 'u.username', 'tu.user_id IS NOT NULL AS in_team')->from('nf_users u')->join('nf_teams_users tu', 'tu.user_id = u.user_id AND tu.team_id = ' . $team_id)->join('nf_teams_roles r', 'r.role_id = tu.role_id')->where('u.deleted', FALSE)->order_by('r.order', 'r.role_id', 'u.username')->get(); $roles = $this->model('roles')->get_roles(); $form_team = $this->title($this('edit_team'))->subtitle($title)->load->library('form')->add_rules('teams', array('title' => $title, 'game_id' => $game_id, 'games' => $this->model()->get_games_list(), 'image_id' => $image_id, 'icon_id' => $icon_id, 'description' => $description))->add_submit($this('edit'))->add_back('admin/teams.html')->save(); $form_users = $this->form->add_rules(array('user_id' => array('type' => 'select', 'values' => array_filter(array_map(function ($a) { return !$a['in_team'] ? $a['user_id'] : NULL; }, $users)), 'rules' => 'required'), 'role_id' => array('type' => 'select', 'values' => array_map(function ($a) { return $a['role_id']; }, $roles), 'rules' => 'required')))->save(); if ($form_team->is_valid($post)) { $this->model()->edit_team($team_id, $post['title'], $post['game'], $post['image'], $post['icon'], $post['description']); //add_alert('success', $this('edit_team_success_message')); redirect_back('admin/teams.html'); } else { if ($form_users->is_valid($post)) { $this->db->insert('nf_teams_users', array('team_id' => $team_id, 'user_id' => $post['user_id'], 'role_id' => $post['role_id'])); refresh(); } } $this->load->library('table')->add_columns(array(array('content' => function ($data) { return NeoFrag::loader()->user->link($data['user_id'], $data['username']); }), array('content' => function ($data) { return $data['title']; }), array('content' => array(function ($data) use($team_id, $name) { return button_delete('admin/teams/players/delete/' . $team_id . '/' . $name . '/' . $data['user_id'] . '.html'); }), 'size' => TRUE)))->pagination(FALSE)->data($this->db->select('tu.user_id', 'u.username', 'r.title')->from('nf_teams_users tu')->join('nf_users u', 'u.user_id = tu.user_id')->join('nf_teams_roles r', 'r.role_id = tu.role_id')->where('tu.team_id', $team_id)->order_by('r.title', 'u.username')->get())->no_data($this('no_players_on_team')); return new Row(new Col(new Panel(array('title' => $this('edit_team'), 'icon' => 'fa-gamepad', 'content' => $form_team->display(), 'size' => 'col-md-12 col-lg-7'))), new Col(new Panel(array('title' => $this('players'), 'icon' => 'fa-users', 'content' => $this->table->display(), 'footer' => $this->load->view('users', array('users' => $users, 'roles' => $roles, 'form_id' => $form_users->id)), 'size' => 'col-md-12 col-lg-5')))); }
function add_alert($header, $message = '', $type = 'error') { if (!in_array($type, array('error', 'success', 'info'))) { $type = 'error'; } NeoFrag::loader()->session->add('alerts', array('message' => ($header ? '<h4 class="alert-heading">' . $header . '</h4>' : '') . $message, 'type' => $type)); }
public function display($id = NULL) { static $widgets; if (is_null($widgets)) { foreach (NeoFrag::loader()->db->from('nf_widgets')->get() as $widget) { $widgets[$widget['widget_id']] = $widget; } } $widget = $widgets[$this->widget_id]; $output = array(); $instance = NeoFrag::loader()->widget($widget['widget']); $result = $instance->get_output($widget['type'], is_array($settings = unserialize($widget['settings'])) ? $settings : array()); foreach ($result as $result) { if (is_a($result, 'Panel')) { if (strlen($widget['title'])) { $result->title = $widget['title']; } if (isset($this->style)) { $result->style = $this->style; } $output[] = $result->display($id); } else { $output[] = $result; } } if ($widget['widget'] == 'module') { $type = 'module'; $module = NeoFrag::loader()->module; $name = $module->name; } else { $type = 'widget'; $name = $widget['widget']; } return '<div class="' . $type . ' ' . $type . '-' . $name . (!is_null($id) ? ' live-editor-widget" data-widget-id="' . $id . '" data-title="' . (!empty($module) ? $module->get_title() : $instance->get_title()) . '"' : '"') . '>' . implode($output) . '</div>'; }
function button_delete($url, $title = NULL) { NeoFrag::loader()->css('neofrag.delete')->js('neofrag.delete'); if ($title === NULL) { $title = NeoFrag::loader()->lang('remove'); } return button($url, 'fa-remove', $title, 'danger', 'delete'); }
public static function access() { return array('talk' => array('get_all' => function () { return NeoFrag::loader()->db->select('talk_id', 'CONCAT_WS(" ", "{lang talks}", name)')->from('nf_talks')->where('talk_id >', 1)->get(); }, 'check' => function ($talk_id) { if ($talk_id > 1 && ($talk = NeoFrag::loader()->db->select('name')->from('nf_talks')->where('talk_id', $talk_id)->row()) !== array()) { return '{lang talks} ' . $talk; } }, 'init' => array('read' => array(), 'write' => array(array('visitors', FALSE)), 'delete' => array(array('admins', TRUE))), 'access' => array(array('title' => '{lang talks}', 'icon' => 'fa-comment-o', 'access' => array('read' => array('title' => '{lang read}', 'icon' => 'fa-eye'), 'write' => array('title' => '{lang write}', 'icon' => 'fa-reply'))), array('title' => '{lang moderation}', 'icon' => 'fa-user', 'access' => array('delete' => array('title' => '{lang delete_message}', 'icon' => 'fa-trash-o')))))); }
public static function access() { return array('category' => array('get_all' => function () { return NeoFrag::loader()->db->select('category_id', 'CONCAT_WS(" ", "{lang category}", title)')->from('nf_forum_categories')->get(); }, 'check' => function ($category_id) { if (($category = NeoFrag::loader()->db->select('title')->from('nf_forum_categories')->where('category_id', $category_id)->row()) !== array()) { return '{lang category} ' . $category; } }, 'init' => array('category_read' => array(), 'category_write' => array(array('visitors', FALSE)), 'category_modify' => array(array('admins', TRUE)), 'category_delete' => array(array('admins', TRUE)), 'category_announce' => array(array('admins', TRUE)), 'category_lock' => array(array('admins', TRUE)), 'category_move' => array(array('admins', TRUE))), 'access' => array(array('title' => '{lang category}', 'icon' => 'fa-navicon', 'access' => array('category_read' => array('title' => '{lang read}', 'icon' => 'fa-eye'), 'category_write' => array('title' => '{lang write}', 'icon' => 'fa-reply'))), array('title' => '{lang moderation}', 'icon' => 'fa-user', 'access' => array('category_modify' => array('title' => '{lang edit_topic_message}', 'icon' => 'fa-edit'), 'category_delete' => array('title' => '{lang remove_topic_message}', 'icon' => 'fa-trash-o'), 'category_announce' => array('title' => '{lang set_topic_announce}', 'icon' => 'fa-flag'), 'category_lock' => array('title' => '{lang lock_a_topic}', 'icon' => 'fa-lock'), 'category_move' => array('title' => 'Déplacer un sujet', 'icon' => 'fa-reply fa-flip-horizontal')))))); }
public function __construct($module_name) { if (NeoFrag::loader()->theme) { if (in_array($theme_name = NeoFrag::loader()->theme->name, array('default', 'admin'))) { unset($theme_name); } } $this->load = new Loader(array('assets' => array('./assets', !empty($theme_name) ? './themes/' . $theme_name . '/overrides/modules/' . $module_name : '', './overrides/modules/' . $module_name, './neofrag/modules/' . $module_name, './modules/' . $module_name), 'controllers' => array(!empty($theme_name) ? './themes/' . $theme_name . '/overrides/modules/' . $module_name . '/controllers' : '', './overrides/modules/' . $module_name . '/controllers', './neofrag/modules/' . $module_name . '/controllers', './modules/' . $module_name . '/controllers'), 'forms' => array(!empty($theme_name) ? './themes/' . $theme_name . '/overrides/modules/' . $module_name . '/forms' : '', './overrides/modules/' . $module_name . '/forms', './neofrag/modules/' . $module_name . '/forms', './modules/' . $module_name . '/forms'), 'helpers' => array(!empty($theme_name) ? './themes/' . $theme_name . '/overrides/modules/' . $module_name . '/helpers' : '', './overrides/modules/' . $module_name . '/helpers', './neofrag/modules/' . $module_name . '/helpers', './modules/' . $module_name . '/helpers'), 'lang' => array(!empty($theme_name) ? './themes/' . $theme_name . '/overrides/modules/' . $module_name . '/lang' : '', './overrides/modules/' . $module_name . '/lang', './neofrag/modules/' . $module_name . '/lang', './modules/' . $module_name . '/lang'), 'libraries' => array(!empty($theme_name) ? './themes/' . $theme_name . '/overrides/modules/' . $module_name . '/libraries' : '', './overrides/modules/' . $module_name . '/libraries', './neofrag/modules/' . $module_name . '/libraries', './modules/' . $module_name . '/libraries'), 'models' => array(!empty($theme_name) ? './themes/' . $theme_name . '/overrides/modules/' . $module_name . '/models' : '', './overrides/modules/' . $module_name . '/models', './neofrag/modules/' . $module_name . '/models', './modules/' . $module_name . '/models'), 'views' => array(!empty($theme_name) ? './themes/' . $theme_name . '/overrides/modules/' . $module_name . '/views' : '', './overrides/modules/' . $module_name . '/views', './neofrag/modules/' . $module_name . '/views', './modules/' . $module_name . '/views')), NeoFrag::loader()); $this->name = $module_name; $this->set_path(); }
public function index() { $users = $this->title($this('dashboard'))->js('jquery.knob')->js_load('$(\'.knob\').knob();')->load->library('table')->add_columns(array(array('content' => function ($data) { return '<a href="mailto:' . $data['email'] . '" data-toggle="tooltip" title="' . $data['email'] . '">' . icon('fa-envelope') . '</a>'; }), array('content' => function ($data) { return NeoFrag::loader()->user->link($data['user_id'], $data['username']); }), array('content' => function ($data, $loader) { return '<span data-toggle="tooltip" title="' . timetostr($loader->lang('date_time_long'), $data['registration_date']) . '">' . time_span($data['registration_date']) . '</span>'; }, 'class' => 'text-right')))->data($this->db->from('nf_users')->where('deleted', FALSE)->order_by('user_id DESC')->limit(5)->get())->display(); return array(new Row(new Col(new Panel_box(array('label' => $this('news', $count = $this->db->select('COUNT(*)')->from('nf_news')->where('published', TRUE)->row()), 'icon' => 'fa-newspaper-o', 'color' => 'bg-aqua', 'count' => $count, 'url' => 'admin/news.html', 'footer' => $this('manage_news') . ' ' . icon('fa-arrow-circle-right'), 'size' => 'col-md-4 col-lg-2'))), new Col(new Panel_box(array('label' => $this('members', $count = $this->db->select('COUNT(*)')->from('nf_users')->where('deleted', FALSE)->row()), 'icon' => 'fa-users', 'color' => 'bg-green', 'count' => $count, 'url' => 'admin/members.html', 'footer' => $this('manage_members') . ' ' . icon('fa-arrow-circle-right'), 'size' => 'col-md-4 col-lg-2'))), new Col(new Panel_box(array('label' => $this('events', $count = 0, $count), 'icon' => 'fa-calendar', 'color' => 'bg-blue', 'count' => $count, 'url' => 'admin/events.html', 'footer' => $this('manage_events') . ' ' . icon('fa-arrow-circle-right'), 'size' => 'col-md-4 col-lg-2'))), new Col(new Panel_box(array('label' => $this('teams', $count = $this->db->select('COUNT(*)')->from('nf_teams')->row(), $count), 'icon' => 'fa-gamepad', 'color' => 'bg-red', 'count' => $count, 'url' => 'admin/teams.html', 'footer' => $this('manage_teams') . ' ' . icon('fa-arrow-circle-right'), 'size' => 'col-md-4 col-lg-2'))), new Col(new Panel_box(array('label' => $this('messages', $count = $this->db->select('COUNT(*)')->from('nf_forum_messages')->row()), 'icon' => 'fa-comments', 'color' => 'bg-teal', 'count' => $count, 'url' => 'admin/forum.html', 'footer' => $this('manage_forum') . ' ' . icon('fa-arrow-circle-right'), 'size' => 'col-md-4 col-lg-2'))), new Col(new Panel_box(array('label' => $this('comments', $count = $this->db->select('COUNT(*)')->from('nf_comments')->row()), 'icon' => 'fa-comments-o', 'color' => 'bg-maroon', 'count' => $count, 'url' => 'admin/comments.html', 'footer' => $this('manage_comments') . ' ' . icon('fa-arrow-circle-right'), 'size' => 'col-md-4 col-lg-2')))), new Row(new Col(new Widget_view(array('widget_id' => 1)), new Panel(array('title' => '<a href="//www.neofrag.com">' . $this('nf_news') . '</a>', 'icon' => 'fa-newspaper-o', 'content' => $this->load->view('nf_news'), 'size' => 'col-md-8'))), new Col(new Panel(array('title' => $this('connected_users'), 'icon' => 'fa-globe', 'content' => $this->load->view('users_online', array('currently' => $this->db->select('COUNT(*)')->from('nf_sessions')->where('last_activity > DATE_SUB(NOW(), INTERVAL 5 MINUTE)')->where('is_crawler', FALSE)->row(), 'max' => statistics('nf_sessions_max_simultaneous'))), 'footer' => '<a href="' . url('admin/members/sessions.html') . '">' . $this('view_all_sessions') . '</a>', 'size' => 'col-md-4')), new Panel(array('title' => $this('last_registrations'), 'icon' => 'fa-users', 'content' => $users, 'size' => 'col-md-4'))))); }
public function index($members) { $this->title($this('member_list'))->load->library('table')->add_columns(array(array('content' => function ($data) { return '<img class="img-avatar-members" style="max-height: 40px; max-width: 40px;" src="' . NeoFrag::loader()->user->avatar($data['avatar'], $data['sex']) . '" title="' . $data['username'] . '" alt="" />'; }, 'size' => TRUE), array('title' => 'Membre', 'content' => function ($data, $loader) { return '<div>' . NeoFrag::loader()->user->link($data['user_id'], $data['username']) . '</div><small>' . icon('fa-circle ' . ($data['online'] ? 'text-green' : 'text-gray')) . ' ' . $loader->lang($data['admin'] ? 'admin' : 'member') . ' ' . $loader->lang($data['online'] ? 'online' : 'offline') . '</small>'; }, 'search' => function ($data) { return $data['username']; })))->data($members)->no_data($this('no_members')); return new Panel(array('title' => $this('member_list'), 'icon' => 'fa-users', 'content' => $this->table->display())); }
public function display($id = NULL) { NeoFrag::loader()->css('neofrag.panel-box'); return '<div class="small-box ' . $this->color . '"> <div class="inner"> <h3>' . $this->count . '</h3> <p>' . $this->label . '</p> </div> ' . ($this->icon ? '<div class="icon">' . icon($this->icon) . '</div>' : '') . ' <a class="small-box-footer" href="' . url($this->url) . '"> ' . $this->footer . ' </a> </div>'; }
public function index($news) { $this->title($this('news'))->load->library('table'); $news = $this->table->add_columns(array(array('content' => function ($data, $loader) { return $data['published'] ? '<i class="fa fa-circle" data-toggle="tooltip" title="' . $loader->lang('published') . '" style="color: #7bbb17;"></i>' : '<i class="fa fa-circle-o" data-toggle="tooltip" title="' . $loader->lang('awaiting_publication') . '" style="color: #535353;"></i>'; }, 'sort' => function ($data) { return $data['published']; }, 'size' => TRUE), array('title' => $this('title'), 'content' => function ($data) { return '<a href="' . url('news/' . $data['news_id'] . '/' . url_title($data['title']) . '.html') . '">' . $data['title'] . '</a>'; }, 'sort' => function ($data) { return $data['title']; }, 'search' => function ($data) { return $data['title']; }), array('title' => $this('category'), 'content' => function ($data) { return '<a href="' . url('admin/news/categories/' . $data['category_id'] . '/' . $data['category_name'] . '.html') . '"><img src="' . path($data['category_icon']) . '" alt="" /> ' . $data['category_title'] . '</a>'; }, 'sort' => function ($data) { return $data['category_title']; }, 'search' => function ($data) { return $data['category_title']; }), array('title' => $this('author'), 'content' => function ($data) { return NeoFrag::loader()->user->link($data['user_id'], $data['username']); }, 'sort' => function ($data) { return $data['username']; }, 'search' => function ($data) { return $data['username']; }), array('title' => $this('date'), 'content' => function ($data) { return '<span data-toggle="tooltip" title="' . timetostr(NeoFrag::loader()->lang('date_time_long'), $data['date']) . '">' . time_span($data['date']) . '</span>'; }, 'sort' => function ($data) { return $data['date']; }), array('title' => '<i class="fa fa-comments-o" data-toggle="tooltip" title="' . i18n('comments') . '"></i>', 'content' => function ($data) { return NeoFrag::loader()->library('comments')->admin_comments('news', $data['news_id']); }, 'size' => TRUE), array('content' => array(function ($data) { return button_edit('admin/news/' . $data['news_id'] . '/' . url_title($data['title']) . '.html'); }, function ($data) { return button_delete('admin/news/delete/' . $data['news_id'] . '/' . url_title($data['title']) . '.html'); }), 'size' => TRUE)))->sort_by(5, SORT_DESC, SORT_NUMERIC)->data($news)->no_data($this('no_news'))->display(); $categories = $this->table->add_columns(array(array('content' => function ($data) { return '<a href="' . url('admin/news/categories/' . $data['category_id'] . '/' . $data['name'] . '.html') . '"><img src="' . path($data['icon_id']) . '" alt="" /> ' . $data['title'] . '</a>'; }, 'search' => function ($data) { return $data['title']; }, 'sort' => function ($data) { return $data['title']; }), array('content' => array(function ($data) { return button_edit('admin/news/categories/' . $data['category_id'] . '/' . $data['name'] . '.html'); }, function ($data) { return button_delete('admin/news/categories/delete/' . $data['category_id'] . '/' . $data['name'] . '.html'); }), 'size' => TRUE)))->pagination(FALSE)->data($this->model('categories')->get_categories())->no_data($this('no_category'))->display(); return new Row(new Col(new Panel(array('title' => $this('categories'), 'icon' => 'fa-align-left', 'content' => $categories, 'footer' => button_add('admin/news/categories/add.html', $this('create_category')), 'size' => 'col-md-12 col-lg-3'))), new Col(new Panel(array('title' => $this('list_news'), 'icon' => 'fa-file-text-o', 'content' => $news, 'footer' => button_add('admin/news/add.html', $this('add_news')), 'size' => 'col-md-12 col-lg-9')))); }
public function index() { $this->css('font.open-sans.300.400.600.700.800')->css('live-editor')->js('live-editor'); $dispositions = $this->db->select('DISTINCT page')->from('nf_settings_dispositions')->where('theme', $theme)->get(); $modules = array(); foreach ($this->get_modules(TRUE) as $module) { //TODO if (!in_array($module->name, array('access', 'admin', 'comments', 'error', 'live_editor', 'pages', 'settings', 'games', 'talks'))) { $modules[$module->name] = $module->get_title(); } } natcasesort($modules); $modules = array_merge(array('index' => NeoFrag::loader()->lang('home')), $modules); echo $this->load->view('index', array('modules' => $modules, 'styles_row' => NeoFrag::loader()->theme->styles_row(), 'styles_widget' => NeoFrag::loader()->theme->styles_widget())); }
public static function display($disposition_id, $disposition, $page, $zone_id) { global $NeoFrag; $output = display($disposition, NeoFrag::live_editor() ? $zone_id : NULL); if (!NeoFrag::live_editor() && in_string('<div class="module', $output)) { $output .= $NeoFrag->profiler->output(); } if (NeoFrag::live_editor()) { if (NeoFrag::live_editor() & NeoFrag::ZONES) { $output = ' <div class="pull-right"> ' . ($page == '*' ? '<button type="button" class="btn btn-link live-editor-fork" data-enable="0">' . icon('fa-toggle-off') . ' ' . $NeoFrag->lang('common_layout') . '</button>' : '<button type="button" class="btn btn-link live-editor-fork" data-enable="1">' . icon('fa-toggle-on') . ' ' . $NeoFrag->lang('custom_layout') . '</button>') . ' </div> <h3>' . (!empty($NeoFrag->load->theme->zones[$zone_id]) ? $NeoFrag->load->theme->load->lang($NeoFrag->load->theme->zones[$zone_id], NULL) : $NeoFrag->lang('zone', $zone_id)) . ' <div class="btn-group"><button type="button" class="btn btn-xs btn-success live-editor-add-row" data-toggle="tooltip" data-container="body" title="' . $NeoFrag->lang('new_row') . '">' . icon('fa-plus') . '</button></div></h3>' . $output; } $output = '<div' . (NeoFrag::live_editor() & NeoFrag::ZONES ? ' class="live-editor-zone"' : '') . ' data-disposition-id="' . $disposition_id . '">' . $output . '</div>'; } return $output; }
public function _tab_index($objects, $title, $module, $type, $all_access) { $this->subtitle($title)->load->library('table')->add_columns(array(array('title' => $this('name'), 'content' => function ($data) { return $data['title']; }))); foreach ($all_access['access'] as $a) { foreach ($a['access'] as $action => $access) { $this->table->add_columns(array(array('title' => '<div class="text-center" data-toggle="tooltip" title="' . $module->load->lang($access['title'], NULL) . '">' . icon($access['icon']) . '</div>', 'content' => function ($data) use($module, $action) { return NeoFrag::loader()->access->count($module->name, $action, $data['id']); }, 'class' => 'col-md-1'))); } } $this->table->add_columns(array(array('content' => array(function ($data, $loader) use($module, $type) { return button(NULL, 'fa-refresh', $loader->lang('reset'), 'info', 'access-reset', array('module' => $module->name, 'type' => $type, 'id' => $data['id'])); }, function ($data, $loader) use($module, $type) { return button_access($data['id'], $type, $module->name, $loader->lang('edit')); }))))->data($objects); echo $this->table->display(); }
function statistics($name, $value = NULL, $callback = NULL) { static $statistics; if (is_null($statistics)) { foreach (NeoFrag::loader()->db->from('nf_statistics')->get() as $stat) { $statistics[$stat['name']] = $stat['value']; } } if (func_num_args() > 1) { if (isset($statistics[$name])) { if (is_null($callback) || call_user_func($callback, $value, $statistics[$name])) { NeoFrag::loader()->db->where('name', $name)->update('nf_statistics', array('value' => $value)); } } else { NeoFrag::loader()->db->insert('nf_statistics', array('name' => $name, 'value' => $value)); } } else { return $statistics[$name]; } }
public function display($id = NULL) { $output = ''; if ($live_editor = NeoFrag::live_editor() & NeoFrag::ROWS && !is_null($id)) { $output .= '<div class="live-editor-row-header"> <div class="btn-group"> <button type="button" class="btn btn-sm btn-info live-editor-style" data-toggle="tooltip" data-container="body" title="' . NeoFrag::loader()->lang('design') . '">' . icon('fa-paint-brush') . '</button> <button type="button" class="btn btn-sm btn-danger live-editor-delete" data-toggle="tooltip" data-container="body" title="' . NeoFrag::loader()->lang('remove') . '">' . icon('fa-close') . '</button> </div> <h3>' . NeoFrag::loader()->lang('row') . ' <div class="btn-group"><button type="button" class="btn btn-xs btn-success live-editor-add-col" data-toggle="tooltip" data-container="body" title="' . NeoFrag::loader()->lang('new_col') . '">' . icon('fa-plus') . '</button></div></h3> </div>'; } $cols = array(); foreach ($this->cols as $i => $col) { $cols[] = $col->display(!is_null($id) ? $i : NULL); } $output .= '<div class="row' . (!empty($this->style) ? ' ' . $this->style . ($live_editor ? '" data-original-style="' . $this->style : '') : '') . '"' . (!is_null($id) ? ' data-row-id="' . $id . '"' : '') . '> ' . implode($cols) . ' </div>'; return $live_editor ? '<div class="live-editor-row">' . $output . '</div>' : $output; }
public function _team($team_id, $name, $title, $image_id, $icon_id, $description, $game_id, $game, $game_icon) { $this->title($title)->load->library('table')->add_columns(array(array('content' => function ($data) { return '<img class="img-avatar-members" style="max-height: 40px; max-width: 40px;" src="' . NeoFrag::loader()->user->avatar($data['avatar'], $data['sex']) . '" title="' . $data['username'] . '" alt="" />'; }, 'size' => TRUE), array('content' => function ($data, $loader) { return '<div>' . NeoFrag::loader()->user->link($data['user_id'], $data['username']) . '</div><small>' . icon('fa-circle ' . ($data['online'] ? 'text-green' : 'text-gray')) . ' ' . $loader->lang($data['admin'] ? 'admin' : 'member') . ' ' . $loader->lang($data['online'] ? 'online' : 'offline') . '</small>'; }), array('content' => function ($data) { return $data['title']; })))->data($this->model()->get_players($team_id))->no_data($this('no_players_on_team')); $panel = array('title' => ' <div class="pull-right"> <span class="label label-default">' . $game . '</span> </div> <a href="' . url('teams/' . $team_id . '/' . $name . '.html') . '">' . $title . '</a>', 'body' => FALSE); $panel['content'] = $this->load->view('index', array('team_id' => $team_id, 'name' => $name, 'title' => $title, 'image_id' => $image_id, 'description' => bbcode($description), 'users' => $this->table->display())); if ($icon_id || $game_icon) { $panel['title'] = '<img src="' . path($icon_id ?: $game_icon) . '" alt="" /> ' . $panel['title']; } else { $panel['icon'] = 'fa-gamepad'; } return array(new Panel($panel), new Button_back('teams.html')); }
public function get_addons($type, &$list_nf, &$list) { $list = $list_nf = array(); foreach ($this->_addons() as $object) { if ($object['type'] != $type) { continue; } $object_instance = NeoFrag::loader()->{$type}($object['name'], FALSE); if (is_null($object_instance)) { continue; } if ($object_instance->is_core()) { if (isset($object_instance->deactivatable) && !$object_instance->deactivatable) { continue; } $list_nf[] = $this->_data($object_instance); } else { $list[] = $this->_data($object_instance); } } }
public function display($id = NULL) { $output = ''; foreach ($this->widgets as $i => $widget) { if (!empty($widget->size)) { $this->_size = $widget->size; } $output .= $widget->display(!is_null($id) ? $i : NULL); } if (NeoFrag::live_editor() & NeoFrag::COLS && !is_null($id)) { $output = '<div class="live-editor-col"> <div class="btn-group"> <button type="button" class="btn btn-sm btn-default live-editor-size" data-size="-1" data-toggle="tooltip" data-container="body" title="' . NeoFrag::loader()->lang('reduce') . '">' . icon('fa-compress fa-rotate-45') . '</button> <button type="button" class="btn btn-sm btn-default live-editor-size" data-size="1" data-toggle="tooltip" data-container="body" title="' . NeoFrag::loader()->lang('increase') . '">' . icon('fa-expand fa-rotate-45') . '</button> <button type="button" class="btn btn-sm btn-danger live-editor-delete" data-toggle="tooltip" data-container="body" title="' . NeoFrag::loader()->lang('remove') . '">' . icon('fa-close') . '</button> </div> <h3>' . NeoFrag::loader()->lang('col') . ' <div class="btn-group"><button type="button" class="btn btn-xs btn-success live-editor-add-widget" data-toggle="tooltip" data-container="body" title="' . NeoFrag::loader()->lang('new_widget') . '">' . icon('fa-plus') . '</button></div></h3> ' . $output . ' </div>'; } return '<div class="' . $this->_size . '"' . (!is_null($id) ? ' data-col-id="' . $id . '"' : '') . '>' . $output . '</div>'; }
function display($objects, $id = NULL) { $output = ''; if (!NeoFrag::loader()->config->ajax_url) { if (is_object($objects) && is_a($objects, 'Panel')) { $objects = new Col($objects); } if (is_object($objects) && is_a($objects, 'Col')) { $objects = new Row($objects); } } if (!is_array($objects)) { $objects = array($objects); } foreach ($objects as $i => $object) { if (is_object($object)) { $output .= $object->display(!is_null($id) ? $i : NULL); } else { $output .= $object; } } return $output; }
public function display($module_name, $module_id) { $this->css('neofrag.comments')->js('neofrag.comments')->load->library('form')->add_rules(array('comment_id' => array(), 'comment' => array('rules' => 'required'))); if ($this->form->is_valid($post)) { $parent_id = NULL; if (!empty($post['comment_id']) && $this->db->select('COUNT(*)')->from('nf_comments')->where('module', $module_name)->where('module_id', $module_id)->where('parent_id', NULL)->where('comment_id', $post['comment_id'])->row() == 1) { $parent_id = $post['comment_id']; } $comment_id = $this->db->insert('nf_comments', array('parent_id' => $parent_id, 'user_id' => $this->user('user_id'), 'module_id' => $module_id, 'module' => $module_name, 'content' => $post['comment'])); redirect($this->config->request_url . '#comment-' . $comment_id); } $comments = $this->db->select('c.comment_id', 'c.parent_id', 'u.user_id', 'c.module_id', 'c.module', 'c.content', 'c.date', 'u.username', 'up.avatar', 'up.sex')->from('nf_comments c')->join('nf_users u', 'u.user_id = c.user_id AND u.deleted = "0"')->join('nf_users_profiles up', 'u.user_id = up.user_id')->where('module', $module_name)->where('module_id', $module_id)->order_by('IFNULL(c.parent_id, c.comment_id) DESC')->get(); $output = ''; foreach ($comments as $comment) { $output .= $this->load->view('index', $comment); } $count = count($comments); $panels = array(); if ($errors = $this->form->get_errors()) { $panels[] = new Panel(array('title' => '<a name="comments"></a>' . NeoFrag::loader()->lang('message_needed'), 'icon' => 'fa-warning', 'style' => 'panel-danger')); } $panels[] = new Panel(array('title' => '<a name="comments"></a>' . NeoFrag::loader()->lang('comments', $count, $count), 'icon' => 'fa-comments-o', 'content' => $output . $this->load->view('new', array('form_id' => $this->form->id)))); return display($panels); }
public function _tab_index($comments, $title = NULL) { $this->subtitle(is_null($title) ? $this('all_comments') : $title)->load->library('table'); if (is_null($title)) { $this->table->add_columns(array(array('title' => $this('module'), 'content' => function ($data) { return '<a href="' . url('admin/comments/' . $data['module'] . '.html') . '">' . icon($data['icon']) . ' ' . $data['module_title'] . '</a>'; }, 'size' => '25%', 'sort' => function ($data) { return $data['module_title']; }, 'search' => function ($data) { return $data['module_title']; }))); } echo $this->table->add_columns(array(array('title' => $this('name'), 'content' => function ($data) { return $data['title']; }, 'sort' => function ($data) { return $data['title']; }, 'search' => function ($data) { return $data['title']; }), array('title' => '<i class="fa fa-comments-o" data-toggle="tooltip" title="' . $this('number_comments') . '"></i>', 'content' => function ($data) { return NeoFrag::loader()->library('comments')->admin_comments($data['module'], $data['module_id'], FALSE); }, 'size' => TRUE), array('content' => function ($data, $loader) { return button($data['url'], 'fa-eye', $loader->lang('see_comments'), 'info'); }, 'size' => TRUE)))->data($comments)->no_data($this('no_comments'))->sort_by(1)->display(); }
private function _init() { if ($user_id = $this->session('user_id')) { $user = $this->db->select('u.username', 'u.password', 'u.salt', 'u.email', 'u.admin', 'u.theme', 'u.language', 'u.registration_date', 'p.first_name', 'p.last_name', 'p.avatar', 'p.signature', 'p.date_of_birth', 'p.sex', 'p.location', 'p.website', 'p.quote')->from('nf_users u')->join('nf_users_profiles p', 'u.user_id = p.user_id')->where('u.user_id', $user_id)->where('u.deleted', FALSE)->row(); if ($user) { $this->_user_data['user_id'] = (int) $user_id; $this->_user_data['username'] = $user['username']; $this->_user_data['password'] = $user['password']; $this->_user_data['salt'] = $user['salt']; $this->_user_data['email'] = $user['email']; $this->_user_data['admin'] = (bool) $user['admin']; $this->_user_data['theme'] = $user['theme']; $this->_user_data['language'] = $user['language']; $this->_user_data['registration_date'] = $user['registration_date']; $this->_user_data['last_activity_date'] = now(); $this->_user_data['first_name'] = $user['first_name']; $this->_user_data['last_name'] = $user['last_name']; $this->_user_data['avatar'] = $user['avatar']; $this->_user_data['signature'] = $user['signature']; $this->_user_data['date_of_birth'] = $user['date_of_birth']; $this->_user_data['sex'] = $user['sex']; $this->_user_data['location'] = $user['location']; $this->_user_data['website'] = $user['website']; $this->_user_data['quote'] = $user['quote']; $this->_user_data['messages_unread'] = $this->db->from('nf_users_messages_recipients')->where('user_id', $this('user_id'))->where('`read`', FALSE)->num_rows(); $this->db->where('user_id', $this->_user_data['user_id'])->update('nf_users', array('last_activity_date' => now())); } } $this->config->set_language(); $this->check_http_authentification(); if ($this->config->nf_maintenance) { if ($this->config->nf_maintenance_opening && date_create() >= ($opening = date_create($this->config->nf_maintenance_opening))) { $this->config('nf_maintenance', FALSE, 'bool')->config('nf_maintenance_opening', ''); } else { if (!$this('admin') && $this->config->request_url != 'user/logout.html') { header('HTTP/1.0 503 Service Unavailable'); if (!empty($opening)) { header('Retry-After: ' . $opening->setTimezone(new DateTimezone('UTC'))->format('D, d M Y H:i:s \\G\\M\\T')); } if (!$this->config->ajax_header) { $form_login = $this->load->library('form')->set_id('dd74f62896869c798933e29305aa9473')->add_rules(array('login' => array('rules' => 'required'), 'password' => array('type' => 'password')))->save(); if ($form_login->is_valid($post)) { $module = $this->load->init_module('user'); $user_id = $module->load->model($module, 'user')->check_login($post['login'], $hash, $salt); if ($user_id > 0 && $this->load->library('password')->is_valid($post['password'] . $salt, $hash, (bool) $salt)) { $this->login($user_id, FALSE); refresh(); } } $this->load->theme($this->config->nf_default_theme); echo $this->load->theme->load->view('default', array('lang' => $this->config->lang, 'css' => implode("\r\n", array('<link rel="stylesheet" href="' . path('font.open-sans.300.400.600.700.800.css', 'css') . '" type="text/css" media="screen" />', '<link rel="stylesheet" href="' . path('jquery.countdown.css', 'css') . '" type="text/css" media="screen" />', '<link rel="stylesheet" href="' . path('style.maintenance.css', 'css') . '" type="text/css" media="screen" />')), 'js' => implode("\r\n", array('<script type="text/javascript" src="' . path('jquery.countdown.js', 'js') . '"></script>', '<script type="text/javascript" src="' . path('maintenance.js', 'js') . '"></script>')), 'page_title' => ($page_title = $this->config->nf_maintenance_title ?: NeoFrag::loader()->lang('website_under_maintenance')) . ' :: ' . $this->config->nf_name, 'body' => $this->load->theme->load->view('maintenance', array('page_title' => $page_title)))); } exit; } } } }
public static function unset_module() { unset(NeoFrag::loader()->module); NeoFrag::loader()->config->extension_url = 'html'; NeoFrag::loader()->module = NULL; }
function user_agent($user_agent) { NeoFrag::loader()->js('neofrag.user-agent'); return '<img src="' . image('ajax-loader.gif') . '" data-user-agent="' . $user_agent . '" alt="" />'; }
public function users($action, $title, $icon, $module_name, $id) { $this->load->library('table')->add_columns(array(array('title' => $this('member'), 'content' => function ($data) { return NeoFrag::loader()->user->link($data['user_id'], $data['username']) . '<span data-user-id="' . $data['user_id'] . '"></span>'; }, 'sort' => function ($data) { return $data['username']; }, 'search' => function ($data) { return $data['username']; }), array('title' => $this('groups'), 'content' => function ($data) { return NeoFrag::loader()->groups->user_groups($data['user_id']); }, 'sort' => function ($data) { return NeoFrag::loader()->groups->user_groups($data['user_id'], FALSE); }, 'search' => function ($data) { return NeoFrag::loader()->groups->user_groups($data['user_id'], FALSE); }), array('content' => function ($data, $loader) { $output = ''; if ($data['active'] === NULL) { $output = '<div data-toggle="tooltip" title="' . $loader->lang('ambiguity') . '">' . icon('fa-warning text-danger') . '</div>'; } else { if (is_int($data['active'])) { $output = '<a class="access-revoke" href="#" data-toggle="tooltip" title="' . $loader->lang('reset_automatic') . '">' . icon('fa-thumb-tack') . '</a>'; } } return '<td class="access-status">' . $output . '</td>'; }, 'sort' => function ($data) { return $data['active'] === NULL; }, 'size' => TRUE, 'td' => FALSE), array('title' => '<div class="text-center" data-toggle="tooltip" title="' . $this('authorized_member') . '">' . icon('fa-check') . '</i></div>', 'content' => function ($data, $loader) { return $loader->view('radio', array('class' => 'success', 'active' => $data['active'])); }, 'td' => FALSE), array('title' => '<div class="text-center" data-toggle="tooltip" title="' . $this('forbidden_member') . '">' . icon('fa-ban') . '</i></div>', 'content' => function ($data, $loader) { static $admins; if ($admins === NULL) { $admins = NeoFrag::loader()->groups()['admins']['users']; } return in_array($data['user_id'], $admins) ? '<td></td>' : $loader->view('radio', array('class' => 'danger', 'active' => !$data['active'] && $data['active'] !== NULL)); }, 'td' => FALSE)))->data($this->db->select('user_id', 'username')->from('nf_users')->where('deleted', FALSE)->get())->preprocessing(function ($row) use($module_name, $action, $id) { $row['active'] = NeoFrag::loader()->access($module_name, $action, $id, NULL, $row['user_id']); return $row; })->sort_by(3, SORT_DESC)->sort_by(2, SORT_ASC)->sort_by(1, SORT_ASC); return $this->load->view('users', array('title' => $title, 'icon' => $icon, 'users' => $this->table->display())); }
function bbcode($string) { return nl2br(strtolink(NeoFrag::loader()->load->library('text_editor')->bbcode2html($string), TRUE)); }
along with NeoFrag. If not, see <http://www.gnu.org/licenses/>. **************************************************************************/ $rules = array('username' => array('label' => '{lang username}', 'value' => $username, 'rules' => 'required', 'check' => function ($value) use($username) { if ($value != $username && NeoFrag::loader()->db->select('1')->from('nf_users')->where('username', $value)->row()) { return i18n('username_unavailable'); } }), 'password_old' => array('label' => '{lang current_password}', 'icon' => 'fa-lock', 'type' => 'password', 'check' => function ($value, $post) { if (strlen($value) && strlen($post['password_new']) && strlen($post['password_confirm']) && !NeoFrag::loader()->load->library('password')->is_valid($value . ($salt = NeoFrag::loader()->user('salt')), NeoFrag::loader()->user('password'), (bool) $salt)) { return i18n('invalid_password'); } }), 'password_new' => array('label' => '{lang new_password}', 'icon' => 'fa-lock', 'type' => 'password'), 'password_confirm' => array('label' => '{lang password_confirmation}', 'icon' => 'fa-lock', 'type' => 'password', 'check' => function ($value, $post) { if ($post['password_new'] != $value) { return '{password_not_match}'; } }), 'email' => array('label' => '{lang email}', 'value' => $email, 'type' => 'email', 'rules' => 'required', 'check' => function ($value) use($email) { if ($value != $email && NeoFrag::loader()->db->select('1')->from('nf_users')->where('email', $value)->row()) { return i18n('email_unavailable'); } }), 'first_name' => array('label' => '{lang first_name}', 'value' => $first_name), 'last_name' => array('label' => '{lang last_name}', 'value' => $last_name), 'avatar' => array('label' => '{lang avatar}', 'value' => $avatar, 'upload' => 'members', 'type' => 'file', 'info' => i18n('file_icon', 250, file_upload_max_size() / 1024 / 1024), 'check' => function ($filename, $ext) { if (!in_array($ext, array('gif', 'jpeg', 'jpg', 'png'))) { return i18n('select_image_file'); } list($w, $h) = getimagesize($filename); if ($w != $h) { return i18n('avatar_must_be_square'); } else { if ($w < 250) { return i18n('avatar_size_error', 250); } } }, 'post_upload' => function ($filename) {
$rules = array('username' => array('label' => '{lang username}', 'value' => $username, 'rules' => 'required', 'check' => function ($value) use($username) { if ($value != $username && NeoFrag::loader()->db->select('1')->from('nf_users')->where('username', $value)->row()) { return i18n('username_unavailable'); } }), 'email' => array('label' => '{lang email}', 'value' => $email, 'type' => 'email', 'rules' => 'required', 'check' => function ($value) use($email) { if ($value != $email && NeoFrag::loader()->db->select('1')->from('nf_users')->where('email', $value)->row()) { return i18n('email_unavailable'); } }), 'first_name' => array('label' => '{lang first_name}', 'value' => $first_name), 'last_name' => array('label' => '{lang last_name}', 'value' => $last_name), 'avatar' => array('label' => '{lang avatar}', 'value' => $avatar, 'upload' => 'members', 'type' => 'file', 'info' => i18n('file_icon', 250, file_upload_max_size() / 1024 / 1024), 'check' => function ($filename, $ext) { if (!in_array($ext, array('gif', 'jpeg', 'jpg', 'png'))) { return i18n('select_image_file'); } list($w, $h) = getimagesize($filename); if ($w != $h) { return i18n('avatar_must_be_square'); } else { if ($w < 250) { return i18n('avatar_size_error', 250); } } }, 'post_upload' => function ($filename) { image_resize($filename, 250, 250); }), 'date_of_birth' => array('label' => '{lang birth_date}', 'value' => $date_of_birth && $date_of_birth != '0000-00-00' ? timetostr(NeoFrag::loader()->lang('date_short'), strtotime($date_of_birth)) : '', 'type' => 'date', 'check' => function ($value) { if ($value && strtotime($value) > strtotime(date('Y-m-d'))) { return i18n('invalid_birth_date'); } }), 'sex' => array('label' => '{lang gender}', 'value' => $sex, 'values' => array('female' => icon('fa-female') . ' {lang female}', 'male' => icon('fa-male') . ' {lang male}'), 'type' => 'radio'), 'location' => array('label' => '{lang location}', 'value' => $location), 'website' => array('label' => '{lang website}', 'value' => $website, 'type' => 'url'), 'quote' => array('label' => '{lang quote}', 'value' => $quote), 'signature' => array('label' => '{lang signature}', 'value' => $signature, 'type' => 'editor')); /* NeoFrag Alpha 0.1.2 ./neofrag/modules/members/forms/members.php */
/************************************************************************** Copyright © 2015 Michaël BILCOT & Jérémy VALENTIN This file is part of NeoFrag. NeoFrag is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. NeoFrag is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with NeoFrag. If not, see <http://www.gnu.org/licenses/>. **************************************************************************/ $rules = array('title' => array('label' => '{lang page_title}', 'value' => $title, 'type' => 'text', 'rules' => 'required'), 'subtitle' => array('label' => '{lang subtitle}', 'value' => $subtitle, 'type' => 'text'), 'name' => array('label' => '{lang access_path}', 'value' => $name, 'type' => 'text', 'check' => function ($value, $post) use($name) { if (!$value) { $value = $post['title']; } $value = url_title($value); if ($value != $name && NeoFrag::loader()->db->select('1')->from('nf_pages')->where('name', $value)->row()) { return i18n('access_path_already_used'); } }), 'content' => array('label' => '{lang content}', 'value' => $content, 'type' => 'editor'), 'published' => array('type' => 'checkbox', 'checked' => array('on' => $published), 'values' => array('on' => '{lang publish_now}'))); /* NeoFrag Alpha 0.1.2 ./neofrag/modules/pages/forms/pages.php */