Commit 4367d3b4 by 庄欣

2016.4.21

parent b32576c2
......@@ -12,5 +12,7 @@ model = app/model/
view = app/view/
library = lib/
baseUri = /user.yuepai.com/
runtime = runtime/view/
temp_view = ../runtime/user/view/
shareDir = ../runtime/share/
access_log = ../runtime/user/log/
session_unique_id = Front
<?php
namespace config;
use lib\RouteApi;
use Phalcon\Mvc\Router;
class route {
public function setRoute() {
$router = new Router();
$module = new RouteApi();
$router = $module->getRoute();
$router->notFound([
'controller' => 'Error',
'action' => 'error404'
]);
return $router;
}
}
......@@ -33,7 +33,7 @@ $di->set("db",function() use ($di,$config){
$di->set('volt', function ($view, $di) use ($config){
$volt = new VoltEngine($view, $di);
$volt->setOptions([
'compiledPath' => $config->application->runtime,
'compiledPath' => $config->application->temp_view,
'compiledSeparator' => '-'
]);
$compiler = $volt->getCompiler();
......
......@@ -24,6 +24,7 @@ abstract class BaseController extends Controller
unset($this->_get['p']);
}
unset($this->_get['_url']);
$this->_get = $this->parse_where($this->_get);
define('__SELF__',$_SERVER['REQUEST_URI']);
$this->_init();
$this->view->setVar("DEFAULT_AVATAR",$this->url->getStatic("./static/default_avatar.jpg"));
......@@ -75,7 +76,7 @@ abstract class BaseController extends Controller
/**
* 获取省
*/
public function getProvince()
public function getProvinceAction()
{
$lists = Citys::find(['father = 0']);
if ($this->request->isAjax()) {
......@@ -88,13 +89,13 @@ abstract class BaseController extends Controller
/**
* 获取市
*/
public function getCity()
public function getCityAction()
{
if(isset($this->_get['province_id'])){
$province_id = $this->_get['province_id'];
$lists = Citys::find(['father = '.$province_id]);
if ($this->request->isAjax()) {
$this->success($lists);
$this->success($lists->toArray());
} else {
$this->view->setVar("city_list",$lists);
}
......@@ -104,7 +105,7 @@ abstract class BaseController extends Controller
/**
* 获取区县
*/
public function getDistrict()
public function getDistrictAction()
{
if(isset($this->_get['city_id'])){
$city_id = $this->_get['city_id'];
......@@ -156,10 +157,19 @@ abstract class BaseController extends Controller
$this->view->setVar("_page",$_page);
}
public function LogicError($code = 404,$msg = "")
//$level 0 ERR 1 NOTICE
public function LogicError($code = 404,$msg = "",$level = 0)
{
$view = "error/".$code;
$this->view->setVar("msg",$msg);
if (PRODUCTION) {
if( $level>0) {
$this->view->setVar("msg",$msg);
} else {
$this->view->setVar("msg","系统出现了一个错误,请稍后再试!");
}
} else {
$this->view->setVar("msg",$msg);
}
$this->view->setVar("path",CONTROLLER_NAME);
$this->view->pick($view);
return;
......@@ -182,6 +192,18 @@ abstract class BaseController extends Controller
}
protected function parse_where() {
$where = $this->_get;
foreach ($this->_get as $k=>$v) {
if ($k == "filter") {
$where[$this->_get[$k]]= ['like',"'%".$where['keywords']."%'"];
}
}
unset($where['filter']);
unset($where['keywords']);
return $where;
}
//应该使用事件管理器在视图渲染前做好日志
private function log()
{
......@@ -200,4 +222,9 @@ abstract class BaseController extends Controller
fwrite($log,$ip." ".$method.$uri."\n".$condition);
fclose($log);
}
public function beforeRenderView()
{
$this->dump([]);
}
}
\ No newline at end of file
<?php
use Phalcon\Mvc\Controller;
class CatesController extends BaseController
{
const Category = 1;
......
......@@ -8,45 +8,9 @@ class FileController extends BaseController
public function initialize()
{
parent::initialize();
$this->upyun = new \lib\UpYun();
$this->ACCESS_DATE = date("Ymd",time());
}
public function imageAction()
{
$files=[];
if(isset($_FILES)){
//使用多重数组使文件的NAME可随意并支持多文件上传
$ext = "";
foreach($_FILES as $file){
if($file['error'] == 0){
switch($file['type']){
case "image/jpeg":
case "image/jpg":
$ext = ".jpg";
break;
case "image/png":
$ext = ".png";
break;
default:
$ext = ".jpg";
};
$file_name = '/uploads/'. $this->ACCESS_DATE.'/'.sha1(uniqid().$file['name']).$ext;
$res = $this->upyun->writeFile($file_name,fopen($file['tmp_name'],"r"));
if($res) {
$files[] = self::ADDR_PREFIX . $file_name;
}
}
}
if (!empty($files)){
echo json_encode(['status' =>"1",'info'=>$files[0],'data'=>$files[0]]);
} else {
echo json_encode(['status' =>"0",'info'=>'','data' => ""]);
}
}
exit();
}
//单文件上传
public function uploadAction()
{
......@@ -65,4 +29,55 @@ class FileController extends BaseController
}
}
//编辑器
public function editAction()
{
$action = $this->request->get("action");
$CONFIG = json_decode(preg_replace("/\/\*[\s\S]+?\*\//", "", file_get_contents("./static/boot/plugins/ueditor/php/config.json")), true);
switch ($action) {
case 'config':
$result = json_encode($CONFIG);
break;
case 'uploadimage':
case 'uploadscrawl':
case 'uploadvideo':
case 'uploadfile':
$tx = new \lib\TxImg\TxImgCloud();
$res = $tx->upload($_FILES['upfile']);
if ($res !== false) {
$result = json_encode([
"state" => "SUCCESS",
"url" => $res,
"title" => $res,
"original" => $_FILES['upfile']['name'],
"type" =>$_FILES['upfile']['type'],
"size" =>$_FILES['upfile']['size']
]);
} else {
$result = json_encode([
"state" => "上传失败"
]);
}
break;
case 'catchimage':
$result = json_encode([
"state" => "上传失败,不允许远程获取"
]);
break;
default:
$result = json_encode(array(
'state'=> '请求地址出错'
));
break;
}
echo $result;
}
private function saveRemote()
{
}
}
\ No newline at end of file
......@@ -10,6 +10,9 @@ class HelpController extends BaseController
public function infoAction()
{
$id = $this->request->get("id");
if(!$id) {
$id = $this->dispatcher->getParam("id");
}
if ($id) {
$info = Help::findFirst(['id='.$id]);
}
......
......@@ -6,19 +6,40 @@ class IdentController extends BaseController
{
$lists = Ident::lists();
$this->page($lists);
$this->view->setVar("can_create_new",$this->can_create_new());
}
public function editAction()
{
$id = isset($this->_get['id'])?$this->_get['id']:null;
if($id) {
$info = Ident::info(['id='.$id]);
}
if ($this->request->isGet()) {
if (isset($id)) {
$info = Ident::info(['id='.$id]);
if($info) {
$info->glory = json_decode($info->glory,true);
$info->device = json_decode($info->device,true);
$info->web_url = json_decode($info->web_url,true);
$info->org = json_decode($info->org,true);
}
$this->view->setVar("info",$info);
$city_info = Citys::findFirst(["id=".$info->city]);
$this->view->setVar("city",json_encode($city_info->toArray()));
} else {
if(!$this->can_create_new()) {
$this->LogicError(404,"您暂时不能创建新认证资料",1);
}
}
$this->getOpencity();
$userinfo = User::findFirst(['id='.UID]);
$this->view->setVar("user",$userinfo);
$this->getProvinceAction();
} else {
$model = new Ident();
if($info) {
$model = $info;
}else {
$model = new Ident();
}
if (isset($id)) {
if ($this->_post["id"] != $id) {
$this->error("参数错误!");
......@@ -27,13 +48,27 @@ class IdentController extends BaseController
$this->_post['uid'] = 1;
unset($this->_post['id']);
}
$this->_post['device'] = json_encode($this->_post['device']);
$this->_post['glory'] = json_encode($this->_post['glory']);
$this->_post['web_url'] = json_encode($this->_post['web_url']);
$this->_post['org'] = json_encode($this->_post['org']);
$status = $model->save($this->_post);
if ($status) {
$this->success("操作成功",$this->url->getStatic("ident"));
$this->success("操作成功",$this->url->getStatic("ident/success"));
} else {
$this->error($model->getError()[0]);
}
}
}
public function successAction()
{
}
protected function can_create_new()
{
$is_checked = Ident::count(['checked_status in (0,2)']);
return $is_checked <= 0;
}
}
\ No newline at end of file
......@@ -10,17 +10,26 @@ class SetsController extends BaseController
public function indexAction()
{
$where = filter_where($this->_get);
$lists = Sets::lists($where);
$this->page($lists);
try {
if ($this->request->get("start_time")) {
$where[]=sprintf("start_time between '%s' and '%s'",$this->_get['start_time'],$this->_get['end_time']);
}
$lists = Sets::lists($where);
$this->page($lists);
$this->dump($where);
} catch(Exception $e) {
$this->LogicError(404,$e->getMessage());
}
}
public function editAction()
{
//请求详情
$id = isset($this->_get["id"])?$this->_get["id"]:null;
if (isset($id)) {
$info = Sets::info(['id=' . $id]);
}
if ($this->request->isGet()) {
if (isset($id)) {
$info = Sets::info(['id='.$id]);
if($info) {
$_cates = json_encode([]);
$_kw = [];
......@@ -36,10 +45,17 @@ class SetsController extends BaseController
$this->view->setVar("category",json_encode($_cates));
$this->view->setVar("info",$info);
}
}
$this->getOpencity();
} else {
$model = new Sets();
if(isset($info)) {
if ($info->uid == UID) {
$model = $info;
} else {
$this->LogicError(401,"您的权限不足");
}
} else {
$model = new Sets();
}
$this->_post['uid'] = UID;
$validator = new \validation\SetsValidation();
$errors = $validator->validate($this->_post);
......@@ -79,6 +95,7 @@ class SetsController extends BaseController
$this->page($lists);
}
//todo 删除评论
public function delCommentAction()
{
$id = $this->request->get("id");
......
......@@ -4,10 +4,14 @@ class WorksController extends BaseController
{
public function indexAction()
{
$this->_row = 25;
$this->_row = 15;
$where = filter_where($this->_get);
$lists = Works::lists($where);
$this->page($lists);
try {
$lists = Works::lists($where);
$this->page($lists);
} catch(Exception $e) {
$this->LogicError(404,$e->getMessage());
}
}
//新建相册
......@@ -69,6 +73,10 @@ class WorksController extends BaseController
if($this->request->isDelete()){
$work_id = $this->request->get("workid");
$id = $this->request->get("id");
$count = WorksDetail::count(['is_del=0 AND works_id='.$work_id]);
if ($count<=5) {
$this->error("该相册已少于5张图片,不能删除");
}
$info = WorksDetail::findFirst(["id=".$id]);
if (!($info->works_id == $work_id)) {
$this->error();
......@@ -84,7 +92,6 @@ class WorksController extends BaseController
}
}
//TODO 更改封面
public function setCoverAction()
{
if($this->request->isGet()) {
......@@ -140,9 +147,14 @@ class WorksController extends BaseController
public function getWorkAction()
{
$id = $this->request->get("id");
$info = Works::findFirst(['id='.$id.' AND uid='.UID]);
$info = Works::findFirst(['id='.$id.' AND uid='.UID]);
if($info) {
$this->success($info->toArray());
$count = WorksDetail::count(['works_id='.$id]);
if($count <= 5) {
$this->error("相册:$info->name,图片少于5张,不可用");
} else {
$this->success($info->toArray());
}
} else {
$this->error("相册不存在");
}
......
<?php
function filter_where($where,$self = true) {
if (!empty($where)) {
if(isset($where['start_time'])){
unset($where['start_time']);
}
if(isset($where['end_time'])){
unset($where['end_time']);
}
foreach($where as $k => $v){
$_where[] = $k."='".$v."'";
if (is_array($v)) {
switch(strtolower($v[0])){
case "elt":
case "<=":
$_where[] = $k."<='".$v[1]."'";
break;
case "eq":
case "=":
$_where[] = $k."='".$v[1]."'";
break;
case "glt":
case ">=":
$_where[] = $k.">='".$v[1]."'";
break;
case "like":
$_where[] = $k." like ".$v[1];
break;
case "in":
$_where[] = $k." in('".is_array($v[1])?implode(",",$v[1]):$v[1]."')";
break;
}
} else {
if (isset($v)) {
$_where[] = $k . "='" . $v . "'";
}
}
}
$where = $_where;
}
$where[] = "is_del=0";
if ($self && defined("UID")) {
$where[] = "uid=".UID;
$where[] = "uid=".UID;
}
return $where;
}
......@@ -35,4 +66,122 @@ function getUser($id,$field = "nickname") {
$res[$id] =User::findFirst(['id='.$id]);
}
return $res[$id]->$field;
}
\ No newline at end of file
}
function getCityName ($id,$field = "city_name") {
static $res = [];
if(!isset($res[$id])) {
$res[$id] =Citys::findFirst(['id='.$id]);
}
return $res[$id]->$field;
}
function list_to_tree($list, $pk='id', $pid = 'pid', $child = 'child', $root = 0) {
// 创建Tree
$tree = array();
if(is_array($list)) {
// 创建基于主键的数组引用
$refer = array();
foreach ($list as $key => $data) {
$refer[$data[$pk]] =& $list[$key];
}
foreach ($list as $key => $data) {
// 判断是否存在parent
$parentId = $data[$pid];
if ($root == $parentId) {
$tree[] =& $list[$key];
}else{
if (isset($refer[$parentId])) {
$parent =& $refer[$parentId];
$parent[$child][] =& $list[$key];
}
}
}
}
return $tree;
}
//
function getChannelList($lists , $pid = 0,$depth = 0 ,$child = "child") {
$html = "";
$pre = "";
if(isset($lists)){
$len = count($lists);
foreach($lists as $index => $vo) {
$space = "";
$html.="<option value='" . $vo['id']."'" ;
if ($vo['id'] == $pid){
$html.=" selected=selected ";
}
$html.=">";
if ($depth > 0) {
if ($index == $len-1) {
$pre = "└";
}else{
$pre = "├";
}
for ($i=0;$i<$depth;$i++){
$space .= "&nbsp;&nbsp;";
}
}
$html.=$space.$pre.$vo["title"]."</option>";
if (!empty($vo[$child])) {
$tmp = $depth + 1;
$html .= getChannelList($vo[$child],$pid,$tmp,$child);
}
}
}
return $html;
}
function getCateList($lists , $pid = 0,$depth = 0 ,$child = "child") {
$html = "";
$pre = "";
if(isset($lists)){
$len = count($lists);
foreach($lists as $index => $vo) {
$space = "";
$html.="<option value='" . $vo['id']."'" ;
if ($vo['id'] == $pid){
$html.=" selected=selected ";
}
$html.=">";
if ($depth > 0) {
if ($index == $len-1) {
$pre = "└";
}else{
$pre = "├";
}
for ($i=0;$i<$depth;$i++){
$space .= "&nbsp;&nbsp;";
}
}
$html.=$space.$pre.$vo["category_name"]."</option>";
if (!empty($vo[$child])) {
$tmp = $depth + 1;
$html .= getChannelList($vo[$child],$pid,$tmp,$child);
}
}
}
return $html;
}
function getAuthGroups($ids) {
if($ids === false) {
return "";
}
$data = Groups::find(["id in(".$ids.")"]);
return implode(",",array_column($data->toArray(),"title"));
}
function getCache($expire = 172800)
{
$frontCache = new \Phalcon\Cache\Frontend\Data([
"lifetime" => $expire
]);
$config = new \Phalcon\Config\Adapter\Ini(APP_PATH.'./app/config/config.ini');
return new Phalcon\Cache\Backend\File($frontCache,[
"cacheDir" => $config->application->shareDir
]);
}
......@@ -4,11 +4,7 @@ use Phalcon\Mvc\Model\Validator\PresenceOf;
class Ident extends Base
{
public function initialize()
{
parent::initialize();
}
public function getSource()
{
......@@ -22,6 +18,8 @@ class Ident extends Base
return parent::save($data, $whiteList);
}
public function validation()
{
$this->validate(
......
......@@ -21,7 +21,7 @@ class Sets extends Base
$this->hasMany("id","SetsPromotion","sets_id");
$this->hasOne("id","SetsStatus","sets_id");
$this->hasMany("id","SetsComments","sets_id");
$this->skipAttributesOnUpdate(["create_time","star","star_count"]);
$this->skipAttributesOnUpdate(["create_time","star","star_count","collect_count"]);
$this->skipAttributes(['order_count']);
}
......@@ -35,7 +35,7 @@ class Sets extends Base
public function save($data = null, $whiteList = null)
{
$data['service_city_name'] = "cd";
$data['service_city_name'] = getCityName($data['service_city_id']);
$data['is_del'] = 0;
$data['star'] = 0;
$data['star_count'] = 0;
......@@ -47,7 +47,6 @@ class Sets extends Base
return false;
}
//附件
if (isset($data['attachment'])) {
foreach($data['attachment'] as $i => $v) {
......
File mode changed from 100644 to 100755
File mode changed from 100644 to 100755
File mode changed from 100644 to 100755
......@@ -109,17 +109,6 @@ class SetsValidation extends BaseValidation
public function validate($data = null, $entity = null)
{
//使用积分
if ($data["is_use_score"] == 1) {
$this->add("use_score",new PresenceOf([
'message' => '您还未填写积分抵扣上限'
]));
$this->add("use_score", new Numericality([
'message' => '积分是数字'
]));
}
if (isset($data["allow_self_take"])) {
$this->add("modeling_count_from_user",new PresenceOf([
'message' => '您还未填写允许用户自带数量'
......
File mode changed from 100644 to 100755
......@@ -2,7 +2,9 @@
{%block body%}
<div class="row">
<div class="col-md-1">
{%if can_create_new is true%}
<a href="<?=$this->url->getStatic('ident/edit')?>" class="btn btn-primary btn-block margin-bottom">新建</a>
{%endif%}
</div>
</div>
<div class="row">
......
{%extends "base/base.html"%}
{%block body%}
您的申请已提交,我们将在一个工作日内以手机短信和私信形式通知您审核结果
{%endblock%}
\ No newline at end of file
......@@ -34,15 +34,6 @@
</div>
</div>
</div>
<div class="form-group">
<label>允许积分折扣<span class="red">*</span></label>
<div class="clear"></div>
<div class="radio"><label><input type="radio" value="1" name="is_use_score"/></label></div>
<div class="radio"><label><input type="radio" value="0" name="is_use_score" checked/></label></div>
<div class="clear"></div>
最多使用<input type="text" data-type="number" name="use_score" value="{{info.use_score|default('0')}}" class="form-control"/>积分
</div>
<div class="form-inline">
<div class="form-group">
<label>人员配备<span class="red">*</span></label>
......@@ -448,12 +439,16 @@
<div class="form-group">
<label>促销价</label>
<input type="hidden" value="{{promotion.id|default('')}}" name="promotion[id]"/>
<input type="text" class="form-control" value="{{promotion.promotion_price|default('')}}" name="promotion[promotion_price]" placeholder="促销价格"/>
<input type="text"
{%if(info.is_promotion|default('0') == 1)%}disabled{%endif%}
class="form-control" value="{{promotion.promotion_price|default('')}}" name="promotion[promotion_price]" placeholder="促销价格"/>
</div>
<div class="clear"></div>
<div class="form-group">
<label>促销数量</label>
<input type="text" class="form-control" value="{{promotion.count|default('0')}}" name="promotion[count]" placeholder="促销数量"/>
<input type="text"
{%if(info.is_promotion|default('0') == 1)%}disabled{%endif%}
class="form-control" value="{{promotion.count|default('0')}}" name="promotion[count]" placeholder="促销数量"/>
</div>
<div class="clear"></div>
<div class="form-inline">
......@@ -462,7 +457,9 @@
<div class="clear"></div>
<div class="form-group">
<label class="sr-only"></label>
<input type="text" value="{{promotion.start_time|default('0000-00-00 00:00:00')}}" name="promotion[start_time]" class="form-control form_date" placeholder="促销开始时间"/>
<input type="text"
{%if(info.is_promotion|default('0') == 1)%}disabled{%endif%}
value="{{promotion.start_time|default('0000-00-00 00:00:00')}}" name="promotion[start_time]" class="form-control form_date" placeholder="促销开始时间"/>
</div>
<div class="form-group">
<label class="sr-only"></label>
......@@ -470,7 +467,9 @@
</div>
<div class="form-group">
<label class="sr-only"></label>
<input type="text" value="{{promotion.end_time|default('0000-00-00 00:00:00')}}" name="promotion[end_time]" class="form-control form_date" placeholder="促销结束时间"/>
<input type="text"
{%if(info.is_promotion|default('0') == 1)%}disabled{%endif%}
value="{{promotion.end_time|default('0000-00-00 00:00:00')}}" name="promotion[end_time]" class="form-control form_date" placeholder="促销结束时间"/>
</div>
</div>
</div>
......@@ -478,7 +477,9 @@
<div class="form-group">
<label>每名用户限制购买量</label>
<div class="input-group">
<input type="text" value="{{promotion.per_user_count|default('0')}}" name="promotion[per_user_count]" class="form-control"/>
<input type="text"
{%if(info.is_promotion|default('0') == 1)%}disabled{%endif%}
value="{{promotion.per_user_count|default('0')}}" name="promotion[per_user_count]" class="form-control"/>
<span class="input-group-addon"></span>
</div>
</div>
......
{%extends "base/base.html"%}
{%block body%}
<div class="row">
<div class="col-md-2">
<div class="col-md-1">
<a href="<?=$this->url->getStatic('sets/edit')?>" class="btn btn-primary btn-block margin-bottom">新建</a>
<div class="box box-solid">
<div class="box-header with-border">
<h3 class="box-title">Folders</h3>
<div class="box-tools">
<button type="button" class="btn btn-box-tool" data-widget="collapse"><i class="fa fa-minus"></i>
</button>
</div>
</div>
<div class="box-body no-padding">
<ul class="nav nav-pills nav-stacked">
<li class="active"><a href="#"><i class="fa fa-inbox"></i> Inbox
<span class="label label-primary pull-right">12</span></a></li>
<li><a href="#"><i class="fa fa-envelope-o"></i> Sent</a></li>
<li><a href="#"><i class="fa fa-file-text-o"></i> Drafts</a></li>
<li><a href="#"><i class="fa fa-filter"></i> Junk <span class="label label-warning pull-right">65</span></a>
</li>
<li><a href="#"><i class="fa fa-trash-o"></i> Trash</a></li>
</ul>
</div>
<!-- /.box-body -->
</div>
</div>
<div class="col-sm-10">
<div class="col-sm-11">
<form action="<?php echo __SELF__;?>" class="form-inline mixed-mode">
<label class="control-label"> 创建时间:</label>
<!-- <label class="control-label"> 创建时间:</label>
<div class="form-control">
<input type="text" name="register_start_time" value="2000-01-01 00:00" class="form_date no-border">
<input type="text" name="start_time" value="2000-01-01 00:00" class="form_date no-border">
<i class="ico-date"></i>
</div>
<label class="control-label"> 至:</label>
<div class="form-control" >
<input type="text" name="register_end_time" value="2037-12-31 00:00" class="form_date no-border">
<input type="text" name="end_time" value="2037-12-31 00:00" class="form_date no-border">
<i class="ico-date"></i>
</div>
</div>-->
<label class="control-label"> 关键词:</label>
<select name="filter" class="form-control">
<option value="nickname">名称</option>
<option value="title">名称</option>
</select>
<input type="text" name="keywords" value="" class="form-control input-small" placeholder="请输入关键词">
<button type="submit" class="btn btn-primary btn-sm btn-submit">搜索<i class="icon-search icon-on-right bigger-110"></i></button>
</form>
</div>
<div class="col-xs-10">
<div class="col-xs-12">
<div class="box">
<div class="box-header">
<h3 class="box-title">列表</h3>
......
......@@ -42,13 +42,14 @@
</div>
<div class="col-md-10">
<div class="grid-container">
{%for index,item in info.getWorksDetail(['is_del=0'])%}
{%set lists = info.getWorksDetail(['is_del=0'])%}
{%for index,item in lists%}
<div class="grid-item">
<div class="editbox">
<a href="<?=$this->url->get('works/setCover',['id'=>$item->id,'work_id'=>$info->id])?>" class="ajax-get">设为封面</a>
<a href="javascript:" class="delpic" data-id="{{item.id}}">删除</a>
</div>
<div class="box alerts">
<div class="box alerts" data-index="{{index}}">
<img src="{{item.works_url}}">
</div>
</div>
......@@ -66,6 +67,15 @@
{{javascript_include("./static/boot/plugins/webuploader/dist/webuploader.min.js")}}
{{javascript_include("./static/app/works.js")}}
<script type="text/javascript">
var lists = [];
{%for item in lists%}
var al = new Object();
al.alt = "";
al.src = "{{item.works_url}}";
al.thumb = "";
al.pid = "{{item.id}}";
lists.push(al);
{%endfor%}
$(function(){
var s = new Stackgrid();
var selector = $(".grid-container");
......@@ -74,26 +84,6 @@
s.config.columnWidth = e/num;
s.config.numberOfColumns = num;
s.initialize('.grid-container', '.grid-item');
layer.config({extend:"./extend/layer.ext.js"});
$(".alerts").click(function(){
var img = $(this).find("img");
var data = {
"title": "", //相册标题
"id": "", //相册id
"start": 0, //初始显示的图片序号,默认0
"data": [ //相册包含的图片,数组格式
{
"alt": "",
"pid": 0, //图片id
"src": $(img).attr("src"), //原图地址
"thumb": "" //缩略图地址
}
]
}
layer.photos({
photos: data //格式见API文档手册页
});
})
})
</script>
{%endblock%}
{%extends "base/base.html"%}
{%block body%}
<a class="btn btn-primary addNew" href="javascript:">新建相册</a>
<div class="flex-images">
{%for index,item in lists.items%}
<div class="item" data-w="200" data-h="150">
<div class="editbox">
<div style="text-align: left;width: 50%;float: left">{{item.name}}</div>
<div style="text-align: right;width: 50%;float: left">
<a href="javascript:" class="editWork" data-id="{{item.id}}">编辑</a>
<a href="javascript:" class="delWork" data-id="{{item.id}}">删除</a>
</div>
</div>
<a class="grid-item" href="<?=$this->url->getStatic('works/edit?id='.$item->id);?>">
<div class="box"><img src="{{item.cover}}"/></div>
</a>
<div class="col-sm-12">
<div class="col-md-1">
<a class="btn btn-primary addNew" href="javascript:">新建相册</a>
</div>
<div class="col-md-11">
<form action="<?php echo __SELF__;?>" class="form-inline mixed-mode">
<label class="control-label"> 关键词:</label>
<select name="filter" class="form-control">
<option value="name">名称</option>
</select>
<input type="text" name="keywords" value="" class="form-control input-small" placeholder="请输入关键词">
<button type="submit" class="btn btn-primary btn-sm btn-submit">搜索<i class="icon-search icon-on-right bigger-110"></i></button>
</form>
</div>
{%endfor%}
</div>
<div class="page">
{{_page}}
<div class="col-sm-12">
<div class="flex-images">
{%for index,item in lists.items%}
<div class="item" data-w="200" data-h="150">
<div class="editbox">
<div style="text-align: left;width: 50%;float: left">{{item.name}}</div>
<div style="text-align: right;width: 50%;float: left">
<a href="javascript:" class="editWork" data-id="{{item.id}}">编辑</a>
<a href="javascript:" class="delWork" data-id="{{item.id}}">删除</a>
</div>
</div>
<a class="grid-item" href="<?=$this->url->getStatic('works/edit?id='.$item->id);?>">
<div class="box"><img src="{{item.cover}}"/></div>
</a>
</div>
{%endfor%}
</div>
<div class="page">
{{_page}}
</div>
</div>
{%endblock%}
{%block style%}
......
......@@ -2,11 +2,7 @@
$varArr = explode(",",$value);
?>
<div id="upload_{{name}}"></div>
<?php if(isset($val)):?>
<input type="hidden" name="{{name}}" value="<?php echo $val;?>" class="icon {{name}}" />
<?php else:?>
<input type="hidden" name="{{name}}" value="" class="icon {{name}}" />
<?php endif;?>
<input type="hidden" name="{{name}}" value="{{val|default('')}}" class="icon {{name}}" />
<div class="upload-img-box">
<?php if(isset($varArr) && !empty($varArr)):?>
<?php foreach($varArr as $v):?>
......@@ -54,7 +50,7 @@
var src = '';
if(data.status){
src = data.info;
upload_img = "<div class='upload-pre-item'><img src=" + src +" title='点击显示大图' data-id="+data.id+"> <span class='btn-close btn-close-{{name}}' title='删除图片'></span></div>";
upload_img = "<div class='upload-pre-item'><img src=" + src +" title='点击显示大图' data-id="+src+"> <span class='btn-close btn-close-{{name}}' title='删除图片'></span></div>";
picsbox = $("#upload_{{name}}").siblings('.upload-img-box');
picsbox.append(upload_img)
picArr = [];
......@@ -62,7 +58,7 @@
picArr.push(picsbox.children('.upload-pre-item:eq('+i+')').find('img').attr('data-id'));
};
picStr = picArr.join(',');
$('.icon.{{name}}').val(src);
$('.icon.{{name}}').val(picStr);
} else {
layer.msg("上传失败");
}
......
......@@ -41,7 +41,7 @@
var target = $('#upload_{{name}}').siblings('.upload-img-box');
var img = $(target).find("img");
if (img.length == 0) {
var imgs = "<div class='upload-pre-item'><img src=" + src + " title='点击显示大图' data-id=" + data.id + "> <span class='btn-close btn-close-{{name}}' title='删除图片'></span></div>";
var imgs = "<div class='upload-pre-item'><img src=" + src + " title='点击显示大图' data-id=" + src + "> <span class='btn-close btn-close-{{name}}' title='删除图片'></span></div>";
target.append(imgs)
} else {
$(img).attr("src", src);
......
......@@ -3,12 +3,14 @@ if(get_extension_funcs("phalcon") === false) {
echo "This Program Needs Extension Phalcon(version > 2.0.9)!";
die();
}
error_reporting(E_ALL);
use Phalcon\Mvc\Application;
use Phalcon\Config\Adapter\Ini;
error_reporting(E_ALL);
define("PRODUCTION",false); // 是否产品模式,相对的,就是开发模式
try {
define('APP_PATH', realpath('.') . '/');
$config = new Ini(APP_PATH.'./app/config/config.ini');
check_config($config);
require_once (APP_PATH."./app/config/loader.php");
require_once (APP_PATH."./app/config/service.php");
require_once ("./app/functions/functions.php");
......@@ -18,3 +20,14 @@ try {
echo "PhalconException: ", $e->getMessage();
}
function check_config(&$config) {
if(!file_exists($config->application->temp_view)) {
@mkdir($config->application->temp_view,0777,true);
}
if(!file_exists($config->application->shareDir)) {
@mkdir($config->application->shareDir,0777,true);
}
if(!file_exists($config->application->access_log)) {
@mkdir($config->application->access_log,0777,true);
}
}
\ No newline at end of file
<?php
namespace lib;
use Phalcon\Mvc\Router;
class RouteApi
{
protected $cache;
protected $router;
public function __construct()
{
$this->cache = getCache(3600*24*3);
$this->router = new Router();
}
public function add($path,$data)
{
$this->router->add($path,$data);
$this->cache->save("Route",serialize($this->router));
}
public function getRoute()
{
$router = $this->cache->get("Route");
if ($router) {
$router = unserialize($router);
return $router;
} else {
return new Router();
}
}
}
\ No newline at end of file
......@@ -31,8 +31,6 @@
.clear {
float: none;
clear: both;
margin-top:5px;
margin-bottom: 5px;
}
.button-container {
......
'use strict'
$(function(){
$(".addGlories").click(function(){
var dom = $(".glories");
var html = '<div class="form-group">\
<input type="text" class="form-control" name="glory[]" value="">\
</div>\
<div class="form-group">\
<i class="fa fa-minus-square reduceGlory" aria-hidden="true"></i>\
</div> <div class="clear"></div>';
dom.append(html)
})
$(".addDevice").click(function(){
var dom = $(".devices");
var html = '<div class="form-group">\
<input type="text" class="form-control" name="device[]" value="">\
</div>\
<div class="form-group">\
<i class="fa fa-minus-square reduceDevice" aria-hidden="true"></i>\
</div> <div class="clear"></div>';
dom.append(html)
})
$(".addUrl").click(function(){
var dom = $(".urls");
var html = '<div class="form-group">\
<input type="text" class="form-control" name="web_url[]" value="">\
</div>\
<div class="form-group">\
<i class="fa fa-minus-square reduceDevice" aria-hidden="true"></i>\
</div> <div class="clear"></div>';
dom.append(html)
})
$(".addOrg").click(function(){
var dom = $(".orgs");
var html = '<div class="form-group">\
<input type="text" class="form-control" name="org[]" value="">\
</div>\
<div class="form-group">\
<i class="fa fa-minus-square reduceOrg" aria-hidden="true"></i>\
</div> <div class="clear"></div>';
dom.append(html)
})
$(".orgs").on("click",".reduceOrg",function(){
var $this = $(this);
layer.confirm("是否删除这个条目",["是的","算了"],function(){
$this.parent().prev().remove();
$this.parent().remove();
layer.closeAll();
},function(){
layer.closeAll();
})
})
$(".glories").on("click",".reduceGlory",function(){
var $this = $(this);
layer.confirm("是否删除这个条目",["是的","算了"],function(){
$this.parent().prev().remove();
$this.parent().remove();
layer.closeAll();
},function(){
layer.closeAll();
})
})
$(".devices").on("click",".reduceDevice",function(){
var $this = $(this);
layer.confirm("是否删除这个条目",["是的","算了"],function(){
$this.parent().prev().remove();
$this.parent().remove();
layer.closeAll();
},function(){
layer.closeAll();
})
})
$(".urls").on("click",".reduceUrl",function(){
var $this = $(this);
layer.confirm("是否删除这个条目",["是的","算了"],function(){
$this.parent().prev().remove();
$this.parent().remove();
layer.closeAll();
},function(){
layer.closeAll();
})
})
$("input[name=protocal]").click(function(){
if($(this).prop("checked")) {
$("button[type=submit]").prop('disabled',false);
} else {
$("button[type=submit]").prop('disabled',true);
}
})
})
\ No newline at end of file
......@@ -42,7 +42,6 @@ $(function(){
layer.msg(data.info);
}
});
}
return false;
});
......@@ -117,7 +116,11 @@ $(function(){
}
}, 1500);
} else {
layer.msg(data.info);
layer.alert(data.info, {
icon: 2,
skin: 'layer-ext-moon',
title:'错误'
})
setTimeout(function () {
$(that).removeClass('disabled').prop('disabled', false);
if (data.url) {
......@@ -160,11 +163,71 @@ $(function(){
$(this).parent().siblings("input[type=hidden]").val(val);
})
function setValue(selector,value) {
$(selector).val(value);
}
$(".province").change(function(){
var $this = $(this);
var pid = $this.val();
var dom = $(".city");
$.getJSON(HOST+"/Help/getCity?province_id="+pid,function(data){
if(data.status == 1) {
var list = data.info;
var html = "";
for(var i in list) {
html += "<option value='"+list[i].id+"'>"+list[i].city_name+"</option>"
}
dom.html(html);
}
})
})
})
var _PROTOCOL = window.location.protocol;
var _HOSTNAME = window.location.host;
var HOST = _PROTOCOL + "//" + _HOSTNAME;
\ No newline at end of file
var HOST = _PROTOCOL + "//" + _HOSTNAME;
(function(){
var URI = parseURL(window.location.href);
var u = URI.params;
if (u.start_time != undefined) {
setValue("input[name=start_time]",unescape(u.start_time));
}
if (u.end_time != undefined) {
setValue("input[name=end_time]", unescape(u.end_time));
}
if (u.filter != undefined) {
setValue("select[name=filter]",unescape(u.filter));
}
if (u.keywords != undefined) {
setValue("input[name=keywords]",unescape(u.keywords));
}
})();
function setValue(selector,value) {
$(selector).val(value);
}
function parseURL(url) {
var a = document.createElement('a');
a.href = url;
return {
source: url,
protocol: a.protocol.replace(':', ''),
host: a.hostname,
port: a.port,
query: a.search,
params: (function () {
var ret = {},
seg = a.search.replace(/^\?/, '').split('&'),
len = seg.length, i = 0, s;
for (; i < len; i++) {
if (!seg[i]) {
continue;
}
s = seg[i].split('=');
ret[s[0]] = s[1];
}
return ret;
})()
}
}
\ No newline at end of file
......@@ -53,7 +53,8 @@ $(function(){
var _p = 0;
$("#dddddd").click(function(){
layer.closeAll();
var ids = $(this).data("ids").toString();
var $this = $(this);
var ids = $this.attr("data-ids").toString();
var lists = ids.split(",");
var work_id;
for(var i in lists){
......@@ -77,7 +78,7 @@ $(function(){
<input type="hidden" name="works['+_p+'][works_id]" value="'+info.id+'"/>\
<input type="hidden" name="works['+_p+'][is_hidden]" value="0"/>\
<input type="hidden" class="is_del" name="works['+_p+'][is_del]" value="0"/>\
待上传</td><td>'+info.name+'</td>\
'+info.id+'</td><td>'+info.name+'</td>\
<td><div class="upload-pre-item"><img src="'+info.cover+'"/></div></td>\
<td>'+time+'</td>\
<td style="width:60px"><a href="javascript:void(0)" data-id="'+info.id+'" class="delWork">删除</a></td>\
......@@ -85,7 +86,11 @@ $(function(){
$("#gallery_list").find(".works_list").append(html);
exist_arr.push(work_id);
} else {
layer.msg(data.info);
layer.alert(data.info, {
icon: 2,
skin: 'layer-ext-moon',
title:'错误'
})
}
})
}
......
......@@ -90,7 +90,11 @@ $(function(){
window.location.reload();
} else {
layer.closeAll();
layer.msg("操作失败");
layer.alert(res.info, {
icon: 2,
skin: 'layer-ext-moon',
title:'错误'
})
}
}
});
......@@ -107,4 +111,17 @@ $(function(){
});
}
layer.config({extend:"./extend/layer.ext.js"});
$(".alerts").click(function(){
var img = $(this).find("img");
var data = {
"title": "", //相册标题
"id": "", //相册id
"start": $(this).data('index'), //初始显示的图片序号,默认0
"data": lists
}
layer.photos({
photos: data //格式见API文档手册页
});
})
})
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment