示例#1
0
	/**
	 * @todo Implement testGetOverwrite().
	 */
	public function testGetAndSetOverwrite()
	{
		$this->saveFactoryState();

		$newDbo = $this->getMock('test');

		JFactory::$database = &$newDbo;

		$this->object = JInstaller::getInstance();
		$this->object->setOverwrite(false);

		$this->assertThat(
			$this->object->getOverwrite(),
			$this->equalTo(false),
			'Get or Set overwrite failed'
		);

		$this->assertThat(
			$this->object->setOverwrite(true),
			$this->equalTo(false),
			'setOverwrite did not return the old value properly.'
		);

		$this->assertThat(
			$this->object->getOverwrite(),
			$this->equalTo(true),
			'getOverwrite did not return the expected value.'
		);

		$this->restoreFactoryState();
	}
 /**
  * Test...
  *
  * @covers  JInstaller::setOverwrite
  * @covers  JInstaller::isOverwrite
  *
  * @return void
  */
 public function testIsAndSetOverwrite()
 {
     $this->object->setOverwrite(false);
     $this->assertThat($this->object->isOverwrite(), $this->equalTo(false), 'Get or Set overwrite failed');
     $this->assertThat($this->object->setOverwrite(true), $this->equalTo(false), 'setOverwrite did not return the old value properly.');
     $this->assertThat($this->object->isOverwrite(), $this->equalTo(true), 'getOverwrite did not return the expected value.');
 }
示例#3
0
 function installExtensions($extPath = null)
 {
     //if no path defined, use default path
     if ($extPath == null) {
         $extPath = dirname(__FILE__) . DS . 'extensions';
     }
     if (!JFolder::exists($extPath)) {
         return false;
     }
     $extensions = JFolder::folders($extPath);
     //no apps there to install
     if (empty($extensions)) {
         return true;
     }
     //get instance of installer
     $installer = new JInstaller();
     $installer->setOverwrite(true);
     //install all apps
     foreach ($extensions as $ext) {
         $msg = "Supportive Plugin/Module {$ext} Installed Successfully";
         // Install the packages
         if ($installer->install($extPath . DS . $ext) == false) {
             $msg = "Supportive Plugin/Module {$ext} Installation Failed";
         }
         //enque the message
         JFactory::getApplication()->enqueueMessage($msg);
     }
     return true;
 }
示例#4
0
文件: install.php 项目: 01J/bealtine
        function install()
        {
            $pkg_path = JPATH_ADMINISTRATOR . DIRECTORY_SEPARATOR . 'components' . DIRECTORY_SEPARATOR . $this->com . DIRECTORY_SEPARATOR . 'extensions' . DIRECTORY_SEPARATOR;
            if (JFolder::exists($pkg_path . 'nextend')) {
                $librariesPath = defined('JPATH_LIBRARIES') ? JPATH_LIBRARIES : JPATH_PLATFORM;
                JFolder::copy($pkg_path . 'nextend', $librariesPath . DIRECTORY_SEPARATOR . 'nextend', '', true);
                JFolder::delete($pkg_path . 'nextend');
            }
            $extensions = array_merge(JFolder::folders($pkg_path, '^(?!com_)\\w+$'), JFolder::folders($pkg_path, '^com_\\w+$'));
            if (version_compare(JVERSION, '3.0.0', 'ge')) {
                foreach ($extensions as $pkg) {
                    $f = $pkg_path . DIRECTORY_SEPARATOR . $pkg;
                    $xmlfiles = JFolder::files($f, '.xml$', 1, true);
                    foreach ($xmlfiles as $xmlf) {
                        $file = file_get_contents($xmlf);
                        file_put_contents($xmlf, preg_replace("/<\\/install/", "</extension", preg_replace("/<install/", "<extension", $file)));
                    }
                }
            }
            foreach ($extensions as $pkg) {
                $installer = new JInstaller();
                $installer->setOverwrite(true);
                if ($success = $installer->install($pkg_path . DIRECTORY_SEPARATOR . $pkg)) {
                    $msgcolor = "#E0FFE0";
                    $name = version_compare(JVERSION, '1.6.0', 'l') ? $installer->getManifest()->document->name[0]->data() : $installer->getManifest()->name;
                    $msgtext = $name . " successfully installed.";
                } else {
                    $msgcolor = "#FFD0D0";
                    $msgtext = "ERROR: Could not install the {$pkg}. Please contact us on our support page: http://www.nextendweb.com/help/support";
                }
                ?>
        <table bgcolor="<?php 
                echo $msgcolor;
                ?>
" width ="100%">
          <tr style="height:30px">
            <td><font size="2"><b><?php 
                echo $msgtext;
                ?>
</b></font></td>
          </tr>
        </table><?php 
                if ($success && file_exists("{$pkg_path}/{$pkg}/install.php")) {
                    require_once "{$pkg_path}/{$pkg}/install.php";
                    $com = new $pkg();
                    $com->install();
                }
            }
            $db = JFactory::getDBO();
            if (version_compare(JVERSION, '1.6.0', 'lt')) {
                $db->setQuery("UPDATE #__plugins SET published=1 WHERE name LIKE '%nextend%'");
            } else {
                $db->setQuery("UPDATE #__extensions SET enabled=1 WHERE name LIKE '%nextend%' AND type='plugin'");
            }
            $db->query();
            if (JFolder::exists(JPATH_SITE . DIRECTORY_SEPARATOR . 'media' . DIRECTORY_SEPARATOR . 'dojo' . DIRECTORY_SEPARATOR)) {
                JFolder::delete(JPATH_SITE . DIRECTORY_SEPARATOR . 'media' . DIRECTORY_SEPARATOR . 'dojo' . DIRECTORY_SEPARATOR);
                JFolder::create(JPATH_SITE . DIRECTORY_SEPARATOR . 'media' . DIRECTORY_SEPARATOR . 'dojo' . DIRECTORY_SEPARATOR);
            }
        }
