예제 #1
0
 public function get_data_for_main_page()
 {
     $db = new Db();
     $components = $db->getAll("SELECT `title`,`name` FROM ##extensions WHERE `type`='component' AND `enabled`=1");
     $modules = $db->getAll('SELECT `name`,`id` FROM ##modules WHERE `published`=1');
     echo Json::encode([$components, $modules]);
 }
예제 #2
0
 /**
  * Lists all Barangalias models.
  * @return mixed
  */
 public function actionProduct()
 {
     $out = [];
     if (isset($_POST['depdrop_parents'])) {
         $parents = $_POST['depdrop_parents'];
         if ($parents != null) {
             $id = $parents[0];
             $model = Barang::find()->asArray()->where(['PARENT' => $id])->andwhere('STATUS <> 3')->all();
             // print_r($model);
             // die();
             //$out = self::getSubCatList($cat_id);
             // the getSubCatList function will query the database based on the
             // cat_id and return an array like below:
             // [
             //    ['id'=>'<sub-cat-id-1>', 'name'=>'<sub-cat-name1>'],
             //    ['id'=>'<sub-cat_id_2>', 'name'=>'<sub-cat-name2>']
             // ]
             foreach ($model as $key => $value) {
                 $out[] = ['id' => $value['KD_BARANG'], 'name' => $value['NM_BARANG']];
             }
             echo json_encode(['output' => $out, 'selected' => '']);
             return;
         }
     }
     echo Json::encode(['output' => '', 'selected' => '']);
 }
예제 #3
0
 public function get()
 {
     $fields = explode(',', Request::get('fields', true, Validator::STRICT_STRING_COMMAS));
     $filter = Request::get('filter', false, null);
     if ($filter !== null) {
         $filter = Json::decode($filter);
         if (!$filter) {
             throw new ValidatorException('Некорректный параметр filter');
         }
         foreach ($filter as $key => $value) {
             Validator::strictString($key, 'Некорректный ключ для фильтра');
             if (!in_array($key, $this->fields)) {
                 throw new ValidatorException('Поля для фильтра с именем "' . $key . '" не существует');
             }
         }
     } else {
         $filter = [];
     }
     foreach ($fields as $field) {
         if (!in_array($field, $this->fields)) {
             throw new ValidatorException('Поля с именем "' . $field . '" не существует в таблице базы данных');
         }
         if (isset($this->fieldOptions[$field])) {
             if (strripos($this->fieldOptions[$field][0], 'r') === false) {
                 throw new ValidatorException('Поле "' . $field . '" недоступно для чтения');
             }
         }
     }
     echo Json::encode($this->_get($fields, $filter));
 }
