Skip to content
Browse files

* Merge fixes from framework

  • Loading branch information...
1 parent 8ffeace commit bb9559f97f8c1684f0f12946f951f8a8d13e1337 Danny Allen committed Jun 25, 2011
View
13 src/autoload.php
@@ -29,18 +29,27 @@
// define app constants
define('APP_ID', 'commit-digest');
define('APP_NAME', 'KDE Commit-Digest');
-define('VERSION', '1.12');
+define('VERSION', '1.13');
-define('JAVASCRIPT_LIBRARY', 'prototype');
+// define meta tags
define('META_AUTHOR', 'Danny Allen');
define('META_DESCRIPTION', 'A weekly overview of the development activity in KDE.');
define('META_KEYWORDS', 'kde, commit-digest, danny allen, dannya, plasma, akonadi, decibel, oxygen, solid, phonon, strigi');
+// make APP_ID's consistently available
+define('DIGEST_APP_ID', APP_ID);
+define('ENZYME_APP_ID', 'enzyme');
+
+define('JAVASCRIPT_LIBRARY', 'prototype');
+
+
+// set initial values
if (empty($_SERVER['DOCUMENT_ROOT'])) {
define('COMMAND_LINE', true);
define('BASE_DIR', dirname(__FILE__));
+
} else {
define('BASE_DIR', rtrim($_SERVER['DOCUMENT_ROOT'], '/'));
define('COMMAND_LINE', false);
View
23 src/classes/db/dbmysql.php
@@ -706,6 +706,29 @@ public static function prepareLike($value) {
// remove & and _
return str_replace(array('%', '_'), null, $value);
}
+
+
+ public static function objectify($class, $data) {
+ if (!$data) {
+ return $data;
+ }
+
+ if (isset($data[0])) {
+ // numerically-indexed, create list of objects
+ $list = array();
+
+ foreach ($data as $item) {
+ $list[] = new $class($item);
+ }
+
+ return $list;
+
+ } else {
+ // create single object
+ return new $class($data);
+ }
+
+ }
}
?>
View
46 src/classes/shared/date.php
@@ -19,6 +19,10 @@ class Date {
public static function get($type, $date) {
if ($type == 'full') {
$format = 'jS F Y';
+ } else if ($type == 'full-day') {
+ $format = 'l, jS F Y';
+ } else if ($type == 'full-day-time') {
+ $format = 'l, jS F Y @ g:ia';
} else if ($type == 'short') {
$format = 'd/m/Y';
}
@@ -61,6 +65,48 @@ public static function ago($timestamp, $comparison = null) {
return sprintf($periods[$j], $difference);
}
+
+
+ public static function getSelectData($context, $prependBlank = false) {
+ if ($prependBlank) {
+ $data = array(0 => ' ');
+ } else {
+ $data = array();
+ }
+
+ if ($context == 'days') {
+ for ($i = 1; $i <= 31; $i++) {
+ $data[$i] = $i;
+ }
+
+ } else if ($context == 'months') {
+ $data = array('01' => _('January'),
+ '02' => _('February'),
+ '03' => _('March'),
+ '04' => _('April'),
+ '05' => _('May'),
+ '06' => _('June'),
+ '07' => _('July'),
+ '08' => _('August'),
+ '09' => _('September'),
+ '10' => _('October'),
+ '11' => _('November'),
+ '12' => _('December'));
+
+ if ($prependBlank) {
+ $data = array_merge(array(0 => '&nbsp;'), $data);
+ }
+
+ } else if ($context == 'years') {
+ $time = self::load();
+
+ for ($i = ($time['year'] - 12); $i >= ($time['year'] - 80); $i--) {
+ $data[$i] = $i;
+ }
+ }
+
+ return $data;
+ }
}
?>
View
19 src/classes/shared/enzyme.php
@@ -48,7 +48,7 @@ public static function getBugData(&$bug, $displayMsg = false) {
// extract data
if ($page) {
$bug['date'] = (string)$page->bug->creation_ts;
- $bug['title'] = (string)$page->bug->short_desc;
+ $bug['title'] = self::stripSmartQuotes((string)$page->bug->short_desc);
$bug['product'] = (string)$page->bug->product;
$bug['component'] = (string)$page->bug->component;
$bug['votes'] = (string)$page->bug->votes;
@@ -1755,6 +1755,23 @@ public static function statusArea($type, $user = null) {
public static function formatRepositoryName($repositoryName) {
return '[' . $repositoryName . '] ';
}
+
+
+ public static function stripSmartQuotes($string) {
+ $search = array(chr(145),
+ chr(146),
+ chr(147),
+ chr(148),
+ chr(151));
+
+ $replace = array("'",
+ "'",
+ '"',
+ '"',
+ '-');
+
+ return str_replace($search, $replace, $string);
+ }
}
?>
View
13 src/classes/shared/log.php
@@ -16,12 +16,11 @@
class Log {
- public static function error($error) {
+ public static function error($error, $userData = false) {
$backtrace = debug_backtrace();
$source = reset($backtrace);
// set error details
- $data['date'] = date('Y-m-d H:i:s');
$data['file'] = $source['file'];
$data['line'] = $source['line'];
$data['page'] = $_SERVER['SCRIPT_NAME'];
@@ -30,6 +29,16 @@ public static function error($error) {
$data['string'] = $error;
$data['backtrace'] = Db::serialize($backtrace);
+ // add user data?
+ if ($userData && class_exists('User')) {
+ if ($userData === true) {
+ // try and load user data
+ $userData = new User();
+ }
+
+ $data['user'] = Db::serialize($userData);
+ }
+
// insert into errors table
Db::insert('errors', $data);
}
View
37 src/classes/shared/object.php
@@ -0,0 +1,37 @@
+<?php
+
+/*-------------------------------------------------------+
+ | Enzyme
+ | Copyright 2010-2011 Danny Allen <danny@enzyme-project.org>
+ | http://www.enzyme-project.org/
+ +--------------------------------------------------------+
+ | This program is released as free software under the
+ | Affero GPL license. You can redistribute it and/or
+ | modify it under the terms of this license which you
+ | can read by viewing the included agpl.txt or online
+ | at www.gnu.org/licenses/agpl.html. Removal of this
+ | copyright header is strictly prohibited without
+ | written permission from the original author(s).
+ +--------------------------------------------------------*/
+
+
+abstract class Object {
+ protected $data = array();
+
+
+ public function __construct($data) {
+ $this->data = $data;
+ }
+
+
+ public function __get($key) {
+ return $this->data[$key];
+ }
+
+
+ public function __isset($key) {
+ return isset($this->data[$key]);
+ }
+}
+
+?>

0 comments on commit bb9559f

Please sign in to comment.
Something went wrong with that request. Please try again.