本文整理汇总了PHP中eZINI::instance方法的典型用法代码示例。如果您正苦于以下问题:PHP eZINI::instance方法的具体用法?PHP eZINI::instance怎么用?PHP eZINI::instance使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类eZINI
的用法示例。
在下文中一共展示了eZINI::instance方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: eZSurveyFile
function eZSurveyFile($row = false)
{
$bfsf_ini = eZINI::instance('bfsurveyfile.ini');
$varPath = eZSys::storageDirectory();
$survey_object_id = 0;
//get survey object (lookup object ID, as the survey_id changes with each edit)
$survey = new eZSurveyType();
$surveyObject = $survey->fetchSurveyByID($row['survey_id']);
if ($surveyObject) {
$survey_object_id = $surveyObject->attribute('contentobject_id');
}
//set directory paths
$surveyUploadDir = self::UPLOAD_DIR_BASE . '/' . self::UPLOAD_DIR_PREFIX . $survey_object_id . '/';
// syntax example: surveryfiles/survey_123/
$this->uploadPath = $varPath . '/' . $surveyUploadDir;
//create directory if NOT exists
if (!is_dir($this->uploadPath)) {
mkdir($this->uploadPath, 0777, true);
}
//TODO: error if directory cannot be created
//set allowed file extensions
$allowedExtensions = $bfsf_ini->variable('SurveyFile', 'AllowedExtensions');
if (isset($allowedExtensions)) {
$this->allowedExtensions = $allowedExtensions;
}
//set max file size
$sizeLimit = $bfsf_ini->variable('SurveyFile', 'MaxFileSize');
$row['type'] = 'File';
if (!isset($row['mandatory'])) {
$row['mandatory'] = 0;
}
$this->eZSurveyQuestion($row);
}
示例2: 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;
}
示例3: initialize
function initialize($params = array())
{
eZExchangeRatesUpdateHandler::initialize($params);
$shopINI = eZINI::instance('shop.ini');
if (!isset($params['ServerName'])) {
$params['ServerName'] = '';
if ($shopINI->hasVariable('ECBExchangeRatesSettings', 'ServerName')) {
$params['ServerName'] = $shopINI->variable('ECBExchangeRatesSettings', 'ServerName');
}
}
if (!isset($params['ServerPort'])) {
$params['ServerPort'] = '';
if ($shopINI->hasVariable('ECBExchangeRatesSettings', 'ServerPort')) {
$params['ServerPort'] = $shopINI->variable('ECBExchangeRatesSettings', 'ServerPort');
}
}
if (!isset($params['RatesURI'])) {
$params['RatesURI'] = '';
if ($shopINI->hasVariable('ECBExchangeRatesSettings', 'RatesURI')) {
$params['RatesURI'] = $shopINI->variable('ECBExchangeRatesSettings', 'RatesURI');
}
}
if (!isset($params['BaseCurrency'])) {
// the ECB returns currencies against 'EUR'
$params['BaseCurrency'] = 'EUR';
}
$this->setServerName($params['ServerName']);
$this->setServerPort($params['ServerPort']);
$this->setRatesURI($params['RatesURI']);
$this->setBaseCurrency($params['BaseCurrency']);
}
示例4: initFrameMargins
function initFrameMargins()
{
$this->ezFrame = array();
$config = eZINI::instance('pdf.ini');
$this->ezFrame['header'] = array('y0' => $this->ez['pageHeight'], 'leftMargin' => $config->variable('Header', 'LeftMargin'), 'rightMargin' => $config->variable('Header', 'RightMargin'), 'topMargin' => $config->variable('Header', 'TopMargin'), 'bottomMargin' => $config->variable('Header', 'BottomMargin'));
$this->ezFrame['footer'] = array('y0' => $this->ez['bottomMargin'], 'leftMargin' => $config->variable('Footer', 'LeftMargin'), 'rightMargin' => $config->variable('Footer', 'RightMargin'), 'topMargin' => $config->variable('Footer', 'TopMargin'), 'bottomMargin' => $config->variable('Footer', 'BottomMargin'));
}
示例5: create
static function create($user_id)
{
$config = eZINI::instance('site.ini');
$dateTime = time();
$row = array('id' => null, 'title' => ezpI18n::tr('kernel/pdfexport', 'New PDF Export'), 'show_frontpage' => 1, 'intro_text' => '', 'sub_text' => '', 'source_node_id' => 0, 'export_structure' => 'tree', 'export_classes' => '', 'site_access' => '', 'pdf_filename' => 'file.pdf', 'modifier_id' => $user_id, 'modified' => $dateTime, 'creator_id' => $user_id, 'created' => $dateTime, 'status' => 0, 'version' => 1);
return new eZPDFExport($row);
}
示例6: initializeTopNodes
function initializeTopNodes($package, $http, $step, &$persistentData, $tpl, $module)
{
if (!isset($persistentData['top_nodes_map'])) {
$persistentData['top_nodes_map'] = array();
$rootDOMNode = $this->rootDOMNode();
$topNodeListNode = $rootDOMNode->getElementsByTagName('top-node-list')->item(0);
$ini = eZINI::instance('content.ini');
$defaultPlacementNodeID = $ini->variable('NodeSettings', 'RootNode');
$defaultPlacementNode = eZContentObjectTreeNode::fetch($defaultPlacementNodeID);
$defaultPlacementName = $defaultPlacementNode->attribute('name');
foreach ($topNodeListNode->getElementsByTagName('top-node') as $topNodeDOMNode) {
$persistentData['top_nodes_map'][(string) $topNodeDOMNode->getAttribute('node-id')] = array('old_node_id' => $topNodeDOMNode->getAttribute('node-id'), 'name' => $topNodeDOMNode->textContent, 'new_node_id' => $defaultPlacementNodeID, 'new_parent_name' => $defaultPlacementName);
}
}
foreach (array_keys($persistentData['top_nodes_map']) as $topNodeArrayKey) {
if ($http->hasPostVariable('BrowseNode_' . $topNodeArrayKey)) {
eZContentBrowse::browse(array('action_name' => 'SelectObjectRelationNode', 'description_template' => 'design:package/installers/ezcontentobject/browse_topnode.tpl', 'from_page' => '/package/install', 'persistent_data' => array('PackageStep' => $http->postVariable('PackageStep'), 'InstallerType' => $http->postVariable('InstallerType'), 'InstallStepID' => $http->postVariable('InstallStepID'), 'ReturnBrowse_' . $topNodeArrayKey => 1)), $module);
} else {
if ($http->hasPostVariable('ReturnBrowse_' . $topNodeArrayKey) && !$http->hasPostVariable('BrowseCancelButton')) {
$nodeIDArray = $http->postVariable('SelectedNodeIDArray');
if ($nodeIDArray != null) {
$persistentData['top_nodes_map'][$topNodeArrayKey]['new_node_id'] = $nodeIDArray[0];
$contentNode = eZContentObjectTreeNode::fetch($nodeIDArray[0]);
$persistentData['top_nodes_map'][$topNodeArrayKey]['new_parent_name'] = $contentNode->attribute('name');
}
}
}
}
$tpl->setVariable('top_nodes_map', $persistentData['top_nodes_map']);
}
示例7: lazyDbHelper
protected static function lazyDbHelper()
{
$dbMapping = array( 'ezmysqli' => 'mysql',
'ezmysql' => 'mysql',
'mysql' => 'mysql',
'mysqli' => 'mysql',
'postgresql' => 'pgsql',
'ezpostgresql' => 'pgsql',
'ezoracle' => 'oracle',
'oracle' => 'oracle' );
$ini = eZINI::instance();
list( $dbType, $dbHost, $dbPort, $dbUser, $dbPass, $dbName ) =
$ini->variableMulti( 'DatabaseSettings',
array( 'DatabaseImplementation', 'Server', 'Port',
'User', 'Password', 'Database',
)
);
if ( !isset( $dbMapping[$dbType] ) )
{
// @TODO: Add a proper exception type here.
throw new Exception( "Unknown / unmapped DB type '$dbType'" );
}
$dbType = $dbMapping[$dbType];
$dsnHost = $dbHost . ( $dbPort != '' ? ":$dbPort" : '' );
$dsnAuth = $dbUser . ( $dbPass != '' ? ":$dbPass" : '' );
$dsn = "{$dbType}://{$dbUser}:{$dbPass}@{$dsnHost}/{$dbName}";
return $dsn;
}
示例8: instance
/**
* Returns a shared instance of the eZNotificationTransport class.
*
*
* @param string|false $transport Uses notification.ini[TransportSettings]DefaultTransport if false
* @param bool $forceNewInstance
* @return eZNotificationTransport
*/
static function instance($transport = false, $forceNewInstance = false)
{
$ini = eZINI::instance('notification.ini');
if ($transport == false) {
$transport = $ini->variable('TransportSettings', 'DefaultTransport');
}
$transportImpl =& $GLOBALS['eZNotificationTransportGlobalInstance_' . $transport];
$class = $transportImpl !== null ? strtolower(get_class($transportImpl)) : '';
$fetchInstance = false;
if (!preg_match('/.*?transport/', $class)) {
$fetchInstance = true;
}
if ($forceNewInstance) {
$fetchInstance = true;
}
if ($fetchInstance) {
$extraPluginPathArray = $ini->variable('TransportSettings', 'TransportPluginPath');
$pluginPathArray = array_merge(array('kernel/classes/notification/'), $extraPluginPathArray);
foreach ($pluginPathArray as $pluginPath) {
$transportFile = $pluginPath . $transport . 'notificationtransport.php';
if (file_exists($transportFile)) {
include_once $transportFile;
$className = $transport . 'notificationtransport';
$impl = new $className();
break;
}
}
}
if (!isset($impl)) {
$impl = new eZNotificationTransport();
eZDebug::writeError('Transport implementation not supported: ' . $transport, __METHOD__);
}
return $impl;
}
示例9: checkRecurrenceCondition
function checkRecurrenceCondition($newsletter)
{
if (!$newsletter->attribute('recurrence_condition')) {
return true;
}
if (0 < count($this->conditionExtensions)) {
foreach ($this->conditionExtensions as $conditionExtension) {
// TODO: Extend to ask multiple condition extensions to allow more complex checks
$siteINI = eZINI::instance();
$siteINI->loadCache();
$extensionDirectory = $siteINI->variable('ExtensionSettings', 'ExtensionDirectory');
$extensionDirectories = eZDir::findSubItems($extensionDirectory);
$directoryList = eZExtension::expandedPathList($extensionDirectories, 'condition_handler');
foreach ($directoryList as $directory) {
$handlerFile = $directory . '/' . strtolower($conditionExtension) . 'handler.php';
// we only check one extension for now
if ($conditionExtension === $newsletter->attribute('recurrence_condition') && file_exists($handlerFile)) {
include_once $handlerFile;
$className = $conditionExtension . 'Handler';
if (class_exists($className)) {
$impl = new $className();
// Ask if condition is fullfilled
return $impl->checkCondition($newsletter);
} else {
eZDebug::writeError("Class {$className} not found. Unable to verify recurrence condition. Blocked recurrence.");
return false;
}
}
}
}
}
// If we have a condition but no match we prevent the sendout
eZDebug::writeError("Newsletter recurrence condition '" . $newsletter->attribute('recurrence_condition') . "' extension not found ");
return false;
}
示例10: push
public function push($Account, $TwitterStatus)
{
$NGPushIni = eZINI::instance('ngpush.ini');
$Token = self::getToken($Account);
if (!$Token) {
self::requestToken($Account);
$Token = self::getToken($Account);
}
if ($Token) {
$tokenCredentials = explode('%%%', $Token);
$connection = new TwitterOAuth($NGPushIni->variable($Account, 'ConsumerKey'), $NGPushIni->variable($Account, 'ConsumerSecret'), $tokenCredentials[0], $tokenCredentials[1]);
$connection->host = "https://api.twitter.com/1.1/";
$TwitterResponse = $connection->post('statuses/update', array('status' => $TwitterStatus));
self::$response['response'] = $TwitterResponse;
//Let's analyize some Twitter JSON response (lots of data but no clear structure and no status)
if ($TwitterResponse->error) {
self::$response['status'] = 'error';
self::$response['messages'][] = $TwitterResponse->error;
} elseif ($TwitterResponse->errors) {
self::$response['status'] = 'error';
foreach ($TwitterResponse->errors as $TwitterResponseError) {
self::$response['messages'][] = $TwitterResponseError->message;
}
} else {
self::$response['status'] = 'success';
if ($TwitterResponse->created_at) {
self::$response['messages'][] = 'Status is published!';
}
}
} else {
self::$response['status'] = 'error';
self::$response['messages'][] = 'You need access token to use this application with Twitter.';
}
return self::$response;
}
示例11: sendMail
function sendMail(eZMail $mail)
{
$ini = eZINI::instance();
$sendmailOptions = '';
$emailFrom = $mail->sender();
$emailSender = $emailFrom['email'];
if (!$emailSender || count($emailSender) <= 0) {
$emailSender = $ini->variable('MailSettings', 'EmailSender');
}
if (!$emailSender) {
$emailSender = $ini->variable('MailSettings', 'AdminEmail');
}
if (!eZMail::validate($emailSender)) {
$emailSender = false;
}
$isSafeMode = ini_get('safe_mode');
if ($isSafeMode and $emailSender and $mail->sender() == false) {
$mail->setSenderText($emailSender);
}
$filename = time() . '-' . mt_rand() . '.mail';
$data = preg_replace('/(\\r\\n|\\r|\\n)/', "\r\n", $mail->headerText() . "\n" . $mail->body());
$returnedValue = eZFile::create($filename, 'var/log/mail', $data);
if ($returnedValue === false) {
eZDebug::writeError('An error occurred writing the e-mail file in var/log/mail', __METHOD__);
}
return $returnedValue;
}
示例12: requestToken
public function requestToken($Account)
{
$NGPushIni = eZINI::instance('ngpush.ini');
$ConsumerKey = $NGPushIni->variable($Account, 'ConsumerKey');
$ConsumerSecret = $NGPushIni->variable($Account, 'ConsumerSecret');
$AccessToken = $NGPushIni->variable($Account, 'AccessToken');
$AccessTokenSecret = $NGPushIni->variable($Account, 'AccessTokenSecret');
// If access tokens are given
if ($AccessToken && $AccessTokenSecret) {
// Save request signing tokens to cache
ngPushBase::save_token($Account, $AccessToken, 'request_sign_oauth_token');
ngPushBase::save_token($Account, $AccessTokenSecret, 'request_sign_oauth_token_secret');
ngPushBase::save_token($Account, $AccessToken . '%%%' . $AccessTokenSecret, 'main_token');
} else {
$connection = new TwitterOAuth($ConsumerKey, $ConsumerSecret);
$connection->host = "https://api.twitter.com/1.1/";
$AdministrationUrl = '/';
eZURI::transformURI($AdministrationUrl, false, 'full');
$AdministrationUrl = base64_encode($AdministrationUrl);
$SettingsBlock = base64_encode($Account);
$temporary_credentials = $connection->getRequestToken('http://' . $NGPushIni->variable('PushNodeSettings', 'ConnectURL') . '/redirect.php/' . $AdministrationUrl . '/' . $SettingsBlock . '?case=twitter');
// Save request signing tokens to cache
ngPushBase::save_token($Account, $temporary_credentials['oauth_token'], 'request_sign_oauth_token');
ngPushBase::save_token($Account, $temporary_credentials['oauth_token_secret'], 'request_sign_oauth_token_secret');
$redirect_url = $connection->getAuthorizeURL($temporary_credentials, FALSE);
self::$response['RequestPermissionsUrl'] = $redirect_url;
}
}
示例13: __construct
/**
* Constructor.
*
* $filePath File path. If specified, file metadata is fetched in the constructor.
*/
function __construct( $filePath = false )
{
$filePath = eZDBFileHandler::cleanPath( $filePath );
eZDebugSetting::writeDebug( 'kernel-clustering', "db::ctor( '$filePath' )" );
if ( self::$dbbackend === null )
{
$optionArray = array( 'iniFile' => 'file.ini',
'iniSection' => 'ClusteringSettings',
'iniVariable' => 'DBBackend' );
$options = new ezpExtensionOptions( $optionArray );
self::$dbbackend = eZExtension::getHandlerClass( $options );
self::$dbbackend->_connect( false );
// connection failed
if( self::$dbbackend->db === false )
throw new eZClusterHandlerDBNoConnectionException( self::$dbbackend->dbparams['host'], self::$dbbackend->dbparams['user'], self::$dbbackend->dbparams['pass'] );
}
$this->filePath = $filePath;
if ( !isset( $GLOBALS['eZDBFileHandler_Settings'] ) )
{
$fileINI = eZINI::instance( 'file.ini' );
$GLOBALS['eZDBFileHandler_Settings']['NonExistantStaleCacheHandling'] = $fileINI->variable( "ClusteringSettings", "NonExistantStaleCacheHandling" );
unset( $fileINI );
}
$this->nonExistantStaleCacheHandling = $GLOBALS['eZDBFileHandler_Settings']['NonExistantStaleCacheHandling'];
$this->filePermissionMask = octdec( eZINI::instance()->variable( 'FileSettings', 'StorageFilePermissions' ) );
}
示例14: instance
/**
* Returns a shared instance of the eZDBSchemaInterface class.
*
* @param array|eZDBInterface|false $params If array, following key is needed:
* - instance: the eZDB instance (optional), if none provided, eZDB::instance() will be used.
* @return eZDBSchemaInterface|false
*/
static function instance($params = false)
{
if (is_object($params)) {
$db = $params;
$params = array('instance' => $db);
}
if (!isset($params['instance'])) {
$db = eZDB::instance();
$params['instance'] = $db;
}
$db = $params['instance'];
if (!isset($params['type'])) {
$params['type'] = $db->databaseName();
}
if (!isset($params['schema'])) {
$params['schema'] = false;
}
$dbname = $params['type'];
/* Load the database schema handler INI stuff */
$ini = eZINI::instance('dbschema.ini');
$schemaPaths = $ini->variable('SchemaSettings', 'SchemaPaths');
$schemaHandlerClasses = $ini->variable('SchemaSettings', 'SchemaHandlerClasses');
/* Check if we have a handler */
if (!isset($schemaPaths[$dbname]) or !isset($schemaHandlerClasses[$dbname])) {
eZDebug::writeError("No schema handler for database type: {$dbname}", __METHOD__);
return false;
}
/* Include the schema file and instantiate it */
require_once $schemaPaths[$dbname];
return new $schemaHandlerClasses[$dbname]($params);
}
示例15: validNodes
/**
* Return valid items for block with given $blockID
*
* @static
* @param string $blockID
* @param bool $asObject
* @return array(eZContentObjectTreeNode)
*/
static function validNodes($blockID, $asObject = true)
{
if (isset($GLOBALS['eZFlowPool']) === false) {
$GLOBALS['eZFlowPool'] = array();
}
if (isset($GLOBALS['eZFlowPool'][$blockID])) {
return $GLOBALS['eZFlowPool'][$blockID];
}
$visibilitySQL = "";
if (eZINI::instance('site.ini')->variable('SiteAccessSettings', 'ShowHiddenNodes') !== 'true') {
$visibilitySQL = "AND ezcontentobject_tree.is_invisible = 0 ";
}
$db = eZDB::instance();
$validNodes = $db->arrayQuery("SELECT ezm_pool.node_id\n FROM ezm_pool, ezcontentobject_tree, ezcontentobject\n WHERE ezm_pool.block_id='{$blockID}'\n AND ezm_pool.ts_visible>0\n AND ezm_pool.ts_hidden=0\n AND ezcontentobject_tree.node_id = ezm_pool.node_id\n AND ezcontentobject.id = ezm_pool.object_id\n AND " . eZContentLanguage::languagesSQLFilter('ezcontentobject') . "\n {$visibilitySQL}\n ORDER BY ezm_pool.priority DESC");
if ($asObject && !empty($validNodes)) {
$validNodesObjects = array();
foreach ($validNodes as $node) {
$validNodeObject = eZContentObjectTreeNode::fetch($node['node_id']);
if ($validNodeObject instanceof eZContentObjectTreeNode && $validNodeObject->canRead()) {
$validNodesObjects[] = $validNodeObject;
}
}
$GLOBALS['eZFlowPool'][$blockID] = $validNodesObjects;
return $validNodesObjects;
} else {
return $validNodes;
}
}