예제 #1
1
파일: js.php 프로젝트: nextghost/dokuwiki
/**
 * Output all needed JavaScript
 *
 * @author Andreas Gohr <*****@*****.**>
 */
function js_out()
{
    global $conf;
    global $lang;
    global $config_cascade;
    // The generated script depends on some dynamic options
    $cache = new cache('scripts' . $_SERVER['HTTP_HOST'] . $_SERVER['SERVER_PORT'], '.js');
    $cache->_event = 'JS_CACHE_USE';
    // load minified version for some files
    $min = $conf['compress'] ? '.min' : '';
    // array of core files
    $files = array(DOKU_INC . "lib/scripts/jquery/jquery{$min}.js", DOKU_INC . 'lib/scripts/jquery/jquery.cookie.js', DOKU_INC . "lib/scripts/jquery/jquery-ui{$min}.js", DOKU_INC . "lib/scripts/fileuploader.js", DOKU_INC . "lib/scripts/fileuploaderextended.js", DOKU_INC . 'lib/scripts/helpers.js', DOKU_INC . 'lib/scripts/delay.js', DOKU_INC . 'lib/scripts/cookie.js', DOKU_INC . 'lib/scripts/script.js', DOKU_INC . 'lib/scripts/tw-sack.js', DOKU_INC . 'lib/scripts/qsearch.js', DOKU_INC . 'lib/scripts/tree.js', DOKU_INC . 'lib/scripts/index.js', DOKU_INC . 'lib/scripts/drag.js', DOKU_INC . 'lib/scripts/textselection.js', DOKU_INC . 'lib/scripts/toolbar.js', DOKU_INC . 'lib/scripts/edit.js', DOKU_INC . 'lib/scripts/editor.js', DOKU_INC . 'lib/scripts/locktimer.js', DOKU_INC . 'lib/scripts/linkwiz.js', DOKU_INC . 'lib/scripts/media.js', DOKU_INC . 'lib/scripts/compatibility.js', DOKU_INC . 'lib/scripts/behaviour.js', DOKU_INC . 'lib/scripts/page.js', tpl_incdir() . 'script.js');
    // add possible plugin scripts and userscript
    $files = array_merge($files, js_pluginscripts());
    if (isset($config_cascade['userscript']['default'])) {
        $files[] = $config_cascade['userscript']['default'];
    }
    $cache_files = array_merge($files, getConfigFiles('main'));
    $cache_files[] = __FILE__;
    // check cache age & handle conditional request
    // This may exit if a cache can be used
    $cache_ok = $cache->useCache(array('files' => $cache_files));
    http_cached($cache->cache, $cache_ok);
    // start output buffering and build the script
    ob_start();
    // add some global variables
    print "var DOKU_BASE   = '" . DOKU_BASE . "';";
    print "var DOKU_TPL    = '" . tpl_basedir() . "';";
    // FIXME: Move those to JSINFO
    print "var DOKU_UHN    = " . (int) useHeading('navigation') . ";";
    print "var DOKU_UHC    = " . (int) useHeading('content') . ";";
    // load JS specific translations
    $json = new JSON();
    $lang['js']['plugins'] = js_pluginstrings();
    echo 'LANG = ' . $json->encode($lang['js']) . ";\n";
    // load toolbar
    toolbar_JSdefines('toolbar');
    // load files
    foreach ($files as $file) {
        echo "\n\n/* XXXXXXXXXX begin of " . str_replace(DOKU_INC, '', $file) . " XXXXXXXXXX */\n\n";
        js_load($file);
        echo "\n\n/* XXXXXXXXXX end of " . str_replace(DOKU_INC, '', $file) . " XXXXXXXXXX */\n\n";
    }
    // init stuff
    if ($conf['locktime'] != 0) {
        js_runonstart("dw_locktimer.init(" . ($conf['locktime'] - 60) . "," . $conf['usedraft'] . ")");
    }
    // init hotkeys - must have been done after init of toolbar
    # disabled for FS#1958    js_runonstart('initializeHotkeys()');
    // end output buffering and get contents
    $js = ob_get_contents();
    ob_end_clean();
    // compress whitespace and comments
    if ($conf['compress']) {
        $js = js_compress($js);
    }
    $js .= "\n";
    // https://bugzilla.mozilla.org/show_bug.cgi?id=316033
    http_cached_finish($cache->cache, $js);
}
예제 #2
0
 function display()
 {
     global $app_strings, $current_user, $mod_strings, $theme, $beanList, $beanFiles;
     $smarty = new Sugar_Smarty();
     $json = new JSON();
     require_once 'include/JSON.php';
     //Load the field list from the target module
     if (!empty($_REQUEST['targetModule']) && $_REQUEST['targetModule'] != 'undefined') {
         $module = $_REQUEST['targetModule'];
         if (isset($_REQUEST['package']) && $_REQUEST['package'] != 'studio' && $_REQUEST['package'] != '') {
             //Get the MB Parsers
             require_once 'modules/ModuleBuilder/MB/MBPackage.php';
             $pak = new MBPackage($_REQUEST['package']);
             $defs = $pak->modules[$module]->getVardefs();
             $fields = FormulaHelper::cleanFields(array_merge($pak->modules[$module]->getLinkFields(), $defs['fields']));
         } else {
             $seed = BeanFactory::getBean($module);
             $fields = FormulaHelper::cleanFields($seed->field_defs);
         }
         $smarty->assign('Field_Array', $json->encode($fields));
     } else {
         $fields = array(array('income', 'number'), array('employed', 'boolean'), array('first_name', 'string'), array('last_name', 'string'));
         $smarty->assign('Field_Array', $json->encode($fields));
     }
     if (!empty($_REQUEST['targetField'])) {
         $smarty->assign("target", $_REQUEST['targetField']);
     }
     if (isset($_REQUEST['returnType'])) {
         $smarty->assign("returnType", $_REQUEST['returnType']);
     }
     //Assign any requested Javascript event actions
     foreach (array('onSave', 'onLoad', 'onClose') as $e) {
         if (!empty($_REQUEST[$e])) {
             $smarty->assign($e, html_entity_decode($_REQUEST[$e], ENT_QUOTES));
         } else {
             $smarty->assign($e, 'function(){}');
         }
     }
     //Check if we need to load Ext ourselves
     if (!isset($_REQUEST['loadExt']) || $_REQUEST['loadExt'] && $_REQUEST['loadExt'] != "false") {
         $smarty->assign('loadExt', true);
     } else {
         $smarty->assign('loadExt', false);
     }
     if (!empty($_REQUEST['formula'])) {
         $smarty->assign('formula', $json->decode(htmlspecialchars_decode($_REQUEST['formula'])));
     }
     if (isset($_REQUEST['returnType'])) {
         $smarty->assign('returnType', $_REQUEST['returnType']);
     }
     $smarty->assign('app_strings', $app_strings);
     $smarty->assign('mod', $mod_strings);
     $smarty->display('modules/ExpressionEngine/tpls/formulaBuilder.tpl');
 }
