-
Notifications
You must be signed in to change notification settings - Fork 26
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
144 changed files
with
8,774 additions
and
1,861 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
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,52 @@ | ||
<?php | ||
namespace app\pro; | ||
|
||
use xenice\theme\Theme; | ||
|
||
class Loader extends \app\web\Loader | ||
{ | ||
public function __construct() | ||
{ | ||
Theme::set('default_theme', 'web'); | ||
|
||
$aliases = [ | ||
'article' => 'app\pro\model\Article', | ||
'article_pointer' => 'app\pro\model\pointer\Article', | ||
'template' => 'app\pro\template\Template', | ||
]; | ||
|
||
$prepares = [ | ||
11 => 'xenice\login\Login', | ||
60 => 'app\pro\ajax\Ajax', | ||
]; | ||
|
||
if(is_admin()){ | ||
//Theme::bind('xenice_options_init', [$this,'set']); | ||
$prepares[90] = 'app\pro\module\inner\Admin'; | ||
} | ||
else{ | ||
$prepares[100] = 'app\pro\module\inner\Guest'; | ||
} | ||
|
||
$args = [ | ||
'aliases' => $aliases, | ||
'prepares' => $prepares, | ||
]; | ||
|
||
parent::__construct($args); | ||
} | ||
|
||
/* | ||
public function set($options) | ||
{ | ||
$options = parent::set($options); | ||
$options[0]['fields'][0]['value'] = '#FF5E52 #FF5E52 #FF5E52 #f13c2f #fff #fc938b'; | ||
$options[0]['fields'][2]['value'] = STATIC_URL_EX . '/images/logo.png'; | ||
$options[1]['fields'][3]['value'][0]['src'] = STATIC_URL_EX . '/images/onenice-1.jpg'; | ||
$options[1]['fields'][3]['value'][1]['src'] = STATIC_URL_EX . '/images/onenice-2.jpg'; | ||
$options[1]['fields'][3]['value'][2]['src'] = STATIC_URL_EX . '/images/onenice-3.jpg'; | ||
return array_merge($options, require(__DIR__ . '/options.php')); | ||
}*/ | ||
} |
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,12 @@ | ||
<?php | ||
namespace app\pro\ajax; | ||
|
||
|
||
class Ajax extends \app\web\ajax\Ajax | ||
{ | ||
public function __construct() | ||
{ | ||
parent::__construct(); | ||
LikeAjax::instance(); | ||
} | ||
} |
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,40 @@ | ||
<?php | ||
namespace app\pro\ajax; | ||
|
||
use xenice\theme\Theme; | ||
use xenice\theme\Ajax; | ||
|
||
class LikeAjax extends Ajax | ||
{ | ||
public function __construct() | ||
{ | ||
$this->action('like'); | ||
} | ||
|
||
public function like() | ||
{ | ||
$id = esc_sql($_POST['pid']); | ||
if(isset($_COOKIE['xenice_like_'.$id])){ | ||
echo json_encode(['key'=>'liked', 'value'=>_t('You already liked it')]); | ||
exit; | ||
} | ||
|
||
$count = get_post_meta($id, 'likes', true); | ||
if($count){ | ||
$count ++; | ||
update_post_meta($id, 'likes', $count); | ||
} | ||
else{ | ||
$count = 1; | ||
add_post_meta($id, 'likes', $count, true); | ||
} | ||
|
||
$html = '<i class="fa fa-thumbs-o-up"></i> ' . _t('Liked') . '(<span>' .$count . '</span>)'; | ||
echo json_encode(['key'=>'success','value'=>$html]); | ||
|
||
$expire = time() + 99999999; | ||
$domain = ($_SERVER['HTTP_HOST'] != 'localhost') ? $_SERVER['HTTP_HOST'] : false; // make cookies work with localhost | ||
setcookie('xenice_like_'.$id, $id, $expire, '/', $domain); | ||
exit; | ||
} | ||
} |
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,15 @@ | ||
<?php | ||
|
||
namespace app\pro\controller; | ||
|
||
use xenice\theme\Theme; | ||
|
||
class CategoryController extends \app\web\controller\CategoryController | ||
{ | ||
|
||
public function index($view = 'index') | ||
{ | ||
parent::index($view); | ||
} | ||
|
||
} |
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,122 @@ | ||
<?php | ||
|
||
namespace app\pro\controller; | ||
|
||
use xenice\theme\Theme; | ||
|
||
class SingleController extends \app\web\controller\SingleController | ||
{ | ||
public function index($view = 'index') | ||
{ | ||
$this->addScripts(); | ||
parent::index($view); | ||
} | ||
|
||
public function scripts() | ||
{ | ||
parent::scripts(); | ||
|
||
$cdn = take('enable_cdn'); | ||
$cdn_url = take('cdn_url'); | ||
|
||
if(take('enable_photoswipe')){ | ||
if($cdn){ | ||
wp_enqueue_style('photoswipe-css', $cdn_url . '/photoswipe/4.1.0/photoswipe.min.css', [], '4.1.0'); | ||
wp_enqueue_style('photoswipe-css-skin', $cdn_url . '/photoswipe/4.1.0/default-skin/default-skin.min.css', [], '4.1.0'); | ||
wp_enqueue_script('photoswipe-js', $cdn_url . '/photoswipe/4.1.0/photoswipe.min.js', [], '4.1.0', true); | ||
wp_enqueue_script('photoswipe-js-ui', $cdn_url . '/photoswipe/4.1.0/photoswipe-ui-default.min.js', [], '4.1.0', true); | ||
} | ||
else{ | ||
wp_enqueue_style('photoswipe-css', STATIC_URL_EX . '/lib/photoswipe/css/photoswipe.css', [], '4.1.0'); | ||
wp_enqueue_style('photoswipe-css-skin', STATIC_URL_EX . '/lib/photoswipe/css/default-skin/default-skin.css', [], '4.1.0'); | ||
wp_enqueue_script('photoswipe-js', STATIC_URL_EX . '/lib/photoswipe/js/photoswipe.min.js', [], '4.1.0', true); | ||
wp_enqueue_script('photoswipe-js-ui', STATIC_URL_EX . '/lib/photoswipe/js/photoswipe-ui-default.min.js', [], '4.1.0', true); | ||
} | ||
wp_enqueue_script('photoswipe-init', STATIC_URL_EX . '/lib/photoswipe/init.js', [], '4.1.0', true); | ||
} | ||
|
||
|
||
} | ||
|
||
private function addScripts() | ||
{ | ||
if(take('enable_photoswipe')){ | ||
Theme::use('template')->js .=<<<js | ||
jQuery(function($){ | ||
var imgdefereds=[]; | ||
$('.gallery img').each(function(){ | ||
var dfd=$.Deferred(); | ||
$(this).bind('load',function(){ | ||
dfd.resolve(); | ||
}).bind('error',function(){ | ||
// dfd.resolve(); | ||
}); | ||
if(this.complete){ | ||
setTimeout(function(){ | ||
dfd.resolve(); | ||
},1000); | ||
} | ||
else{ | ||
imgdefereds.push(dfd); | ||
} | ||
}); | ||
$.when.apply(null,imgdefereds).done(function(){ | ||
$('.gallery img').each(function(i, val){ | ||
var img = new Image(); | ||
img.src = this.src; | ||
let obj = {} | ||
// 如果图片被缓存,则直接返回缓存数据 | ||
if (img.complete) { | ||
obj.width = img.width; | ||
obj.height = img.height; | ||
} else { | ||
img.onload = function () { | ||
obj.width = img.width; | ||
obj.height = img.height; | ||
} | ||
} | ||
var str = ''; | ||
str += '<figure><a href="'+this.src+'" data-size="'+obj.width+'x'+obj.height+'">'; | ||
str += '<img src="'+this.src+'" alt="'+this.alt+'" title="'+this.title+'" />'; | ||
str +='</a></figure>'; | ||
$(this).replaceWith(str); | ||
}); | ||
initPhotoSwipeFromDOM('.gallery'); | ||
}); | ||
}); | ||
js; | ||
} | ||
|
||
if(take('enable_like')){ | ||
Theme::use('template')->js .=<<<js | ||
jQuery(function($){ | ||
$('.post-like-a').on('click', function(){ | ||
var pid = $(this).attr('data-pid'); | ||
var nonce = $(this).attr('data-nonce'); | ||
$.post( | ||
xenice.action + 'like', | ||
{ | ||
like_nonce: nonce, | ||
pid: pid, | ||
}, | ||
function (data) { | ||
var data = JSON.parse(data) | ||
if(data.key == 'success'){ | ||
$('.post-like-a').html(data.value); | ||
} | ||
else if(data.key == 'liked'){ | ||
alert(data.value); | ||
} | ||
else{ | ||
console.log(data); | ||
} | ||
} | ||
); | ||
}) | ||
}); | ||
js; | ||
} | ||
|
||
|
||
} | ||
} |
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,16 @@ | ||
<?php | ||
|
||
namespace app\pro\model; | ||
|
||
use xenice\theme\Theme; | ||
|
||
class Article extends \app\web\model\Article | ||
{ | ||
public function __construct() | ||
{ | ||
parent::__construct(); | ||
|
||
} | ||
|
||
|
||
} |
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,75 @@ | ||
<?php | ||
|
||
namespace app\pro\model\pointer; | ||
|
||
use xenice\theme\Theme; | ||
|
||
class Article extends \app\web\model\pointer\Article | ||
{ | ||
private $shotcodes = []; | ||
|
||
public function __construct($mix) | ||
{ | ||
parent::__construct($mix); | ||
} | ||
|
||
/* | ||
public function shortcode($tagname = 'data') | ||
{ | ||
if(isset($this->shotcodes[$tagname])){ | ||
return $this->shotcodes[$tagname]; | ||
} | ||
$shortcode = []; | ||
$pattern = get_shortcode_regex([$tagname]); | ||
if (preg_match_all( '/'. $pattern .'/s', $this->row('post_content'), $matches) && array_key_exists(2, $matches)){ | ||
$shortcode['code'] = $matches[0][0]; | ||
$shortcode['atts'] = shortcode_parse_atts($matches[0][0]); | ||
unset($shortcode['atts'][0]); | ||
unset($shortcode['atts'][1]); | ||
$shortcode['value'] = $matches[5][0]; | ||
$this->shotcodes[$tagname] = $shortcode; | ||
return $shortcode; | ||
} | ||
} | ||
public function atts($name, $tagname = 'data') | ||
{ | ||
if(isset($this->shotcodes[$tagname]['atts'][$name])){ | ||
return $this->shotcodes[$tagname]['atts'][$name]; | ||
} | ||
if(isset($this->shotcodes[$tagname])){ // already execute | ||
return; | ||
} | ||
$shortcode = $this->shortcode($tagname); | ||
return $shortcode['atts'][$name]??null; | ||
} | ||
public function thumbnail($type = 'full') | ||
{ | ||
if(empty($this->atts('image'))){ | ||
return parent::thumbnail($type); | ||
} | ||
else{ | ||
return $this->atts('image'); | ||
} | ||
} | ||
public function price() | ||
{ | ||
if(empty($this->atts('price'))){ | ||
return _t('Free'); | ||
} | ||
else{ | ||
return '¥' . $this->atts('price'); | ||
} | ||
} | ||
public function cnt($tags = ['data']) | ||
{ | ||
$content = $this->content(); | ||
$pattern = get_shortcode_regex($tags); | ||
//$pattern = '\[(\[?)([^\]\/]*(?:\/(?!\])[^\]\/]*)*?)(?:(\/)\]|\](?:([^\[]*+(?:\[(?!\/\2\])[^\[]*+)*+)\[\/\2\])?)(\]?)'; | ||
$content = preg_replace("/$pattern/", '', $content); | ||
return $content; | ||
}*/ | ||
} |
Oops, something went wrong.