Пример #1
0
 function GetAddonTexts($addon)
 {
     global $langmessage, $config;
     $addon_config = gpPlugin::GetAddonConfig($addon);
     $addonDir = $addon_config['code_folder_full'];
     if (!is_dir($addonDir)) {
         return false;
     }
     //not set up correctly
     if (!isset($config['addons'][$addon]['editable_text'])) {
         return false;
     }
     $file = $addonDir . '/' . $config['addons'][$addon]['editable_text'];
     if (!file_exists($file)) {
         return false;
     }
     $texts = array();
     include $file;
     if (!$texts) {
         return false;
     }
     return $texts;
 }
Пример #2
0
 function PluginPanelGroup($addon_key, $info)
 {
     global $langmessage, $gpLayouts;
     $addon_config = gpPlugin::GetAddonConfig($addon_key);
     $addon_config += $info;
     //merge the upgrade info
     echo '<div class="panelgroup" id="panelgroup_' . md5($addon_key) . '">';
     echo '<h3>';
     echo common::Link('Admin_Addons/' . admin_tools::encode64($addon_key), $addon_config['name']);
     echo '</h3>';
     echo '<div class="panelgroup2">';
     echo '<ul class="submenu">';
     $this->AddonPanelGroup($addon_key);
     $this->OptionLinks($addon_key, $addon_config);
     echo '</ul>';
     $this->UpgradeLinks($addon_config);
     echo '</div>';
     echo '</div>';
 }
Пример #3
0
 function PluginPanelGroup($addon_key, $info)
 {
     global $config, $langmessage, $gpLayouts;
     $addon_config = gpPlugin::GetAddonConfig($addon_key);
     $addon_config += $info;
     //merge the upgrade info
     echo '<div class="panelgroup" id="panelgroup_' . md5($addon_key) . '">';
     $label = '<i class="gpicon_plug"></i>' . $addon_config['name'];
     echo common::Link('Admin_Addons/' . admin_tools::encode64($addon_key), $label);
     echo '<div class="panelgroup2">';
     echo '<ul class="submenu">';
     $this->AddonPanelGroup($addon_key, $addon_config);
     //options
     if (!isset($addon_config['is_theme']) || !$addon_config['is_theme']) {
         echo '<li class="expand_child_click">';
         echo '<a>' . $langmessage['options'] . '</a>';
         echo '<ul>';
         //editable text
         if (isset($config['addons'][$addon_key]['editable_text']) && admin_tools::HasPermission('Admin_Theme_Content')) {
             echo '<li>';
             echo common::Link('Admin_Theme_Content', $langmessage['editable_text'], 'cmd=addontext&addon=' . urlencode($addon_key), array('title' => urlencode($langmessage['editable_text']), 'data-cmd' => 'gpabox'));
             echo '</li>';
         }
         //upgrade link
         if (isset($addon_config['upgrade_from'])) {
             echo '<li>';
             echo common::Link('Admin_Addons', $langmessage['upgrade'], 'cmd=local_install&source=' . $addon_config['upgrade_from'], array('data-cmd' => 'creq'));
             echo '</li>';
         }
         //uninstall
         echo '<li>';
         echo common::Link('Admin_Addons', $langmessage['uninstall'], 'cmd=uninstall&addon=' . rawurlencode($addon_key), 'data-cmd="gpabox"');
         echo '</li>';
         //version
         if (!empty($addon_config['version'])) {
             echo '<li><a>' . $langmessage['Your_version'] . ' ' . $addon_config['version'] . '</a></li>';
         }
         //rating
         if (isset($addon_config['id']) && is_numeric($addon_config['id'])) {
             $id = $addon_config['id'];
             $rating = 5;
             if (isset($this->addonReviews[$id])) {
                 $rating = $this->addonReviews[$id]['rating'];
             }
             $label = $langmessage['rate_this_addon'] . ' ' . $this->ShowRating($id, $rating);
             echo '<li><span>' . $label . '</span></li>';
         }
         echo '</ul></li>';
     } else {
         //show list of themes using these addons
         echo '<li class="expand_child_click">';
         echo '<a>' . $langmessage['layouts'] . '</a>';
         echo '<ul>';
         foreach ($gpLayouts as $layout_id => $layout_info) {
             if (!isset($layout_info['addon_key']) || $layout_info['addon_key'] !== $addon_key) {
                 continue;
             }
             echo '<li>';
             echo '<span>';
             echo '<span class="layout_color_id" style="background:' . $layout_info['color'] . '"></span> ';
             echo common::Link('Admin_Theme_Content', $layout_info['label']);
             echo ' ( ';
             echo common::Link('Admin_Theme_Content/' . $layout_id, $langmessage['edit']);
             echo ' )';
             echo '</span>';
             //echo '<a>';
             //echo $layout_info['label'];
             //echo '</a>';
             //echo pre($layout_info);
             echo '</li>';
         }
         echo '</ul>';
         echo '</li>';
     }
     echo '</ul>';
     //upgrade gpeasy.com
     if (isset($addon_config['id']) && isset(admin_tools::$new_versions[$addon_config['id']])) {
         $version_info = admin_tools::$new_versions[$addon_config['id']];
         echo '<div class="gp_notice">';
         echo '<a href="' . addon_browse_path . '/Plugins?id=' . $addon_config['id'] . '" data-cmd="remote">';
         echo $langmessage['new_version'];
         echo ' &nbsp; ' . $version_info['version'] . ' (gpEasy.com)</a>';
         echo '</div>';
     }
     //upgrade local
     if (isset($addon_config['upgrade_from']) && isset($addon_config['upgrade_version'])) {
         if (version_compare($addon_config['upgrade_version'], $addon_config['version'], '>')) {
             echo '<div class="gp_notice">';
             $label = $langmessage['new_version'] . ' &nbsp; ' . $addon_config['upgrade_version'];
             echo common::Link('Admin_Addons', $label, 'cmd=local_install&source=' . $addon_config['upgrade_from'], array('data-cmd' => 'creq'));
             echo '</div>';
         }
     }
     echo '</div>';
     echo '</div>';
 }
