function sendConfirmation()
 {
     if ($this->attribute('status') != eZSubscription::StatusPending) {
         return;
     }
     $res = eZTemplateDesignResource::instance();
     $ini = eZINI::instance();
     $hostname = eZSys::hostname();
     $template = 'design:eznewsletter/sendout/registration.tpl';
     $tpl = eZNewsletterTemplateWrapper::templateInit();
     $tpl->setVariable('userData', eZUserSubscriptionData::fetch($this->attribute('email')));
     $tpl->setVariable('hostname', $hostname);
     $tpl->setVariable('subscription', $this);
     $tpl->setVariable('subscriptionList', $this->attribute('subscription_list'));
     $templateResult = $tpl->fetch($template);
     if ($tpl->hasVariable('subject')) {
         $subject = $tpl->variable('subject');
     }
     $mail = new eZMail();
     $mail->setSender($ini->variable('MailSettings', 'EmailSender'), $ini->variable('SiteSettings', 'SiteName'));
     $mail->setReceiver($this->attribute('email'));
     $mail->setBody($templateResult);
     $mail->setSubject($subject);
     eZMailTransport::send($mail);
 }
 /**
  * Invoca il template per il form di attributo
  *
  * @see SearchFormOperator::modify
  * @param OCClassSearchFormHelper $instance
  * @param OCClassSearchFormAttributeField $field
  *
  * @return array|null|string
  */
 public static function displayAttribute(OCClassSearchFormHelper $instance, OCClassSearchFormAttributeField $field)
 {
     $keyArray = array(array('class', $instance->getContentClass()->attribute('id')), array('class_identifier', $instance->getContentClass()->attribute('identifier')), array('class_group', $instance->getContentClass()->attribute('match_ingroup_id_list')), array('attribute', $field->contentClassAttribute->attribute('id')), array('attribute_identifier', $field->contentClassAttribute->attribute('identifier')));
     $tpl = eZTemplate::factory();
     $tpl->setVariable('class', $instance->getContentClass());
     $tpl->setVariable('attribute', $field->contentClassAttribute);
     $res = eZTemplateDesignResource::instance();
     $res->setKeys($keyArray);
     $templateName = $field->contentClassAttribute->attribute('data_type_string');
     return $tpl->fetch('design:class_search_form/datatypes/' . $templateName . '.tpl');
 }
Exemplo n.º 3
0
function contentPDFGenerate($cacheFile, $node, $object = false, $viewCacheEnabled = true, $languageCode = false, $viewParameters = array())
{
    if ($languageCode) {
        $node->setCurrentLanguage($languageCode);
    }
    if ($object == false) {
        $object = $node->attribute('object');
    }
    $res = eZTemplateDesignResource::instance();
    $res->setKeys(array(array('object', $node->attribute('contentobject_id')), array('remote_id', $object->attribute('remote_id')), array('node_remote_id', $node->attribute('remote_id')), array('section', $object->attribute('section_id')), array('node', $node->attribute('node_id')), array('parent_node', $node->attribute('parent_node_id')), array('class', $object->attribute('contentclass_id')), array('depth', $node->attribute('depth')), array('url_alias', $node->attribute('url_alias')), array('class_group', $object->attribute('match_ingroup_id_list')), array('class_identifier', $object->attribute('class_identifier'))));
    $tpl = eZTemplate::factory();
    $tpl->setVariable('view_parameters', $viewParameters);
    $tpl->setVariable('node', $node);
    $tpl->setVariable('generate_toc', 0);
    $tpl->setVariable('tree_traverse', 0);
    $tpl->setVariable('class_array', 0);
    $tpl->setVariable('show_frontpage', 0);
    if ($viewCacheEnabled) {
        $tpl->setVariable('generate_file', 1);
        $tpl->setVariable('filename', $cacheFile);
    } else {
        $tpl->setVariable('generate_file', 0);
        $tpl->setVariable('generate_stream', 1);
    }
    $textElements = array();
    $uri = 'design:node/view/pdf.tpl';
    $tpl->setVariable('pdf_root_template', 1);
    eZTemplateIncludeFunction::handleInclude($textElements, $uri, $tpl, '', '');
    $pdf_definition = implode('', $textElements);
    $pdf_definition = str_replace(array(' ', "\r\n", "\t", "\n"), '', $pdf_definition);
    $tpl->setVariable('pdf_definition', $pdf_definition);
    $uri = 'design:node/view/execute_pdf.tpl';
    $textElements = '';
    eZTemplateIncludeFunction::handleInclude($textElements, $uri, $tpl, '', '');
}
Exemplo n.º 4
0
function generatePDF($pdfExport, $toFile = false)
{
    if ($pdfExport == null) {
        return;
    }
    $node = $pdfExport->attribute('source_node');
    if ($node) {
        $object = $node->attribute('object');
        $tpl = eZTemplate::factory();
        $tpl->setVariable('node', $node);
        $tpl->setVariable('generate_toc', 1);
        $tpl->setVariable('tree_traverse', $pdfExport->attribute('export_structure') == 'tree' ? 1 : 0);
        $tpl->setVariable('class_array', explode(':', $pdfExport->attribute('export_classes')));
        $tpl->setVariable('show_frontpage', $pdfExport->attribute('show_frontpage'));
        if ($pdfExport->attribute('show_frontpage') == 1) {
            $tpl->setVariable('intro_text', $pdfExport->attribute('intro_text'));
            $tpl->setVariable('sub_intro_text', $pdfExport->attribute('sub_text'));
        }
        if ($toFile === false) {
            $tpl->setVariable('generate_stream', 1);
        } else {
            $tpl->setVariable('generate_file', 1);
            $tpl->setVariable('filename', $toFile);
        }
        $res = eZTemplateDesignResource::instance();
        $res->setKeys(array(array('object', $object->attribute('id')), array('node', $node->attribute('node_id')), array('parent_node', $node->attribute('parent_node_id')), array('class', $object->attribute('contentclass_id')), array('class_identifier', $object->attribute('class_identifier')), array('depth', $node->attribute('depth')), array('url_alias', $node->attribute('url_alias'))));
        $textElements = array();
        $uri = 'design:node/view/pdf.tpl';
        $tpl->setVariable('pdf_root_template', 1);
        eZTemplateIncludeFunction::handleInclude($textElements, $uri, $tpl, '', '');
        $pdf_definition = implode('', $textElements);
        $pdf_definition = str_replace(array(' ', "\r\n", "\t", "\n"), '', $pdf_definition);
        $tpl->setVariable('pdf_definition', $pdf_definition);
        $uri = 'design:node/view/execute_pdf.tpl';
        $textElements = '';
        eZTemplateIncludeFunction::handleInclude($textElements, $uri, $tpl, '', '');
    }
}
Exemplo n.º 5
0
    static function restore( $siteDesign, $nodeID, $viewMode, $language, $offset, $roleList, $discountList, $layout,
                      $parameters = array() )
    {
        $result = array();
        $cachePathInfo = eZContentCache::cachePathInfo( $siteDesign, $nodeID, $viewMode, $language, $offset, $roleList, $discountList,
                                                        $layout, false, $parameters );
        $cacheDir = $cachePathInfo['dir'];
        $cacheFile = $cachePathInfo['file'];
        $cachePath = $cachePathInfo['path'];
        $timestamp = false;

        $cacheFile = eZClusterFileHandler::instance( $cachePath );

        if ( $cacheFile->exists() )
        {
            $timestamp = $cacheFile->mtime();
            if ( eZContentObject::isCacheExpired( $timestamp ) )
            {
                eZDebugSetting::writeDebug( 'kernel-content-view-cache', 'cache expired #2' );
                return false;
            }
            eZDebugSetting::writeDebug( 'kernel-content-view-cache', "checking viewmode '$viewMode' #1" );
            if ( eZContentObject::isComplexViewModeCacheExpired( $viewMode, $timestamp ) )
            {
                eZDebugSetting::writeDebug( 'kernel-content-view-cache', "viewmode '$viewMode' cache expired #2" );
                return false;
            }

        }

        if ( $viewMode == 'pdf' )
        {
            return $cachePath;
        }

        eZDebugSetting::writeDebug( 'kernel-content-view-cache', 'cache used #2' );

        $fileName = $cacheDir . "/" . $cacheFile;

        $cacheFile = eZClusterFileHandler::instance( $fileName );
        $contents = $cacheFile->fetchContents();

        $cachedArray = unserialize( $contents );

        $cacheTTL = $cachedArray['cache_ttl'];

        // Check if cache has expired
        if ( $cacheTTL > 0 )
        {
            $expiryTime = $timestamp + $cacheTTL;
            if ( time() > $expiryTime )
            {
                return false;
            }
        }

        // Check for template language timestamp
        $cacheCodeDate = $cachedArray['cache_code_date'];
        if ( $cacheCodeDate != self::CODE_DATE )
            return false;

        $viewMode = $cachedArray['content_info']['viewmode'];

        $res = eZTemplateDesignResource::instance();
        $res->setKeys( array( array( 'node', $nodeID ),
                              array( 'view_offset', $offset ),
                              array( 'viewmode', $viewMode ),
                              array( 'section', $cachedArray['section_id'] )
                              ) );
        $result['content_info'] = $cachedArray['content_info'];
        $result['content'] = $cachedArray['content'];

        $result['view_parameters'] = $cachedArray['content_info']['view_parameters'];

        foreach ( array( 'path', 'node_id', 'section_id', 'navigation_part' ) as $item )
        {
            if ( isset( $cachedArray[$item] ) )
            {
                $result[$item] = $cachedArray[$item];
            }
        }

        return $result;
    }
 function &outputText()
 {
     if (!$this->XMLData) {
         $output = '';
         return $output;
     }
     $this->Tpl = eZTemplate::factory();
     $this->Res = eZTemplateDesignResource::instance();
     if ($this->ContentObjectAttribute) {
         $this->Res->setKeys(array(array('attribute_identifier', $this->ContentObjectAttribute->attribute('contentclass_attribute_identifier'))));
     }
     $this->Document = new DOMDocument('1.0', 'utf-8');
     $success = $this->Document->loadXML($this->XMLData);
     if (!$success) {
         $this->Output = '';
         return $this->Output;
     }
     $this->prefetch();
     $this->XMLSchema = eZXMLSchema::instance();
     // Add missing elements to the OutputTags array
     foreach ($this->XMLSchema->availableElements() as $element) {
         if (!isset($this->OutputTags[$element])) {
             $this->OutputTags[$element] = array();
         }
     }
     $this->NestingLevel = 0;
     $params = array();
     $output = $this->outputTag($this->Document->documentElement, $params);
     $this->Output = $output[1];
     unset($this->Document);
     $this->Res->removeKey('attribute_identifier');
     return $this->Output;
 }
