Пример #1
0
/**
* Function to edit images
*/
function edit_image()
{
    global $xoopsUser, $xoopsSecurity;
    $id = rmc_server_var($_GET, 'id', 0);
    $page = rmc_server_var($_GET, 'page', '');
    if ($id <= 0) {
        redirectMsg('images.php', __('Invalid image ID', 'rmcommon'), 1);
        die;
    }
    $image = new RMImage($id);
    if ($image->isNew()) {
        redirectMsg('images.php', __('Image not found!', 'rmcommon'), 1);
        die;
    }
    $cat = new RMImageCategory($image->getVar('cat'));
    $sizes = $cat->getVar('sizes');
    $current_size = array();
    $fd = pathinfo($image->getVar('file'));
    $updir = '/' . date('Y', $image->getVar('date')) . '/' . date('m', time());
    foreach ($sizes as $size) {
        if ($size['width'] <= 0) {
            continue;
        }
        if (empty($current_size)) {
            $current_size = $size;
        } else {
            if ($current_size['width'] >= $size['width'] && $size['width'] > 0) {
                $current_size = $size;
            }
        }
        $image_data['sizes'][] = array('file' => XOOPS_UPLOAD_URL . $updir . '/sizes/' . $fd['filename'] . '_' . $size['width'] . 'x' . $size['height'] . '.' . $fd['extension'], 'name' => $size['name']);
    }
    $image_data['thumbnail'] = XOOPS_UPLOAD_URL . $updir . '/sizes/' . $fd['filename'] . '_' . $current_size['width'] . 'x' . $current_size['height'] . '.' . $fd['extension'];
    $mimes = (include XOOPS_ROOT_PATH . '/include/mimetypes.inc.php');
    $image_data['mime'] = isset($mimes[$fd['extension']]) ? $mimes[$fd['extension']] : 'application/octet-stream';
    $image_data['file'] = $image->getVar('file');
    $image_data['date'] = $image->getVar('date');
    $image_data['title'] = $image->getVar('title');
    $image_data['desc'] = $image->getVar('desc', 'e');
    $image_data['url'] = XOOPS_UPLOAD_URL . $updir . '/' . $image->getVar('file');
    $categories = RMFunctions::load_images_categories("WHERE status='open' ORDER BY id_cat DESC");
    xoops_cp_header();
    RMFunctions::create_toolbar();
    RMTemplate::get()->add_script('include/js/images.js');
    RMTemplate::get()->add_script('include/js/jquery.validate.min.js');
    RMTemplate::get()->add_style('imgmgr.css', 'rmcommon');
    include RMTemplate::get()->get_template('images_edit.php', 'module', 'rmcommon');
    xoops_cp_footer();
}
Пример #2
0
        $uploader = new RMFlashUploader('files-container', 'upload.php');
        $uploader->add_setting('scriptData', array('action' => 'upload', 'category' => $cat->id(), 'rmsecurity' => TextCleaner::getInstance()->encrypt($xoopsUser->uid() . '|' . RMCURL . '/images.php' . '|' . $xoopsSecurity->createToken(), true)));
        $uploader->add_setting('multi', true);
        $uploader->add_setting('fileExt', '*.jpg;*.png;*.gif');
        $uploader->add_setting('fileDesc', __('All Images (*.jpg, *.png, *.gif)', 'rmcommon'));
        $uploader->add_setting('sizeLimit', $cat->getVar('filesize') * $cat->getVar('sizeunit'));
        $uploader->add_setting('buttonText', __('Browse Images...', 'rmcommon'));
        $uploader->add_setting('queueSizeLimit', 100);
        $uploader->add_setting('auto', true);
        $uploader->add_setting('onSelect', "function(event, qid, file){\n        \tif (queuefiles[qid]) return false;\n        \tqueuefiles[qid] = true;\n        \treturn true;\n        }");
        $uploader->add_setting('onComplete', "function(event, id, file, resp, data){\n            eval('ret = '+resp);\n            if (ret.error){\n                \$('#upload-errors').append('<span class=\"failed\"><strong>'+file.name+'</strong>: '+ret.message+'</span>');\n            } else {\n                total++;\n                ids[total-1] = ret.id;\n                \$('#upload-errors').append('<span class=\"done\"><strong>'+file.name+'</strong>: " . __('Uploaded successfully!', 'rmcommon') . "</span>');\n            }\n            return true;\n        }");
        $uploader->add_setting('onAllComplete', "function(event, data){\n            if(total<=0) return;\n                \$('.categories_selector').hide('slow');\n                \$('#upload-errors').hide('slow');\n                \$('#upload-errors').html('');\n                \$('#upload-controls').hide('slow');\n                \$('#resizer-bar').show('slow');\n                \$('#resizer-bar').effect('highlight',{},1000);\n                \$('#gen-thumbnails').show();\n                    \n                var increments = 1/total*100;\n                url = '" . RMCURL . "/images.php';\n                    \n                params = '" . TextCleaner::getInstance()->encrypt($xoopsUser->uid() . '|' . RMCURL . '/images.php' . '|' . $xoopsSecurity->createToken(), true) . "';\n                resize_image(params);\n                    \n        }");
        $uploader->add_setting('onSelectOnce', "function(event, data){\n            \$('#upload-errors').html('');\n        }");
        RMTemplate::get()->add_head($uploader->render());
    }
    $categories = RMFunctions::load_images_categories("WHERE status='open' ORDER BY id_cat DESC", true);
    RMTemplate::get()->add_style('imgmgr.css', 'rmcommon');
    RMTemplate::get()->add_style('pagenav.css', 'rmcommon');
    RMTemplate::get()->add_style('editor_img.css', 'rmcommon');
    if ($type == 'tiny') {
        RMTemplate::get()->add_script(RMCURL . '/api/editors/tinymce/tiny_mce_popup.js');
    } else {
        RMTemplate::get()->add_head('<script type="text/javascript">var exmPopup = window.parent.' . $en . ';</script>');
    }
    RMEvents::get()->run_event('rmcommon.loading_editorimages', '');
    include RMTemplate::get()->get_template('editor_image.php', 'module', 'rmcommon');
} elseif ($action == 'load-images') {
    $db = Database::getInstance();
    if (!$xoopsSecurity->check()) {
        _e('Sorry, unauthorized operation!', 'rmcommon');
        die;