コード例 #1
0
ファイル: debug.php プロジェクト: jordanmanning/ezpublish
 /**
  * Initializes/updates debug settings, system wide
  */
 public function updateDebugSettings()
 {
     $ini = eZINI::instance();
     $debugSettings = array();
     $debugSettings['debug-enabled'] = ($ini->variable('DebugSettings', 'DebugOutput') == 'enabled' and $this->restINI->variable('DebugSettings', 'Debug') == 'enabled');
     $debugSettings['debug-by-ip'] = $ini->variable('DebugSettings', 'DebugByIP') == 'enabled';
     $debugSettings['debug-ip-list'] = $ini->variable('DebugSettings', 'DebugIPList');
     $logList = $ini->variable('DebugSettings', 'AlwaysLog');
     $logMap = array('notice' => eZDebug::LEVEL_NOTICE, 'warning' => eZDebug::LEVEL_WARNING, 'error' => eZDebug::LEVEL_ERROR, 'debug' => eZDebug::LEVEL_DEBUG, 'strict' => eZDebug::LEVEL_STRICT);
     $debugSettings['always-log'] = array();
     foreach ($logMap as $name => $level) {
         $debugSettings['always-log'][$level] = in_array($name, $logList);
     }
     eZDebug::updateSettings($debugSettings);
 }
コード例 #2
0
    /**
     * @param string $publisher
     * @param string $xmlFile
     * @param array $blobedFiles
     */
    public function archiveFiles( $publisher, $xmlFile, $blobedFiles )
    {
        $this->buildArchiveFolder( $publisher );

        $rootImport             = $this->importINI->variable( 'XMLImportSettings', 'RootImport' );
        $publisherFolder        = "$rootImport/{$this->rootImportFolder}/$publisher";
        $publisherArchiveFolder = "$publisherFolder/archived";

        self::handleModeUATFile( "$publisherFolder/$xmlFile", "$publisherArchiveFolder/$xmlFile" );

        XMLImportMonitor::log( "Archive xml file : $publisherFolder/$xmlFile => $publisherArchiveFolder/$xmlFile", 'info' );
        XMLImportMonitor::setMonitorData('nb_of_retry', 0);

        foreach ( $blobedFiles as $blobedFile )
        {
            $tmpFile = str_replace( "$publisherFolder/", '', $blobedFile );

            if ( $tmpFile == $blobedFile )
            {
                XMLImportMonitor::log( "Unarchivable blobed file : $blobedFile", 'warning' );
            }
            else
            {
                self::handleModeUATFile( "$publisherFolder/$tmpFile", "$publisherArchiveFolder/$tmpFile" );
                XMLImportMonitor::log( "Archive blobed file : $publisherFolder/$tmpFile => $publisherArchiveFolder/$tmpFile", 'info' );
            }
        }
    }
コード例 #3
0
 /**
  * Test scenario for LDAP login using SimpleMapping, moving a user when the groups change
  *
  * Test Outline
  * ------------
  * 1. Set LDAPGroupMappingType = SimpleMapping but add no mappings
  * 2. Login with username and password
  * 3. Check parent nodes of user object
  *
  * @result: User is placed under the node given by LDAPGroupRootNodeId
  * @expected: User is placed under the node given by LDAPGroupRootNodeId
  *
  * 1. Set LDAPGroupMappingType = SimpleMapping and mapping settings
  * 2. Login with username and password
  * 3. Check parent nodes of user object
  *
  * @result: User is placed in the RebelAlliance group
  * @expected: User is placed in the RebelAlliance group
  *
  * 1. Change mapping settings, RebelAlliance => StarWars
  * 2. Login with username and password
  * 3. Check parent nodes of user object
  *
  * @result: User is placed in the StarWars group
  * @expected: User is placed in the StarWars group
  */
 public function testLoginUserSimpleMappingExistingUser()
 {
     // First login, to get an existing user object
     $this->ldapINI->setVariable('LDAPSettings', 'LDAPGroupMappingType', 'SimpleMapping');
     $this->ldapINI->setVariable('LDAPSettings', 'LDAPGroupNameAttribute', 'ou');
     $this->ldapINI->setVariable('LDAPSettings', 'LDAPGroupMemberAttribute', 'seeAlso');
     $this->ldapINI->setVariable('LDAPSettings', 'LDAPUserGroupMap', array());
     $this->ldapINI->setVariable('LDAPSettings', 'KeepGroupAssignment', 'disabled');
     // The user should be placed under the node given by LDAPGroupRootNodeId
     $user = eZLDAPUser::loginUser('leia', 'bunhead');
     $contentObject = $user->attribute('contentobject');
     self::assertEquals(array($this->ldapINI->variable('LDAPSettings', 'LDAPGroupRootNodeId')), $contentObject->attribute('parent_nodes'));
     // Then login again, with correct group mapping
     $this->ldapINI->setVariable('LDAPSettings', 'LDAPUserGroupMap', array('StarWars' => 'StarWars', 'RebelAlliance' => 'RebelAlliance', 'Rogues' => 'Rogues'));
     // The user should have moved to the RebelAlliance group
     $user = eZLDAPUser::loginUser('leia', 'bunhead');
     $contentObject = $user->attribute('contentobject');
     self::assertEquals(array($this->rebelGroupNodeId), $contentObject->attribute('parent_nodes'));
     // Change mapping and login again
     $this->ldapINI->setVariable('LDAPSettings', 'LDAPUserGroupMap', array('StarWars' => 'StarWars', 'RebelAlliance' => 'StarWars', 'Rogues' => 'Rogues'));
     // The user should have moved to the StarWars group
     $user = eZLDAPUser::loginUser('leia', 'bunhead');
     $contentObject = $user->attribute('contentobject');
     self::assertEquals(array($this->starWarsGroupNodeId), $contentObject->attribute('parent_nodes'));
 }
