• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP AjaxResponse类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: theme_route_change_sudo

 public function theme_route_change_sudo()
 {
     $form = $this->get_form();
     $user_id = $form->userlist->value;
     $user = User::get_by_id($user_id);
     if ($_SESSION['user_id'] == $user->id) {
         unset($_SESSION['sudo']);
     } else {
         $_SESSION['sudo'] = $user->id;
     }
     $ar = new AjaxResponse(200, 'Ok.');
     $ar->html('#sudo_handle', $user->displayname);
     $ar->out();
 }
开发者ID:ringmaster,项目名称:sudo,代码行数:14,代码来源:sudo.plugin.php


示例17: WMU

function WMU()
{
    global $wgRequest, $wgGroupPermissions, $wgAllowCopyUploads;
    // Overwrite configuration settings needed by image import functionality
    $wgAllowCopyUploads = true;
    $wgGroupPermissions['user']['upload_by_url'] = true;
    $dir = dirname(__FILE__) . '/';
    require_once $dir . 'WikiaMiniUpload_body.php';
    $method = $wgRequest->getVal('method');
    $wmu = new WikiaMiniUpload();
    $html = $wmu->{$method}();
    $ar = new AjaxResponse($html);
    $ar->setContentType('text/html; charset=utf-8');
    return $ar;
}
开发者ID:schwarer2006,项目名称:wikia,代码行数:15,代码来源:WikiaMiniUpload_setup.php


示例18: __construct

	/**
	 * Verifies user credentials before creating the theme and displaying the request.
	 */
	public function __construct()
	{
		$user = User::identify();
		if ( !$user->loggedin ) {
			Session::add_to_set( 'login', $_SERVER['REQUEST_URI'], 'original' );
			if ( URL::get_matched_rule()->action == 'admin_ajax' && isset( $_SERVER['HTTP_REFERER'] ) ) {
				 $ar = new AjaxResponse(408, _t('Your session has ended, please log in and try again.') );
				 $ar->out();
			}
			else {
				$post_raw = $_POST->get_array_copy_raw();
				if ( !empty( $post_raw ) ) {
					Session::add_to_set( 'last_form_data', $post_raw, 'post' );
					Session::error( _t( 'We saved the last form you posted. Log back in to continue its submission.' ), 'expired_form_submission' );
				}
				$get_raw = $_GET->get_array_copy_raw();
				if ( !empty( $get_raw ) ) {
					Session::add_to_set( 'last_form_data', $get_raw, 'get' );
					Session::error( _t( 'We saved the last form you posted. Log back in to continue its submission.' ), 'expired_form_submission' );
				}
				Utils::redirect( URL::get( 'auth', array( 'page' => 'login' ) ) );
			}
			exit;
		}

		$last_form_data = Session::get_set( 'last_form_data' ); // This was saved in the "if ( !$user )" above, UserHandler transferred it properly.
		/* At this point, Controller has not created handler_vars, so we have to modify $_POST/$_GET. */
		if ( isset( $last_form_data['post'] ) ) {
			$_POST = $_POST->merge( $last_form_data['post'] );
			$_SERVER['REQUEST_METHOD'] = 'POST'; // This will trigger the proper act_admin switches.
			Session::remove_error( 'expired_form_submission' );
		}
		if ( isset( $last_form_data['get'] ) ) {
			$_GET = $_GET->merge( $last_form_data['get'] );
			Session::remove_error( 'expired_form_submission' );
			// No need to change REQUEST_METHOD since GET is the default.
		}
		$user->remember();

		// Create an instance of the active public theme so that its plugin functions are implemented
		$this->active_theme = Themes::create();

		// setup the stacks for javascript in the admin - it's a method so a plugin can call it externally
		self::setup_stacks();
		
		// on every page load check the plugins currently loaded against the list we last checked for updates and trigger a cron if we need to
		Update::check_plugins();
	}
开发者ID:rynodivino,项目名称:system,代码行数:51,代码来源:adminhandler.php


示例19: executeRemove

 public function executeRemove()
 {
     $this->validAjaxRequest();
     $res = new \AjaxResponse();
     if (!($banner = \Banner::retrieveById($this->request()->get('id')))) {
         $res->type = \AjaxResponse::ERROR;
         $res->message = t('Banner not found');
         return $this->renderText($res->toString());
     }
     $banner->delete();
     $res->type = \AjaxResponse::SUCCESS;
     $res->id = $banner->getId();
     $res->banner = $banner->toArray();
     $res->message = t('Banner ' . $banner->getTitle() . ' was removed!');
     return $this->renderText($res->toString());
 }
开发者ID:hosivan90,项目名称:toxotes,代码行数:16,代码来源:Banner.php


示例20: HomePageListAjax

function HomePageListAjax()
{
    global $wgRequest;
    $method = $wgRequest->getVal("method", false);
    if (method_exists("HomePageList", $method)) {
        $data = HomePageList::$method(true);
        if (is_array($data)) {
            $json = json_encode($data);
            $response = new AjaxResponse($json);
            $response->setContentType("application/json; charset=utf-8");
        } else {
            $response = new AjaxResponse($data);
            $response->setContentType("text/html; charset=utf-8");
        }
        return $response;
    }
}
开发者ID:Tjorriemorrie,项目名称:app,代码行数:17,代码来源:HomePageList.php



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP AjaxResponseObject类代码示例发布时间:2022-05-23
下一篇:
PHP AjaxCompose类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap