/** * User profile */ public function _view() { $this->tab_id = 'profile'; $owner = $this->user && $this->member->id == $this->user->id; if ($owner && $this->user->newcomments) { $this->user->newcomments = 0; $this->user->save(); } // Actions if ($this->member->has_access(User_Model::ACCESS_EDIT)) { $this->page_actions[] = array('link' => url::user($this->member) . '/edit', 'text' => __('Settings'), 'class' => 'settings'); } // Picture widget::add('side', View_Mod::factory('member/member', array('mod_class' => 'member member-' . $this->member->id, 'user' => $this->member))); // Comments if ($this->member->has_access(User_Model::ACCESS_COMMENT)) { $comment = new User_Comment_Model(); $form_values = $comment->as_array(); $form_errors = array(); // check post if (csrf::valid() && ($post = $this->input->post())) { $comment->user_id = $this->member->id; $comment->author_id = $this->user->id; $comment->comment = $post['comment']; if (isset($post['private'])) { $comment->private = 1; } try { $comment->save(); if (!$owner) { $this->member->newcomments += 1; $this->member->save(); } $this->user->commentsleft += 1; $this->user->save(); if (!request::is_ajax()) { url::redirect(url::current()); } } catch (ORM_Validation_Exception $e) { $form_errors = $e->validation->errors(); $form_values = arr::overwrite($form_values, $post); } } // Handle pagination $per_page = 25; $page_num = $this->uri->segment('page') ? $this->uri->segment('page') : 1; $page_offset = ($page_num - 1) * $per_page; $total_comments = $this->member->get_comment_count(); $comments = $this->member->find_comments($page_num, $per_page, $this->user); $pagination = new Pagination(array('items_per_page' => $per_page, 'total_items' => $total_comments)); $view = View::factory('generic/comments', array('delete' => '/member/comment/%d/delete/?token=' . csrf::token(), 'private' => '/member/comment/%d/private/?token=' . csrf::token(), 'comments' => $comments, 'errors' => $form_errors, 'values' => $form_values, 'pagination' => $pagination, 'user' => $this->user)); if (request::is_ajax()) { echo $view; return; } widget::add('main', $view); } // Basic info $basic_info = array(); if (!empty($this->member->name)) { $basic_info[__('Name')] = html::specialchars($this->member->name); } if (!empty($this->member->city_name)) { $basic_info[__('City')] = html::specialchars($this->member->city_name); } if (!empty($this->member->dob) && $this->member->dob != '0000-00-00') { $basic_info[__('Date of Birth')] = __(':dob (:years years)', array(':dob' => date::format('DMYYYY', $this->member->dob), ':years' => date::timespan(strtotime($this->member->dob), null, 'years'))); } if (!empty($this->member->gender)) { $basic_info[__('Gender')] = $this->member->gender == 'm' ? __('Male') : __('Female'); } if (!empty($this->member->latitude) && !empty($this->member->longitude)) { $basic_info[__('Location')] = $this->member->latitude . ', ' . $this->member->longitude; $basic_info[__('Location')] = html::anchor('#map', __('Toggle map'), array('class' => 'expander', 'title' => __('Show/hide'))) . '<div id="map" style="display: none">' . __('Map loading') . '</div>'; $map = new Gmap('map', array('ScrollWheelZoom' => true)); $map->center($this->member->latitude, $this->member->longitude, 15)->controls('small')->types(); $map->add_marker($this->member->latitude, $this->member->longitude, html::avatar($this->member->avatar, $this->member->username) . html::user($this->member)); widget::add('foot', html::script_source($map->render('gmaps/jquery_event'))); widget::add('foot', html::script_source("\$('a[href*=\"#map\"]:first').click(function() { \$('#map').toggle('normal', gmap_open); return false; });")); } // Site info $site_info = array(__('Registered') => date::format('DMYYYY_HM', $this->member->created) . ' [#' . $this->member->id . ']', __('Logins') => __(':logins (:ago ago)', array(':logins' => number_format($this->member->logins, 0), ':ago' => '<abbr title="' . date::format('DMYYYY_HM', $this->member->last_login) . '">' . date::timespan_short($this->member->last_login) . '</abbr>')), __('Posts') => number_format($this->member->posts, 0), __('Comments') => number_format($this->member->commentsleft, 0)); // Initialize tabs $tabs = array('basic-info' => array('href' => '#basic-info', 'title' => __('Basic info'), 'tab' => new View('generic/list_info', array('id' => 'basic-info', 'title' => __('Basic info'), 'list' => $basic_info))), 'site-info' => array('href' => '#site-info', 'title' => __('Site info'), 'tab' => new View('generic/list_info', array('id' => 'site-info', 'title' => __('Site info'), 'list' => $site_info)))); widget::add('side', View::factory('generic/tabs', array('id' => 'info-tab', 'tabs' => $tabs))); $this->_side_views(); }
public function jquery() { $map = new Gmap('map'); $map->center(0, 35, 16)->controls('large'); View::factory('gmaps/jquery')->set(array('api_url' => Gmap::api_url(), 'map' => $map->render('gmaps/jquery_javascript')))->render(TRUE); }
</dd> <?php } ?> </dl> <?php if ($venue->latitude && $venue->longitude) { ?> <div id="map" style="display: none"><?php echo __('Map loading'); ?> </div> <?php $map = new Gmap('map', array('ScrollWheelZoom' => true)); $map->center($venue->latitude, $venue->longitude, 15)->controls('small')->types(); $map->add_marker($venue->latitude, $venue->longitude, '<strong>' . html::chars($venue->name) . '</strong><p>' . html::chars($venue->address) . '<br />' . html::chars($venue->zip) . ' ' . html::chars($venue->city_name) . '</p>'); widget::add('foot', html::script_source($map->render('gmaps/jquery_event'))); widget::add('foot', html::script_source("\$('.contact a[href=#map]').click(function() { \$('#map').toggle('normal', gmap_open); return false; });")); ?> <?php } ?> <?php } ?> </article> <?php if (count($venue->images->find_all()) > 1) {
?> , <?php echo $user->longitude; ?> </dd> <dd><?php echo html::anchor('#map', __('Toggle map'), array('class' => 'expander', 'title' => __('Show/hide'))); ?> </dd> <dd><div id="map" style="display: none"><?php echo __('Map loading'); ?> </div></dd> <?php $map = new Gmap('map', array('ScrollWheelZoom' => true)); $map->center($user->latitude, $user->longitude, 15)->controls('small')->types('G_PHYSICAL_MAP', 'add'); $map->add_marker($user->latitude, $user->longitude, '<strong>' . html::specialchars($user->username) . '</strong>'); widget::add('foot', html::script_source($map->render('gmaps/jquery_event'))); widget::add('foot', html::script_source("\$('a[href*=\"#map\"]:first').click(function() { \$('#map').toggle('normal', gmap_open); return false; });")); ?> <?php } ?> </dl> </div> <div id="site-info"> <h4><?php echo __('Site Info'); ?> </h4>