function eZTemplateImageOperator($texttoimageName = "texttoimage", $imageName = "image", $imagefileName = "imagefile")
 {
     $this->Operators = array($texttoimageName, $imageName, $imagefileName);
     $ini = eZINI::instance('texttoimage.ini');
     $fontDirs = $ini->variable("PathSettings", "FontDir");
     $this->FontDir = array();
     foreach ($fontDirs as $fontDir) {
         $this->FontDir[] = $fontDir;
     }
     $this->CacheDir = $ini->variable("PathSettings", "CacheDir");
     $this->HTMLDir = eZSys::wwwDir() . $ini->variable("PathSettings", "HtmlDir");
     $this->DefaultClass = 'default';
     $this->Family = "arial";
     $this->Colors = array("bgcolor" => array(255, 255, 255), "textcolor" => array(0, 0, 0));
     $this->PointSize = 12;
     $this->Angle = 0;
     $this->XAdjust = 0;
     $this->YAdjust = 0;
     $this->WAdjust = 0;
     $this->HAdjust = 0;
     $this->UseCache = true;
     if ($ini->variable("ImageSettings", "UseCache") == "disabled") {
         $this->UseCache = false;
     }
     $functions = array("ImageTTFBBox", "ImageCreate", "ImageColorAllocate", "ImageColorAllocate", "ImageTTFText", "ImagePNG", "ImageJPEG", "ImageDestroy");
     $this->MissingGDFunctions = array();
     foreach ($functions as $function) {
         if (!function_exists($function)) {
             $this->MissingGDFunctions[] = $function;
         }
     }
     $this->ImageGDSupported = count($this->MissingGDFunctions) == 0;
 }
/**
 * Loose extension path function for include use originally from ezextension.php
 *
 * @deprecated Since 4.3
 */
