Beispiel #1
0
 function PluginPanelGroup($addon_key, $info)
 {
     global $langmessage, $gpLayouts;
     $addon_config = \gp\tool\Plugins::GetAddonConfig($addon_key);
     $addon_config += $info;
     //merge the upgrade info
     echo '<div class="panelgroup" id="panelgroup_' . md5($addon_key) . '">';
     echo '<h3>';
     echo \gp\tool::Link('Admin/Addons/' . \gp\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>';
 }
Beispiel #2
0
 public function GetAddonTexts($addon)
 {
     global $langmessage, $config;
     $addon_config = \gp\tool\Plugins::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 (empty($texts)) {
         return false;
     }
     return $texts;
 }
Beispiel #3
0
 /**
  * Make sure the file is a css or js file and that it exists
  * @static
  */
 public static function CheckFile(&$file)
 {
     global $dataDir;
     $comment_start = '<!--';
     $comment_end = '-->';
     $file = self::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 = \gp\tool\Plugins::GetAddonConfig($addon_key);
         if ($addon_config) {
             $file = $addon_config['code_folder_rel'] . '/' . implode('/', $file_parts);
         }
     }
     //remove null charachters
     $file = \gp\tool\Files::NoNull($file);
     //require .js or .css
     $ext = \gp\tool::Ext($file);
     if ($ext !== 'js' && $ext !== 'css' && $ext !== 'less' && $ext !== 'scss') {
         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 = self::CheckFileSub($decoded_file)) {
             $file = $decoded_file;
             return $full_path;
         }
     }
     //paths that have not been encoded
     if ($full_path = self::CheckFileSub($file)) {
         return $full_path;
     }
     echo "\n{$comment_start} File Not Found {$dataDir}{$file} {$comment_end}\n";
     return false;
 }
Beispiel #4
0
 /**
  * Remove an addon from the site configuration
  * Delete code folders if needed
  *
  */
 public function Uninstall($addon)
 {
     global $config, $langmessage, $gp_titles, $gp_menu, $gp_index;
     $this->GetAddonData();
     $addon_config = \gp\tool\Plugins::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 = \gp\tool::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 (!\gp\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 = \gp\tool::IdUrl('ci');
         \gp\tool::IdReq($img_path);
     }
     $this->message($langmessage['SAVED']);
     return true;
 }
Beispiel #5
0
 /**
  * Output addon information about a layout
  *
  */
 public function LayoutDivAddon($layout_info)
 {
     global $langmessage;
     // layouts with hooks
     ob_start();
     $addon_config = false;
     if (isset($layout_info['addon_key'])) {
         $addon_key = $layout_info['addon_key'];
         $addon_config = \gp\tool\Plugins::GetAddonConfig($addon_key);
         echo '<li>';
         echo \gp\tool::link('Admin/Addons/' . \gp\admin\Tools::encode64($addon_key), '<i class="fa fa-plug"></i> ' . $addon_config['name']);
         echo '</li>';
         //hooks
         $this->AddonPanelGroup($addon_key, false);
     }
     //version
     if (!empty($layout_info['version'])) {
         echo '<li><a>' . $langmessage['Your_version'] . ' ' . $layout_info['version'] . '</a></li>';
     } elseif ($addon_config && !empty($addon_config['version'])) {
         echo '<li><a>' . $langmessage['Your_version'] . ' ' . $addon_config['version'] . '</a></li>';
     }
     //upgrade
     if ($addon_config !== false) {
         echo '<li>';
         if ($layout_info['is_addon']) {
             $source = $layout_info['name'] . '(remote)/' . $layout_info['theme_color'];
         } else {
             $source = $layout_info['theme_name'] . '(local)/' . $layout_info['theme_color'];
         }
         echo \gp\tool::Link('Admin_Theme_Content', $langmessage['upgrade'], 'cmd=UpgradeTheme&source=' . rawurlencode($source), array('data-cmd' => 'creq'));
         echo '</li>';
     }
     $options = ob_get_clean();
     if (!empty($options)) {
         echo '<li class="expand_child_click">';
         echo '<a>' . $langmessage['options'] . '</a>';
         echo '<ul>';
         echo $options;
         echo '</ul></li>';
     }
 }