123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150 |
- <?php
- class ModuleUpdater extends Updater implements DrupalUpdaterInterface {
-
- public function getInstallDirectory() {
- if ($this->isInstalled() && ($relative_path = drupal_get_path('module', $this->name))) {
- $relative_path = dirname($relative_path);
- }
- else {
- $relative_path = 'sites/all/modules';
- }
- return DRUPAL_ROOT . '/' . $relative_path;
- }
- public function isInstalled() {
- return (bool) drupal_get_filename('module', $this->name, NULL, FALSE);
- }
- public static function canUpdateDirectory($directory) {
- if (file_scan_directory($directory, '/.*\.module$/')) {
- return TRUE;
- }
- return FALSE;
- }
- public static function canUpdate($project_name) {
- return (bool) drupal_get_path('module', $project_name);
- }
-
- public function getSchemaUpdates() {
- require_once DRUPAL_ROOT . '/includes/install.inc';
- require_once DRUPAL_ROOT . '/includes/update.inc';
- if (_update_get_project_type($project) != 'module') {
- return array();
- }
- module_load_include('install', $project);
- if (!$updates = drupal_get_schema_versions($project)) {
- return array();
- }
- $updates_to_run = array();
- $modules_with_updates = update_get_update_list();
- if ($updates = $modules_with_updates[$project]) {
- if ($updates['start']) {
- return $updates['pending'];
- }
- }
- return array();
- }
-
- public function postInstallTasks() {
- return array(
- l(t('Install another module'), 'admin/modules/install'),
- l(t('Enable newly added modules'), 'admin/modules'),
- l(t('Administration pages'), 'admin'),
- );
- }
- public function postUpdateTasks() {
-
-
- }
- }
- class ThemeUpdater extends Updater implements DrupalUpdaterInterface {
-
- public function getInstallDirectory() {
- if ($this->isInstalled() && ($relative_path = drupal_get_path('theme', $this->name))) {
- $relative_path = dirname($relative_path);
- }
- else {
- $relative_path = 'sites/all/themes';
- }
- return DRUPAL_ROOT . '/' . $relative_path;
- }
- public function isInstalled() {
- return (bool) drupal_get_filename('theme', $this->name, NULL, FALSE);
- }
- static function canUpdateDirectory($directory) {
-
- if (file_scan_directory($directory, '/.*\.module$/')) {
- return FALSE;
- }
- return TRUE;
- }
- public static function canUpdate($project_name) {
- return (bool) drupal_get_path('theme', $project_name);
- }
- public function postInstall() {
-
- clearstatcache();
- system_rebuild_theme_data();
- }
- public function postInstallTasks() {
- return array(
- l(t('Enable newly added themes'), 'admin/appearance'),
- l(t('Administration pages'), 'admin'),
- );
- }
- }
|