function extension_path($extension, $withWWWDir = false, $withHost = false, $withProtocol = false)
{
    $base = eZExtension::baseDirectory();
    $path = '';
    if ($withProtocol) {
        if (is_string($withProtocol)) {
            $path .= $withProtocol;
        } else {
            $path .= eZSys::serverProtocol();
        }
        $path .= ':';
    }
    if ($withHost) {
        $path .= '//';
        if (is_string($withHost)) {
            $path .= $withHost;
        } else {
            $path .= eZSys::hostname();
        }
    }
    if ($withWWWDir) {
        $path .= eZSys::wwwDir();
    }
    if ($withWWWDir) {
        $path .= '/' . $base . '/' . $extension;
    } else {
        $path .= $base . '/' . $extension;
    }
    return $path;
}
 function modify($tpl, $operatorName, $operatorParameters, $rootNamespace, $currentNamespace, &$operatorValue, $namedParameters)
 {
     switch ($operatorName) {
         case 'parsexml':
             $firstParam = $namedParameters['first_param'];
             if (trim($operatorValue) != '') {
                 $dom = new DOMDocument('1.0', 'utf-8');
                 if ($dom->loadXML($operatorValue)) {
                     $FileAttributeValue = $dom->getElementsByTagName($firstParam)->item(0)->textContent;
                     if (!$FileAttributeValue) {
                         $FileAttributeValue = $dom->getElementsByTagName($firstParam)->item(0)->getAttribute('value');
                     }
                 }
                 $operatorValue = $FileAttributeValue;
             }
             break;
         case 'filecheck':
             if (trim($operatorValue) != '') {
                 $dom = new DOMDocument('1.0', 'utf-8');
                 if ($dom->loadXML($operatorValue)) {
                     $FileAttributeValue = $dom->getElementsByTagName('Filename')->item(0)->textContent;
                     if (!$FileAttributeValue) {
                         $FileAttributeValue = $dom->getElementsByTagName('Filename')->item(0)->getAttribute('value');
                     }
                 }
                 if (file_exists(eZSys::wwwDir() . $FileAttributeValue)) {
                     $operatorValue = true;
                 } else {
                     $operatorValue = false;
                 }
             }
             break;
     }
 }
 /**
  * Sets a cookie with the current user hash
  *
  * @param bool $unsetCookie controls whether to remove the cookie
  */
 public static function setUserHashCookie($unsetCookie = false)
 {
     $wwwDir = eZSys::wwwDir();
     // On host based site accesses this can be empty, causing the cookie to be set for the current dir,
     // but we want it to be set for the whole eZ publish site
     $cookiePath = $wwwDir != '' ? $wwwDir : '/';
     if (eZUser::isCurrentUserRegistered()) {
         setcookie('vuserhash', self::getUserHash($newSession), 0, $cookiePath);
     } elseif ($unsetCookie) {
         //removes cookie
         setcookie('vuserhash', '0', 1, $cookiePath);
     }
 }
 protected static function getWwwDir()
 {
     static $wwwDir = null;
     if ($wwwDir === null) {
         $wwwDir = eZSys::wwwDir() . '/';
     }
     return $wwwDir;
 }
 function modify($tpl, $operatorName, $operatorParameters, $rootNamespace, $currentNamespace, &$operatorValue, $namedParameters)
 {
     switch ($operatorName) {
         case "wordtoimage":
             $ini = eZINI::instance("wordtoimage.ini");
             $iconRoot = $ini->variable('WordToImageSettings', 'IconRoot');
             $replaceText = $ini->variable('WordToImageSettings', 'ReplaceText');
             $replaceIcon = $ini->variable('WordToImageSettings', 'ReplaceIcon');
             $wwwDirPrefix = "";
             if (strlen(eZSys::wwwDir()) > 0) {
                 $wwwDirPrefix = eZSys::wwwDir() . "/";
             }
             foreach ($replaceIcon as $icon) {
                 // Issue 015718, constructing alt text from icon name
                 $aReplaceIconName = explode('.', $icon);
                 $altText = $aReplaceIconName[0];
                 $icons[] = '<img src="' . $wwwDirPrefix . $iconRoot . '/' . $icon . '" alt="' . $altText . '"/>';
             }
             $operatorValue = str_replace($replaceText, $icons, $operatorValue);
             break;
             // icon_info( <type> ) => array() containing:
             // - repository - Repository path
             // - theme - Theme name
             // - theme_path - Theme path
             // - size_path_list - Associative array of size paths
             // - size_info_list - Associative array of size info (width and height)
             // - icons - Array of icon files, relative to theme and size path
             // - default - Default icon file, relative to theme and size path
         // icon_info( <type> ) => array() containing:
         // - repository - Repository path
         // - theme - Theme name
         // - theme_path - Theme path
         // - size_path_list - Associative array of size paths
         // - size_info_list - Associative array of size info (width and height)
         // - icons - Array of icon files, relative to theme and size path
         // - default - Default icon file, relative to theme and size path
         case 'icon_info':
             if (!isset($operatorParameters[0])) {
                 $tpl->missingParameter($operatorName, 'type');
                 return;
             }
             $type = $tpl->elementValue($operatorParameters[0], $rootNamespace, $currentNamespace);
             // Check if we have it cached
             if (isset($this->IconInfo[$type])) {
                 $operatorValue = $this->IconInfo[$type];
                 return;
             }
             $ini = eZINI::instance('icon.ini');
             $repository = $ini->variable('IconSettings', 'Repository');
             $theme = $ini->variable('IconSettings', 'Theme');
             $groups = array('mimetype' => 'MimeIcons', 'class' => 'ClassIcons', 'classgroup' => 'ClassGroupIcons', 'action' => 'ActionIcons', 'icon' => 'Icons');
             $configGroup = $groups[$type];
             $mapNames = array('mimetype' => 'MimeMap', 'class' => 'ClassMap', 'classgroup' => 'ClassGroupMap', 'action' => 'ActionMap', 'icon' => 'IconMap');
             $mapName = $mapNames[$type];
             // Check if the specific icon type has a theme setting
             if ($ini->hasVariable($configGroup, 'Theme')) {
                 $theme = $ini->variable($configGroup, 'Theme');
             }
             // Load icon settings from the theme
             $themeINI = eZINI::instance('icon.ini', $repository . '/' . $theme);
             $sizes = $themeINI->variable('IconSettings', 'Sizes');
             if ($ini->hasVariable('IconSettings', 'Sizes')) {
                 $sizes = array_merge($sizes, $ini->variable('IconSettings', 'Sizes'));
             }
             $sizePathList = array();
             $sizeInfoList = array();
             if (is_array($sizes)) {
                 foreach ($sizes as $key => $size) {
                     $pathDivider = strpos($size, ';');
                     if ($pathDivider !== false) {
                         $sizePath = substr($size, $pathDivider + 1);
                         $size = substr($size, 0, $pathDivider);
                     } else {
                         $sizePath = $size;
                     }
                     $width = false;
                     $height = false;
                     $xDivider = strpos($size, 'x');
                     if ($xDivider !== false) {
                         $width = (int) substr($size, 0, $xDivider);
                         $height = (int) substr($size, $xDivider + 1);
                     }
                     $sizePathList[$key] = $sizePath;
                     $sizeInfoList[$key] = array($width, $height);
                 }
             }
             $map = array();
             // Load mapping from theme
             if ($themeINI->hasVariable($configGroup, $mapName)) {
                 $map = array_merge($map, $themeINI->variable($configGroup, $mapName));
             }
             // Load override mappings if they exist
             if ($ini->hasVariable($configGroup, $mapName)) {
                 $map = array_merge($map, $ini->variable($configGroup, $mapName));
             }
             $default = false;
             if ($themeINI->hasVariable($configGroup, 'Default')) {
                 $default = $themeINI->variable($configGroup, 'Default');
             }
             if ($ini->hasVariable($configGroup, 'Default')) {
                 $default = $ini->variable($configGroup, 'Default');
             }
             // Build return value
             $iconInfo = array('repository' => $repository, 'theme' => $theme, 'theme_path' => $repository . '/' . $theme, 'size_path_list' => $sizePathList, 'size_info_list' => $sizeInfoList, 'icons' => $map, 'default' => $default);
             $this->IconInfo[$type] = $iconInfo;
             $operatorValue = $iconInfo;
             break;
         case 'flag_icon':
             $ini = eZINI::instance('icon.ini');
             $repository = $ini->variable('FlagIcons', 'Repository');
             $theme = $ini->variable('FlagIcons', 'Theme');
             // Load icon settings from the theme
             $themeINI = eZINI::instance('icon.ini', $repository . '/' . $theme);
             $iconFormat = $themeINI->variable('FlagIcons', 'IconFormat');
             if ($ini->hasVariable('FlagIcons', 'IconFormat')) {
                 $iconFormat = $ini->variable('FlagIcons', 'IconFormat');
             }
             $icon = $operatorValue . '.' . $iconFormat;
             $iconPath = $repository . '/' . $theme . '/' . $icon;
             if (!is_readable($iconPath)) {
                 $defaultIcon = $themeINI->variable('FlagIcons', 'DefaultIcon');
                 $iconPath = $repository . '/' . $theme . '/' . $defaultIcon . '.' . $iconFormat;
             }
             if (strlen(eZSys::wwwDir()) > 0) {
                 $wwwDirPrefix = eZSys::wwwDir() . '/';
             } else {
                 $wwwDirPrefix = '/';
             }
             $operatorValue = $wwwDirPrefix . $iconPath;
             break;
         case 'mimetype_icon':
         case 'class_icon':
         case 'classgroup_icon':
         case 'action_icon':
         case 'icon':
             // Determine whether we should return only the image URI instead of the whole HTML code.
             if (isset($operatorParameters[2])) {
                 $returnURIOnly = $tpl->elementValue($operatorParameters[2], $rootNamespace, $currentNamespace);
             } else {
                 $returnURIOnly = false;
             }
             $ini = eZINI::instance('icon.ini');
             $repository = $ini->variable('IconSettings', 'Repository');
             $theme = $ini->variable('IconSettings', 'Theme');
             $groups = array('mimetype_icon' => 'MimeIcons', 'class_icon' => 'ClassIcons', 'classgroup_icon' => 'ClassGroupIcons', 'action_icon' => 'ActionIcons', 'icon' => 'Icons');
             $configGroup = $groups[$operatorName];
             // Check if the specific icon type has a theme setting
             if ($ini->hasVariable($configGroup, 'Theme')) {
                 $theme = $ini->variable($configGroup, 'Theme');
             }
             // Load icon settings from the theme
             $themeINI = eZINI::instance('icon.ini', $repository . '/' . $theme);
             if (isset($operatorParameters[0])) {
                 $sizeName = $tpl->elementValue($operatorParameters[0], $rootNamespace, $currentNamespace);
             } else {
                 $sizeName = $ini->variable('IconSettings', 'Size');
                 // Check if the specific icon type has a size setting
                 if ($ini->hasVariable($configGroup, 'Size')) {
                     $theme = $ini->variable($configGroup, 'Size');
                 }
             }
             $sizes = $themeINI->variable('IconSettings', 'Sizes');
             if ($ini->hasVariable('IconSettings', 'Sizes')) {
                 $sizes = array_merge($sizes, $ini->variable('IconSettings', 'Sizes'));
             }
             if (isset($sizes[$sizeName])) {
                 $size = $sizes[$sizeName];
             } else {
                 $size = $sizes[0];
             }
             $pathDivider = strpos($size, ';');
             if ($pathDivider !== false) {
                 $sizePath = substr($size, $pathDivider + 1);
                 $size = substr($size, 0, $pathDivider);
             } else {
                 $sizePath = $size;
             }
             $width = false;
             $height = false;
             $xDivider = strpos($size, 'x');
             if ($xDivider !== false) {
                 $width = (int) substr($size, 0, $xDivider);
                 $height = (int) substr($size, $xDivider + 1);
             }
             if (isset($operatorParameters[1])) {
                 $altText = $tpl->elementValue($operatorParameters[1], $rootNamespace, $currentNamespace);
             } else {
                 $altText = $operatorValue;
             }
             if ($operatorName == 'mimetype_icon') {
                 $icon = $this->iconGroupMapping($ini, $themeINI, 'MimeIcons', 'MimeMap', strtolower($operatorValue));
             } else {
                 if ($operatorName == 'class_icon') {
                     $icon = $this->iconDirectMapping($ini, $themeINI, 'ClassIcons', 'ClassMap', strtolower($operatorValue));
                 } else {
                     if ($operatorName == 'classgroup_icon') {
                         $icon = $this->iconDirectMapping($ini, $themeINI, 'ClassGroupIcons', 'ClassGroupMap', strtolower($operatorValue));
                     } else {
                         if ($operatorName == 'action_icon') {
                             $icon = $this->iconDirectMapping($ini, $themeINI, 'ActionIcons', 'ActionMap', strtolower($operatorValue));
                         } else {
                             if ($operatorName == 'icon') {
                                 $icon = $this->iconDirectMapping($ini, $themeINI, 'Icons', 'IconMap', strtolower($operatorValue));
                             }
                         }
                     }
                 }
             }
             $iconPath = '/' . $repository . '/' . $theme;
             $iconPath .= '/' . $sizePath;
             $iconPath .= '/' . $icon;
             $wwwDirPrefix = "";
             if (strlen(eZSys::wwwDir()) > 0) {
                 $wwwDirPrefix = eZSys::wwwDir();
             }
             $sizeText = '';
             if ($width !== false and $height !== false) {
                 $sizeText = ' width="' . $width . '" height="' . $height . '"';
             }
             // The class will be detected by ezpngfix.js, which will force alpha blending in IE.
             if ((!isset($sizeName) || $sizeName == 'normal' || $sizeName == 'original') && strstr(strtolower($iconPath), ".png")) {
                 $class = 'class="transparent-png-icon" ';
             } else {
                 $class = '';
             }
             if ($returnURIOnly) {
                 $operatorValue = $wwwDirPrefix . $iconPath;
             } else {
                 $operatorValue = '<img ' . $class . 'src="' . $wwwDirPrefix . $iconPath . '"' . $sizeText . ' alt="' . htmlspecialchars($altText) . '" title="' . htmlspecialchars($altText) . '" />';
             }
             break;
         default:
             eZDebug::writeError("Unknown operator: {$operatorName}", "ezwordtoimageoperator.php");
     }
 }
 public static function setCookie()
 {
     $ini = eZINI::instance('scachecookie.ini');
     $siteIni = eZINI::instance('site.ini');
     $hasUserData = false;
     $displayedData = $ini->variable('CacheCookieSettings', 'DisplayedData');
     $cookieValue = $ini->variable('CacheCookieSettings', 'CookieValue') || 'true';
     if ($cookieValue === true) {
         $cookieValue = 'true';
     }
     $useDetailedValue = $ini->variable('CacheCookieSettings', 'DetailedCookieValue') == 'enabled';
     $detailedValue = '';
     if (in_array('basket', $displayedData)) {
         $http = eZHTTPTool::instance();
         $sessionID = $http->sessionID();
         $basket = eZBasket::fetch($sessionID);
         if ($basket) {
             if (!$basket->isEmpty()) {
                 $hasUserData = true;
                 if ($useDetailedValue) {
                     $detailedValue .= ',basket';
                 }
             }
         }
     }
     if ((!$hasUserData || $useDetailedValue) && in_array('wishlist', $displayedData)) {
         $user = eZUser::currentUser();
         $userID = $user->attribute('contentobject_id');
         $WishListArray = eZPersistentObject::fetchObjectList(eZWishList::definition(), null, array("user_id" => $userID), null, null, true);
         if (count($WishListArray) > 0) {
             if ($WishListArray[0]->itemCount() > 0) {
                 $hasUserData = true;
                 if ($useDetailedValue) {
                     $detailedValue .= ',wishlist';
                 }
             }
         }
     }
     if (!$hasUserData || $useDetailedValue) {
         $prefs = eZPreferences::values();
         $hasPrefs = false;
         foreach ($prefs as $key => $val) {
             if ($key != '') {
                 if (in_array('preferences', $displayedData) || in_array($key, $displayedData)) {
                     if ($val != '') {
                         $hasUserData = true;
                         if ($useDetailedValue) {
                             if (in_array('preferences', $displayedData) && !$hasPrefs) {
                                 $detailedValue .= ',preferences';
                             }
                             if (in_array($key, $displayedData)) {
                                 $detailedValue .= ",{$key}:{$val}";
                             }
                         }
                         $hasPrefs = true;
                     }
                 }
             }
         }
     }
     $value = $hasUserData ? $cookieValue . $detailedValue : false;
     $wwwDir = eZSys::wwwDir();
     $cookiePath = $wwwDir != '' ? $wwwDir : '/';
     setcookie($ini->variable('CacheCookieSettings', 'CookieName'), $value, time() + (int) $siteIni->variable('Session', 'SessionTimeout'), $cookiePath);
 }
