mirror of
https://github.com/NNTmux/newznab-tmux.git
synced 2026-08-29 01:01:24 +00:00
Update cs of some files, use Category model in Category class
This commit is contained in:
@@ -1,3 +1,5 @@
|
||||
2017-10-06 DariusIII
|
||||
* Chg: Update cs of some files, use Category model in Category class
|
||||
2017-10-05 DariusIII
|
||||
* Chg: Update cs of TMDB class
|
||||
* Chg: Update Release and Category models relationship
|
||||
|
||||
+1
-1
@@ -12,7 +12,7 @@
|
||||
*/
|
||||
|
||||
$app = new Illuminate\Foundation\Application(
|
||||
dirname(__DIR__).'/'
|
||||
dirname(__DIR__).'/'
|
||||
);
|
||||
|
||||
/*
|
||||
|
||||
+1
-1
@@ -176,7 +176,7 @@ return [
|
||||
// App\Providers\BroadcastServiceProvider::class,
|
||||
App\Providers\EventServiceProvider::class,
|
||||
App\Providers\RouteServiceProvider::class,
|
||||
App\Providers\YencServiceProvider::class,
|
||||
App\Providers\YencServiceProvider::class,
|
||||
|
||||
],
|
||||
|
||||
|
||||
@@ -21,11 +21,6 @@ class Categorize extends Category
|
||||
*/
|
||||
protected $catWebDL;
|
||||
|
||||
/**
|
||||
* Temporary category while we sort through the name.
|
||||
* @var int
|
||||
*/
|
||||
protected $tmpCat = Category::OTHER_MISC;
|
||||
|
||||
/**
|
||||
* Release name to sort through.
|
||||
@@ -80,7 +75,6 @@ class Categorize extends Category
|
||||
{
|
||||
$this->releaseName = $releaseName;
|
||||
$this->groupid = $groupID;
|
||||
$this->tmpCat = Category::OTHER_MISC;
|
||||
$this->poster = $poster;
|
||||
|
||||
switch (true) {
|
||||
|
||||
+105
-123
@@ -2,6 +2,7 @@
|
||||
|
||||
namespace nntmux;
|
||||
|
||||
use App\Models\Category as CategoryModel;
|
||||
use nntmux\db\DB;
|
||||
|
||||
/**
|
||||
@@ -91,19 +92,23 @@ class Category
|
||||
const STATUS_DISABLED = 2;
|
||||
|
||||
const OTHERS_GROUP =
|
||||
[
|
||||
self::BOOKS_UNKNOWN,
|
||||
self::GAME_OTHER,
|
||||
self::MOVIE_OTHER,
|
||||
self::MUSIC_OTHER,
|
||||
self::PC_PHONE_OTHER,
|
||||
self::TV_OTHER,
|
||||
self::OTHER_HASHED,
|
||||
self::XXX_OTHER,
|
||||
self::OTHER_MISC,
|
||||
];
|
||||
[
|
||||
self::BOOKS_UNKNOWN,
|
||||
self::GAME_OTHER,
|
||||
self::MOVIE_OTHER,
|
||||
self::MUSIC_OTHER,
|
||||
self::PC_PHONE_OTHER,
|
||||
self::TV_OTHER,
|
||||
self::OTHER_HASHED,
|
||||
self::XXX_OTHER,
|
||||
self::OTHER_MISC,
|
||||
];
|
||||
|
||||
private $tmpCat = 0;
|
||||
/**
|
||||
* Temporary category while we sort through the name.
|
||||
* @var int
|
||||
*/
|
||||
protected $tmpCat = self::OTHER_MISC;
|
||||
|
||||
/**
|
||||
* @var DB
|
||||
@@ -114,12 +119,13 @@ class Category
|
||||
* Construct.
|
||||
*
|
||||
* @param array $options Class instances.
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function __construct(array $options = [])
|
||||
{
|
||||
$defaults = [
|
||||
'Settings' => null,
|
||||
];
|
||||
'Settings' => null,
|
||||
];
|
||||
$options += $defaults;
|
||||
|
||||
$this->pdo = ($options['Settings'] instanceof DB ? $options['Settings'] : new DB());
|
||||
@@ -128,7 +134,7 @@ class Category
|
||||
/**
|
||||
* Parse category search constraints.
|
||||
*
|
||||
* @param array|string $cat
|
||||
* @param array $cat
|
||||
*
|
||||
* @return string $catsrch
|
||||
*/
|
||||
@@ -160,19 +166,19 @@ class Category
|
||||
$catCount = count($categories);
|
||||
|
||||
switch ($catCount) {
|
||||
//No category constraint
|
||||
case 0:
|
||||
$catsrch = ' AND 1=1 ';
|
||||
break;
|
||||
// One category constraint
|
||||
case 1:
|
||||
$catsrch = $categories[0] !== -1 ? ' AND r.categories_id = '.$categories[0] : '';
|
||||
break;
|
||||
// Multiple category constraints
|
||||
default:
|
||||
$catsrch = ' AND r.categories_id IN ('.implode(', ', $categories).') ';
|
||||
break;
|
||||
}
|
||||
//No category constraint
|
||||
case 0:
|
||||
$catsrch = ' AND 1=1 ';
|
||||
break;
|
||||
// One category constraint
|
||||
case 1:
|
||||
$catsrch = $categories[0] !== -1 ? ' AND r.categories_id = '.$categories[0] : '';
|
||||
break;
|
||||
// Multiple category constraints
|
||||
default:
|
||||
$catsrch = ' AND r.categories_id IN ('.implode(', ', $categories).') ';
|
||||
break;
|
||||
}
|
||||
|
||||
return $catsrch;
|
||||
}
|
||||
@@ -184,20 +190,20 @@ class Category
|
||||
*/
|
||||
public static function getCategoryOthersGroup(): string
|
||||
{
|
||||
return implode(',',
|
||||
[
|
||||
self::BOOKS_UNKNOWN,
|
||||
self::GAME_OTHER,
|
||||
self::MOVIE_OTHER,
|
||||
self::MUSIC_OTHER,
|
||||
self::PC_PHONE_OTHER,
|
||||
self::TV_OTHER,
|
||||
self::OTHER_HASHED,
|
||||
self::XXX_OTHER,
|
||||
self::OTHER_MISC,
|
||||
self::OTHER_HASHED,
|
||||
]
|
||||
);
|
||||
return implode(
|
||||
',',
|
||||
[
|
||||
self::BOOKS_UNKNOWN,
|
||||
self::GAME_OTHER,
|
||||
self::MOVIE_OTHER,
|
||||
self::MUSIC_OTHER,
|
||||
self::PC_PHONE_OTHER,
|
||||
self::TV_OTHER,
|
||||
self::OTHER_HASHED,
|
||||
self::XXX_OTHER,
|
||||
self::OTHER_MISC,
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -219,79 +225,62 @@ class Category
|
||||
*/
|
||||
public function isParent($cid): bool
|
||||
{
|
||||
$ret = $this->pdo->query(
|
||||
sprintf('SELECT id FROM categories WHERE id = %d AND parentid IS NULL', $cid),
|
||||
true, NN_CACHE_EXPIRY_LONG
|
||||
);
|
||||
$ret = CategoryModel::query()->where(['id' => $cid, 'parentid' => null])->first();
|
||||
|
||||
return isset($ret[0]['id']);
|
||||
return $ret !== null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param bool $activeonly
|
||||
*
|
||||
* @return array
|
||||
* @return \Illuminate\Database\Eloquent\Collection|static[]
|
||||
*/
|
||||
public function getFlat($activeonly = false): array
|
||||
public function getFlat()
|
||||
{
|
||||
$act = '';
|
||||
if ($activeonly) {
|
||||
$act = sprintf(' WHERE c.status = %d ', self::STATUS_ACTIVE);
|
||||
}
|
||||
|
||||
return $this->pdo->query('SELECT c.*, (SELECT title FROM categories WHERE id=c.parentid) AS parentName FROM categories c '.$act.' ORDER BY c.id');
|
||||
return CategoryModel::query()->get();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get children of a parent category.
|
||||
*
|
||||
* @param $cid
|
||||
*
|
||||
* @return array
|
||||
* @param $cid
|
||||
* @return mixed
|
||||
*/
|
||||
public function getChildren($cid): array
|
||||
public function getChildren($cid)
|
||||
{
|
||||
return $this->pdo->query(
|
||||
sprintf('SELECT c.* FROM categories c WHERE parentid = %d', $cid),
|
||||
true, NN_CACHE_EXPIRY_LONG
|
||||
);
|
||||
return CategoryModel::find($cid)->children;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get names of enabled parent categories.
|
||||
* @return array
|
||||
*
|
||||
* @return \Illuminate\Database\Eloquent\Collection|static[]
|
||||
*/
|
||||
public function getEnabledParentNames(): array
|
||||
public function getEnabledParentNames()
|
||||
{
|
||||
return $this->pdo->query(
|
||||
'SELECT title FROM categories WHERE parentid IS NULL AND status = 1',
|
||||
true, NN_CACHE_EXPIRY_LONG
|
||||
);
|
||||
return CategoryModel::query()->where(['parentid' => null, 'status' => 1])->get(['title']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns category ID's for site disabled categories.
|
||||
*
|
||||
* @return array
|
||||
*
|
||||
* @return \Illuminate\Database\Eloquent\Collection|static[]
|
||||
*/
|
||||
public function getDisabledIDs(): array
|
||||
public function getDisabledIDs()
|
||||
{
|
||||
return $this->pdo->query(
|
||||
'SELECT id FROM categories WHERE status = 2 OR parentid IN (SELECT id FROM categories WHERE status = 2 AND parentid IS NULL)',
|
||||
true, NN_CACHE_EXPIRY_LONG
|
||||
);
|
||||
return CategoryModel::query()->where('status', '=', 2)->orWhere(['status' => 2, 'parentid' => null])->get(['id']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a category row by its id.
|
||||
*
|
||||
* @param $id
|
||||
*
|
||||
* @return array|bool
|
||||
* @param $id
|
||||
* @return \Illuminate\Database\Eloquent\Collection|static[]
|
||||
*/
|
||||
public function getById($id)
|
||||
{
|
||||
return $this->pdo->queryOneRow(sprintf("SELECT c.disablepreview, c.id, c.description, c.minsizetoformrelease, c.maxsizetoformrelease, CONCAT(COALESCE(cp.title,'') , CASE WHEN cp.title IS NULL THEN '' ELSE ' > ' END , c.title) as title, c.status, c.parentid from categories c left outer join categories cp on cp.id = c.parentid where c.id = %d", $id));
|
||||
return CategoryModel::query()->where('id', $id)->get();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -304,14 +293,7 @@ class Category
|
||||
public function getByIds($ids)
|
||||
{
|
||||
if (count($ids) > 0) {
|
||||
return $this->pdo->query(
|
||||
sprintf(
|
||||
"SELECT CONCAT(cp.title, ' > ',c.title) AS title
|
||||
FROM categories c
|
||||
INNER JOIN categories cp ON cp.id = c.parentid
|
||||
WHERE c.id IN (%s)", implode(',', $ids)
|
||||
), true, NN_CACHE_EXPIRY_LONG
|
||||
);
|
||||
return CategoryModel::query()->whereIn('id', $ids)->get();
|
||||
}
|
||||
|
||||
return false;
|
||||
@@ -319,40 +301,41 @@ class Category
|
||||
|
||||
/**
|
||||
* Return the parent and category name from the supplied categoryID.
|
||||
* @param $ID
|
||||
*
|
||||
*
|
||||
* @param $ID
|
||||
* @return string
|
||||
*/
|
||||
public function getNameByID($ID): string
|
||||
public function getNameByID($ID)
|
||||
{
|
||||
$cat = $this->pdo->queryOneRow(
|
||||
sprintf('
|
||||
SELECT c.title AS ctitle, cp.title AS ptitle
|
||||
FROM categories c
|
||||
INNER JOIN categories cp ON c.parentid = cp.id
|
||||
WHERE c.id = %d',
|
||||
$ID
|
||||
)
|
||||
);
|
||||
$cat = CategoryModel::query()->where('id', $ID)->first();
|
||||
|
||||
return $cat['ptitle'].' -> '.$cat['ctitle'];
|
||||
return $cat !== null ? $cat->parent->title .' -> '.$cat->title : '';
|
||||
}
|
||||
|
||||
/**
|
||||
* Update a category.
|
||||
*
|
||||
*
|
||||
* @param $id
|
||||
* @param $status
|
||||
* @param $desc
|
||||
* @param $desc->update
|
||||
* @param $disablepreview
|
||||
* @param $minsize
|
||||
* @param $maxsize
|
||||
*
|
||||
* @return bool|\PDOStatement
|
||||
* @return int
|
||||
*/
|
||||
public function update($id, $status, $desc, $disablepreview, $minsize, $maxsize)
|
||||
public function update($id, $status, $desc, $disablepreview, $minsize, $maxsize): int
|
||||
{
|
||||
return $this->pdo->queryExec(sprintf('UPDATE categories SET disablepreview = %d, status = %d, minsizetoformrelease = %d, maxsizetoformrelease = %d, description = %s WHERE id = %d', $disablepreview, $status, $minsize, $maxsize, $this->pdo->escapeString($desc), $id));
|
||||
return CategoryModel::query()->where('id', $id)->update(
|
||||
[
|
||||
'disablepreview' => $disablepreview,
|
||||
'status' => $status,
|
||||
'minsizetoformrelease' => $minsize,
|
||||
'maxsizetoformrelease' => $maxsize,
|
||||
'description' => $desc,
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -376,9 +359,10 @@ class Category
|
||||
}
|
||||
|
||||
$arr = $this->pdo->query(
|
||||
sprintf('SELECT * FROM categories WHERE status = %d %s', self::STATUS_ACTIVE, $exccatlist),
|
||||
true, NN_CACHE_EXPIRY_LONG
|
||||
);
|
||||
sprintf('SELECT * FROM categories WHERE status = %d %s', self::STATUS_ACTIVE, $exccatlist),
|
||||
true,
|
||||
NN_CACHE_EXPIRY_LONG
|
||||
);
|
||||
|
||||
foreach ($arr as $key => $val) {
|
||||
if ($val['id'] === '0') {
|
||||
@@ -440,27 +424,25 @@ class Category
|
||||
}
|
||||
|
||||
/**
|
||||
* Get array of categories in DB.
|
||||
*
|
||||
* @param bool $activeonly
|
||||
* @param bool $activeonly
|
||||
* @param array $excludedcats
|
||||
*
|
||||
* @return array
|
||||
* @return string|static
|
||||
*/
|
||||
public function getCategories($activeonly = false, array $excludedcats = []): array
|
||||
public function getCategories($activeonly = false, array $excludedcats = [])
|
||||
{
|
||||
return $this->pdo->query(
|
||||
"SELECT c.id, CONCAT(cp.title, ' > ',c.title) AS title, cp.id AS parentid, c.status
|
||||
"SELECT c.id, CONCAT(cp.title, ' > ',c.title) AS title, cp.id AS parentid, c.status
|
||||
FROM categories c
|
||||
INNER JOIN categories cp ON cp.id = c.parentid ".
|
||||
($activeonly ?
|
||||
sprintf(
|
||||
' WHERE c.status = %d %s ',
|
||||
self::STATUS_ACTIVE,
|
||||
(count($excludedcats) > 0 ? ' AND c.id NOT IN ('.implode(',', $excludedcats).')' : '')
|
||||
) : ''
|
||||
).
|
||||
' ORDER BY c.id'
|
||||
);
|
||||
(
|
||||
$activeonly ?
|
||||
sprintf(
|
||||
' WHERE c.status = %d %s ',
|
||||
self::STATUS_ACTIVE,
|
||||
(count($excludedcats) > 0 ? ' AND c.id NOT IN ('.implode(',', $excludedcats).')' : '')
|
||||
) : ''
|
||||
).
|
||||
' ORDER BY c.id'
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -33,13 +33,14 @@ $results = $releases->getBrowseRange($catarray, $offset, ITEMS_PER_PAGE, $orderb
|
||||
$browsecount = $results[0]['_totalcount'] ?? 0;
|
||||
|
||||
$page->smarty->assign(
|
||||
[
|
||||
'pagertotalitems' => $browsecount,
|
||||
'pageroffset'=> $offset,
|
||||
'pageritemsperpage'=> ITEMS_PER_PAGE,
|
||||
'pagerquerybase' => WWW_TOP.'/browse?t='.$category.'&g='.$grp.'&ob='.$orderby.'&offset=',
|
||||
'pagerquerysuffix' => '#results',
|
||||
]);
|
||||
[
|
||||
'pagertotalitems' => $browsecount,
|
||||
'pageroffset'=> $offset,
|
||||
'pageritemsperpage'=> ITEMS_PER_PAGE,
|
||||
'pagerquerybase' => WWW_TOP.'/browse?t='.$category.'&g='.$grp.'&ob='.$orderby.'&offset=',
|
||||
'pagerquerysuffix' => '#results',
|
||||
]
|
||||
);
|
||||
|
||||
$pager = $page->smarty->fetch('pager.tpl');
|
||||
$page->smarty->assign('pager', $pager);
|
||||
|
||||
@@ -47,65 +47,66 @@ function smarty_function_html_options_multiple($params, $template)
|
||||
$extra = '';
|
||||
foreach ($params as $_key => $_val) {
|
||||
switch ($_key) {
|
||||
case 'name':
|
||||
case 'class':
|
||||
case 'id':
|
||||
$$_key = (string) $_val;
|
||||
break;
|
||||
case 'options':
|
||||
$options = (array) $_val;
|
||||
break;
|
||||
case 'values':
|
||||
case 'output':
|
||||
$$_key = array_values((array) $_val);
|
||||
break;
|
||||
case 'selected':
|
||||
if (is_array($_val)) {
|
||||
$selected = [];
|
||||
foreach ($_val as $_sel) {
|
||||
if (is_object($_sel)) {
|
||||
if (method_exists($_sel, '__toString')) {
|
||||
$_sel = smarty_function_escape_special_chars((string) $_sel->__toString());
|
||||
} else {
|
||||
trigger_error("html_options_multiple: selected attribute contains an object of class '".get_class($_sel)."' without __toString() method", E_USER_NOTICE);
|
||||
continue;
|
||||
}
|
||||
} else {
|
||||
$_sel = smarty_function_escape_special_chars((string) $_sel);
|
||||
}
|
||||
$selected[$_sel] = true;
|
||||
}
|
||||
} elseif (is_object($_val)) {
|
||||
if (method_exists($_val, '__toString')) {
|
||||
$selected = smarty_function_escape_special_chars((string) $_val->__toString());
|
||||
} else {
|
||||
trigger_error("html_options_multiple: selected attribute is an object of class '".get_class($_val)."' without __toString() method", E_USER_NOTICE);
|
||||
}
|
||||
} else {
|
||||
$selected = smarty_function_escape_special_chars((string) $_val);
|
||||
}
|
||||
break;
|
||||
case 'strict': break;
|
||||
case 'disabled':
|
||||
case 'readonly':
|
||||
if (! empty($params['strict'])) {
|
||||
if (! is_scalar($_val)) {
|
||||
trigger_error("html_options_multiple: $_key attribute must be a scalar, only boolean true or string '$_key' will actually add the attribute", E_USER_NOTICE);
|
||||
}
|
||||
if ($_val === true || $_val === $_key) {
|
||||
$extra .= ' '.$_key.'="'.smarty_function_escape_special_chars($_key).'"';
|
||||
}
|
||||
break;
|
||||
}
|
||||
// omit break; to fall through!
|
||||
default:
|
||||
if (! is_array($_val)) {
|
||||
$extra .= ' '.$_key.'="'.smarty_function_escape_special_chars($_val).'"';
|
||||
} else {
|
||||
trigger_error("html_options_multiple: extra attribute '$_key' cannot be an array", E_USER_NOTICE);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 'name':
|
||||
case 'class':
|
||||
case 'id':
|
||||
$$_key = (string) $_val;
|
||||
break;
|
||||
case 'options':
|
||||
$options = (array) $_val;
|
||||
break;
|
||||
case 'values':
|
||||
case 'output':
|
||||
$$_key = array_values((array) $_val);
|
||||
break;
|
||||
case 'selected':
|
||||
if (is_array($_val)) {
|
||||
$selected = [];
|
||||
foreach ($_val as $_sel) {
|
||||
if (is_object($_sel)) {
|
||||
if (method_exists($_sel, '__toString')) {
|
||||
$_sel = smarty_function_escape_special_chars((string) $_sel->__toString());
|
||||
} else {
|
||||
trigger_error("html_options_multiple: selected attribute contains an object of class '".get_class($_sel)."' without __toString() method", E_USER_NOTICE);
|
||||
continue;
|
||||
}
|
||||
} else {
|
||||
$_sel = smarty_function_escape_special_chars((string) $_sel);
|
||||
}
|
||||
$selected[$_sel] = true;
|
||||
}
|
||||
} elseif (is_object($_val)) {
|
||||
if (method_exists($_val, '__toString')) {
|
||||
$selected = smarty_function_escape_special_chars((string) $_val->__toString());
|
||||
} else {
|
||||
trigger_error("html_options_multiple: selected attribute is an object of class '".get_class($_val)."' without __toString() method", E_USER_NOTICE);
|
||||
}
|
||||
} else {
|
||||
$selected = smarty_function_escape_special_chars((string) $_val);
|
||||
}
|
||||
break;
|
||||
case 'strict': break;
|
||||
case 'disabled':
|
||||
case 'readonly':
|
||||
if (! empty($params['strict'])) {
|
||||
if (! is_scalar($_val)) {
|
||||
trigger_error("html_options_multiple: $_key attribute must be a scalar, only boolean true or string '$_key' will actually add the attribute", E_USER_NOTICE);
|
||||
}
|
||||
if ($_val === true || $_val === $_key) {
|
||||
$extra .= ' '.$_key.'="'.smarty_function_escape_special_chars($_key).'"';
|
||||
}
|
||||
break;
|
||||
}
|
||||
// omit break; to fall through!
|
||||
// no break
|
||||
default:
|
||||
if (! is_array($_val)) {
|
||||
$extra .= ' '.$_key.'="'.smarty_function_escape_special_chars($_val).'"';
|
||||
} else {
|
||||
trigger_error("html_options_multiple: extra attribute '$_key' cannot be an array", E_USER_NOTICE);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (! isset($options) && ! isset($values)) {
|
||||
/* raise error here? */
|
||||
|
||||
@@ -9,26 +9,26 @@ function load_plugin_dependency($filename)
|
||||
}
|
||||
|
||||
switch (true) {
|
||||
case is_string($smarty->plugins_dir) && is_dir($smarty->plugins_dir):
|
||||
$plugins_dir = $smarty->plugins_dir;
|
||||
require_once $plugins_dir.DIRECTORY_SEPARATOR.$filename;
|
||||
break;
|
||||
case is_array($smarty->plugins_dir):
|
||||
$plugins_dir = '';
|
||||
foreach ($smarty->plugins_dir as $dir) {
|
||||
if (is_string($dir) && is_dir($dir)) {
|
||||
$file = $dir.DIRECTORY_SEPARATOR.$filename;
|
||||
if (file_exists($file) && is_readable($file)) {
|
||||
$plugins_dir = $dir;
|
||||
require_once $file;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
$plugins_dir = '';
|
||||
}
|
||||
case is_string($smarty->plugins_dir) && is_dir($smarty->plugins_dir):
|
||||
$plugins_dir = $smarty->plugins_dir;
|
||||
require_once $plugins_dir.DIRECTORY_SEPARATOR.$filename;
|
||||
break;
|
||||
case is_array($smarty->plugins_dir):
|
||||
$plugins_dir = '';
|
||||
foreach ($smarty->plugins_dir as $dir) {
|
||||
if (is_string($dir) && is_dir($dir)) {
|
||||
$file = $dir.DIRECTORY_SEPARATOR.$filename;
|
||||
if (file_exists($file) && is_readable($file)) {
|
||||
$plugins_dir = $dir;
|
||||
require_once $file;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
$plugins_dir = '';
|
||||
}
|
||||
|
||||
if (! is_dir($plugins_dir)) {
|
||||
exit('Fatal: Unable to find smarty plugins directory.'.PHP_EOL);
|
||||
|
||||
@@ -9,17 +9,17 @@
|
||||
* Author: Joscha Feth, joscha@feth.com
|
||||
* Purpose: formats a filesize (in bytes) to human-readable format
|
||||
* Usage: In the template, use
|
||||
{$filesize|fsize_format} => 123.45 B|KB|MB|GB|TB
|
||||
or
|
||||
{$filesize|fsize_format:"MB"} => 123.45 MB
|
||||
or
|
||||
{$filesize|fsize_format:"TB":4} => 0.0012 TB
|
||||
{$filesize|fsize_format} => 123.45 B|KB|MB|GB|TB
|
||||
or
|
||||
{$filesize|fsize_format:"MB"} => 123.45 MB
|
||||
or
|
||||
{$filesize|fsize_format:"TB":4} => 0.0012 TB
|
||||
* Params:
|
||||
int size the filesize in bytes
|
||||
string format the format, the output shall be: B, KB, MB, GB or TB
|
||||
int precision the rounding precision
|
||||
string dec_point the decimal separator
|
||||
string thousands_sep the thousands separator
|
||||
int size the filesize in bytes
|
||||
string format the format, the output shall be: B, KB, MB, GB or TB
|
||||
int precision the rounding precision
|
||||
string dec_point the decimal separator
|
||||
string thousands_sep the thousands separator
|
||||
* Install: Drop into the plugin directory
|
||||
* Version:
|
||||
* 2007-05-24 Version 0.3 - added the peta, exa, zeta, and yeta byte magnitudes thanks to coreone (at) gmail (dot) com
|
||||
|
||||
@@ -14,20 +14,20 @@ if (! isset($smarty)) {
|
||||
$smarty = new Smarty();
|
||||
}
|
||||
switch (true) {
|
||||
case is_string($smarty->plugins_dir) && is_dir($smarty->plugins_dir):
|
||||
$plugins_dir = $smarty->plugins_dir;
|
||||
break;
|
||||
case is_array($smarty->plugins_dir):
|
||||
$plugins_dir = '';
|
||||
foreach ($smarty->plugins_dir as $dir) {
|
||||
if (is_string($dir) && is_dir($dir)) {
|
||||
$plugins_dir = $dir;
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
$plugins_dir = '';
|
||||
case is_string($smarty->plugins_dir) && is_dir($smarty->plugins_dir):
|
||||
$plugins_dir = $smarty->plugins_dir;
|
||||
break;
|
||||
case is_array($smarty->plugins_dir):
|
||||
$plugins_dir = '';
|
||||
foreach ($smarty->plugins_dir as $dir) {
|
||||
if (is_string($dir) && is_dir($dir)) {
|
||||
$plugins_dir = $dir;
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
$plugins_dir = '';
|
||||
}
|
||||
if (! is_dir($plugins_dir)) {
|
||||
exit('Fatal: Unable to find smarty plugins directory.'.PHP_EOL);
|
||||
@@ -55,24 +55,24 @@ require_once $plugins_dir.'shared.make_timestamp.php';
|
||||
function smarty_modifier_phpdate_format($string, $format = 'Y/m/d H:i:s', $default_date = null)
|
||||
{
|
||||
/* if (substr(PHP_OS,0,3) == 'WIN') {
|
||||
$_win_from = array ('%e', '%T', '%D');
|
||||
$_win_to = array ('%#d', '%H:%M:%S', '%m/%d/%y');
|
||||
$format = str_replace($_win_from, $_win_to, $format);
|
||||
}*/
|
||||
$_win_from = array ('%e', '%T', '%D');
|
||||
$_win_to = array ('%#d', '%H:%M:%S', '%m/%d/%y');
|
||||
$format = str_replace($_win_from, $_win_to, $format);
|
||||
}*/
|
||||
if (substr($format, 0, 5) == 'DATE_') {
|
||||
switch ($format) {
|
||||
case 'DATE_ATOM': $nformat = DATE_ATOM; break;
|
||||
case 'DATE_COOKIE': $nformat = DATE_COOKIE; break;
|
||||
case 'DATE_ISO8601': $nformat = DATE_ISO8601; break;
|
||||
case 'DATE_RFC822': $nformat = 'D, d M y H:i:s O'; break; //The php constant is not quite right - as the time-zone comes out with invalid values like "UTC"...
|
||||
case 'DATE_RFC850': $nformat = DATE_RFC850; break;
|
||||
case 'DATE_RFC1036': $nformat = DATE_RFC1036; break;
|
||||
case 'DATE_RFC1123': $nformat = DATE_RFC1123; break;
|
||||
case 'DATE_RFC2822': $nformat = DATE_RFC2822; break;
|
||||
case 'DATE_RFC3339': $nformat = DATE_RFC3339; break;
|
||||
case 'DATE_RSS': $nformat = 'D, d M Y H:i:s O'; break; //as rfc822 ...
|
||||
case 'DATE_W3C': $nformat = DATE_W3C; break;
|
||||
}
|
||||
case 'DATE_ATOM': $nformat = DATE_ATOM; break;
|
||||
case 'DATE_COOKIE': $nformat = DATE_COOKIE; break;
|
||||
case 'DATE_ISO8601': $nformat = DATE_ISO8601; break;
|
||||
case 'DATE_RFC822': $nformat = 'D, d M y H:i:s O'; break; //The php constant is not quite right - as the time-zone comes out with invalid values like "UTC"...
|
||||
case 'DATE_RFC850': $nformat = DATE_RFC850; break;
|
||||
case 'DATE_RFC1036': $nformat = DATE_RFC1036; break;
|
||||
case 'DATE_RFC1123': $nformat = DATE_RFC1123; break;
|
||||
case 'DATE_RFC2822': $nformat = DATE_RFC2822; break;
|
||||
case 'DATE_RFC3339': $nformat = DATE_RFC3339; break;
|
||||
case 'DATE_RSS': $nformat = 'D, d M Y H:i:s O'; break; //as rfc822 ...
|
||||
case 'DATE_W3C': $nformat = DATE_W3C; break;
|
||||
}
|
||||
} else {
|
||||
$nformat = $format;
|
||||
}
|
||||
|
||||
@@ -17,10 +17,10 @@ function smarty_modifier_timeAgo($date)
|
||||
return 'n/a';
|
||||
}
|
||||
$timeStrings = ['now', // 0
|
||||
'Sec', 'Secs', // 1,1
|
||||
'Min', 'Mins', // 3,3
|
||||
'Hour', 'Hrs', // 5,5
|
||||
'Day', 'Days', ];
|
||||
'Sec', 'Secs', // 1,1
|
||||
'Min', 'Mins', // 3,3
|
||||
'Hour', 'Hrs', // 5,5
|
||||
'Day', 'Days', ];
|
||||
$sec = time() - ((! is_numeric($date) && strtotime($date)) ? strtotime($date) : $date);
|
||||
if ($sec <= 0) {
|
||||
return $timeStrings[0];
|
||||
|
||||
@@ -22,8 +22,14 @@ function smarty_make_timestamp($string)
|
||||
return (int) $string->format('U'); // PHP 5.2 BC
|
||||
} elseif (strlen($string) == 14 && ctype_digit($string)) {
|
||||
// it is mysql timestamp format of YYYYMMDDHHMMSS?
|
||||
return mktime(substr($string, 8, 2), substr($string, 10, 2), substr($string, 12, 2),
|
||||
substr($string, 4, 2), substr($string, 6, 2), substr($string, 0, 4));
|
||||
return mktime(
|
||||
substr($string, 8, 2),
|
||||
substr($string, 10, 2),
|
||||
substr($string, 12, 2),
|
||||
substr($string, 4, 2),
|
||||
substr($string, 6, 2),
|
||||
substr($string, 0, 4)
|
||||
);
|
||||
} elseif (is_numeric($string)) {
|
||||
// it is a numeric string, we handle it as timestamp
|
||||
return (int) $string;
|
||||
|
||||
@@ -19,13 +19,13 @@
|
||||
<th>disable preview</th>
|
||||
</tr>
|
||||
|
||||
{foreach from=$categorylist item=category}
|
||||
{foreach $categorylist as $category}
|
||||
<tr class="{cycle values=",alt"}">
|
||||
<td>{$category.id}</td>
|
||||
<td><a href="{$smarty.const.WWW_TOP}/category-edit.php?id={$category.id}">{$category.title}</a></td>
|
||||
<td>
|
||||
{if $category.parentid != null}
|
||||
{$category.parentName}
|
||||
{$category->parent->title}
|
||||
{else}
|
||||
n/a
|
||||
{/if}
|
||||
|
||||
Reference in New Issue
Block a user