本文整理汇总了PHP中eZPackage::fetch方法的典型用法代码示例。如果您正苦于以下问题:PHP eZPackage::fetch方法的具体用法?PHP eZPackage::fetch怎么用?PHP eZPackage::fetch使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类eZPackage
的用法示例。
在下文中一共展示了eZPackage::fetch方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testIssue15263
/**
* Regression test for issue #15263
* Content object name/url of imported content classes aren't generated correctly
*
* @url http://issues.ez.no/15263
*
* @outline
* 1) Expire and force generation of class attribute cache
* 2) Load a test package
* 3) Install the package
* 4) Publish an object of the imported class
* 5) The object name / url alias shouldn't be the expected one
**/
public function testIssue15263()
{
$adminUser = eZUser::fetchByName('admin');
$previousUser = eZUser::currentUser();
eZUser::setCurrentlyLoggedInUser($adminUser, $adminUser->attribute('contentobject_id'));
// 1) Expire and force generation of class attribute cache
$handler = eZExpiryHandler::instance();
$handler->setTimestamp('class-identifier-cache', time() - 1);
$handler->store();
eZContentClassAttribute::classAttributeIdentifierByID(1);
// 1) Load a test package
$packageName = 'ezpackage_regression_testIssue15223.ezpkg';
$packageFilename = dirname(__FILE__) . DIRECTORY_SEPARATOR . $packageName;
$packageImportTried = false;
while (!$packageImportTried) {
$package = eZPackage::import($packageFilename, $packageName);
if (!$package instanceof eZPackage) {
if ($package === eZPackage::STATUS_ALREADY_EXISTS) {
$packageToRemove = eZPackage::fetch($packageName);
$packageToRemove->remove();
} else {
self::fail("An error occured loading the package '{$packageFilename}'");
}
}
$packageImportTried = true;
}
// 2) Install the package
$installParameters = array('site_access_map' => array('*' => false), 'top_nodes_map' => array('*' => 2), 'design_map' => array('*' => false), 'restore_dates' => true, 'user_id' => $adminUser->attribute('contentobject_id'), 'non-interactive' => true, 'language_map' => $package->defaultLanguageMap());
$result = $package->install($installParameters);
// 3) Publish an object of the imported class
$object = new ezpObject('test_issue_15523', 2, $adminUser->attribute('contentobject_id'), 1);
$object->myname = __METHOD__;
$object->myothername = __METHOD__;
$publishedObjectID = $object->publish();
unset($object);
// 4) Test data from the publish object
$publishedNodeArray = eZContentObjectTreeNode::fetchByContentObjectID($publishedObjectID);
if (count($publishedNodeArray) != 1) {
$this->fail("An error occured fetching node for object #{$publishedObjectID}");
}
$publishedNode = $publishedNodeArray[0];
if (!$publishedNode instanceof eZContentObjectTreeNode) {
$this->fail("An error occured fetching node for object #{$publishedObjectID}");
} else {
$this->assertEquals("eZPackageRegression::testIssue15263", $publishedNode->attribute('name'));
$this->assertEquals("eZPackageRegression-testIssue15263", $publishedNode->attribute('url_alias'));
}
// Remove the installed package & restore the logged in user
$package->remove();
eZUser::setCurrentlyLoggedInUser($previousUser, $previousUser->attribute('contentobject_id'));
}
示例2: selectSiteType
/**
* @param string $sitePackageName
* @return bool
*/
function selectSiteType($sitePackageName)
{
$package = eZPackage::fetch($sitePackageName);
if (!$package) {
return false;
}
$this->PersistenceList['chosen_site_package']['0'] = $sitePackageName;
$this->PersistenceList['site_extra_data_title'][$sitePackageName] = $package->attribute('summary');
return true;
}
示例3: initializePackage
//.........这里部分代码省略.........
if ($primaryLanguage->localeCode() == 'eng-GB') {
$siteINIChanges['RegionalSettings']['TextTranslation'] = 'disabled';
} else {
$siteINIChanges['RegionalSettings']['TextTranslation'] = 'enabled';
}
$installParameters['ini']['siteaccess'][$adminSiteaccessName]['site.ini.append'] = $siteINIChanges;
$installParameters['ini']['siteaccess'][$userSiteaccessName]['site.ini.append'] = $siteINIChanges;
$installParameters['ini']['siteaccess'][$userSiteaccessName]['site.ini']['DesignSettings'] = array('SiteDesign' => $userDesignName);
$installParameters['variables']['user_siteaccess'] = $userSiteaccessName;
$installParameters['variables']['admin_siteaccess'] = $adminSiteaccessName;
$installParameters['variables']['design'] = $userDesignName;
$tmpSiteINI = eZINI::create('site.ini');
// Set ReadOnlySettingsCheck to false: towards
// Ignore site.ini[eZINISettings].ReadonlySettingList[] settings when saving ini variables.
$tmpSiteINI->setReadOnlySettingsCheck(false);
$tmpSiteINI->setVariable('FileSettings', 'VarDir', $siteINIChanges['FileSettings']['VarDir']);
// Change the current translation variables, before other parts start using them
$tmpSiteINI->setVariable('RegionalSettings', 'Locale', $siteINIChanges['RegionalSettings']['Locale']);
$tmpSiteINI->setVariable('RegionalSettings', 'ContentObjectLocale', $siteINIChanges['RegionalSettings']['ContentObjectLocale']);
$tmpSiteINI->setVariable('RegionalSettings', 'TextTranslation', $siteINIChanges['RegionalSettings']['TextTranslation']);
$tmpSiteINI->save(false, '.append.php', false, true, "settings/siteaccess/{$userSiteaccessName}");
/*
$typeFunctionality = eZSetupFunctionality( $siteType['identifier'] );
$extraFunctionality = array_merge( isset( $this->PersistenceList['additional_packages'] ) ?
$this->PersistenceList['additional_packages'] :
array(),
$typeFunctionality['required'] );
$extraFunctionality = array_unique( $extraFunctionality );
*/
// Add a policy to permit editors using OE
eZPolicy::createNew(3, array('ModuleName' => 'ezoe', 'FunctionName' => '*'));
// Install site package and it's required packages
$sitePackageName = $this->chosenSitePackage();
$sitePackage = eZPackage::fetch($sitePackageName);
if (!is_object($sitePackage)) {
$resultArray['errors'][] = array('code' => 'EZSW-041', 'text' => " Could not fetch site package: '{$sitePackageName}'");
return false;
}
$dependecies = $sitePackage->attribute('dependencies');
$requires = $dependecies['requires'];
$requiredPackages = array();
// Include setting files
$settingsFiles = $sitePackage->attribute('settings-files');
foreach ($settingsFiles as $settingsFileName) {
if (file_exists($sitePackage->path() . '/settings/' . $settingsFileName)) {
include_once $sitePackage->path() . '/settings/' . $settingsFileName;
}
}
// Call user function for additional setup tasks.
if (function_exists('eZSitePreInstall')) {
eZSitePreInstall($siteType);
}
// Make sure objects use the selected main language instead of eng-GB
if ($primaryLanguageLocaleCode != 'eng-GB') {
$engLanguageObj = eZContentLanguage::fetchByLocale('eng-GB');
$engLanguageID = (int) $engLanguageObj->attribute('id');
$updateSql = "UPDATE ezcontent_language\nSET\nlocale='{$primaryLanguageLocaleCode}',\nname='{$primaryLanguageName}'\nWHERE\nid={$engLanguageID}";
$db->query($updateSql);
eZContentLanguage::expireCache();
$primaryLanguageObj = eZContentLanguage::fetchByLocale($primaryLanguageLocaleCode);
// Add it if it is missing (most likely)
if (!$primaryLanguageObj) {
$primaryLanguageObj = eZContentLanguage::addLanguage($primaryLanguageLocaleCode, $primaryLanguageName);
}
$primaryLanguageID = (int) $primaryLanguageObj->attribute('id');
// Find objects which are always available
示例4: array
$persistentData = $http->sessionVariable( 'eZPackageInstallerData' );
if ( isset( $persistentData['currentItem'] ) )
$currentItem = $persistentData['currentItem'];
}
else
{
$persistentData = array();
$persistentData['currentItem'] = $currentItem;
$persistentData['error'] = array();
$persistentData['error_default_actions'] = array();
}
if ( !eZPackage::canUsePolicyFunction( 'install' ) )
return $module->handleError( eZError::KERNEL_ACCESS_DENIED, 'kernel' );
$package = eZPackage::fetch( $packageName );
if ( !$package )
return $module->handleError( eZError::KERNEL_NOT_AVAILABLE, 'kernel' );
if ( $module->isCurrentAction( 'SkipPackage' ) )
{
$http->removeSessionVariable( 'eZPackageInstallerData' );
return $module->redirectToView( 'view', array( 'full', $package->attribute( 'name' ) ) );
}
$tpl = eZTemplate::factory();
// Get all uninstall items and reverse array
$uninstallItems = array_reverse( $package->installItemsList( false, false, false, false ) );
if ( $module->isCurrentAction( 'HandleError' ) )
示例5: display
function display()
{
$remoteSitePackages = $this->retrieveRemoteSitePackagesList();
$importedSitePackages = $this->fetchAvailableSitePackages();
$dependenciesStatus = array();
// check site package dependencies to show their status in the template
foreach ($importedSitePackages as $sitePackage) {
$sitePackageName = $sitePackage->attribute('name');
$dependencies = $sitePackage->attribute('dependencies');
$requirements = $dependencies['requires'];
foreach ($requirements as $req) {
$requiredPackageName = $req['name'];
$requiredPackageVersion = $req['min-version'];
$packageOK = false;
$package = eZPackage::fetch($requiredPackageName, false, false, false);
if (is_object($package)) {
$currentPackageVersion = $package->getVersion();
if (version_compare($currentPackageVersion, $requiredPackageVersion) >= 0) {
$packageOK = true;
}
}
$dependenciesStatus[$sitePackageName][$requiredPackageName] = array('version' => $requiredPackageVersion, 'status' => $packageOK);
}
}
$sitePackages = $this->createSitePackagesList($remoteSitePackages, $importedSitePackages, $dependenciesStatus);
$chosenSitePackage = $this->chosenSitePackage();
$this->Tpl->setVariable('site_packages', $sitePackages);
$this->Tpl->setVariable('dependencies_status', $dependenciesStatus);
$this->Tpl->setVariable('chosen_package', $chosenSitePackage);
$this->Tpl->setVariable('error', $this->ErrorMsg);
$this->Tpl->setVariable('index_url', $this->IndexURL);
$this->Tpl->setVariable('message', $this->Message);
// Return template and data to be shown
$result = array();
// Display template
$result['content'] = $this->Tpl->fetch('design:setup/init/site_types.tpl');
$result['path'] = array(array('text' => ezpI18n::tr('design/standard/setup/init', 'Site selection'), 'url' => false));
return $result;
}
示例6: validatePackageInformation
function validatePackageInformation($package, $http, $currentStepID, &$stepMap, &$persistentData, &$errorList)
{
$packageName = false;
$packageSummary = false;
$packageVersion = false;
$packageDescription = false;
$packageLicence = 'GPL';
$packageHost = false;
$packagePackager = false;
if ($http->hasPostVariable('PackageName')) {
$packageName = trim($http->postVariable('PackageName'));
}
if ($http->hasPostVariable('PackageSummary')) {
$packageSummary = $http->postVariable('PackageSummary');
}
if ($http->hasPostVariable('PackageDescription')) {
$packageDescription = $http->postVariable('PackageDescription');
}
if ($http->hasPostVariable('PackageVersion')) {
$packageVersion = trim($http->postVariable('PackageVersion'));
}
if ($http->hasPostVariable('PackageLicence')) {
$packageLicence = $http->postVariable('PackageLicence');
}
if ($http->hasPostVariable('PackageHost')) {
$packageHost = $http->postVariable('PackageHost');
}
if ($http->hasPostVariable('PackagePackager')) {
$packagePackager = $http->postVariable('PackagePackager');
}
$persistentData['name'] = $packageName;
$persistentData['summary'] = $packageSummary;
$persistentData['description'] = $packageDescription;
$persistentData['version'] = $packageVersion;
$persistentData['licence'] = $packageLicence;
$persistentData['host'] = $packageHost;
$persistentData['packager'] = $packagePackager;
$result = true;
if ($packageName == '') {
$errorList[] = array('field' => ezpI18n::tr('kernel/package', 'Package name'), 'description' => ezpI18n::tr('kernel/package', 'Package name is missing'));
$result = false;
} else {
$existingPackage = eZPackage::fetch($packageName, false, true);
if ($existingPackage) {
$errorList[] = array('field' => ezpI18n::tr('kernel/package', 'Package name'), 'description' => ezpI18n::tr('kernel/package', 'A package named %packagename already exists, please give another name', false, array('%packagename' => $packageName)));
$result = false;
} else {
// Make sure the package name contains only valid characters
$trans = eZCharTransform::instance();
$validPackageName = $trans->transformByGroup($packageName, 'identifier');
if (strcmp($validPackageName, $packageName) != 0) {
$errorList[] = array('field' => ezpI18n::tr('kernel/package', 'Package name'), 'description' => ezpI18n::tr('kernel/package', "The package name %packagename is not valid, it can only contain characters in the range a-z, 0-9 and underscore.", false, array('%packagename' => $packageName)));
$result = false;
}
}
}
if (!$packageSummary) {
$errorList[] = array('field' => ezpI18n::tr('kernel/package', 'Summary'), 'description' => ezpI18n::tr('kernel/package', 'Summary is missing'));
$result = false;
}
if (!preg_match("#^[0-9](\\.[0-9]([a-zA-Z]+[0-9]*)?)*\$#", $packageVersion)) {
$errorList[] = array('field' => ezpI18n::tr('kernel/package', 'Version'), 'description' => ezpI18n::tr('kernel/package', 'The version must only contain numbers (optionally followed by text) and must be delimited by dots (.), e.g. 1.0, 3.4.0beta1'));
$result = false;
}
return $result;
}
示例7: foreach
/**************************************************************
* do the work *
***************************************************************/
if (downloadPackages($packageList, $packageURL, $packageDir, $packageRepository)) {
if (file_exists(installScriptDir($packageRepository))) {
//
// Prepare siteaccesses access info.
//
$locales = eZContentLanguage::fetchLocaleList();
$primaryLanguage = eZContentLanguage::topPriorityLanguage();
$siteINI = eZINI::instance();
$matchOrder = $siteINI->variableArray('SiteAccessSettings', 'MatchOrder');
$accessType = $matchOrder[0];
$accessTypeValue = 'ezwebin_site';
$adminAccessTypeValue = 'ezwebin_site_admin';
$package = eZPackage::fetch('ezwebin_site');
if ($accessType == 'port') {
$portAccessList = $siteINI->group('PortAccessSettings');
$usedPorts = array_keys($portAccessList);
foreach ($portAccessList as $port => $siteaccess) {
if ($siteaccess == $userSiteaccess) {
while (in_array($port, $usedPorts)) {
// $port is used => get next port
++$port;
}
$accessTypeValue = $port;
$usedPorts[] = $port;
} else {
if ($siteaccess == $adminSiteaccess) {
while (in_array($port, $usedPorts)) {
// $port is used => get next port
示例8: init
function init()
{
/*
if( $this->hasKickstartData() )
{
$data = $this->kickstartData();
return $this->kickstartContinueNextStep();
}
*/
//
// Get all available languages
//
$languages = false;
$defaultLanguage = false;
$defaultExtraLanguages = false;
eZSetupLanguageList($languages, $defaultLanguage, $defaultExtraLanguages);
//
// Get info about package and site languages
//
$siteLanguageLocaleList = $this->PersistenceList['regional_info']['languages'];
$packageNameList = array();
$packageLanguageLocaleList = array();
$sitePackageName = $this->chosenSitePackage();
$sitePackage = eZPackage::fetch($sitePackageName, false, false, false);
if (is_object($sitePackage)) {
$dependencies = $sitePackage->attribute('dependencies');
$requirements = $dependencies['requires'];
foreach ($requirements as $req) {
$packageNameList[] = $req['name'];
}
$packageLanguageLocaleList = eZPackage::languageInfoFromPackageList($packageNameList, false);
}
// Explicitly add 'eng-GB' cause clean data is in 'eng-GB'.
if (!in_array('eng-GB', $packageLanguageLocaleList)) {
$packageLanguageLocaleList[] = 'eng-GB';
}
//
// Exclude languages which exist both in packges and site.
//
$packageLanguageLocaleList = array_diff($packageLanguageLocaleList, $siteLanguageLocaleList);
if (count($packageLanguageLocaleList) > 0) {
//
// Get language names
//
$siteLanguageList = array();
$packageLanguageList = array();
foreach ($languages as $language) {
$locale = $language->attribute('locale_code');
$name = $language->attribute('intl_language_name');
if (in_array($locale, $siteLanguageLocaleList)) {
$siteLanguageList[] = array('locale' => $locale, 'name' => $name);
}
if (in_array($locale, $packageLanguageLocaleList)) {
$packageLanguageList[] = array('locale' => $locale, 'name' => $name);
}
}
$this->MissedPackageLanguageList = $packageLanguageList;
$this->SiteLanguageList = $siteLanguageList;
return false;
}
// There are no language conflicts => proceed with next step
return true;
}
示例9: array
}
$creator->generateStepMap($package, $persistentData);
}
} else {
if ($module->isCurrentAction('PackageStep')) {
if ($module->hasActionParameter('CreatorItemID')) {
$creatorID = $module->actionParameter('CreatorItemID');
$creator = eZPackageCreationHandler::instance($creatorID);
if ($http->hasSessionVariable('eZPackageCreatorData' . $creatorID)) {
$persistentData = $http->sessionVariable('eZPackageCreatorData' . $creatorID);
} else {
$persistentData = array();
}
$package = false;
if (isset($persistentData['package_name'])) {
$package = eZPackage::fetch($persistentData['package_name']);
}
$creator->generateStepMap($package, $persistentData);
}
}
}
$tpl = eZTemplate::factory();
$templateName = 'design:package/create.tpl';
if ($creator) {
$currentStepID = false;
if ($module->hasActionParameter('CreatorStepID')) {
$currentStepID = $module->actionParameter('CreatorStepID');
}
$steps =& $creator->stepMap();
if (!isset($steps['map'][$currentStepID])) {
$currentStepID = $steps['first']['id'];
示例10: fetchDependentPackageList
function fetchDependentPackageList($packageName, $filterArray = false, $repositoryID)
{
$filterParams = array();
$filterList = false;
if (isset($filterArray) and is_array($filterArray) and count($filterArray) > 0) {
$filterList = $filterArray;
if (count($filterArray) > 1 and !is_array($filterArray[0])) {
$filterList = array($filterArray);
}
}
if ($filterList !== false) {
foreach ($filterList as $filter) {
if (is_array($filter) and count($filter) > 0) {
$filterName = $filter[0];
switch ($filterName) {
case 'type':
$typeValue = $filter[1];
$typeParam = array('type' => $typeValue);
$filterParams = array_merge($filterParams, $typeParam);
break;
case 'name':
$nameValue = $filter[1];
$nameParam = array('name' => $nameValue);
$filterParams = array_merge($filterParams, $nameParam);
break;
case 'priority':
$priorityValue = $filter[1];
$priorityParam = array('priority' => $priorityValue);
$filterParams = array_merge($filterParams, $priorityParam);
break;
case 'vendor':
$vendorValue = $filter[1];
$vendorParam = array('vendor' => $vendorValue);
$filterParams = array_merge($filterParams, $vendorParam);
break;
case 'extension':
$extensionValue = $filter[1];
$extensionParam = array('extension' => $extensionValue);
$filterParams = array_merge($filterParams, $extensionParam);
break;
default:
eZDebug::writeWarning('Unknown package filter name: ' . $filterName);
continue;
}
}
}
}
$package = eZPackage::fetch($packageName, false, $repositoryID);
$packageList = $package->fetchDependentPackages($filterParams);
if ($packageList === false) {
$retValue = array('error' => array('error_type' => 'kernel', 'error_code' => eZError::KERNEL_NOT_FOUND));
} else {
$retValue = array('result' => $packageList);
}
return $retValue;
}
示例11: array
$module = $Params['Module'];
$offset = (int) $Params['Offset'];
$repositoryID = 'local';
if ($Params['RepositoryID']) {
$repositoryID = $Params['RepositoryID'];
}
if ($module->isCurrentAction('InstallPackage')) {
return $module->redirectToView('upload');
}
$removeList = array();
if ($module->isCurrentAction('RemovePackage') or $module->isCurrentAction('ConfirmRemovePackage')) {
if ($module->hasActionParameter('PackageSelection')) {
$removeConfirmation = $module->isCurrentAction('ConfirmRemovePackage');
$packageSelection = $module->actionParameter('PackageSelection');
foreach ($packageSelection as $packageID) {
$package = eZPackage::fetch($packageID);
if ($package) {
if ($removeConfirmation) {
$package->remove();
} else {
$removeList[] = $package;
}
}
}
if ($removeConfirmation) {
return $module->redirectToView('list');
}
}
}
if ($module->isCurrentAction('ChangeRepository')) {
$repositoryID = $module->actionParameter('RepositoryID');
示例12:
}
eZPackageCreationHandler::appendLicence($package);
if ($userObject) {
$package->appendChange($userObject->attribute('name'), $user->attribute('email'), 'Creation of package');
}
$package->store();
$text = "Created package " . $cli->stylize('symbol', $commandItem['name']) . "-" . $cli->stylize('symbol', $commandItem['version']);
if ($commandItem['summary']) {
$text .= " " . $cli->stylize('archive', $commandItem['summary']);
}
$cli->output($text);
$alreadyCreated = true;
$createdPackages[$commandItem['name']] =& $package;
} else {
if ($command == 'delete') {
$package = eZPackage::fetch($commandItem['name']);
if ($package) {
$package->remove();
$cli->output("Package " . $commandItem['name'] . " deleted.");
} else {
$cli->error("Could not open package " . $commandItem['name']);
}
}
}
}
}
}
}
}
}
}
示例13: if
<?php
/**
* @copyright Copyright (C) 1999-2011 eZ Systems AS. All rights reserved.
* @license http://www.gnu.org/licenses/gpl-2.0.txt GNU General Public License v2
* @version //autogentag//
* @package kernel
*/
$module = $Params['Module'];
$viewMode = $Params['ViewMode'];
$packageName = $Params['PackageName'];
$repositoryID = false;
if ( isset( $Params['RepositoryID'] ) and $Params['RepositoryID'] )
$repositoryID = $Params['RepositoryID'];
$package = eZPackage::fetch( $packageName, false, $repositoryID );
if ( !is_object( $package ) )
return $module->handleError( eZError::KERNEL_NOT_AVAILABLE, 'kernel' );
if ( !$package->attribute( 'can_read' ) )
return $module->handleError( eZError::KERNEL_ACCESS_DENIED, 'kernel' );
if ( $module->isCurrentAction( 'Export' ) )
{
return $module->run( 'export', array( $packageName ) );
}
else if ( $module->isCurrentAction( 'Install' ) )
{
return $module->redirectToView( 'install', array( $packageName ) );
}
示例14: objectAttributeContent
function objectAttributeContent($contentObjectAttribute)
{
$packageName = $contentObjectAttribute->attribute("data_text");
$package = eZPackage::fetch($packageName);
return $package;
}
示例15: languageInfoFromPackageList
static function languageInfoFromPackageList($packageNameList, $withLanguageNames = false)
{
$languageInfo = array();
foreach ($packageNameList as $packageName) {
$package = eZPackage::fetch($packageName, false, false, false);
if (is_object($package)) {
$packageLanguageInfo = $package->languageInfo($withLanguageNames);
// merge arrays
if ($withLanguageNames) {
// we have array like 'locale' => 'name'. can use array_merge
$languageInfo = array_merge($languageInfo, $packageLanguageInfo);
} else {
foreach ($packageLanguageInfo as $languageLocale) {
if (!in_array($languageLocale, $languageInfo)) {
$languageInfo[] = $languageLocale;
}
}
}
} else {
eZDebug::writeWarning("Unable to fetch package '{$packageName}'", __METHOD__);
}
}
return $languageInfo;
}