From 6b1b7870232f54dc41a531d95f9f0756704b9bde Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 27 Jan 2015 13:24:13 +0100 Subject: [PATCH] apply codeformatter --- htdocs/application/controllers/api.php | 2 +- htdocs/application/models/pastes.php | 48 +++++++++++++++++++------- 2 files changed, 36 insertions(+), 14 deletions(-) diff --git a/htdocs/application/controllers/api.php b/htdocs/application/controllers/api.php index 8dadb3e..64f2544 100644 --- a/htdocs/application/controllers/api.php +++ b/htdocs/application/controllers/api.php @@ -153,7 +153,7 @@ class Api extends Main show_404(); } $this->load->model('pastes'); - $pastes = $this->pastes->getTrends('api/trending',2); + $pastes = $this->pastes->getTrends('api/trending', 2); $pastes = $pastes['pastes']; $data = array(); foreach ($pastes as $paste) diff --git a/htdocs/application/models/pastes.php b/htdocs/application/models/pastes.php index 92cce00..134f151 100644 --- a/htdocs/application/models/pastes.php +++ b/htdocs/application/models/pastes.php @@ -26,7 +26,7 @@ class Pastes extends CI_Model { - + function __construct() { parent::__construct(); @@ -297,7 +297,7 @@ class Pastes extends CI_Model //diff //yes, I'm aware, two times htmlspecialchars_decode(). Needs to be, since it's saved that way in the DB from the original stikked author ages ago ;) - include_once (APPPATH.'/libraries/finediff.php'); + include_once (APPPATH . '/libraries/finediff.php'); $from_text = htmlspecialchars_decode(utf8_decode($row['raw'])); $to_text = htmlspecialchars_decode(utf8_decode($data['raw'])); $opcodes = FineDiff::getDiffOpcodes($from_text, $to_text, FineDiff::$wordGranularity); @@ -468,11 +468,18 @@ class Pastes extends CI_Model $total_rows = $query->num_rows(); // query - if($this->db->dbdriver == "postgre") { + + if ($this->db->dbdriver == "postgre") + { $sql = "SELECT id, title, name, created, pid, lang, raw FROM pastes WHERE private = 0 AND (title LIKE ? OR raw LIKE ?) ORDER BY created DESC LIMIT $amount OFFSET $page"; - } else if ($root == 'api/recent'){ + } + else + if ($root == 'api/recent') + { $sql = "SELECT id, title, name, created, pid, lang, raw FROM pastes WHERE private = 0 AND (title LIKE ? OR raw LIKE ?) ORDER BY created DESC LIMIT 0,15"; - } else { + } + else + { $sql = "SELECT id, title, name, created, pid, lang, raw FROM pastes WHERE private = 0 AND (title LIKE ? OR raw LIKE ?) ORDER BY created DESC LIMIT $page,$amount"; } $query = $this->db->query($sql, array( @@ -489,11 +496,15 @@ class Pastes extends CI_Model $total_rows = $query->num_rows(); // query - if($this->db->dbdriver == "postgre") { + + if ($this->db->dbdriver == "postgre") + { $sql = "SELECT id, title, name, created, pid, lang, raw FROM pastes WHERE private = 0 ORDER BY created DESC LIMIT $amount OFFSET $page"; - } else { + } + else + { $sql = "SELECT id, title, name, created, pid, lang, raw FROM pastes WHERE private = 0 ORDER BY created DESC LIMIT $page,$amount"; - } + } $query = $this->db->query($sql); } @@ -551,11 +562,18 @@ class Pastes extends CI_Model $total_rows = $query->num_rows(); // query - if($this->db->dbdriver == "postgre") { + + if ($this->db->dbdriver == "postgre") + { $sql = "SELECT id, title, name, created, pid, lang, raw, hits FROM pastes WHERE private = 0 AND (title LIKE ? OR raw LIKE ?) ORDER BY hits DESC, created DESC LIMIT $amount OFFSET $page"; - } else if ($root == "api/trending"){ + } + else + if ($root == "api/trending") + { $sql = "SELECT id, title, name, created, pid, lang, raw, hits FROM pastes WHERE private = 0 AND (title LIKE ? OR raw LIKE ?) ORDER BY hits DESC, created DESC LIMIT 0,15"; - }else { + } + else + { $sql = "SELECT id, title, name, created, pid, lang, raw, hits FROM pastes WHERE private = 0 AND (title LIKE ? OR raw LIKE ?) ORDER BY hits DESC, created DESC LIMIT $page,$amount"; } $query = $this->db->query($sql, array( @@ -572,9 +590,13 @@ class Pastes extends CI_Model $total_rows = $query->num_rows(); // query - if($this->db->dbdriver == "postgre") { + + if ($this->db->dbdriver == "postgre") + { $sql = "SELECT id, title, name, created, pid, lang, raw, hits FROM pastes WHERE private = 0 ORDER BY hits DESC, created DESC LIMIT $amount OFFSET $page"; - } else { + } + else + { $sql = "SELECT id, title, name, created, pid, lang, raw, hits FROM pastes WHERE private = 0 ORDER BY hits DESC, created DESC LIMIT $page,$amount"; } $query = $this->db->query($sql);