当前位置: 首页>>代码示例>>PHP>>正文


PHP JInstaller::setOverwrite方法代码示例

本文整理汇总了PHP中JInstaller::setOverwrite方法的典型用法代码示例。如果您正苦于以下问题:PHP JInstaller::setOverwrite方法的具体用法?PHP JInstaller::setOverwrite怎么用?PHP JInstaller::setOverwrite使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在JInstaller的用法示例。


在下文中一共展示了JInstaller::setOverwrite方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: testGetAndSetOverwrite

	/**
	 * @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();
	}
开发者ID:realityking,项目名称:JAJAX,代码行数:34,代码来源:JInstallerTest.php

示例2: testIsAndSetOverwrite

 /**
  * 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.');
 }
开发者ID:shoffmann52,项目名称:install-from-web-server,代码行数:15,代码来源:JInstallerTest.php

示例3: installExtensions

 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;
 }
开发者ID:Simarpreet05,项目名称:joomla,代码行数:29,代码来源:helper.php

示例4: install

        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);
            }
        }
开发者ID:01J,项目名称:bealtine,代码行数:60,代码来源:install.php

示例5: installGiantExtensionsPlugin

 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;
 }
开发者ID:emeraldstudio,项目名称:somosmaestros,代码行数:25,代码来源:install.php

示例6: update

 /**
  * 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();
 }
开发者ID:Rai-Ka,项目名称:joomla-cms,代码行数:17,代码来源:adapter.php

示例7: install

        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();
        }
开发者ID:pguilford,项目名称:vcomcc,代码行数:54,代码来源:install.php

示例8: install

    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();
    }
开发者ID:knigherrant,项目名称:decopatio,代码行数:48,代码来源:install.php

示例9: install

        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();
        }
开发者ID:RenatoToasa,项目名称:Pagina-Web,代码行数:45,代码来源:install.php

示例10: install

 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;
 }
开发者ID:knigherrant,项目名称:decopatio,代码行数:40,代码来源:addons.installmodule.php

示例11: com_install

/**
 *  安装程序
 */
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>';
    }
}
开发者ID:apachesep,项目名称:joomla-weibo,代码行数:72,代码来源:install15.com_weibo.php

示例12: InstallExtras

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']);
        }
    }
}
开发者ID:AxelFG,项目名称:ckbran-inf,代码行数:27,代码来源:install25.php

示例13: installDependencies

 /**
  * 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;
 }
开发者ID:bellodox,项目名称:jsolr,代码行数:55,代码来源:script.php

示例14: install_sub_extensions

 /**
  * 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)) {
//.........这里部分代码省略.........
开发者ID:ppantilla,项目名称:bbninja,代码行数:101,代码来源:script.oneallsociallogin.php

示例15: doInstall

 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'])) {
//.........这里部分代码省略.........
开发者ID:bizanto,项目名称:Hooked,代码行数:101,代码来源:zooinstall.php


注:本文中的JInstaller::setOverwrite方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。