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)); }
if ($imgdata[0] > $maxwidth) { $imgratio = $imgdata[0] / $imgdata[1]; // width/height $height = ceil($maxwidth / $imgratio); $onerow->filewidthheight = 'width="' . $maxwidth . '" height="' . $height . '"'; $imgscale = $imgdata[0] / $maxwidth; } $params['multiaction'] = 'switchactive'; $onerow->activelink = $this->CreateLink($id, 'multiaction', $returnid, $file['active'] ? $trueimage : $falseimage, $params); unset($params['multiaction']); if ($params['template'] == 0) { $onerow->thumburl = '../' . DEFAULT_GALLERY_PATH . $file['filepath'] . IM_PREFIX . $file['filename']; } else { $onerow->thumburl = '../' . DEFAULT_GALLERYTHUMBS_PATH . $file['fileid'] . '-' . $params['template'] . substr($file['filename'], strrpos($file['filename'], '.')); if (!file_exists($onerow->thumburl)) { $templateprops = Gallery_utils::GetTemplateprops($params['template']); Gallery_utils::CreateThumbnail($onerow->thumburl, $onerow->file, $templateprops['thumbwidth'], $templateprops['thumbheight'], $templateprops['resizemethod']); } } $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'];
$params['origaction'] = $params['action']; $galleryinfo = Gallery_utils::Getgalleryinfobyid($params['gid']); // check permission to edit $userid = get_userid(); $editors = explode(';', $galleryinfo['editors']); if (Gallery_utils::CheckEditor($userid, $params['gid'], $editors)) { $permission_to_edit = TRUE; $disabled = ''; } else { $permission_to_edit = FALSE; $disabled = ' disabled="disabled"'; } $defaulttemplate = $this->GetPreference('current_template'); if ($galleryinfo['templateid'] == 0) { // override template settings with default template $templateprops = Gallery_utils::GetTemplateprops($defaulttemplate); $galleryinfo['thumbwidth'] = $templateprops['thumbwidth']; $galleryinfo['sortitems'] = $templateprops['sortitems']; } $totaloffileorder = 0; $numberofimages = 0; if ($params['mode'] == 'add') { $smarty->assign('formstart', $this->CreateFormStart($id, 'do_editgallery', $returnid, 'post', '', false, '', $params)); $smarty->assign('prompt_directoryname', $this->Lang('directoryname')); $smarty->assign('directoryname', $this->CreateInputText($id, 'directoryname', "", 40, 100)); $smarty->assign('gallerytitle', $this->CreateInputText($id, 'gallerytitle', "", 40, 100)); $smarty->assign('gallerycomment', $this->CreateTextArea($this->GetPreference('use_comment_wysiwyg', 1), $id, "", 'gallerycomment', 'fake" style="height:6em;', '', '', '', '80', '3')); if ($this->GetPreference('editdirdates')) { $smarty->assign('gallerydate', $this->CreateInputText($id, 'gallerydate', Date('Y-m-d'), 10, 10)); } else { $smarty->assign('gallerydate', "");
$smarty->assign('gallerytitle', htmlspecialchars(trim(substr($params['dir'], strrpos($params['dir'], '/')), "/"))); $smarty->assign('galleryid', ''); // get gallery info $galleryinfo = Gallery_utils::Getgalleryinfo($params['dir']); if (isset($params['template'])) { // override template settings with param template $templateprops = Gallery_utils::GetTemplateprops($params['template']); $galleryinfo['templateid'] = $templateprops['templateid']; $galleryinfo['template'] = $templateprops['template']; $galleryinfo['thumbwidth'] = $templateprops['thumbwidth']; $galleryinfo['thumbheight'] = $templateprops['thumbheight']; $galleryinfo['resizemethod'] = $templateprops['resizemethod']; } if (empty($galleryinfo['templateid'])) { // override template settings with default template $templateprops = Gallery_utils::GetTemplateprops($template); $galleryinfo['templateid'] = $templateprops['templateid']; $galleryinfo['template'] = $templateprops['template']; $galleryinfo['thumbwidth'] = $templateprops['thumbwidth']; $galleryinfo['thumbheight'] = $templateprops['thumbheight']; $galleryinfo['resizemethod'] = $templateprops['resizemethod']; } $template = $galleryinfo['template']; if ($galleryinfo['active'] == 1) { if (!empty($galleryinfo['title'])) { $smarty->assign('gallerytitle', $galleryinfo['title']); } $smarty->assign('gallerycomment', $galleryinfo['comment']); $smarty->assign('parentlink', ''); } $targetpage = '';
<?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')); }