cache changes to support scss, scssphp library reference included, system api contains cache call now
This commit is contained in:
parent
b7d8a48710
commit
0c8e11f2d9
@ -22,4 +22,7 @@ class api_system extends api_login{
|
||||
|
||||
public static function call_bug($message,$data){
|
||||
return \SYSTEM\SAI\saimod_sys_todo::report($message,$data);}
|
||||
|
||||
public static function call_cache($id,$ident){
|
||||
return \SYSTEM\CACHE\cache::get($id, $ident,true);}
|
||||
}
|
||||
33
cache/cache.php
vendored
33
cache/cache.php
vendored
@ -1,30 +1,29 @@
|
||||
<?php
|
||||
|
||||
namespace SYSTEM\CACHE;
|
||||
|
||||
class cache {
|
||||
|
||||
public static function get($cache_id, $ident){
|
||||
$result = \SYSTEM\SQL\SYS_CACHE_CHECK::Q1(array($cache_id,$ident));
|
||||
class cache {
|
||||
public static function get($cache, $ident,$header = false){
|
||||
$result = \SYSTEM\SQL\SYS_CACHE_CHECK::Q1(array($cache,$ident));
|
||||
if(!$result){
|
||||
return NULL;}
|
||||
|
||||
return pg_unescape_bytea($result['data']);
|
||||
if($header){
|
||||
if(\SYSTEM\HEADER::available($result['type'])){
|
||||
call_user_func('\SYSTEM\HEADER::'.$result['type']);
|
||||
}else{
|
||||
\SYSTEM\HEADER::FILE($ident);}
|
||||
}
|
||||
return $result['data'];
|
||||
}
|
||||
|
||||
public static function put($cache_id, $ident, $data, $fail_on_exist = false){
|
||||
if((self::get($cache_id,$ident) != NULL)){
|
||||
if($fail_on_exist){
|
||||
return false;}
|
||||
self::del($cache_id, $ident);
|
||||
}
|
||||
public static function put($cache, $ident, $type, $data, $fail_on_exist = false){
|
||||
if(($fail_on_exist && self::get($cache,$ident) != NULL)){
|
||||
return false;}
|
||||
|
||||
$result = \SYSTEM\SQL\SYS_CACHE_PUT::Q1(array($cache_id,$ident, pg_escape_bytea($data)));
|
||||
$result = \SYSTEM\SQL\SYS_CACHE_PUT::Q1(array($cache,$ident, $type, $data));
|
||||
return $result ? $data : NULL;
|
||||
}
|
||||
|
||||
public static function del($cache_id, $ident){
|
||||
$result = \SYSTEM\SQL\SYS_CACHE_DELETE::Q1(array($cache_id,$ident));
|
||||
public static function del($cache, $ident){
|
||||
$result = \SYSTEM\SQL\SYS_CACHE_DELETE::Q1(array($cache,$ident));
|
||||
return $result ? true : false;
|
||||
}
|
||||
}
|
||||
15
cache/cache_scss.php
vendored
Normal file
15
cache/cache_scss.php
vendored
Normal file
@ -0,0 +1,15 @@
|
||||
<?php
|
||||
namespace SYSTEM\CACHE;
|
||||
class cache_scss {
|
||||
const CACHE_SCSS = 10;
|
||||
public static function put($file,$data){
|
||||
return \SYSTEM\CACHE\cache::put(self::CACHE_SCSS, self::ident($file), 'css', $data);}
|
||||
public static function get($file,$header = false){
|
||||
return \SYSTEM\CACHE\cache::get(self::CACHE_SCSS, self::ident($file),$header);}
|
||||
public static function ident($file){
|
||||
return sha1($file.';'.filemtime($file));
|
||||
}
|
||||
public static function url($file){
|
||||
return './api.php?call=cache&id='.self::CACHE_SCSS.'&ident='.self::ident($file);
|
||||
}
|
||||
}
|
||||
8
cache/qq/SYS_CACHE_CHECK.php
vendored
8
cache/qq/SYS_CACHE_CHECK.php
vendored
@ -2,9 +2,13 @@
|
||||
namespace SYSTEM\SQL;
|
||||
class SYS_CACHE_CHECK extends \SYSTEM\DB\QP {
|
||||
public static function get_class(){return \get_class();}
|
||||
public static function pgsql(){return
|
||||
public static function pTsql(){return
|
||||
'SELECT "data" FROM system.cache'.
|
||||
' WHERE "CacheID" = $1 AND'.
|
||||
' "Ident" = $2;';
|
||||
}
|
||||
}
|
||||
public static function mysql(){return
|
||||
'SELECT * FROM system_cache'.
|
||||
' WHERE cache = ? AND ident = ?;';
|
||||
}
|
||||
}
|
||||
6
cache/qq/SYS_CACHE_PUT.php
vendored
6
cache/qq/SYS_CACHE_PUT.php
vendored
@ -2,8 +2,12 @@
|
||||
namespace SYSTEM\SQL;
|
||||
class SYS_CACHE_PUT extends \SYSTEM\DB\QP {
|
||||
public static function get_class(){return \get_class();}
|
||||
public static function pqsql(){return
|
||||
public static function pTsql(){return
|
||||
'INSERT INTO system.cache ("CacheID", "Ident", "data")'.
|
||||
' VALUES ($1,$2,$3);';
|
||||
}
|
||||
public static function mysql(){return
|
||||
'REPLACE INTO system_cache (cache, ident, type, data)'.
|
||||
' VALUES (?,?,?,?);';
|
||||
}
|
||||
}
|
||||
@ -10,7 +10,7 @@ class files {
|
||||
public static function get($cat = null, $id = null, $returnasjson = false) {
|
||||
if (!$cat) {
|
||||
return $returnasjson ? \SYSTEM\LOG\JsonResult::toString(self::$folders) : self::$folders;}
|
||||
|
||||
|
||||
if (!array_key_exists($cat, self::$folders)) {
|
||||
throw new \SYSTEM\LOG\ERROR("No matching Cat '" . $cat . "' found.");}
|
||||
|
||||
|
||||
@ -5,4 +5,6 @@ class html{
|
||||
return '<link href="'.$href.'" rel="'.$rel.'" type="'.$type.'"/>';}
|
||||
public static function script($src,$type = 'text/javascript',$rel = 'stylesheet', $language = 'JavaScript', $script = ''){
|
||||
return '<script src="'.$src.'" language="'.$language.'" type="'.$type.'">'.$script.'</script>';}
|
||||
public static function style($style){
|
||||
return '<style> '.$style.'</style>';}
|
||||
}
|
||||
|
||||
@ -11,4 +11,5 @@ require_once dirname(__FILE__).'/animate/autoload.inc';
|
||||
require_once dirname(__FILE__).'/lettering/autoload.inc';
|
||||
require_once dirname(__FILE__).'/bootstrap_growl/autoload.inc';
|
||||
require_once dirname(__FILE__).'/git/autoload.inc';
|
||||
require_once dirname(__FILE__).'/jqbootstrapvalidation/autoload.inc';
|
||||
require_once dirname(__FILE__).'/jqbootstrapvalidation/autoload.inc';
|
||||
require_once dirname(__FILE__).'/scssphp/autoload.inc';
|
||||
@ -31,6 +31,14 @@ class State {
|
||||
$row['css'] = $row['js'] = array();
|
||||
if(\class_exists($row['php_class']) && \method_exists($row['php_class'], 'css') && \is_callable($row['php_class'].'::css')){
|
||||
$row['css'] = array_merge($row['css'], \call_user_func($row['php_class'].'::css'));}
|
||||
\LIB\lib_scssphp::php();
|
||||
if(\class_exists($row['php_class']) && \method_exists($row['php_class'], 'scss') && \is_callable($row['php_class'].'::scss')){
|
||||
$scss = \call_user_func($row['php_class'].'::scss');
|
||||
foreach($scss as $s){
|
||||
if(!\SYSTEM\CACHE\cache_scss::get($s)){
|
||||
\SYSTEM\CACHE\cache_scss::put($s, (new \Leafo\ScssPhp\Compiler())->compile(file_get_contents($s)));}
|
||||
$row['css'][] = \SYSTEM\CACHE\cache_scss::url($s);}
|
||||
}
|
||||
if(\class_exists($row['php_class']) && \method_exists($row['php_class'], 'js') && \is_callable($row['php_class'].'::js')){
|
||||
$row['js'] = array_merge($row['js'], \call_user_func($row['php_class'].'::js'));}
|
||||
$row['php_class'] = '';
|
||||
|
||||
@ -28,6 +28,9 @@ INSERT INTO `system_api` (`ID`, `group`, `type`, `parentID`, `parentValue`, `nam
|
||||
INSERT INTO `system_api` (`ID`, `group`, `type`, `parentID`, `parentValue`, `name`, `verify`) VALUES (60, 0, 2, 10, 'bug', 'message', 'STRING');
|
||||
INSERT INTO `system_api` (`ID`, `group`, `type`, `parentID`, `parentValue`, `name`, `verify`) VALUES (61, 0, 2, 10, 'bug', 'data', 'JSON');
|
||||
|
||||
INSERT INTO `system_api` (`ID`, `group`, `type`, `parentID`, `parentValue`, `name`, `verify`) VALUES (70, 0, 2, 10, 'cache', 'id', 'INT');
|
||||
INSERT INTO `system_api` (`ID`, `group`, `type`, `parentID`, `parentValue`, `name`, `verify`) VALUES (71, 0, 2, 10, 'cache', 'ident', 'STRING');
|
||||
|
||||
INSERT INTO `system_api` (`ID`, `group`, `type`, `parentID`, `parentValue`, `name`, `verify`) VALUES (90, 0, 4, -1, NULL, '_lang', 'LANG');
|
||||
INSERT INTO `system_api` (`ID`, `group`, `type`, `parentID`, `parentValue`, `name`, `verify`) VALUES (91, 0, 4, -1, NULL, '_result', 'RESULT');
|
||||
INSERT INTO `system_api` (`ID`, `group`, `type`, `parentID`, `parentValue`, `name`, `verify`) VALUES (92, 0, 4, -1, NULL, '_escaped_fragment_', 'STRING');
|
||||
Loading…
x
Reference in New Issue
Block a user