예제 #3
0
 /**
  * Step up
  *
  * @param Doku_Event $event
  */
 public function handle_ajax(Doku_Event $event)
 {
     if ($event->data != 'plugin_move_progress') {
         return;
     }
     $event->preventDefault();
     $event->stopPropagation();
     global $INPUT;
     global $USERINFO;
     if (!auth_ismanager($_SERVER['REMOTE_USER'], $USERINFO['grps'])) {
         http_status(403);
         exit;
     }
     $return = array('error' => '', 'complete' => false, 'progress' => 0);
     /** @var helper_plugin_move_plan $plan */
     $plan = plugin_load('helper', 'move_plan');
     if (!$plan->isCommited()) {
         // There is no plan. Something went wrong
         $return['complete'] = true;
     } else {
         $todo = $plan->nextStep($INPUT->bool('skip'));
         $return['progress'] = $plan->getProgress();
         $return['error'] = $plan->getLastError();
         if ($todo === 0) {
             $return['complete'] = true;
         }
     }
     $json = new JSON();
     header('Content-Type: application/json');
     echo $json->encode($return);
 }
예제 #4
0
파일: token.php 프로젝트: MenZil-Team/cms
 public function action_index()
 {
     try {
         if ($token = $this->grantAccessToken()) {
             // @see http://tools.ietf.org/html/rfc6749#section-5.1
             // server MUST disable caching in headers when tokens are involved
             $this->response->status(200);
             $this->response->headers(array('Cache-Control' => 'no-store', 'Pragma' => 'no-cache'));
             $this->response->headers('content-type', 'application/json; charset=' . Kohana::$charset);
             $this->response->body(JSON::encode($token));
             return;
         }
     } catch (Oauth2_Exception $e) {
         // Throw an exception because there was a problem with the client's request
         $response = array('error' => $e->getError(), 'error_description' => $e->getMessage());
         $this->response->status($e->getCode());
         $this->response->headers(array('Cache-Control' => 'no-store', 'Pragma' => 'no-cache'));
         $this->response->headers('content-type', 'application/json; charset=' . Kohana::$charset);
         $this->response->body(json_encode($response));
         return;
     } catch (Exception $e) {
         /**
          * Something went wrong!
          *
          * Throw an error when a non-library specific exception has been thrown
          *
          * You should probably show a nice error page :)
          *
          * Do NOT redirect the user back to the client.
          */
         throw HTTP_Exception::factory(500, $e->getMessage());
     }
 }