示例#5
0
 private function installGiantExtensionsPlugin()
 {
     $pluginPath = dirname(__FILE__) . '/plg_content_giantcontent.zip';
     $installResult = JInstallerHelper::unpack($pluginPath);
     if (empty($installResult)) {
         $app = JFactory::getApplication();
         $app->enqueueMessage('Giant Content can not install "Content - Giant Content" plugin. Please install plugin manually inside package.', 'error');
         return false;
     }
     $installer = new JInstaller();
     $installer->setOverwrite(true);
     if (!$installer->install($installResult['extractdir'])) {
         $app = JFactory::getApplication();
         $app->enqueueMessage('Giant Content can not install "Content - Giant Content" plugin. Please install plugin manually inside package.', 'error');
         return false;
     }
     $db = JFactory::getDBO();
     $db->setQuery('UPDATE #__extensions SET enabled = 1 WHERE type = "plugin" AND folder = "content" AND element = "giantcontent"');
     $db->query();
     if ($db->getErrorNum()) {
         $app = JFactory::getApplication();
         $app->enqueueMessage('Giant Content can not enable "Content - Giant Content" plugin. Please enable plugin manually in the plugin manager.', 'warning');
     }
     return true;
 }
示例#6
0
 /**
  * Generic update method for extensions
  *
  * @return  boolean  True on success
  *
  * @since   3.4
  */
 public function update()
 {
     // Set the overwrite setting
     $this->parent->setOverwrite(true);
     $this->parent->setUpgrade(true);
     // And make sure the route is set correctly
     $this->setRoute('update');
     // Now jump into the install method to run the update
     return $this->install();
 }
示例#7
0
        function install()
        {
            $pkg_path = JPATH_ADMINISTRATOR . DS . 'components' . DS . $this->com . DS . 'extensions' . DS;
            $extensions = array_merge(JFolder::folders($pkg_path, '^(?!com_)\\w+$'), JFolder::folders($pkg_path, '^com_\\w+$'));
            $v3 = version_compare(JVERSION, '3.0.0', 'ge');
            if ($v3) {
                foreach ($extensions as $pkg) {
                    $f = $pkg_path . DS . $pkg;
                    $xmlfiles = JFolder::files($f, '.xml$', 1, true);
                    foreach ($xmlfiles as $xmlf) {
                        $file = file_get_contents($xmlf);
                        file_put_contents($xmlf, preg_replace("/<\\/install/", "</extension", preg_replace("/<install/", "<extension", $file)));
                    }
                }
            }
            foreach ($extensions as $pkg) {
                if ($pkg == 'plg_offlajnjoomla3compat' && !$v3 || $pkg == 'plg_sticky_toolbar' && !$v3) {
                    continue;
                }
                $installer = new JInstaller();
                $installer->setOverwrite(true);
                if ($success = $installer->install($pkg_path . DS . $pkg)) {
                    $msgcolor = "#E0FFE0";
                    $msgtext = "{$pkg} successfully installed.";
                } else {
                    $msgcolor = "#FFD0D0";
                    $msgtext = "ERROR: Could not install the {$pkg}. Please contact us on our support page: http://offlajn.com/support.html";
                }
                ?>
        <table bgcolor="<?php 
                echo $msgcolor;
                ?>
" width ="100%">
          <tr style="height:30px">
            <td><font size="2"><b><?php 
                echo $msgtext;
                ?>
</b></font></td>
          </tr>
        </table><?php 
                if ($success && file_exists("{$pkg_path}/{$pkg}/install.php")) {
                    require_once "{$pkg_path}/{$pkg}/install.php";
                    $com = new $pkg();
                    $com->install();
                }
            }
            $db = JFactory::getDBO();
            if (version_compare(JVERSION, '1.6.0', 'lt')) {
                $db->setQuery("UPDATE #__plugins SET published=1 WHERE name LIKE '%offlajn%' OR name LIKE 'Nextend Joomla 3.0 compatibility' OR name LIKE 'Nextend Dojo Loader'");
            } else {
                $db->setQuery("UPDATE #__extensions SET enabled=1 WHERE (name LIKE '%offlajn%' OR name LIKE 'Nextend Joomla 3.0 compatibility' OR name LIKE 'Nextend Dojo Loader') AND type='plugin'");
            }
            $db->query();
        }
示例#8
0
    function install()
    {
        $installer = new JInstaller();
        $installer->setOverwrite(true);
        $pkg_path = JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_universal_ajax_live_search' . DS . 'extensions' . DS;
        $pkgs = array('mod_universal_ajaxlivesearch' => 'Ajax Live Search', 'mod_ajaxlivesearchresult' => 'AJAX Live Search results', 'offlajnjoomla3compat' => 'joomla3compat');
        $v3 = version_compare(JVERSION, '3.0.0', 'ge');
        if ($v3) {
            foreach ($pkgs as $pkg => $pkgname) {
                $f = $pkg_path . DS . $pkg;
                $xmlfiles = JFolder::files($f, '.xml$', 1, true);
                foreach ($xmlfiles as $xmlf) {
                    $file = file_get_contents($xmlf);
                    file_put_contents($xmlf, preg_replace("/<\\/install/", "</extension", preg_replace("/<install/", "<extension", $file)));
                }
            }
        }
        foreach ($pkgs as $pkg => $pkgname) {
            if ($installer->install($pkg_path . DS . $pkg)) {
                $msgcolor = "#E0FFE0";
                $msgtext = "{$pkgname} successfully installed.";
            } else {
                $msgcolor = "#FFD0D0";
                $msgtext = "ERROR: Could not install the {$pkgname}. Please contact us on our support page: http://offlajn.com/support.html";
            }
            ?>
      <table bgcolor="<?php 
            echo $msgcolor;
            ?>
" width ="100%">
        <tr style="height:30px">
          <td width="50px"><img src="/administrator/images/tick.png" height="20px" width="20px"></td>
          <td><font size="2"><b><?php 
            echo $msgtext;
            ?>
</b></font></td>
        </tr>
      </table>
    <?php 
        }
        $db = JFactory::getDBO();
        if (version_compare(JVERSION, '1.6.0', 'lt')) {
            $db->setQuery("UPDATE #__plugins SET published=1 WHERE name LIKE '%offlajn%' OR name LIKE 'Nextend Joomla 3.0 compatibility' OR name LIKE 'Nextend Dojo Loader'");
        } else {
            $db->setQuery("UPDATE #__extensions SET enabled=1 WHERE (name LIKE '%offlajn%' OR name LIKE 'Nextend Joomla 3.0 compatibility' OR name LIKE 'Nextend Dojo Loader') AND type='plugin'");
        }
        $db->query();
    }
