| 1 |
<?php |
| 2 |
/** |
| 3 |
* |
| 4 |
*/ |
| 5 |
|
| 6 |
// No direct access. |
| 7 |
defined('ABSPATH') or die('Access denied'); |
| 8 |
|
| 9 |
// Import dependencies. |
| 10 |
cssJSToolbox::import('framework:mvc:controller-ajax.inc.php'); |
| 11 |
|
| 12 |
/** |
| 13 |
* |
| 14 |
*/ |
| 15 |
class CJTTinymceBlocksController extends CJTAjaxController { |
| 16 |
|
| 17 |
/** |
| 18 |
* put your comment there... |
| 19 |
* |
| 20 |
* @var mixed |
| 21 |
*/ |
| 22 |
protected $controllerInfo = array('model' => 'tinymce-blocks'); |
| 23 |
|
| 24 |
/** |
| 25 |
* put your comment there... |
| 26 |
* |
| 27 |
*/ |
| 28 |
public function __construct($hasView = null, $request = null) { |
| 29 |
// Initialize parent! |
| 30 |
parent::__construct($hasView, $request); |
| 31 |
// Register actions! |
| 32 |
$this->registryAction('getBlocksList'); |
| 33 |
// @TODO: $this->defaultCapability is risky if there is any admin actions added later, please remove! |
| 34 |
$this->defaultCapability = array('edit_posts', 'edit_pages'); |
| 35 |
} |
| 36 |
|
| 37 |
/** |
| 38 |
* put your comment there... |
| 39 |
* |
| 40 |
*/ |
| 41 |
public function getBlocksListAction() { |
| 42 |
// Read all blocks! |
| 43 |
$blocks = $this->model->getItems(); |
| 44 |
// retreive owener name! |
| 45 |
foreach ($blocks as $id => $block) { |
| 46 |
$user = get_userdata($block->owner); |
| 47 |
$block->owner = !$user ? 'N/A' : $user->display_name; |
| 48 |
$this->response['list'][$id] = $block; |
| 49 |
} |
| 50 |
$this->response['count'] = count($this->response['list']); |
| 51 |
} |
| 52 |
|
| 53 |
} // End class. |
| 54 |
|