예제 #5
0
 /**
  * @param Doku_Event$event
  * @param $param
  */
 public function ajax(Doku_Event $event, $param)
 {
     if ($event->data !== 'bureaucracy_user_field') {
         return;
     }
     $event->stopPropagation();
     $event->preventDefault();
     $search = $_REQUEST['search'];
     /** @var DokuWiki_Auth_Plugin $auth */
     global $auth;
     $users = array();
     foreach ($auth->retrieveUsers() as $username => $data) {
         if ($search === '' || stripos($username, $search) === 0 || stripos($data['name'], $search) !== false) {
             // Full name
             $users[$username] = $data['name'];
         }
         if (count($users) === 10) {
             break;
         }
     }
     if (count($users) === 1 && key($users) === $search) {
         $users = array();
     }
     require_once DOKU_INC . 'inc/JSON.php';
     $json = new JSON();
     echo $json->encode($users);
 }
예제 #6
0
 /**
  * Retrieve a JSON object containing autocomplete suggestions for existing users.
  */
 public function action_tag()
 {
     $string = $this->request->param('string', FALSE);
     $type = $this->request->param('type', 'blog');
     // The user enters a comma-separated list of tags. We only autocomplete the last tag.
     $tags_typed = Tags::explode($string);
     $tag_last = UTF8::strtolower(array_pop($tags_typed));
     $matches = array();
     if (!empty($tag_last)) {
         $query = DB::select('name')->from('tags')->where('name', 'LIKE', $tag_last . '%')->where('type', '=', $type);
         // Do not select already entered terms.
         if (!empty($tags_typed)) {
             $query->where('name', 'NOT IN', $tags_typed);
         }
         $result = $query->limit('10')->execute();
         $prefix = count($tags_typed) ? implode(', ', $tags_typed) . ', ' : '';
         foreach ($result as $tag) {
             $n = $tag['name'];
             // Tag names containing commas or quotes must be wrapped in quotes.
             if (strpos($tag['name'], ',') !== FALSE or strpos($tag['name'], '"') !== FALSE) {
                 $n = '"' . str_replace('"', '""', $tag['name']) . '"';
             } else {
                 $matches[$prefix . $n] = Text::plain($tag['name']);
             }
         }
     }
     $this->response->body(JSON::encode($matches));
 }
예제 #7
0
파일: action.php 프로젝트: rauschen/do
 function handle_ajax_call(&$event, $param)
 {
     if ($event->data == 'plugin_do') {
         $id = cleanID($_REQUEST['do_page']);
         if (auth_quickaclcheck($id) < AUTH_EDIT) {
             echo -1;
             $event->preventDefault();
             $event->stopPropagation();
             return false;
         }
         // toggle status of a single task
         $hlp = plugin_load('helper', 'do');
         $status = $hlp->toggleTaskStatus($id, $_REQUEST['do_md5'], $_REQUEST['do_commit']);
         // rerender the page
         p_get_metadata(cleanID($_REQUEST['do_page']), '', true);
         header('Content-Type: text/plain; charset=utf-8');
         echo $status;
         $event->preventDefault();
         $event->stopPropagation();
         return false;
     } elseif ($event->data == 'plugin_do_status') {
         // read status for a bunch of tasks
         require_once DOKU_INC . 'inc/JSON.php';
         $JSON = new JSON();
         $hlp = plugin_load('helper', 'do');
         $status = $hlp->getAllPageStatuses(cleanID($_REQUEST['do_page']));
         $status = $JSON->encode($status);
         header('Content-Type: text/plain; charset=utf-8');
         echo $status;
         $event->preventDefault();
         $event->stopPropagation();
         return false;
     }
     return true;
 }
예제 #8
0
파일: apiv1.php 프로젝트: ricberw/BotQueue
 public function endpoint()
 {
     $provider = new MyOAuthProvider();
     //we need to disable a check if it is our first call to requesttoken.
     $c = strtolower($this->args('api_call'));
     if ($c == 'requesttoken') {
         $provider->oauth->isRequestTokenEndpoint(true);
         $this->set('provider', $provider);
     } elseif ($c == 'accesstoken') {
         $this->set('provider', $provider);
     }
     try {
         $provider->oauth->checkOAuthRequest();
         $calls = array('requesttoken', 'accesstoken', 'listqueues', 'queueinfo', 'createqueue', 'listjobs', 'jobinfo', 'grabjob', 'findnewjob', 'dropjob', 'canceljob', 'completejob', 'downloadedjob', 'createjob', 'updatejobprogress', 'listbots', 'botinfo', 'registerbot', 'updatebot');
         if (in_array($c, $calls)) {
             $fname = "api_{$c}";
             $data = $this->{$fname}();
         } else {
             throw new Exception("Specified api_call '{$c}' does not exist.");
         }
         $result = array('status' => 'success', 'data' => $data);
     } catch (Exception $e) {
         $result = array('status' => 'error', 'error' => $e->getMessage());
     }
     //add in our version.
     $result['_api_version'] = self::$api_version;
     echo JSON::encode($result);
     exit;
 }
