23 include __DIR__ .
'/header.php';
26 $xoops->header(
'admin:images/images_admin_images.tpl');
31 $mimetypes = array(
'image/gif',
'image/jpeg',
'image/pjpeg',
'image/x-png',
'image/png');
35 if (!
$xoops->security()->check()) {
36 $xoops->redirect(
'images.php?imgcat_id=' .
$imgcat_id, 3, implode(
'<br />',
$xoops->security()->getErrors()));
42 $image_id = Request::getInt(
'image_id', 0);
47 $obj =
$helper->getHandlerImages()->create();
48 $obj->setVar(
'image_name',
'blank.gif');
49 $obj->setVar(
'image_mimetype',
'image/gif');
53 $obj->setVar(
'image_nicename', Request::getString(
'image_nicename',
''));
54 $obj->setVar(
'image_created', time());
55 $obj->setVar(
'image_display', Request::getInt(
'image_display', 1));
56 $obj->setVar(
'image_weight', Request::getInt(
'image_weight', 0));
63 $xoops_upload_file = Request::getArray(
'xoops_upload_file', array());
64 if ($_FILES[$xoops_upload_file[0]][
'error'] === 0) {
65 $uploader =
new XoopsMediaUploader(XOOPS_UPLOAD_PATH .
'/images',
$mimetypes, $category->getVar(
'imgcat_maxsize'), $category->getVar(
'imgcat_maxwidth'), $category->getVar(
'imgcat_maxheight'));
66 if ($uploader->fetchMedia($xoops_upload_file[0])) {
67 $uploader->setPrefix(
'img');
68 if (!$uploader->upload()) {
69 $error_message .= $uploader->getErrors();
70 $obj->setVar(
'image_name',
'blank.gif');
71 $obj->setVar(
'image_mimetype',
'image/gif');
74 $obj->setVar(
'image_mimetype', $uploader->getMediaType());
75 if ($category->getVar(
'imgcat_storetype') ==
'db' && $isnew) {
76 $fp = @fopen($uploader->getSavedDestination(),
'rb');
77 $fbinary = @fread($fp, filesize($uploader->getSavedDestination()));
79 $image_body = $fbinary;
81 $obj->setVar(
'image_name',
'images/' . $uploader->getSavedFileName());
87 $xoops->tpl()->assign(
'error_message', $error_message);
90 if ($category->getVar(
'imgcat_storetype') ==
'db' && $isnew) {
92 if (!is_object($imagebody)) {
93 $imagebody =
$helper->getHandlerImagesBody()->create();
94 $imagebody->setVar(
'image_id',
$image_id);
96 $imagebody->setVar(
'image_body', $image_body);
97 if (
$helper->getHandlerImagesBody()->insert($imagebody)) {
98 @unlink($uploader->getSavedDestination());
103 echo
$xoops->alert(
'error', $obj->getHtmlErrors());
110 $obj =
$helper->getHandlerImages()->create();
117 $image_id = Request::getInt(
'image_id', 0);
126 $image_id = Request::getInt(
'image_id', 0);
128 $ok = Request::getInt(
'ok', 0);
132 if (!
$xoops->security()->check()) {
133 $xoops->redirect(
'images.php?imgcat_id=' .
$imgcat_id, 3, implode(
'<br />',
$xoops->security()->getErrors()));
135 $category =
$helper->getHandlerCategories()->get($obj->getvar(
'imgcat_id'));
137 if (
$helper->getHandlerImages()->delete($obj)) {
138 if ($category->getVar(
'imgcat_storetype') ==
'db') {
146 $category =
$helper->getHandlerCategories()->get($obj->getvar(
'imgcat_id'));
147 if ($category->getVar(
'imgcat_storetype') ==
'db') {
153 array(
'op' =>
'del',
'ok' => 1,
'image_id' =>
$image_id,
'imgcat_id' => $obj->getVar(
'imgcat_id')),
156 .
'<br /><br /><img src="' . $img .
'" /><br />'
163 $image_id = Request::getInt(
'image_id', 0);
166 $old = $obj->getVar(
'image_display');
167 $obj->setVar(
'image_display', !$old);
168 if (!
$helper->getHandlerImages()->insert($obj)) {
185 if (is_object($category)) {
186 if ($category->getVar(
'imgcat_storetype') ==
'db') {
187 $xoops->tpl()->assign(
'db_store', 1);
193 $xoops->tpl()->assign(
'form_category', $form_category->render());
197 $xoops->tpl()->assign(
'images', $images);
199 if ($imgcount > 0 && $imgcount >
$helper->getConfig(
'images_pager')) {
201 $xoops->tpl()->assign(
'nav_menu', $nav->renderNav());
204 $xoops->tpl()->assign(
'listimg',
true);
if(empty($settings['ROOT_PATH'])) elseif(empty($settings['DB_PARAMETERS'])) $error
if(!is_object($module)||!$module->getVar('isactive')) $msg
const _AM_IMAGES_IMG_DELETE
const _AM_IMAGES_IMG_SAVE