예제 #4
0
 function render()
 {
     if (!$this->name) {
         throw new \Exception('must set a name');
     }
     if (!$this->xhr_url) {
         throw new \Exception('must set xhr url');
     }
     if (!$this->js_format_result || !$this->result_fields) {
         throw new \Exception('need js code');
     }
     $header = XhtmlHeader::getInstance();
     $header->includeCss('core_dev/js/ext/yui/2.9.0/build/fonts/fonts-min.css');
     $header->includeCss('core_dev/js/ext/yui/2.9.0/build/autocomplete/assets/skins/sam/autocomplete.css');
     $header->includeCss('core_dev/js/ext/yui/2.9.0/build/button/assets/skins/sam/button.css');
     $header->includeJs('core_dev/js/ext/yui/2.9.0/build/yahoo-dom-event/yahoo-dom-event.js');
     $header->includeJs('core_dev/js/ext/yui/2.9.0/build/get/get-min.js');
     $header->includeJs('core_dev/js/ext/yui/2.9.0/build/animation/animation-min.js');
     $header->includeJs('core_dev/js/ext/yui/2.9.0/build/datasource/datasource-min.js');
     $header->includeJs('core_dev/js/ext/yui/2.9.0/build/autocomplete/autocomplete-min.js');
     $header->includeJs('core_dev/js/ext/yui/2.9.0/build/element/element-min.js');
     $header->includeJs('core_dev/js/ext/yui/2.9.0/build/button/button-min.js');
     $div_holder = 'yui_ac' . mt_rand();
     $container_holder = 'ac_contain_' . mt_rand();
     $button_id = 'ac_toggle_' . mt_rand();
     $input_id = 'ac_input_' . mt_rand();
     $header->embedJs('function highlight(s,h)' . '{' . 'var regex = new RegExp("("+h+")","ig");' . 'return s.replace(regex, "<span class=\\"highlighted\\">$1</span>");' . '}');
     $header->embedCss('label {' . 'color:#E76300;' . 'font-weight:bold;' . '}' . '#' . $div_holder . ' {' . 'width:20em;' . '}' . '.yui-ac .result {position:relative;height:20px;}' . '.yui-ac .name {position:absolute;bottom:0;}' . '.highlighted {color:#CA485E;font-weight:bold; }' . '.yui-ac .yui-button {vertical-align:middle;}' . '.yui-ac .yui-button button {background: url(http://developer.yahoo.com/yui/examples/autocomplete/assets/img/ac-arrow-rt.png) center center no-repeat}' . '.yui-ac .open .yui-button button {background: url(http://developer.yahoo.com/yui/examples/autocomplete/assets/img/ac-arrow-dn.png) center center no-repeat}' . '.yui-skin-sam .yui-ac-input {position:static; vertical-align:middle;}' . '.yui-skin-sam .yui-ac-content {' . 'max-height:250px;overflow:auto;overflow-x:hidden;' . '}');
     $res = 'YAHOO.example.CustomFormatting = (function(){' . 'var oDS = new YAHOO.util.ScriptNodeDataSource("' . $this->xhr_url . '");' . 'oDS.responseSchema = {' . 'resultsList:"records",' . 'fields:' . Json::encode($this->result_fields, false) . '};' . 'var oAC = new YAHOO.widget.AutoComplete("' . $input_id . '","' . $container_holder . '", oDS);' . 'oAC.minQueryLength = 0;' . 'oAC.queryDelay = ' . $this->query_delay . ';' . 'oAC.animSpeed = 0.01;' . 'oAC.maxResultsDisplayed = 100;' . 'oAC.forceSelection = true;' . 'oAC.generateRequest = function(sQuery) {' . 'return sQuery + "&format=json";' . '};' . 'oAC.resultTypeList = false;' . 'oAC.formatResult = function(oResultData, sQuery, sResultMatch) {' . $this->js_format_result . '};' . 'oAC.itemSelectEvent.subscribe(function(sType, aArgs) {' . 'var oData = aArgs[2];' . 'var input = document.createElement("input");' . 'input.setAttribute("type", "hidden");' . 'input.setAttribute("name", "' . $this->name . '");' . 'input.setAttribute("value", oData.id);' . 'document.getElementById("' . $div_holder . '").appendChild(input);' . '});' . 'var validateForm = function() {' . 'return true;' . '};' . 'return {' . 'oDS: oDS,' . 'oAC: oAC,' . 'validateForm: validateForm' . '}' . '})();';
     $in = new XhtmlComponentInput();
     $in->name = $input_id;
     $in->width = 200;
     // XXXX HACK, should not set width at all.. but we do it now so button dont end up on the next line
     return '<div id="' . $div_holder . '">' . $in->render() . '<div id="' . $container_holder . '"></div>' . '</div>' . js_embed($res);
 }