예제 #9
0
파일: JSONTest.php 프로젝트: gekt/www
 public function testEncoding()
 {
     $formatter = new JSON();
     $data = array('name' => 'Joe', 'age' => 21, 'employed' => true);
     $options = defined('JSON_PRETTY_PRINT') ? JSON_PRETTY_PRINT : null;
     $this->assertSame(json_encode($data, $options), $formatter->encode($data));
 }
예제 #10
0
 /**
  * Rename a single page
  */
 public function handle_ajax(Doku_Event $event)
 {
     if ($event->data != 'plugin_move_rename') {
         return;
     }
     $event->preventDefault();
     $event->stopPropagation();
     global $MSG;
     global $INPUT;
     $src = cleanID($INPUT->str('id'));
     $dst = cleanID($INPUT->str('newid'));
     /** @var helper_plugin_move_op $MoveOperator */
     $MoveOperator = plugin_load('helper', 'move_op');
     $JSON = new JSON();
     header('Content-Type: application/json');
     if ($this->renameOkay($src) && $MoveOperator->movePage($src, $dst)) {
         // all went well, redirect
         echo $JSON->encode(array('redirect_url' => wl($dst, '', true, '&')));
     } else {
         if (isset($MSG[0])) {
             $error = $MSG[0];
             // first error
         } else {
             $error = $this->getLang('cantrename');
         }
         echo $JSON->encode(array('error' => $error));
     }
 }
예제 #11
0
파일: Log.php 프로젝트: reekoheek/php-fw
	function log($priority, $message, $file = null, $line = null, $e = null) {
		$schema = "DEFAULT";
		$table = "logs";
		$trace = "";
		if (!empty($e)) {
			$trace = $e->getTraceAsString();
		}
		if (is_object($message)) {
			$message = JSON::encode($message);
		}
		$now = new Date();
		$log = array();
		$log["priority"] = $priority;
		$log["message"] = $message;
		$log["trace"] = $trace;
		$log["file"] = $file;
		$log["line"] = $line;
		$log["createdBy"] = "SYS";
		$log["createdTime"] = $now;
		$log["updatedBy"] = "SYS";
		$log["updatedTime"] = $now;

		$driver = $GLOBALS["CFG_DB"]->CON[$schema]->DRIVER;
		$insert = new Insert($table, $log, $schema);
		$link = DB::connect();
		$success = mysql_query($insert->sql(), $link);
		if (!$success) {
			$result = Bean::invoke(String::camelize('_'.$driver.'_driver'), "error", array($schema));
			throw new Exception("Cannot persist object. ".$result);
		}
	}
예제 #12
0
 /**
  * send the result back to the client and exit
  * @param mixed $result the result to send back to the client
  */
 protected function respond($result)
 {
     header('Content-Type: application/json');
     $json = new JSON();
     echo $json->encode($result);
     exit;
 }
예제 #13
0
파일: good.php 프로젝트: jiusanzhou/ecapi
/**
 * API数据返回
 *
 * @access  public
 * @param   array
 * @return  void
 */
function api_return($api_data, $data)
{
    include_once 'includes/cls_json.php';
    $return_data = array('version' => 0.1, 'api_url' => 'good.php', 'api_data' => $api_data, 'error' => 0, 'data' => $return_data['data'] = $data ? $data : '');
    header('Content-type: application/json');
    die(JSON::encode($return_data));
}
예제 #14
0
 function display()
 {
     global $app_strings, $current_user, $mod_strings, $app_list_strings;
     $smarty = new Sugar_Smarty();
     require_once 'include/JSON.php';
     //Load the field list from the target module
     $selected_lang = $_SESSION['authenticated_user_language'];
     $vardef = array();
     //Copy app strings
     $my_list_strings = array_merge($app_list_strings);
     $child = $_REQUEST['field'];
     //if we are using ModuleBuilder then process the following
     if (!empty($_REQUEST['package']) && $_REQUEST['package'] != 'studio') {
         require_once 'modules/ModuleBuilder/MB/ModuleBuilder.php';
         $mb = new ModuleBuilder();
         $this->module = $mb->getPackageModule($_REQUEST['package'], $_REQUEST['view_module']);
         $vardef = $this->module->getVardefs();
         $this->module->mblanguage->generateAppStrings(false);
         $my_list_strings = array_merge($my_list_strings, $this->module->mblanguage->appListStrings[$selected_lang . '.lang.php']);
     } else {
         $vardef = BeanFactory::getBean($_REQUEST['view_module'])->field_defs;
     }
     foreach ($my_list_strings as $key => $value) {
         if (!is_array($value)) {
             unset($my_list_strings[$key]);
         }
     }
     $parents = $this->getParentDDs($vardef, $child, $my_list_strings);
     $visibility_grid = !empty($vardef[$child]['visibility_grid']) ? $vardef[$child]['visibility_grid'] : array();
     $smarty->assign('app_strings', $app_strings);
     $smarty->assign('mod', $mod_strings);
     $smarty->assign('parents', JSON::encode($parents));
     $smarty->assign('visibility_grid', JSON::encode($visibility_grid));
     $smarty->display('modules/ExpressionEngine/tpls/ddEditor.tpl');
 }