Exemplo n.º 7
0
    function checkContentActions( $module, $class, $object, $version, $contentObjectAttributes, $EditVersion, $EditLanguage, $FromLanguage, &$Result )
    {
        if ( $module->isCurrentAction( 'Preview' ) )
        {
            $module->redirectToView( 'versionview', array( $object->attribute('id'), $EditVersion, $EditLanguage, $FromLanguage ) );
            return eZModule::HOOK_STATUS_CANCEL_RUN;
        }

        if ( $module->isCurrentAction( 'Translate' ) )
        {
            $module->redirectToView( 'translate', array( $object->attribute( 'id' ), $EditVersion, $EditLanguage, $FromLanguage ) );
            return eZModule::HOOK_STATUS_CANCEL_RUN;
        }

        if ( $module->isCurrentAction( 'VersionEdit' ) )
        {
            if ( isset( $GLOBALS['eZRequestedURI'] ) and is_object( $GLOBALS['eZRequestedURI'] ) )
            {
                $uri = $GLOBALS['eZRequestedURI'];
                $uri = $uri->originalURIString();
                $http = eZHTTPTool::instance();
                $http->setSessionVariable( 'LastAccessesVersionURI', $uri );
            }
            $module->redirectToView( 'history', array( $object->attribute( 'id' ), $EditVersion, $EditLanguage ) );
            return eZModule::HOOK_STATUS_CANCEL_RUN;
        }

        if ( $module->isCurrentAction( 'EditLanguage' ) )
        {
            if ( $module->hasActionParameter( 'SelectedLanguage' ) )
            {
                $EditLanguage = $module->actionParameter( 'SelectedLanguage' );
                // We reset the from language to disable the translation look
                $FromLanguage = false;
                $module->redirectToView( 'edit', array( $object->attribute('id'), $EditVersion, $EditLanguage, $FromLanguage ) );
                return eZModule::HOOK_STATUS_CANCEL_RUN;
            }
        }

        if ( $module->isCurrentAction( 'TranslateLanguage' ) )
        {
            if ( $module->hasActionParameter( 'SelectedLanguage' ) )
            {
                $FromLanguage = $EditLanguage;
                $EditLanguage = $module->actionParameter( 'SelectedLanguage' );
                $module->redirectToView( 'edit', array( $object->attribute('id'), $EditVersion, $EditLanguage, $FromLanguage ) );
                return eZModule::HOOK_STATUS_CANCEL_RUN;
            }
        }

        if ( $module->isCurrentAction( 'FromLanguage' ) )
        {
            $FromLanguage = $module->actionParameter( 'FromLanguage' );
            $module->redirectToView( 'edit', array( $object->attribute('id'), $EditVersion, $EditLanguage, $FromLanguage ) );
            return eZModule::HOOK_STATUS_CANCEL_RUN;
        }

        if ( $module->isCurrentAction( 'Discard' ) )
        {
            $http = eZHTTPTool::instance();
            $objectID = $object->attribute( 'id' );
            $discardConfirm = true;
            if ( $http->hasPostVariable( 'DiscardConfirm' ) )
                $discardConfirm = $http->postVariable( 'DiscardConfirm' );
            $http->setSessionVariable( 'DiscardObjectID', $objectID );
            $http->setSessionVariable( 'DiscardObjectVersion', $EditVersion );
            $http->setSessionVariable( 'DiscardObjectLanguage', $EditLanguage );
            $http->setSessionVariable( 'DiscardConfirm', $discardConfirm );
            $module->redirectTo( $module->functionURI( 'removeeditversion' ) . '/' );
            return eZModule::HOOK_STATUS_CANCEL_RUN;
        }

        // helper function which computes the redirect after
        // publishing and final store of a draft.
        function computeRedirect( $module, $object, $version, $EditLanguage = false )
        {
            $http = eZHTTPTool::instance();

            $node = $object->mainNode();

            if ( $http->hasSessionVariable( 'RedirectIfDiscarded' ) )
            {
                $http->removeSessionVariable( 'RedirectIfDiscarded' );
            }

            $hasRedirected = false;
            if ( $http->hasSessionVariable( 'ParentObject' ) && $http->sessionVariable( 'NewObjectID' ) == $object->attribute( 'id' ) )
            {
                $parentArray = $http->sessionVariable( 'ParentObject' );
                $parentURL = $module->redirectionURI( 'content', 'edit', $parentArray );
                $parentObject = eZContentObject::fetch( $parentArray[0] );
                $db = eZDB::instance();
                $db->begin();
                $parentObject->addContentObjectRelation( $object->attribute( 'id' ), $parentArray[1] );
                $db->commit();
                $http->removeSessionVariable( 'ParentObject' );
                $http->removeSessionVariable( 'NewObjectID' );
                $module->redirectTo( $parentURL );
                $hasRedirected = true;
            }
            if ( $http->hasSessionVariable( 'RedirectURIAfterPublish' ) && !$hasRedirected )
            {
                $uri = $http->sessionVariable( 'RedirectURIAfterPublish' );
                $http->removeSessionVariable( 'RedirectURIAfterPublish' );
                $module->redirectTo( $uri );
                $hasRedirected = true;
            }
            if ( $http->hasPostVariable( 'RedirectURIAfterPublish' )  && !$hasRedirected )
            {
                $uri = $http->postVariable( 'RedirectURIAfterPublish' );
                $module->redirectTo( $uri );
                $hasRedirected = true;
            }
            if ( $http->hasPostVariable( "BackToEdit" ) && $http->postVariable( "BackToEdit" ) )
            {
                $uri = $module->redirectionURI( 'content', 'edit', array( $object->attribute( 'id'), 'f', $EditLanguage ) );
                $module->redirectTo( $uri );
                eZDebug::writeDebug( $uri, "uri  " .  $object->attribute( 'id')  );
                $hasRedirected = true;
            }

            if ( !$hasRedirected )
            {
                if ( $http->hasPostVariable( 'RedirectURI' ) )
                {
                    $uri = $http->postVariable( 'RedirectURI' );
                    $module->redirectTo( $uri );
                }
                else if ( $node !== null )
                {
                    $parentNode = $node->attribute( 'parent_node_id' );
                    if ( $parentNode == 1 )
                    {
                        $parentNode = $node->attribute( 'node_id' );
                    }
                    $module->redirectToView( 'view', array( 'full', $parentNode ) );
                }
                else
                {
                    $module->redirectToView( 'view', array( 'full', $version->attribute( 'main_parent_node_id' ) ) );
                }
            }

        }

        if( $module->isCurrentAction( 'StoreExit' ) )
        {
            computeRedirect( $module, $object, $version, $EditLanguage );
            return eZModule::HOOK_STATUS_CANCEL_RUN;
        }

        if ( $module->isCurrentAction( 'Publish' ) )
        {
            // Checking the source and destination language from the url,
            // if they are the same no confirmation is needed.
            if ( $EditLanguage != $FromLanguage )
            {
                $conflictingVersions = $version->hasConflicts( $EditLanguage );
                if ( $conflictingVersions )
                {
                    $tpl = eZTemplate::factory();
                    $res = eZTemplateDesignResource::instance();
                    $res->setKeys( array( array( 'object', $object->attribute( 'id' ) ),
                                        array( 'remote_id', $object->attribute( 'remote_id' ) ),
                                        array( 'class', $class->attribute( 'id' ) ),
                                        array( 'class_identifier', $class->attribute( 'identifier' ) ),
                                        array( 'class_group', $class->attribute( 'match_ingroup_id_list' ) ) ) );

                    $tpl->setVariable( 'edit_language', $EditLanguage );
                    $tpl->setVariable( 'current_version', $version->attribute( 'version' ) );
                    $tpl->setVariable( 'object', $object );
                    $tpl->setVariable( 'draft_versions', $conflictingVersions );

                    $Result = array();
                    $Result['content'] = $tpl->fetch( 'design:content/edit_conflict.tpl' );
                    return eZModule::HOOK_STATUS_CANCEL_RUN;
                }
            }

            eZDebug::accumulatorStart( 'publish', '', 'publish' );
            $oldObjectName = $object->name();

            $behaviour = new ezpContentPublishingBehaviour();
            $behaviour->isTemporary = true;
            $behaviour->disableAsynchronousPublishing = false;
            ezpContentPublishingBehaviour::setBehaviour( $behaviour );

            $operationResult = eZOperationHandler::execute( 'content', 'publish', array( 'object_id' => $object->attribute( 'id' ),
                                                                                         'version' => $version->attribute( 'version' ) ) );
            eZDebug::accumulatorStop( 'publish' );

            if ( ( array_key_exists( 'status', $operationResult ) && $operationResult['status'] != eZModuleOperationInfo::STATUS_CONTINUE ) )
            {
                eZDebug::writeDebug( $operationResult, __FILE__ );
                switch( $operationResult['status'] )
                {
                    case eZModuleOperationInfo::STATUS_REPEAT:
                    {
                        eZContentOperationCollection::setVersionStatus( $object->attribute( 'id' ),
                            $version->attribute( 'version' ), eZContentObjectVersion::STATUS_REPEAT );
                    }
                    case eZModuleOperationInfo::STATUS_HALTED:
                    {
                        if ( isset( $operationResult['redirect_url'] ) )
                        {
                            $module->redirectTo( $operationResult['redirect_url'] );
                            return;
                        }
                        else if ( isset( $operationResult['result'] ) )
                        {
                            $result = $operationResult['result'];
                            $resultContent = false;
                            if ( is_array( $result ) )
                            {
                                if ( isset( $result['content'] ) )
                                {
                                    $resultContent = $result['content'];
                                }
                                if ( isset( $result['path'] ) )
                                {
                                    $Result['path'] = $result['path'];
                                }
                            }
                            else
                            {
                                $resultContent = $result;
                            }
                            // Temporary fix to make approval workflow work with edit.
                            if ( strpos( $resultContent, 'Deffered to cron' ) === 0 )
                            {
                                $Result = null;
                            }
                            else
                            {
                                $Result['content'] = $resultContent;
                            }
                        }
                    }break;
                    case eZModuleOperationInfo::STATUS_CANCELLED:
                    {
                        $Result = array();
                        $Result['content'] = "Content publish cancelled<br/>";
                    }
                }

                /* If we already have a correct module result
                 * we don't need to continue module execution.
                 */
                if ( is_array( $Result ) )
                    return eZModule::HOOK_STATUS_CANCEL_RUN;
            }

            // update content object attributes array by refetching them from database
            $object = eZContentObject::fetch( $object->attribute( 'id' ) );
            $contentObjectAttributes = $object->attribute( 'contentobject_attributes' );

            // set chosen hidden/invisible attributes for object nodes
            $http          = eZHTTPTool::instance();
            $assignedNodes = $object->assignedNodes( true );
            foreach ( $assignedNodes as $node )
            {
                $nodeID               = $node->attribute( 'node_id' );
                $parentNodeID         = $node->attribute( 'parent_node_id' );
                $updateNodeVisibility =  false;
                $postVarName          = "FutureNodeHiddenState_$parentNodeID";

                if ( !$http->hasPostVariable( $postVarName ) )
                    $updateNodeVisibility = true;
                else
                {
                    $futureNodeHiddenState = $http->postVariable( $postVarName );
                    $db = eZDB::instance();
                    $db->begin();
                    if ( $futureNodeHiddenState == 'hidden' )
                        eZContentObjectTreeNode::hideSubTree( $node );
                    else if ( $futureNodeHiddenState == 'visible' )
                        eZContentObjectTreeNode::unhideSubTree( $node );
                    else if ( $futureNodeHiddenState == 'unchanged' )
                        $updateNodeVisibility = true;
                    else
                        eZDebug::writeWarning( "Unknown value for the future node hidden state: '$futureNodeHiddenState'" );
                    $db->commit();
                }

                if ( $updateNodeVisibility )
                {
                    // this might be redundant
                    $db = eZDB::instance();
                    $db->begin();
                    $parentNode = eZContentObjectTreeNode::fetch( $parentNodeID );
                    eZContentObjectTreeNode::updateNodeVisibility( $node, $parentNode, /* $recursive = */ false );
                    $db->commit();
                    unset( $node, $parentNode );
                }
            }
            unset( $assignedNodes );

            $object = eZContentObject::fetch( $object->attribute( 'id' ) );

            $newObjectName = $object->name();

            $http = eZHTTPTool::instance();

            computeRedirect( $module, $object, $version, $EditLanguage );
            // we have set redirection URI for module so we don't need to continue module execution
            return eZModule::HOOK_STATUS_CANCEL_RUN;
        }
    }