예제 #5
0
파일: Login.php 프로젝트: joksnet/php-old
 public function __construct()
 {
     global $config;
     $username = strip_tags(addslashes(trim($_POST['username'])));
     $password = md5(trim($_POST['password']));
     $viewonly = $_POST['view'] == 1;
     $sql = "SELECT user_id, hours\r\n                FROM users\r\n                WHERE username = '******'\r\n                AND password = '******'";
     if ($data = Db::query($sql)) {
         $user_id = $data['user_id'];
         $hours = $data['hours'];
         if ($config['expires']) {
             $expires = $config['expires'];
         } else {
             $expires = intval($hours) * 3600;
         }
         # if ( headers_sent($file, $line) )
         #     die( "Headers Sent on $file:$line" );
         $modules = $this->getModules($user_id);
         $data = array('username' => $username, 'viewOnly' => $viewonly, 'hours' => $hours, 'modules' => $modules);
         Cookies::set('sid', md5($user_id), $expires);
         Cookies::set('uid', $user_id, $expires);
         Cookies::set('data', Json::encode($data), $expires);
     }
     header('Location: /');
 }
예제 #6
0
파일: manual.php 프로젝트: svetel/FBApp
 public function shipping()
 {
     $json = array();
     $this->load->library('user');
     if ($this->user->isLogged()) {
         $this->language->load('checkout/checkout');
         $this->tax->setZone($shipping_address['country_id'], $shipping_address['zone_id']);
         if (!isset($this->session->data['shipping_methods'])) {
             $quote_data = array();
             $this->load->model('setting/extension');
             $results = $this->model_setting_extension->getExtensions('shipping');
             foreach ($results as $result) {
                 if ($this->config->get($result['code'] . '_status')) {
                     $this->load->model('shipping/' . $result['code']);
                     $quote = $this->{'model_shipping_' . $result['code']}->getQuote($shipping_address);
                     if ($quote) {
                         $quote_data[$result['code']] = array('title' => $quote['title'], 'quote' => $quote['quote'], 'sort_order' => $quote['sort_order'], 'error' => $quote['error']);
                     }
                 }
             }
             $sort_order = array();
             foreach ($quote_data as $key => $value) {
                 $sort_order[$key] = $value['sort_order'];
             }
             array_multisort($sort_order, SORT_ASC, $quote_data);
             $this->session->data['shipping_methods'] = $quote_data;
         }
     }
     $this->load->library('json');
     $this->response->setOutput(Json::encode($json));
 }
예제 #7
0
 public function __construct()
 {
     parent::__construct();
     $this->tags = array();
     $tags = PagesModel::getPageById(27)->getMeta('tag_options');
     foreach (explode("\n", $tags) as $t) {
         $t = trim($t);
         $this->tags[$t] = $t;
     }
     $this->projects = PagesModel::getPagesByMeta("project_tag")->getPairs('');
     $this->addText('username', 'OSM.org username')->setDisabled();
     $this->addText('fullname', 'Celé jméno')->setOption('description', 'Ať se poznáme!')->addRule(Form::FILLED, '%label není vyplněn.')->addRule(Form::MIN_LENGTH, '%label musí mít alespoň 5 znaků.', 5);
     $this->addText('email', 'Talk-cz')->setOption('description', 'Email použivaný pro spočítání příspěvků v talk-cz (neveřejný)')->addRule(Form::FILLED, '%label není vyplněn.')->addRule(Form::EMAIL, '%label není validní.');
     $this->addText('contact', 'Veřejný e-mail')->setOption('description', '(nepovinné)')->addCondition(Form::FILLED)->addRule(Form::EMAIL, '%label není validní.');
     $this->addText('twitter', 'Twitter')->setOption('description', '(nepovinné) Uživatelské jméno bez zavináče');
     $this->addText('github', 'Github')->setOption('description', '(nepovinné) Uživatelské jméno');
     $this->addText('places', 'Výskyt')->setOption('description', '(nepovinné) Kde se vyskystuju - typicky jaká města.');
     $this['places']->getControlPrototype()->placeholder = 'oddělené čárkou';
     $this['places']->getControlPrototype()->style = 'width: 40%';
     $this->addText('tags', 'Oblasti zájmu')->setOption('description', '(nepovinné)');
     $this['tags']->getControlPrototype()->placeholder = 'oddělené čárkou';
     $this['tags']->getControlPrototype()->style = 'width: 60%';
     $this['tags']->getControlPrototype()->{'data-options'} = Json::encode(array_values($this->tags));
     $this->addMultiSelect('projects', 'Projekty', $this->projects)->setOption('description', '(nepovinné) Projektovou stránku možno přidat v administraci. Případně napiš na dev@openstreetmap.cz')->getControlPrototype()->style = 'height:150px;width:40%';
     $this->addCheckbox('public', 'Zveřejnit údaje na openstreetmap.cz');
     $this->addSubmit('submit', 'Uložit údaje');
     $this->onSuccess[] = callback($this, 'submitted');
     $renderer = $this->getRenderer();
     $renderer->wrappers['controls']['container'] = 'table class="table form-inline"';
     $renderer->wrappers['error']['container'] = 'ul class="bg-danger"';
     $renderer->wrappers['control']['.text'] = 'form-control';
     $renderer->wrappers['control']['.email'] = 'form-control';
     $renderer->wrappers['control']['.submit'] = 'btn btn-primary';
 }