예제 #15
0
function output($data)
{
    header("Content-Type:text/html; charset=utf-8");
    $r_type = intval($_REQUEST['r_type']);
    //返回数据格式类型; 0:base64;1;json_encode;2:array
    $data['act'] = ACT;
    $data['act_2'] = ACT_2;
    sql_check("wap");
    if ($r_type == 0) {
        require_once APP_ROOT_PATH . 'system/libs/json.php';
        $JSON = new JSON();
        print_r(base64_encode($JSON->encode($data)));
        //	echo base64_encode(json_encode($data));
    } else {
        if ($r_type == 1) {
            //echo APP_ROOT_PATH; exit;
            require_once APP_ROOT_PATH . 'system/libs/json.php';
            //echo 'ss';exit;
            $JSON = new JSON();
            print_r($JSON->encode($data));
            //print_r(json_encode($data));
        } else {
            if ($r_type == 2) {
                print_r($data);
            }
        }
    }
    exit;
}
예제 #16
0
 /**
  * Register the events
  *
  * @param $event DOKU event on ajax call
  * @param $param parameters, ignored
  */
 function _ajax_call(&$event, $param)
 {
     if ($event->data !== 'plugin_explorertree') {
         return;
     }
     //no other ajax call handlers needed
     $event->stopPropagation();
     $event->preventDefault();
     //e.g. access additional request variables
     global $INPUT;
     //available since release 2012-10-13 "Adora Belle"
     if (!checkSecurityToken()) {
         $data = array('error' => true, 'msg' => 'invalid security token!');
     } else {
         switch ($INPUT->str('operation')) {
             case 'explorertree_branch':
                 if (!($helper = plugin_load('helper', 'explorertree'))) {
                     $data = array('error' => true, 'msg' => "Can't load tree helper.");
                     break;
                 }
                 if (!($route = $helper->loadRoute($INPUT->str('route'), $INPUT->arr('loader')))) {
                     $data = array('error' => true, 'msg' => "Can't load route '" . $INPUT->str('route') . "'!");
                 }
                 $data = array('html' => $helper->htmlExplorer($INPUT->str('route'), ltrim(':' . $INPUT->str('itemid')), ':'));
                 if (!$data['html']) {
                     $data['error'] = true;
                     $data['msg'] = "Can't load tree html.";
                 }
                 break;
             case 'callback':
                 if (!($helper = plugin_load('helper', 'explorertree'))) {
                     $data = array('error' => true, 'msg' => "Can't load tree helper.");
                     break;
                 }
                 $route = $helper->loadRoute($INPUT->str('route'), $INPUT->arr('loader'));
                 if (!$route || !is_callable(@$route['callbacks'][$INPUT->str(event)])) {
                     $data = array('error' => true, 'msg' => "Can't load callback '" . $INPUT->str('event') . "'for '" . $INPUT->str('route') . "'!");
                 }
                 $data = @call_user_func_array($route['callbacks'][$INPUT->str(event)], array($INPUT->str('itemid')));
                 if (!is_array($data)) {
                     $data = array('error' => true, 'msg' => "Callback for '" . $INPUT->str('event') . "' does not exists!");
                 }
                 break;
             default:
                 $data = array('error' => true, 'msg' => 'Unknown operation: ' . $INPUT->str('operation'));
                 break;
         }
         //data
         //json library of DokuWiki
     }
     if (is_array($data)) {
         $data['token'] = getSecurityToken();
     }
     require_once DOKU_INC . 'inc/JSON.php';
     $json = new JSON();
     //set content type
     header('Content-Type: application/json');
     echo $json->encode($data);
     //		$this->get_helper()->check_meta_changes();
 }
예제 #17
0
 public static function enqueue(DB $db, $handler, array $message)
 {
     if (!isset(self::$handlers[$handler])) {
         throw new UnexpectedValueException('Unsupported handler (' . $handler . ').');
     }
     $prepared = $db->prepare("\n\t\t\tINSERT INTO `jobs` (\n\t\t\t\t`handler`,\n\t\t\t\t`status`,\n\t\t\t\t`message`\n\t\t\t) VALUES (\n\t\t\t\t:handler,\n\t\t\t\t:status,\n\t\t\t\t:message\n\t\t\t)\n\t\t");
     $result = $prepared->execute([':handler' => $handler, ':status' => self::QUEUED, ':message' => JSON::encode($message)]);
 }
