$onerow->thumburl .= '?cache=' . time(); $onerow->defaultthumburl = '../' . DEFAULT_GALLERY_PATH . str_replace('%2F', '/', rawurlencode($file['filepath'] . IM_PREFIX . $file['filename'])) . '?nocache=' . time(); $onerow->thumb = '<img src="' . $onerow->defaultthumburl . '" alt="' . $file['filename'] . '" />'; $onerow->filename_input = $file['filename']; $onerow->title_input = $this->CreateInputText($id, 'filetitle', $file['title'], 30, 100); $onerow->comment = $file['comment']; $onerow->comment_input = $this->CreateTextArea(0, $id, $file['comment'], 'filecomment', 'fake" style="height:4em;', '', '', '', '40', '4'); // class filled with fake and style-info to overrule the theme-css if ($this->GetPreference('editfiledates')) { $onerow->filedate_input = $this->CreateInputText($id, 'filedate', substr($file['filedate'], 0, 10), 10, 10); } else { $onerow->filedate_input = $file['filedate']; } Gallery_utils::CreateThumbnail('../' . DEFAULT_GALLERY_PATH . $file['filepath'] . '/' . IM_PREFIX . $file['filename'], '../' . DEFAULT_GALLERY_PATH . $file['filepath'] . '/' . $file['filename'], IM_THUMBWIDTH, IM_THUMBHEIGHT, 'sc'); $onerow->deletelink = $this->CreateLink($id, 'multiaction', $returnid, $themeObject->DisplayImage('icons/system/delete.gif', $this->Lang('delete'), '', '', 'systemicon'), array('multiaction' => 'delete', 'fid' => $file['fileid'], 'origaction' => 'editgallery'), $this->Lang('areyousure')); $onerow->fields = Gallery_utils::Getcustomfields($params['fid'], 0, $id); $onerow->file .= '?cache=' . filemtime($onerow->file); $smarty->assign('image', $onerow); $smarty->assign('id', $id); $smarty->assign('file', $this->Lang('item')); $smarty->assign('title', $this->Lang('title')); $smarty->assign('comment', $this->Lang('comment')); $smarty->assign('filedate', $this->Lang('date')); $smarty->assign('cover', $this->Lang('albumcover')); $smarty->assign('active', $this->Lang('active')); $smarty->assign('rotateclockwise', $this->CreateLink($id, 'do_rotateimage', $returnid, '<img src="../modules/Gallery/images/clockwise.png" alt="' . $this->Lang('rotateclockwise') . '" title="' . $this->Lang('rotateclockwise') . '" />', array('fid' => $params['fid'], 'degr' => 270))); $smarty->assign('rotateanticlockwise', $this->CreateLink($id, 'do_rotateimage', $returnid, '<img src="../modules/Gallery/images/anticlockwise.png" alt="' . $this->Lang('rotateanticlockwise') . '" title="' . $this->Lang('rotateanticlockwise') . '" />', array('fid' => $params['fid'], 'degr' => 90))); $smarty->assign('formstart', $this->CreateFormStart($id, 'do_editimage', $returnid, 'post', '', false, '', $params)); // edit thumbs $smarty->assign('formstart2', $this->CreateFormStart($id, 'do_editthumb', $returnid, 'post', '', false, '', $params)); $smarty->assign('formend2', $this->CreateFormEnd());
$rec->comment = $row['comment']; $rec->active = $row['active']; if ($galleryinfo['thumbwidth'] > 0) { $rec->thumb = DEFAULT_GALLERYTHUMBS_PATH . $row['fileid'] . '-' . $galleryinfo['templateid'] . substr($row['filename'], strrpos($row['filename'], '.')); } else { $rec->thumb = DEFAULT_GALLERY_PATH . $row['filepath'] . IM_PREFIX . $row['filename']; } $rec->isdir = false; $paramslink['dir'] = str_replace('%2F', '/', rawurlencode($row['filepath'])); $prettyurl = $urlprefix . '/' . $paramslink['dir'] . ($targetpage != '' ? $targetpage : $returnid); $rec->galleryid = $row['galleryid']; $rec->gallery_url = $this->CreateFrontendLink($id, $targetpage != '' ? $targetpage : $returnid, 'default', '', $paramslink, '', true, true, '', false, $prettyurl); $rec->fields = Gallery_utils::Getcustomfields($rec->fileid, $rec->isdir, '', 1); $itemcount++; $imgcount++; Gallery_utils::CreateThumbnail($rec->thumb, DEFAULT_GALLERY_PATH . trim($row['filepath'] . '/' . $row['filename'], '/'), $galleryinfo['thumbwidth'] > 0 ? $galleryinfo['thumbwidth'] : IM_THUMBWIDTH, $galleryinfo['thumbwidth'] > 0 ? $galleryinfo['thumbheight'] : IM_THUMBHEIGHT, $galleryinfo['thumbwidth'] > 0 ? $galleryinfo['resizemethod'] : 'sc'); array_push($images, $rec); } } } else { $params['module_message'] = $this->Lang('message_wrongdir', htmlspecialchars($params['dir'])); $smarty->assign('hideparentlink', true); } // Expose the list to smarty. Use "by_ref" to save memory. $smarty->assign_by_ref('images', $images); // and a count of records $smarty->assign('imagecount', $imgcount . ' ' . ($imgcount == 1 ? $this->Lang('image') : $this->Lang('images'))); $smarty->assign('itemcount', $itemcount); $smarty->assign('numimages', $imgcount); $smarty->assign('numdirs', $itemcount - $imgcount); $smarty->assign('pages', 1);
function GetGallerytree($subgallery, $sortitems, &$output, &$galleries) { $sortarray = explode('/', 'n+fileorder/' . $sortitems); $subgalleries = Gallery_utils::ArraySort($subgallery, $sortarray, false); foreach ($subgalleries as $key => $subgallery) { $output[] = $subgallery; if (array_key_exists('gid' . $subgallery->fileid, $galleries)) { GetGallerytree($galleries['gid' . $subgallery->fileid], $subgallery->sortitems, $output, $galleries); } } }
$onerow->file = $this->CreateLink($id, 'editgallery', $returnid, $gallery['fileid'] == 1 ? 'Gallery/' : $gallery['filename'], array('gid' => $gallery['fileid'], 'mode' => "edit")); $onerow->dirtag = '{Gallery' . ($gallery['fileid'] == 1 ? '}' : ' dir=\'' . substr($gallery['filepath'] . $gallery['filename'], 0, -1) . '\'}'); if ($gallery['active']) { $activeimage = $themeObject->DisplayImage('icons/system/true.gif', $this->Lang('setfalse'), '', '', 'systemicon'); } else { $activeimage = $themeObject->DisplayImage('icons/system/false.gif', $this->Lang('settrue'), '', '', 'systemicon'); } $onerow->activelink = $this->CreateLink($id, 'multiaction', $returnid, $activeimage, array('multiaction' => 'switchactive', 'gid' => $gallery['galleryid'], 'fid' => $gallery['fileid'], 'origaction' => 'defaultadmin')); $onerow->editlink = $this->CreateLink($id, 'editgallery', $returnid, $themeObject->DisplayImage('icons/system/edit.gif', $this->Lang('editgallery'), '', '', 'systemicon'), array('gid' => $gallery['fileid'], 'mode' => "edit")); $onerow->deletelink = $this->CheckPermission('Gallery - Edit all galleries') ? $this->CreateLink($id, 'multiaction', $returnid, $gCms->variables['admintheme']->DisplayImage('icons/system/delete.gif', $this->Lang('delete'), '', '', 'systemicon'), array('multiaction' => 'delete', 'gid' => $gallery['galleryid'], 'fid' => $gallery['fileid'], 'origaction' => 'defaultadmin'), $this->Lang('areyousure')) : ''; $onerow->imgselect = $this->CreateInputCheckbox($id, 'imgselect[' . $gallery['fileid'] . ']', 1); if (is_dir('../' . DEFAULT_GALLERY_PATH . $gallery['filepath'] . $gallery['filename']) || $gallery['fileid'] == 1) { array_push($showgalleries, $onerow); } else { // delete directory and all of its contents from the database Gallery_utils::DeleteGalleryDB($gallery['filepath'] . $gallery['filename'], $gallery['fileid']); } } } $smarty->assign_by_ref('items', $showgalleries); $smarty->assign('itemcount', count($showgalleries)); $smarty->assign('formstart', $this->CreateFormStart($id, 'multiaction', $returnid, 'post', '', false, '', array('origaction' => 'defaultadmin', 'gid' => 1))); $smarty->assign('formend', $this->CreateFormEnd()); $multiactionlist = array($this->Lang('delete') => 'delete', $this->Lang('active') => 'active', $this->Lang('inactive') => 'inactive'); $smarty->assign('prompt_multiaction', $this->CheckPermission('Gallery - Edit all galleries') ? $this->Lang('withselected') : ''); $smarty->assign('multiaction', $this->CheckPermission('Gallery - Edit all galleries') ? $this->CreateInputDropdown($id, 'multiaction', $multiactionlist, -1) . ' ' . $this->CreateInputSubmit($id, 'multiactionsubmit', $this->Lang('apply'), '', '', $this->Lang('areyousuremulti')) : ''); $smarty->assign('gallerypath', $this->Lang('gallerypath')); $smarty->assign('dirtag', $this->Lang('dirtag')); $smarty->assign('active', $this->Lang('active')); $smarty->assign('addgallery', $this->CheckPermission('Gallery - Edit all galleries') && $this->CheckPermission('Gallery - Add subgalleries') ? $this->CreateLink($id, 'editgallery', $returnid, $themeObject->DisplayImage('icons/system/newfolder.gif', $this->Lang('addsubgallery'), '', '', 'systemicon'), array('gid' => -1, 'mode' => 'add')) . ' ' . $this->CreateLink($id, 'editgallery', $returnid, $this->Lang('addsubgallery'), array('gid' => -1, 'mode' => 'add')) : ''); // Display the populated template
if (!empty($field) || $field == 0) { if (isset($nonpublicfields) && !in_array($key, $nonpublicfields)) { $searchwords .= ' ' . $field; } $query = "INSERT INTO " . cms_db_prefix() . "module_gallery_fieldvals (fieldid, fileid, value) VALUES (?,?,?)"; $result = $db->Execute($query, array($key, $params['gid'], $field)); } } } $params['hideparentlink'] = isset($params['hideparentlink']) ? $params['hideparentlink'] : false; $params['hideparentlink'] = $params['gid'] == 1 ? true : $params['hideparentlink']; $params['templateid'] = $params['templateid'] == '' ? 0 : $params['templateid']; $params['editors'] = is_array($params['editors']) ? $params['editors'] : explode(';', $params['editors']); // prevent an editor to lock himself out $userid = get_userid(); if (!Gallery_utils::CheckEditor($userid, $params['gid'], $params['editors'])) { array_push($params['editors'], $userid); } $editors = implode(';', $params['editors']); $query = "UPDATE " . cms_db_prefix() . "module_gallery_props SET templateid=?,hideparentlink=?,editors=? WHERE fileid=?"; $result = $db->Execute($query, array($params['templateid'], $params['hideparentlink'], $editors, $params['gid'])); // Save images and subgalleries if (!empty($params['sort'])) { $sort = explode(",", $params['sort']); } if (isset($params['filetitle'])) { foreach ($params['filetitle'] as $key => $filetitle) { $filedate = ''; if (!empty($params['filedate'][$key])) { $checkdate = explode('-', $params['filedate'][$key]); $filedate = count($checkdate) == 3 && checkdate($checkdate[1], $checkdate[2], $checkdate[0]) ? $params['filedate'][$key] : '';
<?php if (!$gCms) { exit; } if (!$this->CheckPermission('Use Gallery')) { echo $this->ShowErrors(lang('needpermissionto', 'Use Gallery')); return; } if (!isset($params['gid'])) { $params['module_error'] = lang('missingparams'); $this->Redirect($id, 'defaultadmin', '', $params); return; } $galleryinfo = Gallery_utils::Getgalleryinfobyid($params['gid']); $gallerypath = $params['gid'] == 1 ? '' : trim($galleryinfo['filepath'] . '/' . $galleryinfo['filename'], '/'); $gallery = Gallery_utils::Getgalleryfiles($gallerypath); foreach ($gallery as $file) { if (substr($file['filename'], -1) != '/') { $thumbname = '../' . DEFAULT_GALLERYTHUMB_PATH . $file['fileid'] . '-' . $params['templateid'] . substr($file['filename'], strrpos($file['filename'], '.')); Gallery_utils::CreateThumbnail($thumbname, '../' . DEFAULT_GALLERY_PATH . (empty($file['filepath']) ? '' : $file['filepath'] . '/') . $file['filename'], $galleryinfo['thumbwidth'], $galleryinfo['thumbheight'], $galleryinfo['resizemethod']); } } $this->Redirect($id, 'editgallery', '', array('gid' => $params['gid'], 'mode' => "edit", 'module_message' => $this->Lang('thumbscreated')));
// move only one file, let's don't forget the thumb if ($permission_to_edit == 'all' || $permission_to_edit == 'this') { if (@rename($oldpath, $newpath)) { $newpath = '../' . DEFAULT_GALLERY_PATH . $newdir . IM_PREFIX . $fileinfo['filename']; $oldpath = '../' . DEFAULT_GALLERY_PATH . $fileinfo['filepath'] . IM_PREFIX . $fileinfo['filename']; @rename($oldpath, $newpath); $query = "UPDATE " . cms_db_prefix() . "module_gallery SET filepath = ?, galleryid = ? WHERE fileid = ?"; $db->Execute($query, array($newdir, $params['moveto'], $fid)); } } else { $nopermission++; } } else { // move directory $editors = explode(';', $fileinfo['editors']); if (Gallery_utils::CheckEditor($userid, $fid, $editors)) { if (@rename($oldpath, $newpath)) { $query = "UPDATE " . cms_db_prefix() . "module_gallery SET filepath = ?, galleryid = ? WHERE fileid = ?"; $db->Execute($query, array($newdir, $params['moveto'], $fid)); //move content $oldpath = $fileinfo['filepath'] . $fileinfo['filename']; $newpath = $newdir . $fileinfo['filename']; $query = "UPDATE " . cms_db_prefix() . "module_gallery SET filepath = REPLACE(filepath,?,?) WHERE filepath = ? OR filepath LIKE ?"; $db->Execute($query, array($oldpath, $newpath, $oldpath, $oldpath . '%')); } } else { $nopermission++; } } } }
//session_start(); //ini_set("html_errors", "0"); // Check the upload if (!isset($_FILES['Filedata']) || !is_uploaded_file($_FILES['Filedata']['tmp_name']) || $_FILES['Filedata']['error'] != 0) { echo 'ERROR:invalid upload'; exit(0); } // Check the uploaddirectory $root_path = str_replace('\\', '/', $config['root_path']) . '/'; if (!isset($_SESSION['uploaddir']) || !is_dir($root_path . $_SESSION['uploaddir'])) { echo 'ERROR:invalid uploaddirectory'; exit(0); } // cleanup the filename, copied some code from munge_string_to_url() and modified to exclude the extension $pos = strrpos($_FILES['Filedata']['name'], '.'); include '../lib/replacement.php'; $alias = substr($_FILES['Filedata']['name'], 0, $pos); $alias = str_replace($toreplace, $replacement, $alias); $alias = preg_replace('/[^a-z0-9-_]+/i', '-', $alias); $alias = trim($alias . substr($_FILES['Filedata']['name'], $pos), '-'); $filename = $_SESSION['uploaddir'] . '/' . $alias; $thumbname = $_SESSION['uploaddir'] . '/thumb_' . $alias; $thumbid = urlencode(base64_encode($thumbname)); if (Gallery_utils::CreateThumbnail('../' . $thumbname, $_FILES['Filedata']['tmp_name'], get_site_preference('thumbnail_width', 96), get_site_preference('thumbnail_height', 96), 'sc')) { move_uploaded_file($_FILES['Filedata']['tmp_name'], str_replace('/', DIRECTORY_SEPARATOR, $root_path . $filename)); echo 'FILEID:' . $thumbid; // Return the file id to the script } else { echo 'File corrupt: ' . $alias; } exit(0);
<?php if (!isset($gCms)) { exit; } // Check permissions if (!$this->CheckPermission('Use Gallery')) { echo $this->ShowErrors(lang('needpermissionto', 'Use Gallery')); return; } $file_id = isset($params['fid']) ? $params['fid'] : ''; $gallery = isset($params['gid']) ? $params['gid'] : ''; $galleryinfo = Gallery_utils::Getgalleryinfobyid($gallery); $query = "UPDATE " . cms_db_prefix() . "module_gallery SET defaultfile = ? WHERE fileid = ?"; $db->Execute($query, array($file_id, $gallery)); // Also change albumcovers of parentgalleries if ($galleryinfo['defaultfile'] != 0) { $query = "UPDATE " . cms_db_prefix() . "module_gallery SET defaultfile = ? WHERE defaultfile = ? AND fileid < ?"; $db->Execute($query, array($file_id, $galleryinfo['defaultfile'], $gallery)); } $this->Redirect($id, 'editgallery', $returnid, $params);
<?php if (!isset($gCms)) { exit; } if (!$this->CheckPermission('Use Gallery')) { echo $this->ShowErrors(lang('needpermissionto', 'Use Gallery')); return; } if (!isset($params['fid']) || !isset($params['degr'])) { $params = array('active_tab' => 'galleries', 'module_error' => lang('missingparams')); $this->Redirect($id, 'defaultadmin', '', $params); return; } // get image info $imageprops = Gallery_utils::Getimagebyid($params['fid']); $image = '../' . DEFAULT_GALLERY_PATH . $imageprops['filepath'] . $imageprops['filename']; Gallery_utils::RotateImage($image, $params['degr']); $params = array('fid' => $params['fid'], 'mode' => 'edit', 'active_tab' => 'thumbs', 'module_message' => $this->Lang('imageupdated')); $this->Redirect($id, 'editimage', '', $params);
function SearchReindex(&$module) { $galleries = Gallery_utils::GetGalleries(); foreach ($galleries as $gid => $gallery) { $galleryinfo = Gallery_utils::Getgalleryinfobyid($gid); if ($galleryinfo['active']) { $searchwords = $gallery['title'] . ' ' . $gallery['comment']; $db = $this->GetDB(); $query = "SELECT title, comment \n\t\t\t\t\t\t\t\t\tFROM " . cms_db_prefix() . "module_gallery g1\n\t\t\t\t\t\t\t\t\tWHERE galleryid=?"; $result = $db->Execute($query, array($gid)); if ($result && $result->RecordCount() > 0) { while ($row = $result->FetchRow()) { $searchwords .= ' ' . $row['title'] . ' ' . $row['comment']; } } $module->AddWords($this->GetName(), $gid, 'gallery', $searchwords); } } }
} // get the public custom fields for this item $rec->fields = Gallery_utils::Getcustomfields($rec->fileid, $rec->isdir, '', 1); if ($rec->thumb != $folderpath) { Gallery_utils::CreateThumbnail($rec->thumb, $originalimage, $galleryinfo['thumbwidth'] > 0 ? $galleryinfo['thumbwidth'] : IM_THUMBWIDTH, $galleryinfo['thumbwidth'] > 0 ? $galleryinfo['thumbheight'] : IM_THUMBHEIGHT, $galleryinfo['thumbwidth'] > 0 ? $galleryinfo['resizemethod'] : 'sc'); } array_push($images, $rec); } } // Sort array $images // second parameter of _ArraySort is an array of strings, which contains: // n for number, s for string // + for ascending, - for descending // fieldname $sortarray = explode('/', 'n+fileorder/' . $galleryinfo['sortitems']); $images = Gallery_utils::ArraySort($images, $sortarray, false); $itemcount = count($images); // Get the images we want $images = array_splice($images, $start - 1, $number); } else { $params['module_message'] = $this->Lang('message_wrongdir', htmlspecialchars($params['dir'])); $smarty->assign('hideparentlink', true); } // Expose the list to smarty. Use "by_ref" to save memory. $smarty->assign_by_ref('images', $images); // and a count of records $smarty->assign('imagecount', $imgcount . ' ' . ($imgcount == 1 ? $this->Lang('image') : $this->Lang('images'))); $smarty->assign('itemcount', $itemcount); $smarty->assign('numimages', $imgcount); $smarty->assign('numdirs', $itemcount - $imgcount); $smarty->assign('number', $number);
} if (!empty($params['x2']) && !empty($params['y2'])) { // get image info $image = Gallery_utils::Getimagebyid($params['fid']); // get templateproperties for thumbsizes if ($params['template'] == 0) { $tplthumb = array('templateid' => 0, 'thumbname' => '../' . DEFAULT_GALLERY_PATH . $image['filepath'] . IM_PREFIX . $image['filename'], 'thumbwidth' => IM_THUMBWIDTH, 'thumbheight' => IM_THUMBHEIGHT, 'resizemethod' => 'sc'); } else { $db = $this->GetDB(); $query = "SELECT *\n\t\t\t\tFROM " . cms_db_prefix() . "module_gallery_templateprops\n\t\t\t\tWHERE templateid=?"; $result = $db->Execute($query, array($params['template'])); if ($result && $result->RecordCount() > 0) { $templateprops = $result->GetArray(); $tplthumb = $templateprops[0]; $tplthumb['thumbname'] = '../' . DEFAULT_GALLERYTHUMBS_PATH . $params['fid'] . '-' . $params['template'] . substr($image['filename'], strrpos($image['filename'], '.')); } else { $params = array('fid' => $params['fid'], 'mode' => 'edit', 'active_tab' => 'thumbs', 'module_error' => lang('sqlerror', 'do_editthump.php')); $this->Redirect($id, 'editimage', '', $params); } } // update thumbnail @unlink($tplthumb['thumbname']); $thumbcr = Gallery_utils::CreateThumbnail($tplthumb['thumbname'], '../' . DEFAULT_GALLERY_PATH . $image['filepath'] . $image['filename'], $tplthumb['thumbwidth'], $tplthumb['thumbheight'], $tplthumb['resizemethod'], $params['x1'] * $params['scale'], $params['y1'] * $params['scale'], $params['x2'] * $params['scale'], $params['y2'] * $params['scale']); } if (isset($params['applybutton2'])) { $params = array('fid' => $params['fid'], 'mode' => 'edit', 'template' => $params['template'], 'active_tab' => 'thumbs', 'module_message' => $this->Lang('thumbupdated')); $this->Redirect($id, 'editimage', '', $params); } else { $params = array('gid' => $params['gid'], 'mode' => 'edit', 'module_message' => $this->Lang('thumbupdated')); $this->Redirect($id, 'editgallery', '', $params); }
$smarty->assign('prompt_template', $this->Lang('template')); $smarty->assign('template', $this->CreateInputDropdown($id, 'templateid', $templatelist, -1, isset($galleryinfo['templateid']) ? $galleryinfo['templateid'] : 0, $disabled)); } // editors multiselect field if ($this->GetPreference('use_permissions')) { $editorslist = Gallery_utils::GetEditors(); $selectededitors = $editors; $smarty->assign('prompt_editors', $this->Lang('editors')); $smarty->assign('editors', $this->CreateInputSelectList($id, 'editors[]', $editorslist, $selectededitors, 4, $disabled)); } else { $selectededitors = implode(';', $editors); $smarty->assign('prompt_editors', ''); $smarty->assign('editors', $this->CreateInputHidden($id, 'editors', $selectededitors)); } $multiactionlist = array($this->Lang('delete') => 'delete', $this->Lang('rotateclockwise') => 'rotateclockwise', $this->Lang('rotateanticlockwise') => 'rotateanticlockwise', $this->Lang('active') => 'active', $this->Lang('inactive') => 'inactive', $this->Lang('moveto') => 'move'); $galleries = Gallery_utils::GetGalleries(); foreach ($galleries as $gallery) { $gallerieslist[$gallery['filepath'] . $gallery['filename']] = $gallery['fileid']; } $smarty->assign('prompt_multiaction', $this->Lang('withselected')); $smarty->assign('multiaction', $this->CreateInputDropdown($id, 'multiaction', $multiactionlist, -1, '', 'id="multiaction"' . $disabled)); $smarty->assign('moveto', $this->CreateInputDropdown($id, 'moveto', $gallerieslist, -1, $params['gid'], 'id="moveto"' . $disabled)); $smarty->assign('multiactionsubmit', $this->CreateInputSubmit($id, 'multiactionsubmit', $this->Lang('apply'), $disabled, '', $this->Lang('areyousuremulti'))); $smarty->assign('prompt_parent', $this->Lang('parentgallery')); $smarty->assign('prompt_hideparentlink', $this->Lang('hideparentlink')); $smarty->assign('hidden', $this->CreateInputHidden($id, 'sort', '') . $this->CreateInputHidden($id, 'active', isset($galleryinfo['active']) ? $galleryinfo['active'] : 1)); $smarty->assign('submit', $permission_to_edit ? $this->CreateInputSubmit($id, 'submitbutton', $this->Lang('submit')) : ''); $smarty->assign('cancel', $this->CreateInputSubmit($id, 'cancel', $this->Lang('cancel'))); $smarty->assign('unsort', $permission_to_edit && $totaloffileorder > 0 ? $this->CreateInputSubmit($id, 'unsortbutton', $this->Lang('sortbysettings'), '', '', $this->Lang('sureunsort')) : ''); $smarty->assign('updatethumbs', $permission_to_edit && $numberofimages > 0 ? $this->CreateInputSubmit($id, 'updatethumbsbutton', $this->Lang('updatethumbs'), $disabled, '', $this->Lang('sureupdatethumbs') . "\\n" . $this->Lang('thumbsrecreated')) : ''); $smarty->assign('formend', $this->CreateFormEnd());
break; } } // foreach // save template $templatecode = $tpldetails['tplcode'] . TEMPLATE_SEPARATOR . $tpldetails['tplcss'] . TEMPLATE_SEPARATOR . $tpldetails['tpljs'] . '*}'; $this->SetTemplate($tpldetails['name'], $templatecode); // save css-file if (empty($tpldetails['tplcss'])) { @unlink('../modules/Gallery/templates/css/' . $tpldetails['name'] . '.css'); } else { $handle = fopen('../modules/Gallery/templates/css/' . $tpldetails['name'] . '.css', 'w'); fwrite($handle, $tpldetails['tplcss']); fclose($handle); } if ($tpldetails['thumbwidth'] <= 0 || $tpldetails['thumbheight'] <= 0) { $tpldetails['thumbwidth'] = NULL; $tpldetails['thumbheight'] = NULL; $tpldetails['resizemethod'] = NULL; } $tpldetails['maxnumber'] = $tpldetails['maxnumber'] > 0 ? $tpldetails['maxnumber'] : NULL; // check if the template already exists in the database, but not on initial install: $templates is set $templateprops = isset($templates) ? FALSE : Gallery_utils::GetTemplateprops($tpldetails['name']); // save templateproperties in database if ($templateprops) { $query = "UPDATE " . cms_db_prefix() . "module_gallery_templateprops\n\t\t\tSET version=?,about=?,thumbwidth=?,thumbheight=?,resizemethod=?,maxnumber=?,sortitems=?\n\t\t\tWHERE templateid=?"; $result = $db->Execute($query, array($tpldetails['version'], $tpldetails['about'], $tpldetails['thumbwidth'], $tpldetails['thumbheight'], $tpldetails['resizemethod'], $tpldetails['maxnumber'], $tpldetails['sortitems'], $templateprops['templateid'])); } else { $query = "INSERT INTO " . cms_db_prefix() . "module_gallery_templateprops\n\t\t\t(template,version,about,thumbwidth,thumbheight,resizemethod,maxnumber,sortitems,visible)\n\t\t\tVALUES (?,?,?,?,?,?,?,?,?)"; $result = $db->Execute($query, array($tpldetails['name'], $tpldetails['version'], $tpldetails['about'], $tpldetails['thumbwidth'], $tpldetails['thumbheight'], $tpldetails['resizemethod'], $tpldetails['maxnumber'], $tpldetails['sortitems'], $tpldetails['name'] == 'gallerytree' ? 0 : 1)); }
$contents = $this->GetPreference($params['defaulttemplatepref']); } if (isset($params['template']) && $params['template'] != '') { $contents = $this->GetTemplate($params['template']); $templateprops = Gallery_utils::GetTemplateprops($params['template']); } } else { if (!isset($params['template'])) { $params['module_error'] = lang('missingparams'); $this->Redirect($id, 'defaultadmin', '', $params); return; } $smarty->assign('formstart', $this->CreateFormStart($id, 'do_edittemplate', $returnid, 'post', '', false, '', $params)); $smarty->assign('templatename', $params['template']); $contents = $this->GetTemplate($params['template']); $templateprops = Gallery_utils::GetTemplateprops($params['template']); } $smarty->assign('hidden', $this->CreateInputHidden($id, 'templateid', $templateprops['templateid']) . $this->CreateInputHidden($id, 'version', $templateprops['version']) . $this->CreateInputHidden($id, 'about', $templateprops['about'])); $smarty->assign('prompt_thumbnailsize', $this->Lang('thumbnailsize')); $resizemethodlist = array($this->Lang('crop') => 'cr', $this->Lang('scale') => 'sc', $this->Lang('zoomcrop') => 'zc', $this->Lang('zoomscale') => 'zs'); $smarty->assign('thumbnailsize', $this->Lang('leaveempty') . '<br />' . $this->Lang('width') . ': ' . $this->CreateInputText($id, 'thumbwidth', $templateprops['thumbwidth'], 4, 4) . ' ' . $this->Lang('height') . ': ' . $this->CreateInputText($id, 'thumbheight', $templateprops['thumbheight'], 4, 4) . ' ' . $this->Lang('resizemethod') . ': ' . $this->CreateInputDropdown($id, 'resizemethod', $resizemethodlist, -1, $templateprops['resizemethod'])); $sortfieldlist = array(' -' => '', 'filename' => 's#file', 'filedate' => 's#filedate', 'title' => 's#title', 'titlename' => 's#titlename', 'comment' => 's#comment', 'subgallery (true/false)' => 'n#isdir', 'active (true/false)' => 'n#active'); $sorttypelist = array($this->Lang('ascending') => '+', $this->Lang('descending') => '-'); $sortitems = explode('/', $templateprops['sortitems']); $sortfields = ''; foreach ($sortitems as $sortitem) { $sortfields .= '<p class="sortfield">' . $this->CreateInputDropdown($id, 'sortfield[]', $sortfieldlist, -1, substr($sortitem, 0, 1) . '#' . substr($sortitem, 2)) . ' ' . $this->CreateInputDropdown($id, 'sorttype[]', $sorttypelist, -1, substr($sortitem, 1, 1)) . '</p>'; } $smarty->assign('prompt_sortingoptions', $this->Lang('sortingoptions')); $smarty->assign('sortingoptions', '<p>' . $this->Lang('specifysortfields') . '</p>' . '<div id="sortfields">' . $sortfields . '</div> <p><a href="#" id="addfield">' . $this->Lang('addfield') . '</a> <a href="#" id="deletefield">' . $this->Lang('deletefield') . '</a></p>');
} $this->SetPreference('allowed_extensions', $params['allowed_extensions']); if (ctype_digit($params['maximagewidth'])) { $this->SetPreference("maximagewidth", $params['maximagewidth']); } if (ctype_digit($params['maximageheight'])) { $this->SetPreference("maximageheight", $params['maximageheight']); } if (ctype_digit($params['imagejpgquality']) && $params['imagejpgquality'] <= 100) { $this->SetPreference('imagejpgquality', $params['imagejpgquality']); } if (ctype_digit($params['thumbjpgquality']) && $params['thumbjpgquality'] <= 100) { $this->SetPreference('thumbjpgquality', $params['thumbjpgquality']); } $this->SetPreference('use_permissions', isset($params['use_permissions']) ? $params['use_permissions'] : false); $this->SetPreference('newgalleries_active', isset($params['newgalleries_active']) ? $params['newgalleries_active'] : false); $this->SetPreference('use_comment_wysiwyg', isset($params['use_comment_wysiwyg']) ? $params['use_comment_wysiwyg'] : false); $this->SetPreference('editdirdates', isset($params['editdirdates']) ? $params['editdirdates'] : false); $this->SetPreference('editfiledates', isset($params['editfiledates']) ? $params['editfiledates'] : false); $this->SetPreference('fe_folderpath', empty($params['fe_folderpath']) ? 'modules/Gallery/images/folder.png' : $params['fe_folderpath']); $this->SetPreference('be_folderpath', empty($params['be_folderpath']) ? 'modules/Gallery/images/foldersmall.png' : $params['be_folderpath']); if (isset($params['updatethumbs']) && $params['updatethumbs'] == 1) { Gallery_utils::DeleteFiles(str_replace('/', DIRECTORY_SEPARATOR, '../' . DEFAULT_GALLERYTHUMBS_PATH), '*', false); $galleries = Gallery_utils::GetGalleries(); foreach ($galleries as $gallery) { $dir = str_replace('/', DIRECTORY_SEPARATOR, '../' . DEFAULT_GALLERY_PATH . $gallery['filepath'] . (empty($gallery['filepath']) ? '' : '/') . ($gallery['filename'] == "Gallery/" ? '' : $gallery['filename'])); Gallery_utils::DeleteFiles($dir, IM_PREFIX . '*', false); } } $params = array('tab_message' => 'optionsupdated', 'active_tab' => 'options'); $this->Redirect($id, 'defaultadmin', '', $params);
<?php $falseimage1 = $themeObject->DisplayImage('icons/system/false.gif', $this->Lang('settrue'), '', '', 'systemicon'); $trueimage1 = $themeObject->DisplayImage('icons/system/true.gif', $this->Lang('default'), '', '', 'systemicon'); $falseimage2 = $themeObject->DisplayImage('icons/system/false.gif', $this->Lang('makevisible'), '', '', 'systemicon'); $trueimage2 = $themeObject->DisplayImage('icons/system/true.gif', $this->Lang('makeinvisible'), '', '', 'systemicon'); $alltemplates = $this->ListTemplates(); $current_template = $this->GetPreference('current_template'); $singleimg_template = $this->GetPreference('singleimg_template'); $rowarray = array(); $rowclass = 'row1'; foreach ($alltemplates as $tpl) { $tplprops = Gallery_utils::GetTemplateprops($tpl); $row = new StdClass(); $row->name = $this->CreateLink($id, 'edittemplate', $returnid, $tpl, array('template' => $tpl, 'mode' => 'edit')); $row->version = $tplprops['version']; $row->about = $this->CreateLink($id, 'edittplabout', $returnid, $this->Lang('prompt_about'), array('template' => $tpl, 'mode' => 'show')); $row->rowclass = $rowclass; if ($tpl == $current_template) { $row->default = $trueimage1; } else { $row->default = $this->CreateLink($id, 'switchdefaulttemplate', $returnid, $falseimage1, array('template' => $tpl)); } $row->visible = $this->CreateLink($id, 'edittemplate', $returnid, $tplprops['visible'] ? $trueimage2 : $falseimage2, array('mode' => 'switchactive', 'templateid' => $tplprops['templateid'])); $row->editlink = $this->CreateLink($id, 'edittemplate', $returnid, $gCms->variables['admintheme']->DisplayImage('icons/system/edit.gif', $this->Lang('edit'), '', '', 'systemicon'), array('template' => $tpl, 'mode' => 'edit')); $row->copylink = $this->CreateLink($id, 'edittemplate', $returnid, $gCms->variables['admintheme']->DisplayImage('icons/system/copy.gif', $this->Lang('copy'), '', '', 'systemicon'), array('template' => $tpl, 'mode' => 'add')); if ($tpl == $current_template || $tpl == $singleimg_template) { $row->deletelink = ' '; } else { $row->deletelink = $this->CreateLink($id, 'deletetemplate', $returnid, $gCms->variables['admintheme']->DisplayImage('icons/system/delete.gif', $this->Lang('delete'), '', '', 'systemicon'), array('template' => $tpl), $this->Lang('areyousure')); }