Skip to content

Commit

Permalink
- reformating for PSR-2 coding standards #483
Browse files Browse the repository at this point in the history
  • Loading branch information
uwetews committed Aug 31, 2018
1 parent d52a04f commit 4f7cd8f
Show file tree
Hide file tree
Showing 177 changed files with 1,887 additions and 1,480 deletions.
4 changes: 3 additions & 1 deletion change_log.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
===== 3.1.33-dev-9 =====
===== 3.1.33-dev-10 =====
31.08.2018
- reformating for PSR-2 coding standards https://github.com/smarty-php/smarty/pull/483

- bugfix on Windows absolute filepathes did fail if the drive letter was followed by a linux DIRECTORY_SEPARATOR
like C:/ at Smarty > 3.1.33-dev-5 https://github.com/smarty-php/smarty/issues/451

Expand Down
23 changes: 12 additions & 11 deletions demo/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,31 +4,32 @@
*
* @package Example-application
*/

require '../libs/Smarty.class.php';

$smarty = new Smarty;

//$smarty->force_compile = true;
$smarty->debugging = true;
$smarty->caching = true;
$smarty->cache_lifetime = 120;

$smarty->assign("Name", "Fred Irving Johnathan Bradley Peppergill", true);
$smarty->assign("FirstName", array("John", "Mary", "James", "Henry"));
$smarty->assign("LastName", array("Doe", "Smith", "Johnson", "Case"));
$smarty->assign(
"Class", array(array("A", "B", "C", "D"), array("E", "F", "G", "H"), array("I", "J", "K", "L"),
array("M", "N", "O", "P"))
"Class",
array(
array("A", "B", "C", "D"),
array("E", "F", "G", "H"),
array("I", "J", "K", "L"),
array("M", "N", "O", "P")
)
);

$smarty->assign(
"contacts", array(array("phone" => "1", "fax" => "2", "cell" => "3"),
array("phone" => "555-4444", "fax" => "555-3333", "cell" => "760-1234"))
"contacts",
array(
array("phone" => "1", "fax" => "2", "cell" => "3"),
array("phone" => "555-4444", "fax" => "555-3333", "cell" => "760-1234")
)
);

$smarty->assign("option_values", array("NY", "NE", "KS", "IA", "OK", "TX"));
$smarty->assign("option_output", array("New York", "Nebraska", "Kansas", "Iowa", "Oklahoma", "Texas"));
$smarty->assign("option_selected", "NE");

$smarty->display('index.tpl');
3 changes: 0 additions & 3 deletions demo/plugins/cacheresource.apc.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ protected function read(array $keys)
foreach ($res as $k => $v) {
$_res[ $k ] = $v;
}

return $_res;
}

Expand All @@ -56,7 +55,6 @@ protected function write(array $keys, $expire = null)
foreach ($keys as $k => $v) {
apc_store($k, $v, $expire);
}

return true;
}

Expand All @@ -72,7 +70,6 @@ protected function delete(array $keys)
foreach ($keys as $k) {
apc_delete($k);
}

return true;
}

Expand Down
6 changes: 3 additions & 3 deletions demo/plugins/cacheresource.memcache.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ class Smarty_CacheResource_Memcache extends Smarty_CacheResource_KeyValueStore
*/
protected $memcache = null;

/**
* Smarty_CacheResource_Memcache constructor.
*/
public function __construct()
{
if (class_exists('Memcached')) {
Expand Down Expand Up @@ -50,7 +53,6 @@ protected function read(array $keys)
foreach ($res as $k => $v) {
$_res[ $lookup[ $k ] ] = $v;
}

return $_res;
}

Expand All @@ -68,7 +70,6 @@ protected function write(array $keys, $expire = null)
$k = sha1($k);
$this->memcache->set($k, $v, 0, $expire);
}

return true;
}

Expand All @@ -85,7 +86,6 @@ protected function delete(array $keys)
$k = sha1($k);
$this->memcache->delete($k);
}

return true;
}

Expand Down
40 changes: 27 additions & 13 deletions demo/plugins/cacheresource.mysql.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,24 @@
*/
class Smarty_CacheResource_Mysql extends Smarty_CacheResource_Custom
{
// PDO instance
/**
* @var \PDO
*/
protected $db;

/**
* @var \PDOStatement
*/
protected $fetch;

/**
* @var \PDOStatement
*/
protected $fetchTimestamp;

/**
* @var \PDOStatement
*/
protected $save;

/**
Expand All @@ -42,8 +53,7 @@ public function __construct()
{
try {
$this->db = new PDO("mysql:dbname=test;host=127.0.0.1", "smarty");
}
catch (PDOException $e) {
} catch (PDOException $e) {
throw new SmartyException('Mysql Resource failed: ' . $e->getMessage());
}
$this->fetch = $this->db->prepare('SELECT modified, content FROM output_cache WHERE id = :id');
Expand Down Expand Up @@ -83,7 +93,8 @@ protected function fetch($id, $name, $cache_id, $compile_id, &$content, &$mtime)
/**
* Fetch cached content's modification timestamp from data source
*
* @note implementing this method is optional. Only implement it if modification times can be accessed faster than loading the complete cached content.
* @note implementing this method is optional. Only implement it if modification times can be accessed faster than
* loading the complete cached content.
*
* @param string $id unique cache content identifier
* @param string $name template name
Expand All @@ -97,7 +108,6 @@ protected function fetchTimestamp($id, $name, $cache_id, $compile_id)
$this->fetchTimestamp->execute(array('id' => $id));
$mtime = strtotime($this->fetchTimestamp->fetchColumn());
$this->fetchTimestamp->closeCursor();

return $mtime;
}

Expand All @@ -116,10 +126,12 @@ protected function fetchTimestamp($id, $name, $cache_id, $compile_id)
protected function save($id, $name, $cache_id, $compile_id, $exp_time, $content)
{
$this->save->execute(
array('id' => $id, 'name' => $name, 'cache_id' => $cache_id, 'compile_id' => $compile_id,
'content' => $content,)
array('id' => $id,
'name' => $name,
'cache_id' => $cache_id,
'compile_id' => $compile_id,
'content' => $content,)
);

return !!$this->save->rowCount();
}

Expand All @@ -139,8 +151,7 @@ protected function delete($name, $cache_id, $compile_id, $exp_time)
if ($name === null && $cache_id === null && $compile_id === null && $exp_time === null) {
// returning the number of deleted caches would require a second query to count them
$query = $this->db->query('TRUNCATE TABLE output_cache');

return - 1;
return -1;
}
// build the filter
$where = array();
Expand All @@ -158,12 +169,15 @@ protected function delete($name, $cache_id, $compile_id, $exp_time)
}
// equal test cache_id and match sub-groups
if ($cache_id !== null) {
$where[] = '(cache_id = ' . $this->db->quote($cache_id) . ' OR cache_id LIKE ' .
$this->db->quote($cache_id . '|%') . ')';
$where[] =
'(cache_id = ' .
$this->db->quote($cache_id) .
' OR cache_id LIKE ' .
$this->db->quote($cache_id . '|%') .
')';
}
// run delete query
$query = $this->db->query('DELETE FROM output_cache WHERE ' . join(' AND ', $where));

return $query->rowCount();
}
}
Loading

0 comments on commit 4f7cd8f

Please sign in to comment.