示例#9
0
        function install()
        {
            $pkg_path = str_replace('/', DIRECTORY_SEPARATOR, JPATH_ADMINISTRATOR . DIRECTORY_SEPARATOR . 'components' . DIRECTORY_SEPARATOR . $this->com . DIRECTORY_SEPARATOR);
            if (JFolder::exists($pkg_path . 'libraries')) {
                $librariesPath = defined('JPATH_LIBRARIES') ? JPATH_LIBRARIES : JPATH_PLATFORM;
                $target = $librariesPath . DIRECTORY_SEPARATOR . 'nextend2';
                if (JFolder::exists($target)) {
                    JFolder::delete($target);
                }
                JFolder::copy($pkg_path . 'libraries/nextend2', $target, '', true);
                JFolder::delete($pkg_path . 'libraries');
            }
            $extensions = array_merge(JFolder::folders($pkg_path . 'components', '.', false, true), JFolder::folders($pkg_path . 'modules', '.', false, true), JFolder::folders($pkg_path . 'plugins/system', '.', false, true));
            foreach ($extensions as $path) {
                $installer = new JInstaller();
                $installer->setOverwrite(true);
                if ($success = $installer->install($path)) {
                } else {
                    $msgcolor = "#FFD0D0";
                    $msgtext = "ERROR: Could not install the {$path}. Please contact us on our support page: http://www.nextendweb.com/help/support";
                    ?>
                    <table bgcolor="<?php 
                    echo $msgcolor;
                    ?>
" width="100%">
                        <tr style="height:30px">
                            <td><font size="2"><b><?php 
                    echo $msgtext;
                    ?>
</b></font></td>
                        </tr>
                    </table>
                <?php 
                }
                if ($success && file_exists($path . "/install.php")) {
                    require_once $path . "/install.php";
                }
                if ($success && file_exists($path . "/message.php")) {
                    include $path . "/message.php";
                }
            }
            $db = JFactory::getDBO();
            $db->setQuery("UPDATE #__extensions SET enabled=1 WHERE name LIKE '%nextend%' AND type='plugin'");
            $db->query();
        }
 public function install($element, $path)
 {
     // Get Joomla's installer instance
     $installer = new JInstaller();
     // Allow overwriting existing modules
     $installer->setOverwrite(true);
     // Install the module
     $state = $installer->install($path);
     if (!$state) {
         return false;
     }
     $db = EB::db();
     $query = array();
     $query[] = 'UPDATE ' . $db->qn('#__extensions') . ' SET ' . $db->qn('access') . '=' . $db->Quote(1);
     $query[] = 'WHERE ' . $db->qn('type') . '=' . $db->Quote('module');
     $query[] = 'AND ' . $db->qn('element') . '=' . $db->Quote($element);
     $query[] = 'AND ' . $db->qn('access') . '=' . $db->Quote(0);
     $query = implode(' ', $query);
     $db->setQuery($query);
     $db->Query();
     // Check if this module already exists on module_menu
     $query = array();
     $query[] = 'SELECT a.' . $db->qn('id') . ', b.' . $db->qn('moduleid') . ' FROM ' . $db->qn('#__modules') . ' AS a';
     $query[] = 'LEFT JOIN ' . $db->qn('#__modules_menu') . ' AS b ON a.' . $db->qn('id') . ' = b.' . $db->qn('moduleid');
     $query[] = 'WHERE a.' . $db->qn('module') . ' = ' . $db->Quote($element);
     $query[] = 'AND b.' . $db->qn('moduleid') . ' IS NULL';
     $query = implode(' ', $query);
     $db->setQuery($query);
     $result = $db->loadObjectList();
     if (!$result) {
         return false;
     }
     foreach ($result as $row) {
         $mod = new stdClass();
         $mod->moduleid = $row->id;
         $mod->menuid = 0;
         $db->insertObject('#__modules_menu', $mod);
     }
     return true;
 }
/**
 *  安装程序
 */