예제 #18
0
 /**
  * @brief 获取物流轨迹线路
  * @param $ShipperCode string 物流公司代号
  * @param $LogisticCode string 物流单号
  * @return string array 轨迹数据
  */
 public function line($ShipperCode, $LogisticCode)
 {
     $params = array('ShipperCode' => $ShipperCode, 'LogisticCode' => $LogisticCode);
     $sendData = JSON::encode($params);
     $curlData = array('RequestData' => $sendData, 'EBusinessID' => $this->appid, 'RequestType' => '1002', 'DataType' => 2, 'DataSign' => base64_encode(md5($sendData . $this->appkey)));
     $result = $this->curlSend($this->getSubmitUrl(), $curlData);
     return $this->response(JSON::decode($result));
 }
 public function actionGetcomerciobyruta($usuario, $dia)
 {
     $response = file_get_contents('http://localhost/yii2-grupo8/api/web/v1/apimobile/ruta/' . $usuario . '-' . $dia);
     $arrayRuta = array();
     $arrayRuta = explode('[', json_decode($response));
     $arrayRuta = explode(']', $arrayRuta[2]);
     $arrayRuta = explode(',', $arrayRuta[0]);
     echo JSON::encode($arrayRuta);
 }
예제 #20
0
 function list_action()
 {
     $ctrlId = IReq::get('ctrlId');
     if ($ctrlId != '') {
         $baseContrl = get_class_methods('IController');
         $advContrl = get_class_methods($ctrlId);
         $diffArray = array_diff($advContrl, $baseContrl);
         echo JSON::encode($diffArray);
     }
 }
예제 #21
0
 /**
  * @brief 处理curd动作
  * @return String
  */
 public function curd()
 {
     $action = $this->id;
     $controller = $this->controller;
     $curdinfo = $this->initinfo();
     if (is_array($curdinfo)) {
         $modelName = $curdinfo['model'];
         $key = $curdinfo['key'];
         $actions = $curdinfo['actions'];
         switch ($action) {
             case 'add':
             case 'upd':
                 if (method_exists($controller, 'getValidate')) {
                     $validate = $controller->getValidate();
                 } else {
                     $validate = null;
                 }
                 if ($validate != null) {
                     $formValidate = new IFormValidation($validate);
                     $data = $formValidate->run();
                 }
                 $model = new IModel($modelName);
                 if (isset($data) && $data !== null) {
                     $model->setData($data[$modelName]);
                     if ($action = 'add') {
                         $flag = $model->add();
                     } else {
                         $flag = $model->upd("{$key} = '" . IReq::get($key) . "'");
                     }
                 }
                 if (isset($flag) && $flag) {
                     $_GET['action'] = $actions['success'];
                 } else {
                     $_GET['action'] = $actions['fail'];
                 }
                 $controller->run();
                 return true;
             case 'del':
                 $model = new IModel($modelName);
                 $flag = $model->del("{$key} = '" . IReq::get($key) . "'");
                 if ($flag) {
                     $_GET['action'] = $actions['success'];
                 } else {
                     $_GET['action'] = $actions['fail'];
                 }
                 $controller->run();
                 return true;
             case 'get':
                 $model = new IModel($modelName);
                 $rs = $model->getObj("{$key} = '" . IReq::get($key) . "'");
                 echo JSON::encode($rs);
                 return false;
         }
     }
 }
예제 #22
0
/**
 * Prepares and prints an JavaScript array with all toolbar buttons
 *
 * @todo add toolbar plugins
 * @param  string $varname Name of the JS variable to fill
 * @author Andreas Gohr <*****@*****.**>
 */