Exemplo n.º 8
0
include_once "kernel/setup/ezsetuptests.php";
include_once 'kernel/setup/ezsetup_summary.php';
// Initialize template
$tpl = eZTemplate::instance();
//$tpl->registerFunction( "section", new eZTemplateSectionFunction( "section" ) );
//$tpl->registerFunction( "include", new eZTemplateIncludeFunction() );
$ini = eZINI::instance();
if ($ini->variable('TemplateSettings', 'Debug') == 'enabled') {
    eZTemplate::setIsDebugEnabled(true);
}
//eZDebug::setLogOnly( true );
//$ini->setVariable( 'RegionalSettings', 'TextTranslation', 'disabled' );
$Module = $Params['Module'];
$tpl->setAutoloadPathList($ini->variable('TemplateSettings', 'AutoloadPathList'));
$tpl->autoload();
$tpl->registerResource(eZTemplateDesignResource::instance());
// Initialize HTTP variables
$http = eZHTTPTool::instance();
$baseDir = 'kernel/setup/';
// Load step list data. See this file for install step references.
$stepDataFile = $baseDir . "steps/ezstep_data.php";
$stepData = null;
if (file_exists($stepDataFile)) {
    include_once $stepDataFile;
    $stepData = new eZStepData();
}
if ($stepData == null) {
    print "<h1>Setup step data file not found. Setup is exiting...</h1>";
    //TODO : i18n translate
    eZDisplayResult($templateResult);
    eZExecution::cleanExit();
 /**
  * @return string
  */
 protected function getForm()
 {
     $classKeyArray = array(array('class', $this->contentClass->attribute('id')), array('class_identifier', $this->contentClass->attribute('identifier')), array('class_group', $this->contentClass->attribute('match_ingroup_id_list')));
     $tpl = eZTemplate::factory();
     $tpl->setVariable('class', $this->contentClass);
     $tpl->setVariable('remote_class_id', $this->remoteContentClassDefinition->ID);
     $tpl->setVariable('client', $this);
     $attributeFields = array();
     $dataMap = $this->contentClass->attribute('data_map');
     $disabled = array();
     if (eZINI::instance('ocsearchtools.ini')->hasVariable('RemoteClassSearchFormSettings', 'DisabledAttributes')) {
         $disabled = eZINI::instance('ocsearchtools.ini')->variable('RemoteClassSearchFormSettings', 'DisabledAttributes');
     }
     /** @var $dataMap eZContentClassAttribute[] */
     foreach ($dataMap as $attribute) {
         if (!in_array($this->contentClass->attribute('identifier') . '/' . $attribute->attribute('identifier'), $disabled) && $attribute->attribute('is_searchable')) {
             if (isset($this->remoteContentClassDefinition->DataMap[0]->{$attribute->attribute('identifier')})) {
                 $inputField = OCRemoteClassSearchFormAttributeField::instance($attribute, $this->remoteContentClassDefinition->DataMap[0]->{$attribute->attribute('identifier')}, $this);
                 $keyArray = array(array('class', $this->contentClass->attribute('id')), array('class_identifier', $this->contentClass->attribute('identifier')), array('class_group', $this->contentClass->attribute('match_ingroup_id_list')), array('attribute', $inputField->contentClassAttribute->attribute('id')), array('attribute_identifier', $inputField->contentClassAttribute->attribute('identifier')));
                 $tpl = eZTemplate::factory();
                 $tpl->setVariable('class', $this->contentClass);
                 $tpl->setVariable('attribute', $inputField->contentClassAttribute);
                 $tpl->setVariable('input', $inputField);
                 $res = eZTemplateDesignResource::instance();
                 $res->setKeys($keyArray);
                 $templateName = $inputField->contentClassAttribute->attribute('data_type_string');
                 $attributeFields[$inputField->attribute('id')] = $tpl->fetch('design:class_search_form/datatypes/' . $templateName . '.tpl');
             }
         }
     }
     $tpl->setVariable('attribute_fields', $attributeFields);
     $parameters = array('action' => 'search');
     $tpl->setVariable('parameters', $parameters);
     $formAction = $this->attributes['definition']['ClientBasePath'];
     eZURI::transformURI($formAction);
     $tpl->setVariable('form_action', $formAction);
     $res = eZTemplateDesignResource::instance();
     $res->setKeys($classKeyArray);
     return $tpl->fetch('design:repository/contentclass_client/remote_class_search_form.tpl');
 }
Exemplo n.º 10
0
function sendConfirmation($email, $subscription, $subscribe)
{
    //send mail
    $res = eZTemplateDesignResource::instance();
    $ini = eZINI::instance();
    $hostname = eZSys::hostname();
    if ($subscribe) {
        $template = 'design:eznewsletter/sendout/subscription.tpl';
    } else {
        $template = 'design:eznewsletter/sendout/unsubscription.tpl';
    }
    $tpl = eZNewsletterTemplateWrapper::templateInit();
    $tpl->setVariable('userData', eZUserSubscriptionData::fetch($email));
    $tpl->setVariable('hostname', $hostname);
    $tpl->setVariable('subscription', $subscription);
    $subscriptionList = eZSubscriptionList::fetch($subscription->attribute('subscriptionlist_id'), eZSubscriptionList::StatusPublished, true, true);
    $tpl->setVariable('subscriptionList', $subscriptionList);
    $templateResult = $tpl->fetch($template);
    if ($tpl->hasVariable('subject')) {
        $subject = $tpl->variable('subject');
    }
    $mail = new eZMail();
    $mail->setSender($ini->variable('MailSettings', 'EmailSender'));
    $mail->setReceiver($email);
    $mail->setBody($templateResult);
    $mail->setSubject($subject);
    eZMailTransport::send($mail);
}
Exemplo n.º 11
0
 /**
  *  Generate cache  key array based on current user roles, requested url, layout
  *
  * @param $userKeys Array
  * @return array
  */
 public function getCacheKeysArray($userKeys)
 {
     if (!is_array($userKeys)) {
         $userKeys = array($userKeys);
     }
     $user = eZUser::currentUser();
     $limitedAssignmentValueList = $user->limitValueList();
     $roleList = $user->roleIDList();
     $discountList = eZUserDiscountRule::fetchIDListByUserID($user->attribute('contentobject_id'));
     $currentSiteAccess = isset($GLOBALS['eZCurrentAccess']['name']) ? $GLOBALS['eZCurrentAccess']['name'] : false;
     $res = eZTemplateDesignResource::instance();
     $keys = $res->keys();
     $layout = isset($keys['layout']) ? $keys['layout'] : false;
     $uri = eZURI::instance(eZSys::requestURI());
     $actualRequestedURI = $uri->uriString();
     $userParameters = $uri->userParameters();
     $cacheKeysArray = array('spdf2png', $currentSiteAccess, $layout, $actualRequestedURI, implode('.', $userParameters), implode('.', $roleList), implode('.', $limitedAssignmentValueList), implode('.', $discountList), implode('.', $userKeys));
     return $cacheKeysArray;
 }
 /**
  * @param eZNotificationEvent $event
  * @param array $parameters
  *
  * @return int
  */
 function handlePublishEvent($event, &$parameters)
 {
     /** @var eZContentObjectVersion $versionObject */
     $versionObject = $event->attribute('content');
     if (!$versionObject) {
         return eZNotificationEventHandler::EVENT_SKIPPED;
     }
     /** @var eZContentObject $contentObject */
     $contentObject = $versionObject->attribute('contentobject');
     if (!$contentObject) {
         return eZNotificationEventHandler::EVENT_SKIPPED;
     }
     /** @var eZContentObjectTreeNode $contentNode */
     $contentNode = $contentObject->attribute('main_node');
     if (!$contentNode) {
         return eZNotificationEventHandler::EVENT_SKIPPED;
     }
     // Notification should only be sent out when the object is published (is visible)
     if ($contentNode->attribute('is_invisible') == 1) {
         return eZNotificationEventHandler::EVENT_SKIPPED;
     }
     /** @var eZContentClass $contentClass */
     $contentClass = $contentObject->attribute('content_class');
     if (!$contentClass) {
         return eZNotificationEventHandler::EVENT_SKIPPED;
     }
     if ($versionObject->attribute('version') != $contentObject->attribute('current_version')) {
         return eZNotificationEventHandler::EVENT_SKIPPED;
     }
     try {
         $post = ITNewsletterPost::instanceFromEzContentObject($contentObject);
         if (!$post instanceof ITNewsletterPost) {
             throw new Exception("Post not found");
         }
         if (!$post->isValid()) {
             throw new Exception("Post not valid");
         }
         /*
                     if ( !$post->attribute( 'is_sent' ) )
                     {
            throw new Exception( "Post not already sent" );
                     }
         * 
         */
     } catch (Exception $e) {
         return eZNotificationEventHandler::EVENT_SKIPPED;
     }
     $tpl = eZTemplate::factory();
     $tpl->resetVariables();
     /** @var eZContentObjectTreeNode $parentNode */
     $parentNode = $contentNode->attribute('parent');
     if (!$parentNode instanceof eZContentObjectTreeNode) {
         eZDebug::writeError('DB corruption: Node id ' . $contentNode->attribute('node_id') . ' is missing parent node.', __METHOD__);
         return eZNotificationEventHandler::EVENT_SKIPPED;
     }
     /** @var eZContentObject $parentContentObject */
     $parentContentObject = $parentNode->attribute('object');
     if (!$parentContentObject instanceof eZContentObject) {
         eZDebug::writeError('DB corruption: Node id ' . $parentNode->attribute('node_id') . ' is missing object.', __METHOD__);
         return eZNotificationEventHandler::EVENT_SKIPPED;
     }
     /** @var eZContentClass $parentContentClass */
     $parentContentClass = $parentContentObject->attribute('content_class');
     if (!$parentContentClass instanceof eZContentClass) {
         eZDebug::writeError('DB corruption: Object id ' . $parentContentObject->attribute('id') . ' is missing class object.', __METHOD__);
         return eZNotificationEventHandler::EVENT_SKIPPED;
     }
     $res = eZTemplateDesignResource::instance();
     $res->setKeys(array(array('object', $contentObject->attribute('id')), array('node', $contentNode->attribute('node_id')), array('class', $contentObject->attribute('contentclass_id')), array('class_identifier', $contentClass->attribute('identifier')), array('parent_node', $contentNode->attribute('parent_node_id')), array('parent_class', $parentContentObject->attribute('contentclass_id')), array('parent_class_identifier', $parentContentClass != null ? $parentContentClass->attribute('identifier') : 0), array('depth', $contentNode->attribute('depth')), array('url_alias', $contentNode->attribute('url_alias'))));
     $tpl->setVariable('object', $contentObject);
     $notificationINI = eZINI::instance('notification.ini');
     $emailSender = $notificationINI->variable('MailSettings', 'EmailSender');
     $ini = eZINI::instance();
     if (!$emailSender) {
         $emailSender = $ini->variable('MailSettings', 'EmailSender');
     }
     if (!$emailSender) {
         $emailSender = $ini->variable("MailSettings", "AdminEmail");
     }
     $tpl->setVariable('sender', $emailSender);
     $result = $tpl->fetch('design:notification/handler/templatepat/view/plain.tpl');
     $subject = $tpl->variable('subject');
     if ($tpl->hasVariable('message_id')) {
         $parameters['message_id'] = $tpl->variable('message_id');
     }
     if ($tpl->hasVariable('references')) {
         $parameters['references'] = $tpl->variable('references');
     }
     if ($tpl->hasVariable('reply_to')) {
         $parameters['reply_to'] = $tpl->variable('reply_to');
     }
     if ($tpl->hasVariable('from')) {
         $parameters['from'] = $tpl->variable('from');
     }
     if ($tpl->hasVariable('content_type')) {
         $parameters['content_type'] = $tpl->variable('content_type');
     }
     $collection = eZNotificationCollection::create($event->attribute('id'), self::NOTIFICATION_HANDLER_ID, self::TRANSPORT);
     $collection->setAttribute('data_subject', $subject);
     $collection->setAttribute('data_text', $result);
     $collection->store();
     $tags = $post->notificationTags();
     $userList = ITNewsletterNotificationRule::fetchUserList($tags);
     $locale = eZLocale::instance();
     $weekDayNames = $locale->attribute('weekday_name_list');
     $weekDaysByName = array_flip($weekDayNames);
     foreach ($userList as $user) {
         $item = $collection->addItem($user->attribute('email'));
         // digest forzato
         eZNotificationSchedule::setDateForItem($item, array('frequency' => 'day', 'hour' => '12'));
         $item->store();
         ///** @var eZGeneralDigestUserSettings $settings */
         //$settings = eZGeneralDigestUserSettings::fetchForUser( $user->attribute( 'email' ) );
         //if ( $settings !== null && $settings->attribute( 'receive_digest' ) == 1 )
         //{
         //    $time = $settings->attribute( 'time' );
         //    $timeArray = explode( ':', $time );
         //    $hour = $timeArray[0];
         //
         //    if ( $settings->attribute( 'digest_type' ) == eZGeneralDigestUserSettings::TYPE_DAILY )
         //    {
         //        eZNotificationSchedule::setDateForItem( $item, array( 'frequency' => 'day',
         //                                                              'hour' => $hour ) );
         //    }
         //    else if ( $settings->attribute( 'digest_type' ) == eZGeneralDigestUserSettings::TYPE_WEEKLY )
         //    {
         //        $weekday = $weekDaysByName[ $settings->attribute( 'day' ) ];
         //        eZNotificationSchedule::setDateForItem( $item, array( 'frequency' => 'week',
         //                                                              'day' => $weekday,
         //                                                              'hour' => $hour ) );
         //    }
         //    else if ( $settings->attribute( 'digest_type' ) == eZGeneralDigestUserSettings::TYPE_MONTHLY )
         //    {
         //        eZNotificationSchedule::setDateForItem( $item,
         //            array( 'frequency' => 'month',
         //                   'day' => $settings->attribute( 'day' ),
         //                   'hour' => $hour ) );
         //    }
         //    $item->store();
         //}
     }
     return eZNotificationEventHandler::EVENT_HANDLED;
 }
Exemplo n.º 13
0
 function generateNewsletter($contentObject)
 {
     // 1. Set resource keys
     $res = eZTemplateDesignResource::instance();
     $res->setKeys(array(array('newslettertype_id', $this->attribute('newslettertype_id')), array('newsletter_id', $this->attribute('id')), array('class_identifier', ''), array('newsletter_type', 'mail')));
     // 2. Set general mail and template properties
     $ini = eZINI::instance();
     $hostname = eZSys::hostname();
     $newsletterType = $this->attribute('newsletter_type');
     // 3. get skin for newsletter
     if ($this->attribute('design_to_use')) {
         $skin_prefix = $this->attribute('design_to_use');
     } else {
         $skin_prefix = 'eznewsletter';
     }
     $mail = new ezpMailComposer();
     $mail->charset = 'utf-8';
     $tpl = eZTemplate::factory();
     $tpl->setVariable('hostname', $hostname);
     $tpl->setVariable('contentobject', $contentObject);
     $tpl->setVariable('newsletter', $this);
     $tpl->setVariable('SkipMIMEPart', false);
     $mail->plainText = $tpl->fetch('design:' . $skin_prefix . '/sendout/text.tpl');
     $mail->plainText = rtrim(preg_replace('/(\\r\\n|\\r|\\n)/', "\r\n", $mail->plainText));
     if ($tpl->hasVariable('SkipMIMEPart') && $tpl->variable('SkipMIMEPart') === true) {
         $mail->plainText = null;
     }
     $tpl->setVariable('SkipMIMEPart', false);
     $mail->htmlText = $tpl->fetch('design:' . $skin_prefix . '/sendout/html.tpl');
     $mail->htmlText = rtrim(preg_replace('/(\\r\\n|\\r|\\n)/', "\r\n", $mail->htmlText));
     if ($tpl->hasVariable('SkipMIMEPart') && $tpl->variable('SkipMIMEPart') === true) {
         $mail->htmlText = null;
     }
     if ($tpl->hasVariable('attachments')) {
         foreach ($tpl->hasVariable('attachments') as $attachment) {
             $mail->addFileAttachment($attachment);
         }
     }
     $emailSender = $newsletterType->attribute('sender_address') ? $newsletterType->attribute('sender_address') : $ini->variable('MailSettings', 'EmailSender');
     if ($tpl->hasVariable('emailSenderName')) {
         $mail->from = new ezcMailAddress($emailSender, $tpl->variable('emailSenderName'), 'utf-8');
     } else {
         $mail->from = new ezcMailAddress($emailSender, null, 'utf-8');
     }
     $subject = $this->attribute('name');
     if ($tpl->hasVariable('subject')) {
         $subject = $tpl->variable('subject');
     }
     $mail->subject = $subject;
     $mail->subjectCharset = 'utf-8';
     if (preg_match_all('/(<img)\\s (src="\\/([a-zA-Z0-9-\\.;:!\\/\\?&=_|\\r|\\n]{1,})")/isxmU', $mail->htmlText, $patterns)) {
         foreach ($patterns[3] as $key => $file) {
             if (file_exists($file) and !is_dir($file)) {
                 $mail->htmlText = preg_replace("/" . preg_quote($patterns[0][$key], '/') . "/", $patterns[1][$key] . ' src="file://' . str_replace("\\", "/", eZSys::rootDir()) . '/' . $file . "\"", $mail->htmlText);
             }
         }
     }
     //setting the reply-to head from site.ini
     if ($ini->variable('MailSettings', 'EmailReplyTo') != "") {
         $mail->setHeader('Reply-To', $ini->variable('MailSettings', 'EmailReplyTo'));
     }
     return $mail;
 }
Exemplo n.º 14
0
 function handlePublishEvent($event, &$parameters)
 {
     $versionObject = $event->attribute('content');
     if (!$versionObject) {
         return eZNotificationEventHandler::EVENT_SKIPPED;
     }
     $contentObject = $versionObject->attribute('contentobject');
     if (!$contentObject) {
         return eZNotificationEventHandler::EVENT_SKIPPED;
     }
     $contentNode = $contentObject->attribute('main_node');
     if (!$contentNode) {
         return eZNotificationEventHandler::EVENT_SKIPPED;
     }
     // Notification should only be sent out when the object is published (is visible)
     if ($contentNode->attribute('is_invisible') == 1) {
         return eZNotificationEventHandler::EVENT_SKIPPED;
     }
     $contentClass = $contentObject->attribute('content_class');
     if (!$contentClass) {
         return eZNotificationEventHandler::EVENT_SKIPPED;
     }
     if ($versionObject->attribute('version') != $contentObject->attribute('current_version')) {
         return eZNotificationEventHandler::EVENT_SKIPPED;
     }
     $tpl = eZTemplate::factory();
     $tpl->resetVariables();
     $parentNode = $contentNode->attribute('parent');
     if (!$parentNode instanceof eZContentObjectTreeNode) {
         eZDebug::writeError('DB corruption: Node id ' . $contentNode->attribute('node_id') . ' is missing parent node.', __METHOD__);
         return eZNotificationEventHandler::EVENT_SKIPPED;
     }
     $parentContentObject = $parentNode->attribute('object');
     if (!$parentContentObject instanceof eZContentObject) {
         eZDebug::writeError('DB corruption: Node id ' . $parentNode->attribute('node_id') . ' is missing object.', __METHOD__);
         return eZNotificationEventHandler::EVENT_SKIPPED;
     }
     $parentContentClass = $parentContentObject->attribute('content_class');
     if (!$parentContentClass instanceof eZContentClass) {
         eZDebug::writeError('DB corruption: Object id ' . $parentContentObject->attribute('id') . ' is missing class object.', __METHOD__);
         return eZNotificationEventHandler::EVENT_SKIPPED;
     }
     $res = eZTemplateDesignResource::instance();
     $res->setKeys(array(array('object', $contentObject->attribute('id')), array('node', $contentNode->attribute('node_id')), array('class', $contentObject->attribute('contentclass_id')), array('class_identifier', $contentClass->attribute('identifier')), array('parent_node', $contentNode->attribute('parent_node_id')), array('parent_class', $parentContentObject->attribute('contentclass_id')), array('parent_class_identifier', $parentContentClass != null ? $parentContentClass->attribute('identifier') : 0), array('depth', $contentNode->attribute('depth')), array('url_alias', $contentNode->attribute('url_alias'))));
     $tpl->setVariable('object', $contentObject);
     $notificationINI = eZINI::instance('notification.ini');
     $emailSender = $notificationINI->variable('MailSettings', 'EmailSender');
     $ini = eZINI::instance();
     if (!$emailSender) {
         $emailSender = $ini->variable('MailSettings', 'EmailSender');
     }
     if (!$emailSender) {
         $emailSender = $ini->variable("MailSettings", "AdminEmail");
     }
     $tpl->setVariable('sender', $emailSender);
     $result = $tpl->fetch('design:notification/handler/ezsubtree/view/plain.tpl');
     $subject = $tpl->variable('subject');
     if ($tpl->hasVariable('message_id')) {
         $parameters['message_id'] = $tpl->variable('message_id');
     }
     if ($tpl->hasVariable('references')) {
         $parameters['references'] = $tpl->variable('references');
     }
     if ($tpl->hasVariable('reply_to')) {
         $parameters['reply_to'] = $tpl->variable('reply_to');
     }
     if ($tpl->hasVariable('from')) {
         $parameters['from'] = $tpl->variable('from');
     }
     if ($tpl->hasVariable('content_type')) {
         $parameters['content_type'] = $tpl->variable('content_type');
     }
     $collection = eZNotificationCollection::create($event->attribute('id'), self::NOTIFICATION_HANDLER_ID, self::TRANSPORT);
     $collection->setAttribute('data_subject', $subject);
     $collection->setAttribute('data_text', $result);
     $collection->store();
     $assignedNodes = $contentObject->parentNodes(true);
     $nodeIDList = array();
     foreach ($assignedNodes as $node) {
         if ($node) {
             $pathString = $node->attribute('path_string');
             $pathString = ltrim(rtrim($pathString, '/'), '/');
             $nodeIDListPart = explode('/', $pathString);
             $nodeIDList = array_merge($nodeIDList, $nodeIDListPart);
         }
     }
     $nodeIDList[] = $contentNode->attribute('node_id');
     $nodeIDList = array_unique($nodeIDList);
     $userList = eZSubtreeNotificationRule::fetchUserList($nodeIDList, $contentObject);
     $locale = eZLocale::instance();
     $weekDayNames = $locale->attribute('weekday_name_list');
     $weekDaysByName = array_flip($weekDayNames);
     foreach ($userList as $subscriber) {
         $item = $collection->addItem($subscriber['address']);
         if ($subscriber['use_digest'] == 0) {
             $settings = eZGeneralDigestUserSettings::fetchByUserId($subscriber['user_id']);
             if ($settings !== null && $settings->attribute('receive_digest') == 1) {
                 $time = $settings->attribute('time');
                 $timeArray = explode(':', $time);
                 $hour = $timeArray[0];
                 if ($settings->attribute('digest_type') == eZGeneralDigestUserSettings::TYPE_DAILY) {
                     eZNotificationSchedule::setDateForItem($item, array('frequency' => 'day', 'hour' => $hour));
                 } else {
                     if ($settings->attribute('digest_type') == eZGeneralDigestUserSettings::TYPE_WEEKLY) {
                         $weekday = $weekDaysByName[$settings->attribute('day')];
                         eZNotificationSchedule::setDateForItem($item, array('frequency' => 'week', 'day' => $weekday, 'hour' => $hour));
                     } else {
                         if ($settings->attribute('digest_type') == eZGeneralDigestUserSettings::TYPE_MONTHLY) {
                             eZNotificationSchedule::setDateForItem($item, array('frequency' => 'month', 'day' => $settings->attribute('day'), 'hour' => $hour));
                         }
                     }
                 }
                 $item->store();
             }
         }
     }
     return eZNotificationEventHandler::EVENT_HANDLED;
 }
Exemplo n.º 15
0
 /**
  * This function is only a helpfunction
  *
  * @param $mailTemplate
  * @return unknown_type
  */
 function sendSubcriptionMail($mailTemplate)
 {
     $tplResource = eZTemplateDesignResource::instance();
     $ini = eZINI::instance('site.ini');
     $cjwNewsletterIni = eZINI::instance('cjw_newsletter.ini');
     $hostName = eZSys::hostname();
     // $template = 'design:newsletter/mail/subscription_confirmation.tpl';
     $template = $mailTemplate;
     $newsletterUser = $this;
     include_once 'kernel/common/template.php';
     $tpl = templateInit();
     $tpl->setVariable('newsletter_user', $newsletterUser);
     $tpl->setVariable('hostname', $hostName);
     $templateResult = $tpl->fetch($template);
     // get subject from template var definition
     if ($tpl->hasVariable('subject')) {
         $subject = $tpl->variable('subject');
     }
     $emailSender = $cjwNewsletterIni->variable('NewsletterMailSettings', 'EmailSender');
     $emailSenderName = $cjwNewsletterIni->variable('NewsletterMailSettings', 'EmailSenderName');
     $emailReceiver = $newsletterUser->attribute('email');
     $emailReplyTo = $cjwNewsletterIni->variable('NewsletterMailSettings', 'EmailReplyTo');
     $emailReturnPath = $cjwNewsletterIni->variable('NewsletterMailSettings', 'EmailReturnPath');
     // TODO Namen extrahieren
     $emailReceiverName = '';
     $emailSubject = $subject;
     $emailBody['text'] = $templateResult;
     $cjwMail = new CjwNewsletterMail();
     // x header set for current user
     $cjwMail->setExtraMailHeadersByNewsletterUser($this);
     $cjwMail->setTransportMethodDirectlyFromIni();
     // trigger_error("test error", E_USER_ERROR);
     $sendResult = $cjwMail->sendEmail($emailSender, $emailSenderName, $emailReceiver, $emailReceiverName, $emailSubject, $emailBody, false, 'utf-8', $emailReplyTo, $emailReturnPath);
     return $sendResult;
 }
Exemplo n.º 16
0
 /**
  * Retrieve content view data
  *
  * @see contentViewGenerate()
  *
  * @param string $file
  * @param int $mtime File modification time
  * @param array $args Hash containing arguments, the used ones are:
  *  - ini
  *
  * @return \eZClusterFileFailure
  */
 public static function contentViewRetrieve($file, $mtime, $args)
 {
     extract($args);
     $cacheExpired = false;
     // Read Cache file
     if (!eZContentObject::isCacheExpired($mtime)) {
         //        $contents = $cacheFile->fetchContents();
         $contents = file_get_contents($file);
         $Result = unserialize($contents);
         if (!is_array($Result)) {
             $expiryReason = 'Unexpected cache file content';
             $cacheExpired = true;
         }
         // Check if a no_cache key has been set in the viewcache, and
         // return an eZClusterFileFailure if it has
         if (isset($Result['no_cache'])) {
             return new eZClusterFileFailure(3, "Cache has been disabled for this node");
         }
         // Check if cache has expired when cache_ttl is set
         $cacheTTL = isset($Result['cache_ttl']) ? $Result['cache_ttl'] : -1;
         if ($cacheTTL > 0) {
             $expiryTime = $mtime + $cacheTTL;
             if (time() > $expiryTime) {
                 $cacheExpired = true;
                 $expiryReason = 'Content cache is expired by cache_ttl=' . $cacheTTL;
             }
         }
         // Check if template source files are newer, but only if the cache is not expired
         if (!$cacheExpired) {
             $developmentModeEnabled = $ini->variable('TemplateSettings', 'DevelopmentMode') == 'enabled';
             // Only do filemtime checking when development mode is enabled.
             if ($developmentModeEnabled && isset($Result['template_list'])) {
                 foreach ($Result['template_list'] as $templateFile) {
                     if (!file_exists($templateFile)) {
                         $cacheExpired = true;
                         $expiryReason = "Content cache is expired by template file '" . $templateFile . "', it does not exist anymore";
                         break;
                     } else {
                         if (filemtime($templateFile) > $mtime) {
                             $cacheExpired = true;
                             $expiryReason = "Content cache is expired by template file '" . $templateFile . "'";
                             break;
                         }
                     }
                 }
             }
         }
         if (!$cacheExpired) {
             if (!isset($Result['content_info'])) {
                 // set error type & number for kernel errors (see https://jira.ez.no/browse/EZP-23046)
                 if (isset($Result['errorType']) && isset($Result['errorNumber'])) {
                     $res = eZTemplateDesignResource::instance();
                     $res->setKeys(array(array('error_type', $Result['errorType']), array('error_number', $Result['errorNumber'])));
                 }
                 return $Result;
             }
             $keyArray = array(array('object', $Result['content_info']['object_id']), array('node', $Result['content_info']['node_id']), array('parent_node', $Result['content_info']['parent_node_id']), array('parent_node_remote_id', $Result['content_info']['parent_node_remote_id']), array('parent_object_remote_id', $Result['content_info']['parent_object_remote_id']), array('class', $Result['content_info']['class_id']), array('view_offset', $Result['content_info']['offset']), array('navigation_part_identifier', $Result['content_info']['navigation_part_identifier']), array('viewmode', $Result['content_info']['viewmode']), array('depth', $Result['content_info']['node_depth']), array('remote_id', $Result['content_info']['remote_id']), array('node_remote_id', $Result['content_info']['node_remote_id']), array('url_alias', $Result['content_info']['url_alias']), array('persistent_variable', $Result['content_info']['persistent_variable']), array('class_group', $Result['content_info']['class_group']), array('parent_class_id', $Result['content_info']['parent_class_id']), array('parent_class_identifier', $Result['content_info']['parent_class_identifier']), array('state', $Result['content_info']['state']), array('state_identifier', $Result['content_info']['state_identifier']), array('section', $Result['section_id']));
             if (isset($Result['content_info']['class_identifier'])) {
                 $keyArray[] = array('class_identifier', $Result['content_info']['class_identifier']);
             }
             $res = eZTemplateDesignResource::instance();
             $res->setKeys($keyArray);
             return $Result;
         }
     } else {
         $expiryReason = 'Content cache is expired by eZContentObject::isCacheExpired(' . $mtime . ")";
     }
     // Cache is expired so return specialized cluster object
     if (!isset($expiryReason)) {
         $expiryReason = 'Content cache is expired';
     }
     return new eZClusterFileFailure(1, $expiryReason);
 }
Exemplo n.º 17
0
 public static function filter($module, $node, $tpl, $viewMode)
 {
     //Make it compatable with patches before 5.2 and 5.2(no patch) because a patch reverse
     //Ref.https://github.com/ezsystems/ezpublish-legacy/commit/85ab7fb8374f31c5cba00450e71d27e456552878
     if (!$module instanceof eZModule) {
         $viewMode = $tpl;
         $tpl = $node;
         $node = $module;
         $module = null;
     }
     //End of compatability fix
     $ini = eZINI::instance('override.ini');
     $conditions = $ini->groups();
     $nodeID = $node->attribute('node_id');
     $object = $node->attribute('object');
     $classIdentifier = $object->attribute('class_identifier');
     $overrideClass = null;
     foreach ($conditions as $condition) {
         if (isset($condition['Match'])) {
             $matches = $condition['Match'];
             // node condition
             $matchNode = null;
             if (isset($matches['node'])) {
                 if ($matches['node'] == $nodeID) {
                     $matchNode = true;
                 } else {
                     $matchNode = false;
                 }
             }
             // class_identifier condition
             $matchClass = null;
             if (isset($matches['class_identifier'])) {
                 if ($matches['class_identifier'] == $classIdentifier) {
                     $matchClass = true;
                 } else {
                     $matchClass = false;
                 }
             }
             // view mode condition
             $matchViewmode = null;
             if (isset($matches['viewmode'])) {
                 if ($matches['viewmode'] == $viewMode) {
                     $matchViewmode = true;
                 } else {
                     $matchViewmode = false;
                 }
             }
             $useIt = false;
             // When viewmode is not set or viewmode matches
             if (!isset($matchViewmode) || $matchViewmode === true) {
                 // When class_identifier is not set or class_identifier matches
                 if (!isset($matchClass) || $matchClass === true) {
                     // When node(id) is not set or node(id) matches
                     if (!isset($matchNode) || $matchNode === true) {
                         if (isset($condition['Class'])) {
                             $overrideClass = $condition['Class'];
                             break;
                         }
                     }
                 }
             }
         }
     }
     //Support Match[attribute_<attribute_identifier>]=<value> in override.ini
     $object = $node->attribute('object');
     $dataMap = $object->dataMap();
     $ini = eZINI::instance('xoverride.ini');
     $siteAccessesMatch = false;
     if (!$ini->hasVariable('TemplateOverride', 'AvailableSiteAccess')) {
         $siteAccessesMatch = true;
     } else {
         $siteAccesses = $ini->variable('TemplateOverride', 'AvailableSiteAccess');
         $currentSiteAccessArray = eZSiteAccess::current();
         $currentSiteAccess = $currentSiteAccessArray['name'];
         if (is_array($siteAccesses) && (in_array($currentSiteAccess, $siteAccesses) or in_array('*', $siteAccesses))) {
             $siteAccessesMatch = true;
         }
     }
     if ($siteAccessesMatch) {
         $supportedDatatype = $ini->variable('General', 'SupportedDatatype');
         $keys = array();
         foreach ($dataMap as $attributeId => $attribute) {
             $dataType = $attribute->attribute('data_type_string');
             if (in_array($dataType, $supportedDatatype)) {
                 $value = $attribute->attribute('content');
                 $keys[] = array('attribute_' . $attributeId, $value);
             }
         }
         $res = eZTemplateDesignResource::instance();
         $res->setKeys($keys);
         if (!empty($overrideClass)) {
             $overrideView = new $overrideClass();
             $http = eZHTTPTool::instance();
             eZDebug::writeNotice("Loading nodeview render {$overrideClass}, node id: {$nodeID}", __METHOD__);
             $overrideView->initNodeview($module, $node, $tpl, $viewMode);
         }
     }
 }
Exemplo n.º 18
0
    function &inputTagXML( &$tag, $currentSectionLevel, $tdSectionLevel = null )
    {
        $output       = '';
        $tagName      = $tag instanceof DOMNode ? $tag->nodeName : '';
        $childTagText = '';

        // render children tags
        if ( $tag->hasChildNodes() )
        {
            $tagChildren = $tag->childNodes;
            foreach ( $tagChildren as $childTag )
            {
                $childTagText .= $this->inputTagXML( $childTag, $currentSectionLevel, $tdSectionLevel );
            }
        }
        switch ( $tagName )
        {
            case '#text' :
            {
                $tagContent = $tag->textContent;
                if ( !strlen( $tagContent ) )
                {
                    break;
                }

                $tagContent = htmlspecialchars( $tagContent );
                $tagContent = str_replace ( '&amp;nbsp;', '&nbsp;', $tagContent );

                if ( $this->allowMultipleSpaces )
                {
                    $tagContent = str_replace( '  ', ' &nbsp;', $tagContent );
                }
                else
                {
                    $tagContent = preg_replace( "/ {2,}/", ' ', $tagContent );
                }

                if ( $tagContent[0] === ' ' && !$tag->previousSibling )//- Fixed "first space in paragraph" issue (ezdhtml rev.12246)
                {
                    $tagContent[0] = ';';
                    $tagContent = '&nbsp' . $tagContent;
                }

                if ( $this->allowNumericEntities )
                    $tagContent = preg_replace( '/&amp;#([0-9]+);/', '&#\1;', $tagContent );

                $output .= $tagContent;

            }break;

            case 'embed' :
            case 'embed-inline' :
            {
                $view      = $tag->getAttribute( 'view' );
                $size      = $tag->getAttribute( 'size' );
                $alignment = $tag->getAttribute( 'align' );
                $objectID  = $tag->getAttribute( 'object_id' );
                $nodeID    = $tag->getAttribute( 'node_id' );
                $showPath  = $tag->getAttribute( 'show_path' );
                $htmlID    = $tag->getAttributeNS( 'http://ez.no/namespaces/ezpublish3/xhtml/', 'id' );
                $className = $tag->getAttribute( 'class' );
                $idString  = '';
                $tplSuffix = '';

                if ( !$size )
                {
                    $contentIni = eZINI::instance( 'content.ini' );
                    $size       = $contentIni->variable( 'ImageSettings', 'DefaultEmbedAlias' );
                }

                if ( !$view )
                {
                    $view = $tagName;
                }

                $objectAttr = '';
                $objectAttr .= ' alt="' . $size . '"';
                $objectAttr .= ' view="' . $view . '"';

                if ( $htmlID != '' )
                {
                    $objectAttr .= ' html_id="' . $htmlID . '"';
                }
                if ( $showPath === 'true' )
                {
                    $objectAttr .= ' show_path="true"';
                }

                if ( $tagName === 'embed-inline' )
                    $objectAttr .= ' inline="true"';
                else
                    $objectAttr .= ' inline="false"';

                $customAttributePart = self::getCustomAttrPart( $tag, $styleString );
                $object              = false;

                if ( is_numeric( $objectID ) )
                {
                    $object = eZContentObject::fetch( $objectID );
                    $idString = 'eZObject_' . $objectID;
                }
                elseif ( is_numeric( $nodeID ) )
                {
                    $node      = eZContentObjectTreeNode::fetch( $nodeID );
                    $object    = $node instanceof eZContentObjectTreeNode ? $node->object() : false;
                    $idString  = 'eZNode_' . $nodeID;
                    $tplSuffix = '_node';
                }

                if ( $object instanceof eZContentObject )
                {
                    $objectName = $object->attribute( 'name' );
                    $classIdentifier = $object->attribute( 'class_identifier' );
                    if ( !$object->attribute( 'can_read' ) ||
                         !$object->attribute( 'can_view_embed' ) )
                    {
                        $tplSuffix = '_denied';
                    }
                    else if ( $object->attribute( 'status' ) == eZContentObject::STATUS_ARCHIVED )
                    {
                        $className .= ' ezoeItemObjectInTrash';
                        if ( self::$showEmbedValidationErrors )
                        {
                            $oeini = eZINI::instance( 'ezoe.ini' );
                            if ( $oeini->variable('EditorSettings', 'ValidateEmbedObjects' ) === 'enabled' )
                                $className .= ' ezoeItemValidationError';
                        }
                    }
                }
                else
                {
                    $objectName = 'Unknown';
                    $classIdentifier = false;
                    $tplSuffix = '_denied';
                    $className .= ' ezoeItemObjectDeleted';
                    if ( self::$showEmbedValidationErrors )
                    {
                        $className .= ' ezoeItemValidationError';
                    }
                }

                $embedContentType = self::embedTagContentType( $classIdentifier );
                if ( $embedContentType === 'images' )
                {
                    $ini = eZINI::instance();
                    $URL = self::getServerURL();
                    $objectAttributes = $object->contentObjectAttributes();
                    $imageDatatypeArray = $ini->variable('ImageDataTypeSettings', 'AvailableImageDataTypes');
                    $imageWidth = 32;
                    $imageHeight = 32;
                    foreach ( $objectAttributes as $objectAttribute )
                    {
                        $classAttribute = $objectAttribute->contentClassAttribute();
                        $dataTypeString = $classAttribute->attribute( 'data_type_string' );
                        if ( in_array ( $dataTypeString, $imageDatatypeArray ) && $objectAttribute->hasContent() )
                        {
                            $content = $objectAttribute->content();
                            if ( $content == null )
                                continue;

                            if ( $content->hasAttribute( $size ) )
                            {
                                $imageAlias  = $content->imageAlias( $size );
                                $srcString   = $URL . '/' . $imageAlias['url'];
                                $imageWidth  = $imageAlias['width'];
                                $imageHeight = $imageAlias['height'];
                                break;
                            }
                            else
                            {
                                eZDebug::writeError( "Image alias does not exist: $size, missing from image.ini?",
                                    __METHOD__ );
                            }
                        }
                    }

                    if ( !isset( $srcString ) )
                    {
                        $srcString = self::getDesignFile('images/tango/mail-attachment32.png');
                    }

                    if ( $alignment === 'center' )
                    {
                        $objectAttr .= ' align="middle"';
                        $className .= ' ezoeAlignmiddle'; // align="middle" is not taken into account by browsers on img
                    }
                    else if ( $alignment )
                        $objectAttr .= ' align="' . $alignment . '"';

                    if ( $className != '' )
                        $objectAttr .= ' class="' . $className . '"';

                    $output .= '<img id="' . $idString . '" title="' . $objectName . '" src="' .
                               $srcString . '" width="' . $imageWidth . '" height="' . $imageHeight .
                               '" ' . $objectAttr . $customAttributePart . $styleString . ' />';
                }
                else if ( self::embedTagIsCompatibilityMode() )
                {
                    $srcString = self::getDesignFile('images/tango/mail-attachment32.png');
                    if ( $alignment === 'center' )
                        $objectAttr .= ' align="middle"';
                    else if ( $alignment )
                        $objectAttr .= ' align="' . $alignment . '"';

                    if ( $className != '' )
                        $objectAttr .= ' class="' . $className . '"';

                    $output .= '<img id="' . $idString . '" title="' . $objectName . '" src="' .
                               $srcString . '" width="32" height="32" ' . $objectAttr .
                               $customAttributePart . $styleString . ' />';
                }
                else
                {
                    if ( $alignment )
                        $objectAttr .= ' align="' . $alignment . '"';

                    if ( $className )
                        $objectAttr .= ' class="ezoeItemNonEditable ' . $className . ' ezoeItemContentType' .
                                       ucfirst( $embedContentType ) . '"';
                    else
                        $objectAttr .= ' class="ezoeItemNonEditable ezoeItemContentType' .
                                       ucfirst( $embedContentType ) . '"';

                    if ( $tagName === 'embed-inline' )
                        $htmlTagName = 'span';
                    else
                        $htmlTagName = 'div';

                    $objectParam = array( 'size' => $size, 'align' => $alignment, 'show_path' => $showPath );
                    if ( $htmlID ) $objectParam['id'] = $htmlID;

                    $res = eZTemplateDesignResource::instance();
                    $res->setKeys( array( array('classification', $className) ) );

                    if ( isset( $node ) )
                    {
                        $templateOutput = self::fetchTemplate( 'design:content/datatype/view/ezxmltags/' . $tagName . $tplSuffix . '.tpl', array(
                            'view' => $view,
                            'object' => $object,
                            'link_parameters' => array(),
                            'classification' => $className,
                            'object_parameters' => $objectParam,
                            'node' => $node,
                        ));
                    }
                    else
                    {
                        $templateOutput = self::fetchTemplate( 'design:content/datatype/view/ezxmltags/' . $tagName . $tplSuffix . '.tpl', array(
                            'view' => $view,
                            'object' => $object,
                            'link_parameters' => array(),
                            'classification' => $className,
                            'object_parameters' => $objectParam,
                        ));
                    }

                    $output .= '<' . $htmlTagName . ' id="' . $idString . '" title="' . $objectName . '"' .
                               $objectAttr . $customAttributePart . $styleString . '>' . $templateOutput .
                               '</' . $htmlTagName . '>';
                }
            }break;

            case 'custom' :
            {
                $name = $tag->getAttribute( 'name' );
                $align = $tag->getAttribute( 'align' );
                $customAttributePart = self::getCustomAttrPart( $tag, $styleString );
                $inline = self::customTagIsInline( $name );
                if ( $align )
                {
                    $customAttributePart .= ' align="' . $align . '"';
                }

                if ( isset( self::$nativeCustomTags[ $name ] ))
                {
                    if ( !$childTagText ) $childTagText = '&nbsp;';
                    $output .= '<' . self::$nativeCustomTags[ $name ] . $customAttributePart . $styleString .
                               '>' . $childTagText . '</' . self::$nativeCustomTags[ $name ] . '>';
                }
                else if ( $inline === true )
                {
                    if ( !$childTagText ) $childTagText = '&nbsp;';
                    $output .= '<span class="ezoeItemCustomTag ' . $name . '" type="custom"' .
                               $customAttributePart . $styleString . '>' . $childTagText . '</span>';
                }
                else if ( $inline )
                {
                    $imageUrl = self::getCustomAttribute( $tag, 'image_url' );
                    if ( $imageUrl === null || !$imageUrl )
                    {
                        $imageUrl = self::getDesignFile( $inline );
                        $customAttributePart .= ' width="22" height="22"';
                    }
                    $output .= '<img src="' . $imageUrl . '" class="ezoeItemCustomTag ' . $name .
                               '" type="custom"' . $customAttributePart . $styleString . ' />';
                }
                else if ( $tag->textContent === '' && !$tag->hasChildNodes() )
                {
                    // for empty custom tag, just put a paragraph with the name
                    // of the custom tag in to handle it in the rich text editor
                    $output .= '<div class="ezoeItemCustomTag ' . $name . '" type="custom"' .
                                    $customAttributePart . $styleString . '><p>' . $name . '</p></div>';
                }
                else
                {
                    $customTagContent = $this->inputSectionXML( $tag, $currentSectionLevel, $tdSectionLevel );
                    /*foreach ( $tag->childNodes as $tagChild )
                    {
                        $customTagContent .= $this->inputTdXML( $tagChild,
                                                                $currentSectionLevel,
                                                                $tdSectionLevel );
                    }*/
                    $output .= '<div class="ezoeItemCustomTag ' . $name . '" type="custom"' .
                               $customAttributePart . $styleString . '>' . $customTagContent . '</div>';
                }
            }break;

            case 'literal' :
            {
                $literalText = '';
                foreach ( $tagChildren as $childTag )
                {
                    $literalText .= $childTag->textContent;
                }
                $className = $tag->getAttribute( 'class' );

                $customAttributePart = self::getCustomAttrPart( $tag, $styleString );

                $literalText = htmlspecialchars( $literalText );
                $literalText = str_replace( "\n", '<br />', $literalText );

                if ( $className != '' )
                    $customAttributePart .= ' class="' . $className . '"';

                $output .= '<pre' . $customAttributePart . $styleString . '>' . $literalText . '</pre>';

            }break;

            case 'ul' :
            case 'ol' :
            {
                $listContent = '';

                $customAttributePart = self::getCustomAttrPart( $tag, $styleString );

                // find all list elements
                foreach ( $tag->childNodes as $listItemNode )
                {
                    if ( !$listItemNode instanceof DOMElement )
                    {
                        continue;// ignore whitespace
                    }

                    $LIcustomAttributePart = self::getCustomAttrPart( $listItemNode, $listItemStyleString );

                    $noParagraphs = self::childTagCount( $listItemNode ) <= 1;
                    $listItemContent = '';
                    foreach ( $listItemNode->childNodes as $itemChildNode )
                    {
                        $listSectionLevel = $currentSectionLevel;
                        if ( $itemChildNode instanceof DOMNode
                        && ( $itemChildNode->nodeName === 'section'
                          || $itemChildNode->nodeName === 'paragraph' ) )
                        {
                            $listItemContent .= $this->inputListXML( $itemChildNode,
                                                                     $currentSectionLevel,
                                                                     $listSectionLevel,
                                                                     $noParagraphs );
                        }
                        else
                        {
                            $listItemContent .= $this->inputTagXML( $itemChildNode,
                                                                    $currentSectionLevel,
                                                                    $tdSectionLevel );
                        }
                    }

                    $LIclassName = $listItemNode->getAttribute( 'class' );

                    if ( $LIclassName )
                        $LIcustomAttributePart .= ' class="' . $LIclassName . '"';

                    $listContent .= '<li' . $LIcustomAttributePart . $listItemStyleString . '>' .
                                    $listItemContent . '</li>';
                }
                $className = $tag->getAttribute( 'class' );
                if ( $className != '' )
                    $customAttributePart .= ' class="' . $className . '"';

                $output .= '<' . $tagName . $customAttributePart . $styleString . '>' . $listContent . '</' .
                           $tagName . '>';
            }break;

            case 'table' :
            {
                $tableRows = '';
                $border = $tag->getAttribute( 'border' );
                $width = $tag->getAttribute( 'width' );
                $align = $tag->getAttribute( 'align' );
                $tableClassName = $tag->getAttribute( 'class' );

                $customAttributePart = self::getCustomAttrPart( $tag, $styleString );

                // find all table rows
                foreach ( $tag->childNodes as $tableRow )
                {
                    if ( !$tableRow instanceof DOMElement )
                    {
                        continue; // ignore whitespace
                    }
                    $TRcustomAttributePart = self::getCustomAttrPart( $tableRow, $tableRowStyleString );
                    $TRclassName = $tableRow->getAttribute( 'class' );

                    $tableData = '';
                    foreach ( $tableRow->childNodes as $tableCell )
                    {
                        if ( !$tableCell instanceof DOMElement )
                        {
                            continue; // ignore whitespace
                        }

                        $TDcustomAttributePart = self::getCustomAttrPart( $tableCell, $tableCellStyleString );

                        $className = $tableCell->getAttribute( 'class' );
                        $cellAlign = $tableCell->getAttribute( 'align' );

                        $colspan = $tableCell->getAttributeNS( 'http://ez.no/namespaces/ezpublish3/xhtml/',
                                                               'colspan' );
                        $rowspan = $tableCell->getAttributeNS( 'http://ez.no/namespaces/ezpublish3/xhtml/',
                                                               'rowspan' );
                        $cellWidth = $tableCell->getAttributeNS( 'http://ez.no/namespaces/ezpublish3/xhtml/',
                                                                 'width' );
                        if ( $className != '' )
                        {
                            $TDcustomAttributePart .= ' class="' . $className . '"';
                        }
                        if ( $cellWidth != '' )
                        {
                            $TDcustomAttributePart .= ' width="' . $cellWidth . '"';
                        }
                        if ( $colspan && $colspan !== '1' )
                        {
                            $TDcustomAttributePart .= ' colspan="' . $colspan . '"';
                        }
                        if ( $rowspan && $rowspan !== '1' )
                        {
                            $TDcustomAttributePart .= ' rowspan="' . $rowspan . '"';
                        }
                        if ( $cellAlign )
                        {
                                $TDcustomAttributePart .= ' align="' . $cellAlign . '"';
                        }
                        $cellContent = '';
                        $tdSectionLevel = $currentSectionLevel;
                        foreach ( $tableCell->childNodes as $tableCellChildNode )
                        {
                            $cellContent .= $this->inputTdXML( $tableCellChildNode,
                                                               $currentSectionLevel,
                                                               $tdSectionLevel - $currentSectionLevel );
                        }
                        if ( $cellContent === '' )
                        {
                            // tinymce has some issues with empty content in some browsers
                            if ( self::browserSupportsDHTMLType() != 'Trident' )
                                $cellContent = '<p><br data-mce-bogus="1"/></p>';
                        }
                        if ( $tableCell->nodeName === 'th' )
                        {
                            $tableData .= '<th' . $TDcustomAttributePart . $tableCellStyleString . '>' .
                                          $cellContent . '</th>';
                        }
                        else
                        {
                            $tableData .= '<td' . $TDcustomAttributePart . $tableCellStyleString . '>' .
                                          $cellContent . '</td>';
                        }
                    }
                    if ( $TRclassName )
                        $TRcustomAttributePart .= ' class="' . $TRclassName . '"';

                    $tableRows .= '<tr' . $TRcustomAttributePart . $tableRowStyleString . '>' .
                                  $tableData . '</tr>';
                }
                //if ( self::browserSupportsDHTMLType() === 'Trident' )
                //{
                    $customAttributePart .= ' width="' . $width . '"';
                /*}
                else
                {
                    // if this is reenabled merge it with $styleString
                    $customAttributePart .= ' style="width:' . $width . ';"';
                }*/

                if ( $border !== '' && is_string( $border ) )
                {
                    if ( $border === '0%' )
                        $border = '0';// Strip % if 0 to make sure TinyMCE shows a dotted border

                    $customAttributePart .= ' border="' . $border . '"';
                }

                if ( $align )
                {
                    $customAttributePart .= ' align="' . $align . '"';
                }

                if ( $tableClassName )
                {
                    $customAttributePart .= ' class="' . $tableClassName . '"';
                }

                $output .= '<table' . $customAttributePart . $styleString . '><tbody>' . $tableRows .
                           '</tbody></table>';
            }break;

            // normal content tags
            case 'emphasize' :
            {
                $customAttributePart = self::getCustomAttrPart( $tag, $styleString );

                $className = $tag->getAttribute( 'class' );
                if ( $className )
                {
                    $customAttributePart .= ' class="' . $className . '"';
                }
                $output .= '<em' . $customAttributePart . $styleString . '>' . $childTagText  . '</em>';
            }break;

            case 'strong' :
            {
                $customAttributePart = self::getCustomAttrPart( $tag, $styleString );

                $className = $tag->getAttribute( 'class' );
                if ( $className  )
                {
                    $customAttributePart .= ' class="' . $className . '"';
                }
                $output .= '<strong' . $customAttributePart . $styleString . '>' . $childTagText  . '</strong>';
            }break;

            case 'line' :
            {
                $output .= $childTagText . '<br />';
            }break;

            case 'anchor' :
            {
                $name = $tag->getAttribute( 'name' );

                $customAttributePart = self::getCustomAttrPart( $tag, $styleString );

                $output .= '<a name="' . $name . '" class="mceItemAnchor"' . $customAttributePart .
                           $styleString . '></a>';
            }break;

            case 'link' :
            {
                $customAttributePart = self::getCustomAttrPart( $tag, $styleString );

                $linkID = $tag->getAttribute( 'url_id' );
                $target = $tag->getAttribute( 'target' );
                $className = $tag->getAttribute( 'class' );
                $viewName = $tag->getAttribute( 'view' );
                $objectID = $tag->getAttribute( 'object_id' );
                $nodeID = $tag->getAttribute( 'node_id' );
                $anchorName = $tag->getAttribute( 'anchor_name' );
                $showPath = $tag->getAttribute( 'show_path' );
                $htmlID = $tag->getAttributeNS( 'http://ez.no/namespaces/ezpublish3/xhtml/', 'id' );
                $htmlTitle = $tag->getAttributeNS( 'http://ez.no/namespaces/ezpublish3/xhtml/', 'title' );
                $attributes = array();

                if ( $objectID != null )
                {
                    $href = 'ezobject://' .$objectID;
                }
                elseif ( $nodeID != null )
                {
                    if ( $showPath === 'true' )
                    {
                        $node = eZContentObjectTreeNode::fetch( $nodeID );
                        $href = $node ?
                                'eznode://' . $node->attribute('path_identification_string') :
                                'eznode://' . $nodeID;
                    }
                    else
                    {
                        $href = 'eznode://' . $nodeID;
                    }
                }
                elseif ( $linkID != null )
                {
                    $href = eZURL::url( $linkID );
                }
                else
                {
                    $href = $tag->getAttribute( 'href' );
                }

                if ( $anchorName != null )
                {
                    $href .= '#' . $anchorName;
                }

                if ( $className != '' )
                {
                    $attributes[] = 'class="' . $className . '"';
                }

                if ( $viewName != '' )
                {
                    $attributes[] = 'view="' . $viewName . '"';
                }

                $attributes[] = 'href="' . $href . '"';
                // Also set mce_href for use by OE to make sure href attribute is not messed up by IE 6 / 7
                $attributes[] = 'data-mce-href="' . $href . '"';
                if ( $target != '' )
                {
                    $attributes[] = 'target="' . $target . '"';
                }
                if ( $htmlTitle != '' )
                {
                    $attributes[] = 'title="' . $htmlTitle . '"';
                }
                if ( $htmlID != '' )
                {
                   $attributes[] = 'id="' . $htmlID . '"';
                }

                $attributeText = '';
                if ( !empty( $attributes ) )
                {
                    $attributeText = ' ' .implode( ' ', $attributes );
                }
                $output .= '<a' . $attributeText . $customAttributePart . $styleString . '>' .
                           $childTagText . '</a>';
            }break;
            case 'tr' :
            case 'td' :
            case 'th' :
            case 'li' :
            case 'paragraph' :
            {
            }break;
            default :
            {

            }break;
        }
        return $output;
    }
Exemplo n.º 19
0
 /**
  * Returns a shared instance of the eZTemplate class with
  * default settings applied, like:
  * - Autoload operators loaded
  * - Debug mode set
  * - eZTemplateDesignResource::instance registered
  *
  * @since 4.3
  * @return eZTemplate
  */
 public static function factory()
 {
     if (self::$factory === false) {
         $instance = self::instance();
         $ini = eZINI::instance();
         if (!isset($GLOBALS['eZTemplateDebugInternalsEnabled']) && $ini->variable('TemplateSettings', 'Debug') == 'enabled') {
             eZTemplate::setIsDebugEnabled(true);
         }
         $compatAutoLoadPath = $ini->variableArray('TemplateSettings', 'AutoloadPath');
         $autoLoadPathList = $ini->variable('TemplateSettings', 'AutoloadPathList');
         $extensionAutoloadPath = $ini->variable('TemplateSettings', 'ExtensionAutoloadPath');
         $extensionPathList = eZExtension::expandedPathList($extensionAutoloadPath, 'autoloads/');
         $autoLoadPathList = array_unique(array_merge($compatAutoLoadPath, $autoLoadPathList, $extensionPathList));
         $instance->setAutoloadPathList($autoLoadPathList);
         $instance->autoload();
         $instance->registerResource(eZTemplateDesignResource::instance());
         self::$factory = true;
     }
     return self::instance();
 }
Exemplo n.º 20
0
    } else {
        $subTreeList = array($http->variable("SubTreeArray"));
    }
    foreach ($subTreeList as $subTreeItem) {
        if ($subTreeItem > 0) {
            $subTreeArray[] = $subTreeItem;
        }
    }
}
$Module->setTitle("Search for: {$searchText}");
if ($useSearchCode) {
    $sortArray = array(array('attribute', true, 153), array('priority', true));
    $searchResult = eZSearch::search($searchText, array("SearchType" => $searchType, "SearchSectionID" => $searchSectionID, "SearchSubTreeArray" => $subTreeArray, 'SearchTimestamp' => $searchTimestamp, "SearchLimit" => $pageLimit, "SearchOffset" => $Offset));
}
if ($searchSectionID != -1) {
    $res = eZTemplateDesignResource::instance();
    $section = eZSection::fetch($searchSectionID);
    $keyArray = array(array('section', $searchSectionID), array('section_identifier', $section->attribute('identifier')));
    $res->setKeys($keyArray);
}
$viewParameters = array('offset' => $Offset);
$searchData = false;
$tpl->setVariable("search_data", $searchData);
$tpl->setVariable("search_section_id", $searchSectionID);
$tpl->setVariable("search_subtree_array", $subTreeArray);
$tpl->setVariable('search_timestamp', $searchTimestamp);
$tpl->setVariable("search_text", $searchText);
$tpl->setVariable('search_page_limit', $searchPageLimit);
$tpl->setVariable("view_parameters", $viewParameters);
$tpl->setVariable('use_template_search', !$useSearchCode);
if ($http->hasVariable('Mode') && $http->variable('Mode') == 'browse') {
Exemplo n.º 21
0
 function generateNewsletter($format = eZNewsletter::OutputFormatText, $sendPreview = false)
 {
     // 1. Set resource keys
     $res = eZTemplateDesignResource::instance();
     $res->setKeys(array(array('newslettertype_id', $this->attribute('newslettertype_id')), array('newsletter_id', $this->attribute('id')), array('class_identifier', ''), array('newsletter_type', 'mail')));
     if ($format == eZNewsletter::OutputFormatText) {
         $res->setKeys(array(array('output_format', 'plaintext')));
     }
     // 2. Set general mail and template properties
     $ini = eZINI::instance();
     $hostname = eZSys::hostname();
     $newsletterType = $this->attribute('newsletter_type');
     if (true === $sendPreview) {
         // Fetch the draft because the object is not published during preview
         $contentObject = $this->contentObjectVersion();
     } else {
         $contentObject = $this->contentObject();
     }
     // 3. get skin for newsletter
     $skin_prefix = 'eznewsletter';
     $custom_skin = $this->attribute('template_to_use');
     if ($custom_skin) {
         $skin_prefix = $custom_skin;
     }
     // 3. Generate mail variation
     switch ($format) {
         default:
         case eZNewsletter::OutputFormatText:
             $template = 'design:' . $skin_prefix . '/sendout/text.tpl';
             break;
         case eZNewsletter::OutputFormatExternalHTML:
             $template = 'design:' . $skin_prefix . '/sendout/linked.tpl';
             break;
         case eZNewsletter::OutputFormatHTML:
             $template = 'design:' . $skin_prefix . '/sendout/html.tpl';
             break;
         case eZNewsletter::OutputFormatSMS:
             $template = 'design:' . $skin_prefix . '/sendout/sms.tpl';
             break;
     }
     $tpl = eZNewsletterTemplateWrapper::templateInit();
     $tpl->setVariable('hostname', $hostname);
     $tpl->setVariable('contentobject', $contentObject);
     $tpl->setVariable('newsletter', $this);
     $body = $tpl->fetch($template);
     // Get images used.
     $imageList = false;
     $imageListName = false;
     if ($tpl->hasVariable('imageFileList') && $format == eZNewsletter::OutputFormatHTML) {
         foreach ($tpl->variable('imageFileList') as $imageMap) {
             $tplImageList = explode(';', $imageMap);
             $imagePath = $tplImageList[0];
             $imageURL = $tplImageList[1];
             $imageName = isset($tplImageList[2]) ? $tplImageList[2] : basename($imagePath);
             $md5Sum = md5($imageURL);
             $body = str_replace($imageURL, 'cid:' . $md5Sum, $body);
             $imageList[$md5Sum] = $imagePath;
             $imageListName[$md5Sum] = $imageName;
         }
     }
     if ($format == eZNewsletter::OutputFormatText || $format == eZNewsletter::OutputFormatExternalHTML) {
         if ($format == eZNewsletter::OutputFormatText) {
             $body = strip_tags($body);
         }
         $body = trim($body);
     }
     $subject = $this->attribute('name');
     if ($tpl->hasVariable('subject')) {
         $subject = $tpl->variable('subject');
     }
     if ($tpl->hasVariable('emailSenderName')) {
         $emailSenderName = $tpl->variable('emailSenderName');
     } else {
         $emailSenderName = false;
     }
     return array('body' => $body, 'subject' => $subject, 'emailSender' => $newsletterType->attribute('sender_address') ? $newsletterType->attribute('sender_address') : $ini->variable('MailSettings', 'EmailSender'), 'emailSenderName' => $emailSenderName, 'imageNameMap' => $imageList, 'userhash' => 'userhash', 'templateInstance' => $tpl, 'imageNameMapName' => $imageListName);
 }