本文整理汇总了PHP中eZINI::hasVariable方法的典型用法代码示例。如果您正苦于以下问题:PHP eZINI::hasVariable方法的具体用法?PHP eZINI::hasVariable怎么用?PHP eZINI::hasVariable使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类eZINI
的用法示例。
在下文中一共展示了eZINI::hasVariable方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: isCacheEnabled
/**
* Checks if application cache is enabled for this controller/action, as set in rest.ini
*
* Default value will be [CacheSettings].ApplicationCache
* This can be refined by setting a [<controllerClass>_<action>_CacheSettings] section (see comments in rest.ini).
*
* @return bool
*/
private function isCacheEnabled()
{
// Global switch
if ( $this->restINI->variable( 'CacheSettings', 'ApplicationCache' ) !== 'enabled' )
{
return false;
}
$routingInfos = $this->getRouter()->getRoutingInformation();
// Check if we have a specific setting for this controller/action
$actionSectionName = $routingInfos->controllerClass . '_' . $routingInfos->action . '_CacheSettings';
if ( $this->restINI->hasVariable( $actionSectionName, 'ApplicationCache' ) )
{
return $this->restINI->variable( $actionSectionName, 'ApplicationCache' ) === 'enabled';
}
// Nothing at controller/action level, check at controller level
$controllerSectionName = $routingInfos->controllerClass . '_CacheSettings';
if ( $this->restINI->hasVariable( $controllerSectionName, 'ApplicationCache' ) )
{
return $this->restINI->variable( $controllerSectionName, 'ApplicationCache' ) === 'enabled';
}
// Nothing at controller level, take the default value
return $this->restINI->variable( 'CacheSettings', 'ApplicationCacheDefault' ) === 'enabled';
}
示例2: processObject
/**
* Processes Open Graph metadata from object attributes
*
* @param eZContentObject $contentObject
* @param array $returnArray
*
* @return array
*/
function processObject($contentObject, $returnArray)
{
if ($this->ogIni->hasVariable($contentObject->contentClassIdentifier(), 'LiteralMap')) {
$literalValues = $this->ogIni->variable($contentObject->contentClassIdentifier(), 'LiteralMap');
if ($this->debug) {
eZDebug::writeDebug($literalValues, 'LiteralMap');
}
if ($literalValues) {
foreach ($literalValues as $key => $value) {
if (!empty($value)) {
$returnArray[$key] = $value;
}
}
}
}
if ($this->ogIni->hasVariable($contentObject->contentClassIdentifier(), 'AttributeMap')) {
$attributeValues = $this->ogIni->variableArray($contentObject->contentClassIdentifier(), 'AttributeMap');
if ($this->debug) {
eZDebug::writeDebug($attributeValues, 'AttributeMap');
}
if ($attributeValues) {
foreach ($attributeValues as $key => $value) {
$contentObjectAttributeArray = $contentObject->fetchAttributesByIdentifier(array($value[0]));
if (!is_array($contentObjectAttributeArray)) {
continue;
}
$contentObjectAttributeArray = array_values($contentObjectAttributeArray);
$contentObjectAttribute = $contentObjectAttributeArray[0];
if ($contentObjectAttribute instanceof eZContentObjectAttribute) {
$openGraphHandler = ngOpenGraphBase::getInstance($contentObjectAttribute);
if (count($value) == 1) {
$data = $openGraphHandler->getData();
} else {
if (count($value) == 2) {
$data = $openGraphHandler->getDataMember($value[1]);
} else {
$data = "";
}
}
if (!empty($data)) {
$returnArray[$key] = $data;
}
}
}
}
}
return $returnArray;
}
示例3: getVariable
function getVariable($block, $settingName, $iniFile, $path)
{
$ini = new eZINI($iniFile, $path, null, null, null, true, true);
$result = $ini->hasVariable($block, $settingName) ? $ini->variable($block, $settingName) : false;
$result = parseArrayToStr($result, '<br>');
return $result;
}
示例4: unset
if ( !$ini->save() )
{
eZDebug::writeError( "Can't save ini file: $iniPath/$fileName.append" );
}
unset( $baseIni );
unset( $ini );
// Remove variable from the global override
if ( $siteAccess != "global_override" )
{
$ini = new eZINI( $fileName . '.append', "settings/override", null, null, null, true, true );
foreach( $settings as $setting )
{
if ( $ini->hasVariable( $setting[0], $setting[1] ) )
$ini->removeSetting( $setting[0], $setting[1] );
}
if ( !$ini->save() )
{
eZDebug::writeError( "Can't save ini file: $iniPath/$fileName.append" );
}
unset($ini);
}
}
$uri = $http->postVariable( 'RedirectURI', $http->sessionVariable( 'LastAccessedModifyingURI', '/' ) );
$module->redirectTo( $uri );
?>
示例5: removePathPrefixIfNeeded
/**
* Remove PathPrefix from url, if applicable (present in siteaccess and matched in url)
*
* @param eZINI $saIni eZINI instance of site.ini for the siteaccess to check
* @param string $url
*
* @return bool true if no PathPrefix exists, or removed from url. false if not removed.
*/
protected static function removePathPrefixIfNeeded(eZINI $saIni, &$url)
{
if ($saIni->hasVariable('SiteAccessSettings', 'PathPrefix')) {
$pathPrefix = $saIni->variable('SiteAccessSettings', 'PathPrefix');
if (!empty($pathPrefix)) {
if (strpos($url, $pathPrefix . '/') === 0 || $pathPrefix === $url) {
$url = substr($url, strlen($pathPrefix) + 1);
} else {
// PathPrefix exists, but not matched in url.
return false;
}
}
}
return true;
}
示例6: runImport
/**
* Starts to run the import
* @param array( SQLIImportItem ) $aImportItems
* @throws SQLIImportBaseException
* @throws ezcConfigurationNoConfigException
*/
public function runImport(array $aImportItems)
{
// First check if an import is already running
if (SQLIImportToken::importIsRunning()) {
throw new SQLIImportBaseException('Another import is already running. Aborting...', SQLIImportBaseException::IMPORT_ALREADY_RUNNING);
}
$this->token = SQLIImportToken::registerNewImport();
$this->handlePerformanceSettings();
if (empty($aImportItems)) {
// If no source handler is provided, consider processing all source handlers available
$aImportItems = $this->importINI->variable('ImportSettings', 'AvailableSourceHandlers');
}
// Process import items one by one
for ($i = 0, $iMax = count($aImportItems); $i < $iMax; ++$i) {
try {
if (!$aImportItems[$i] instanceof SQLIImportItem) {
throw new SQLIImportRuntimeException('Invalid import item !');
}
// Update status for import item
$aImportItems[$i]->setAttribute('status', SQLIImportItem::STATUS_RUNNING);
$aImportItems[$i]->store();
$this->currentImportItem = $aImportItems[$i];
// First check if this handler has all needed configuration
$handler = $aImportItems[$i]->attribute('handler');
$handlerSection = $handler . '-HandlerSettings';
if (!$this->importINI->hasSection($handlerSection)) {
// Check INI Section
throw new ezcConfigurationNoConfigException('Error : Handler "' . $handler . '" does not have proper config section in sqliimport.ini !');
}
if (!$this->importINI->hasVariable($handlerSection, 'ClassName')) {
// Check if ClassName is properly defined
throw new ezcConfigurationNoConfigException('Error : ClassName not defined for "' . $handler . '" in sqliimport.ini !');
}
// Default values
$handlerClassName = $this->importINI->variable($handlerSection, 'ClassName');
$handlerEnabled = true;
$debug = false;
$defaultParentNodeID = $this->importINI->variable('ImportSettings', 'DefaultParentNodeID');
$streamTimeout = $this->importINI->variable('ImportSettings', 'StreamTimeout');
if ($this->importINI->hasVariable($handlerSection, 'Enabled')) {
$handlerEnabled = $this->importINI->variable($handlerSection, 'Enabled') === 'true';
}
if ($this->importINI->hasVariable($handlerSection, 'Debug')) {
$debug = $this->importINI->variable($handlerSection, 'Debug') === 'enabled';
}
if ($this->importINI->hasVariable($handlerSection, 'DefaultParentNodeID')) {
$localParentNodeID = $this->importINI->variable($handlerSection, 'DefaultParentNodeID');
$defaultParentNodeID = is_int($localParentNodeID) ? (int) $localParentNode : $defaultParentNodeID;
}
if ($this->importINI->hasVariable($handlerSection, 'StreamTimeout')) {
$streamTimeout = (int) $this->importINI->variable($handlerSection, 'StreamTimeout');
}
// Check $defaultParentNodeID and throw an exception if not consistent
$parentNode = eZContentObjectTreeNode::fetch($defaultParentNodeID, false, false);
if (!$parentNode) {
throw new SQLIImportRuntimeException('Error : invalid DefaultParentNodeID ( ' . $defaultParentNodeID . ' )');
}
unset($parentNode);
// Check handler class validity
if (!class_exists($handlerClassName)) {
throw new SQLIImportRuntimeException('Error : invalid handler class "' . $handlerClassName . '". Did you regenerate autolads ?');
}
// ####################################
// ##### IMPORT HANDLER PROCESSING
// ####################################
// Instantiate the handler with appropriate options and process it.
// Handler must implement ISQLIImportHandler and extend SQLIImportAbstractHandler
$handlerOptions = $aImportItems[$i]->attribute('options');
$importHandler = new $handlerClassName($handlerOptions);
if (!$importHandler instanceof ISQLIImportHandler || !$importHandler instanceof SQLIImportAbstractHandler) {
throw new SQLIImportRuntimeException('Error : invalid handler "' . $handlerClassName . '". Must implement ISQLIImportHandler and extend SQLIImportAbstractHandler.');
}
$importHandler->handlerConfArray = $this->importINI->group($handlerSection);
$importHandler->initialize();
// Get process length to calculate advancement percentage to track advancement
$processLength = $importHandler->getProcessLength();
$percentageAdvancementStep = 100 / $processLength;
$handlerName = $importHandler->getHandlerName();
$handlerIdentifier = $importHandler->getHandlerIdentifier();
// Progress bar implementation
$progressBarOptions = array('emptyChar' => ' ', 'barChar' => '=');
$progressBar = new ezcConsoleProgressbar($this->output, $processLength, $progressBarOptions);
$progressBar->start();
$this->cli->warning('Now processing "' . $handlerName . '" handler.');
$isInterrupted = false;
while ($row = $importHandler->getNextRow()) {
try {
$progressBar->advance();
$startTime = time();
$importHandler->process($row);
} catch (Exception $e) {
SQLIImportLogger::logError('An error occurred during "' . $handlerIdentifier . '" import process : ' . $e->getMessage());
}
$aImportItems[$i]->updateProgress($percentageAdvancementStep, $importHandler->getProgressionNotes());
//.........这里部分代码省略.........
示例7: import
//.........这里部分代码省略.........
if ($bodyNodeArray->length === 1) {
$xmlText = "";
$level = 1;
foreach ($bodyNodeArray->item(0)->childNodes as $childNode) {
$xmlText .= self::handleNode($childNode, $level);
}
$endSectionPart = "";
$levelDiff = 1 - $level;
if ($levelDiff < 0) {
$endSectionPart = str_repeat("</section>", abs($levelDiff));
}
$charset = eZTextCodec::internalCharset();
$xmlTextBody = "<?xml version='1.0' encoding='{$charset}' ?>" . "<section xmlns:image='http://ez.no/namespaces/ezpublish3/image/' " . " xmlns:xhtml='http://ez.no/namespaces/ezpublish3/xhtml/'><section>" . $xmlText . $endSectionPart . "</section></section>";
}
}
}
// Check if we should replace the current object or import a new
if ($importType !== "replace") {
$place_object = $place_node->attribute('object');
$sectionID = $place_object->attribute('section_id');
$creatorID = $this->currentUserID;
$parentNodeID = $placeNodeID;
$object = $contentClass->instantiate($creatorID, $sectionID);
$nodeAssignment = eZNodeAssignment::create(array('contentobject_id' => $object->attribute('id'), 'contentobject_version' => $object->attribute('current_version'), 'parent_node' => $parentNodeID, 'is_main' => 1));
$nodeAssignment->store();
$version = $object->version(1);
$version->setAttribute('modified', eZDateTime::currentTimeStamp());
$version->setAttribute('status', eZContentObjectVersion::STATUS_DRAFT);
$version->store();
$dataMap = $object->dataMap();
} else {
// Check if class is supported before we start changing anything
$placeClassIdentifier = $place_node->attribute('class_identifier');
if ($this->ooINI->hasVariable($placeClassIdentifier, 'DefaultImportTitleAttribute') && $this->ooINI->hasVariable($placeClassIdentifier, 'DefaultImportBodyAttribute')) {
$titleAttribute = $this->ooINI->variable($placeClassIdentifier, 'DefaultImportTitleAttribute');
$bodyAttribute = $this->ooINI->variable($placeClassIdentifier, 'DefaultImportBodyAttribute');
// Extra check to see if attributes exist in dataMap (config is not wrong)
$dataMap = $place_node->attribute('data_map');
if (!isset($dataMap[$titleAttribute]) || !isset($dataMap[$bodyAttribute])) {
$this->setError(self::ERROR_IMPORTING, "Error in configuration for {$placeClassIdentifier}, please check configuration file.");
return false;
}
unset($dataMap);
} else {
$this->setError(self::ERROR_IMPORTING, "No settings for replacing node of type {$placeClassIdentifier}. Stopping.");
return false;
}
// Change class for importing
$importClassIdentifier = $placeClassIdentifier;
// already fetched: $node = eZContentObjectTreeNode::fetch( $placeNodeID );
$object = $place_node->attribute('object');
$version = $object->createNewVersion();
$dataMap = $object->fetchDataMap($version->attribute('version'));
}
$contentObjectID = $object->attribute('id');
if ($this->useCustomClass) {
// Initialize the actual object attributes
$attributeArray = $this->ooINI->variable($importClassIdentifier, 'Attribute');
foreach ($attributeArray as $attributeIdentifier => $sectionName) {
switch ($dataMap[$attributeIdentifier]->DataTypeString) {
case "ezstring":
case "eztext":
$eztextDom = new DOMDOcument('1.0', 'UTF-8');
$eztextDom->loadXML($xmlTextArray[$sectionName]);
$text = $eztextDom->documentElement->textContent;
$dataMap[$attributeIdentifier]->setAttribute('data_text', trim($text));