/** * @return OBJECT * @param [ARRAY] * @desc Formats data to be used by ETS. Assumes extra data has been passed. * @date 12-19-03 */ function format($d = false, &$user, $lang_edit = 'edit') { if ($d) { $this->setData($d); } $allowed = array('author', 'access', 'subject', 'body', 'mood', 'views', 'custom_title'); foreach ($this->data as $key => $val) { if (in_array($key, $allowed)) { $r->{$key} = $val; } } if (!empty($this->data['mood'])) { $r->mood = $this->data['mood']; } if (!empty($this->data['custom_text']) && !empty($this->data['custom_title'])) { $r->custom_text = $this->data['custom_text']; } if ($this->data['comments'] != -1) { $r->comments = true; $r->comments_num = $this->data['comments']; if ($this->data['access'] == access_news) { // process as news item $r->comments_url = build_link('index.php', array('action' => 'comment', 'id' => $this->data['blog_id'])); } else { $r->comments_url = build_link('blog.php', array('id' => $this->data['blog_id'])); } } else { $r->comments = false; } $r->author_url_profile = build_link('profile.php', array('user' => $this->data['author_id'])); $r->author_url_blogs = build_link('blog.php', array('user' => $this->data['author_id'])); if ($this->data['html'] == 0) { $r->body = htmlspecialchars($r->body); } if ($this->data['bb'] == 1) { $r->body = insertBBCode($r->body); } if ($this->data['smiles'] == 1) { $r->body = $this->addSmiles($r->body); } $r->body = nl2br($r->body); // Set to users local timezone if ($this->offset_server && $this->offset_user) { $servertime = date_offset($this->data['date'], $this->offset_server); $localtime = date_offset($servertime, $this->offset_user); $r->date = date($this->date_format, $localtime); } else { // no timezone settings, user is probally not loged in. $r->date = date($this->date_format, $this->data['date']); } // admin-only edit link? if ($this->data['access'] != access_news && $user->isAllowed('admin')) { $adminurl = script_path . 'admincp.php?action=edit_blog&id=' . $this->data['blog_id']; $r->body .= ' [<a href="' . $adminurl . '">' . $lang_edit . '</a>]'; } return $r; }
function build_timezone_list($server_offset) { $server_timezone = date_offset(time(), $server_offset); $list = array(); $i = range(-12, 12); foreach ($i as $zone) { $t = $zone; $date = date('M jS, g:i a', date_offset($server_timezone, $t)); $t = $t > 0 ? "+{$t}" : $t; $list[$zone] = " {$t} GMT [ {$date} ]"; } return $list; }