function com_install()
{
    if (version_compare(JVERSION, '1.6.0', 'ge')) {
        return;
    }
    $msg = array();
    $COM_NAME = 'com_weibo';
    // 从已经安装到com_weibo组件的文件中,找出zip文件
    $files = JFolder::files(JPATH_ADMINISTRATOR . DS . 'components' . DS . $COM_NAME, 'zip', true, true);
    if ($files) {
        foreach ($files as $file) {
            // 对于每个zip文件
            // 解压zip文件,取得安装包的相关信息
            $dest = dirname($file) . DS . JFile::stripExt(basename($file));
            JArchive::extract($file, $dest);
            $package = getPackageFromFolder($dest);
            // 使用JInstaller对象
            $installer = new JInstaller();
            $installer->setOverwrite(true);
            // 安装相应的ZIP包
            if (!$installer->install($package['dir'])) {
                // 如果有错,将错误信息加入信息列表中
                $msg[] = '<span style="color:#FF0000">' . basename($file) . ': ' . JText::sprintf('INSTALLERR', JText::_($package['type']), ' - ' . JText::_('ERROR')) . '</span>';
                $result = false;
            } else {
                // 安装成功,也将成功信息加入信息列表中
                $msg[] = basename($file) . ': ' . JText::sprintf('INSTALLOK', JText::_($package['type']), JText::_('Success'));
                $result = true;
            }
        }
    }
    $path = JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_weibo' . DS . 'mod_weibologin';
    if (!JFolder::delete($path)) {
        $msg[] = JText::_('DELETETMPERROR');
    }
    $path = JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_weibo' . DS . 'plg_authentication_weibo';
    if (!JFolder::delete($path)) {
        $msg[] = JText::_('DELETETMPERROR');
    }
    $path = JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_weibo' . DS . 'plg_content_weibo';
    if (!JFolder::delete($path)) {
        $msg[] = JText::_('DELETETMPERROR');
    }
    // 数据库的创立
    $db =& JFactory::getDBO();
    $sql = 'CREATE TABLE IF NOT EXISTS `#__weibo_auth` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `oauth_token` varchar(255) NOT NULL,
  `oauth_token_secret` varchar(255) NOT NULL,
  `name` varchar(255) NOT NULL,
  `type` varchar(10),
  PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
';
    $db->setQuery($sql);
    $db->query() or die("数据库创立错误");
    // 加上这段话是因为在%VERSION%以前的版本中,这个字段没有AUTO_INCREMEN
    $sql = 'ALTER TABLE `#__weibo_auth` CHANGE `id` `id` INT( 11 ) NOT NULL AUTO_INCREMENT ';
    $db->setQuery($sql);
    $db->query() or die("数据库创立错误");
    // 输出结果
    if (count($msg)) {
        echo '<dt>安装结果:</dt>';
        foreach ($msg as $m) {
            echo '<dd> - ' . $m . '</dd>';
        }
        echo '</dl>';
    }
}
示例#12
0
function InstallExtras($source)
{
    global $install_status;
    $pkg_path = $source . DS . 'admin' . DS . 'extensions' . DS;
    if ($dir = opendir($pkg_path)) {
        while (($file = readdir($dir)) !== false) {
            if ($file == "." || $file == "..") {
                continue;
            }
            if (stripos($file, ".zip") < 1) {
                continue;
            }
            $installer = new JInstaller();
            $installer->setOverwrite(true);
            $status = new Status();
            $status->status = $status->STATUS_FAIL;
            $package = JInstallerHelper::unpack($pkg_path . $file);
            if ($installer->install($package['dir'])) {
                $status->status = $status->STATUS_SUCCESS;
            } else {
                $status->errmsg[] = JText::_("UNABLE_TO_INSTALL_{$PKGNAME}");
            }
            $install_status[$file] = $status;
            JInstallerHelper::cleanupInstall($pkg_path . $file, $package['dir']);
        }
    }
}
示例#13
0
文件: script.php 项目: bellodox/jsolr
 /**
  * Installs all dependencies.
  *
  * @param JAdapterInstance $parent
  */
 private function installDependencies($parent)
 {
     $installed = array();
     $installer = new JInstaller();
     $installer->setOverwrite(true);
     $src = $parent->getParent()->getPath('source');
     foreach ($this->dependencies as $type => $extension) {
         foreach ($extension as $name => $params) {
             $packageZip = $src . '/' . $type . '/' . $name . '.zip';
             if (JFile::exists($packageZip)) {
                 if ($package = JInstallerHelper::unpack($packageZip)) {
                     $doInstall = true;
                     $path = $this->getInstalledManifest($type, $name, $params);
                     $oldManifest = null;
                     if (JFile::exists($path)) {
                         $oldManifest = $installer->parseXMLInstallFile($path);
                     }
                     $dir = JArrayHelper::getValue($package, 'dir') . '/';
                     $path = $this->getExtractedManifest($dir, $type, $name);
                     $newManifest = $installer->parseXMLInstallFile($path);
                     if ($oldManifest) {
                         $oldVersion = JArrayHelper::getValue($oldManifest, 'version');
                         $newVersion = JArrayHelper::getValue($newManifest, 'version');
                         if (version_compare($oldVersion, $newVersion, 'ge')) {
                             $doInstall = false;
                         }
                     }
                     $success = true;
                     if ($doInstall) {
                         if ($success = $installer->install($dir)) {
                             $installed[$name] = array('status' => 1);
                         } else {
                             $installed[$name] = array('status' => 0);
                         }
                     } else {
                         $installed[$name] = array('status' => 2);
                     }
                     if ($success) {
                         // post installation configuration.
                         if ($type == 'modules') {
                             $this->configureModule($name, $params);
                         }
                     }
                     JInstallerHelper::cleanupInstall($packageZip, $dir);
                 }
             }
         }
     }
     return $installed;
 }
 /**
  * Installs subextensions (modules, plugins) bundled with the main extension
  */
 private function install_sub_extensions($parent)
 {
     $src = $parent->getParent()->getPath('source');
     $db = JFactory::getDbo();
     // The subextension installation status
     $status = new JObject();
     $status->modules = array();
     $status->plugins = array();
     // Modules installation
     if (isset($this->installation_queue['modules']) and is_array($this->installation_queue['modules'])) {
         foreach ($this->installation_queue['modules'] as $folder => $modules) {
             if (is_array($modules)) {
                 foreach ($modules as $module => $module_preferences) {
                     //Look for the temporary installation folder
                     $path = $src . '/modules/' . $folder . '/' . $module;
                     if (!is_dir($path)) {
                         $path = $src . '/modules/' . $folder . '/mod_' . $module;
                     }
                     if (!is_dir($path)) {
                         $path = $src . '/modules/' . $module;
                     }
                     if (!is_dir($path)) {
                         $path = $src . '/modules/mod_' . $module;
                     }
                     if (!is_dir($path)) {
                         $path = $src . '/mod_' . $module;
                     }
                     if (!is_dir($path)) {
                         continue;
                     }
                     // Was the module already installed?
                     $sql = $db->getQuery(true)->select('COUNT(*)')->from('#__modules')->where($db->qn('module') . ' = ' . $db->q('mod_' . $module));
                     $db->setQuery($sql);
                     $count = $db->loadResult();
                     //Install
                     $installer = new JInstaller();
                     $installer->setOverwrite(true);
                     $result = $installer->install($path);
                     //Store status
                     $status->modules[] = array('name' => 'mod_' . $module, 'client' => $folder, 'result' => $result);
                     // Modify where it's published and its published state
                     if (!$count) {
                         // Flags
                         $module_position = isset($module_preferences['position']) ? $module_preferences['position'] : 1;
                         $module_published = !empty($module_preferences['published']);
                         $module_showtitle = !empty($module_preferences['showtitle']);
                         // Position
                         $sql = $db->getQuery(true)->update($db->qn('#__modules'))->set($db->qn('position') . ' = ' . $db->q($module_position))->where($db->qn('module') . ' = ' . $db->q('mod_' . $module));
                         // Published
                         if ($module_published) {
                             $sql->set($db->qn('published') . ' = ' . $db->q('1'));
                         }
                         // Do not display the title?
                         if (!$module_showtitle) {
                             $sql->set($db->qn('showtitle') . ' = ' . $db->q('0'));
                         }
                         $db->setQuery($sql);
                         $db->query();
                         // Change the ordering of back-end modules to 1 + max ordering
                         if ($folder == 'admin') {
                             $query = $db->getQuery(true);
                             $query->select('MAX(' . $db->qn('ordering') . ')')->from($db->qn('#__modules'))->where($db->qn('position') . '=' . $db->q($module_position));
                             $db->setQuery($query);
                             $position = $db->loadResult();
                             $position++;
                             $query = $db->getQuery(true);
                             $query->update($db->qn('#__modules'))->set($db->qn('ordering') . ' = ' . $db->q($position))->where($db->qn('module') . ' = ' . $db->q('mod_' . $module));
                             $db->setQuery($query);
                             $db->query();
                         }
                         // Link to all pages
                         $query = $db->getQuery(true);
                         $query->select('id')->from($db->qn('#__modules'))->where($db->qn('module') . ' = ' . $db->q('mod_' . $module));
                         $db->setQuery($query);
                         $moduleid = $db->loadResult();
                         $query = $db->getQuery(true);
                         $query->select('*')->from($db->qn('#__modules_menu'))->where($db->qn('moduleid') . ' = ' . $db->q($moduleid));
                         $db->setQuery($query);
                         $assignments = $db->loadObjectList();
                         $isAssigned = !empty($assignments);
                         if (!$isAssigned) {
                             $o = (object) array('moduleid' => $moduleid, 'menuid' => 0);
                             $db->insertObject('#__modules_menu', $o);
                         }
                     }
                 }
             }
         }
     }
     // Plugins installation
     if (isset($this->installation_queue['plugins']) and is_array($this->installation_queue['plugins'])) {
         foreach ($this->installation_queue['plugins'] as $folder => $plugins) {
             if (is_array($plugins)) {
                 foreach ($plugins as $plugin => $plugin_preferences) {
                     //Look for the temporary installation folder
                     $path = $src . '/plugins/' . $folder . '/$plugin';
                     if (!is_dir($path)) {
                         $path = $src . '/plugins/' . $folder . '/plg_' . $plugin;
                     }
                     if (!is_dir($path)) {
                         $path = $src . '/plugins/' . $plugin;
                     }
                     if (!is_dir($path)) {
                         $path = $src . '/plugins/plg_' . $plugin;
                     }
                     if (!is_dir($path)) {
                         $path = $src . '/plg_' . $plugin;
                     }
                     if (!is_dir($path)) {
                         continue;
                     }
                     // Was the plugin already installed?
                     $query = $db->getQuery(true)->select('COUNT(*)')->from($db->qn('#__extensions'))->where($db->qn('element') . ' = ' . $db->q($plugin))->where($db->qn('folder') . ' = ' . $db->q($folder));
                     $db->setQuery($query);
                     $count = $db->loadResult();
                     //Install
                     $installer = new JInstaller();
                     $result = $installer->install($path);
                     //Store status
                     $status->plugins[] = array('name' => 'plg_' . $plugin, 'group' => $folder, 'result' => $result);
                     //Publish plugin
                     if (!empty($plugin_preferences['published']) && !$count) {
                         $query = $db->getQuery(true)->update($db->qn('#__extensions'))->set($db->qn('enabled') . ' = ' . $db->q('1'))->where($db->qn('element') . ' = ' . $db->q($plugin))->where($db->qn('folder') . ' = ' . $db->q($folder));
                         $db->setQuery($query);
                         $db->query();
                     }
                 }
             }
         }
     }
     return $status;
 }
