当前位置: 首页>>代码示例>>PHP>>正文


PHP utils::encodeRequest方法代码示例

本文整理汇总了PHP中utils::encodeRequest方法的典型用法代码示例。如果您正苦于以下问题:PHP utils::encodeRequest方法的具体用法?PHP utils::encodeRequest怎么用?PHP utils::encodeRequest使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在utils的用法示例。


在下文中一共展示了utils::encodeRequest方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: testCreatePush

 public function testCreatePush()
 {
     $this->assertTrue($this->p2pBot1->createPush('PushCity11', '[[Category:titi]]'), 'failed to create push PushCity : (' . $this->p2pBot1->bot->results . ')');
     assertPageExist($this->p2pBot1->bot->wikiServer, 'PushFeed:PushCity11');
     // assert that patch contains is ok
     $pushFound = getSemanticRequest($this->p2pBot1->bot->wikiServer, '[[name::PushFeed:PushCity11]]', '-3Fname/-3FhasSemanticQuery');
     $this->assertEquals('PushFeed:PushCity11', $pushFound[0], 'Create push PushCity error, push name must be PushFeed:PushCity but ' . $pushFound[0] . ' was found');
     $this->assertEquals(utils::encodeRequest('[[Category:titi]]'), $pushFound[1], 'Create push PushCity error, semantic request must be [[Category:city]] but ' . utils::decodeRequest($pushFound[1]) . ' was found');
 }
开发者ID:realsoc,项目名称:mediawiki-extensions,代码行数:9,代码来源:pushTest.php

示例2: getSemanticRequest

function getSemanticRequest($server, $request, $param, $sep = '!')
{
    $request = utils::encodeRequest($request);
    $url = $server . '/index.php/Special:Ask/' . $request . '/' . $param . '/format=csv/sep=' . $sep . '/limit=100';
    $php = file_get_contents($server . '/index.php/Special:Ask/' . $request . '/' . $param . '/headers=hide/format=csv/sep=' . $sep . '/limit=100');
    $array = explode($sep, substr($php, 0, -1));
    if (count($array) == 1) {
        return $array;
    }
    $arrayRes[] = $array[1];
    for ($i = 2; $i < count($array); $i++) {
        $arrayRes[] = ereg_replace('"', '', $array[$i]);
    }
    return $arrayRes;
}
开发者ID:hala54,项目名称:DSMW,代码行数:15,代码来源:p2pAssert.php