Ejemplo n.º 8
0
 }
 $mail->setSubject($subject);
 //BEGIN ENHANCED BINARY EXTENSION MAIL CODE ADDITION
 $fileAttachments = array();
 foreach (array_keys($contentObjectAttributes) as $key) {
     if ($contentObjectAttributes[$key]->DataTypeString == "enhancedezbinaryfile") {
         $id = $contentObjectAttributes[$key]->attribute('id');
         $xmlText = $collectionAttributes[$id]->DataText;
         if (trim($xmlText) != '') {
             $dom = new DOMDocument('1.0', 'utf-8');
             if ($dom->loadXML($xmlText)) {
                 $OriginalFilename = $dom->getElementsByTagName('OriginalFilename')->item(0)->textContent;
                 $FileType = $dom->getElementsByTagName('Type')->item(0)->textContent;
                 $Filename = $dom->getElementsByTagName('Filename')->item(0)->textContent;
                 if (file_exists(eZSys::wwwDir() . $Filename)) {
                     $fileAttachments[] = array(eZSys::wwwDir() . $Filename, $OriginalFilename, $FileType);
                 }
             }
         }
     }
 }
 if (count($fileAttachments) != 0) {
     $mime_boundary = "==Multipart_Boundary_" . md5(time());
     //Plain Text part of Message
     $message = "--{$mime_boundary}\n" . "Content-Type: text/html; " . eZTextCodec::internalCharset() . "\n" . "Content-Transfer-Encoding: 8bit\n\n";
     //Form Result
     $message .= $templateResult;
     //Attachment(s) part of message
     foreach ($fileAttachments as $attacharray) {
         $filedata = chunk_split(base64_encode(eZFile::getContents($attacharray[0])));
         $message .= "\n\n\n--{$mime_boundary}\n" . "Content-Type: " . $attacharray[2] . ";\n" . " name=\"" . $attacharray[1] . "\"\n" . "Content-Transfer-Encoding: base64\n" . "Content-Disposition: inline;\n" . " filename=\"" . $attacharray[1] . "\"\n\n" . $filedata . "\n";
Ejemplo n.º 9
0
    function createSiteaccessUrls( $params )
    {
        $urlList = array();

        $siteaccessList = $params['siteaccess_list'];
        $accessType = $params['access_type'];
        $accessTypeValue = $params['access_type_value'];

        $excludePortList = isset( $params['exclude_port_list'] ) ? $params['exclude_port_list'] : array();

        $hostname = false;

        if ( isset( $params['host'] ) && $params['host'] !== '' )
            $hostname = $this->extractHostname( $params['host'] );

        if ( !$hostname )
            $hostname = eZSys::hostname();

        $indexFile = eZSys::wwwDir() . eZSys::indexFileName();

        switch( $accessType )
        {
            case 'port':
                {
                    $port = $accessTypeValue;

                    // build urls
                    foreach( $siteaccessList as $siteaccess )
                    {
                        // skip ports which are already in use
                        while( in_array( $port, $excludePortList ) )
                            ++$port;

                        $urlList[$siteaccess]['url'] = "$hostname:$port" . $indexFile;
                        $urlList[$siteaccess]['port'] = $port;
                        ++$port;
                    }
                }
                break;
            case 'host':
            case 'hostname':
                {
                    $prependSiteAccess = isset( $params['host_prepend_siteaccess'] ) && is_bool( $params['host_prepend_siteaccess'] ) ? $params['host_prepend_siteaccess'] : true;

                    $hostname = $this->extractHostname( $accessTypeValue );

                    if ( !$hostname )
                        $hostname = $accessTypeValue;

                    foreach( $siteaccessList as $siteaccess )
                    {
                        if ( $prependSiteAccess )
                        {
                            // replace undescores with dashes( '_' -> '-' );
                            $hostPrefix = preg_replace( '/(_)/', '-', $siteaccess);

                            // create url and host
                            $urlList[$siteaccess]['url'] = $hostPrefix . '.' . $hostname . $indexFile;
                            $urlList[$siteaccess]['host'] = $hostPrefix . '.' . $hostname;
                        }
                        else
                        {
                            // create url and host
                            $urlList[$siteaccess]['url'] = $hostname . $indexFile;
                            $urlList[$siteaccess]['host'] = $hostname;
                        }
                    }
                }
                break;
            case 'url':
            case 'uri':
                {
                    foreach( $siteaccessList as $siteaccess )
                    {
                        $urlList[$siteaccess]['url'] = $hostname . $indexFile . '/' . $siteaccess;
                    }
                }
                break;

            default:
                break;
        }

        return $urlList;
    }
Ejemplo n.º 10
0
 /**
  * Execution point for controller actions
  */
 public function run()
 {
     ob_start();
     $this->requestInit();
     // send header information
     foreach (eZHTTPHeader::headerOverrideArray($this->uri) + array('Expires' => 'Mon, 26 Jul 1997 05:00:00 GMT', 'Last-Modified' => gmdate('D, d M Y H:i:s') . ' GMT', 'Cache-Control' => 'no-cache, must-revalidate', 'Pragma' => 'no-cache', 'X-Powered-By' => 'eZ Publish', 'Content-Type' => 'text/html; charset=' . $this->httpCharset, 'Served-by' => $_SERVER["SERVER_NAME"], 'Content-language' => $this->languageCode) as $key => $value) {
         header($key . ': ' . $value);
     }
     try {
         $moduleResult = $this->dispatchLoop();
     } catch (Exception $e) {
         $this->shutdown();
         throw $e;
     }
     $ini = eZINI::instance();
     /**
      * Ouput an is_logged_in cookie when users are logged in for use by http cache solutions.
      *
      * @deprecated As of 4.5, since 4.4 added lazy session support (init on use)
      */
     if ($ini->variable("SiteAccessSettings", "CheckValidity") !== 'true') {
         $currentUser = eZUser::currentUser();
         $wwwDir = eZSys::wwwDir();
         // On host based site accesses this can be empty, causing the cookie to be set for the current dir,
         // but we want it to be set for the whole eZ publish site
         $cookiePath = $wwwDir != '' ? $wwwDir : '/';
         if ($currentUser->isLoggedIn()) {
             // Only set the cookie if it doesnt exist. This way we are not constantly sending the set request in the headers.
             if (!isset($_COOKIE['is_logged_in']) || $_COOKIE['is_logged_in'] !== 'true') {
                 setcookie('is_logged_in', 'true', 0, $cookiePath);
             }
         } else {
             if (isset($_COOKIE['is_logged_in'])) {
                 setcookie('is_logged_in', false, 0, $cookiePath);
             }
         }
     }
     if ($this->module->exitStatus() == eZModule::STATUS_REDIRECT) {
         $this->redirect();
     }
     // Store the last URI for access history for login redirection
     // Only if user has session and only if there was no error or no redirects happen
     if (eZSession::hasStarted() && $this->module->exitStatus() == eZModule::STATUS_OK) {
         $currentURI = $this->completeRequestedURI;
         if (strlen($currentURI) > 0 && $currentURI[0] !== '/') {
             $currentURI = '/' . $currentURI;
         }
         $lastAccessedURI = "";
         $lastAccessedViewURI = "";
         $http = eZHTTPTool::instance();
         // Fetched stored session variables
         if ($http->hasSessionVariable("LastAccessesURI")) {
             $lastAccessedViewURI = $http->sessionVariable("LastAccessesURI");
         }
         if ($http->hasSessionVariable("LastAccessedModifyingURI")) {
             $lastAccessedURI = $http->sessionVariable("LastAccessedModifyingURI");
         }
         // Update last accessed view page
         if ($currentURI != $lastAccessedViewURI && !in_array($this->module->uiContextName(), array('edit', 'administration', 'browse', 'authentication'))) {
             $http->setSessionVariable("LastAccessesURI", $currentURI);
         }
         // Update last accessed non-view page
         if ($currentURI != $lastAccessedURI) {
             $http->setSessionVariable("LastAccessedModifyingURI", $currentURI);
         }
     }
     eZDebug::addTimingPoint("Module end '" . $this->module->attribute('name') . "'");
     if (!is_array($moduleResult)) {
         eZDebug::writeError('Module did not return proper result: ' . $this->module->attribute('name'), 'index.php');
         $moduleResult = array();
         $moduleResult['content'] = false;
     }
     if (!isset($moduleResult['ui_context'])) {
         $moduleResult['ui_context'] = $this->module->uiContextName();
     }
     $moduleResult['ui_component'] = $this->module->uiComponentName();
     $moduleResult['is_mobile_device'] = $this->mobileDeviceDetect->isMobileDevice();
     $moduleResult['mobile_device_alias'] = $this->mobileDeviceDetect->getUserAgentAlias();
     $templateResult = null;
     eZDebug::setUseExternalCSS($this->siteBasics['external-css']);
     if ($this->siteBasics['show-page-layout']) {
         $tpl = eZTemplate::factory();
         if ($tpl->hasVariable('node')) {
             $tpl->unsetVariable('node');
         }
         if (!isset($moduleResult['path'])) {
             $moduleResult['path'] = false;
         }
         $moduleResult['uri'] = eZSys::requestURI();
         $tpl->setVariable("module_result", $moduleResult);
         $meta = $ini->variable('SiteSettings', 'MetaDataArray');
         if (!isset($meta['description'])) {
             $metaDescription = "";
             if (isset($moduleResult['path']) && is_array($moduleResult['path'])) {
                 foreach ($moduleResult['path'] as $pathPart) {
                     if (isset($pathPart['text'])) {
                         $metaDescription .= $pathPart['text'] . " ";
                     }
                 }
             }
             $meta['description'] = $metaDescription;
         }
         $this->site['uri'] = $this->oldURI;
         $this->site['redirect'] = false;
         $this->site['meta'] = $meta;
         $this->site['version'] = eZPublishSDK::version();
         $this->site['page_title'] = $this->module->title();
         $tpl->setVariable("site", $this->site);
         if ($ini->variable('DebugSettings', 'DisplayDebugWarnings') === 'enabled') {
             // Make sure any errors or warnings are reported
             if (isset($GLOBALS['eZDebugError']) && $GLOBALS['eZDebugError']) {
                 eZAppendWarningItem(array('error' => array('type' => 'error', 'number' => 1, 'count' => $GLOBALS['eZDebugErrorCount']), 'identifier' => 'ezdebug-first-error', 'text' => ezpI18n::tr('index.php', 'Some errors occurred, see debug for more information.')));
             }
             if (isset($GLOBALS['eZDebugWarning']) && $GLOBALS['eZDebugWarning']) {
                 eZAppendWarningItem(array('error' => array('type' => 'warning', 'number' => 1, 'count' => $GLOBALS['eZDebugWarningCount']), 'identifier' => 'ezdebug-first-warning', 'text' => ezpI18n::tr('index.php', 'Some general warnings occured, see debug for more information.')));
             }
         }
         if ($this->siteBasics['user-object-required']) {
             $currentUser = eZUser::currentUser();
             $tpl->setVariable("current_user", $currentUser);
             $tpl->setVariable("anonymous_user_id", $ini->variable('UserSettings', 'AnonymousUserID'));
         } else {
             $tpl->setVariable("current_user", false);
             $tpl->setVariable("anonymous_user_id", false);
         }
         $tpl->setVariable("access_type", $this->access);
         $tpl->setVariable('warning_list', !empty($this->warningList) ? $this->warningList : false);
         $resource = "design:";
         if (is_string($this->siteBasics['show-page-layout'])) {
             if (strpos($this->siteBasics['show-page-layout'], ":") !== false) {
                 $resource = "";
             }
         } else {
             $this->siteBasics['show-page-layout'] = "pagelayout.tpl";
         }
         // Set the navigation part
         // Check for navigation part settings
         $navigationPartString = 'ezcontentnavigationpart';
         if (isset($moduleResult['navigation_part'])) {
             $navigationPartString = $moduleResult['navigation_part'];
             // Fetch the navigation part
         }
         $navigationPart = eZNavigationPart::fetchPartByIdentifier($navigationPartString);
         $tpl->setVariable('navigation_part', $navigationPart);
         $tpl->setVariable('uri_string', $this->uri->uriString());
         if (isset($moduleResult['requested_uri_string'])) {
             $tpl->setVariable('requested_uri_string', $moduleResult['requested_uri_string']);
         } else {
             $tpl->setVariable('requested_uri_string', $this->actualRequestedURI);
         }
         // Set UI context and component
         $tpl->setVariable('ui_context', $moduleResult['ui_context']);
         $tpl->setVariable('ui_component', $moduleResult['ui_component']);
         $templateResult = $tpl->fetch($resource . $this->siteBasics['show-page-layout']);
     } else {
         $templateResult = $moduleResult['content'];
     }
     eZDebug::addTimingPoint("Script end");
     $content = trim(ob_get_clean());
     ob_start();
     eZDB::checkTransactionCounter();
     eZDisplayResult($templateResult);
     $content .= ob_get_clean();
     $this->shutdown();
     return new ezpKernelResult($content);
 }
 static function generateStatistics($as_html = true)
 {
     $statStartTime = microtime(true);
     $stats = '';
     if (!eZTemplate::isTemplatesUsageStatisticsEnabled()) {
         return $stats;
     }
     if ($as_html) {
         $stats .= "<h2>Templates used to render the page:</h2>";
         $stats .= "<table id='templateusage' summary='List of used templates' style='border: 1px dashed black;' cellspacing='0'>" . "<tr><th>Usage count</th>" . "<th>Requested template</th>" . "<th>Template</th>" . "<th>Template loaded</th>" . "<th>Edit</th>" . "<th>Override</th></tr>";
     } else {
         $formatString = "%-40s%-40s%-40s\n";
         $stats .= "Templates usage statistics\n";
         $stats .= sprintf($formatString, 'Templates', 'Requested template', 'Template loaded');
     }
     if ($as_html) {
         $iconSizeX = 16;
         $iconSizeY = 16;
         $templateViewFunction = 'visual/templateview';
         eZURI::transformURI($templateViewFunction);
         $templateEditFunction = 'visual/templateedit';
         eZURI::transformURI($templateEditFunction);
         $templateOverrideFunction = 'visual/templatecreate';
         eZURI::transformURI($templateOverrideFunction);
         $std_base = eZTemplateDesignResource::designSetting('standard');
         $wwwDir = eZSys::wwwDir();
         $editIconFile = "{$wwwDir}/design/{$std_base}/images/edit.gif";
         $overrideIconFile = "{$wwwDir}/design/{$std_base}/images/override-template.gif";
         $tdClass = 'used_templates_stats1';
         $j = 0;
         $currentSiteAccess = $GLOBALS['eZCurrentAccess']['name'];
     }
     $templatesUsageStatistics = eZTemplate::templatesUsageStatistics();
     $alreadyListedTemplate = $templateCounts = array();
     //Generate usage count for each unique template first.
     foreach ($templatesUsageStatistics as $templateInfo) {
         $actualTemplateName = $templateInfo['actual-template-name'];
         if (!array_key_exists($actualTemplateName, $templateCounts)) {
             $templateCounts[$actualTemplateName] = 1;
         } else {
             ++$templateCounts[$actualTemplateName];
         }
     }
     //Then create the actual listing
     foreach ($templatesUsageStatistics as $templateInfo) {
         $actualTemplateName = $templateInfo['actual-template-name'];
         $requestedTemplateName = $templateInfo['requested-template-name'];
         $templateFileName = $templateInfo['template-filename'];
         if (!in_array($actualTemplateName, $alreadyListedTemplate)) {
             $alreadyListedTemplate[] = $actualTemplateName;
             if ($as_html) {
                 $tdClass = $j % 2 == 0 ? 'used_templates_stats1' : 'used_templates_stats2';
                 $requestedTemplateViewURI = $templateViewFunction . '/' . $requestedTemplateName;
                 $actualTemplateViewURI = $templateViewFunction . '/' . $actualTemplateName;
                 $templateEditURI = $templateEditFunction . '/' . $templateFileName;
                 $templateOverrideURI = $templateOverrideFunction . '/' . $actualTemplateName;
                 $actualTemplateNameOutput = $actualTemplateName == $requestedTemplateName ? "<span style=\"font-style: italic;\">&lt;No override&gt;</span>" : $actualTemplateName;
                 $stats .= "<tr><td class=\"{$tdClass}\" style=\"text-align: center;\">{$templateCounts[$actualTemplateName]}</td>" . "<td class=\"{$tdClass}\"><a href=\"{$requestedTemplateViewURI}\">{$requestedTemplateName}</a></td>" . "<td class=\"{$tdClass}\">{$actualTemplateNameOutput}</td>" . "<td class=\"{$tdClass}\">{$templateFileName}</td>" . "<td class=\"{$tdClass}\" align=\"center\"><a href=\"{$templateEditURI}/(siteAccess)/{$currentSiteAccess}\"><img src=\"{$editIconFile}\" width=\"{$iconSizeX}\" height=\"{$iconSizeY}\" alt=\"Edit template\" title=\"Edit template\" /></a></td>" . "<td class=\"{$tdClass}\" align=\"center\"><a href=\"{$templateOverrideURI}/(siteAccess)/{$currentSiteAccess}\"><img src=\"{$overrideIconFile}\" width=\"{$iconSizeX}\" height=\"{$iconSizeY}\" alt=\"Override template\" title=\"Override template\" /></a></td></tr>";
                 $j++;
             } else {
                 $stats .= sprintf($formatString, $requestedTemplateName, $actualTemplateName, $templateFileName);
             }
         }
     }
     $totalTemplatesCount = count($templatesUsageStatistics);
     $totalUniqueTemplatesCopunt = count(array_keys($alreadyListedTemplate));
     $statEndTime = microtime(true);
     $timeUsage = number_format($statEndTime - $statStartTime, 4);
     if ($as_html) {
         $stats .= "<tr><td class=\"{$tdClass}\">&nbsp;</td>" . "<td class=\"{$tdClass}\">&nbsp;</td>" . "<td class=\"{$tdClass}\">&nbsp;</td>" . "<td class=\"{$tdClass}\">&nbsp;</td>" . "<td class=\"{$tdClass}\">&nbsp;</td>" . "<td class=\"{$tdClass}\">&nbsp;</td></tr>";
         $stats .= "<tr><td colspan=\"2\" style=\"text-align: left;\"><b>&nbsp;Number of times templates used: {$totalTemplatesCount}<br />&nbsp;Number of unique templates used: {$totalUniqueTemplatesCopunt}</b></td></tr>";
         $stats .= "<tr><td colspan=\"2\" style=\"text-align: left;\"><b>&nbsp;Time used to render template usage: {$timeUsage} secs</b></td></tr>";
         $stats .= "</table>";
     } else {
         $stats .= "\nTotal templates count: " . $totalTemplatesCount . "\n" . "Total unique templates count: " . $totalUniqueTemplatesCopunt . "\n";
     }
     return $stats;
 }
Ejemplo n.º 12
0
    public static function getServerURL()
    {
        if ( self::$serverURL === null  )
        {
            $oeini = eZINI::instance( 'ezoe.ini' );
            if ( $oeini->hasVariable( 'SystemSettings', 'RelativeURL' ) &&
                 $oeini->variable( 'SystemSettings', 'RelativeURL' ) === 'enabled' )
            {
                self::$serverURL = eZSys::wwwDir();
                if ( self::$serverURL === '/'  )
                    self::$serverURL = '';
            }
            else
            {
                $domain = eZSys::hostname();
                $protocol = 'http';

                // Default to https if SSL is enabled
                // Check if SSL port is defined in site.ini
                $sslPort = 443;
                $ini = eZINI::instance();
                if ( $ini->hasVariable( 'SiteSettings', 'SSLPort' ) )
                    $sslPort = $ini->variable( 'SiteSettings', 'SSLPort' );

                if ( eZSys::serverPort() == $sslPort )
                    $protocol = 'https';

                self::$serverURL = $protocol . '://' . $domain . eZSys::wwwDir();
            }
        }
        return self::$serverURL;
    }
Ejemplo n.º 13
0
 /**
  * Internal function to get current index dir
  *
  * @return string
  */
 protected static function getDesignFile($file)
 {
     static $bases = null;
     static $wwwDir = null;
     if ($bases === null) {
         $bases = eZTemplateDesignResource::allDesignBases();
     }
     if ($wwwDir === null) {
         $wwwDir = eZSys::wwwDir() . '/';
     }
     $triedFiles = array();
     $match = eZTemplateDesignResource::fileMatch($bases, '', $file, $triedFiles);
     if ($match === false) {
         eZDebug::writeWarning("Could not find: {$file}", __METHOD__);
         return false;
     }
     return $wwwDir . htmlspecialchars($match['path']);
 }
 static function generateStatistics($as_html = true)
 {
     $stats = '';
     if (!eZTemplate::isTemplatesUsageStatisticsEnabled()) {
         return $stats;
     }
     if ($as_html) {
         $stats .= "<h3>Templates used to render the page:</h3>";
         $stats .= "<table id='templateusage' class='debug_resource_usage' title='List of used templates'>" . "<tr><th title='Usage count of this particular template'>Usage</th>" . "<th>Requested template</th>" . "<th>Template</th>" . "<th>Template loaded</th>" . "<th>Edit</th>" . "<th>Override</th></tr>";
     } else {
         $formatString = "%-40s%-40s%-40s\n";
         $stats .= "Templates usage statistics\n";
         $stats .= sprintf($formatString, 'Templates', 'Requested template', 'Template loaded');
     }
     if ($as_html) {
         $iconSizeX = 16;
         $iconSizeY = 16;
         $templateViewFunction = 'visual/templateview';
         eZURI::transformURI($templateViewFunction);
         $templateEditFunction = 'visual/templateedit';
         eZURI::transformURI($templateEditFunction);
         $templateOverrideFunction = 'visual/templatecreate';
         eZURI::transformURI($templateOverrideFunction);
         $std_base = eZTemplateDesignResource::designSetting('standard');
         $wwwDir = htmlspecialchars(eZSys::wwwDir(), ENT_COMPAT, 'UTF-8');
         $editIconFile = "{$wwwDir}/design/{$std_base}/images/edit.gif";
         $overrideIconFile = "{$wwwDir}/design/{$std_base}/images/override-template.gif";
         $tdClass = 'used_templates_stats1';
         $j = 0;
         $currentSiteAccess = $GLOBALS['eZCurrentAccess']['name'];
     }
     $templatesUsageStatistics = eZTemplate::templatesUsageStatistics();
     $alreadyListedTemplate = $templateCounts = array();
     //Generate usage count for each unique template first.
     foreach ($templatesUsageStatistics as $templateInfo) {
         $actualTemplateName = $templateInfo['actual-template-name'];
         if (!array_key_exists($actualTemplateName, $templateCounts)) {
             $templateCounts[$actualTemplateName] = 1;
         } else {
             ++$templateCounts[$actualTemplateName];
         }
     }
     //Then create the actual listing
     foreach ($templatesUsageStatistics as $templateInfo) {
         $actualTemplateName = $templateInfo['actual-template-name'];
         $requestedTemplateName = $templateInfo['requested-template-name'];
         $templateFileName = $templateInfo['template-filename'];
         if (!in_array($actualTemplateName, $alreadyListedTemplate)) {
             $alreadyListedTemplate[] = $actualTemplateName;
             if ($as_html) {
                 $requestedTemplateViewURI = $templateViewFunction . '/' . $requestedTemplateName;
                 $actualTemplateViewURI = $templateViewFunction . '/' . $actualTemplateName;
                 $templateEditURI = $templateEditFunction . '/' . $templateFileName;
                 $templateOverrideURI = $templateOverrideFunction . '/' . $actualTemplateName;
                 $actualTemplateNameOutput = $actualTemplateName == $requestedTemplateName ? "<em>&lt;No override&gt;</em>" : $actualTemplateName;
                 $stats .= "<tr class='data'><td>{$templateCounts[$actualTemplateName]}</td>" . "<td><a href=\"{$requestedTemplateViewURI}\">{$requestedTemplateName}</a></td>" . "<td>{$actualTemplateNameOutput}</td>" . "<td>{$templateFileName}</td>" . "<td><a href=\"{$templateEditURI}/(siteAccess)/{$currentSiteAccess}\"><img src=\"{$editIconFile}\" width=\"{$iconSizeX}\" height=\"{$iconSizeY}\" alt=\"Edit template\" title=\"Edit template\" /></a></td>" . "<td><a href=\"{$templateOverrideURI}/(siteAccess)/{$currentSiteAccess}\"><img src=\"{$overrideIconFile}\" width=\"{$iconSizeX}\" height=\"{$iconSizeY}\" alt=\"Override template\" title=\"Override template\" /></a></td></tr>";
                 $j++;
             } else {
                 $stats .= sprintf($formatString, $requestedTemplateName, $actualTemplateName, $templateFileName);
             }
         }
     }
     $totalTemplatesCount = count($templatesUsageStatistics);
     $totalUniqueTemplatesCopunt = count(array_keys($alreadyListedTemplate));
     if ($as_html) {
         $stats .= "<tr><td colspan=\"6\"><b>&nbsp;Number of times templates used: {$totalTemplatesCount}<br />&nbsp;Number of unique templates used: {$totalUniqueTemplatesCopunt}</b></td></tr>";
         $stats .= "</table>";
     } else {
         $stats .= "\nTotal templates count: " . $totalTemplatesCount . "\n" . "Total unique templates count: " . $totalUniqueTemplatesCopunt . "\n";
     }
     return $stats;
 }
Ejemplo n.º 15
0
            $show_page_layout = $moduleResult["pagelayout"];
            $GLOBALS['eZCustomPageLayout'] = $moduleResult["pagelayout"];
        }
        if (isset($moduleResult["external_css"])) {
            $use_external_css = $moduleResult["external_css"];
        }
    }
}
/**
 * Ouput an is_logged_in cookie when users are logged in for use by http cache soulutions.
 *
 * @deprecated As of 4.5, since 4.4 added lazy session support (init on use)
 */