示例#15
0
        function install()
        {
            $pkg_path = str_replace('/', DIRECTORY_SEPARATOR, JPATH_ADMINISTRATOR . DIRECTORY_SEPARATOR . 'components' . DIRECTORY_SEPARATOR . $this->com . DIRECTORY_SEPARATOR . 'extensions' . DIRECTORY_SEPARATOR);
            if (JFolder::exists($pkg_path . 'nextend')) {
                $librariesPath = defined('JPATH_LIBRARIES') ? JPATH_LIBRARIES : JPATH_PLATFORM;
                JFolder::copy($pkg_path . 'nextend', $librariesPath . DIRECTORY_SEPARATOR . 'nextend', '', true);
                JFolder::delete($pkg_path . 'nextend');
            }
            $extensions = array_merge(JFolder::folders($pkg_path, '^(?!com_)\\w+$'), JFolder::folders($pkg_path, '^com_\\w+$'));
            if (($key = array_search('plugins', $extensions)) !== false) {
                unset($extensions[$key]);
                foreach (JFolder::folders($pkg_path . 'plugins' . DIRECTORY_SEPARATOR, '.', false, true) as $f) {
                    $plgs = JFolder::folders($f, '.', false, true);
                    for ($i = 0; $i < count($plgs); $i++) {
                        $plgs[$i] = str_replace($pkg_path, '', $plgs[$i]);
                    }
                    $extensions = array_merge($extensions, $plgs);
                }
            }
            if (version_compare(JVERSION, '1.6.0', 'l')) {
                foreach ($extensions as $pkg) {
                    $f = $pkg_path . DIRECTORY_SEPARATOR . $pkg;
                    $xmlfiles = JFolder::files($f, '.xml$', 1, true);
                    foreach ($xmlfiles as $xmlf) {
                        $file = file_get_contents($xmlf);
                        JFile::write($xmlf, preg_replace("/<\\/extension/", "</install", preg_replace("/<extension/", "<install", $file)));
                    }
                }
            }
            foreach ($extensions as $pkg) {
                $installer = new JInstaller();
                $installer->setOverwrite(true);
                if ($success = $installer->install($pkg_path . DIRECTORY_SEPARATOR . $pkg)) {
                } else {
                    $msgcolor = "#FFD0D0";
                    $msgtext = "ERROR: Could not install the {$pkg}. Please contact us on our support page: http://www.nextendweb.com/help/support";
                    ?>
                    <table bgcolor="<?php 
                    echo $msgcolor;
                    ?>
" width="100%">
                        <tr style="height:30px">
                            <td><font size="2"><b><?php 
                    echo $msgtext;
                    ?>
</b></font></td>
                        </tr>
                    </table>
                <?php 
                }
                if ($success && file_exists($pkg_path . "/" . $pkg . "/install.php")) {
                    require_once $pkg_path . "/" . $pkg . "/install.php";
                    $com = new $pkg();
                    $com->install();
                }
                if ($success && file_exists($pkg_path . "/" . $pkg . "/message.php")) {
                    include $pkg_path . "/" . $pkg . "/message.php";
                }
            }
            $db = JFactory::getDBO();
            if (version_compare(JVERSION, '1.6.0', 'lt')) {
                $db->setQuery("UPDATE #__plugins SET published=1 WHERE name LIKE '%nextend%'");
            } else {
                $db->setQuery("UPDATE #__extensions SET enabled=1 WHERE name LIKE '%nextend%' AND type='plugin'");
            }
            $db->query();
            if (JFolder::exists(JPATH_SITE . DIRECTORY_SEPARATOR . 'media' . DIRECTORY_SEPARATOR . 'dojo' . DIRECTORY_SEPARATOR)) {
                JFolder::delete(JPATH_SITE . DIRECTORY_SEPARATOR . 'media' . DIRECTORY_SEPARATOR . 'dojo' . DIRECTORY_SEPARATOR);
                JFolder::create(JPATH_SITE . DIRECTORY_SEPARATOR . 'media' . DIRECTORY_SEPARATOR . 'dojo' . DIRECTORY_SEPARATOR);
            }
        }
