-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
29 changed files
with
270 additions
and
91 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,6 @@ | ||
<?php | ||
/** | ||
* @package Fluid | ||
* @subpackage Home controller | ||
* @copyright 2015-2016, Robin de Graaf, devvoh webdevelopment | ||
* @license MIT | ||
* @author Robin de Graaf ([email protected]) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,6 @@ | ||
<?php | ||
/** | ||
* @package Fluid | ||
* @subpackage Users example model | ||
* @copyright 2015-2016, Robin de Graaf, devvoh webdevelopment | ||
* @license MIT | ||
* @author Robin de Graaf ([email protected]) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,6 @@ | ||
<?php | ||
/** | ||
* @package Fluid | ||
* @subpackage example Routes file | ||
* @copyright 2015-2016, Robin de Graaf, devvoh webdevelopment | ||
* @license MIT | ||
* @author Robin de Graaf ([email protected]) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,6 @@ | ||
<?php | ||
/** | ||
* @package Fluid | ||
* @subpackage Base controller | ||
* @copyright 2015-2016, Robin de Graaf, devvoh webdevelopment | ||
* @license MIT | ||
* @author Robin de Graaf ([email protected]) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,6 @@ | ||
<?php | ||
/** | ||
* @package Fluid | ||
* @subpackage router | ||
* @copyright 2015-2016, Robin de Graaf, devvoh webdevelopment | ||
* @license MIT | ||
* @author Robin de Graaf ([email protected]) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,6 @@ | ||
<?php | ||
/** | ||
* @package Devvoh | ||
* @subpackage Components | ||
* @subpackage Autoloader | ||
* @package Devvoh Components | ||
* @license MIT | ||
* @author Robin de Graaf <[email protected]> | ||
* @copyright 2015-2016, Robin de Graaf, devvoh webdevelopment | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,6 @@ | ||
<?php | ||
/** | ||
* @package Devvoh | ||
* @subpackage Components | ||
* @subpackage Cli | ||
* @package Devvoh Components | ||
* @license MIT | ||
* @author Robin de Graaf <[email protected]> | ||
* @copyright 2015-2016, Robin de Graaf, devvoh webdevelopment | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,6 @@ | ||
<?php | ||
/** | ||
* @package Devvoh | ||
* @subpackage Components | ||
* @subpackage Curl | ||
* @package Devvoh Components | ||
* @license MIT | ||
* @author Robin de Graaf <[email protected]> | ||
* @copyright 2015-2016, Robin de Graaf, devvoh webdevelopment | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,6 @@ | ||
<?php | ||
/** | ||
* @package Devvoh | ||
* @subpackage Components | ||
* @subpackage Database | ||
* @package Devvoh Components | ||
* @license MIT | ||
* @author Robin de Graaf <[email protected]> | ||
* @copyright 2015-2016, Robin de Graaf, devvoh webdevelopment | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,6 @@ | ||
<?php | ||
/** | ||
* @package Devvoh | ||
* @subpackage Components | ||
* @subpackage Date | ||
* @package Devvoh Components | ||
* @license MIT | ||
* @author Robin de Graaf <[email protected]> | ||
* @copyright 2015-2016, Robin de Graaf, devvoh webdevelopment | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,6 @@ | ||
<?php | ||
/** | ||
* @package Devvoh | ||
* @subpackage Components | ||
* @subpackage Debug | ||
* @package Devvoh Components | ||
* @license MIT | ||
* @author Robin de Graaf <[email protected]> | ||
* @copyright 2015-2016, Robin de Graaf, devvoh webdevelopment | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,6 @@ | ||
<?php | ||
/** | ||
* @package Devvoh | ||
* @subpackage Components | ||
* @subpackage Dock | ||
* @package Devvoh Components | ||
* @license MIT | ||
* @author Robin de Graaf <[email protected]> | ||
* @copyright 2015-2016, Robin de Graaf, devvoh webdevelopment | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,6 @@ | ||
<?php | ||
/** | ||
* @package Devvoh | ||
* @subpackage Components | ||
* @subpackage GetSet | ||
* @package Devvoh Components | ||
* @license MIT | ||
* @author Robin de Graaf <[email protected]> | ||
* @copyright 2015-2016, Robin de Graaf, devvoh webdevelopment | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,6 @@ | ||
<?php | ||
/** | ||
* @package Devvoh | ||
* @subpackage Components | ||
* @subpackage Hook | ||
* @package Devvoh Components | ||
* @license MIT | ||
* @author Robin de Graaf <[email protected]> | ||
* @copyright 2015-2016, Robin de Graaf, devvoh webdevelopment | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,6 @@ | ||
<?php | ||
/** | ||
* @package Devvoh | ||
* @subpackage Components | ||
* @subpackage Log | ||
* @package Devvoh Components | ||
* @license MIT | ||
* @author Robin de Graaf <[email protected]> | ||
* @copyright 2015-2016, Robin de Graaf, devvoh webdevelopment | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,113 @@ | ||
<?php | ||
/** | ||
* @package Devvoh Components | ||
* @license MIT | ||
* @author Robin de Graaf <[email protected]> | ||
* @copyright 2015-2016, Robin de Graaf, devvoh webdevelopment | ||
*/ | ||
|
||
namespace Devvoh\Components; | ||
|
||
class Mailer { | ||
|
||
protected $to = []; | ||
protected $from = null; | ||
protected $subject = null; | ||
protected $body = null; | ||
protected $headers = []; | ||
protected $isHTML = false; | ||
|
||
public function setTo($to) { | ||
if (!is_array($to)) { | ||
$to = [$to]; | ||
} | ||
$this->to = $to; | ||
return $this; | ||
} | ||
|
||
public function getTo() { | ||
return $this->to; | ||
} | ||
|
||
public function addTo($to) { | ||
$this->to[] = $to; | ||
return $this; | ||
} | ||
|
||
public function setSubject($subject) { | ||
$this->subject = $subject; | ||
return $this; | ||
} | ||
|
||
public function getSubject() { | ||
return $this->subject; | ||
} | ||
|
||
public function setBody($body) { | ||
$this->body = $body; | ||
return $this; | ||
} | ||
|
||
public function getBody() { | ||
return $this->body; | ||
} | ||
|
||
public function setHeaders($headers) { | ||
if (!is_array($headers)) { | ||
$headers = [$headers]; | ||
} | ||
$this->headers = $headers; | ||
return $this; | ||
} | ||
|
||
public function getHeaders() { | ||
return $this->headers; | ||
} | ||
|
||
public function addHeader($header) { | ||
$this->headers[] = $header; | ||
return $this; | ||
} | ||
|
||
public function setFrom($from) { | ||
$this->from = $from; | ||
} | ||
|
||
public function getFrom() { | ||
return $this->from; | ||
} | ||
|
||
public function setHTML($active) { | ||
$this->isHTML = (bool)$active; | ||
} | ||
|
||
public function isHTML() { | ||
return $this->isHTML; | ||
} | ||
|
||
public function send() { | ||
$to = $this->getTo(); | ||
if ($to) { | ||
$to = implode(',', $this->getTo()); | ||
} | ||
// Get From, and set Reply-To as well if it's set | ||
// @todo add setReplyTo & getReplyTo, as well as CC/BCC | ||
if ($this->getFrom()) { | ||
$this->addHeader('From: ' . $this->getFrom()); | ||
$this->addHeader('Reply-To: ' . $this->getFrom()); | ||
} | ||
if ($this->isHTML()) { | ||
$this->addHeader('MIME-Version: 1.0'); | ||
$this->addHeader('Content-type: text/html; charset=utf-8'); | ||
} | ||
$headers = $this->getHeaders(); | ||
if (count($headers) > 0) { | ||
$headers = implode("\r\n", $this->getHeaders()); | ||
} | ||
$subject = $this->getSubject(); | ||
$body = $this->getBody(); | ||
|
||
return mail($to, $subject, $body, $headers); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,6 @@ | ||
<?php | ||
/** | ||
* @package Devvoh | ||
* @subpackage Components | ||
* @subpackage Query | ||
* @package Devvoh Components | ||
* @license MIT | ||
* @author Robin de Graaf <[email protected]> | ||
* @copyright 2015-2016, Robin de Graaf, devvoh webdevelopment | ||
|
@@ -137,6 +135,15 @@ public function setAction($action) { | |
return $this; | ||
} | ||
|
||
/** | ||
* Return the action | ||
* | ||
* @return string | ||
*/ | ||
public function getAction() { | ||
return $this->action; | ||
} | ||
|
||
/** | ||
* In case of a select, what we're going to select (default *) | ||
* | ||
|
@@ -185,7 +192,7 @@ public function join($table, $condition, $value = null) { | |
* @return $this | ||
*/ | ||
public function addValue($key, $value) { | ||
$this->values[] = ['key' => $key, 'value' => $value]; | ||
$this->values[$key] = $value; | ||
return $this; | ||
} | ||
|
||
|
@@ -317,8 +324,6 @@ public function __toString() { | |
} | ||
} | ||
$query[] = "WHERE " . implode(' AND ', $wheres); | ||
} else { | ||
$query = []; | ||
} | ||
|
||
} elseif ($this->action === 'update') { | ||
|
@@ -333,13 +338,18 @@ public function __toString() { | |
$tableKeyValue = null; | ||
|
||
$values = []; | ||
foreach ($this->values as $value) { | ||
foreach ($this->values as $key => $value) { | ||
// skip id, since we'll use that as a where condition | ||
if ($value['key'] !== $this->tableKey) { | ||
$values[] = "'" . $value['key'] . "'=" . $this->pdoInstance->quote($value['value']); | ||
if ($key !== $this->tableKey) { | ||
if ($value === null) { | ||
$correctValue = 'NULL'; | ||
} else { | ||
$correctValue = $this->pdoInstance->quote($value); | ||
} | ||
$values[] = "'" . $key . "'=" . $correctValue; | ||
} else { | ||
$tableKey = $value['key']; | ||
$tableKeyValue = $value['value']; | ||
$tableKey = $key; | ||
$tableKeyValue = $value; | ||
} | ||
} | ||
$query[] = "SET " . implode(',', $values); | ||
|
@@ -358,9 +368,15 @@ public function __toString() { | |
|
||
$keys = []; | ||
$values = []; | ||
foreach ($this->values as $value) { | ||
$keys[] = "'" . $value['key'] . "'"; | ||
$values[] = $this->pdoInstance->quote($value['value']); | ||
foreach ($this->values as $key => $value) { | ||
$keys[] = "'" . $key . "'"; | ||
|
||
if ($value === null) { | ||
$correctValue = 'NULL'; | ||
} else { | ||
$correctValue = $this->pdoInstance->quote($value); | ||
} | ||
$values[] = $correctValue; | ||
} | ||
|
||
$query[] = "(" . implode(',', $keys) . ")"; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,6 @@ | ||
<?php | ||
/** | ||
* @package Devvoh | ||
* @subpackage Components | ||
* @subpackage Response | ||
* @package Devvoh Components | ||
* @license MIT | ||
* @author Robin de Graaf <[email protected]> | ||
* @copyright 2015-2016, Robin de Graaf, devvoh webdevelopment | ||
|
@@ -146,6 +144,18 @@ public function setContent($content) { | |
return $this; | ||
} | ||
|
||
/** | ||
* Send content immediately | ||
* | ||
* @param $content | ||
* | ||
* @return $this | ||
*/ | ||
public function sendContent($content) { | ||
echo $content; | ||
return $this; | ||
} | ||
|
||
/** | ||
* Prepend data to content | ||
* | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,6 @@ | ||
<?php | ||
/** | ||
* @package Devvoh | ||
* @subpackage Components | ||
* @subpackage Rights | ||
* @package Devvoh Components | ||
* @license MIT | ||
* @author Robin de Graaf <[email protected]> | ||
* @copyright 2015-2016, Robin de Graaf, devvoh webdevelopment | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,6 @@ | ||
<?php | ||
/** | ||
* @package Devvoh | ||
* @subpackage Components | ||
* @subpackage Router | ||
* @package Devvoh Components | ||
* @license MIT | ||
* @author Robin de Graaf <[email protected]> | ||
* @copyright 2015-2016, Robin de Graaf, devvoh webdevelopment | ||
|
Oops, something went wrong.