예제 #8
0
파일: Jsonp.php 프로젝트: joselfonseca/api
 /**
  * Encode the content to its JSON representation.
  *
  * @param string $content
  *
  * @return string
  */
 protected function encode($content)
 {
     if ($this->hasValidCallback()) {
         return sprintf('%s(%s);', $this->getCallback(), json_encode($content));
     }
     return parent::encode($content);
 }
예제 #9
0
파일: Json.php 프로젝트: sayi21cn/kyphp2.0
 public static function encode($data)
 {
     if (function_exists('json_encode')) {
         return json_encode($data);
     } else {
         switch (gettype($data)) {
             case 'boolean':
                 return $data ? 'true' : 'false';
             case 'integer':
             case 'double':
                 return $data;
             case 'resource':
             case 'string':
                 return '"' . str_replace(array("\r", "\n", "<", ">", "&"), array('\\r', '\\n', '\\x3c', '\\x3e', '\\x26'), addslashes($data)) . '"';
             case 'array':
                 if (empty($data) || array_keys($data) === range(0, sizeof($data) - 1)) {
                     $output = array();
                     foreach ($data as $value) {
                         $output[] = Json::encode($value);
                     }
                     return '[ ' . implode(', ', $output) . ' ]';
                 }
             case 'object':
                 $output = array();
                 foreach ($data as $key => $value) {
                     $output[] = Json::encode(strval($key)) . ': ' . Json::encode($value);
                 }
                 return '{ ' . implode(', ', $output) . ' }';
             default:
                 return 'null';
         }
     }
 }
예제 #10
0
 public function calculate()
 {
     $this->language->load('total/reward');
     $json = array();
     if (isset($this->request->post['reward'])) {
         if (!$this->request->post['reward']) {
             $json['error'] = $this->language->get('error_empty');
         }
         $points = $this->customer->getRewardPoints();
         if ($this->request->post['reward'] > $points) {
             $json['error'] = sprintf($this->language->get('error_points'), $this->request->post['reward']);
         }
         $points_total = 0;
         foreach ($this->cart->getProducts() as $product) {
             if ($product['points']) {
                 $points_total += $product['points'];
             }
         }
         if ($this->request->post['reward'] > $points_total) {
             $json['error'] = sprintf($this->language->get('error_maximum'), $points_total);
         }
         if (!isset($json['error'])) {
             $this->session->data['reward'] = $this->request->post['reward'];
             $this->session->data['success'] = $this->language->get('text_success');
             $json['redirect'] = $this->url->link('checkout/cart', '', 'SSL');
         }
     }
     $this->load->library('json');
     $this->response->setOutput(Json::encode($json));
 }
예제 #11
0
 /**
  * 显示登录页(默认Action)
  */
 function doDefault()
 {
     $data = array('a', 'b' => 'roast');
     $json = new Json();
     $str_encoded = $json->encode($data);
     var_dump($str_encoded);
     var_dump($json->decode($str_encoded));
 }
