?> | version <?php echo $theme['version']; ?> </h4></span> <p><?php echo $theme['description']; ?> </p> </div> <div class="action"> <?php if ($theme['id'] !== 'themr') { ?> <?php if (Themr::isInstalled($theme['id'])) { ?> <a href="<?php echo get_url('plugin/themr/uninstall/' . $theme['id']); ?> " onclick="return confirm('<?php echo __('Are you sure you wish to uninstall'); ?> <?php echo $theme['name']; ?> ?');"><?php echo __('Uninstall'); ?> </a> <?php
/** * Uninstall a theme along with snippets that came with it. * * @since 0.1.0 * */ public function uninstall($id) { $layoutUsed = 0; $theme = Record::findOneFrom('Themr', 'name=?', array($id)); // Get Current Theme Info $theme_info = Themr::findTheme($id); foreach (unserialize($theme->layout) as $layouts) { // find the user to delete if ($layout = Record::findOneFrom('Layout', 'name=?', array(Themr::theme_name($layouts)))) { if ($layout->isUsed()) { Flash::set('error', __('Theme <b>:theme</b> CANNOT be deleted because layout <b>:name</b> is being used!', array(':name' => $layout->name, ':theme' => $theme_info['name']))); $layoutUsed = 1; } else { if ($layout->delete()) { Flash::set('success', __('Layout <b>:name</b> has been deleted!', array(':name' => $layout->name))); } else { Flash::set('error', __('Layout <b>:name</b> has not been deleted!', array(':name' => $layout->name))); } } } else { Flash::set('error', __('Layout not found!')); } } if ($layoutUsed !== 1) { foreach (unserialize($theme->snippet) as $snippets) { // find the snippet to delete if ($snippet = Record::findOneFrom('Snippet', 'name=?', array($snippets))) { if ($snippet->delete()) { Flash::set('success', __('Snippet <b>:name</b> has been deleted!', array(':name' => $snippet->name))); } else { Flash::set('error', __('Snippet <b>:name</b> has not been deleted!', array(':name' => $snippet->name))); } } else { Flash::set('error', __('Snippet not found!')); } } if ($theme->delete()) { Flash::set('success', __('Theme <b>:name</b> has been uninstalled!', array(':name' => $theme_info['name']))); redirect(get_url('plugin/themr')); } else { Flash::set('error', __('Theme <b>:name</b> has not been uninstalled!', array(':name' => $theme_info['name']))); redirect(get_url('plugin/themr')); } } else { redirect(get_url('plugin/themr')); } }