Example #1
1
/**
 * 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);
}
Example #2
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);
 }
Example #3
0
 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;
 }
 /**
  * Remotely set a user setting.
  * @param $args array
  * @param $request PKPRequest
  * @return string a JSON message
  */
 function setUserSetting($args, &$request)
 {
     // Retrieve the user from the session.
     $user =& $request->getUser();
     assert(is_a($user, 'User'));
     // Exit with an error if request parameters are missing.
     if (!isset($args['setting-name']) && isset($args['setting-value'])) {
         $json = new JSON('false', 'Required request parameter "setting-name" or "setting-value" missing!');
         return $json->getString();
     }
     // Validate the setting.
     $settingName = $args['setting-name'];
     $settingValue = $args['setting-value'];
     $settingType = $this->_settingType($settingName);
     switch ($settingType) {
         case 'bool':
             if (!($settingValue === 'false' || $settingValue === 'true')) {
                 $json = new JSON('false', 'Invalid setting value! Must be "true" or "false".');
                 return $json->getString();
             }
             $settingValue = $settingValue === 'true' ? true : false;
             break;
         default:
             // Exit with a fatal error when an unknown setting is found.
             $json = new JSON('false', 'Unknown setting!');
             return $json->getString();
     }
     // Persist the validated setting.
     $userSettingsDAO =& DAORegistry::getDAO('UserSettingsDAO');
     $userSettingsDAO->updateSetting($user->getId(), $settingName, $settingValue, $settingType);
     // Return a success message.
     $json = new JSON('true');
     return $json->getString();
 }
Example #5
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();
 }
Example #6
0
/**
 * 功能:与 ECShop 交换数据
 *
 * @param   array     $certi    登录参数
 * @param   array     $license  网店license信息
 * @param   bool      $use_lib  使用哪一个json库,0为ec,1为shopex
 * @return  array
 */
function exchange_shop_license($certi, $license, $use_lib = 0)
{
    if (!is_array($certi)) {
        return array();
    }
    include_once ROOT_PATH . 'includes/cls_transport.php';
    include_once ROOT_PATH . 'includes/cls_json.php';
    $params = '';
    foreach ($certi as $key => $value) {
        $params .= '&' . $key . '=' . $value;
    }
    $params = trim($params, '&');
    $transport = new transport();
    //$transport->connect_timeout = 1;
    $request = $transport->request($license['certi'], $params, 'POST');
    $request_str = json_str_iconv($request['body']);
    if (empty($use_lib)) {
        $json = new JSON();
        $request_arr = $json->decode($request_str, 1);
    } else {
        include_once ROOT_PATH . 'includes/shopex_json.php';
        $request_arr = json_decode($request_str, 1);
    }
    return $request_arr;
}
Example #7
0
 /**
  * 针对return_url验证消息是否是连连支付发出的合法消息
  * @return  验证结果
  */
 function verifyReturn()
 {
     if (empty($_POST)) {
         //判断POST来的数组是否为空
         return false;
     } else {
         $res_data = $_POST["res_data"];
         //  file_put_contents("log.txt", "返回结果:" . $res_data . "\n", FILE_APPEND);
         $json = new JSON();
         //error_reporting(3);
         //商户编号
         $oid_partner = $json->decode($res_data)->{'oid_partner'};
         //首先对获得的商户号进行比对
         if (trim($oid_partner) != $this->llpay_config['oid_partner']) {
             //商户号错误
             return false;
         }
         //生成签名结果
         $parameter = array('oid_partner' => $oid_partner, 'sign_type' => $json->decode($res_data)->{'sign_type'}, 'dt_order' => $json->decode($res_data)->{'dt_order'}, 'no_order' => $json->decode($res_data)->{'no_order'}, 'oid_paybill' => $json->decode($res_data)->{'oid_paybill'}, 'money_order' => $json->decode($res_data)->{'money_order'}, 'result_pay' => $json->decode($res_data)->{'result_pay'}, 'settle_date' => $json->decode($res_data)->{'settle_date'}, 'info_order' => $json->decode($res_data)->{'info_order'}, 'pay_type' => $json->decode($res_data)->{'pay_type'}, 'bank_code' => $json->decode($res_data)->{'bank_code'});
         if (!$this->getSignVeryfy($parameter, $json->decode($res_data)->{'sign'})) {
             return false;
         }
         return true;
     }
 }