示例#16
0
 public static function doInstall(JInstallerComponent &$component)
 {
     // fix joomla 1.5 bug
     $component->parent->getDBO = $component->parent->getDBO();
     // initialize zoo framework
     require_once $component->parent->getPath('source') . '/admin/config.php';
     // sanatize table indexes
     $index_sql_path = $component->parent->getPath('source') . '/admin/installation/index.sql';
     if (JFile::exists($index_sql_path)) {
         $db = YDatabase::getInstance();
         // read index.sql
         $buffer = JFile::read($index_sql_path);
         // Create an array of queries from the sql file
         jimport('joomla.installer.helper');
         $queries = JInstallerHelper::splitSql($buffer);
         if (!empty($queries)) {
             foreach ($queries as $query) {
                 // replace table prefixes
                 $query = $db->replacePrefix($query);
                 // parse table name
                 preg_match('/ALTER\\s*TABLE\\s*`(.*)`/i', $query, $result);
                 if (count($result) < 2) {
                     continue;
                 }
                 $table = $result[1];
                 // get existing indexes
                 $indexes = $db->queryObjectList('SHOW INDEX FROM ' . $table);
                 // drop existing indexes
                 $removed = array();
                 foreach ($indexes as $index) {
                     if (in_array($index->Key_name, $removed)) {
                         continue;
                     }
                     if ($index->Key_name != 'PRIMARY') {
                         $db->query('DROP INDEX ' . $index->Key_name . ' ON ' . $table);
                         $removed[] = $index->Key_name;
                     }
                 }
                 // add new indexes
                 $db->query($query);
             }
         }
     }
     // applications
     if (!JFolder::exists(ZOO_APPLICATION_PATH)) {
         JFolder::create(ZOO_APPLICATION_PATH);
     }
     $applications = array();
     foreach (JFolder::folders($component->parent->getPath('source') . '/applications', '.', false, true) as $folder) {
         try {
             if ($manifest = InstallHelper::findManifest($folder)) {
                 $name = InstallHelper::getName($manifest);
                 $status = InstallHelper::installApplicationFromFolder($folder);
                 $applications[] = compact('name', 'status');
             }
         } catch (YException $e) {
             $name = basename($folder);
             $status = false;
             $applications[] = compact('name', 'status');
         }
     }
     self::displayResults($applications, 'Applications', 'Application');
     // additional extensions
     // init vars
     $error = false;
     $extensions = array();
     // get plugin files
     $plugin_files = array();
     foreach (YFile::readDirectoryFiles(JPATH_PLUGINS, JPATH_PLUGINS . '/', '/\\.php$/', true) as $file) {
         $plugin_files[] = basename($file);
     }
     // get extensions
     if (isset($component->manifest->additional[0])) {
         $add = $component->manifest->additional[0];
         if (count($add->children())) {
             $exts = $add->children();
             foreach ($exts as $ext) {
                 $installer = new JInstaller();
                 $installer->setOverwrite(true);
                 $update = false;
                 if ($ext->name() == 'module' && JFolder::exists(JPATH_ROOT . '/modules/' . $ext->attributes('name')) || $ext->name() == 'plugin' && in_array($ext->attributes('name') . '.php', $plugin_files)) {
                     $update = true;
                 }
                 $folder = $component->parent->getPath('source') . '/' . $ext->attributes('folder');
                 $folder = rtrim($folder, "\\/") . '/';
                 if (JFolder::exists($folder)) {
                     if ($update) {
                         foreach (YFile::readDirectoryFiles($folder, $folder, '/positions\\.config$/', true) as $file) {
                             JFile::delete($file);
                         }
                     }
                     $extensions[] = array('name' => $ext->data(), 'type' => $ext->name(), 'folder' => $folder, 'installer' => $installer, 'status' => false, 'update' => $update);
                 }
             }
         }
     }
     // install additional extensions
     for ($i = 0; $i < count($extensions); $i++) {
         if (is_dir($extensions[$i]['folder'])) {
             if (@$extensions[$i]['installer']->install($extensions[$i]['folder'])) {
                 $extensions[$i]['status'] = $extensions[$i]['update'] ? 2 : 1;
             } else {
                 $error = true;
                 break;
             }
         }
     }
     // rollback on installation errors
     if ($error) {
         $component->parent->abort(JText::_('Component') . ' ' . JText::_('Install') . ': ' . JText::_('Error'), 'component');
         for ($i = 0; $i < count($extensions); $i++) {
             if ($extensions[$i]['status']) {
                 $extensions[$i]['installer']->abort(JText::_($extensions[$i]['type']) . ' ' . JText::_('Install') . ': ' . JText::_('Error'), $extensions[$i]['type']);
                 $extensions[$i]['status'] = false;
             }
         }
         return false;
     }
     self::displayResults($extensions, 'Extensions', 'Extension');
     // UPGRADES
     // get versions
     $new_version = $component->manifest->getElementByPath('version')->data();
     $version = '';
     // check for old version number
     $version_file_path = $component->parent->getPath('extension_administrator') . '/version.php';
     if (JFile::exists($version_file_path)) {
         require_once $version_file_path;
     }
     // write new version file
     $buffer = "<?php\n\ndefined('_JEXEC') or die('Restricted access');\n\n\$version = '{$new_version}';";
     JFile::write($version_file_path, $buffer);
     // include update script
     require_once $component->parent->getPath('source') . '/admin/installation/update.php';
     return true;
 }
