function smarty_block_form($params, $content = '', $template, &$repeat) { if ($repeat) { // Set the current form to the context Clips\clips_context('indent_level', 1, true); $name = Clips\get_default($params, 'name', Clips\default_form_name()); $data = Clips\context('form_' . $name); if ($data) { Clips\context('current_form_data', $data); } Clips\clips_context('current_form', $name); return; } $content .= "\t" . Clips\create_tag('input', array('type' => 'hidden', 'name' => Clips\Form::FORM_FIELD, 'value' => Clips\get_default($params, 'name', 'form'))); $action = Clips\get_default($params, 'action'); if ($action) { if (strpos($action, 'http') !== 0) { $params['action'] = Clips\site_url($action); } } if (Clips\get_default($params, 'upload')) { unset($params['upload']); $params['enctype'] = 'multipart/form-data'; } Clips\context_pop('current_form'); Clips\context_pop('current_form_data'); Clips\context_pop('indent_level'); return Clips\create_tag_with_content('form', $content, $params, array('action' => '#', 'method' => 'post', 'class' => ['clips-form', 'default-form'])); }
public function pages($total, $pagesize = 10, $page_no, $url) { $page_no = $page_no < 1 ? 1 : $page_no; $page = new \Pinet\BestPay\Core\Pages(); $pagestr = $page->multi($total, $pagesize, $page_no, \Clips\site_url($url), ''); return $pagestr; }
function smarty_function_cancel($params, $template) { Clips\require_widget_smarty_plugin('html', 'a'); $bundle_name = Clips\context('current_bundle'); $bundle = Clips\get_default($params, 'bundle', $bundle_name); $cancel = Clips\get_default($params, 'label', 'Cancel'); if ($bundle !== null) { $bundle = Clips\bundle($bundle); $cancel = $bundle->message($cancel); } $request = Clips\context('request'); $bs = $request->breadscrumb(); if (count($bs) > 1) { array_pop($bs); // Pop current $params['href'] = Clips\site_url(array_pop($bs)); $params['title'] = $cancel; $f = true; // Open the link smarty_block_a($params, '', $template, $f); $f = false; return smarty_block_a($params, $cancel, $template, $f); } return ''; }
function site_url($arr) { if ($arr) { return \Clips\site_url($arr[0]); } return false; }
/** * @Clips\Form({"search"}) * @Clips\Widget({"epg", "navigation", "image"}) * @Clips\Scss({"welcome/list"}) * @Clips\Js({"application/static/js/welcome/list.js"}) */ public function show($name = '', $filter = 'new', $filter_value = 'all') { if ($name) { $all_movies = $this->movie->queryMovies($this->getSerials('movie')); $this->request->session('all_movies', $all_movies); $this->request->session('sift_name', $name); $this->title('Pinet Home Page', true); $col = $this->column->getColumnByName($name); $this->updateQuery('column', $name); if ($filter == 'new' || $filter == 'hot') { $this->request->session('new_type', $filter); } switch ($filter) { case 'new': $query = $this->updateQuery('order', 'year desc'); break; case 'hot': $query = $this->updateQuery('order', 'year asc'); break; default: $query = $this->updateQuery($filter, $filter_value); } $serial = $this->movie->queryMovies($this->getSerials('serials')); $this->request->session('serial_movies', $serial); if ($col) { $movies = $this->movie->queryMovies($query); return $this->render('movie/list', array('sifts' => $this->column->getTypeNav($col->name), 'movies' => $movies, 'items' => $all_movies, 'tab' => array('navs' => array(array('url' => \Clips\site_url("/column/show/{$name}/new"), 'name' => '最新', 'active' => $this->request->session('new_type') == 'new' ? 'active' : ''), array('url' => \Clips\site_url("/column/show/{$name}/hot"), 'name' => '最热', 'active' => $this->request->session('new_type') == 'hot' ? 'active' : ''))), 'actions' => $this->column->getNav())); } } return $this->redirect(\Clips\site_url('')); }
/** * @Clips\Widget({"grid", "image", "bootstrap", "owlcarousel", "yizhifu"}) * @Clips\Form("merchant/show") * @Clips\Model({"user","merchant"}) */ public function show($id) { $this->title('Merchant Information', true); $merchant = $this->merchant->load($id); $this->formData("merchant/show", $merchant); $form_action = \Clips\site_url('merchant/index'); return $this->render('merchant/show', array('form_action' => $form_action)); }
function smarty_block_figure($params, $content = '', $template, &$repeat) { if ($repeat) { Clips\clips_context('indent_level', 1, true); return; } $src = Clips\get_default($params, 'src'); $path = Clips\get_default($params, 'path', 'responsive/size'); $resolutions = Clips\get_default($params, 'resolutions'); $img_path = Clips\find_image($src); if (!$img_path) { Clips\error('figure', array('Can\'t find image ' . $src . '!')); return ''; } $size = Clips\image_size($img_path); $size = $size['width']; if ($resolutions) { // If we are using auto resizing, skip the resolutions foreach ($resolutions as $res) { $attr['data-media' . $res] = Clips\site_url('responsive/size/' . (double) $res / 2880 * (double) $size . '/' . $src); } } else { $attr = array('path' => Clips\site_url($path)); } foreach ($params as $key => $value) { if ($key == 'path') { continue; } if (strpos($key, 'media') !== false) { $attr['data-' . $key] = Clips\site_url('responsive/size/' . $value . '/' . $src); } else { $attr[$key] = $value; } } $caption = Clips\create_tag_with_content('figcaption', $content); $image_dir = Clips\config('image_dir'); if ($image_dir) { $image_dir = $image_dir[0]; } else { $image_dir = 'application/static/img/'; } $img = Clips\create_tag('img', array('src' => Clips\static_url(Clips\path_join($image_dir, $src)))); $noscript = Clips\create_tag_with_content('noscript', $img); $level = Clips\context('indent_level'); if ($level === null) { $level = 0; } else { $level = count($level); } $indent = ''; for ($i = 0; $i < $level; $i++) { $indent .= "\t"; } Clips\context_pop('indent_level'); return Clips\create_tag_with_content('figure', $noscript . "\n{$indent}" . $caption, $attr); }
public function getFrontPageColumns() { $cols = $this->getAllColumns(); $result = array(); foreach ($cols as $col) { $col->url = \Clips\site_url('/column/show/' . $col->name); $col->videos = $this->getMovies($col->name); $result[] = $col; } return $result; }
function smarty_block_a($params, $content = '', $template, &$repeat) { if ($repeat) { Clips\clips_context('indent_level', 1, true); return; } $uri = Clips\get_default($params, 'uri'); if ($uri) { unset($params['uri']); $params['href'] = Clips\site_url($uri); } Clips\context_pop('indent_level'); return Clips\create_tag_with_content('a', $content, $params); }
public function init() { $this->tool->widget('ListView'); if (isset($this->value)) { if (!is_array($this->value)) { $this->value = array($this->value); } } else { $this->value = array(\Clips\default_form_name()); } // Initialize the ListView in javacript foreach ($this->getConfig() as $name => $config) { if ($config) { // Setting the default values for the datatable configuration if (!isset($config->ajax)) { $controller_class = \Clips\context('controller_seg'); $method = \Clips\context('controller_method'); $uri = \Clips\context('uri'); if (strpos($uri, $method) !== false) { $d = explode($method, $uri); $config->ajax = \Clips\site_url(\Clips\path_join($d[0], $name)); } else { if (strpos($uri, $controller_class) !== false) { $config->ajax = \Clips\site_url(\Clips\path_join($uri, $name)); } else { $config->ajax = \Clips\site_url(\Clips\path_join($uri, $controller_class, $name)); } } } $config->processing = true; $config->serverSide = true; foreach ($config->columns as $col) { if (isset($col->data)) { // Must smooth the data $col->data = \Clips\smooth($col->data); } if (isset($col->refer)) { $col->refer = \Clips\smooth($col->refer); } if (isset($col->action)) { // If has action, use action render $col->render = 'datatable_action_column'; } } // Adding the initialize script to jquery init \Clips\context('jquery_init', '$("ul[name=' . \Clips\to_flat($name) . ']").listview(' . json_encode($config) . ')', true); } } }
/** * @Clips\Form("login") */ public function index_form() { $username = $this->post()['username']; $password = $this->post()['password']; if ($this->user->get(array('username' => $username, 'password' => $password))) { $permissions = $this->user->getPermissionsByUid($this->user->get(array('username' => $username, 'password' => $password))[0]->id); } else { echo '用户名或者密码错误,请重新输入'; return $this->render('admin/login'); } $this->request->session('username', $username); $this->request->session('global_permissions', $permissions); $this->title('Login Page', true); return $this->redirect(\Clips\site_url('admin/home/index')); }
/** * @Clips\Model({"user"}) */ public function submit_checkcode() { $checkCode = $this->post('code'); $username = $this->post('username'); $password = $this->post('password'); $user = $this->user->getUser(array('username' => $username, 'password' => $password)); $usernameSql = $user->username; $passwordSql = $user->password; $checkCodeSessicon = $this->request->session('checkCode'); if (strtolower($checkCode) != strtolower($checkCodeSessicon) || $username != $usernameSql || $password != $passwordSql) { echo '<script>location.href="index";</script>'; } else { $url = \Clips\site_url('home/index'); echo '<script>location.href="' . $url . '";</script>'; } }
public function init() { $this->tool->widget('DataTable'); if (isset($this->value)) { if (!is_array($this->value)) { $this->value = array($this->value); } } else { $this->value = array(\Clips\default_form_name()); } // Initialize the datatable in javacript foreach ($this->getConfig() as $name => $config) { if ($config) { // Enforce security by default for DataTable $config->security = $this->securityengine; $config->name = $name; // Setting the default values for the datatable configuration if (!isset($config->ajax)) { $controller_class = \Clips\context('controller_seg'); $method = \Clips\context('controller_method'); $uri = \Clips\context('uri'); if (strpos($uri, $method) !== false) { $d = explode($method, $uri); $config->ajax = \Clips\site_url(\Clips\path_join($d[0], $name)); } else { if (strpos($uri, $controller_class) !== false) { $config->ajax = \Clips\site_url(\Clips\path_join($uri, $name)); } else { $config->ajax = \Clips\site_url(\Clips\path_join($uri, $controller_class, $name)); } } } $config->processing = true; $config->serverSide = true; // The bundle configuration in anntation has the highest priority $bundle = \Clips\get_default($this, 'bundle', null); if ($bundle === null) { // Try configuration's bundle settings $bundle = \Clips\get_default($config, 'bundle', null); if ($bundle === null) { // We can't find the bundle in annotation, try to find it using default name $bundle_name = 'pagination/' . $name; $bundle = $this->tool->bundle($bundle_name); if ($bundle->isEmpty()) { // All default bundle can't be found, try current controller's bundle $bundle = \Clips\context('current_bundle'); if ($bundle === null) { $bundle = ''; } } } } $bundle = \Clips\bundle($bundle); // Update the columns configuration to the filtered columns configuration $config->columns = $config->columns(); $replaces = array(); foreach ($config->columns as $col) { if (isset($col->title)) { $col->title = $bundle->message($col->title); } if (isset($col->data)) { // Must smooth the data if (strpos($col->data, " as ")) { $d = explode(' as ', $col->data); if ($d) { $col->data = trim($d[1]); } } $col->data = \Clips\smooth($col->data); } if (isset($col->refer)) { $col->refer = \Clips\smooth($col->refer); } if (isset($col->render)) { if (array_search($col->render, $replaces) === false) { $replaces[] = $col->render; } } if (isset($col->action)) { // If has action, use action render $col->render = 'datatable_action_column'; if (array_search($col->render, $replaces) === false) { $replaces[] = $col->render; } } } // Clean the where data stored in the session $controller = \Clips\context('controller'); if ($controller) { $controller->request->session($name, null); } $json = $config->toJson(); foreach ($replaces as $r) { $json = str_replace('"' . $r . '"', $r, $json); } // Adding the initialize script to jquery init \Clips\context('jquery_init', 'if(window[\'DatatableSettings\'] == undefined ) { DatatableSettings = {}; } DatatableSettings["' . $name . '"] = ' . $json . ';$("table[name=' . \Clips\to_flat($name) . ']").DataTable(DatatableSettings["' . $name . '"]);', true); } } }
/** * @Clips\Model({"order"}) * @Clips\Widget({"selectboxit","grid", "image", "bootstrap", "yizhifu"}) * @Clips\Widgets\ListView("user_orders") * @Clips\Scss("user/orders") */ public function payback() { $order_id = $this->order->updateOrderByBack(); return $this->redirect(\Clips\site_url('order/success')); }
public function delete($uid) { if ($this->permission()) { if ($uid) { $this->userrole->deleteFields($uid); $this->user->delete($uid); return $this->redirect(\Clips\site_url('admin/user/index')); } } else { return $this->render('admin/error'); } }
/** * @Clips\Model({"user","cart"}); */ public function logout() { $this->request->session()->destroy(); return $this->redirect('http://user.pinet.co/api/logout?appid=4000&template=user&callback=' . \Clips\site_url('home/index', true)); }
function smarty_block_action($params, $content = '', $template, &$repeat) { if ($repeat) { Clips\clips_context('indent_level', 1, true); return; } $default = array('class' => 'action'); $action = Clips\get_default($params, 'action'); if ($action && Clips\valid_obj($action, 'Clips\\Interfaces\\Action')) { $ps = $action->params(); $icon = $action->icon(); $caption = array(); if ($icon) { $caption[] = Clips\create_tag_with_content('i', '', array('class' => $icon)); $caption[] = Clips\create_tag_with_content('span', $action->label()); if ($action->children()) { $caption[] = Clips\create_tag_with_content('i', '', array('class' => array('fa', 'fa-angle-left', 'pull-right'))); } $caption = implode('', $caption); } else { $caption = $action->label(); } if (!isset($params['title'])) { // Add tooltip $params['title'] = $action->label(); } // This is valid action object switch ($action->type()) { case Action::CLIENT: $params['caption'] = $caption; if ($ps) { foreach ($ps as $k => $v) { $params['data-' . $k] = $v; } } $content = $action->content(); break; case Action::HEADER: return $caption; case Action::SERVER: $content = $caption; if ($ps) { $suffix = implode('/', array_map(function ($item) { return urlencode($item); }, $ps)); $params['uri'] = \Clips\path_join($action->content(), $suffix); } else { $params['uri'] = $action->content(); } break; case Action::EXTERNAL: $content = $caption; $suffix = array(); foreach ($ps as $k => $v) { $suffix[] = urlencode($k) . '=' . urlencode($v); } if ($suffix) { $suffix = implode('&', $suffix); $params['href'] = $action->content() . '?' . $suffix; } else { $params['href'] = $action->content(); } break; } unset($params['action']); } $value = Clips\get_default($params, 'caption'); if ($value) { // We did have value, so the content is the JavaScript $id = Clips\get_default($params, 'id', 'clips_action_' . Clips\sequence('action')); $js = "\$(\"#{$id}\").click(function(){\n\t\t" . trim($content) . "\n\t});"; $content = $template->fetch('string:' . $value); unset($params['caption']); $params['id'] = $id; $params['href'] = 'javascript:void(0)'; Clips\context('jquery_init', $js, true); } else { // Check for action uri $uri = Clips\get_default($params, 'uri'); if ($uri) { $params['href'] = Clips\site_url($uri); unset($params['uri']); } if (!isset($params['title'])) { // Add tooltip $params['title'] = trim($content); } } Clips\context_pop('indent_level'); $bundle_name = Clips\context('current_bundle'); $bundle = Clips\get_default($params, 'bundle', $bundle_name); if ($bundle !== null) { $bundle = Clips\bundle($bundle); $content = $bundle->message($content); } return Clips\create_tag_with_content('a', $content, $params, $default); }
public function doInit() { \Clips\context('jquery_init', "\n\t//====================================\n\t// Initializing Clips Rules\n\t//====================================\n\tClips.rules = new Clips.RuleEngine('" . \Clips\site_url('clips/commands') . "');\n", true); }
public function testSiteUri() { echo Clips\site_url('adsf'); }
/** * @Clips\Form("admin/user_modify_merchant") * @Clips\Model({"userInfo","user","merchant"}) * @Clips\Form('admin/user_add_merchant') * @Clips\Scss("admin/home") * @Clips\Widget({"grid", "image", "bootstrap", "owlcarousel", "yizhifu"}) */ public function modify_merchant_form() { $this->userinfo->updateInfo($this->request->post(), \Clips\password($this->request->post('password'))); return $this->redirect(\Clips\site_url('admin/user/merchant')); }
/** * @Clips\Model({"orderItem","order","customerProduct","merchant"}) * @Clips\Form("admin/merchant/order_distribute") * @Clips\Scss("admin/merchant/order_distribute") * @Clips\Widget({"grid", "image", "bootstrap", "owlcarousel", "yizhifu"}) * @Clips\Js("application/static/js/admin/merchant/distribute.js") */ public function order_distribute($order_id) { $top_menus = array('订单编号', '下单时间', '支付方式', '付款时间', '订单状态'); $menus = array('商品名称', '商品图片', '单价', '数量', '优惠信息', '小计', '有效期'); $orders = $this->order->load($order_id); $orderItems = $this->orderitem->getOrderItemsByOid($order_id, $type = 'product'); $totalPrice = 0; for ($i = 0; $i < count($orderItems); $i++) { $ss[] = explode(",", $orderItems[$i]->path); } for ($i = 0; $i < count($orderItems); $i++) { $orderItems[$i]->path = $ss[$i]; } for ($i = 0; $i < count($orderItems); $i++) { $totalprice = $orderItems[$i]->amount * $orderItems[$i]->price; $orderItems[$i]->totalprice = $totalprice; $totalPrice += $totalprice; } $merchants = $this->merchant->getMerchants(); for ($i = 0; $i < count($merchants); $i++) { $children_merchants[$i] = $merchants[$i]->name; } $args = array_merge(array('=请选择要分配的商家='), $children_merchants); $this->formData("admin/merchant/order_distribute", $orderItems); $p[] = new \Clips\Libraries\CommonOperator('orders.status', 'DELETE', '!='); $form_action = \Clips\site_url('admin/merchant/deliver_goods'); return $this->render('admin/merchant/order_distribute', array('order_details' => $orderItems, 'menus' => $menus, 'top_menus' => $top_menus, 'orders' => $orders, 'totalPrice' => $totalPrice, 'form_action' => $form_action, 'children_merchants' => $args, 'type' => 'bestpay_coupon')); }
public function get_checkcode() { $checkCode = \Clips\site_url('login/getCheckCode'); echo $checkCode; exit; }
public function show_ajax() { //curl return $this->redirect('http://user.pinet.co/api/login?appid=-1&validation_code=111111&mobile=13656227964&template=user&callback=' . \Clips\site_url('user/register', true)); }
public function delete($id = null) { if ($id) { $this->group->delete($id); } else { $this->group->delete($this->post('ids')); } return $this->redirect(\Clips\site_url('group/index')); }
function smarty_function_picture($params, $template) { $src = Clips\get_default($params, 'src'); if ($src) { if (preg_match('/_\\([A-Za-z0-9_]+\\)/', $src)) { $is_template = true; } } if (!isset($is_template)) { $path = Clips\get_default($params, 'path', 'responsive/size'); $resolutions = Clips\get_default($params, 'resolutions'); $medias = Clips\get_default($params, 'medias'); $img_path = Clips\find_image($src); if (!$img_path) { Clips\error('picture', array('Can\'t find image ' . $src . '!')); return ''; } $size = Clips\image_size($img_path); $size = $size['width']; $content = array(); $level = Clips\context('indent_level'); if ($level === null) { $level = 0; } else { $level = count($level); } $indent = ''; for ($i = 0; $i < $level; $i++) { $indent .= "\t"; } if ($resolutions || $medias) { if ($resolutions) { // If we are using auto resizing, skip the resolutions unset($params['resolutions']); foreach ($resolutions as $res) { $content[] = "\t" . Clips\create_tag('source', array('src' => Clips\site_url('responsive/size/' . (double) $res / 2880 * (double) $size . '/' . $src), 'media' => '(min-width:' . $res . 'px)')); } } if ($medias) { unset($params['medias']); foreach ($medias as $media => $res) { $content[] = "\t" . Clips\create_tag('source', array('src' => Clips\site_url('responsive/size/' . $res . '/' . $src), 'media' => '(min-width:' . $media . 'px)')); } } } else { $params['path'] = Clips\site_url($path); } $image_dir = Clips\config('image_dir'); if ($image_dir) { $image_dir = $image_dir[0]; } else { $image_dir = 'application/static/img/'; } Clips\clips_context('indent_level', 1, true); $img = Clips\create_tag('img', array('src' => Clips\static_url(Clips\path_join($image_dir, $src)))); $content[] = "\t" . Clips\create_tag_with_content('noscript', $img); Clips\context_pop('indent_level'); } else { $params['data-role'] = 'item-picture'; $params['path'] = Clips\site_url(Clips\get_default($params, 'path', 'responsive/size')); $indent = ''; $content = array(); } return Clips\create_tag_with_content('picture', implode("\n{$indent}", $content), $params); }
/** * @Clips\Model({"partner"}) * @Clips\Actions("admin/partner") */ public function delete($id = null) { if ($this->permission()) { if ($id) { $this->partner->delete($id); } else { $this->partner->delete($this->post('ids')); } return $this->redirect(\Clips\site_url('admin/partner/index')); } else { return $this->render('admin/error'); } }
/** * @Clips\Model({"user","customer","cart","product","merchant"}) * @Clips\Form("cart/buy") */ public function buy_form() { $product = $this->product->load('501'); $merchant = $this->merchant->getMerchant($product->merchant_id); $product->description = $merchant->description; $this->formData('cart/buy', $product); return $this->redirect(\Clips\site_url('cart/index')); }