Example #8
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));
     }
 }
Example #9
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;
}
 /**
  * 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);
 }
Example #11
0
 public function testDecoding()
 {
     $formatter = new JSON();
     $data = (object) array('name' => 'Joe', 'age' => 21, 'employed' => true);
     $raw = '{"name":"Joe","age":21,"employed":true}';
     $this->assertEquals($data, $formatter->decode($raw));
 }
Example #12
0
 /**
  * Delete a file or revision
  * @param $args array
  * @param $request Request
  * @return string a serialized JSON object
  */
 function deleteFile($args, &$request)
 {
     // FIXME: authorize!
     $fileId = (int) $request->getUserVar('fileId');
     $success = false;
     if ($fileId) {
         // Delete all revisions or only one?
         $revision = $request->getUserVar('revision') ? (int) $request->getUserVar('revision') : null;
         // Delete the file/revision but only when it belongs to the authorized monograph
         // and to the right file stage.
         $monograph =& $this->getMonograph();
         $submissionFileDao =& DAORegistry::getDAO('SubmissionFileDAO');
         /* @var $submissionFileDao SubmissionFileDAO */
         if ($revision) {
             $success = (bool) $submissionFileDao->deleteRevisionById($fileId, $revision, $this->getFileStage(), $monograph->getId());
         } else {
             $success = (bool) $submissionFileDao->deleteAllRevisionsById($fileId, $this->getFileStage(), $monograph->getId());
         }
     }
     if ($success) {
         return DAO::getDataChangedEvent($fileId);
     } else {
         $json = new JSON(false);
         return $json->getString();
     }
 }
Example #13
0
 /**
  * 针对notify_url验证消息是否是连连支付发出的合法消息
  * @return 验证结果
  */
 function verifyNotify()
 {
     //生成签名结果
     $is_notify = true;
     include_once 'llpay_cls_json.php';
     $json = new JSON();
     $str = file_get_contents("php://input");
     $val = $json->decode($str);
     $oid_partner = trim($val->{'oid_partner'});
     $sign_type = trim($val->{'sign_type'});
     $sign = trim($val->{'sign'});
     $dt_order = trim($val->{'dt_order'});
     $no_order = trim($val->{'no_order'});
     $oid_paybill = trim($val->{'oid_paybill'});
     $money_order = trim($val->{'money_order'});
     $result_pay = trim($val->{'result_pay'});
     $settle_date = trim($val->{'settle_date'});
     $info_order = trim($val->{'info_order'});
     $pay_type = trim($val->{'pay_type'});
     $bank_code = trim($val->{'bank_code'});
     $no_agree = trim($val->{'no_agree'});
     $id_type = trim($val->{'id_type'});
     $id_no = trim($val->{'id_no'});
     $acct_name = trim($val->{'acct_name'});
     //首先对获得的商户号进行比对
     if ($oid_partner != $this->llpay_config['oid_partner']) {
         //商户号错误
         return false;
     }
     $parameter = array('oid_partner' => $oid_partner, 'sign_type' => $sign_type, 'dt_order' => $dt_order, 'no_order' => $no_order, 'oid_paybill' => $oid_paybill, 'money_order' => $money_order, 'result_pay' => $result_pay, 'settle_date' => $settle_date, 'info_order' => $info_order, 'pay_type' => $pay_type, 'bank_code' => $bank_code, 'no_agree' => $no_agree, 'id_type' => $id_type, 'id_no' => $id_no, 'acct_name' => $acct_name);
     if (!$this->getSignVeryfy($parameter, $sign)) {
         return false;
     }
     return true;
 }