function toolbar_JSdefines($varname)
{
    global $ID;
    global $conf;
    global $lang;
    // build button array
    $menu = array(array('type' => 'format', 'title' => 'Gras', 'icon' => 'bold.png', 'key' => 'b', 'open' => '**', 'close' => '**'), array('type' => 'format', 'title' => 'Italique', 'icon' => 'italic.png', 'key' => 'i', 'open' => '//', 'close' => '//'), array('type' => 'format', 'title' => 'Souligné', 'icon' => 'underline.png', 'key' => 'u', 'open' => '__', 'close' => '__'), array('type' => 'format', 'title' => 'Code', 'icon' => 'mono.png', 'key' => 'c', 'open' => "''", 'close' => "''"), array('type' => 'format', 'title' => 'Texte barré', 'icon' => 'strike.png', 'key' => 'd', 'open' => '<del>', 'close' => '</del>'), array('type' => 'format', 'title' => 'En-tête 1', 'icon' => 'h1.png', 'key' => '1', 'open' => '====== ', 'close' => ' ======\\n'), array('type' => 'format', 'title' => 'En-tête 2', 'icon' => 'h2.png', 'key' => '2', 'open' => '===== ', 'close' => ' =====\\n'), array('type' => 'format', 'title' => 'En-tête 3', 'icon' => 'h3.png', 'key' => '3', 'open' => '==== ', 'close' => ' ====\\n'), array('type' => 'format', 'title' => 'En-tête 4', 'icon' => 'h4.png', 'key' => '4', 'open' => '=== ', 'close' => ' ===\\n'), array('type' => 'format', 'title' => 'En-tête 5', 'icon' => 'h5.png', 'key' => '5', 'open' => '== ', 'close' => ' ==\\n'), array('type' => 'format', 'title' => 'Lien interne', 'icon' => 'link.png', 'key' => 'l', 'open' => '[[', 'close' => ']]'), array('type' => 'format', 'title' => 'Lien externe', 'icon' => 'linkextern.png', 'open' => '[[', 'close' => ']]', 'sample' => 'http://example.com|Lien externe'), array('type' => 'format', 'title' => 'Liste numérotée', 'icon' => 'ol.png', 'open' => '  - ', 'close' => '\\n'), array('type' => 'format', 'title' => 'Liste libre', 'icon' => 'ul.png', 'open' => '  * ', 'close' => '\\n'), array('type' => 'insert', 'title' => 'Ligne horizontale', 'icon' => 'hr.png', 'insert' => '----\\n'), array('type' => 'picker', 'title' => 'Insérer des characteres spéciaux', 'icon' => 'chars.png', 'list' => explode(' ', 'À à �? á Â â Ã ã Ä ä �? ǎ Ă ă Å å Ā �? Ą ą Æ æ Ć ć Ç ç Č �? Ĉ ĉ Ċ ċ �? đ ð Ď �? È è É é Ê ê Ë ë Ě ě Ē ē Ė ė Ę ę Ģ ģ Ĝ �? Ğ ğ Ġ ġ Ĥ ĥ Ì ì �? í Î î �? ï �? �? Ī ī İ ı Į į Ĵ ĵ Ķ ķ Ĺ ĺ Ļ ļ Ľ ľ �? ł Ŀ ŀ Ń ń Ñ ñ Ņ ņ Ň ň Ò ò Ó ó Ô ô Õ õ Ö ö Ǒ ǒ Ō �? �? ő Ø ø Ŕ ŕ Ŗ ŗ Ř ř Ś ś Ş ş Š š Ŝ �? Ţ ţ Ť ť Ù ù Ú ú Û û Ü ü Ǔ ǔ Ŭ ŭ Ū ū Ů ů ǖ ǘ ǚ ǜ Ų ų Ű ű Ŵ ŵ �? ý Ÿ ÿ Ŷ ŷ Ź ź Ž ž Ż ż Þ þ ß Ħ ħ ¿ ¡ ¢ £ ¤ ¥ € ¦ § ª ¬ ¯ ° ± ÷ ‰ ¼ ½ ¾ ¹ ² ³ µ ¶ † ‡ · • º ∀ ∂ ∃ �? ə ∅ ∇ ∈ ∉ ∋ �? ∑ ‾ − ∗ √ �? ∞ ∠ ∧ ∨ ∩ ∪ ∫ ∴ ∼ ≅ ≈ ≠ ≡ ≤ ≥ ⊂ ⊃ ⊄ ⊆ ⊇ ⊕ ⊗ ⊥ ⋅ ◊ ℘ ℑ ℜ ℵ ♠ ♣ ♥ ♦ α β Γ γ Δ δ ε ζ η Θ θ ι κ Λ λ μ Ξ ξ Π π �? Σ σ Τ τ υ Φ φ χ Ψ ψ Ω ω')), array('type' => 'picker', 'title' => 'Insérer un module dynamique', 'icon' => 'chars.png', 'list' => explode(';', '{{isi>ue?ID_DIPLOME}};{{isi>ens?ID_MODULE}};{{isi>uenav?ID_MODULE}};{{isi>actu}};{{isi>apog?ID_MODULE}}')));
    // use JSON to build the JavaScript array
    $json = new JSON();
    print "var {$varname} = " . $json->encode($menu) . ";\n";
}
예제 #23
0
 public function setMyCart($goodsInfo)
 {
     $goodsInfo = str_replace(array('"', ','), array('&', '$'), JSON::encode($goodsInfo));
     $cartName = $this->getCartName();
     if ($this->saveType == 'session') {
         ISession::set($cartName, $goodsInfo);
     } else {
         ICookie::set($cartName, $goodsInfo, '7200');
     }
     return true;
 }
예제 #24
0
 /**
  * Ajax handler
  */
 function _ajax_call(Doku_Event $event, $param)
 {
     if ($event->data !== 'plugin_textvar') {
         return;
     }
     $event->stopPropagation();
     $event->preventDefault();
     $json = new JSON();
     $data = array('%SERVER_ADDR%' => $_SERVER['SERVER_ADDR'], '%REMOTE_ADDR%' => $_SERVER['REMOTE_ADDR']);
     header('Content-Type: application/json');
     echo $json->encode($data);
 }