Пример #4
0
 /**
  * Make sure the file is a css or js file and that it exists
  * @static
  */
 static function CheckFile(&$file)
 {
     global $dataDir;
     $comment_start = '<!--';
     $comment_end = '-->';
     $file = gp_combine::TrimQuery($file);
     if (empty($file)) {
         return false;
     }
     //translate addon paths
     $pos = strpos($file, '/data/_addoncode/');
     if ($pos !== false) {
         $file_parts = substr($file, $pos + 17);
         $file_parts = explode('/', $file_parts);
         $addon_key = array_shift($file_parts);
         $addon_config = gpPlugin::GetAddonConfig($addon_key);
         if ($addon_config) {
             $file = $addon_config['code_folder_rel'] . '/' . implode('/', $file_parts);
         }
     }
     //remove null charachters
     $file = gpFiles::NoNull($file);
     //require .js or .css
     $test = strtolower($file);
     if (substr($test, -3) != '.js' && substr($test, -4) != '.css' && substr($test, -5) != '.less') {
         echo "\n{$comment_start} File Not CSS, LESS or JS {$file} {$comment_end}\n";
         return false;
     }
     //paths that have been urlencoded
     if (strpos($file, '%') !== false) {
         $decoded_file = rawurldecode($file);
         if ($full_path = gp_combine::CheckFileSub($decoded_file)) {
             $file = $decoded_file;
             return $full_path;
         }
     }
     //paths that have not been encoded
     if ($full_path = gp_combine::CheckFileSub($file)) {
         return $full_path;
     }
     echo "\n{$comment_start} File Not Found {$dataDir}{$file} {$comment_end}\n";
     return false;
 }