示例3: onUnknownAction

 /**
  * MW Hook used to redirect to page creation (pushfeed, pullfeed, changeset),
  * to forms or to push/pull action testing the action param
  *
  * @since 1.1
  *
  * @param string $action
  * @param Article $article
  *
  * @return true
  */
 public function onUnknownAction($action, Article $article)
 {
     global $wgOut, $wgServerName, $wgScriptPath, $wgUser, $wgScriptExtension, $wgDSMWIP;
     $urlServer = 'http://' . $wgServerName . $wgScriptPath . "/index{$wgScriptExtension}";
     $urlAjax = 'http://' . $wgServerName . $wgScriptPath;
     ///////// / pull form page////////
     if (isset($_GET['action']) && $_GET['action'] == 'addpullpage') {
         wfDebugLog('p2p', 'addPullPage ');
         $newtext = "Add a new site:\n\t<div id='dsmw' style=\"color:green;\"></div>\n\n\t{{#form:action=" . $urlServer . "?action=pullpage|method=POST|\n\t\tPushFeed Url: {{#input:type=button|value=Url test|onClick=\n\t\tvar url = document.getElementsByName('url')[0].value;\n\t\tif(url.indexOf('PushFeed')==-1){\n\t\t\talert('No valid PushFeed syntax, see example.');\n\t\t}else{\n\t\t\tvar urlTmp = url.substring( 0, url.indexOf( 'PushFeed' ) );\n\t\t\t//alert(urlTmp);\n\n\t\t\tvar pos1 = urlTmp.indexOf( 'index.php' );\n\t\t\t//alert( pos1 );\n\t\t\tvar pushUrl='';\n\t\t\tif( pos1 != -1 ){\n\t\t\t\tpushUrl = urlTmp.substring(0,pos1);\n\t\t\t\t//alert('if');\n\t\t\t} else {\n\t\t\t\tpushUrl = urlTmp;\n\t\t\t\t//alert('else');\n\t\t\t}\n\t\t\t//alert(pushUrl);\n\n\t\t\t//alert(pushUrl+'api.php?action=query&meta=patch&papatchId=1&format=xml');\n\t\t\tvar xhr_object = null;\n\n\t\t\tif( window.XMLHttpRequest ) { // Firefox\n\t\t\t\txhr_object = new XMLHttpRequest();\n\t\t\t}else if( window.ActiveXObject ) { // Internet Explorer\n\t\t\t\txhr_object = new ActiveXObject('Microsoft.XMLHTTP');\n\t\t\t} else {\n\t\t\t\talert('Votre navigateur ne supporte pas les objets XMLHTTPRequest...');\n\t\t\t\treturn;\n\t\t\t}\n\t\t\ttry {\n\t\t\t\txhr_object.open('GET', '" . $urlAjax . "/extensions/DSMW/files/ajax.php?url='+escape(pushUrl+'api.php?action=query&meta=patch&papatchId=1&format=xml'), true);\n\t\t\t} catch( e ) {\n\t\t\t\t//alert('There is no DSMW Server responding at this URL');\n\t\t\t\tdocument.getElementById('dsmw').innerHTML = 'There is no DSMW Server responding at this URL!';\n\t\t\t\tdocument.getElementById('dsmw').style.color = 'red';\n\t\t\t}\n\t\t\txhr_object.onreadystatechange = function() {\n\n\t\t\tif( xhr_object.readyState == 4 ) {\n\t\t\t\tif( xhr_object.statusText=='OK' ){\n\t\t\t\t\tif( xhr_object.responseText == 'true' ){\n\t\t\t\t\t\t//alert('URL valid, there is a DSMW Server responding');\n\t\t\t\t\t\tdocument.getElementById('dsmw').innerHTML = 'URL valid, there is a DSMW Server responding!';\n\t\t\t\t\t\tdocument.getElementById('dsmw').style.color = 'green';\n\t\t\t\t\t} else{ //alert('There is no DSMW Server responding at this URL');\n\t\t\t\t\t\tdocument.getElementById('dsmw').innerHTML = 'There is no DSMW Server responding at this URL!';\n\t\t\t\t\t\tdocument.getElementById('dsmw').style.color = 'red';\n\t\t\t\t\t}\n\t\t\t\t} else{\n\t\t\t\t\t//alert('There is no DSMW Server responding at this URL');\n\t\t\t\t\tdocument.getElementById('dsmw').innerHTML = 'There is no DSMW Server responding at this URL!';\n\t\t\t\t\tdocument.getElementById('dsmw').style.color = 'red';\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\txhr_object.send(null);\n\t}\n\t}}<br>        {{#input:type=text|name=url|size=50}} <b>e.g. http://server/path/index.php?title=PushFeed:PushName</b><br>\n\tPullFeed Name:   <br>    {{#input:type=text|name=pullname}}<br>\n\t{{#input:type=submit|value=ADD}}\n\t}}";
         $article->doEdit($newtext, $summary = "");
         $wgOut->redirect($article->getTitle()->getFullURL());
         return false;
     } elseif (isset($_GET['action']) && $_GET['action'] == 'addpushpage') {
         wfDebugLog('p2p', 'addPushPage');
         $specialAsk = $urlServer . '?title=Special:Ask';
         $newtext = "Add a new pushfeed:\n\n\t{{#form:action=" . $urlServer . "?action=pushpage|method=POST|\n\tPushFeed Name:   <br>    {{#input:class=test|name=name|type=text|onKeyUp=test('{$urlServer}');}}<div style=\"display:inline; \" id=\"state\" ></div><br />\n\tRequest: {{#input:type=button|value=Test your query|title=click here to test your query results|onClick=\n\tvar query = document.getElementsByName('keyword')[0].value;\n\tvar query1 = encodeURI(query);\n\twindow.open('" . $specialAsk . "&q='+query1+'&eq=yes&p%5Bformat%5D=broadtable','querywindow','menubar=no, status=no, scrollbars=yes, menubar=no, width=1000, height=900');}}\n\t  <br>{{#input:type=textarea|cols=30 | style=width:auto |rows=2|name=keyword}} <b>e.g. [[Category:city]][[locatedIn::France]]</b><br>\n\t{{#input:type=submit|value=ADD}}\n\t}}";
         $article->doEdit($newtext, $summary = "");
         $wgOut->redirect($article->getTitle()->getFullURL());
         return false;
     } elseif (isset($_GET['action']) && $_GET['action'] == 'pushpage') {
         // $url = $_POST['url'];//pas url mais changesetId
         wfDebugLog('p2p', 'Create new push ' . $_POST['name'] . ' with ' . $_POST['keyword']);
         $name = $_POST['name'];
         $request = $_POST['keyword'];
         $stringReq = utils::encodeRequest($request);
         // avoid "semantic injection" :))
         // addPushSite($url, $name, $request);
         $newtext = "\n[[Special:ArticleAdminPage|DSMW Admin functions]]\n\n==Features==\n[[name::PushFeed:" . $name . "| ]]\n'''Semantic query:''' [[hasSemanticQuery::" . $stringReq . "| ]]<nowiki>" . $request . "</nowiki>\n\n'''Pages concerned:'''\n{{#ask: " . $request . "}}\n[[deleted::false| ]]\n\n==Actions==\n\n{{#input:type=ajax|value=PUSH|onClick=pushpull('" . $urlServer . "','PushFeed:" . $name . "', 'onpush');}}\nThe \"PUSH\" action publishes the (unpublished) modifications of the articles listed above.\n\n== PUSH Progress : ==\n<div id=\"state\" ></div><br />\n";
         wfDebugLog('p2p', '  -> push page contains : ' . $newtext);
         $title = Title::newFromText($_POST['name'], PUSHFEED);
         $article = new Article($title);
         $edit = $article->doEdit($newtext, $summary = "");
         $wgOut->redirect($title->getFullURL());
         return false;
     } elseif (isset($_POST['action']) && $_POST['action'] == 'onpush') {
         /* In case we push directly from an article page */
         if (isset($_POST['page']) && isset($_POST['request'])) {
             $articlename = Title::newFromText($_POST['name']);
             if (!$articlename->exists()) {
                 $result = utils::createPushFeed($_POST['name'], $_POST['request']);
                 utils::writeAndFlush("Create push <A HREF=" . 'http://' . $wgServerName . $wgScriptPath . "/index.php?title=" . $_POST['name'] . ">" . $_POST['name'] . "</a>");
                 if ($result == false) {
                     throw new MWException(__METHOD__ . ': no Pushfeed created in utils:: createPushFeed: ' . 'name: ' . $_POST['name'] . ' request' . $_POST['request']);
                 }
             }
         }
         wfDebugLog('p2p', 'push on ');
         $patches = array();
         $tmpPatches = array();
         if (isset($_POST['name'])) {
             $name1 = $_POST['name'];
             if (!is_array($name1)) {
                 $name1 = array($name1);
             }
             foreach ($name1 as $push) {
                 wfDebugLog('p2p', ' - ' . $push);
             }
         } else {
             $name1 = '';
         }
         if ($name1 == '') {
             utils::writeAndFlush('<p><b>No pushfeed selected!</b></p>');
             $title = Title::newFromText('Special:ArticleAdminPage');
             $wgOut->redirect($title->getFullURL());
             return false;
         }
         // $name = $name1[0];
         utils::writeAndFlush('<p><b>Start push </b></p>');
         foreach ($name1 as $name) {
             utils::writeAndFlush("<span style=\"margin-left:30px;\">begin push: <A HREF=" . 'http://' . $wgServerName . $wgScriptPath . "/index.php?title={$name}>" . $name . "</a></span> <br/>");
             $patches = array();
             // / / for each pushfeed name==> push
             wfDebugLog('p2p', '  -> pushname ' . $name);
             // $name = $_GET['name'];//PushFeed name
             $request = getPushFeedRequest($name);
             // $previousCSID = getPreviousCSID($name);
             $previousCSID = getHasPushHead($name);
             if ($previousCSID == false) {
                 $previousCSID = "none";
                 // $CSID = $name."_0";
             }
             // else{
             //	$count = explode(" ", $previousCSID);
             //	$cnt = $count[1] + 1;
             //	$CSID = $name."_".$cnt;
             // }
             wfDebugLog('p2p', '  ->pushrequest ' . $request);
             wfDebugLog('p2p', '  ->pushHead : ' . $previousCSID);
             $CSID = utils::generateID();
//.........这里部分代码省略.........
开发者ID:realsoc,项目名称:mediawiki-extensions,代码行数:101,代码来源:DSMW.hooks.php

示例4: createPushFeed

 /**
  * Creates a pushfeed
  *
  * @global <String> $wgServerName
  * @global <String> $wgScriptPath
  * @param <String> $name pushfeed name
  * @param <String> $request
  * @return <bool> true if creation successful, false if not
  */
 static function createPushFeed($name, $request)
 {
     global $wgServerName, $wgScriptPath, $wgScriptExtension;
     $urlServer = 'http://' . $wgServerName . $wgScriptPath . "/index{$wgScriptExtension}";
     $stringReq = utils::encodeRequest($request);
     //avoid "semantic injection"
     $newtext = "\n{{#form:action=" . $urlServer . "?action=onpush|method=POST|\n{{#input:type=hidden|name=push|value=" . $name . "}}<br>\n{{#input:type=hidden|name=action|value=onpush}}<br>\n{{#input:type=submit|value=PUSH}}\n}}\n----\n[[Special:ArticleAdminPage]]\n----\nPushFeed:\nName: [[name::" . $name . "]]\nhasSemanticQuery: [[hasSemanticQuery::" . $stringReq . "]]\nPages concerned:\n{{#ask: " . $request . "}}\n[[deleted::false| ]]\n";
     wfDebugLog('p2p', '  -> push page contains : ' . $newtext);
     $title = Title::newFromText($name, PUSHFEED);
     $article = new Article($title);
     $status = $article->doEdit($newtext, $summary = "");
     if (is_bool($status) && $status || is_object($status) && $status->isGood()) {
         return true;
     } else {
         return false;
     }
 }
开发者ID:hala54,项目名称:DSMW,代码行数:26,代码来源:utils.php


注:本文中的utils::encodeRequest方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。