コード例 #4
0
 protected function loadHandlers()
 {
     $handlers = (array) $this->extraParametersIni->variable('AvailableHandlers', 'Handlers');
     foreach ($handlers as $identifier => $className) {
         if (class_exists($className)) {
             $interfaces = class_implements($className);
             if (in_array('OCClassExtraParametersHandlerInterface', $interfaces)) {
                 $this->handlers[$identifier] = new $className($this->class);
             } else {
                 eZDebug::writeError("{$className} not implements OCClassExtraParametersHandlerInterface", __METHOD__);
             }
         } else {
             eZDebug::writeError("{$className} not found", __METHOD__);
         }
     }
 }
コード例 #5
0
ファイル: rest_controller.php プロジェクト: nottavi/ezpublish
    /**
     * 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';
    }
コード例 #6
0
    /**
     * @param array $fieldArray
     * @param string $type
     * @return string
     */
    public static function getAdjustedType( $fieldArray, $type )
    {
        /* @type $availableRelatedContent array */
        $availableRelatedContent = self::$importINI->variable( 'XMLImportSettings', 'AvailableRelatedContent' );
        if ( $type == 'article' )
            $realType = $type;
        elseif ( $type == 'media_content' )
        {
            $mediaTypeField = is_array($fieldArray['media_type'])?$fieldArray['media_type'][0]:$fieldArray['media_type'];

            if ( $mediaTypeField )
                $realType = $mediaTypeField->fieldNode->nodeValue;
            else
            {
                $fieldMapping = XMLImportMapping::getByFieldName( $type, 'media_type' );
                $realType     = $fieldMapping['default'];
            }
        }
        elseif ( in_array( $type, $availableRelatedContent ) )
            $realType = $type;
        else
            $realType = false;

        return $realType;
    }
コード例 #7
0
    /**
     * @param eZINI $importINI
     * @return void
     */
    public static function init(eZINI $importINI)
    {
        $extDir = eZSys::rootDir() . '/extension/';

        //Get generated mapping config file
        $jsonFile     = $extDir . $importINI->variable('XMLImportSettings', 'MappingConfigGeneratedFile');
        $jsonString   = file_get_contents($jsonFile);
        $mapGenerated = json_decode($jsonString, true);

        //Get fixed mapping config file
        $jsonFile   = $extDir . $importINI->variable('XMLImportSettings', 'MappingConfigFixedFile');
        $jsonString = file_get_contents($jsonFile);
        $mapFixed   = json_decode($jsonString, true);

        //Merge both file
        self::$mapping = $mapGenerated + $mapFixed;
    }
コード例 #8
0
 /**
  * Test for {@link eZSolrBase::sendHTTPRequestRetry()} with a timedout Solr server
  * @link http://issues.ez.no/17862
  * @group issue17862
  */
 public function testSendHTTPRequestRetryTimeout()
 {
     ezpINIHelper::setINISetting('solr.ini', 'SolrBase', 'SearchServerURI', $this->nonReachableSolr);
     $connectionTimeout = $this->solrINI->variable('SolrBase', 'ConnectionTimeout');
     $maxRetries = $this->solrINI->variable('SolrBase', 'ProcessMaxRetries');
     $solrBase = new eZSolrBase();
     $refObj = new ReflectionObject($solrBase);
     $refMethod = $refObj->getMethod('sendHTTPRequestRetry');
     $refMethod->setAccessible(true);
     $startTime = time();
     $postString = $solrBase->buildPostString($this->postParams);
     $res = $refMethod->invoke($solrBase, $solrBase->SearchServerURI . $this->testURI, $postString);
     $stopTime = time();
     $diffTime = $stopTime - $startTime;
     self::assertFalse($res, 'Failed HTTP request to Solr must return false');
     self::assertEquals($diffTime, $maxRetries * $connectionTimeout, "Sending HTTP Request to Solr must be retried a setted number of times (in solr.ini) if server has timed out");
 }
