|
1 <?php |
|
2 /** |
|
3 * Zend Framework |
|
4 * |
|
5 * LICENSE |
|
6 * |
|
7 * This source file is subject to the new BSD license that is bundled |
|
8 * with this package in the file LICENSE.txt. |
|
9 * It is also available through the world-wide-web at this URL: |
|
10 * http://framework.zend.com/license/new-bsd |
|
11 * If you did not receive a copy of the license and are unable to |
|
12 * obtain it through the world-wide-web, please send an email |
|
13 * to license@zend.com so we can send you a copy immediately. |
|
14 * |
|
15 * @category Zend |
|
16 * @package Zend_Controller |
|
17 * @subpackage Zend_Controller_Action_Helper |
|
18 * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) |
|
19 * @license http://framework.zend.com/license/new-bsd New BSD License |
|
20 * @version $Id: AjaxContext.php 20096 2010-01-06 02:05:09Z bkarwin $ |
|
21 */ |
|
22 |
|
23 /** |
|
24 * @see Zend_Controller_Action_Helper_ContextSwitch |
|
25 */ |
|
26 require_once 'Zend/Controller/Action/Helper/ContextSwitch.php'; |
|
27 |
|
28 /** |
|
29 * Simplify AJAX context switching based on requested format |
|
30 * |
|
31 * @uses Zend_Controller_Action_Helper_Abstract |
|
32 * @category Zend |
|
33 * @package Zend_Controller |
|
34 * @subpackage Zend_Controller_Action_Helper |
|
35 * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) |
|
36 * @license http://framework.zend.com/license/new-bsd New BSD License |
|
37 */ |
|
38 class Zend_Controller_Action_Helper_AjaxContext extends Zend_Controller_Action_Helper_ContextSwitch |
|
39 { |
|
40 /** |
|
41 * Controller property to utilize for context switching |
|
42 * @var string |
|
43 */ |
|
44 protected $_contextKey = 'ajaxable'; |
|
45 |
|
46 /** |
|
47 * Constructor |
|
48 * |
|
49 * Add HTML context |
|
50 * |
|
51 * @return void |
|
52 */ |
|
53 public function __construct() |
|
54 { |
|
55 parent::__construct(); |
|
56 $this->addContext('html', array('suffix' => 'ajax')); |
|
57 } |
|
58 |
|
59 /** |
|
60 * Initialize AJAX context switching |
|
61 * |
|
62 * Checks for XHR requests; if detected, attempts to perform context switch. |
|
63 * |
|
64 * @param string $format |
|
65 * @return void |
|
66 */ |
|
67 public function initContext($format = null) |
|
68 { |
|
69 $this->_currentContext = null; |
|
70 |
|
71 if (!$this->getRequest()->isXmlHttpRequest()) { |
|
72 return; |
|
73 } |
|
74 |
|
75 return parent::initContext($format); |
|
76 } |
|
77 } |