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


PHP AjaxResponse类代码示例

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


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

示例1: performAction

 function performAction()
 {
     global $wgAjaxExportList, $wgOut;
     if (empty($this->mode)) {
         return;
     }
     wfProfileIn(__METHOD__);
     if (!in_array($this->func_name, $wgAjaxExportList)) {
         wfHttpError(400, 'Bad Request', "unknown function " . (string) $this->func_name);
     } else {
         try {
             $result = call_user_func_array($this->func_name, $this->args);
             if ($result === false || $result === NULL) {
                 wfHttpError(500, 'Internal Error', "{$this->func_name} returned no data");
             } else {
                 if (is_string($result)) {
                     $result = new AjaxResponse($result);
                 }
                 $result->sendHeaders();
                 $result->printText();
             }
         } catch (Exception $e) {
             if (!headers_sent()) {
                 wfHttpError(500, 'Internal Error', $e->getMessage());
             } else {
                 print $e->getMessage();
             }
         }
     }
     wfProfileOut(__METHOD__);
     $wgOut = null;
 }
开发者ID:negabaro,项目名称:alfresco,代码行数:32,代码来源:AjaxDispatcher.php

示例2: executeUpload

 public function executeUpload()
 {
     $upload_max_filesize = str_replace('M', '', ini_get('upload_max_filesize'));
     $res = new \AjaxResponse();
     $upload_dir = PUBLIC_DIR . '/media/editor_upload/';
     Folder::create($upload_dir, 0777);
     $error = array();
     $fileUploader = new Uploader($upload_dir, 'file_upload');
     $fileUploader->setMaximumFileSize($upload_max_filesize);
     $fileUploader->setFilterType('.jpg, .jpeg, .png, .bmp, .gif');
     $fileUploader->setIsEncryptFileName(true);
     if ($fileUploader->upload('file_upload')) {
         $data = $fileUploader->getData();
         $file_path = '/media/editor_upload/' . $data['file_name'];
         $file_url = rtrim($this->document()->getBaseUrl(), '/') . preg_replace('/(\\/+)/', '/', '/../' . $file_path);
         $image = ['file_name' => $data['file_name'], 'url' => $file_url, 'path' => $file_path];
         $res->type = \AjaxResponse::SUCCESS;
         $res->image = $image;
         return $this->renderText($res->toString());
     } else {
         $error['upload'] = $fileUploader->getError();
     }
     $res->type = \AjaxResponse::ERROR;
     $res->error = $error;
     return $this->renderText($res->toString());
 }
开发者ID:hosivan90,项目名称:toxotes,代码行数:26,代码来源:Media.php

示例3: saveOrder

 function saveOrder($xmlsd)
 {
     global $reporterOrderTable, $readerOrderTable, $editorOrderTable;
     $response = new AjaxResponse();
     $response->setContentType('text/plain');
     $xmlstr = '' . html_entity_decode($xmlsd);
     $dbr =& wfGetDB(DB_WRITE);
     $xml = new SimpleXMLElement($xmlstr);
     //delete all in table
     $result = $dbr->delete($editorOrderTable, "*");
     $result = $dbr->delete($readerOrderTable, "*");
     $result = $dbr->delete($reporterOrderTable, "*");
     foreach ($xml->children() as $child) {
         if ($child->getName() == 'Editor') {
             $sql = 'INSERT INTO ' . $editorOrderTable . ' (id, rank) VALUES (' . $child['id'] . ',' . $child['rank'] . ')';
             $result = $dbr->query($sql);
         } elseif ($child->getName() == 'Reader') {
             $sql = 'INSERT INTO ' . $readerOrderTable . ' (id, rank) VALUES (' . $child['id'] . ',' . $child['rank'] . ')';
             $result = $dbr->query($sql);
         } elseif ($child->getName() == 'Reporter') {
             $sql = 'INSERT INTO ' . $reporterOrderTable . ' (id, rank) VALUES (' . $child['id'] . ',' . $child['rank'] . ')';
             $result = $dbr->query($sql);
         }
     }
     $response->addtext("Changes Saved");
     return $response;
 }
开发者ID:BenoitTalbot,项目名称:bungeni-portal,代码行数:27,代码来源:MV_Staff.php

示例4: performAction

 function performAction()
 {
     global $wgAjaxExportList, $wgOut;
     if (empty($this->mode)) {
         return;
     }
     wfProfileIn('AjaxDispatcher::performAction');
     if (!in_array($this->func_name, $wgAjaxExportList)) {
         header('Status: 400 Bad Request', true, 400);
         print "unknown function " . htmlspecialchars((string) $this->func_name);
     } else {
         try {
             $result = call_user_func_array($this->func_name, $this->args);
             if ($result === false || $result === NULL) {
                 header('Status: 500 Internal Error', true, 500);
                 echo "{$this->func_name} returned no data";
             } else {
                 if (is_string($result)) {
                     $result = new AjaxResponse($result);
                 }
                 $result->sendHeaders();
                 $result->printText();
             }
         } catch (Exception $e) {
             if (!headers_sent()) {
                 header('Status: 500 Internal Error', true, 500);
                 print $e->getMessage();
             } else {
                 print $e->getMessage();
             }
         }
     }
     wfProfileOut('AjaxDispatcher::performAction');
     $wgOut = null;
 }
开发者ID:puring0815,项目名称:OpenKore,代码行数:35,代码来源:AjaxDispatcher.php

示例5: wfTalkHereAjaxEditor

function wfTalkHereAjaxEditor( $page, $section, $returnto ) {
	global $wgRequest, $wgTitle, $wgOut;

	$title = Title::newFromText( $page );
	if ( !$title ) {
		return false;
	}

	//fake editor environment
	$args = array(
		'wpTalkHere' => '1',
		'wpReturnTo' => $returnto,
		'action' => 'edit',
		'section' => $section
	);

	$wgRequest = new FauxRequest( $args );
	$wgTitle = $title;

	$article = Article::newFromTitle( $title, RequestContext::getMain() );
	$editor = new TalkHereEditPage( $article );

	//generate form
	$editor->importFormData( $wgRequest );
	$editor->showEditForm();

	$response = new AjaxResponse();
	$response->addText( $wgOut->getHTML() );
	$response->setCacheDuration( false ); //don't cache, because of tokens etc

	return $response;
}
开发者ID:realsoc,项目名称:mediawiki-extensions,代码行数:32,代码来源:TalkHere.php

示例6: getFogbugzServiceResponse

 /**
  *
  * cmd posible values:
  * 'getCasesInfo' - in response there will be returned set of cases and subcases info formated in WikiText
  * 'getComment' - in response there will be returned comments for particular case
  */
 public static function getFogbugzServiceResponse()
 {
     global $wgRequest, $wgHTTPProxy, $wgFogbugzAPIConfig;
     $command = $wgRequest->getText('cmd');
     $myFBService = new FogbugzService($wgFogbugzAPIConfig['apiUrl'], $wgFogbugzAPIConfig['username'], $wgFogbugzAPIConfig['password'], $wgHTTPProxy);
     // there should be made some kind of protection from setting different value as cmd
     if ($command == 'getCasesInfo') {
         $outerIDs = $wgRequest->getArray('IDs');
         $results = array();
         try {
             $results = $myFBService->logon()->getCasesBasicInfo($outerIDs);
         } catch (Exception $e) {
             $results = array();
         }
         $preparedResults = FogbugzTag::sortAndMakeTickets($results);
         $response = new AjaxResponse();
         $response->addText(json_encode($preparedResults));
     } else {
         // this part is not in use now; it will be after adding displaying comments
         $outerIDs = $wgRequest->getText('ID');
         /* ... */
     }
     if (!$response) {
         $response = new AjaxResponse();
         $response->addText(json_encode(array('status' => wfMsg('fbtag-unknown-error'))));
     }
     return $response;
 }