コード例 #9
0
 /**
  * May activate SearchSettings.DelayedIndexing for current import script if so configured
  * Result is faster import but imported content objects will need to be indexed later
  * (by indexcontent cronjob or sqliimport_cleanup cronjob)
  */
 private function handleSearchIndexPrevention()
 {
     $siteINI = eZINI::instance();
     $objectIndexingEnabled = $this->importINI->variable('ImportSettings', 'ObjectIndexing') === 'enabled';
     if (!$objectIndexingEnabled) {
         $this->delayedIndexingEnabledGlobal = $siteINI->variable('SearchSettings', 'DelayedIndexing') === 'enabled';
         $siteINI->setVariable('SearchSettings', 'DelayedIndexing', 'enabled');
     }
 }
コード例 #10
0
    /**
     * @return DOMElement
     * @throws RootNodeException
     */
    public function getRealRoot()
    {
        $rootDocument = $this->importINI->variable('XMLImportSettings', 'RootXMLDocument');
        $nodeList     = $this->xmlParser->getElementsByTagName($rootDocument);

        if ($nodeList->length == 1)
            return $nodeList->item(0);
        else
            throw new RootNodeException('Root document Node not found');
    }
コード例 #11
0
    /**
     * @param DOMElement $rootNode
     * @throws RootNodeException
     * @return void
     */
    public function setRootNode($rootNode)
    {
        if (is_null($rootNode))
        {
            $rootDocument = $this->importINI->variable('XMLImportSettings', 'RootXMLDocument');
            $nodeList     = $this->xmlParser->getElementsByTagName($rootDocument);

            if ($nodeList->length == 1)
            {
                $this->rootNode = $nodeList->item(0);
                return;
            }
            else
            {
                throw new RootNodeException('Root Node not found in file');
            }
        }
        else
        {
            $this->rootNode = $rootNode;
        }
    }
コード例 #12
0
 /**
  * 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;
 }
コード例 #13
0
    protected function checkESBMethod( $method, $postData )
    {
        $url = sprintf( "%s%s%s?Country_of_Registration=%s",
            \eZINI::instance( 'merck.ini' )->variable( 'WebService', 'BaseUrl' ),
            \eZINI::instance( 'merck.ini' )->variable( 'WebService', 'Prefix' ),
            $method,
            $this->_clusterSiteIni->variable( 'RegionalSettings', 'CountryOfRegistration' )
        );

        $ch = curl_init( $url );
        curl_setopt_array( $ch, array(
            CURLOPT_POST            => 1,
            CURLOPT_POSTFIELDS      => $postData,
            CURLOPT_HEADER          => 1,
            CURLOPT_HTTPHEADER      => array( 'Content-type: application/json' ),
            CURLOPT_RETURNTRANSFER  => 1,
        ));
        $response = curl_exec( $ch );
        list ( $headers, $body ) = explode( "\r\n\r\n", $response, 2 );
        $responseCode = curl_getinfo( $ch, CURLINFO_HTTP_CODE );
        $curlErrorNo = curl_errno( $ch );
        $curlError   = curl_error( $ch );
        curl_close( $ch );

        if ( !$response )
            $this->script->shutdown( 1, "Curl error calling calling $url:\n\t[$curlErrorNo] $curlError" );

        if ( $responseCode != 200 )
            $this->script->shutdown( 1, $response );

        $data = json_decode( $body, true );
        if( !is_array( $data ) )
            $this->script->shutdown( 1, "Could not parse JSON:\n".$response );

        return array(
            'data'      => $data['Data'],
            'headers'   => $headers,
            'body'      => $body );
    }
コード例 #14
0
 /**
  * Pushes the configuration XML to Solr through a custom requestHandler ( HTTP/ReST ).
  * The requestHandler ( Solr extension ) will take care of reloading the configuration.
  *
  * @see $configurationXML
  * @param null $shard
  * @throws Exception
  */
 protected static function pushConfigurationToSolr($shard = null)
 {
     // Keep previous behaviour, but should not be needed
     if ($shard === null) {
         $shard = new eZSolrBase();
     }
     $syncMethodConf = self::$solrINI->variable('Elevate', 'SyncMethod');
     $result = false;
     if (class_exists($syncMethodConf['name'])) {
         $syncMethod = new $syncMethodConf['name']();
         $result = $syncMethod->synchronise($shard, self::getConfiguration(), $syncMethodConf);
     } else {
         eZDebug::writeError("Unable to find the PHP class " . $syncMethodConf['name'] . " defined for elevate synchronisation ", __METHOD__);
     }
     if (!$result) {
         $message = ezpI18n::tr('extension/ezfind/elevate', 'An error occured in updating Solr\'s elevate configuration.');
         eZDebug::writeError($message, __METHOD__);
         throw new Exception($message);
     } elseif (isset($result['error'])) {
         eZDebug::writeError($result['error'], __METHOD__);
     } else {
         eZDebug::writeNotice("Successful update of Solr's configuration through " . $syncMethodConf['name'], __METHOD__);
     }
 }