Пример #5
0
 /**
  * Remove an addon from the site configuration
  * Delete code folders if needed
  *
  */
 function Uninstall($addon)
 {
     global $config, $langmessage, $gp_titles, $gp_menu, $gp_index;
     $this->GetAddonData();
     $addon_config = gpPlugin::GetAddonConfig($addon);
     if (!$addon_config) {
         $this->message($langmessage['OOPS'] . ' (Already uninstalled)');
         return;
     }
     $order = false;
     if (isset($config['addons'][$addon]['order'])) {
         $order = $config['addons'][$addon]['order'];
     }
     //tracking
     $history = array();
     $history['name'] = $config['addons'][$addon]['name'];
     $history['action'] = 'uninstalled';
     if (isset($config['addons'][$addon]['id'])) {
         $history['id'] = $config['addons'][$addon]['id'];
     }
     unset($config['addons'][$addon]);
     //remove links
     $installedGadgets = $this->GetInstalledComponents($config['gadgets'], $addon);
     $this->RemoveFromHandlers($installedGadgets);
     //remove from gp_index, gp_menu
     $installedLinks = $this->GetInstalledComponents($gp_titles, $addon);
     foreach ($installedLinks as $index) {
         if (isset($gp_menu[$index])) {
             unset($gp_menu[$index]);
         }
         $title = common::IndexToTitle($index);
         if ($title) {
             unset($gp_index[$title]);
         }
     }
     $this->RemoveFromConfig($config['gadgets'], $addon);
     $this->RemoveFromConfig($config['admin_links'], $addon);
     $this->RemoveFromConfig($gp_titles, $addon);
     $this->CleanHooks($addon);
     if (!admin_tools::SaveAllConfig()) {
         $this->message($langmessage['OOPS']);
         return false;
     }
     //Delete the code & code folders
     if ($this->rm_folders) {
         //only delete code if remote installation
         if (isset($addon_config['remote_install']) && $addon_config['remote_install']) {
             $installFolder = $addon_config['code_folder_full'];
             if (file_exists($installFolder)) {
                 gpFiles::RmAll($installFolder);
             }
         }
         $dataFolder = $addon_config['data_folder_full'];
         if (file_exists($dataFolder)) {
             gpFiles::RmAll($dataFolder);
         }
     }
     //Record the history
     $history['time'] = time();
     $this->addonHistory[] = $history;
     $this->SaveAddonData();
     if ($order) {
         $img_path = common::IdUrl('ci');
         common::IdReq($img_path);
     }
     $this->message($langmessage['SAVED']);
     return true;
 }
Пример #6
0
 /**
  * Remove an addon from the site configuration
  * Delete code folders if needed
  *
  */
 function Uninstall($addon)
 {
     global $config, $langmessage, $gp_titles, $gp_menu, $gp_index;
     $this->GetAddonData();
     $addon_config = gpPlugin::GetAddonConfig($addon);
     if (!$addon_config) {
         $this->message($langmessage['OOPS'] . ' (Already uninstalled)');
         return;
     }
     unset($config['addons'][$addon]);
     //remove links
     $installedGadgets = $this->GetInstalledComponents($config['gadgets'], $addon);
     $this->RemoveFromHandlers($installedGadgets);
     //remove from gp_index, gp_menu
     $installedLinks = $this->GetInstalledComponents($gp_titles, $addon);
     foreach ($installedLinks as $index) {
         if (isset($gp_menu[$index])) {
             unset($gp_menu[$index]);
         }
         $title = common::IndexToTitle($index);
         if ($title) {
             unset($gp_index[$title]);
         }
     }
     $this->RemoveFromConfig($config['gadgets'], $addon);
     $this->RemoveFromConfig($config['admin_links'], $addon);
     $this->RemoveFromConfig($gp_titles, $addon);
     $this->CleanHooks($addon);
     if (!admin_tools::SaveAllConfig()) {
         $this->message($langmessage['OOPS']);
         return false;
     }
     $this->RemoveFolders($addon_config);
     //Record the history
     $this->addonHistory[] = $this->UninstallHistory($addon_config);
     $this->SaveAddonData();
     if ($addon_config['order']) {
         $img_path = common::IdUrl('ci');
         common::IdReq($img_path);
     }
     $this->message($langmessage['SAVED']);
     return true;
 }