/** Creates a new comment. Takes a cursor as input and returns the new comment ID. @param cur <b>cursor</b> Comment cursor @return <b>integer</b> New comment ID */ public function addComment($cur) { $this->con->writeLock($this->prefix . 'comment'); try { # Get ID $rs = $this->con->select('SELECT MAX(comment_id) ' . 'FROM ' . $this->prefix . 'comment '); $cur->comment_id = (int) $rs->f(0) + 1; $cur->comment_upddt = date('Y-m-d H:i:s'); $offset = dt::getTimeOffset($this->settings->system->blog_timezone); $cur->comment_dt = date('Y-m-d H:i:s', time() + $offset); $cur->comment_tz = $this->settings->system->blog_timezone; $this->getCommentCursor($cur); if ($cur->comment_ip === null) { $cur->comment_ip = http::realIP(); } # --BEHAVIOR-- coreBeforeCommentCreate $this->core->callBehavior('coreBeforeCommentCreate', $this, $cur); $cur->insert(); $this->con->unlock(); } catch (Exception $e) { $this->con->unlock(); throw $e; } # --BEHAVIOR-- coreAfterCommentCreate $this->core->callBehavior('coreAfterCommentCreate', $this, $cur); $this->triggerComment($cur->comment_id); if ($cur->comment_status != -2) { $this->triggerBlog(); } return $cur->comment_id; }
private function translateWpOptions($options = array()) { $timezone = 0; if ($this->core->blog->settings->system->blog_timezone) { $timezone = dt::getTimeOffset($this->core->blog->settings->system->blog_timezone) / 3600; } $res = array('software_name' => array('desc' => 'Software Name', 'readonly' => true, 'value' => 'Dotclear'), 'software_version' => array('desc' => 'Software Version', 'readonly' => true, 'value' => DC_VERSION), 'blog_url' => array('desc' => 'Blog URL', 'readonly' => true, 'value' => $this->core->blog->url), 'time_zone' => array('desc' => 'Time Zone', 'readonly' => true, 'value' => (string) $timezone), 'blog_title' => array('desc' => 'Blog Title', 'readonly' => false, 'value' => $this->core->blog->name), 'blog_tagline' => array('desc' => 'Blog Tagline', 'readonly' => false, 'value' => $this->core->blog->desc), 'date_format' => array('desc' => 'Date Format', 'readonly' => false, 'value' => $this->core->blog->settings->system->date_format), 'time_format' => array('desc' => 'Time Format', 'readonly' => false, 'value' => $this->core->blog->settings->system->time_format)); if (!empty($options)) { $r = array(); foreach ($options as $v) { if (isset($res[$v])) { $r[$v] = $res[$v]; } } return $r; } return $res; }
protected function imageMetaCreate(&$cur, $f, $id) { $file = $this->pwd . '/' . $f; if (!file_exists($file)) { return false; } $xml = new xmlTag('meta'); $meta = imageMeta::readMeta($file); $xml->insertNode($meta); $c = $this->core->con->openCursor($this->table); $c->media_meta = $xml->toXML(); if ($cur->media_title !== null && $cur->media_title == basename($cur->media_file)) { if ($meta['Title']) { $c->media_title = $meta['Title']; } } if ($meta['DateTimeOriginal'] && $cur->media_dt === '') { # We set picture time to user timezone $media_ts = strtotime($meta['DateTimeOriginal']); if ($media_ts !== false) { $o = dt::getTimeOffset($this->core->auth->getInfo('user_tz'), $media_ts); $c->media_dt = dt::str('%Y-%m-%d %H:%M:%S', $media_ts + $o); } } $c->update('WHERE media_id = ' . $id); }
/** Returns comment date formating according to RFC 822. @param rs Invisible parameter @param type <b>string</b> (dt|upddt) defaults to comment_dt @return <b>string</b> */ public static function getRFC822Date($rs, $type = '') { if ($type == 'upddt') { return dt::rfc822($rs->getTS($type) + dt::getTimeOffset($rs->comment_tz), $rs->comment_tz); } else { return dt::rfc822($rs->getTS(), $rs->comment_tz); } }
function blogLine($rs) { global $core; $blog_id = html::escapeHTML($rs->blog_id); $edit_link = ''; if ($GLOBALS['core']->auth->isSuperAdmin()) { $edit_link = '<a href="' . $core->adminurl->get("admin.blog", array('id' => $blog_id)) . '" title="' . sprintf(__('Edit blog settings for %s'), $blog_id) . '">' . '<img src="images/edit-mini.png" alt="' . __('Edit blog settings') . '" /> ' . $blog_id . '</a> '; } else { $edit_link = $blog_id; } $img_status = $rs->blog_status == 1 ? 'check-on' : ($rs->blog_status == 0 ? 'check-off' : 'check-wrn'); $txt_status = $GLOBALS['core']->getBlogStatus($rs->blog_status); $img_status = sprintf('<img src="images/%1$s.png" alt="%2$s" title="%2$s" />', $img_status, $txt_status); $offset = dt::getTimeOffset($core->auth->getInfo('user_tz')); $blog_upddt = dt::str(__('%Y-%m-%d %H:%M'), strtotime($rs->blog_upddt) + $offset); return '<tr class="line">' . '<td class="nowrap">' . $edit_link . '</td>' . '<td class="maximal"><a href="' . $core->adminurl->get("admin.home", array('switchblog' => $rs->blog_id)) . '" ' . 'title="' . sprintf(__('Switch to blog %s'), $rs->blog_id) . '">' . html::escapeHTML($rs->blog_name) . '</a></td>' . '<td class="nowrap"><a class="outgoing" href="' . html::escapeHTML($rs->blog_url) . '">' . html::escapeHTML($rs->blog_url) . ' <img src="images/outgoing-blue.png" alt="" /></a></td>' . '<td class="nowrap count">' . $core->countBlogPosts($rs->blog_id) . '</td>' . '<td class="nowrap count">' . $blog_upddt . '</td>' . '<td class="status">' . $img_status . '</td>' . '</tr>'; }