Esempio n. 1
0
 /**
  * Run through the installation process
  *
  */
 public function InstallSteps()
 {
     global $dataDir, $langmessage;
     $this->GetAddonData();
     // addonHistory
     $this->Init_PT();
     // $this->config
     //get from remote
     if ($this->remote_install && !$this->GetRemote()) {
         return false;
     }
     //check ini contents
     if (!$this->CheckIni()) {
         return false;
     }
     $this->SetDestination();
     $this->DataFolder();
     $this->IniContents();
     if (!$this->PrepConfig()) {
         return false;
     }
     if (!$this->CheckFile()) {
         return false;
     }
     //hooks
     if (!$this->Hooks()) {
         return false;
     }
     //layout
     if (!$this->Layout()) {
         return false;
     }
     //move new addon folder into place
     if (!$this->FinalizeFolder()) {
         return false;
     }
     if (!$this->FinalizeConfig()) {
         return false;
     }
     // Save
     if (!\gp\admin\Tools::SaveAllConfig()) {
         $this->message($langmessage['OOPS'] . ' (Configuration not saved)');
         return false;
     }
     if (!is_null($this->order)) {
         $img_path = \gp\tool::IdUrl('ci');
         \gp\tool::IdReq($img_path);
     }
     $this->UpdateHistory();
     return true;
 }
Esempio n. 2
0
 /**
  * Move To Trash
  * Hide special pages
  *
  */
 public function MoveToTrash()
 {
     global $gp_titles, $gp_index, $langmessage, $gp_menu, $config, $dataDir;
     $this->CacheSettings();
     $_POST += array('index' => '');
     $indexes = explode(',', $_POST['index']);
     $trash_data = array();
     foreach ($indexes as $index) {
         $title = \gp\tool::IndexToTitle($index);
         // Create file in trash
         if ($title) {
             if (!\gp\admin\Content\Trash::MoveToTrash_File($title, $index, $trash_data)) {
                 msg($langmessage['OOPS'] . ' (Not Moved)');
                 $this->RestoreSettings();
                 return false;
             }
         }
         // Remove from menu
         if (isset($gp_menu[$index])) {
             if (count($gp_menu) == 1) {
                 continue;
             }
             if (!$this->RmFromMenu($index, false)) {
                 msg($langmessage['OOPS']);
                 $this->RestoreSettings();
                 return false;
             }
         }
         unset($gp_titles[$index]);
         unset($gp_index[$title]);
     }
     \gp\admin\Menu\Tools::ResetHomepage();
     if (!\gp\admin\Tools::SaveAllConfig()) {
         $this->RestoreSettings();
         return false;
     }
     $link = \gp\tool::GetUrl('Admin/Trash');
     msg(sprintf($langmessage['MOVED_TO_TRASH'], $link));
     \gp\tool\Plugins::Action('MenuPageTrashed', array($indexes));
     return true;
 }
Esempio n. 3
0
 /**
  * Delete a remote theme
  *
  */
 public function DeleteTheme()
 {
     global $langmessage, $dataDir, $gpLayouts, $config;
     $config_before = $config;
     $gpLayoutsBefore = $gpLayouts;
     $theme_folder_name =& $_POST['folder'];
     $theme_folder = $dataDir . '/data/_themes/' . $theme_folder_name;
     if (empty($theme_folder_name) || !ctype_alnum($theme_folder_name)) {
         message($langmessage['OOPS'] . ' (Invalid Request)');
         return false;
     }
     $order = false;
     if (isset($config['themes'][$theme_folder_name]['order'])) {
         $order = $config['themes'][$theme_folder_name]['order'];
     }
     if (!$this->CanDeleteTheme($theme_folder_name, $message)) {
         message($message);
         return false;
     }
     //remove layouts
     $rm_addon = false;
     foreach ($gpLayouts as $layout_id => $layout_info) {
         if (!isset($layout_info['is_addon']) || !$layout_info['is_addon']) {
             continue;
         }
         $layout_folder = dirname($layout_info['theme']);
         if ($layout_folder != $theme_folder_name) {
             continue;
         }
         if (array_key_exists('addon_key', $layout_info)) {
             $rm_addon = $layout_info['addon_key'];
         }
         $this->RmLayoutPrep($layout_id);
         unset($gpLayouts[$layout_id]);
     }
     //remove from settings
     unset($config['themes'][$theme_folder_name]);
     if ($rm_addon) {
         $installer = new \gp\admin\Addon\Installer();
         if (!$installer->Uninstall($rm_addon)) {
             $gpLayouts = $gpLayoutsBefore;
         }
         $installer->OutputMessages();
     } else {
         if (!\gp\admin\Tools::SaveAllConfig()) {
             $config = $config_before;
             $gpLayouts = $gpLayoutsBefore;
             message($langmessage['OOPS'] . ' (s1)');
             return false;
         }
         message($langmessage['SAVED']);
         if ($order) {
             $img_path = \gp\tool::IdUrl('ci');
             \gp\tool::IdReq($img_path);
         }
     }
     //delete the folder if it hasn't already been deleted by addon installer
     $dir = $dataDir . '/data/_themes/' . $theme_folder_name;
     if (file_exists($dir)) {
         \gp\tool\Files::RmAll($dir);
     }
 }