function _ueditor_controller in UEditor - 百度编辑器 7.3
Same name and namespace in other branches
- 7.2 ueditor.module \_ueditor_controller()
The main entrance of ueditor command.
1 string reference to '_ueditor_controller'
- ueditor_menu in ./
ueditor.module - Implements hook_menu().
File
- ./
ueditor.module, line 89 - Integration ueditor for wysiwyg.
Code
function _ueditor_controller() {
//header('Access-Control-Allow-Origin: http://www.baidu.com'); //Set http://www.baidu.com allow cross-domain access
//header('Access-Control-Allow-Headers: X-Requested-With,X_Requested_With'); //Settings allow cross-domain header
date_default_timezone_set("Asia/Chongqing");
error_reporting(E_ERROR);
header("Content-Type: text/html; charset=utf-8");
$file_path = strtr(DRUPAL_ROOT, '\\', '/') . '/' . drupal_get_path('module', 'ueditor');
$CONFIG = drupal_json_decode(preg_replace("/\\/\\*[\\s\\S]+?\\*\\//", "", file_get_contents($file_path . '/includes/config.json')), true);
$ueditor_uploadpath_config = variable_get('ueditor_uploadpath_config', ueditor_config_default());
foreach ($ueditor_uploadpath_config as $key => $pathitem) {
if (isset($CONFIG[$key])) {
$CONFIG[$key] = _ueditor_realpath($pathitem);
}
}
$action = $_GET['action'];
switch ($action) {
case 'config':
$result = json_encode($CONFIG);
break;
/* upload image */
case 'uploadimage':
/* upload scrawl */
case 'uploadscrawl':
/* upload video */
case 'uploadvideo':
/* upload file */
case 'uploadfile':
$result = (include $file_path . '/includes/action_upload.inc');
break;
/* list image */
case 'listimage':
$result = (include $file_path . '/includes/action_list.inc');
break;
/* list file */
case 'listfile':
$result = (include $file_path . '/includes/action_list.inc');
break;
/* catch image */
case 'catchimage':
$result = (include $file_path . '/includes/action_crawler.inc');
break;
default:
$result = json_encode(array(
'state' => t('Request address error'),
));
break;
}
/* output */
if (isset($_GET["callback"])) {
if (preg_match("/^[\\w_]+\$/", $_GET["callback"])) {
echo htmlspecialchars($_GET["callback"]) . '(' . $result . ')';
}
else {
echo json_encode(array(
'state' => t('callback parameters are not legitimate'),
));
}
}
else {
echo $result;
}
}