Example #14
0
 function __register_template()
 {
     global $conf;
     if (!empty($_REQUEST['q'])) {
         require_once DOKU_INC . 'inc/JSON.php';
         $json = new JSON();
         $tempREQUEST = (array) $json->dec(stripslashes($_REQUEST['q']));
     } else {
         if (!empty($_REQUEST['template'])) {
             $tempREQUEST = $_REQUEST;
         } else {
             if (preg_match("/(js|css)\\.php\$/", $_SERVER['SCRIPT_NAME']) && isset($_SERVER['HTTP_REFERER'])) {
                 // this is a css or script, nothing before matched and we have a referrer.
                 // lets asume we came from the dokuwiki page.
                 // Parse the Referrer URL
                 $url = parse_url($_SERVER['HTTP_REFERER']);
                 parse_str($url['query'], $tempREQUEST);
             } else {
                 return;
             }
         }
     }
     // define Template baseURL
     if (empty($tempREQUEST['template'])) {
         return;
     }
     $tplDir = DOKU_INC . 'lib/tpl/' . $tempREQUEST['template'] . '/';
     if (!file_exists($tplDir)) {
         return;
     }
     // Set hint for Dokuwiki_Started event
     if (!defined('SITEEXPORT_TPL')) {
         define('SITEEXPORT_TPL', $tempREQUEST['template']);
     }
     // define baseURL
     // This should be DEPRECATED - as it is in init.php which suggest tpl_basedir and tpl_incdir
     /* **************************************************************************************** */
     if (!defined('DOKU_REL')) {
         define('DOKU_REL', getBaseURL(false));
     }
     if (!defined('DOKU_URL')) {
         define('DOKU_URL', getBaseURL(true));
     }
     if (!defined('DOKU_BASE')) {
         if (isset($conf['canonical'])) {
             define('DOKU_BASE', DOKU_URL);
         } else {
             define('DOKU_BASE', DOKU_REL);
         }
     }
     // This should be DEPRECATED - as it is in init.php which suggest tpl_basedir and tpl_incdir
     if (!defined('DOKU_TPL')) {
         define('DOKU_TPL', (empty($tempREQUEST['base']) ? DOKU_BASE : $tempREQUEST['base']) . 'lib/tpl/' . $tempREQUEST['template'] . '/');
     }
     if (!defined('DOKU_TPLINC')) {
         define('DOKU_TPLINC', $tplDir);
     }
     /* **************************************************************************************** */
 }
function authorstatsReadJSON()
{
    $json = new JSON(JSON_LOOSE_TYPE);
    $file = @file_get_contents(DOKU_PLUGIN . "authorstats/authorstats.json");
    if (!$file) {
        return array();
    }
    return $json->decode($file);
}
Example #16
0
 /**
  * Pass in a JSON object to return it back as
  * an associative array
  * @param JSON $json
  */
 public static function &jsonToArray(JSON $json)
 {
     $array = array();
     for ($i = 0; $json->getCount() > $i; $i++) {
         $item = $json->itemAt($i);
         $array[$item->getProperty()] = $item->getValue();
     }
     return $array;
 }
 /**
  * Show the form to allow the user to select review files
  * (bring in/take out files from submission stage to review stage)
  *
  * FIXME: Move to it's own handler so that it can be re-used among grids.
  *
  * @param $args array
  * @param $request PKPRequest
  * @return string Serialized JSON object
  */
 function selectFiles($args, &$request)
 {
     $monograph =& $this->getMonograph();
     import('controllers.grid.files.review.form.ManageReviewFilesForm');
     $manageReviewFilesForm = new ManageReviewFilesForm($monograph->getId(), $this->getRequestArg('reviewType'), $this->getRequestArg('round'));
     $manageReviewFilesForm->initData($args, $request);
     $json = new JSON(true, $manageReviewFilesForm->fetch($request));
     return $json->getString();
 }
 /**
  * Read config
  *
  * @return bool|mixed
  */
 protected function loadCBData()
 {
     $json = new JSON(JSON_LOOSE_TYPE);
     $file = @file_get_contents(DOKU_PLUGIN . "custombuttons/config.json");
     if (!$file) {
         return false;
     }
     return $json->decode($file);
 }
