本文整理汇总了PHP中uploader::sclear方法的典型用法代码示例。如果您正苦于以下问题:PHP uploader::sclear方法的具体用法?PHP uploader::sclear怎么用?PHP uploader::sclear使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类uploader
的用法示例。
在下文中一共展示了uploader::sclear方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: updatePreview
function updatePreview($file_id, $resource)
{
$objResponse =& new xajaxResponse();
$CFile = new CFile($file_id);
$path_file = $CFile->path . 'sm_' . $CFile->name;
if ($CFile->image_size['height'] > portfolio::PREVIEW_MAX_HEIGHT || $CFile->image_size['width'] > portfolio::PREVIEW_MAX_WIDTH) {
$CFile = $CFile->resizeImage($path_file, portfolio::PREVIEW_MAX_WIDTH, portfolio::PREVIEW_MAX_HEIGHT, 'auto', true);
} else {
$CFile = uploader::remoteCopy($CFile->id, $CFile->table, $CFile->path, false, 'sm_f_');
}
uploader::sclear($resource);
// Чистим заменяем
uploader::screateFile($CFile, $resource);
$callback = uploader::getCallback(uploader::sgetTypeUpload($resource));
$template = uploader::getTemplate('uploader.file', 'portfolio/');
$template = str_replace(array('{idFile}', '{fileName}'), array($CFile->id, $CFile->original_name), $template);
$objResponse->script("\n \$\$('#work_preview_file .qq-upload-list').set('html', '{$template}');\n \$\$('#work_preview_file .qq-upload-list .qq-upload-file').set('href', '" . WDCPREFIX . "/{$path_file}');\n \$\$('#work_preview_file .qq-upload-list .qq-uploader-fileID').show();\n ");
$objResponse->script("\n \$\$('#work_preview_file .qq-upload-delete').addEvent('click', function() {\n new Request.JSON({\n url: '/uploader.php',\n onSuccess: function(resp) {\n if(resp.success) {\n \$\$('#work_preview_file .qq-upload-list').set('html', '');\n if(resp.onComplete !== undefined) {\n eval(resp.onComplete);\n }\n } \n }\n }).post({\n 'action': 'remove',\n 'files' : [{$CFile->id}],\n 'resource': '{$resource}',\n 'u_token_key': '{$_SESSION['rand']}'\n });\n });\n ");
$objResponse->script($callback);
return $objResponse;
}
示例2: editWork
public function editWork($uid, $params)
{
global $DB;
require_once $_SERVER['DOCUMENT_ROOT'] . '/classes/uploader/uploader.php';
$params = self::prepareWork($params);
$error = self::validateWork($params);
$work_id = $params['id'];
if (!empty($error)) {
return $error;
}
$update = array('link' => $params['link'], 'name' => antispam($params['work_name']), 'descr' => antispam($params['work_descr']), 'cost' => $params['work_cost'], 'cost_type' => $params['work_cost_type_db_id'], 'time_value' => $params['time_cost'], 'time_type' => $params['work_time_type_db_id'], 'prev_type' => $params['work_preview_type'], 'prof_id' => $params['work_category_db_id']);
if ($params['video'] != '') {
$video_link = video_validate($params['video']);
$video_link = preg_replace("/^http:\\/\\//", '', $video_link);
$update['video_link'] = $video_link;
$update['is_video'] = true;
} else {
$update['video_link'] = '';
$update['is_video'] = false;
}
if ($uid == $_SESSION['uid'] && !hasPermissions('users')) {
// автор, не админ, не про меняет заголовок либо текст - отправить на модерирование
$update['moderator_status'] = !is_pro() ? '0' : '-2';
}
if ($params['position_num'] !== NULL) {
$update['norder'] = intval($params['position_num']);
}
$dir = 'users/' . substr($_SESSION['login'], 0, 2) . "/{$_SESSION['login']}/upload/";
if (isset($params['IDResource']) && is_array($params['IDResource'])) {
foreach ($params['IDResource'] as $resource) {
$resources[uploader::sgetTypeUpload($resource)] = $resource;
}
if (isset($resources['portfolio'])) {
$mainFile = current(uploader::sgetFiles($resources['portfolio']));
if (!empty($mainFile)) {
// Если что-то загрузили и не удаляли
$MFile = uploader::remoteCopy($mainFile['id'], 'file', $dir, false);
uploader::sclear($resources['portfolio']);
// Делаем отдельное привью из оригинальной большой картинки -- @todo ХЗ зачем но раньше так делали
if (in_array($MFile->getext(), $GLOBALS['graf_array']) && $MFile->getext() != 'swf') {
$MFile->resizeImage($dir . 'tn_' . $MFile->name, self::PREVIEW_MAX_WIDTH, self::PREVIEW_MAX_HEIGHT, 'auto', true);
}
$update['pict'] = $MFile->name;
$is_remove_main_file = true;
}
}
if (isset($resources['pf_preview'])) {
$preview = current(uploader::sgetFiles($resources['pf_preview']));
if (!empty($preview)) {
// Если что-то загрузили и не удаляли
$PFile = uploader::remoteCopy($preview['id'], 'file', $dir, false, 'sm_f_');
uploader::sclear($resources['pf_preview']);
$update['prev_pict'] = $PFile->name;
$is_remove_preview_file = true;
}
}
}
if ($params['main_file'] == '' && !isset($MFile)) {
// Удаляем файл
$update['pict'] = '';
$is_remove_main_file = true;
}
if ($params['preview_file'] == '' && !isset($PFile)) {
// Удаляем файл
$update['prev_pict'] = '';
$is_remove_preview_file = true;
}
if ($is_remove_main_file) {
$cf = new CFile();
$cf->Delete(0, $dir, $params['old_main_file']);
// удаляем ранее загруженный файл
}
if ($is_remove_preview_file) {
$cf = new CFile();
$cf->Delete(0, $dir, $params['old_preview_file']);
// удаляем ранее загруженный файл
}
if (empty($error)) {
$wmodeAllowValues = array('direct', 'gpu', 'window');
if (!in_array($params['wmode'], $wmodeAllowValues)) {
$params['wmode'] = 'window';
}
if ($work_id) {
$update['edit_date'] = 'NOW()';
$result = $DB->update('portfolio', $update, 'id = ?i AND user_id = ?i', $work_id, $uid);
} else {
$update['user_id'] = $uid;
$result = $DB->insert('portfolio', $update, 'id');
$work_id = $result;
}
if ($MFile && $MFile->getext() == 'swf' && $MFile->id) {
$res = $DB->query('UPDATE swf_file_params SET wmode = ?, table_name = ? WHERE fid = ?i', $params['wmode'], $MFile->table, $MFile->id);
if (pg_affected_rows($res) == 0) {
$res = $DB->query('INSERT INTO swf_file_params (fid, wmode, table_name) VALUES(?i, ?, ?)', $MFile->id, $params['wmode'], $MFile->table);
}
} else {
if (!$MFile) {
$ext = preg_replace("#.*(\\.[a-zA-Z0-9]*)\$#", '$1', $params['main_file']);
if (strtolower($ext) == '.swf') {
$res = $DB->query('UPDATE swf_file_params SET wmode = ? WHERE fid = (SELECT id FROM file WHERE fname = ?)', $params['wmode'], $params['main_file']);
//.........这里部分代码省略.........