16 include_once
'../../include/cp_header.php';
17 require_once XOOPS_ROOT_PATH.
'/modules/rmcommon/admin_loader.php';
18 define(
'RMCLOCATION',
'imgmanager');
26 define(
'RMCSUBLOCATION',
'showimages');
28 $db = XoopsDatabaseFactory::getDatabaseConnection();
33 redirectMsg(
'images.php?action=newcat',
__(
'There are not categories yet! Please create one in order to add images.',
'rmcommon'), 1);
39 header(
'location: images.php?action=showcats');
42 $sql =
"SELECT COUNT(*) FROM ".$db->prefix(
"rmc_images");
43 if (
$cat>0)
$sql .=
" WHERE cat='$cat'";
48 $limit = $xoopsModuleConfig[
'imgsnumber'];
57 $nav->target_url(
'images.php?'.(
$cat>0 ?
'category='.
$cat :
'').
'&page={PAGE_NUM}');
60 $sql =
"SELECT * FROM ".$db->prefix(
"rmc_images").
" ".(
$cat>0 ?
"WHERE cat='$cat'" :
'').
" ORDER BY id_img DESC LIMIT $start,$limit";
64 $categories = array();
69 $current_size = array();
71 foreach ($sizes as $size){
72 if (empty($current_size)){
73 $current_size = $size;
75 if ($current_size[
'width']>=$size[
'width'] && $size[
'width']>0){
76 $current_size = $size;
83 $img->assignVars($row);
84 if (!isset($categories[$img->getVar(
'cat')])){
85 $categories[$img->getVar(
'cat')] =
new RMImageCategory($img->getVar(
'cat'));
88 if (!isset($authors[$img->getVar(
'uid')])){
89 $authors[$img->getVar(
'uid')] =
new XoopsUser($img->getVar(
'uid'));
92 $fd = pathinfo($img->getVar(
'file'));
96 'title' => $img->getVar(
'title'),
97 'date' => $img->getVar(
'date'),
98 'desc' => $img->getVar(
'desc',
'n'),
99 'cat' => $categories[$img->getVar(
'cat')]->getVar(
'name'),
100 'author' => $authors[$img->getVar(
'uid')],
101 'file' => XOOPS_UPLOAD_URL.
'/'.date(
'Y',$img->getVar(
'date')).
'/'.date(
'm',$img->getVar(
'date')).
'/sizes/'.$fd[
'filename'].
'_'.$current_size[
'width'].
'x'.$current_size[
'height'].
'.'.$fd[
'extension'],
102 'big' => XOOPS_UPLOAD_URL.
'/'.date(
'Y',$img->getVar(
'date')).
'/'.date(
'm',$img->getVar(
'date')).
'/'.$fd[
'filename'].
'.'.$fd[
'extension']
109 RMLightbox::get()->add_element(
'#list-images a.bigimages');
110 RMLightbox::get()->render();
118 include
RMTemplate::get()->get_template(
'images_images.php',
'module',
'rmcommon');
126 define(
'RMCSUBLOCATION',
'addimages');
131 if (!
$cat->isNew() &&
$cat->getVar(
'status')!=
'open'){
132 showMessage(sprintf(
__(
'Category %s is closed. Please, select another category.',
'rmcommon'),
'"'.
$cat->getVar(
'name').
'"'), 1);
139 $uploader->add_setting(
'formData', array(
141 'category'=>
$cat->id(),
146 $uploader->add_setting(
'fileExt',
'*.jpg;*.png;*.gif');
147 $uploader->add_setting(
'fileDesc',
__(
'All Images (*.jpg, *.png, *.gif)',
'rmcommon'));
148 $uploader->add_setting(
'sizeLimit',
$cat->getVar(
'filesize') *
$cat->getVar(
'sizeunit'));
149 $uploader->add_setting(
'buttonText',
__(
'Browse Images...',
'rmcommon'));
150 $uploader->add_setting(
'queueSizeLimit', 100);
151 $uploader->add_setting(
'onUploadSuccess',
"function(file, resp, data){
154 \$('#upload-errors').append('<span class=\"failed\"><strong>'+file.name+'</strong>: '+ret.message+'</span>');
157 ids[total-1] = ret.id;
158 \$('#upload-errors').append('<span class=\"done\"><strong>'+file.name+'</strong>: ".
__(
'Uploaded successfully!',
'rmcommon').
"</span>');
162 $uploader->add_setting(
'onQueueComplete',
"function(event, data){
166 \$('.select_image_cat').hide('slow');
167 \$('#upload-errors').hide('slow');
168 \$('#upload-errors').html('');
169 \$('#upload-controls').hide('slow');
170 \$('#resizer-bar').show('slow');
171 \$('#resizer-bar').effect('highlight',{},1000);
172 \$('#gen-thumbnails').show();
174 var increments = 1/total*100;
175 url = '".
RMCURL.
"/images.php';
178 resize_image(params);
192 include
RMTemplate::get()->get_template(
'images_uploadimages.php',
'module',
'rmcommon');
201 define(
'RMCSUBLOCATION',
'showcategories');
203 $db = XoopsDatabaseFactory::getDatabaseConnection();
204 $sql =
"SELECT COUNT(*) FROM ".$db->prefix(
"rmc_img_cats");
209 $limit = $xoopsModuleConfig[
'catsnumber'];
218 $nav->target_url(
'images.php?action=showcats&page={PAGE_NUM}');
221 $sql =
"SELECT * FROM ".$db->prefix(
"rmc_img_cats").
" ORDER BY id_cat DESC LIMIT $start,$limit";
224 $categories = array();
228 $cat->assignVars($row);
229 $groups =
$cat->getVar(
'groups');
230 $categories[] = array(
232 'name' =>
$cat->getVar(
'name'),
233 'status' =>
$cat->getVar(
'status'),
236 'sizes' =>
$cat->getVar(
'sizes'),
248 include
RMTemplate::get()->get_template(
'images_categories.php',
'module',
'rmcommon');
258 define(
'RMCSUBLOCATION',
'newcategory');
265 redirectMsg(
'images.php?action=showcats',
__(
'You must specify a category id to edit!',
'rmcommon'), 1);
272 redirectMsg(
'images.php?action=showcats',
__(
'The specified category does not exist!',
'rmcommon'), 1);
277 $perms =
$cat->getVar(
'groups');
278 $write = isset($write) ? $write : $perms[
'write'];
279 $read = isset($read) ? $read : $perms[
'read'];
281 $active =
$cat->getVar(
'status');
288 $form =
new RMForm(
'',
'',
'');
289 $fwrite =
new RMFormGroups(
'',
'write',
true,1, 3, isset($write) ? $write : array(XOOPS_GROUP_ADMIN));
290 $fread =
new RMFormGroups(
'',
'read',
true,1, 3, isset($read) ? $read : array(0));
293 include
RMTemplate::get()->get_template(
'categories_form.php',
'module',
'rmcommon');
305 $q =
'images.php?action='.($edit ?
'editcat' :
'newcat');
306 foreach($_POST as $k => $v){
307 if ($k==
'action' || $k==
'XOOPS_TOKEN_REQUEST')
continue;
309 $q .=
'&'.RMFunctions::urlencode_array($v, $k);
311 $q .=
'&'.$k.
'='.urlencode($v);
320 redirectMsg(
'images.php?action=showcats',
__(
'Specify a valid category id',
'rmcommon'), 1);
326 redirectMsg(
'images.php?action=showcats',
__(
'Specified category does not exists!',
'rmcommon'), 1);
335 redirectMsg($q,
__(
'Please specify a category name',
'rmcommon'), 1);
339 if (empty($read)) $read = array(0);
340 if (empty($write)) $write = array(0);
344 foreach ($sizes as $size){
345 if (trim($size[
'name'])==
'')
continue;
346 if ($size[
'type']!=
'none' && $size[
'width']<=0 && $size[
'height']<=0)
continue;
350 if (empty($schecked)){
351 redirectMsg($q,
__(
'You must create one size for this category at least!',
'rmcommon'), 1);
358 redirectMsg($q,
__(
'There is already a category with the same name!',
'rmcommon'), 1);
362 $cat->setVar(
'name', $name);
363 $cat->setVar(
'status', $status);
364 $cat->setVar(
'groups', array(
'write'=>$write,
'read'=>$read));
365 $cat->setVar(
'sizes',$schecked);
366 $cat->setVar(
'filesize', $filesize<=0 ?
'50' : $filesize);
367 $cat->setVar(
'sizeunit', $sizeunit<=0 ?
'1024' : $sizeunit);
370 redirectMsg(
'images.php?action=showcats',
__($edit ?
'Category updated successfully!' :
'Category saved successfully!',
'rmcommon'), 0);
372 redirectMsg($q,
__(
'There were some erros while trying to save this category.',
'rmcommon').
'<br />'.
$cat->errors(), 1);
388 redirectMsg(
'images.php?action=showcats',
__(
'Specify one category at least to change status!',
'rmcommon'), 1);
396 $db = XoopsDatabaseFactory::getDatabaseConnection();
397 $sql =
"UPDATE ".$db->prefix(
"rmc_img_cats").
" SET status='".
$action.
"' WHERE id_cat IN(".implode(
',',$cats).
")";
400 redirectMsg(
'images.php?action=showcats',
__(
'Database updated successfully!',
'rmcommon'), 0);
403 redirectMsg(
'images.php?action=showcats',
__(
'There were some erros while updating database:',
'rmcommon').
'<br />'.
$db->error(), 1);
411 $data[
'message'] = $message;
412 echo json_encode(
$data);
422 $xoopsLogger->activated =
false;
436 $data = explode(
'|', $params);
438 if (
$data[0]!=$xoopsUser->uid()){
446 if (!$xoopsSecurity->check(
false,
$data[2])){
457 if (!
$cat->user_allowed_toupload($xoopsUser)){
461 $sizes =
$cat->getVar(
'sizes');
462 $updir = XOOPS_UPLOAD_PATH.
'/'.date(
'Y',
$image->getVar(
'date')).
'/'.date(
'm',time());
463 $upurl = XOOPS_UPLOAD_URL.
'/'.date(
'Y',
$image->getVar(
'date')).
'/'.date(
'm',time());;
467 $ret[
'sizes'] = array();
468 foreach ($sizes as $size){
470 if ($size[
'width']<=0 && $size[
'height']<=0)
continue;
474 $name =
$updir.
'/sizes/'.$fd[
'filename'].
'_'.$size[
'width'].
'x'.$size[
'height'].
'.'.$fd[
'extension'];
476 $ret[
'sizes'][$size[
'name']] = str_replace(XOOPS_UPLOAD_PATH, XOOPS_UPLOAD_URL, $name);;
478 list($currentWidth, $currentHeight) = getimagesize(
$updir.
'/'.
$image->getVar(
'file'));
485 if($size[
'type']==
'crop'){
487 if($size[
'width'] > $currentWidth || $size[
'height'] > $currentHeight)
492 if($size[
'width']>$currentWidth && $size[
'height']>$currentHeight)
495 if($size[
'width']>$currentWidth)
496 $size[
'width'] = $currentWidth;
498 if($size[
'height']>$currentHeight)
499 $size[
'height'] = $currentHeight;
504 switch($size[
'type']){
509 if ($size[
'width']<=0 || $size[
'height']<=0){
510 $sizer->resizeWidth($size[
'width']);
512 $sizer->resizeWidthOrHeight($size[
'width'], $size[
'height']);
518 if($size[
'width']<=$width || $width==0){
519 $width = $size[
'width'];
520 $tfile = str_replace(XOOPS_UPLOAD_PATH, XOOPS_UPLOAD_URL, $name);
525 $ret[
'message'] = sprintf(
__(
'%s done!',
'rmcommon'),
$image->getVar(
'file'));
528 $ret[
'title'] =
$image->getVar(
'title');
529 echo json_encode($ret);
543 redirectMsg(
'images.php',
__(
'Invalid image ID',
'rmcommon'), 1);
549 redirectMsg(
'images.php',
__(
'Image not found!',
'rmcommon'), 1);
554 $sizes =
$cat->getVar(
'sizes');
555 $current_size = array();
557 $fd = pathinfo(
$image->getVar(
'file'));
558 $updir =
'/'.date(
'Y',
$image->getVar(
'date')).
'/'.date(
'm',time());
560 foreach ($sizes as $size){
561 if ($size[
'width']<=0)
continue;
562 if (empty($current_size)){
563 $current_size = $size;
565 if ($current_size[
'width']>=$size[
'width'] && $size[
'width']>0){
566 $current_size = $size;
570 $image_data[
'sizes'][] = array(
571 'file' => XOOPS_UPLOAD_URL.$updir.
'/sizes/'.$fd[
'filename'].
'_'.$size[
'width'].
'x'.$size[
'height'].
'.'.$fd[
'extension'],
572 'name' => $size[
'name']
577 $image_data[
'thumbnail'] = XOOPS_UPLOAD_URL.$updir.
'/sizes/'.$fd[
'filename'].
'_'.$current_size[
'width'].
'x'.$current_size[
'height'].
'.'.$fd[
'extension'];
578 $mimes = include(XOOPS_ROOT_PATH.
'/include/mimetypes.inc.php');
579 $image_data[
'mime'] = isset($mimes[$fd[
'extension']]) ? $mimes[$fd[
'extension']] :
'application/octet-stream';
580 $image_data[
'file'] =
$image->getVar(
'file');
581 $image_data[
'date'] =
$image->getVar(
'date');
582 $image_data[
'title'] =
$image->getVar(
'title');
583 $image_data[
'desc'] =
$image->getVar(
'desc',
'e');
584 $image_data[
'url'] = XOOPS_UPLOAD_URL.$updir.
'/'.
$image->getVar(
'file');
594 include
RMTemplate::get()->get_template(
'images_edit.php',
'module',
'rmcommon');
613 if (!$xoopsSecurity->check()){
614 redirectMsg(
'images.php',
__(
'Operation not allowed!',
'rmcommon'), 1);
619 redirectMsg(
"images.php?category=$cat&page=$page",
__(
'Image ID not provided!',
'rmcommon'), 1);
623 if (trim($title)==
''){
624 redirectMsg(
"images.php?action=edit&id=$id&page=$page",
__(
'You must provide a title for this image',
'rmcommon'), 1);
630 redirectMsg(
"images.php?category=$cat&page=$page",
__(
'Image not exists!',
'rmcommon'), 1);
636 redirectMsg(
"images.php",
__(
'Category not exist!',
'rmcommon'), 1);
644 $image->setVar(
'title', $title);
645 $image->setVar(
'desc', $desc);
646 if (isset($pcat))
$image->setVar(
'cat',
$cat->id());
649 redirectMsg(
"images.php?action=edit&id=$id&page=$page",
__(
'the image could not be updated!',
'rmcommon').
'<br />'.
$image->errors(), 1);
655 redirectMsg(
"images.php?category=".
$cat->id().
"&page=$page",
__(
'Image updated succesfully!',
'rmcommon'), 0);
659 $fd = pathinfo(
$image->getVar(
'file'));
660 $updir = XOOPS_UPLOAD_PATH.
'/'.date(
'Y',
$image->getVar(
'date')).
'/'.date(
'm',time());
663 foreach ($pcat->getVar(
'sizes') as $size){
664 if ($size[
'width']<=0)
continue;
665 $file = $updir.
'/sizes/'.$fd[
'filename'].
'_'.$size[
'width'].
'x'.$size[
'height'].
'.'.$fd[
'extension'];
671 foreach (
$cat->getVar(
'sizes') as $size){
672 if ($size[
'width']<=0 && $size[
'height']<=0)
continue;
674 $name = $updir.
'/sizes/'.$fd[
'filename'].
'_'.$size[
'width'].
'x'.$size[
'height'].
'.'.$fd[
'extension'];
677 switch($size[
'type']){
682 if ($size[
'width']<=0 || $size[
'height']<=0){
683 $sizer->resizeWidth($size[
'width']);
685 $sizer->resizeWidthOrHeight($size[
'width'], $size[
'height']);
690 $width = $width==0 ? $size[
'width'] : $width;
691 if($width<$size[
'width']){
692 $with = $size[
'width'];
693 $tfile = str_replace(XOOPS_UPLOAD_PATH, XOOPS_UPLOAD_URL, $name);
697 redirectMsg(
'images.php?category='.
$cat->id(),
__(
'Image updated successfully!',
'rmcommon'), 0);
717 foreach ($ids as
$id){
721 redirectMsg(
'images.php',
__(
'Image not exists!',
'rmcommon'), 1);
727 $fd = pathinfo(
$image->getVar(
'file'));
728 $updir = XOOPS_UPLOAD_PATH.
'/'.date(
'Y',
$image->getVar(
'date')).
'/'.date(
'm',time());
731 foreach (
$cat->getVar(
'sizes') as $size){
732 if ($size[
'width']<=0)
continue;
733 $file = $updir.
'/sizes/'.$fd[
'filename'].
'_'.$size[
'width'].
'x'.$size[
'height'].
'.'.$fd[
'extension'];
741 $errors .=
$image->errors();
747 redirectMsg(
'images.php?category='.
$cat->id().
'&page='.
$page,
__(
'Errors ocurred during images deletion!',
'rmcommon').
'<br />'.$errors, 0);
749 redirectMsg(
'images.php?category='.
$cat->id().
'&page='.
$page,
__(
'Images deleted successfully!',
'rmcommon'), 0);
762 if (!$xoopsSecurity->check()){
763 redirectMsg(
'images.php?action=showcats',
__(
'Operation not allowed!',
'rmcommon'), 1);
768 redirectMsg(
'images.php?action=showcats',
__(
'Category ID not provided',
'rmcommon'), 1);
774 redirectMsg(
'images.php?action=showcats',
__(
'Category not found',
'rmcommon'), 1);
779 foreach (
$cat->getVar(
'sizes') as $size){
780 if ($size[
'width']<=0)
continue;
782 $sizes[] =
'_'.$size[
'width'].
'x'.$size[
'height'];
786 $db = XoopsDatabaseFactory::getDatabaseConnection();
787 $sql =
"SELECT * FROM ".$db->prefix(
"rmc_images").
" WHERE cat='".
$cat->id().
"'";
794 $updir = XOOPS_UPLOAD_PATH.
'/'.date(
'Y',
$image->getVar(
'date')).
'/'.date(
'm',time());
795 $fd = pathinfo(
$image->getVar(
'file'));
797 foreach ($sizes as $size){
798 $file =
$updir.
'/sizes/'.$fd[
'filename'].$size.
'.'.$fd[
'extension'];
807 redirectMsg(
'images.php?action=showcats',
__(
'Category deleted successfully!',
'rmcommon'), 0);
809 redirectMsg(
'images.php?action=showcats',
__(
'Errors ocurred while deleting the category',
'rmcommon').
'<br />'.
$cat->errors(), 0);
822 $ids = implode(
',', $imgs);
832 \$(document).ready(function(){
834 total = ".count($imgs).
";
835 \$('#resizer-bar').show('slow');
836 \$('#resizer-bar').effect('highlight',{},1000);
837 \$('#gen-thumbnails').show();
839 var increments = 1/total*100;
840 url = '".
RMCURL.
"/images.php';
843 resize_image(params);
846 include
RMTemplate::get()->get_template(
'images_uploadimages.php',
'module',
'rmcommon');