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


PHP Loader::package方法代码示例

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


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

示例1: install_package

 public function install_package($package)
 {
     $tp = new TaskPermission();
     if ($tp->canInstallPackages()) {
         $p = Loader::package($package);
         if (is_object($p)) {
             if (!$p->showInstallOptionsScreen() || Loader::helper('validation/token')->validate('install_options_selected')) {
                 $tests = Package::testForInstall($package);
                 if (is_array($tests)) {
                     $tests = Package::mapError($tests);
                     $this->set('error', $tests);
                 } else {
                     $currentLocale = Localization::activeLocale();
                     if ($currentLocale != 'en_US') {
                         // Prevent the database records being stored in wrong language
                         Localization::changeLocale('en_US');
                     }
                     try {
                         $u = new User();
                         $pkg = $p->install($this->post());
                         if ($u->isSuperUser() && $p->allowsFullContentSwap() && $this->post('pkgDoFullContentSwap')) {
                             $p->swapContent($this->post());
                         }
                         if ($currentLocale != 'en_US') {
                             Localization::changeLocale($currentLocale);
                         }
                         $pkg = Package::getByHandle($p->getPackageHandle());
                         $this->redirect('/dashboard/extend/install', 'package_installed', $pkg->getPackageID());
                     } catch (Exception $e) {
                         if ($currentLocale != 'en_US') {
                             Localization::changeLocale($currentLocale);
                         }
                         if ($p->showInstallOptionsScreen()) {
                             $this->set('showInstallOptionsScreen', true);
                             $this->set('pkg', $p);
                         }
                         $this->set('error', $e);
                     }
                 }
             } else {
                 $this->set('showInstallOptionsScreen', true);
                 $this->set('pkg', $p);
             }
         } else {
             $msg = t('Install failed - invalid package. Check log for details');
             $this->error->add($msg);
             $this->set('error', $this->error);
         }
     } else {
         $this->error->add(t('You do not have permission to install add-ons.'));
         $this->set('error', $this->error);
     }
 }
开发者ID:Zyqsempai,项目名称:amanet,代码行数:53,代码来源:install.php

示例2: getAvailablePackages

 public static function getAvailablePackages($filterInstalled = true)
 {
     $dh = Loader::helper('file');
     $packages = $dh->getDirectoryContents(DIR_PACKAGES);
     if ($filterInstalled) {
         $handles = self::getInstalledHandles();
         // strip out packages we've already installed
         $packagesTemp = array();
         foreach ($packages as $p) {
             if (!in_array($p, $handles)) {
                 $packagesTemp[] = $p;
             }
         }
         $packages = $packagesTemp;
     }
     if (count($packages) > 0) {
         $packagesTemp = array();
         // get package objects from the file system
         foreach ($packages as $p) {
             $pkg = Loader::package($p);
             if (!empty($pkg)) {
                 $packagesTemp[] = $pkg;
             }
         }
         $packages = $packagesTemp;
     }
     return $packages;
 }
开发者ID:ojalehto,项目名称:concrete5-legacy,代码行数:28,代码来源:package.php

