function AvailableList($show_options = true) { global $langmessage, $config; //search settings $this->searchPerPage = 10; $this->searchOrderOptions = array(); $this->searchOrderOptions['modified'] = $langmessage['Recently Updated']; $this->searchOrderOptions['rating_score'] = $langmessage['Highest Rated']; $this->searchOrderOptions['downloads'] = $langmessage['Most Downloaded']; $this->SearchOrder(); // get addon information for ordering admin_tools::VersionData($version_data); $version_data = $version_data['packages']; // combine remote addon information foreach ($this->avail_addons as $theme_id => $info) { if (isset($info['id'])) { $id = $info['id']; if (isset($version_data[$id])) { $info = array_merge($info, $version_data[$id]); $info['rt'] *= 5; } //use local rating if (isset($this->addonReviews[$id])) { $info['rt'] = $this->addonReviews[$id]['rating']; } } else { $info['rt'] = 6; //give local themes a high rating to make them appear first, rating won't actually display } $info += array('dn' => 0, 'rt' => 0); //modified time if (!isset($info['tm'])) { $info['tm'] = self::ModifiedTime($info['full_dir']); } $this->avail_addons[$theme_id] = $info; } // sort by uasort($this->avail_addons, array('admin_theme_content', 'SortUpdated')); switch ($this->searchOrder) { case 'downloads': uasort($this->avail_addons, array('admin_theme_content', 'SortDownloads')); break; case 'modified': uasort($this->avail_addons, array('admin_theme_content', 'SortRating')); uasort($this->avail_addons, array('admin_theme_content', 'SortUpdated')); break; case 'rating_score': default: uasort($this->avail_addons, array('admin_theme_content', 'SortRating')); break; } // pagination $this->searchMax = count($this->avail_addons); if (isset($_REQUEST['page']) && ctype_digit($_REQUEST['page'])) { $this->searchPage = $_REQUEST['page']; } $start = $this->searchPage * $this->searchPerPage; $possible = array_slice($this->avail_addons, $start, $this->searchPerPage, true); if ($show_options) { $this->SearchOptions(); } // show themes echo '<div id="gp_avail_themes">'; foreach ($possible as $theme_id => $info) { $theme_label = str_replace('_', ' ', $info['name']); $version = ''; $id = false; if (isset($info['version'])) { $version = $info['version']; } if (isset($info['id']) && is_numeric($info['id'])) { $id = $info['id']; } $has_screenshot = file_exists($info['full_dir'] . '/screenshot.png'); //screenshot if ($has_screenshot) { echo '<div class="expand_child_click">'; echo '<b class="gp_theme_head">' . $theme_label . ' ' . $version . '</b>'; echo '<div style="background-image:url(\'' . common::GetDir($info['rel'] . '/screenshot.png') . '\')">'; } else { echo '<div>'; echo '<b class="gp_theme_head">' . $theme_label . ' ' . $version . '</b>'; echo '<div>'; } //options echo '<div class="gp_theme_options">'; //colors echo '<b>' . $langmessage['preview'] . '</b>'; echo '<ul>'; foreach ($info['colors'] as $color) { echo '<li>'; $q = 'cmd=preview&theme=' . rawurlencode($theme_id . '/' . $color) . $this->searchQuery; if ($this->searchPage) { $q .= '&page=' . $this->searchPage; } echo common::Link('Admin_Theme_Content/Available', str_replace('_', ' ', $color), $q); echo '</li>'; } echo '</ul>'; ob_start(); if ($id) { //more info echo '<li>' . $this->DetailLink('theme', $id, 'More Info...') . '</li>'; //support $forum_id = 1000 + $id; echo '<li><a href="' . addon_browse_path . '/Forum?show=f' . $forum_id . '" target="_blank">' . $langmessage['Support'] . '</a></li>'; //rating $rating = 0; if ($info['rt'] > 0) { $rating = $info['rt']; } echo '<li><span class="nowrap">' . $langmessage['rate'] . ' ' . $this->ShowRating($info['rel'], $rating) . '</span></li>'; //downloads if ($info['dn'] > 0) { echo '<li><span class="nowrap">Downloads: ' . number_format($info['dn']) . '</span></li>'; } } //last updated if ($info['tm'] > 0) { echo '<li><span class="nowrap">' . $langmessage['Modified'] . ': '; echo common::date($langmessage['strftime_datetime'], $info['tm']); echo '</span></li>'; } if ($info['is_addon']) { //delete $folder = $info['folder']; $title = sprintf($langmessage['generic_delete_confirm'], $theme_label); $attr = array('data-cmd' => 'cnreq', 'class' => 'gpconfirm', 'title' => $title); echo '<li>' . common::Link('Admin_Theme_Content', $langmessage['delete'], 'cmd=deletetheme&folder=' . rawurlencode($folder), $attr) . '</li>'; //order if (isset($config['themes'][$folder]['order'])) { echo '<li>Order: ' . $config['themes'][$folder]['order'] . '</li>'; } } $options = ob_get_clean(); if (!empty($options)) { echo '<b>' . $langmessage['options'] . '</b>'; echo '<ul>'; echo $options; echo '</ul>'; } echo '</div></div>'; //remote upgrade if (gp_remote_themes && $id && isset(admin_tools::$new_versions[$id]) && version_compare(admin_tools::$new_versions[$id]['version'], $version, '>')) { $version_info = admin_tools::$new_versions[$id]; echo common::Link('Admin_Theme_Content', $langmessage['new_version'], 'cmd=remote_install&id=' . $id . '&name=' . rawurlencode($version_info['name'])); } echo '</div>'; } echo '</div>'; if ($show_options) { $this->SearchNavLinks(); } }
function Update() { global $langmessage, $gp_filesystem; if (!$this->core_package) { echo $langmessage['OOPS'] . ' (Core Package Not Set)'; return false; } if (isset($_POST['step'])) { $this->curr_step = (int) $_POST['step']; } //already up to date? if ($this->curr_step < 4 && version_compare(gpversion, $this->core_package['version'], '>=')) { msg($langmessage['UP_TO_DATE']); return false; } //filesystem $filesystem_method = $this->DetectFileSystem(); if (!$filesystem_method) { msg('Update Aborted: Could not establish a file writing method compatible with your server.'); return false; } $this->steps[1] = $langmessage['step:prepare']; $this->steps[2] = $langmessage['step:download']; $this->steps[3] = $langmessage['step:unpack']; $this->steps[4] = $langmessage['step:clean']; echo '<div>' . $langmessage['update_steps'] . '</div>'; echo '<ol class="steps">'; $curr_step_label = ''; foreach ($this->steps as $temp_step => $message) { if ($this->curr_step == $temp_step) { echo '<li class="current">' . $message . '</li>'; $curr_step_label = $message; } elseif ($temp_step < $this->curr_step) { echo '<li class="done">' . $message . '</li>'; } else { echo '<li>' . $message . '</li>'; } } echo '</ol>'; echo '<h3>' . $curr_step_label . '</h3>'; echo '<form method="post" action="?cmd=update">'; if ($filesystem_method) { echo '<input type="hidden" name="filesystem_method" value="' . htmlspecialchars($filesystem_method) . '" />'; } $done = false; $passed = false; ob_start(); switch ($this->curr_step) { case 4: $done = $this->CleanUp(); break; case 3: $passed = $this->UnpackAndReplace(); $this->OldFolders(); break; case 2: $passed = $this->DownloadSource(); break; case 1: $passed = $this->GetServerInfo(); break; } $step_content = ob_get_clean(); $this->OutputMessages(); echo $step_content; if ($gp_filesystem) { $gp_filesystem->destruct(); } admin_tools::VersionData($this->update_data); //save any changes made by the steps if (!$done) { if ($passed) { echo '<input type="hidden" name="step" value="' . min(count($this->steps), $this->curr_step + 1) . '"/>'; echo '<input type="submit" class="submit" name="" value="' . htmlspecialchars($langmessage['next_step']) . '" />'; } elseif ($this->curr_step < 3) { echo '<input type="hidden" name="step" value="' . min(count($this->steps), $this->curr_step) . '"/>'; echo '<input type="submit" class="submit" name="" value="' . htmlspecialchars($langmessage['continue']) . '" />'; } else { echo '<input type="hidden" name="failed_install" value="failed_install"/>'; echo '<input type="hidden" name="step" value="4"/>'; echo '<input type="submit" class="submit" name="" value="' . htmlspecialchars($langmessage['step:clean']) . '..." />'; } } echo '</form>'; return true; }