예제 #12
0
 public function __toString()
 {
     $response = array('status' => $this->status, 'message' => $this->message, 'data' => $this->data);
     switch ($this->outputType) {
         case "json":
             return Json::encode($response);
     }
 }
 /**
  * 
  * @param EmailAddressesEntity $emails
  */
 public function unsubscribe(EmailAddressesEntity $emails)
 {
     $request = Request::post("{$this->getCompanyId()}/unsubscribers/");
     $data = $emails->toArray();
     $json = Json::encode($data['emails']);
     $request->setContent($json);
     $this->getConnector()->sendRequest($request);
 }
예제 #14
0
 /**
  * {@inheritdoc}
  */
 public function submitForm(array &$form, FormStateInterface $form_state)
 {
     $form_state->cleanValues();
     // This won't have a proper JSON header, but Drupal doesn't check for that
     // anyway so this is fine until it's replaced with a JsonResponse.
     print Json::encode($form_state->getValues());
     exit;
 }
 /**
  * Registers the needed assets
  */
 public function registerAssets()
 {
     $view = $this->getView();
     $id = $this->options['id'];
     iziModalAsset::register($view);
     $clientOptions = Json::encode([$this->clientOptions ?: new JsExpression('{}')]);
     $js = "\$('#{$id}').iziModal({$clientOptions});";
     $view->registerJs($js);
 }
예제 #16
0
 /**
  * 设定堆栈每一行的值
  *
  * @param string $value 值对应的键值
  * @param string $type 提示类型
  * @param string $typeFix 兼容老插件
  * @return array
  */
 public function set($value, $type = 'notice', $typeFix = 'notice')
 {
     $notice = is_array($value) ? array_values($value) : array($value);
     if (empty($type) && $typeFix) {
         $type = $typeFix;
     }
     Typecho_Cookie::set('__typecho_notice', Json::encode($notice), $this->widget('Widget_Options')->gmtTime + $this->widget('Widget_Options')->timezone + 86400);
     Typecho_Cookie::set('__typecho_notice_type', $type, $this->widget('Widget_Options')->gmtTime + $this->widget('Widget_Options')->timezone + 86400);
 }
예제 #17
0
 /**
  * Serialize array to JSON string.
  *
  * @param  array $args
  * @return string
  * @throws GraphCommons\Util\JsonException
  */
 public function serialize(...$args) : string
 {
     $json = new Json($this->unserialize());
     if ($json->hasError()) {
         $jsonError = $json->getError();
         throw new JsonException(sprintf('JSON error: code(%d) message(%s)', $jsonError['code'], $jsonError['message']), $jsonError['code']);
     }
     return (string) $json->encode($args);
 }
예제 #18
0
 /**
  * @test
  */
 public function depth()
 {
     $data = array('zero' => '{{{{{{{{{{{{{ " {{["[["[{{{{{{{ "', 'one' => array('two' => array('three' => array(1, 2, 3, 4, 5))));
     $this->assertFalse(Json::encode($data, null, 1));
     $this->assertFalse(Json::encode($data, null, 2));
     $this->assertFalse(Json::encode($data, null, 3));
     $this->assertFalse(false === Json::encode($data, null, 4));
     $this->assertFalse(false === Json::encode($data, null, 5));
     $this->assertFalse(false === Json::encode($data));
 }
