コード例 #1
0
 public static function getInstance($basepath = __DIR__, $classprefix = 'TZ_Portfolio_PlusInstallerAdapter', $adapterfolder = 'adapter')
 {
     if (!isset(self::$instances[$basepath])) {
         self::$instances[$basepath] = new TZ_Portfolio_PlusInstaller($basepath, $classprefix, $adapterfolder);
         // For B/C, we load the first instance into the static $instance container, remove at 4.0
         if (!isset(self::$instance)) {
             self::$instance = self::$instances[$basepath];
         }
     }
     return self::$instances[$basepath];
 }
コード例 #2
0
ファイル: script.php プロジェクト: templaza/tz_portfolio_plus
 function postflight($type, $parent)
 {
     $db = JFactory::getDbo();
     if ($this->install_new) {
         $user = JFactory::getUser();
         $query = $db->getQuery(true);
         $query->update('#__tz_portfolio_plus_categories');
         $query->set('created_user_id = ' . $user->id);
         $db->setQuery($query);
         $db->execute();
         $query->clear();
         $query->select('*');
         $query->from('#__assets');
         $query->where('name = ' . $db->quote('com_tz_portfolio_plus'));
         $db->setQuery($query);
         $asset = $db->loadObject();
         $query->clear();
         $query->insert('#__assets');
         $query->columns('parent_id, lft, rgt, level, name, title, rules');
         $query->values($asset->id . ',' . ($asset->lft + 1) . ',' . ($asset->rgt + 1) . ',2,' . $db->quote('com_tz_portfolio_plus.category.2') . ',' . $db->quote('Uncategorised') . ',' . $db->quote('{"core.create":{"6":1,"3":1},"core.delete":{"6":1},"core.edit":{"6":1,"4":1},' . '"core.edit.state":{"6":1,"5":1},"core.edit.own":{"6":1,"3":1}}'));
         $db->setQuery($query);
         $db->execute();
         $new_asset_id = $db->insertid();
         $query->clear();
         $query->update('#__tz_portfolio_plus_categories');
         $query->set('asset_id = ' . $new_asset_id);
         $query->where('id = 2');
         $db->setQuery($query);
         $db->execute();
     }
     JFactory::getLanguage()->load('com_tz_portfolio_plus');
     //Create folder
     $mediaFolder = 'tz_portfolio_plus';
     $mediaFolderPath = JPATH_SITE . '/media/' . $mediaFolder;
     $article = 'article';
     $cache = 'cache';
     $src = 'src';
     $html = htmlspecialchars_decode('<!DOCTYPE html><title></title>');
     if (!JFolder::exists($mediaFolderPath)) {
         JFolder::create($mediaFolderPath);
     }
     if (!JFile::exists($mediaFolderPath . '/index.html')) {
         JFile::write($mediaFolderPath . '/index.html', $html);
     }
     if (!JFolder::exists($mediaFolderPath . '/' . $article)) {
         JFolder::create($mediaFolderPath . '/' . $article);
     }
     if (!JFile::exists($mediaFolderPath . '/' . $article . '/' . 'index.html')) {
         JFile::write($mediaFolderPath . '/' . $article . '/' . 'index.html', $html);
     }
     if (!JFolder::exists($mediaFolderPath . '/' . $article . '/' . $cache)) {
         JFolder::create($mediaFolderPath . '/' . $article . '/' . $cache);
     }
     if (!JFile::exists($mediaFolderPath . '/' . $article . '/' . $cache . '/' . 'index.html')) {
         JFile::write($mediaFolderPath . '/' . $article . '/' . $cache . '/' . 'index.html', $html);
     }
     if (!JFolder::exists($mediaFolderPath . '/' . $article . '/' . $src)) {
         JFolder::create($mediaFolderPath . '/' . $article . '/' . $src);
     }
     if (!JFile::exists($mediaFolderPath . '/' . $article . '/' . $src . '/' . 'index.html')) {
         JFile::write($mediaFolderPath . '/' . $article . '/' . $src . '/' . 'index.html', $html);
     }
     //Install plugins
     $status = new stdClass();
     $status->modules = array();
     $src = $parent->getParent()->getPath('source');
     if (version_compare(JVERSION, '1.6.0', 'ge')) {
         $modules = $parent->getParent()->manifest->xpath('modules/module');
         foreach ($modules as $module) {
             $result = null;
             $mname = $module->attributes()->module;
             $mname = (string) $mname;
             $client = $module->attributes()->client;
             if (is_null($client)) {
                 $client = 'site';
             }
             $client == 'administrator' ? $path = $src . '/' . 'administrator' . '/' . 'modules' . '/' . $mname : ($path = $src . '/' . 'modules' . '/' . $mname);
             $installer = new JInstaller();
             $result = $installer->install($path);
             $status->modules[] = array('name' => $mname, 'client' => $client, 'result' => $result);
         }
         $plugins = $parent->getParent()->manifest->xpath('plugins/plugin');
         foreach ($plugins as $plugin) {
             $result = null;
             $folder = null;
             $pname = $plugin->attributes()->plugin;
             $pname = (string) $pname;
             $group = $plugin->attributes()->group;
             $folder = $plugin->attributes()->folder;
             if (isset($folder)) {
                 $folder = $plugin->attributes()->folder;
             }
             $path = $src . '/' . 'plugins' . '/' . $group . '/' . $folder;
             $installer = new JInstaller();
             $result = $installer->install($path);
             $query = 'UPDATE #__extensions SET `enabled`=1 WHERE `type`="plugin" AND `element`="' . $pname . '" AND `folder`="' . $group . '"';
             $db->setQuery($query);
             $db->execute();
             $status->plugins[] = array('name' => $pname, 'group' => $group, 'result' => $result);
         }
         // Insert default template
         $template_sql = 'SELECT COUNT(*) FROM #__tz_portfolio_plus_templates';
         $db->setQuery($template_sql);
         if (!$db->loadResult()) {
             $def_file = JPATH_ADMINISTRATOR . '/components/com_tz_portfolio_plus/views/template_style/tmpl/default.json';
             if (JFile::exists($def_file)) {
                 $def_value = JFile::read($def_file);
                 $template_sql2 = 'INSERT INTO `#__tz_portfolio_plus_templates`(`id`, `title`, `home`, `params`) VALUES(1, \'Default\', \'1\',\'' . $def_value . '\')';
                 $db->setQuery($template_sql2);
                 $db->query();
             }
         }
     }
     // Reinstall for add-ons to update version
     JLoader::import('com_tz_portfolio_plus.libraries.installer', JPATH_ADMINISTRATOR . DIRECTORY_SEPARATOR . 'components');
     $tzInstaller = TZ_Portfolio_PlusInstaller::getInstance();
     $addon_cores = array('content' => 'vote', 'extrafields' => array('checkboxes', 'dropdownlist', 'multipleselect', 'radio', 'text', 'textarea'), 'mediatype' => 'image', 'user' => 'profile');
     foreach ($addon_cores as $type => $addon) {
         $addon_path = $src . '/site/addons/' . $type;
         if (is_array($addon)) {
             foreach ($addon as $value) {
                 $tzInstaller->install($addon_path . '/' . $value);
             }
         } else {
             $tzInstaller->install($addon_path . '/' . $addon);
         }
     }
     // End reinstall for add-ons to update version
     $this->installationResult($status);
 }