本文整理汇总了PHP中eZPackage类的典型用法代码示例。如果您正苦于以下问题:PHP eZPackage类的具体用法?PHP eZPackage怎么用?PHP eZPackage使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了eZPackage类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: display
function display()
{
// Get site templates from setup.ini
$config = eZINI::instance( 'setup.ini' );
$thumbnailBase = $config->variable( 'SiteTemplates', 'ThumbnailBase' );
$thumbnailExtension = $config->variable( 'SiteTemplates', 'ThumbnailExtension' );
$site_templates = array();
$packages = eZPackage::fetchPackages( array( 'path' => 'kernel/setup/packages' ) );
foreach( $packages as $key => $package )
{
$site_templates[$key]['name'] = $package->attribute( 'summary' );
$site_templates[$key]['identifier'] = $package->attribute( 'name' );
$thumbnails = $package->thumbnailList( 'default' );
if ( count( $thumbnails ) > 0 )
$site_templates[$key]['image_file_name'] = $package->fileItemPath( $thumbnails[0], 'default', 'kernel/setup/packages' );
else
$site_templates[$key]['image_file_name'] = false;
}
$this->Tpl->setVariable( 'site_templates', $site_templates );
$this->Tpl->setVariable( 'error', $this->Error );
// Return template and data to be shown
$result = array();
// Display template
$result['content'] = $this->Tpl->fetch( 'design:setup/init/site_templates.tpl' );
$result['path'] = array( array( 'text' => ezpI18n::tr( 'design/standard/setup/init',
'Site template selection' ),
'url' => false ) );
return $result;
}
示例2: finalize
function finalize(&$package, $http, &$persistentData)
{
$this->createPackage($package, $http, $persistentData, $cleanupFiles);
$classHandler = eZPackage::packageHandler('ezcontentclass');
$classList = $persistentData['classlist'];
foreach ($classList as $classID) {
$classHandler->addClass($package, $classID);
}
$package->setAttribute('is_active', true);
$package->store();
}
示例3: finalize
function finalize(&$package, $http, &$persistentData)
{
$this->createPackage($package, $http, $persistentData, $cleanupFiles, false);
$extensionHandler = eZPackage::packageHandler('ezextension');
$extensionList = $persistentData['extensionlist'];
foreach ($extensionList as $extensionName) {
$extensionHandler->addExtension($package, $extensionName);
}
$package->setAttribute('is_active', true);
$package->store();
}
示例4: 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'));
}
示例5: display
function display()
{
$siteTypes = $this->chosenSiteTypes();
$siteType = $siteTypes[0]['identifier'];
$typeFunctionality = eZSetupFunctionality($siteType);
$requiredPackageList = $typeFunctionality['required'];
$requiredPackages = array();
foreach ($requiredPackageList as $requiredPackage) {
$requiredPackages[] = strtolower($requiredPackage);
}
$packageArray = eZPackage::fetchPackages(array('repository_id' => 'addons'));
$requiredPackageInfoArray = array();
$packageInfoArray = array();
foreach ($packageArray as $package) {
if (in_array(strtolower($package->attribute('name')), $requiredPackages)) {
$requiredPackageInfoArray[] = array('identifier' => $package->attribute('name'), 'name' => $package->attribute('summary'), 'description' => $package->attribute('description'));
} else {
$packageInfoArray[] = array('identifier' => $package->attribute('name'), 'name' => $package->attribute('summary'), 'description' => $package->attribute('description'));
}
}
$recommended = array();
if (isset($typeFunctionality['recommended'])) {
$recommended = $typeFunctionality['recommended'];
}
if (isset($this->PersistenceList['additional_packages'])) {
$recommended = array_unique(array_merge($recommended, $this->PersistenceList['additional_packages']));
}
$this->Tpl->setVariable('site_types', $siteTypes);
$this->Tpl->setVariable('recommended_package_array', $recommended);
$this->Tpl->setVariable('error', $this->ErrorMsg);
$this->Tpl->setVariable('required_package_array', $requiredPackageInfoArray);
$this->Tpl->setVariable('package_array', $packageInfoArray);
// Return template and data to be shown
$result = array();
// Display template
$result['content'] = $this->Tpl->fetch('design:setup/init/site_packages.tpl');
$result['path'] = array(array('text' => ezpI18n::tr('design/standard/setup/init', 'Site functionality'), 'url' => false));
return $result;
}
示例6: showWarning
//
// 'url' option
//
$packageURL = $scriptOptions['url'];
if (!$packageURL) {
$packageINI = eZINI::instance('package.ini');
$packageURL = $packageINI->variable('RepositorySettings', 'RemotePackagesIndexURL');
}
//
// 'auto-mode' option
//
global $autoMode;
$autoMode = $scriptOptions['auto-mode'];
if ($autoMode != 'off') {
$autoMode = 'on';
$importDir = eZPackage::repositoryPath() . "/{$packageRepository}";
showWarning("Processing in auto-mode: \n" . "- packages will be downloaded to '{$packageDir}';\n" . "- packages will be imported to '{$importDir}';\n" . "- installing of existing classes will be skipped;\n" . "- all files(extesion, design, downloaded and imported packages) will be overwritten;");
$action = getUserInput("Continue? [y/n]: ");
if (strpos($action, 'y') !== 0) {
$script->shutdown(0, 'Done');
}
}
/**************************************************************
* do the work *
***************************************************************/
if (downloadPackages($packageList, $packageURL, $packageDir, $packageRepository)) {
// install
installPackages($packageList);
}
if (file_exists(installScriptDir($packageRepository, 'ezwebin_site'))) {
include_once installScriptDir($packageRepository, 'ezwebin_site') . "/settings/ezwebininstaller.php";
示例7: retrieveRemotePackagesList
/**
* Retrieve list of packages available to download.
*
* Example of return value:
* array(
* 'packages' => array(
* '<package_name1>' => array( "name" =>... , "version" =>... , "summary" => ... "url" =>... ),
* '<package_name2>' => array( "name" =>... , "version" =>... , "summary" => ... "url" =>... )
* )
* );
*
*/
function retrieveRemotePackagesList($onlySitePackages = false)
{
// Download index file.
$idxFileName = $this->downloadFile($this->XMLIndexURL, eZStepSiteTypes::tempDir(), 'index.xml');
if ($idxFileName === false) {
// Searching for a local index.xml file to use for offline installation
$destIndexPath = eZStepSiteTypes::tempDir() . DIRECTORY_SEPARATOR . 'index.xml';
$repo = eZPackage::systemRepositoryInformation();
if ($repo) {
$sourceIndexPath = $repo['path'] . DIRECTORY_SEPARATOR . 'index.xml';
if (file_exists($sourceIndexPath)) {
eZFileHandler::copy($sourceIndexPath, $destIndexPath);
$idxFileName = $destIndexPath;
// Removing error message from downloadFile
$this->ErrorMsg = false;
}
}
}
if ($idxFileName === false) {
$this->ErrorMsg = ezpI18n::tr('design/standard/setup/init', 'Retrieving remote site packages list failed. ' . 'You may upload packages manually.');
eZDebug::writeNotice("Cannot download remote packages index file from '{$this->XMLIndexURL}'.");
return false;
}
// Parse it.
$dom = new DOMDocument('1.0', 'utf-8');
$dom->preserveWhiteSpace = false;
$success = $dom->load(realpath($idxFileName));
@unlink($idxFileName);
if (!$success) {
eZDebug::writeError("Unable to open index file.");
return false;
}
$root = $dom->documentElement;
if ($root->localName != 'packages') {
eZDebug::writeError("Malformed index file.");
return false;
}
$packageList = array();
foreach ($root->childNodes as $packageNode) {
if ($packageNode->localName != 'package') {
// skip unwanted chilren
continue;
}
if ($onlySitePackages && $packageNode->getAttribute('type') != 'site') {
// skip non-site packages
continue;
}
$packageAttributes = array();
foreach ($packageNode->attributes as $attributeNode) {
$packageAttributes[$attributeNode->localName] = $attributeNode->value;
}
$packageList[$packageAttributes['name']] = $packageAttributes;
}
return $packageList;
}
示例8: elseif
{
// If this is an unhandled error, we are skipping this item
$currentItem++;
}
$doItemInstall = true;
}
elseif ( $module->isCurrentAction( 'UninstallPackage' ) )
{
$doItemInstall = true;
}
else
{
$uninstallElements = array();
foreach ( $uninstallItems as $uninstallItem )
{
$handler = eZPackage::packageHandler( $uninstallItem['type'] );
if ( $handler )
{
$uninstallElement = $handler->explainInstallItem( $package, $uninstallItem );
if ( $uninstallElement )
{
if ( isset( $uninstallElement[0] ) )
$uninstallElements = array_merge( $uninstallElements, $uninstallElement );
else
$uninstallElements[] = $uninstallElement;
}
}
}
$templateName = "design:package/uninstall.tpl";
示例9: importPackage
function importPackage()
{
$surveyINI = eZINI::instance('ezsurvey.ini');
$packageName = $surveyINI->variable('PackageSettings', 'PackageName');
$packagePath = $surveyINI->variable('PackageSettings', 'PackagePath');
$fileName = $surveyINI->variable('PackageSettings', 'PackageFileName');
$path = eZExtension::baseDirectory() . '/' . $packagePath . '/';
$file = $path . $fileName;
if (file_exists($file)) {
$package = eZPackage::import($file, $packageName);
if (is_object($package)) {
$status = $this->installPackage($package);
} else {
if ($package == eZPackage::STATUS_ALREADY_EXISTS) {
$package = eZPackage::fetch($packageName);
if (is_object($package)) {
$status = $this->installPackage($package);
} else {
eZDebug::writeError("Could not fetch package: {$packageName}", 'eZSurveyWizard::importPackage');
}
} else {
eZDebug::writeError("Uploaded file is not an eZ Publish package", 'eZSurveyWizard::importPackage');
}
}
} else {
eZDebug::writeWarning('File "' . $file . '" does not exist', 'eZSurveyWizard::importPackage');
}
}
示例10: checkPackageMaintainer
function checkPackageMaintainer($package, &$persistentData)
{
$roleList = eZPackage::fetchMaintainerRoleIDList($this->packageType($package, $persistentData), true);
if (count($roleList) > 0) {
if ($package instanceof eZPackage) {
$maintainerPerson = false;
$user = eZUser::currentUser();
$userObject = $user->attribute('contentobject');
if ($userObject) {
$maintainerPerson = $userObject->attribute('name');
}
$maintainers = $package->attribute('maintainers');
foreach ($maintainers as $maintainer) {
if ($maintainer['person'] == $maintainerPerson) {
return false;
}
}
}
return true;
}
return false;
}
示例11: 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 ) );
}
示例12: languageInfo
function languageInfo($withLanguageNames = false)
{
$langaugeInfo = array();
$classHandler = eZPackage::packageHandler('ezcontentclass');
$objectHandler = eZPackage::packageHandler('ezcontentobject');
$explainClassInfo = array('language_info');
$packageItems = $this->installItemsList();
foreach ($packageItems as $item) {
$itemLanguageInfo = array();
if ($item['type'] == 'ezcontentclass') {
$classInfo = $classHandler->explainInstallItem($this, $item, $explainClassInfo);
$itemLanguageInfo = isset($classInfo['language_info']) ? $classInfo['language_info'] : array();
} else {
if ($item['type'] == 'ezcontentobject') {
$objectsInfo = $objectHandler->explainInstallItem($this, $item);
// merge objects info
foreach ($objectsInfo as $objectInfo) {
$objectLanguages = isset($objectInfo['language_info']) ? $objectInfo['language_info'] : array();
foreach ($objectLanguages as $objectLanguage) {
if (!in_array($objectLanguage, $itemLanguageInfo)) {
$itemLanguageInfo[] = $objectLanguage;
}
}
}
}
}
// merge class and objects infos
foreach ($itemLanguageInfo as $languageLocale) {
if (!in_array($languageLocale, $langaugeInfo)) {
$langaugeInfo[] = $languageLocale;
}
}
}
if ($withLanguageNames) {
$langaugeInfoWithNames = array();
foreach ($langaugeInfo as $languageLocale) {
$language = eZContentLanguage::fetchByLocale($languageLocale);
$languageName = $language->attribute('name');
$langaugeInfoWithNames[$languageLocale] = $languageName;
}
$langaugeInfo = $langaugeInfoWithNames;
}
return $langaugeInfo;
}
示例13: objectAttributeContent
function objectAttributeContent($contentObjectAttribute)
{
$packageName = $contentObjectAttribute->attribute("data_text");
$package = eZPackage::fetch($packageName);
return $package;
}
示例14: 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;
}
示例15: canRemove
function canRemove()
{
return array('result' => eZPackage::canUsePolicyFunction('remove'));
}