示例#17
0
 /**
  * Installation of modules on the site
  *
  * @since	1.0
  * @access	public
  */
 public function installModules()
 {
     if ($this->isDevelopment()) {
         return $this->output($this->getResultObj('ok', true));
     }
     // We need the foundry library here
     $this->foundry();
     // Get the path to the current installer archive
     $tmpPath = JRequest::getVar('path');
     // Path to the archive
     $archivePath = $tmpPath . '/modules.zip';
     if (!JFile::exists($archivePath)) {
         return $this->output($this->getResultObj(JText::_('COM_EASYSOCIAL_INSTALLATION_NO_MODULES_AVAILABLE'), true));
     }
     // Where should the archive be extrated to
     $path = $tmpPath . '/modules';
     $state = JArchive::extract($archivePath, $path);
     if (!$state) {
         return $this->output($this->getResultObj(JText::_('COM_EASYSOCIAL_INSTALLATION_ERROR_EXTRACT_MODULES'), false));
     }
     // Get a list of apps we should install.
     $modules = JFolder::folders($path, '.', false, true);
     $result = new stdClass();
     $result->state = true;
     $result->message = '';
     foreach ($modules as $module) {
         $moduleName = basename($module);
         // Get Joomla's installer instance
         $installer = new JInstaller();
         // Allow overwriting existing plugins
         $installer->setOverwrite(true);
         $state = $installer->install($module);
         if ($state) {
             $db = FD::db();
             $sql = $db->sql();
             $query = 'update `#__extensions` set `access` = 1';
             $query .= ' where `type` = ' . $db->Quote('module');
             $query .= ' and `element` = ' . $db->Quote($moduleName);
             $query .= ' and `access` = ' . $db->Quote('0');
             $sql->clear();
             $sql->raw($query);
             $db->setQuery($sql);
             $db->query();
             // we need to check if this module record already exists in module_menu or not. if not, lets create one for this module.
             $query = 'select a.`id`, b.`moduleid` from #__modules as a';
             $query .= ' left join `#__modules_menu` as b on a.`id` = b.`moduleid`';
             $query .= ' where a.`module` = ' . $db->Quote($moduleName);
             $query .= ' and b.`moduleid` is null';
             $sql->clear();
             $sql->raw($query);
             $db->setQuery($sql);
             $results = $db->loadObjectList();
             if ($results) {
                 foreach ($results as $item) {
                     // lets add into module menu.
                     $modMenu = new stdClass();
                     $modMenu->moduleid = $item->id;
                     $modMenu->menuid = 0;
                     $db->insertObject('#__modules_menu', $modMenu);
                 }
             }
         }
         $message = $state ? JText::sprintf('COM_EASYSOCIAL_INSTALLATION_SUCCESS_MODULE', $moduleName) : JText::sprintf('COM_EASYSOCIAL_INSTALLATION_ERROR_MODULE', $moduleName);
         $class = $state ? 'success' : 'error';
         $result->message .= '<div class="text-' . $class . '">' . $message . '</div>';
     }
     return $this->output($result);
 }
示例#18
0
    private function installPackageList($packages)
    {
        foreach ($packages as $package) {
            $installer = new JInstaller();
            $installer->setOverwrite(true);
            $pkgName = $package['name'];
            $pkgFile = $package['file'];
            $pkgInstall = $package['install'];
            $this->installedRow++;
            if (!$pkgInstall) {
                $installed = '<span style="color:blue; font-weight:bold">Not Installed. Third Party Extension not found.</span>';
            } else {
                $pkg = JInstallerHelper::unpack($this->installer->getParent()->getPath('source') . '/packages/' . $pkgFile);
                if ($installer->install($pkg['dir'])) {
                    $installed = '<span style="color:green; font-weight:bold">Installed</span>';
                } else {
                    $installed = '<span style="color:red; font-weight:bold">Not Installed. Please install manually.</span>';
                }
                JFolder::delete($pkg['extractdir']);
            }
            ?>
            <tr class="row<?php 
            echo $this->installedRow % 2;
            ?>
">
                <td><?php 
            echo $pkgName;
            ?>
</td>
                <td><?php 
            echo $installed;
            ?>
</td>
            </tr>
        <?php 
        }
    }