开发者ID:schwarer2006,项目名称:wikia,代码行数:34,代码来源:FogbugzTag.class.php

示例7: smwf_ws_callEQIXML

function smwf_ws_callEQIXML($query)
{
    global $IP;
    require_once $IP . '/extensions/SMWHalo/includes/webservices/SMW_EQI.php';
    $result = new AjaxResponse(query($query, "xml"));
    $result->setContentType("application/xml");
    return $result;
}
开发者ID:seedbank,项目名称:old-repo,代码行数:8,代码来源:SMW_WebInterfaces.php

示例8: getLinkSuggestImage

function getLinkSuggestImage()
{
    global $wgRequest;
    wfProfileIn(__METHOD__);
    $res = LinkSuggest::getLinkSuggestImage($wgRequest->getText('imageName'));
    $ar = new AjaxResponse($res);
    $ar->setCacheDuration(60 * 60);
    $ar->setContentType('text/plain; charset=utf-8');
    wfProfileOut(__METHOD__);
    return $ar;
}
开发者ID:yusufchang,项目名称:app,代码行数:11,代码来源:LinkSuggest.php

示例9: RecipesTemplateAjax

function RecipesTemplateAjax()
{
    global $wgRequest;
    $method = $wgRequest->getVal('method', false);
    if (method_exists('RecipesTemplateAjax', $method)) {
        $data = RecipesTemplateAjax::$method();
        $json = json_encode($data);
        $response = new AjaxResponse($json);
        $response->setContentType('application/json; charset=utf-8');
        return $response;
    }
}
开发者ID:Tjorriemorrie,项目名称:app,代码行数:12,代码来源:RecipesTemplate_setup.php

示例10: ajax_tags

 /**
  * Handles AJAX from /admin/tags
  * Used to delete and rename tags
  */
 public function ajax_tags($handler_vars)
 {
     Utils::check_request_method(array('POST'));
     $response = new AjaxResponse();
     $wsse = Utils::WSSE($handler_vars['nonce'], $handler_vars['timestamp']);
     if ($handler_vars['digest'] != $wsse['digest']) {
         $response->message = _t('WSSE authentication failed.');
         $response->out();
         return;
     }
     $tag_names = array();
     $this->create_theme();
     $action = $this->handler_vars['action'];
     switch ($action) {
         case 'delete':
             foreach ($_POST as $id => $delete) {
                 // skip POST elements which are not tag ids
                 if (preg_match('/^tag_\\d+/', $id) && $delete) {
                     $id = substr($id, 4);
                     $tag = Tags::get_by_id($id);
                     $tag_names[] = $tag->term_display;
                     Tags::vocabulary()->delete_term($tag);
                 }
             }
             $response->message = _n(_t('Tag %s has been deleted.', array(implode('', $tag_names))), _t('%d tags have been deleted.', array(count($tag_names))), count($tag_names));
             break;
         case 'rename':
             if (!isset($this->handler_vars['master'])) {
                 $response->message = _t('Error: New name not specified.');
                 $response->out();
                 return;
             }
             $master = $this->handler_vars['master'];
             $tag_names = array();
             foreach ($_POST as $id => $rename) {
                 // skip POST elements which are not tag ids
                 if (preg_match('/^tag_\\d+/', $id) && $rename) {
                     $id = substr($id, 4);
                     $tag = Tags::get_by_id($id);
                     $tag_names[] = $tag->term_display;
                 }
             }
             Tags::vocabulary()->merge($master, $tag_names);
             $response->message = sprintf(_n('Tag %1$s has been renamed to %2$s.', 'Tags %1$s have been renamed to %2$s.', count($tag_names)), implode($tag_names, ', '), $master);
             break;
     }
     $this->theme->tags = Tags::vocabulary()->get_tree('term_display ASC');
     $this->theme->max = Tags::vocabulary()->max_count();
     $response->data = $this->theme->fetch('tag_collection');
     $response->out();
 }