예제 #25
0
function smarty_function_notifications($params, &$smarty)
{
    $user = array_required_var($params, 'user', true, 'IUser');
    $activity_logs = NotificationsActivityLogs::findRecent($user);
    $interface = array_var($params, 'interface', AngieApplication::getPreferedInterface(), true);
    $id = isset($params['id']) && $params['id'] ? $params['id'] : HTML::uniqueId('activity_log');
    $wrapper = '<div id="' . $id . '" class="quick_view_item">';
    $wrapper .= '</div>';
    list($authors, $subjects, $targets) = ActivityLogs::loadRelatedDataFromActivities($activity_logs, $user);
    // Load related data, so we can pass it to callbacks
    return $wrapper .= '<script type="text/javascript">$("#' . $id . '").activityLog(' . JSON::encode(array('entries' => $activity_logs, 'authors' => $authors, 'subjects' => $subjects, 'targets' => $targets, 'callbacks' => ActivityLogs::getCallbacks(), 'decorator' => ActivityLogs::getDecorator($interface), 'interface' => $interface)) . ');</script>';
}
예제 #26
0
 public function printCronDataList($configuration)
 {
     require_once DOKU_INC . 'inc/JSON.php';
     $json = new JSON();
     $output = array();
     foreach ($configuration as $name => $value) {
         list($path, $query) = explode('?', $value, 2);
         $output[$name] = $this->functions->parseStringToRequestArray($query, true);
         $output[$name]['ns'] = cleanID($path);
     }
     print $json->encode($output);
 }
 /**
  * @see SugarView::display()
  */
 public function display()
 {
     require_once "include/JSON.php";
     $json = new JSON();
     global $mod_strings;
     $title = getClassicModuleTitle("Administration", array("<a href='index.php?module=Administration&action=index'>{$mod_strings['LBL_MODULE_NAME']}</a>", translate('LBL_CONFIGURE_SHORTCUT_BAR')), false);
     $msg = "";
     $GLOBALS['log']->info("Administration ConfigureShortcutBar view");
     $quickCreateModules = $this->getQuickCreateModules();
     //If save is set, save then let the user know if the save worked.
     if (!empty($_REQUEST['enabled_modules'])) {
         $toDecode = html_entity_decode($_REQUEST['enabled_modules'], ENT_QUOTES);
         // get the enabled
         $enabledModules = array_flip(json_decode($toDecode));
         $successful = $this->saveChangesToQuickCreateMetadata($quickCreateModules['enabled'], $quickCreateModules['disabled'], $enabledModules);
         if ($successful) {
             MetaDataManager::refreshSectionCache(array(MetaDataManager::MM_MODULES));
             echo "true";
         } else {
             echo translate("LBL_SAVE_FAILED");
         }
     } else {
         $enabled = $this->sortEnabledModules($quickCreateModules['enabled']);
         $enabled = $this->filterAndFormatModuleList($enabled);
         ksort($quickCreateModules['disabled']);
         $disabled = $this->filterAndFormatModuleList($quickCreateModules['disabled']);
         $this->ss->assign('APP', $GLOBALS['app_strings']);
         $this->ss->assign('MOD', $GLOBALS['mod_strings']);
         $this->ss->assign('title', $title);
         $this->ss->assign('enabled_modules', $json->encode($enabled));
         $this->ss->assign('disabled_modules', $json->encode($disabled));
         $this->ss->assign('description', translate("LBL_CONFIGURE_SHORTCUT_BAR"));
         $this->ss->assign('msg', $msg);
         $returnModule = !empty($_REQUEST['return_module']) ? $_REQUEST['return_module'] : 'Administration';
         $returnAction = !empty($_REQUEST['return_action']) ? $_REQUEST['return_action'] : 'index';
         $this->ss->assign('RETURN_MODULE', $returnModule);
         $this->ss->assign('RETURN_ACTION', $returnAction);
         echo $this->ss->fetch('modules/Administration/templates/ShortcutBar.tpl');
     }
 }
예제 #28
0
function get_node_data($params, $get_array = false)
{
    $click_level = $params['TREE']['depth'];
    $parent_id = $params['NODES'][$click_level]['id'];
    $ret = array();
    $nodes = get_product_categories($parent_id);
    foreach ($nodes as $node) {
        $ret['nodes'][] = $node->get_definition();
    }
    $json = new JSON(JSON_LOOSE_TYPE);
    $str = $json->encode($ret);
    return $str;
}
 /**
  * @see	Action::execute()
  */
 public function execute()
 {
     parent::execute();
     $this->readCache();
     $this->resolveDependencies($this->hash);
     $packages = $this->buildPackageData();
     $resources = $this->getResources();
     // send JSON response
     $json = JSON::encode(array($packages, $resources));
     header('Content-type: application/json');
     echo $json;
     exit;
 }
예제 #30
0
/**
 * 创建一个JSON格式的数据
 *
 * @access  public
 * @param   string      $content
 * @param   integer     $error
 * @param   string      $message
 * @param   array       $append
 * @return  void
 */
function make_json_response($content = '', $error = "0", $message = '', $append = array())
{
    include_once ROOT_PATH . 'includes/cls_json.php';
    $json = new JSON();
    $res = array('error' => $error, 'message' => $message, 'content' => $content);
    if (!empty($append)) {
        foreach ($append as $key => $val) {
            $res[$key] = $val;
        }
    }
    $val = $json->encode($res);
    exit($val);
}