public function getInstalledTemplates() { $templatePath = ISC_BASE_PATH."/templates"; GetLib('class.file'); $templateCount = 0; $templates = scandir($templatePath); natcasesort($templates); foreach($templates as $k => $template) { if ($template == "." || $template == ".." || $template == "CVS" || $template == ".svn" || $template == 'blank.dat' || $template{0} == '_') { continue; } $previewPath = $templatePath . '/' . $template . '/Previews'; if(!is_dir($previewPath)) { continue; } $previews = new FileClass; $previews->SetLoadDir($previewPath); $doneColors = array(); while(($preview = $previews->NextFile()) !== false) { if(substr($preview,-4) != ".jpg" && substr($preview,-5) != ".jpeg" && substr($preview,-4) != ".gif") { continue; } $templateColor = ucfirst(str_replace(array(".jpg",".jpeg","gif","fixed_","stretched_"), "", strtolower($preview))); if(in_array($templateColor, $doneColors)) { continue; } $doneColors[] = $templateColor; $templateList[] = array( 'template' => $template, 'templateName' => ucfirst($template), 'templateColor' => ucfirst($templateColor), 'preview' => $preview, 'installed' => true, 'previewFull' => getConfig('ShopPathNormal').'/templates/'.$template.'/Previews/'.$preview, 'preview' => 'thumb.php?tpl='.$template.'&color='.$preview, ); ++$templateCount; } } return $templateList; }
public function DeleteDir($dir, $Recursive=false) { if (is_dir($this->GetDir() . $dir)) { if($Recursive === true) { $tmp = new FileClass; $tmp->SetLoadDir($this->GetDir() . $dir); while(($f = $tmp->NextFile()) !== false) { $tmp->DeleteFile($f); } $tmp->ResetHandle(); while(($d = $tmp->NextDir()) !== false) { $tmp->DeleteDir($d, $Recursive); } $tmp->CloseDirHandle(); unset($tmp); } if(rmdir($this->GetDir() . $dir)) { return true; } else { return false; } } else { return false; } }
public function LoadChooseTemplateTab() { $templatePath = ISC_BASE_PATH . "/templates"; GetLib('class.file'); $templateCount = 0; $templates = scandir($templatePath); natcasesort($templates); foreach ($templates as $k => $template) { if ($template == "." || $template == ".." || $template == "CVS" || $template == ".svn" || $template == 'blank.dat' || $template[0] == '_') { continue; } $previewPath = $templatePath . '/' . $template . '/Previews'; if (!is_dir($previewPath)) { continue; } $previews = new FileClass(); $previews->SetLoadDir($previewPath); $doneColors = array(); while (($preview = $previews->NextFile()) !== false) { if (substr($preview, -4) != ".jpg" && substr($preview, -5) != ".jpeg" && substr($preview, -4) != ".gif") { continue; } $templateColor = ucfirst(str_replace(array(".jpg", ".jpeg", "gif", "fixed_", "stretched_"), "", strtolower($preview))); if (in_array($templateColor, $doneColors)) { continue; } $doneColors[] = $templateColor; $templateList[] = array('template' => $template, 'templateName' => ucfirst($template), 'templateColor' => $templateColor, 'preview' => $preview, 'id' => uniqid(5)); ++$templateCount; if (GetConfig('template') == $template && strtolower($templateColor) == GetConfig('SiteColor')) { $GLOBALS['CurrentTemplateImage'] = $preview; } } } if (isset($_REQUEST['page'])) { $pageNumber = (int) $_REQUEST['page']; } else { $pageNumber = 1; } $perPage = 20; if (isset($_REQUEST['perpage'])) { $perPage = (int) $_REQUEST['perpage']; } $startNumber = $pageNumber * $perPage - $perPage; $pageCount = ceil(count($templateList) / $perPage); $GLOBALS['PageNumber'] = $pageNumber; switch ($perPage) { case 10: $GLOBALS['PerPage10Selected'] = 'selected="selected"'; break; case 50: $GLOBALS['PerPage50Selected'] = 'selected="selected"'; break; case 100: $GLOBALS['PerPage100Selected'] = 'selected="selected"'; break; default: $GLOBALS['PerPage20Selected'] = 'selected="selected"'; break; } $GLOBALS['Nav'] = ''; if ($pageCount > 1) { $GLOBALS['Nav'] = sprintf("(%s %d of %d) ", GetLang('Page'), $pageNumber, $pageCount); $GLOBALS['Nav'] .= BuildPagination(count($templateList), $perPage, $pageNumber, "index.php?ToDo=viewTemplates"); } $GLOBALS['TemplateListMap'] = ''; for ($i = $startNumber; $i < $startNumber + $perPage; ++$i) { if (!isset($templateList[$i])) { continue; } $template = $templateList[$i]; $GLOBALS['Template'] = $template['template']; $GLOBALS['TemplateName'] = $template['templateName']; $GLOBALS['TemplateColor'] = $template['templateColor']; $GLOBALS['TemplatePreview'] = $template['preview']; $GLOBALS['TemplateID'] = $template['id']; $GLOBALS['ISC_CLASS_TEMPLATE']->SetTemplate('layout.choosetemplate.row'); $templateCode = $GLOBALS['ISC_CLASS_TEMPLATE']->ParseTemplate(true); if (strtolower($template['templateColor']) == strtolower(GetConfig('SiteColor')) && $template['template'] == GetConfig('template')) { $GLOBALS['TemplateListMap'] .= '<div class="TemplateBoxOn" id="' . $GLOBALS['TemplateID'] . '">' . $templateCode . '</div>'; } else { $GLOBALS['TemplateListMap'] .= '<div class="TemplateBox" id="' . $GLOBALS['TemplateID'] . '" onmouseover="this.className=\'TemplateBoxOver\'" onmouseout="this.className=\'TemplateBox\'">' . $templateCode . '</div>'; } } }