예제 #19
0
 function render()
 {
     if (!$this->data_source) {
         throw new \Exception('need data source');
     }
     $header = XhtmlHeader::getInstance();
     $header->includeCss('http://yui.yahooapis.com/3.3.0/build/cssfonts/fonts-min.css');
     $header->includeJs('http://yui.yahooapis.com/3.3.0/build/yui/yui-min.js');
     $res = 'YUI().use("autocomplete", "autocomplete-filters", "autocomplete-highlighters", function (Y)' . '{' . 'var inputNode = Y.one("#ac-input"),' . 'tags = ' . Json::encode($this->data_source, false) . ';' . 'inputNode.plug(Y.Plugin.AutoComplete, {' . 'allowTrailingDelimiter: true,' . 'minQueryLength: 0,' . 'queryDelay: 0,' . 'queryDelimiter: ",",' . 'source: tags,' . 'resultHighlighter: "startsWith",' . 'resultFilters: ["startsWith", function (query, results) {' . 'var selected = inputNode.ac.get("value").split(/\\s*,\\s*/);' . 'selected.pop();' . 'selected = Y.Array.hash(selected);' . 'return Y.Array.filter(results, function (result) {' . 'return !selected.hasOwnProperty(result.text);' . '});' . '}]' . '});' . 'inputNode.on("focus", function () {' . 'inputNode.ac.sendRequest("");' . '});' . 'inputNode.ac.after("select", function () {' . 'inputNode.ac.sendRequest("");' . 'inputNode.ac.show();' . '});' . '});';
     return '<div id="demo">' . '<label for="ac-input">Tags:</label><br/>' . '<input id="ac-input" type="text"/>' . '</div>' . js_embed($res);
 }
예제 #20
0
파일: JsonTest.php 프로젝트: jivoo/core
 public function testEncodeAndDecode()
 {
     $value = 1;
     $this->assertEquals($value, Json::decode(Json::encode($value)));
     $value = 'foo';
     $this->assertEquals($value, Json::decode(Json::encode($value)));
     $value = ['foo' => 'bar'];
     $this->assertEquals($value, Json::decode(Json::encode($value)));
     $value = ['foo', 'bar'];
     $this->assertEquals($value, Json::decode(Json::encode($value)));
 }
예제 #21
0
 public function index()
 {
     $this->language->load('checkout/checkout');
     $json = array();
     if (!$this->cart->hasProducts() && (!isset($this->session->data['vouchers']) || !$this->session->data['vouchers']) || !$this->cart->hasStock() && !$this->config->get('config_stock_checkout')) {
         $json['redirect'] = $this->url->link('checkout/cart');
     }
     if ($this->request->server['REQUEST_METHOD'] == 'POST') {
         if (isset($this->request->post['account'])) {
             $this->session->data['account'] = $this->request->post['account'];
         }
         if (isset($this->request->post['email']) && isset($this->request->post['password'])) {
             if ($this->customer->login($this->request->post['email'], $this->request->post['password'])) {
                 unset($this->session->data['guest']);
                 $this->load->model('account/address');
                 $address_info = $this->model_account_address->getAddress($this->customer->getAddressId());
                 if ($address_info) {
                     $this->tax->setZone($address_info['country_id'], $address_info['zone_id']);
                 }
             } else {
                 $json['error']['warning'] = $this->language->get('error_login');
             }
         }
     } else {
         $this->data['text_new_customer'] = $this->language->get('text_new_customer');
         $this->data['text_returning_customer'] = $this->language->get('text_returning_customer');
         $this->data['text_checkout'] = $this->language->get('text_checkout');
         $this->data['text_register'] = $this->language->get('text_register');
         $this->data['text_guest'] = $this->language->get('text_guest');
         $this->data['text_i_am_returning_customer'] = $this->language->get('text_i_am_returning_customer');
         $this->data['text_register_account'] = $this->language->get('text_register_account');
         $this->data['text_forgotten'] = $this->language->get('text_forgotten');
         $this->data['entry_email'] = $this->language->get('entry_email');
         $this->data['entry_password'] = $this->language->get('entry_password');
         $this->data['button_continue'] = $this->language->get('button_continue');
         $this->data['button_login'] = $this->language->get('button_login');
         $this->data['guest_checkout'] = $this->config->get('config_guest_checkout') && !$this->config->get('config_customer_price') && !$this->cart->hasDownload();
         if (isset($this->session->data['account'])) {
             $this->data['account'] = $this->session->data['account'];
         } else {
             $this->data['account'] = 'register';
         }
         $this->data['forgotten'] = $this->url->link('account/forgotten', '', 'SSL');
         if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/checkout/login.tpl')) {
             $this->template = $this->config->get('config_template') . '/template/checkout/login.tpl';
         } else {
             $this->template = 'default/template/checkout/login.tpl';
         }
         $json['output'] = $this->render();
     }
     $this->load->library('json');
     $this->response->setOutput(Json::encode($json));
 }