if ($ini->variable("SiteAccessSettings", "CheckValidity") !== 'true') {
    $currentUser = eZUser::currentUser();
    $wwwDir = eZSys::wwwDir();
    // On host based site accesses this can be empty, causing the cookie to be set for the current dir,
    // but we want it to be set for the whole eZ publish site
    $cookiePath = $wwwDir != '' ? $wwwDir : '/';
    if ($currentUser->isLoggedIn()) {
        // Only set the cookie if it doesnt exist. This way we are not constantly sending the set request in the headers.
        if (!isset($_COOKIE['is_logged_in']) || $_COOKIE['is_logged_in'] != 'true') {
            setcookie('is_logged_in', 'true', 0, $cookiePath);
        }
    } else {
        if (isset($_COOKIE['is_logged_in'])) {
            setcookie('is_logged_in', false, 0, $cookiePath);
        }
    }
}
if ($module->exitStatus() == eZModule::STATUS_REDIRECT) {
 public static function getServerURL()
 {
     if (self::$serverURL === null) {
         $oeini = eZINI::instance('ezoe.ini');
         if ($oeini->hasVariable('SystemSettings', 'RelativeURL') && $oeini->variable('SystemSettings', 'RelativeURL') === 'enabled') {
             self::$serverURL = eZSys::wwwDir();
             if (self::$serverURL === '/') {
                 self::$serverURL = '';
             }
         } else {
             $domain = eZSys::hostname();
             $protocol = eZSys::serverProtocol();
             self::$serverURL = $protocol . '://' . $domain . eZSys::wwwDir();
         }
     }
     return self::$serverURL;
 }
Ejemplo n.º 17
0
            }
        } else {
            $step = $stepData->step(0);
            //step contains file and class
        }
    }
}
$done = false;
$result = null;
while (!$done && $step != null) {
    // Some common variables for all steps
    $tpl->setVariable("script", eZSys::serverVariable('PHP_SELF'));
    $siteBasics = $GLOBALS['eZSiteBasics'];
    $useIndex = $siteBasics['validity-check-required'];
    if ($useIndex) {
        $script = eZSys::wwwDir() . eZSys::indexFileName();
    } else {
        $script = eZSys::indexFile() . "/setup/{$partName}";
    }
    $tpl->setVariable('script', $script);
    $tpl->setVariable("version", array("text" => eZPublishSDK::version(), "major" => eZPublishSDK::majorVersion(), "minor" => eZPublishSDK::minorVersion(), "release" => eZPublishSDK::release(), "alias" => eZPublishSDK::alias()));
    if ($persistenceList === null) {
        $persistenceList = eZSetupFetchPersistenceList();
    }
    $tpl->setVariable('persistence_list', $persistenceList);
    // Try to include the relevant file
    $includeFile = $baseDir . 'steps/ezstep_' . $step['file'] . '.php';
    $stepClass = false;
    if (file_exists($includeFile)) {
        include_once $includeFile;
        $className = 'eZStep' . $step['class'];
Ejemplo n.º 18
0
 /**
  * Generate text html of a output for preview and sending email
  *
  * @see classes/cjwnewslettermail.php getAllOutputFormatTextByContentObjectVersion()
  * @see modules/newsletter/preview.php
  * @param unknown_type $editionContentObjectId
  * @param unknown_type $versionId
  * @param unknown_type $outputFormat
  * @param string $siteAccess
  * @param string $skinName
  * @param int $forceImageIncludeSettings -1 - use default settings
  *                                       1 - force do not render all img to file://settings from newsletterContentArray['html_mail_image_include'] will be used
  *                                       0 - force renders all img to file://
  * @return array
  */
 static function getOutput($editionContentObjectId, $versionId, $outputFormat, $siteAccess, $skinName = 'default', $forceSettingImageIncludeTo = -1)
 {
     if ($skinName == '') {
         $skinName = 'default';
     }
     $cjwNewsletterIni = eZINI::instance('cjw_newsletter.ini');
     $phpCli = $cjwNewsletterIni->variable('NewsletterSettings', 'PhpCli');
     $currentHostName = eZSys::hostname();
     $wwwDir = eZSys::wwwDir();
     //$wwwDir = 'tmp';
     $wwwDirString = '';
     if ($wwwDir != '') {
         $wwwDirString = "--www_dir={$wwwDir} ";
     }
     $cmd = "\"{$phpCli}\" extension/cjw_newsletter/bin/php/createoutput.php --object_id={$editionContentObjectId} --object_version={$versionId} --output_format_id={$outputFormat} {$wwwDirString}--current_hostname={$currentHostName} --skin_name={$skinName} -s {$siteAccess}";
     $fileSep = eZSys::fileSeparator();
     $cmd = str_replace('/', $fileSep, $cmd);
     eZDebug::writeDebug("shell_exec( {$cmd} )", 'newsletter/preview');
     // echo "<hr>$cmd<hr>";
     $returnValue = shell_exec(escapeshellcmd($cmd));
     $newsletterContentArray = unserialize(trim($returnValue));
     if (CjwNewsletterEdition::imageIncludeIsEnabled()) {
         $htmlMailImageInclude = 1;
     }
     // forpreview
     $imageInclude = false;
     // render file:// if we want to force it
     // or use setting from $newsletterContentArray['html_mail_image_include']
     if ($forceSettingImageIncludeTo === -1 && $newsletterContentArray['html_mail_image_include'] === 1) {
         $imageInclude = true;
     } elseif ($forceSettingImageIncludeTo === 1) {
         $imageInclude = true;
     } elseif ($forceSettingImageIncludeTo === 0) {
         // $imageInclude = false;
     }
     if ($imageInclude === true) {
         $newsletterContentArray = CjwNewsletterEdition::prepareImageInclude($newsletterContentArray);
     }
     return $newsletterContentArray;
 }
Ejemplo n.º 19
0
    function fetchImageURL()
    {

        $imageNode =  $this->attribute( 'image_node' );
        if ( !$imageNode )
            return false;

        $imageObject =  $imageNode->attribute( 'object' );
        if ( !$imageObject )
            return false;

        $dataMap =  $imageObject->attribute( 'data_map' );
        if ( !$dataMap )
            return false;

        $imageAttribute =  $dataMap['image'];
        if ( !$imageAttribute )
            return false;

        $imageHandler =  $imageAttribute->attribute( 'content' );
        if ( !$imageHandler )
            return false;

        $imageAlias =  $imageHandler->imageAlias( 'rss' );
        if( !$imageAlias )
            return false;

        $url = eZSys::hostname() . eZSys::wwwDir() .'/'. $imageAlias['url'];
        $url = preg_replace( "#^(//)#", "/", $url );

        return 'http://'.$url;
    }
Ejemplo n.º 20
0
$offset = $Params['Offset'];
if (!is_numeric($offset)) {
    $offset = 0;
}
$url = eZURL::fetch($urlID);
if (!$url) {
    return $Module->handleError(eZError::KERNEL_NOT_AVAILABLE, 'kernel');
}
$link = $url->attribute('url');
if (preg_match("/^(http:)/i", $link) or preg_match("/^(ftp:)/i", $link) or preg_match("/^(https:)/i", $link) or preg_match("/^(file:)/i", $link) or preg_match("/^(mailto:)/i", $link)) {
    // No changes
} else {
    $domain = getenv('HTTP_HOST');
    $protocol = eZSys::serverProtocol();
    $preFix = $protocol . "://" . $domain;
    $preFix .= eZSys::wwwDir();
    $link = preg_replace("/^\\//e", "", $link);
    $link = $preFix . "/" . $link;
}
$viewParameters = array('offset' => $offset, 'limit' => $limit);
$http = eZHTTPTool::instance();
$objectList = eZURLObjectLink::fetchObjectVersionList($urlID, $viewParameters);
$urlViewCount = eZURLObjectLink::fetchObjectVersionCount($urlID);
if ($Module->isCurrentAction('EditObject')) {
    if ($http->hasPostVariable('ObjectList')) {
        $versionID = $http->postVariable('ObjectList');
        $version = eZContentObjectVersion::fetch($versionID);
        $contentObjectID = $version->attribute('contentobject_id');
        $versionNr = $version->attribute('version');
        $Module->redirect('content', 'edit', array($contentObjectID, $versionNr));
    }
Ejemplo n.º 21
0
 /**
  * Returns a shared instance of the eZUser class pr $id value.
  * If user can not be fetched, then anonymous user is returned and
  * a warning trown, if anonymous user can not be fetched, then NoUser
  * is returned and another warning is thrown.
  *
  * @param int|false $id On false: Gets current user id from session
  *        or from {@link eZUser::anonymousId()} if not set.
  * @return eZUser
  */
 static function instance($id = false)
 {
     if (!empty($GLOBALS["eZUserGlobalInstance_{$id}"])) {
         return $GLOBALS["eZUserGlobalInstance_{$id}"];
     }
     $userId = $id;
     $currentUser = null;
     $http = eZHTTPTool::instance();
     $anonymousUserID = self::anonymousId();
     $sessionHasStarted = eZSession::hasStarted();
     // If not specified get the current user
     if ($userId === false) {
         if ($sessionHasStarted) {
             $userId = $http->sessionVariable('eZUserLoggedInID');
             if (!is_numeric($userId)) {
                 $userId = $anonymousUserID;
                 eZSession::setUserID($userId);
                 $http->setSessionVariable('eZUserLoggedInID', $userId);
             }
         } else {
             $userId = $anonymousUserID;
             eZSession::setUserID($userId);
         }
     }
     // Check user cache (this effectivly fetches user from cache)
     // user not found if !isset( isset( $userCache['info'][$userId] ) )
     $userCache = self::getUserCacheByUserId($userId);
     if (isset($userCache['info'][$userId])) {
         $userArray = $userCache['info'][$userId];
         if (is_numeric($userArray['contentobject_id'])) {
             $currentUser = new eZUser($userArray);
             $currentUser->setUserCache($userCache);
         }
     }
     $ini = eZINI::instance();
     // Check if:
     // - the user has not logged out,
     // - the user is not logged in,
     // - and if a automatic single sign on plugin is enabled.
     if (!self::$userHasLoggedOut && is_object($currentUser) && !$currentUser->isRegistered()) {
         $ssoHandlerArray = $ini->variable('UserSettings', 'SingleSignOnHandlerArray');
         if (!empty($ssoHandlerArray)) {
             $ssoUser = false;
             foreach ($ssoHandlerArray as $ssoHandler) {
                 $className = 'eZ' . $ssoHandler . 'SSOHandler';
                 if (class_exists($className)) {
                     $impl = new $className();
                     $ssoUser = $impl->handleSSOLogin();
                     // If a user was found via SSO, then use it
                     if ($ssoUser !== false) {
                         $currentUser = $ssoUser;
                         $userId = $currentUser->attribute('contentobject_id');
                         $userInfo = array();
                         $userInfo[$userId] = array('contentobject_id' => $userId, 'login' => $currentUser->attribute('login'), 'email' => $currentUser->attribute('email'), 'password_hash' => $currentUser->attribute('password_hash'), 'password_hash_type' => $currentUser->attribute('password_hash_type'));
                         eZSession::setUserID($userId);
                         $http->setSessionVariable('eZUserLoggedInID', $userId);
                         eZUser::updateLastVisit($userId);
                         eZUser::setCurrentlyLoggedInUser($currentUser, $userId);
                         eZHTTPTool::redirect(eZSys::wwwDir() . eZSys::indexFile(false) . eZSys::requestURI() . eZSys::queryString(), array(), 302);
                         eZExecution::cleanExit();
                     }
                 } else {
                     eZDebug::writeError("Undefined ssoHandler class: {$className}", __METHOD__);
                 }
             }
         }
     }
     if ($userId != $anonymousUserID) {
         $sessionInactivityTimeout = $ini->variable('Session', 'ActivityTimeout');
         if (!isset($GLOBALS['eZSessionIdleTime'])) {
             eZUser::updateLastVisit($userId);
         } else {
             $sessionIdle = $GLOBALS['eZSessionIdleTime'];
             if ($sessionIdle > $sessionInactivityTimeout) {
                 eZUser::updateLastVisit($userId);
             }
         }
     }
     if (!$currentUser) {
         $currentUser = eZUser::fetch(self::anonymousId());
         eZDebug::writeWarning('User not found, returning anonymous');
     }
     if (!$currentUser) {
         $currentUser = new eZUser(array('id' => -1, 'login' => 'NoUser'));
         eZDebug::writeWarning('Anonymous user not found, returning NoUser');
     }
     $GLOBALS["eZUserGlobalInstance_{$id}"] = $currentUser;
     return $currentUser;
 }
Ejemplo n.º 22
0
            //step contains file and class
        }
    }
}
$done = false;
$result = null;
while (!$done && $step != null) {
    // Some common variables for all steps
    $uriPrefix = '';
    if (strpos(eZSys::serverVariable('PHP_SELF'), '/ezsetup')) {
        $uriPrefix = '/ezsetup';
    }
    $siteBasics = $GLOBALS['eZSiteBasics'];
    $useIndex = $siteBasics['validity-check-required'];
    if ($useIndex) {
        $script = eZSys::wwwDir() . eZSys::indexFileName() . $uriPrefix;
    } else {
        $script = eZSys::indexFile() . "{$uriPrefix}/setup/{$partName}";
    }
    $tpl->setVariable('script', $script);
    $tpl->setVariable("version", array("text" => eZPublishSDK::version(), "major" => eZPublishSDK::majorVersion(), "minor" => eZPublishSDK::minorVersion(), "release" => eZPublishSDK::release(), "alias" => eZPublishSDK::alias()));
    if ($persistenceList === null) {
        $persistenceList = eZSetupFetchPersistenceList();
    }
    $tpl->setVariable('persistence_list', $persistenceList);
    // Try to include the relevant file
    $includeFile = $baseDir . 'steps/ezstep_' . $step['file'] . '.php';
    $stepClass = false;
    if (file_exists($includeFile)) {
        include_once $includeFile;
        $className = 'eZStep' . $step['class'];