コード例 #15
0
    $iniFiles[$settingArray[2]][] = array ( $settingArray[0], $settingArray[1], in_array( $index, $selectedList ) );
}
unset( $setting );

$iniPath = ( $siteAccess == "global_override" ) ? "settings/override" : "settings/siteaccess/$siteAccess";

foreach( $iniFiles as $fileName => $settings )
{
    $ini = new eZINI( $fileName . '.append', $iniPath, null, null, null, true, true );
    $baseIni = eZINI::instance( $fileName );

    foreach( $settings as $setting )
    {
        if ( $ini->hasVariable( $setting[0], $setting[1] ) )
            $value = $ini->variable( $setting[0], $setting[1] );
        else
            $value = $baseIni->variable( $setting[0], $setting[1] );

        if ( $value == 'true' || $value == 'false' )
            $ini->setVariable( $setting[0], $setting[1], $setting[2] ? 'true' : 'false' );
        else
            $ini->setVariable( $setting[0], $setting[1], $setting[2] ? 'enabled' : 'disabled' );
    }

    if ( !$ini->save() )
    {
        eZDebug::writeError( "Can't save ini file: $iniPath/$fileName.append" );
    }

    unset( $baseIni );
コード例 #16
0
<?php

$ini = new eZINI('content.ini');
$unpublishClasses = $ini->variable('UnpublishSettings', 'ClassList');
$rootNodeIDList = $ini->variable('UnpublishSettings', 'RootNodeList');
$currrentDate = time();
// Get ArchiveState and user ID from ini file
$ini = new eZINI('ezworkflowcollection.ini');
$targetState = $ini->variable('UpdateObjectStatesSettings', 'ArchiveObjectState');
$adminUser = eZUser::fetch($ini->variable('UpdateObjectStatesSettings', 'ObjectStateUserID'));
eZUser::setCurrentlyLoggedInUser($adminUser);
$currentUser = eZUser::currentUser();
$cli->output('Login as admin : ' . $currentUser->attribute('login'));
$cli->output('Archiver : Starting.');
$cli->output('Supported Classes : ' . implode(', ', $unpublishClasses));
foreach ($rootNodeIDList as $nodeID) {
    $rootNode = eZContentObjectTreeNode::fetch($nodeID);
    $articleNodeArray = $rootNode->subTree(array('ClassFilterType' => 'include', 'ClassFilterArray' => $unpublishClasses));
    foreach ($articleNodeArray as $articleNode) {
        $article = $articleNode->attribute('object');
        $dataMap = $article->attribute('data_map');
        $dateAttribute = $dataMap['unpublish_date'];
        if ($dateAttribute === null) {
            continue;
        }
        $date = $dateAttribute->content();
        $articleRetractDate = $date->attribute('timestamp');
        if ($articleRetractDate > 0 && $articleRetractDate < $currrentDate) {
            $ok = "NOT-OK";
            // Switch Object state to Archived
            if (eZOperationHandler::operationIsAvailable('content_updateobjectstate')) {
コード例 #17
0
<?php

$ini = new eZINI('content.ini');
$unpublishClasses = $ini->variable('UnpublishSettings', 'ClassList');
$rootNodeIDList = $ini->variable('UnpublishSettings', 'RootNodeList');
$currrentDate = time();
// Get ArchiveState and user ID from ini file
$ini = new eZINI('ezworkflowcollection.ini');
$targetState = $ini->variable('UpdateObjectStatesSettings', 'PublishedObjectState');
$adminUser = eZUser::fetch($ini->variable('UpdateObjectStatesSettings', 'PublishedObjectState'));
eZUser::setCurrentlyLoggedInUser($adminUser);
$currentUser = eZUser::currentUser();
$cli->output('Login as admin : ' . $currentUser->attribute('login'));
$cli->output('Published : Starting.');
$cli->output('Supported Classes : ' . implode(', ', $unpublishClasses));
foreach ($rootNodeIDList as $nodeID) {
    $rootNode = eZContentObjectTreeNode::fetch($nodeID);
    $articleNodeArray = $rootNode->subTree(array('ClassFilterType' => 'include', 'ClassFilterArray' => $unpublishClasses));
    foreach ($articleNodeArray as $articleNode) {
        $article = $articleNode->attribute('object');
        // Si le contenu est à l'état Mise en ligne programmée 'publish_chain/waituntildate'
        if (in_array($ini->variable('UpdateObjectStatesSettings', 'PendingObjectState'), $article->attribute('state_id_array'))) {
            $dataMap = $article->attribute('data_map');
            $dateAttribute = $dataMap['publish_date'];
            if ($dateAttribute === null) {
                continue;
            }
            $date = $dateAttribute->content();
            $articleRetractDate = $date->attribute('timestamp');
            if ($articleRetractDate > 0 && $articleRetractDate < $currrentDate) {
                $ok = "NOT-OK";
コード例 #18
0
 /**
  * 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;
 }
コード例 #19
0
ファイル: ezooimport.php プロジェクト: netbliss/ezodf
 function handleInlineNode($childNode, $nextLineBreak = false, $prevLineBreak = false)
 {
     $localName = $childNode->localName;
     if ($localName == '') {
         $localName = $childNode->nodeName;
     }
     // Get the real name
     $paragraphContent = '';
     switch ($localName) {
         case "frame":
             $frameContent = "";
             foreach ($childNode->childNodes as $imageNode) {
                 switch ($imageNode->localName) {
                     case "image":
                         $href = ltrim($imageNode->getAttributeNS(self::NAMESPACE_XLINK, 'href'), '#');
                         if (0 < preg_match('@^(?:http://)([^/]+)@i', $href)) {
                             eZDebug::writeDebug("handling http url: {$href}", __METHOD__);
                             $matches = array();
                             if (0 < preg_match('/.*\\/(.*)?/i', $href, $matches)) {
                                 $fileName = $matches[1];
                                 if (false != ($imageData = file_get_contents($href))) {
                                     $href = $this->ImportDir . $fileName;
                                     $fileOut = fopen($href, "wb");
                                     if (fwrite($fileOut, $imageData)) {
                                         eZDebug::writeNotice("External image stored in {$href}", __METHOD__);
                                     } else {
                                         eZDebug::writeError("Could not save file {$href}", __METHOD__);
                                     }
                                     fclose($fileOut);
                                 } else {
                                     eZDebug::writeError("Downloading external image from {$href} has failed, broken link?", __METHOD__);
                                 }
                             } else {
                                 eZDebug::writeError("Could not match filename in {$href}", __METHOD__);
                             }
                         } else {
                             $href = $this->ImportDir . $href;
                         }
                         // Check image name
                         $imageName = $childNode->getAttributeNS(self::NAMESPACE_DRAWING, 'name');
                         if (!$imageName) {
                             // set default image name
                             $imageName = "Imported Image";
                         }
                         $imageSize = "medium";
                         $imageAlignment = "center";
                         // Check image size
                         $imageSize = "large";
                         $pageWidth = 6;
                         $width = $childNode->getAttributeNS(self::NAMESPACE_SVG_COMPATIBLE, 'width');
                         $sizePercentage = $width / $pageWidth * 100;
                         if ($sizePercentage < 80 and $sizePercentage > 30) {
                             $imageSize = 'medium';
                         }
                         if ($sizePercentage <= 30) {
                             $imageSize = 'small';
                         }
                         // Check if image should be set to original
                         $sizeArray = getimagesize($href);
                         if ($imageSize != "small" and $sizeArray[0] < 650) {
                             $imageSize = "original";
                         }
                         $styleName = $childNode->getAttributeNS(self::NAMESPACE_DRAWING, 'style-name');
                         // Check for style definitions
                         $imageAlignment = "center";
                         foreach ($this->AutomaticStyles as $style) {
                             if ($style->nodeType !== XML_ELEMENT_NODE) {
                                 continue;
                             }
                             $tmpStyleName = $style->getAttributeNS(self::NAMESPACE_STYLE, "name");
                             if ($styleName == $tmpStyleName) {
                                 if ($style->childNodes->length == 1) {
                                     $properties = $style->childNodes->item(0);
                                     $alignment = $properties->getAttributeNS(self::NAMESPACE_STYLE, "horizontal-pos");
                                 }
                                 // Check image alignment
                                 switch ($alignment) {
                                     case "left":
                                         $imageAlignment = "left";
                                         break;
                                     case "right":
                                         $imageAlignment = "right";
                                         break;
                                     default:
                                         $imageAlignment = "center";
                                         break;
                                 }
                                 break;
                             }
                         }
                         if (file_exists($href)) {
                             // Calculate RemoteID based on image md5:
                             $remoteID = "ezoo-" . md5(file_get_contents($href));
                             /*
                                                             // Check if an image with the same remote ID already exists
                                                             $db = eZDB::instance();
                                                             $imageParentNodeID = $GLOBALS["OOImportObjectID"];
                                                             $resultArray = $db->arrayQuery( 'SELECT id, node_id, ezcontentobject.remote_id
                                                                                              FROM  ezcontentobject, ezcontentobject_tree
                                                                                              WHERE ezcontentobject.remote_id = "' . $remoteID. '" AND
                                                                                                    ezcontentobject.id=ezcontentobject_tree.contentobject_id AND
                                                                                                    ezcontentobject_tree.parent_node_id=' . $imageParentNodeID );
                                                             $contentObject = false;
                                                             if ( count( $resultArray ) >= 1 )
                                                             {
                                                                 $contentObject = eZContentObject::fetch( $resultArray[0]['id'], true );
                                                                 $contentObjectID = $resultArray[0]['id'];
                                                             }
                             */
                             $contentObject = eZContentObject::fetchByRemoteID($remoteID);
                             // If image does not already exist, create it as an object
                             if (!$contentObject) {
                                 // Import image
                                 $imageClassIdentifier = $this->ooINI->variable("ODFImport", "DefaultImportImageClass");
                                 $class = eZContentClass::fetchByIdentifier($imageClassIdentifier);
                                 $creatorID = $this->currentUserID;
                                 $contentObject = $class->instantiate($creatorID, 1);
                                 $contentObject->setAttribute("remote_id", $remoteID);
                                 $contentObject->store();
                                 $version = $contentObject->version(1);
                                 $version->setAttribute('modified', eZDateTime::currentTimeStamp());
                                 $version->setAttribute('status', eZContentObjectVersion::STATUS_DRAFT);
                                 $version->store();
                                 $contentObjectID = $contentObject->attribute('id');
                                 $dataMap = $contentObject->dataMap();
                                 // set image name
                                 $dataMap['name']->setAttribute('data_text', $imageName);
                                 $dataMap['name']->store();
                                 // set image caption
                                 if (isset($dataMap['caption'])) {
                                     $captionContentAttibute = $dataMap['caption'];
                                     $captionText = "{$imageName}";
                                     // create new xml for caption
                                     $xmlInputParser = new eZXMLInputParser();
                                     $dom = $xmlInputParser->createRootNode();
                                     $captionNode = $dom->createElement('paragraph', $captionText);
                                     $dom->documentElement->appendChild($captionNode);
                                     $xmlString = $dom->saveXML();
                                     $captionContentAttibute->setAttribute('data_text', $xmlString);
                                     $captionContentAttibute->store();
                                 } else {
                                     eZDebug::writeWarning("The image class does not have 'caption' attribute", 'ODF import');
                                 }
                                 // set image
                                 $imageContent = $dataMap['image']->attribute('content');
                                 //echo "Initializing Image from $href<br />";
                                 $imageContent->initializeFromFile($href, false, basename($href));
                                 $dataMap['image']->store();
                             } else {
                                 $contentObjectID = $contentObject->attribute('id');
                             }
                             $this->RelatedImageArray[] = array("ID" => $contentObjectID, "ContentObject" => $contentObject);
                             $frameContent .= "<embed object_id='{$contentObjectID}' align='{$imageAlignment}' size='{$imageSize}' />";
                         }
                         break;
                 }
             }
             // Textboxes are defined inside paragraphs.
             $paragraphContent .= "{$frameContent}";
             break;
         case "text-box":
             foreach ($childNode->childNodes as $textBoxNode) {
                 $boxContent .= self::handleNode($textBoxNode, $sectionLevel);
             }
             // Textboxes are defined inside paragraphs.
             $paragraphContent .= "</paragraph>{$boxContent}<paragraph>";
             break;
         case 'sequence':
         case 'date':
         case 'initial-creator':
             $paragraphContent .= $childNode->textContent;
             break;
         case "s":
             $paragraphContent .= " ";
             break;
         case "a":
             $href = $childNode->getAttributeNS(self::NAMESPACE_XLINK, 'href');
             $paragraphContent .= "<link href='{$href}'>" . $childNode->textContent . "</link>";
             break;
         case "#text":
             $tagContent = str_replace("&", "&amp;", $childNode->textContent);
             $tagContent = str_replace(">", "&gt;", $tagContent);
             $tagContent = str_replace("<", "&lt;", $tagContent);
             $tagContent = str_replace("'", "&apos;", $tagContent);
             $tagContent = str_replace('"', "&quot;", $tagContent);
             $paragraphContent .= $tagContent;
             break;
         case "span":
             // Fetch the style from the span
             $styleName = $childNode->getAttributeNS(self::NAMESPACE_TEXT, 'style-name');
             // Check for bold and italic styles
             $fontWeight = false;
             $fontStyle = false;
             foreach ($this->AutomaticStyles as $style) {
                 if ($style->nodeType !== XML_ELEMENT_NODE) {
                     continue;
                 }
                 $tmpStyleName = $style->getAttributeNS(self::NAMESPACE_STYLE, "name");
                 if ($styleName == $tmpStyleName) {
                     if ($style->childNodes->length >= 1) {
                         foreach ($style->childNodes as $styleChild) {
                             if ($styleChild->nodeType !== XML_ELEMENT_NODE || !$styleChild->hasAttributes()) {
                                 continue;
                             }
                             $fontWeight = $styleChild->getAttributeNS(self::NAMESPACE_FO, 'font-weight');
                             $fontStyle = $styleChild->getAttributeNS(self::NAMESPACE_FO, 'font-style');
                         }
                     }
                 }
             }
             $inlineCustomTagName = false;
             if (substr($styleName, 0, 18) == "eZCustominline_20_") {
                 $inlineCustomTagName = substr($styleName, 18);
             }
             if ($inlineCustomTagName != false) {
                 $paragraphContent .= "<custom name='{$inlineCustomTagName}'>";
             }
             if ($fontWeight == "bold") {
                 $paragraphContent .= "<strong>";
             }
             if ($fontStyle == "italic") {
                 $paragraphContent .= "<emphasize>";
             }
             $paragraphContent .= $childNode->textContent;
             if ($fontStyle == "italic") {
                 $paragraphContent .= "</emphasize>";
             }
             if ($fontWeight == "bold") {
                 $paragraphContent .= "</strong>";
             }
             if ($inlineCustomTagName != false) {
                 $paragraphContent .= "</custom>";
             }
             break;
         default:
             eZDebug::writeError("Unsupported node: '" . $localName . "'");
             break;
     }
     if ($nextLineBreak) {
         $paragraphContent = '<line>' . $paragraphContent . '</line>';
     } elseif ($prevLineBreak && $paragraphContent) {
         $paragraphContent = '<line>' . $paragraphContent . '</line>';
     }
     return $paragraphContent;
 }
コード例 #20
0
ファイル: list.php プロジェクト: gggeek/ezworkflowcollection
<?php

include_once 'kernel/common/template.php';
$Module = $Params['Module'];
$http = eZHTTPTool::instance();
$Offset = $Params['Offset'];
$viewParameters = array('offset' => $Offset);
if ($Params['State'] != 0) {
    $state = $Params['State'];
} elseif ($http->hasPostVariable('State')) {
    $state = $http->postVariable('State');
} else {
    $ini = new eZINI('ezworkflowcollection.ini');
    $state = $ini->variable('UpdateObjectStatesSettings', 'DefaultObjectState');
}
if ($http->hasVariable('SelectIDArray') && $http->hasVariable('UpdateObjectStateButton') && $http->hasVariable('TargetObjectState')) {
    $targetState = null;
    if ($http->variable('TargetObjectState') > 0) {
        $targetState = $http->variable('TargetObjectState');
        $targetState = eZContentObjectState::fetchById($targetState);
    }
    if ($targetState != null) {
        foreach ($http->variable('SelectIDArray') as $objectID) {
            $object = eZContentObject::fetch($objectID);
            if ($object != null) {
                if (eZOperationHandler::operationIsAvailable('content_updateobjectstate')) {
                    $operationResult = eZOperationHandler::execute('content', 'updateobjectstate', array('object_id' => $objectID, 'state_id_list' => array($targetState->attribute('id'))));
                } else {
                    eZContentOperationCollection::updateObjectState($objectID, array($targetState->attribute('id')));
                }
            }
コード例 #21
0
ファイル: edit.php プロジェクト: EVE-Corp-Center/ECC-Website
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;
}
コード例 #22
0
 /**
  * Searches $searchText in the search database.
  *
  * @param string $searchText Search term
  * @param array $params Search parameters
  * @param array $searchTypes Search types
  *
  * @return array
  */
 public function search($searchText, $params = array(), $searchTypes = array())
 {
     $searchText = trim($searchText);
     if (empty($searchText)) {
         return array('SearchResult' => array(), 'SearchCount' => 0, 'StopWordArray' => array());
     }
     $doFullText = true;
     $query = new LocationQuery();
     $criteria = array();
     if (isset($params['SearchDate']) && (int) $params['SearchDate'] > 0) {
         $currentTimestamp = time();
         $dateSearchType = (int) $params['SearchDate'];
         $fromTimestamp = 0;
         if ($dateSearchType === 1) {
             // Last day
             $fromTimestamp = $currentTimestamp - 86400;
         } else {
             if ($dateSearchType === 2) {
                 // Last week
                 $fromTimestamp = $currentTimestamp - 7 * 86400;
             } else {
                 if ($dateSearchType === 3) {
                     // Last month
                     $fromTimestamp = $currentTimestamp - 30 * 86400;
                 } else {
                     if ($dateSearchType === 4) {
                         // Last three months
                         $fromTimestamp = $currentTimestamp - 3 * 30 * 86400;
                     } else {
                         if ($dateSearchType === 5) {
                             // Last year
                             $fromTimestamp = $currentTimestamp - 365 * 86400;
                         }
                     }
                 }
             }
         }
         $criteria[] = new Criterion\DateMetadata(Criterion\DateMetadata::CREATED, Criterion\Operator::GTE, $fromTimestamp);
     }
     if (isset($params['SearchSectionID']) && (int) $params['SearchSectionID'] > 0) {
         $criteria[] = new Criterion\SectionId((int) $params['SearchSectionID']);
     }
     if (isset($params['SearchContentClassID']) && (int) $params['SearchContentClassID'] > 0) {
         $criteria[] = new Criterion\ContentTypeId((int) $params['SearchContentClassID']);
         if (isset($params['SearchContentClassAttributeID']) && (int) $params['SearchContentClassAttributeID'] > 0) {
             $classAttribute = eZContentClassAttribute::fetch($params['SearchContentClassAttributeID']);
             if ($classAttribute instanceof eZContentClassAttribute) {
                 $criteria[] = new Criterion\Field($classAttribute->attribute('identifier'), Criterion\Operator::LIKE, $searchText);
                 $doFullText = false;
             }
         }
     }
     if (isset($params['SearchSubTreeArray']) && !empty($params['SearchSubTreeArray'])) {
         $subTreeArrayCriteria = array();
         foreach ($params['SearchSubTreeArray'] as $nodeId) {
             $node = eZContentObjectTreeNode::fetch($nodeId);
             $subTreeArrayCriteria[] = $node->attribute('path_string');
         }
         $criteria[] = new Criterion\Subtree($subTreeArrayCriteria);
     }
     if ($doFullText) {
         $criteria[] = new Criterion\FullText($searchText);
     }
     $query->query = new Criterion\LogicalAnd($criteria);
     $query->limit = isset($params['SearchLimit']) ? (int) $params['SearchLimit'] : 10;
     $query->offset = isset($params['SearchOffset']) ? (int) $params['SearchOffset'] : 0;
     $useLocationSearch = $this->iniConfig->variable('SearchSettings', 'UseLocationSearch') === 'true';
     if ($useLocationSearch) {
         $searchResult = $this->repository->getSearchService()->findLocations($query);
     } else {
         $searchResult = $this->repository->getSearchService()->findContentInfo($query);
     }
     $nodeIds = array();
     foreach ($searchResult->searchHits as $searchHit) {
         $nodeIds[] = $useLocationSearch ? $searchHit->valueObject->id : $searchHit->valueObject->mainLocationId;
     }
     $resultNodes = array();
     if (!empty($nodeIds)) {
         $nodes = eZContentObjectTreeNode::fetch($nodeIds);
         if ($nodes instanceof eZContentObjectTreeNode) {
             $resultNodes = array($nodes);
         } else {
             if (is_array($nodes)) {
                 $resultNodes = $nodes;
             }
         }
     }
     return array('SearchResult' => $resultNodes, 'SearchCount' => $searchResult->totalCount, 'StopWordArray' => array());
 }