예제 #22
0
 public function login()
 {
     $json = array();
     if ($this->request->server['REQUEST_METHOD'] == 'POST' && $this->validate()) {
         $json['success'] = 1;
     } else {
         $json['error'] = 1;
         $json['msg'] = $this->language->get('error_email');
     }
     $this->load->library('json');
     $this->response->setOutput(Json::encode($json), $this->config->get('config_compression'));
 }
예제 #23
0
 /**
  * @param yii\rbac\Item $item
  * @param array $config name-value pairs that will be used to initialize the object properties
  */
 public function __construct($item, $config = array())
 {
     $this->item = $item;
     if ($item !== null) {
         $this->isNewRecord = false;
         $this->name = $item->name;
         $this->description = $item->description;
         $this->ruleName = $item->ruleName;
         $this->data = $item->data === null ? null : Json::encode($item->data);
     }
     parent::__construct($config);
 }
예제 #24
0
 public function actionAddReserve()
 {
     if (Yii::$app->request->isAjax) {
         $reserve = new Reserve();
         $reserve->user_id = Yii::$app->user->id;
         $reserve->service_id = $id;
         $reserve->phone = $phone;
         $reserve->description = $description;
         $reserve->save();
         die(Json::encode(['html' => $html]));
     }
 }
예제 #25
0
 public function run()
 {
     $container = 'div';
     if (isset($this->containerOptions['tag'])) {
         $container = $this->containerOptions['tag'];
         unset($this->containerOptions['tag']);
     }
     echo Html::tag($container, Html::tag('iframe', '', $this->frameOptions), $this->containerOptions);
     if (!empty($this->callbackFunction)) {
         AssetsCallBack::register($this->getView());
         $this->getView()->registerJs("mihaildev.elFinder.register(" . Json::encode($this->id) . "," . Json::encode($this->callbackFunction) . ");");
     }
 }
예제 #26
0
 /**
  * 页面内容输出
  * @param boolean $fetch 是否提取输出结果
  * @return string JSON结果
  */
 function output($fetch = false)
 {
     ob_start();
     $json = new Json();
     echo $json->encode($this->value);
     $content = ob_get_contents();
     if ($fetch) {
         ob_end_clean();
     } else {
         ob_end_flush();
     }
     return $content;
 }
예제 #27
0
 public function autocomplete()
 {
     $json = array();
     if (isset($this->request->post['filter_name'])) {
         $this->load->model('catalog/product');
         $data = array('filter_name' => $this->request->post['filter_name'], 'start' => 0, 'limit' => 20);
         $results = $this->model_catalog_product->getProducts($data);
         foreach ($results as $result) {
             $json[] = array('name' => html_entity_decode($result['name'], ENT_QUOTES, 'UTF-8'), 'link' => str_replace('&amp;', '&', $this->url->link('product/product', 'product_id=' . $result['product_id'] . '&tracking=' . $this->affiliate->getCode())));
         }
     }
     $this->load->library('json');
     $this->response->setOutput(Json::encode($json));
 }
 public function actionImageDelete($name)
 {
     $directory = \Yii::getAlias('@frontend/web/img/temp') . DIRECTORY_SEPARATOR . Yii::$app->session->id;
     if (is_file($directory . DIRECTORY_SEPARATOR . $name)) {
         unlink($directory . DIRECTORY_SEPARATOR . $name);
     }
     $files = FileHelper::findFiles($directory);
     $output = [];
     foreach ($files as $file) {
         $path = '/img/temp/' . Yii::$app->session->id . DIRECTORY_SEPARATOR . basename($file);
         $output['files'][] = ['name' => basename($file), 'size' => filesize($file), "url" => $path, "thumbnailUrl" => $path, "deleteUrl" => 'image-delete?name=' . basename($file), "deleteType" => "POST"];
     }
     return Json::encode($output);
 }