Example #19
0
function showpageafterlogin_read_json()
{
    $json = new JSON(JSON_LOOSE_TYPE);
    $file = @file_get_contents(DOKU_PLUGIN . "showpageafterlogin/showpageafterlogincount.json");
    if (!$file) {
        return array();
    }
    return $json->decode($file);
}
 /**
  * Retrieve the user's data
  *
  * The array needs to contain at least 'user', 'mail', 'name' and optional 'grps'
  *
  * @return array
  */
 public function getUser()
 {
     $JSON = new \JSON(JSON_LOOSE_TYPE);
     $data = array();
     $result = $JSON->decode($this->oAuth->request('https://kelder.zeus.ugent.be/oauth/api/current_user?format=json'));
     $data['user'] = $result['username'];
     $data['name'] = $result['username'];
     $data['mail'] = $result['username'] . '@zeus.ugent.be';
     return $data;
 }
 /**
  * Retrieve the user's data
  *
  * The array needs to contain at least 'user', 'email', 'name' and optional 'grps'
  *
  * @return array
  */
 public function getUser()
 {
     $JSON = new \JSON(JSON_LOOSE_TYPE);
     $data = array();
     $result = $JSON->decode($this->oAuth->request('https://www.googleapis.com/oauth2/v1/userinfo'));
     $data['user'] = $result['name'];
     $data['name'] = $result['name'];
     $data['mail'] = $result['email'];
     return $data;
 }
 /**
  * Retrieve the user's data
  *
  * The array needs to contain at least 'user', 'mail', 'name' and optional 'grps'
  *
  * @return array
  */
 public function getUser()
 {
     $JSON = new \JSON(JSON_LOOSE_TYPE);
     $data = array();
     /** var OAuth\OAuth2\Service\Generic $this->oAuth */
     $result = $JSON->decode($this->oAuth->request('https://doorkeeper-provider.herokuapp.com/api/v1/me.json'));
     $data['user'] = '******' . $result['id'];
     $data['name'] = 'doorkeeper-' . $result['id'];
     $data['mail'] = $result['email'];
     return $data;
 }
Example #23
0
 private function parseJSON($json)
 {
     if (!extension_loaded('json')) {
         include_once dirname(__FILE__) . '/JSON.class.php';
         $json = new JSON();
         $objs = $json->unserialize($json);
     } else {
         $objs = json_decode($json);
     }
     return $objs;
 }
 /**
  * Display the submission participants grid
  * @param $args array
  * @param $request PKPRequest
  * @return string Serialized JSON object
  * @see Form::fetch()
  */
 function fetch($args, &$request)
 {
     // Identify the submission Id
     $monographId = $request->getUserVar('monographId');
     // Form handling
     import('controllers.modals.submissionParticipants.form.SubmissionParticipantsForm');
     $submissionParticipantsForm = new SubmissionParticipantsForm($monographId);
     $submissionParticipantsForm->initData($args, $request);
     $json = new JSON('true', $submissionParticipantsForm->fetch($request));
     return $json->getString();
 }
Example #25
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";
}
 /**
  * Get keywords for reviewer interests autocomplete.
  * @param $args array
  * @param $request PKPRequest
  * @return string Serialized JSON object
  */
 function getInterests($args, &$request)
 {
     // Get the input text used to filter on
     $filter = $request->getUserVar('term');
     import('lib.pkp.classes.user.InterestManager');
     $interestManager = new InterestManager();
     $interests = $interestManager->getAllInterests($filter);
     import('lib.pkp.classes.core.JSON');
     $json = new JSON(true, $interests);
     return $json->getString();
 }
Example #27
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');
 }
 /**
  * Retrieve the user's data
  *
  * The array needs to contain at least 'user', 'mail', 'name' and optional 'grps'
  *
  * @return array
  */
 public function getUser()
 {
     $JSON = new \JSON(JSON_LOOSE_TYPE);
     $data = array();
     /** var OAuth\OAuth2\Service\Generic $this->oAuth */
     $result = $JSON->decode($this->oAuth->request($this->hlp->conf['custom-meurl']));
     foreach (explode(" ", $this->hlp->conf['custom-mapping']) as $map) {
         $smap = explode("=", $map, 2);
         $data[$smap[0]] = $result[$smap[1]];
     }
     return $data;
 }
 /**
  * Display the submission's metadata
  * @return string Serialized JSON object
  * @see Form::fetch()
  * @param $args array
  * @param $request PKPRequest
  */
 function fetch($args, &$request)
 {
     // Identify the press Id
     $pressId = $request->getUserVar('pressId');
     Locale::requireComponents(array(LOCALE_COMPONENT_APPLICATION_COMMON));
     // Form handling
     import('controllers.modals.competingInterests.form.CompetingInterestsForm');
     $competingInterestsForm = new CompetingInterestsForm($pressId);
     $competingInterestsForm->initData($args, $request);
     $json = new JSON(true, $competingInterestsForm->fetch($request));
     return $json->getString();
 }
Example #30
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);
 }