示例#19
0
 /**
  * Install additional packages
  * @return Array or false
  * @param object $path[optional] Path to package folder
  */
 private static function installPackages($source)
 {
     jimport('joomla.installer.installer');
     $db = JFactory::getDBO();
     $result = '';
     JTable::addIncludePath(JPATH_LIBRARIES . '/joomla/database/table');
     $packages = array('editor' => array('jce'), 'quickicon' => array('jcefilebrowser'), 'module' => array('mod_jcefilebrowser'));
     foreach ($packages as $folder => $element) {
         // Joomla! 2.5
         if (defined('JPATH_PLATFORM')) {
             if ($folder == 'module') {
                 continue;
             }
             // Joomla! 1.5
         } else {
             if ($folder == 'quickicon') {
                 continue;
             }
         }
         $installer = new JInstaller();
         $installer->setOverwrite(true);
         if ($installer->install($source . '/' . $folder)) {
             if (method_exists($installer, 'loadLanguage')) {
                 $installer->loadLanguage();
             }
             if ($installer->message) {
                 $result .= '<li class="success">' . JText::_($installer->message, $installer->message) . '</li>';
             }
             // enable quickicon
             if ($folder == 'quickicon') {
                 $plugin = JTable::getInstance('extension');
                 foreach ($element as $item) {
                     $id = $plugin->find(array('type' => 'plugin', 'folder' => $folder, 'element' => $item));
                     $plugin->load($id);
                     $plugin->publish();
                 }
             }
             // enable module
             if ($folder == 'module') {
                 $module = JTable::getInstance('module');
                 $id = self::getModule('mod_jcefilebrowser');
                 $module->load($id);
                 $module->position = 'icon';
                 $module->ordering = 100;
                 $module->published = 1;
                 $module->store();
             }
             // rename editor manifest
             if ($folder == 'editor') {
                 $manifest = $installer->getPath('manifest');
                 if (basename($manifest) == 'legacy.xml') {
                     // rename legacy.xml to jce.xml
                     JFile::move($installer->getPath('extension_root') . '/' . basename($manifest), $installer->getPath('extension_root') . '/jce.xml');
                 }
             }
             // add index files
             self::addIndexfiles(array($installer->getPath('extension_root')));
         } else {
             $result .= '<li class="error">' . JText::_($installer->message, $installer->message) . '</li>';
         }
     }
     return $result;
 }
 /**
  * method to update the component
  *
  * @return void
  */
 function update($parent)
 {
     // $parent is the class calling this method
     echo '<p>' . JText::_('COM_SMARTICONS_UPDATE_TEXT') . '</p>';
     jimport('joomla.installer.installer');
     /*
      * Uninstall old module
      */
     $db = JFactory::getDbo();
     $query = $db->getQuery(true);
     $query->select('extension_id');
     $query->from('#__extensions');
     $query->where('element = \'mod_smarticons\'');
     $db->setQuery($query);
     if ($id = $db->loadResult()) {
         $installer = new JInstaller();
         if ($installer->uninstall('module', $id)) {
             echo '<p>' . JText::_('COM_SMARTICONS_INSTALLER_MODULE_UNINSTALL_SUCCESS') . '</p>';
         } else {
             echo '<p>' . JText::_('COM_SMARTICONS_INSTALLER_MODULE_UNINSTALL_FAIL') . '</p>';
         }
     } else {
         echo '<p>' . JText::_('COM_SMARTICONS_INSTALLER_MODULE_UNINSTALL_FAIL') . $id . '</p>';
     }
     /*
      * Unistall complete
      */
     /*
      * Install new module
      */
     $modulePath = JPATH_BASE . DS . 'components' . DS . 'com_smarticons' . DS . 'module';
     $installer = new JInstaller();
     $installer->setOverwrite(true);
     if ($installer->install($modulePath)) {
         JFolder::delete($modulePath);
         echo '<p>' . JText::_('COM_SMARTICONS_INSTALLER_MODULE_INSTALL_SUCCESS') . '</p>';
     } else {
         echo '<p style="color:red">' . JText::_('COM_SMARTICONS_INSTALLER_MODULE_INSTALL_FAIL') . '</p>';
         echo nl2br($installer->message);
     }
     /*
      * Install complete
      */
     /*
      * Enable module
      */
     $query = $db->getQuery(true);
     $query->select('id');
     $query->from('#__modules');
     $query->where('module = ' . $db->Quote('mod_smarticons'));
     $db->setQuery($query);
     if ($id = $db->loadResult()) {
         $query = $db->getQuery(true);
         $query->update('#__modules');
         $query->set('published = 1');
         $query->set('position = \'icon\'');
         $query->set('ordering = 1');
         $query->set('access = 3');
         $query->where('id = ' . $db->Quote($id));
         $db->setQuery($query);
         if ($db->query()) {
             $query = $db->getQuery(true);
             $query->insert('#__modules_menu');
             $query->set('moduleid = ' . $db->Quote($id));
             $query->set('menuid = 0');
             $db->setQuery($query);
             if ($db->query()) {
                 echo '<p>' . JText::_('COM_SMARTICONS_INSTALLER_MODULE_ENABLE_SUCCESS') . '</p>';
             } else {
                 echo '<p>' . JText::_('COM_SMARTICONS_INSTALLER_MODULE_ENABLE_FAIL') . '</p>';
             }
         } else {
             echo '<p>' . JText::_('COM_SMARTICONS_INSTALLER_MODULE_ENABLE_FAIL') . '</p>';
         }
     } else {
         echo '<p>' . JText::_('COM_SMARTICONS_INSTALLER_MODULE_ENABLE_FAIL') . '</p>';
     }
     /*
      * Enable complete
      */
 }