示例3: foreach

            }
        }
    }
}
if (!is_object($mri)) {
    $error->add(t('Invalid package or no package specified.'));
}
if (!$error->has() && $install) {
    $tests = Package::testForInstall($mri->getHandle());
    if (is_array($tests)) {
        $results = Package::mapError($tests);
        foreach ($results as $te) {
            $error->add($te);
        }
    } else {
        $p = Loader::package($mri->getHandle());
        try {
            $p->install();
        } catch (Exception $e) {
            $error->add($e->getMessage());
        }
    }
}
if (!$error->has()) {
    ?>
	<p>
	<?php 
    if ($install) {
        $_pkg = Package::getByHandle($p->getPackageHandle());
        if ($_pkg->hasInstallPostScreen()) {
            Loader::element('dashboard/install_post', false, $_pkg->getPackageHandle());
开发者ID:ojalehto,项目名称:concrete5-legacy,代码行数:31,代码来源:download.php

示例4: download

 public function download()
 {
     $file = Marketplace::downloadRemoteFile($this->getRemoteFileURL());
     if (empty($file) || $file == Package::E_PACKAGE_DOWNLOAD) {
         return array(Package::E_PACKAGE_DOWNLOAD);
     } else {
         if ($file == Package::E_PACKAGE_SAVE) {
             return array($file);
         } else {
             if ($file == Package::E_PACKAGE_INVALID_APP_VERSION) {
                 return array($file);
             }
         }
     }
     try {
         Loader::model('package_archive');
         $am = new PackageArchive($this->getHandle());
         $am->install($file, true);
     } catch (Exception $e) {
         return array($e->getMessage());
     }
     if ($install) {
         $tests = Package::testForInstall($this->getHandle());
         if (is_array($tests)) {
             return $tests;
         } else {
             $p = Loader::package($this->getHandle());
             try {
                 $p->install();
             } catch (Exception $e) {
                 return array(Package::E_PACKAGE_INSTALL);
             }
         }
     }
 }
开发者ID:ronlobo,项目名称:concrete5-de,代码行数:35,代码来源:marketplace_remote_item.php

示例5: defined

<?php

defined('C5_EXECUTE') or die("Access Denied.");
$pla = PackageList::get();
$pl = $pla->getPackages();
foreach ($pl as $p) {
    if ($p->isPackageInstalled()) {
        $pkg = Loader::package($p->getPackageHandle());
        if (is_object($pkg)) {
            if (method_exists($pkg, 'on_start')) {
                $pkg->on_start();
            }
        }
    }
}
开发者ID:Zyqsempai,项目名称:amanet,代码行数:15,代码来源:packages.php

示例6: configure

 public function configure()
 {
     try {
         $val = Loader::helper('validation/form');
         $val->setData($this->post());
         $val->addRequired("SITE", t("Please specify your site's name"));
         $val->addRequiredEmail("uEmail", t('Please specify a valid email address'));
         $val->addRequired("DB_DATABASE", t('You must specify a valid database name'));
         $val->addRequired("DB_SERVER", t('You must specify a valid database server'));
         $e = Loader::helper('/validation/error');
         if (is_object($this->fileWriteErrors)) {
             $e = $this->fileWriteErrors;
         }
         if (!function_exists('mysql_connect')) {
             $e->add($this->getDBErrorMsg());
         } else {
             // attempt to connect to the database
             $db = Loader::db($_POST['DB_SERVER'], $_POST['DB_USERNAME'], $_POST['DB_PASSWORD'], $_POST['DB_DATABASE'], true);
             if ($_POST['DB_SERVER'] && $_POST['DB_DATABASE']) {
                 if (!$db) {
                     $e->add(t('Unable to connect to database.'));
                 } else {
                     $num = $db->GetCol("show tables");
                     if (count($num) > 0) {
                         $e->add(t('There are already %s tables in this database. Concrete must be installed in an empty database.', count($num)));
                     }
                 }
             }
         }
         if ($val->test() && !$e->has()) {
             if (!is_dir($this->installData['DIR_FILES_UPLOADED_THUMBNAILS'])) {
                 mkdir($this->installData['DIR_FILES_UPLOADED_THUMBNAILS']);
             }
             if (!is_dir($this->installData['DIR_FILES_INCOMING'])) {
                 mkdir($this->installData['DIR_FILES_INCOMING']);
             }
             if (!is_dir($this->installData['DIR_FILES_TRASH'])) {
                 mkdir($this->installData['DIR_FILES_TRASH']);
             }
             if (!is_dir($this->installData['DIR_FILES_CACHE'])) {
                 mkdir($this->installData['DIR_FILES_CACHE']);
             }
             if (!is_dir($this->installData['DIR_FILES_CACHE_DB'])) {
                 mkdir($this->installData['DIR_FILES_CACHE_DB']);
             }
             if (!is_dir($this->installData['DIR_FILES_AVATARS'])) {
                 mkdir($this->installData['DIR_FILES_AVATARS']);
             }
             if (isset($_POST['uPasswordForce'])) {
                 $this->installData['uPassword'] = $_POST['uPasswordForce'];
             }
             if (isset($_POST['packages'])) {
                 $this->installData['packages'] = $_POST['packages'];
             }
             $this->installDB();
             $vh = Loader::helper('validation/identifier');
             // copy the files
             $fh = Loader::helper('file');
             if ($_POST['INSTALL_SAMPLE_CONTENT']) {
                 $fh->copyAll($this->installData['DIR_BASE_CORE'] . '/config/install/files', DIR_FILES_UPLOADED);
             }
             // insert admin user into the user table
             $salt = defined('MANUAL_PASSWORD_SALT') ? MANUAL_PASSWORD_SALT : $vh->getString(64);
             if (!isset($this->installData['uPassword'])) {
                 $uPassword = rand(100000, 999999);
             } else {
                 $uPassword = $this->installData['uPassword'];
             }
             $uEmail = $_POST['uEmail'];
             $uPasswordEncrypted = User::encryptPassword($uPassword, $salt);
             UserInfo::addSuperUser($uPasswordEncrypted, $uEmail);
             if (defined('PERMISSIONS_MODEL') && PERMISSIONS_MODEL != 'simple') {
                 $setPermissionsModel = PERMISSIONS_MODEL;
             }
             if (file_exists($this->installData['DIR_CONFIG_SITE'])) {
                 $this->fp = @fopen($this->installData['DIR_CONFIG_SITE'] . '/site.php', 'w+');
                 if ($this->fp) {
                     Cache::flush();
                     if (is_array($this->installData['packages'])) {
                         foreach ($this->installData['packages'] as $pkgHandle) {
                             $p = Loader::package($pkgHandle);
                             $p->install();
                         }
                     }
                     // write the config file
                     $configuration = "<?php\n";
                     $configuration .= "define('DB_SERVER', '" . addslashes($_POST['DB_SERVER']) . "');\n";
                     $configuration .= "define('DB_USERNAME', '" . addslashes($_POST['DB_USERNAME']) . "');\n";
                     $configuration .= "define('DB_PASSWORD', '" . addslashes($_POST['DB_PASSWORD']) . "');\n";
                     $configuration .= "define('DB_DATABASE', '" . addslashes($_POST['DB_DATABASE']) . "');\n";
                     $configuration .= "define('BASE_URL', '" . $this->installData['BASE_URL'] . "');\n";
                     $configuration .= "define('DIR_REL', '" . $this->installData['DIR_REL'] . "');\n";
                     if (isset($setPermissionsModel)) {
                         $configuration .= "define('PERMISSIONS_MODEL', '" . addslashes($setPermissionsModel) . "');\n";
                     }
                     $configuration .= "define('PASSWORD_SALT', '{$salt}');\n";
                     if (is_array($_POST['SITE_CONFIG'])) {
                         foreach ($_POST['SITE_CONFIG'] as $key => $value) {
                             $configuration .= "define('" . $key . "', '" . $value . "');\n";
                         }
//.........这里部分代码省略.........
开发者ID:VonUniGE,项目名称:concrete5-1,代码行数:101,代码来源:install.php

示例7: setLocale

 /** Changes the currently active locale
  * @param string $locale The locale to activate (for example: 'en_US')
  * @param bool $coreOnly = false Set to true to load only the core translation files, set to false (default) to load also packages and site locale translations
  */
 public function setLocale($locale, $coreOnly = false)
 {
     $localeNeededLoading = false;
     if ($locale == 'en_US' && !ENABLE_TRANSLATE_LOCALE_EN_US) {
         if (isset($this->translate)) {
             unset($this->translate);
         }
         return;
     }
     if (is_dir(DIR_LANGUAGES . '/' . $locale)) {
         $languageDir = DIR_LANGUAGES . '/' . $locale;
     } elseif (is_dir(DIR_LANGUAGES_CORE . '/' . $locale)) {
         $languageDir = DIR_LANGUAGES_CORE . '/' . $locale;
     } else {
         return;
     }
     $options = array('adapter' => 'gettext', 'content' => $languageDir, 'locale' => $locale, 'disableNotices' => true, 'ignore' => array('.', 'messages.po'));
     if (defined('TRANSLATE_OPTIONS')) {
         $_options = unserialize(TRANSLATE_OPTIONS);
         if (is_array($_options)) {
             $options = array_merge($options, $_options);
         }
     }
     if (!isset($this->translate)) {
         $this->translate = new Zend_Translate($options);
         $localeNeededLoading = true;
     } else {
         if (!in_array($locale, $this->translate->getList())) {
             $this->translate->addTranslation($options);
             $localeNeededLoading = true;
         }
         $this->translate->setLocale($locale);
     }
     if (!$coreOnly) {
         $this->addSiteInterfaceLanguage($locale);
         global $config_check_failed;
         if (!(isset($config_check_failed) && $config_check_failed)) {
             foreach (PackageList::get(1)->getPackages() as $p) {
                 $pkg = Loader::package($p->getPackageHandle());
                 if (is_object($pkg)) {
                     $pkg->setupPackageLocalization($locale, null, $this->translate);
                 }
             }
         }
     }
     if ($localeNeededLoading) {
         Events::fire('on_locale_load', $locale);
     }
 }
开发者ID:Zyqsempai,项目名称:amanet,代码行数:53,代码来源:localization.php

示例8: importPackages

	protected function importPackages(SimpleXMLElement $sx) {
		if (isset($sx->packages)) {
			foreach($sx->packages->package as $p) {
				$pkg = Loader::package($p['handle']);
				$pkg->install();
			}
		}
	}
开发者ID:nveid,项目名称:concrete5,代码行数:8,代码来源:importer.php

示例9: install_package

	public function install_package($package) {
		$tp = new TaskPermission();
		if ($tp->canInstallPackages()) { 
			$tests = Package::testForInstall($package);
			if (is_array($tests)) {
				$tests = Package::mapError($tests);
				$this->set('error', $tests);
			} else {
				$p = Loader::package($package);
				try {
					$p->install();
					$this->set('message', t('The package has been installed.'));
				} catch(Exception $e) {
					$this->set('error', $e);
				}
			}
		} else {
			$this->error->add(t('You do not have permission to install add-ons.'));
			$this->set('error', $this->error);
		}
	}
开发者ID:rii-J,项目名称:concrete5-de,代码行数:21,代码来源:install.php

示例10: install_package

	public function install_package($package) {
		$tp = new TaskPermission();
		if ($tp->canInstallPackages()) { 
			$p = Loader::package($package);
			if (is_object($p)) {
				if (
					(!$p->showInstallOptionsScreen()) ||
					Loader::helper('validation/token')->validate('install_options_selected')
				) {
					$tests = Package::testForInstall($package);
					if (is_array($tests)) {
						$tests = Package::mapError($tests);
						$this->set('error', $tests);
					} else {
						try {
							$u = new User();
							$p->install($this->post());
							if ($u->isSuperUser() && $p->allowsFullContentSwap() && $this->post('pkgDoFullContentSwap')) { 
								$p->swapContent($this->post());
							}
							$this->set('message', t('The package has been installed.'));
						} catch(Exception $e) {
							if ($p->showInstallOptionsScreen()) {
								$this->set('showInstallOptionsScreen', true);
								$this->set('pkg', $p);
							}
							$this->set('error', $e);
						}
					}
				} else {
					$this->set('showInstallOptionsScreen', true);
					$this->set('pkg', $p);
				}
			}
		} else {
			$this->error->add(t('You do not have permission to install add-ons.'));
			$this->set('error', $this->error);
		}
	}
开发者ID:nbourguig,项目名称:concrete5,代码行数:39,代码来源:install.php


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