예제 #29
0
 function render()
 {
     if (!$this->name) {
         throw new \Exception('must set a name');
     }
     $header = XhtmlHeader::getInstance();
     $header->includeCss('core_dev/js/ext/yui/2.9.0/build/calendar/assets/skins/sam/calendar.css');
     $header->includeJs('core_dev/js/ext/yui/2.9.0/build/yahoo-dom-event/yahoo-dom-event.js');
     $header->includeJs('core_dev/js/ext/yui/2.9.0/build/calendar/calendar-min.js');
     $locale = LocaleHandler::getInstance();
     $div_holder = 'yui_date_hold' . mt_rand();
     $res = 'YAHOO.namespace("example.calendar");' . 'YAHOO.example.calendar.init = function() {' . 'var inTxt = YAHOO.util.Dom.get("' . $this->name . '");' . ($this->selected_date ? 'inTxt.value  = "' . sql_date($this->selected_date) . '";' : '') . 'var cal = YAHOO.example.calendar.cal1 = new YAHOO.widget.Calendar("' . $div_holder . '");' . ($this->selected_date ? 'cal.cfg.setProperty("selected", "' . js_date($this->selected_date) . '");' . 'cal.cfg.setProperty("pagedate", "' . date('n/Y', $this->selected_date) . '");' : '') . 'cal.cfg.setProperty("start_weekday",' . $this->start_weekday . ');' . 'cal.cfg.setProperty("MONTHS_SHORT",' . Json::encode($locale->handle->month_short, false) . ');' . 'cal.cfg.setProperty("MONTHS_LONG",' . Json::encode($locale->handle->month_long, false) . ');' . 'cal.cfg.setProperty("WEEKDAYS_1CHAR",' . Json::encode($locale->handle->weekday_1char, false) . ');' . 'cal.cfg.setProperty("WEEKDAYS_SHORT",' . Json::encode($locale->handle->weekday_short, false) . ');' . 'cal.cfg.setProperty("WEEKDAYS_MEDIUM",' . Json::encode($locale->handle->weekday_medium, false) . ');' . 'cal.cfg.setProperty("WEEKDAYS_LONG",' . Json::encode($locale->handle->weekday_long, false) . ');' . 'cal.selectEvent.subscribe(function() {' . 'var dates = this.getSelectedDates();' . 'var inDate = dates[0];' . 'inTxt.value = inDate.getFullYear() + "-" + (inDate.getMonth() + 1) + "-" + inDate.getDate();' . '}, cal, true);' . 'cal.render();' . '}' . "\n" . 'YAHOO.util.Event.onDOMReady(YAHOO.example.calendar.init);';
     return '<div id="' . $div_holder . '"></div>' . '<div style="clear:both"></div>' . xhtmlInput($this->name) . '<br/>' . js_embed($res);
 }
예제 #30
0
 public function index()
 {
     //Upload
     $allowedExtensions = array();
     // max file size in bytes
     $sizeLimit = 1024 * 1024 * 10;
     $uploader = new qqFileUploader($this->registry, $allowedExtensions, $sizeLimit);
     $directory = rtrim(DIR_IMAGE . 'data/' . $this->request->get['directory'] . '/');
     $result = $uploader->handleUpload($directory);
     $filename = $uploader->filename;
     $code = array('id' => 'data/' . $filename, 'filename' => $filename);
     $this->load->library('json');
     $this->response->setOutput(Json::encode(array_merge($code, $result)));
 }