<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[GlotPress][704] trunk/gp-includes/thing.php: Remove trailing whitespace</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg > ul, #logmsg > ol { margin-left: 0; margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="https://glotpress.trac.wordpress.org/changeset/704">704</a></dd>
<dt>Author</dt> <dd>nbachiyski</dd>
<dt>Date</dt> <dd>2012-10-23 08:16:43 +0000 (Tue, 23 Oct 2012)</dd>
</dl>

<h3>Log Message</h3>
<pre>Remove trailing whitespace</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkgpincludesthingphp">trunk/gp-includes/thing.php</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkgpincludesthingphp"></a>
<div class="modfile"><h4>Modified: trunk/gp-includes/thing.php (703 => 704)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/gp-includes/thing.php        2012-10-13 12:38:55 UTC (rev 703)
+++ trunk/gp-includes/thing.php        2012-10-23 08:16:43 UTC (rev 704)
</span><span class="lines">@@ -1,6 +1,6 @@
</span><span class="cx"> &lt;?php
</span><span class="cx"> class GP_Thing {
</span><del>-        
</del><ins>+
</ins><span class="cx">         var $table = null;
</span><span class="cx">         var $field_names = array();
</span><span class="cx">         var $non_db_field_names = array();
</span><span class="lines">@@ -9,10 +9,10 @@
</span><span class="cx">         var $per_page = 30;
</span><span class="cx">         var $map_results = true;
</span><span class="cx">         var $static = array();
</span><del>-        
</del><ins>+
</ins><span class="cx">         static $static_by_class = array();
</span><span class="cx">         static $validation_rules_by_class = array();
</span><del>-        
</del><ins>+
</ins><span class="cx">         function __construct( $fields = array() ) {
</span><span class="cx">                 global $gpdb;
</span><span class="cx">                 $this-&gt;class = get_class( $this );
</span><span class="lines">@@ -21,7 +21,7 @@
</span><span class="cx">                         $this-&gt;$field_name = null;
</span><span class="cx">                 }
</span><span class="cx">                 $this-&gt;set_fields( $fields );
</span><del>-                
</del><ins>+
</ins><span class="cx">                 if ( isset( self::$validation_rules_by_class[$this-&gt;class] ) ) {
</span><span class="cx">                         $this-&gt;validation_rules = &amp;self::$validation_rules_by_class[$this-&gt;class];
</span><span class="cx">                 } else {
</span><span class="lines">@@ -37,19 +37,19 @@
</span><span class="cx">                         $this-&gt;set_static( 'static-vars-are-set', true );
</span><span class="cx">                 }
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         function get_static( $name, $default = null ) {
</span><span class="cx">                 return isset( self::$static_by_class[$this-&gt;class][$name] )? self::$static_by_class[$this-&gt;class][$name] : $default;
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         function has_static( $name ) {
</span><span class="cx">                 return isset( self::$static_by_class[$this-&gt;class][$name] );
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         function set_static( $name, $value ) {
</span><span class="cx">                 self::$static_by_class[$this-&gt;class][$name] = $value;
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         function __call( $name, $args ) {
</span><span class="cx">                 $suffix = '_no_map';
</span><span class="cx">                 if ( gp_endswith( $name, $suffix ) ) {
</span><span class="lines">@@ -60,7 +60,7 @@
</span><span class="cx">                 }
</span><span class="cx">                 trigger_error(sprintf('Call to undefined function: %s::%s().', get_class($this), $name), E_USER_ERROR);
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         // CRUD
</span><span class="cx"> 
</span><span class="cx">         /**
</span><span class="lines">@@ -69,7 +69,7 @@
</span><span class="cx">         function all( $order = null ) {
</span><span class="cx">                 return $this-&gt;many( $this-&gt;select_all_from_conditions_and_order( array(), $order ) );
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         /**
</span><span class="cx">          * Reloads the object data from the database, based on its id
</span><span class="cx">          */
</span><span class="lines">@@ -80,7 +80,7 @@
</span><span class="cx"> 
</span><span class="cx">         /**
</span><span class="cx">          * Retrieves a single row from this table
</span><del>-         * 
</del><ins>+         *
</ins><span class="cx">          * For parameters description see BPDB::prepare()
</span><span class="cx">          * @return mixed an object, containing the selected row or false on error
</span><span class="cx">          */
</span><span class="lines">@@ -92,7 +92,7 @@
</span><span class="cx"> 
</span><span class="cx">         /**
</span><span class="cx">          * Retrieves a single value from this table
</span><del>-         * 
</del><ins>+         *
</ins><span class="cx">          * For parameters description see BPDB::prepare()
</span><span class="cx">          * @return scalar the result of the query or false on error
</span><span class="cx">          */
</span><span class="lines">@@ -115,7 +115,7 @@
</span><span class="cx"> 
</span><span class="cx">         /**
</span><span class="cx">          * Retrieves multiple rows from this table
</span><del>-         * 
</del><ins>+         *
</ins><span class="cx">          * For parameters description see BPDB::prepare()
</span><span class="cx">          * @return mixed an object, containing the selected row or false on error
</span><span class="cx">          */
</span><span class="lines">@@ -136,7 +136,7 @@
</span><span class="cx">         function find( $conditions, $order = null ) {
</span><span class="cx">                 return $this-&gt;find_many( $conditions, $order );
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         function query() {
</span><span class="cx">                 global $gpdb;
</span><span class="cx">                 $args = func_get_args();
</span><span class="lines">@@ -145,7 +145,7 @@
</span><span class="cx"> 
</span><span class="cx">         /**
</span><span class="cx">          * Inserts a new row
</span><del>-         * 
</del><ins>+         *
</ins><span class="cx">          * @param $args array associative array with fields as keys and values as values
</span><span class="cx">          * @return mixed the object corresponding to the inserted row or false on error
</span><span class="cx">          */
</span><span class="lines">@@ -161,10 +161,10 @@
</span><span class="cx">                 $inserted-&gt;after_create();
</span><span class="cx">                 return $inserted;
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         /**
</span><span class="cx">          * Inserts a record and then selects it back based on the id
</span><del>-         * 
</del><ins>+         *
</ins><span class="cx">          * @param $args array see create()
</span><span class="cx">          * @return mixed the selected object or false on error
</span><span class="cx">          */
</span><span class="lines">@@ -174,10 +174,10 @@
</span><span class="cx">                 $created-&gt;reload();
</span><span class="cx">                 return $created;
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         /**
</span><span class="cx">          * Updates a single row
</span><del>-         * 
</del><ins>+         *
</ins><span class="cx">          * @param $data array associative array with fields as keys and updated values as values
</span><span class="cx">          */
</span><span class="cx">         function update( $data, $where = null ) {
</span><span class="lines">@@ -206,7 +206,7 @@
</span><span class="cx">                 $update_res = $this-&gt;after_save();
</span><span class="cx">                 return $update_res;
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         function delete() {
</span><span class="cx">                 return $this-&gt;delete_all( array( 'id' =&gt; $this-&gt;id ) );
</span><span class="cx">         }
</span><span class="lines">@@ -217,9 +217,9 @@
</span><span class="cx">                 if ( $conditions_sql ) $query .= &quot; WHERE $conditions_sql&quot;;
</span><span class="cx">                 return $this-&gt;query( $query, $this-&gt;id );
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         // Fields handling
</span><del>-        
</del><ins>+
</ins><span class="cx">         function set_fields( $db_object ) {
</span><span class="cx">                 $db_object = $this-&gt;normalize_fields( $db_object );
</span><span class="cx">                 foreach( $db_object as $key =&gt; $value ) {
</span><span class="lines">@@ -230,17 +230,17 @@
</span><span class="cx">         /**
</span><span class="cx">          * Normalizes an array with key-value pairs representing
</span><span class="cx">          * a GP_Thing object.
</span><del>-         * 
</del><ins>+         *
</ins><span class="cx">          * @todo Include default type handling. For example dates 0000-00-00 should be set to null
</span><span class="cx">          */
</span><span class="cx">         function normalize_fields( $args ) {
</span><span class="cx">                 return $args;
</span><span class="cx">         }
</span><del>-                        
</del><ins>+
</ins><span class="cx">         /**
</span><span class="cx">          * Prepares for enetering the database an array with
</span><span class="cx">          * key-value pairs, preresenting a GP_Thing object.
</span><del>-         * 
</del><ins>+         *
</ins><span class="cx">          */
</span><span class="cx">         function prepare_fields_for_save( $args ) {
</span><span class="cx">                 $args = (array)$args;
</span><span class="lines">@@ -254,26 +254,26 @@
</span><span class="cx">                                 unset( $args[$key] );
</span><span class="cx">                         }
</span><span class="cx">                 }
</span><del>-                
</del><ins>+
</ins><span class="cx">                 if ( in_array( 'date_modified', $this-&gt;field_names ) ) {
</span><span class="cx">                         $args['date_modified'] = $this-&gt;now_in_mysql_format();
</span><span class="cx">                 }
</span><del>-                                
</del><ins>+
</ins><span class="cx">                 return $args;
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         function now_in_mysql_format() {
</span><span class="cx">                 $now = new DateTime( 'now', new DateTimeZone( 'UTC' ) );
</span><del>-                return $now-&gt;format( DATE_MYSQL );                
</del><ins>+                return $now-&gt;format( DATE_MYSQL );
</ins><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         function prepare_fields_for_create( $args ) {
</span><span class="cx">                 if ( in_array( 'date_added', $this-&gt;field_names ) ) {
</span><span class="cx">                         $args['date_added'] = $this-&gt;now_in_mysql_format();
</span><span class="cx">                 }
</span><span class="cx">                 return $args;
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         function coerce( $thing ) {
</span><span class="cx">                 if ( !$thing || is_wp_error( $thing ) ) {
</span><span class="cx">                         return false;
</span><span class="lines">@@ -294,15 +294,15 @@
</span><span class="cx">         }
</span><span class="cx"> 
</span><span class="cx">         // Triggers
</span><del>-        
</del><ins>+
</ins><span class="cx">         function after_create() {
</span><span class="cx">                 return true;
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         function after_save() {
</span><span class="cx">                 return true;
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         function sql_condition_from_php_value( $php_value ) {
</span><span class="cx">                 global $gpdb;
</span><span class="cx">                 if ( is_array( $php_value ) ) {
</span><span class="lines">@@ -319,7 +319,7 @@
</span><span class="cx">                 }
</span><span class="cx">                 return &quot;$operator $sql_value&quot;;
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         function sql_from_conditions( $conditions ) {
</span><span class="cx">                 if ( is_string( $conditions ) ) {
</span><span class="cx">                         $conditions;
</span><span class="lines">@@ -336,17 +336,17 @@
</span><span class="cx">                 }
</span><span class="cx">                 return $this-&gt;apply_default_conditions( $conditions );
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         function sql_from_order( $order_by, $order_how = '' ) {
</span><span class="cx">                 if ( is_array( $order_by ) ) {
</span><span class="cx">                         $order_by = implode( ' ', $order_by );
</span><span class="cx">                         $order_how = '';
</span><span class="cx">                 }
</span><span class="cx">                 $order_by = trim( $order_by );
</span><del>-                if ( !$order_by ) return gp_member_get( $this, 'default_order' );                
</del><ins>+                if ( !$order_by ) return gp_member_get( $this, 'default_order' );
</ins><span class="cx">                 return 'ORDER BY ' . $order_by . ( $order_how? &quot; $order_how&quot; : '' );
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         function select_all_from_conditions_and_order( $conditions, $order = null ) {
</span><span class="cx">                 $query = &quot;SELECT * FROM $this-&gt;table&quot;;
</span><span class="cx">                 $conditions_sql = $this-&gt;sql_from_conditions( $conditions );
</span><span class="lines">@@ -355,21 +355,21 @@
</span><span class="cx">                 if ( $order_sql ) $query .= &quot; $order_sql&quot;;
</span><span class="cx">                 return $query;
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         function restrict_fields( $thing ) {
</span><span class="cx">                 // Don't restrict any fields by default
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         function validate() {
</span><span class="cx">                 $verdict = $this-&gt;validation_rules-&gt;run( $this );
</span><span class="cx">                 $this-&gt;errors = $this-&gt;validation_rules-&gt;errors;
</span><span class="cx">                 return $verdict;
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         function force_false_to_null( $value ) {
</span><span class="cx">                 return $value? $value : null;
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         function fields() {
</span><span class="cx">                 $result = array();
</span><span class="cx">                 foreach( $this-&gt;field_names as $field_name ) {
</span><span class="lines">@@ -379,27 +379,27 @@
</span><span class="cx">                 }
</span><span class="cx">                 return $result;
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         function sql_limit_for_paging( $page, $per_page = null ) {
</span><span class="cx">                 $per_page = is_null( $per_page )? $this-&gt;per_page : $per_page;
</span><span class="cx">                 if ( 'no-limit' == $per_page || 'no-limit' == $page ) return '';
</span><span class="cx">                 $page = intval( $page )? intval( $page ) : 1;
</span><span class="cx">                 return sprintf( &quot;LIMIT %d OFFSET %d&quot;, $this-&gt;per_page, ($page-1)*$this-&gt;per_page );
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         function found_rows() {
</span><span class="cx">                 global $gpdb;
</span><span class="cx">                 return $gpdb-&gt;get_var(&quot;SELECT FOUND_ROWS();&quot;);
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         function like_escape_printf( $s ) {
</span><span class="cx">                 return str_replace( '%', '%%', like_escape( $s ) );
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         function apply_default_conditions( $conditions_str ) {
</span><span class="cx">                 $conditions = array();
</span><span class="cx">                 if ( isset( $this-&gt;default_conditions ) )  $conditions[] = $this-&gt;default_conditions;
</span><span class="cx">                 if ( $conditions_str ) $conditions[] = $conditions_str;
</span><span class="cx">                 return implode( ' AND ', $conditions );
</span><span class="cx">         }
</span><del>-}
</del><span class="cx">\ No newline at end of file
</span><ins>+}
</ins></span></pre>
</div>
</div>

</body>
</html>