apply codeformatter

This commit is contained in:
Claude 2015-01-27 13:24:13 +01:00
parent ce412d56a4
commit 6b1b787023
2 changed files with 36 additions and 14 deletions

View File

@ -153,7 +153,7 @@ class Api extends Main
show_404(); show_404();
} }
$this->load->model('pastes'); $this->load->model('pastes');
$pastes = $this->pastes->getTrends('api/trending',2); $pastes = $this->pastes->getTrends('api/trending', 2);
$pastes = $pastes['pastes']; $pastes = $pastes['pastes'];
$data = array(); $data = array();
foreach ($pastes as $paste) foreach ($pastes as $paste)

View File

@ -297,7 +297,7 @@ class Pastes extends CI_Model
//diff //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 ;) //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'])); $from_text = htmlspecialchars_decode(utf8_decode($row['raw']));
$to_text = htmlspecialchars_decode(utf8_decode($data['raw'])); $to_text = htmlspecialchars_decode(utf8_decode($data['raw']));
$opcodes = FineDiff::getDiffOpcodes($from_text, $to_text, FineDiff::$wordGranularity); $opcodes = FineDiff::getDiffOpcodes($from_text, $to_text, FineDiff::$wordGranularity);
@ -468,11 +468,18 @@ class Pastes extends CI_Model
$total_rows = $query->num_rows(); $total_rows = $query->num_rows();
// query // 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"; $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"; $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"; $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( $query = $this->db->query($sql, array(
@ -489,9 +496,13 @@ class Pastes extends CI_Model
$total_rows = $query->num_rows(); $total_rows = $query->num_rows();
// query // 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"; $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"; $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); $query = $this->db->query($sql);
@ -551,11 +562,18 @@ class Pastes extends CI_Model
$total_rows = $query->num_rows(); $total_rows = $query->num_rows();
// query // 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"; $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"; $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"; $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( $query = $this->db->query($sql, array(
@ -572,9 +590,13 @@ class Pastes extends CI_Model
$total_rows = $query->num_rows(); $total_rows = $query->num_rows();
// query // 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"; $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"; $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); $query = $this->db->query($sql);