开发者ID:wwxgitcat,项目名称:habari,代码行数:55,代码来源:admintagshandler.php

示例11: error

 protected function error($msg)
 {
     $this->setNoRender();
     $this->_request->setDispatched(true);
     if ($this->_request->isXmlHttpRequest()) {
         $arp = new AjaxResponse();
         $arp->setStatus(AjaxResponse::STATUS_FAILED);
         $arp->setMessage($msg);
         $this->json($arp);
     } else {
         $this->view->msg = $msg;
         $this->renderScript('common/error.phtml');
     }
 }
开发者ID:RobertCar,项目名称:RobertCarrential,代码行数:14,代码来源:ControllerAbstract.php

示例12: VET

function VET()
{
    global $wgRequest;
    $method = $wgRequest->getVal('method');
    $vet = new VideoEmbedTool();
    $html = $vet->{$method}();
    $domain = $wgRequest->getVal('domain', null);
    if (!empty($domain)) {
        $html .= '<script type="text/javascript">document.domain = "' . $domain . '"</script>';
    }
    $resp = new AjaxResponse($html);
    $resp->setContentType('text/html');
    return $resp;
}
开发者ID:Tjorriemorrie,项目名称:app,代码行数:14,代码来源:VideoEmbedTool_setup.php

示例13: playerAjaxHandler

function playerAjaxHandler($file, $options)
{
    $response = new AjaxResponse();
    try {
        #TODO: caching!
        $player = Player::newFromName($file, $options, 'thumbsize');
        $html = $player->getPlayerHTML();
        $response->addText($html);
    } catch (PlayerException $ex) {
        $response->setResponseCode($ex->getHTTPCode());
        $response->addText($ex->getHTML());
    }
    return $response;
}
开发者ID:Tjorriemorrie,项目名称:app,代码行数:14,代码来源:Player.php

示例14: MyHomeAjax

function MyHomeAjax()
{
    global $wgRequest;
    $method = $wgRequest->getVal('method', false);
    if (method_exists('MyHomeAjax', $method)) {
        wfProfileIn(__METHOD__);
        $data = MyHomeAjax::$method();
        $json = json_encode($data);
        $response = new AjaxResponse($json);
        $response->setContentType('application/json; charset=utf-8');
        wfProfileOut(__METHOD__);
        return $response;
    }
}
开发者ID:Tjorriemorrie,项目名称:app,代码行数:14,代码来源:MyHome.php

示例15: ajax

 /**
  * Ajax call. This is called by efCategoryTreeAjaxWrapper, which is used to
  * load CategoryTreeFunctions.php on demand.
  */
 function ajax($category, $mode)
 {
     global $wgDBname;
     $title = self::makeTitle($category);
     if (!$title) {
         return false;
     }
     #TODO: error message?
     $this->mIsAjaxRequest = true;
     # Retrieve page_touched for the category
     $dbkey = $title->getDBkey();
     $dbr =& wfGetDB(DB_SLAVE);
     $touched = $dbr->selectField('page', 'page_touched', array('page_namespace' => NS_CATEGORY, 'page_title' => $dbkey), __METHOD__);
     $mckey = "{$wgDBname}:categorytree({$mode}):{$dbkey}";
     //FIXME: would need to add depth parameter.
     $response = new AjaxResponse();
     if ($response->checkLastModified($touched)) {
         return $response;
     }
     if ($response->loadFromMemcached($mckey, $touched)) {
         return $response;
     }
     $html = $this->renderChildren($title, $mode);
     //FIXME: would need to pass depth parameter.
     if ($html == '') {
         $html = ' ';
     }
     #HACK: Safari doesn't like empty responses.
     #see Bug 7219 and http://bugzilla.opendarwin.org/show_bug.cgi?id=10716
     $response->addText($html);
     $response->storeInMemcached($mckey, 86400);
     return $response;
 }
开发者ID:BackupTheBerlios,项目名称:shoutwiki-svn,代码行数:37,代码来源:CategoryTreeFunctions.php


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