本文整理汇总了PHP中eZSys::instance方法的典型用法代码示例。如果您正苦于以下问题:PHP eZSys::instance方法的具体用法?PHP eZSys::instance怎么用?PHP eZSys::instance使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类eZSys
的用法示例。
在下文中一共展示了eZSys::instance方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: sendMail
function sendMail(ezcMail $mail)
{
$separator = "/";
$mail->appendExcludeHeaders(array('to', 'subject'));
$headers = rtrim($mail->generateHeaders());
// rtrim removes the linebreak at the end, mail doesn't want it.
if (count($mail->to) + count($mail->cc) + count($mail->bcc) < 1) {
throw new ezcMailTransportException('No recipient addresses found in message header.');
}
$additionalParameters = "";
if (isset($mail->returnPath)) {
$additionalParameters = "-f{$mail->returnPath->email}";
}
$sys = eZSys::instance();
$fname = time() . '-' . rand() . '.mail';
$qdir = eZSys::siteDir() . eZSys::varDirectory() . $separator . 'mailq';
$data = $headers . ezcMailTools::lineBreak();
$data .= ezcMailTools::lineBreak();
$data .= $mail->generateBody();
$data = preg_replace('/(\\r\\n|\\r|\\n)/', "\r\n", $data);
$success = eZFile::create($fname, $qdir, $data);
if ($success === false) {
throw new ezcMailTransportException('The email could not be sent by sendmail');
}
}
示例2: sendMail
function sendMail(eZMail $mail)
{
$ini = eZINI::instance();
$sendmailOptions = '';
$emailFrom = $mail->sender();
$emailSender = isset($emailFrom['email']) ? $emailFrom['email'] : false;
if (!$emailSender || count($emailSender) <= 0) {
$emailSender = $ini->variable('MailSettings', 'EmailSender');
}
if (!$emailSender) {
$emailSender = $ini->variable('MailSettings', 'AdminEmail');
}
if (!eZMail::validate($emailSender)) {
$emailSender = false;
}
$isSafeMode = ini_get('safe_mode') != 0;
$sendmailOptionsArray = $ini->variable('MailSettings', 'SendmailOptions');
if (is_array($sendmailOptionsArray)) {
$sendmailOptions = implode(' ', $sendmailOptionsArray);
} elseif (!is_string($sendmailOptionsArray)) {
$sendmailOptions = $sendmailOptionsArray;
}
if (!$isSafeMode and $emailSender) {
$sendmailOptions .= ' -f' . $emailSender;
}
if ($isSafeMode and $emailSender and $mail->sender() == false) {
$mail->setSenderText($emailSender);
}
if (function_exists('mail')) {
$message = $mail->body();
$sys = eZSys::instance();
$excludeHeaders = array('Subject');
// If not Windows PHP mail() implementation, we can not specify a To: header in the $additional_headers parameter,
// because then there will be 2 To: headers in the resulting e-mail.
// However, we can use "undisclosed-recipients:;" in $to.
if ($sys->osType() != 'win32') {
$excludeHeaders[] = 'To';
$receiverEmailText = count($mail->ReceiverElements) > 0 ? $mail->receiverEmailText() : 'undisclosed-recipients:;';
} else {
$receiverEmailText = $mail->receiverEmailText();
}
// If in debug mode, send to debug email address and nothing else
if ($ini->variable('MailSettings', 'DebugSending') == 'enabled') {
$receiverEmailText = $ini->variable('MailSettings', 'DebugReceiverEmail');
$excludeHeaders[] = 'To';
$excludeHeaders[] = 'Cc';
$excludeHeaders[] = 'Bcc';
}
$extraHeaders = $mail->headerText(array('exclude-headers' => $excludeHeaders));
$returnedValue = mail($receiverEmailText, $mail->subject(), $message, $extraHeaders, $sendmailOptions);
if ($returnedValue === false) {
eZDebug::writeError('An error occurred while sending e-mail. Check the Sendmail error message for further information (usually in /var/log/messages)', __METHOD__);
}
return $returnedValue;
} else {
eZDebug::writeWarning("Unable to send mail: 'mail' function is not compiled into PHP.", __METHOD__);
}
return false;
}
示例3: __construct
public function __construct()
{
$sys = eZSys::instance();
$storage_dir = $sys->storageDirectory();
$this->ArchiveDir = $storage_dir . '/' . $this->ArchiveDirName;
if (!file_exists($this->ArchiveDir)) {
eZDir::mkdir($this->ArchiveDir, false, true);
}
}
示例4: storageDir
function storageDir( $sub_dir = false )
{
$sys = eZSys::instance();
$storage_dir = $sys->storageDirectory();
if ( $sub_dir !== false )
$dir = $storage_dir . "/$sub_dir/" . $this->MimeCategory;
else
$dir = $storage_dir . "/" . $this->MimeCategory;
return $dir;
}
示例5: setUp
public function setUp()
{
parent::setUp();
// Backup previous instance of eZSys (if any) and reset it
$this->oldSysInstance = eZSys::instance();
eZSys::setInstance();
// Set the RequestURI to a known value so that eZSys::requestURI()
// returns something known and useful.
$this->queryString = "?foo=bar&this=that";
eZSys::setServerVariable("REQUEST_URI", "/all/work/and/no/sleep/makes/(ole)/a/(dull)/boy{$this->queryString}");
eZSys::init();
}
示例6: deleteStoredObjectAttribute
function deleteStoredObjectAttribute($contentObjectAttribute, $version = null)
{
$contentObjectAttributeID = $contentObjectAttribute->attribute("id");
$mediaFiles = ezflowMedia::fetch($contentObjectAttributeID, null);
$sys = eZSys::instance();
$storage_dir = $sys->storageDirectory();
if ($version == null) {
foreach ($mediaFiles as $mediaFile) {
$mimeType = $mediaFile->attribute("mime_type");
list($prefix, $suffix) = split('[/]', $mimeType);
// $orig_dir = "var/storage/original/" . $prefix;
$orig_dir = $storage_dir . '/original/' . $prefix;
$fileName = $mediaFile->attribute("filename");
if ($fileName == '') {
continue;
}
$file = eZClusterFileHandler::instance($orig_dir . "/" . $fileName);
if ($file->exists()) {
$file->delete();
}
}
} else {
$count = 0;
$currentBinaryFile = ezflowMedia::fetch($contentObjectAttributeID, $version);
if ($currentBinaryFile != null) {
$mimeType = $currentBinaryFile->attribute("mime_type");
$currentFileName = $currentBinaryFile->attribute("filename");
list($prefix, $suffix) = is_string($mimeType) && $mimeType ? split('[/]', $mimeType) : array(null, null);
// $orig_dir = "var/storage/original/" . $prefix;
$orig_dir = $storage_dir . '/original/' . $prefix;
foreach ($mediaFiles as $mediaFile) {
$fileName = $mediaFile->attribute("filename");
if ($currentFileName == $fileName) {
$count += 1;
}
}
if ($count == 1 && $currentFileName != '') {
$file = eZClusterFileHandler::instance($orig_dir . "/" . $currentFileName);
if ($file->exists()) {
$file->delete();
}
}
}
}
ezflowMedia::removeByID($contentObjectAttributeID, $version);
}
示例7: createMailFile
/**
*
* @param unknown_type $receiver
* @param unknown_type $subject
* @param unknown_type $message
* @param unknown_type $extraHeaders
* @param unknown_type $emailReturnPath
* @return file
*/
function createMailFile($receiver, $subject, $message, $extraHeaders, $emailReturnPath = '')
{
$sys = eZSys::instance();
$lineBreak = $sys->osType() == 'win32' ? "\r\n" : "\n";
// $separator = ($sys->osType() == 'win32' ? "\\" : "/" );
// $fileName = date("Ymd") .'-' .date("His").'-'.rand().'.mail';
$fileName = time() . '-' . rand() . '-cjw_nl.mail';
// $mailDir = eZSys::siteDir().eZSys::varDirectory().'/log/mail';
// $mailDir = eZSys::siteDir().'var/log/mail';
$data = $extraHeaders . $lineBreak;
if ($emailReturnPath != '') {
$data .= "Return-Path: <" . $emailReturnPath . ">" . $lineBreak;
}
$data .= "To: " . $receiver . $lineBreak;
$data .= "Subject: " . $subject . $lineBreak;
// $data .= "From: ".$emailSender.$lineBreak;
$data .= $lineBreak;
$data .= $message;
$data = preg_replace('/(\\r\\n|\\r|\\n)/', "\r\n", $data);
return eZFile::create($fileName, $this->mailDir, $data);
}
示例8: __construct
function __construct()
{
$this->ReceiverElements = array();
$this->MobileElements = array();
$this->From = false;
$this->CcElements = array();
$this->BccElements = array();
$this->ReplyTo = false;
$this->Subject = false;
$this->BodyText = false;
$this->ExtraHeaders = array();
$this->TextCodec = false;
$this->MessageID = false;
$this->Date = false;
// Sets some default values
$version = eZPublishSDK::version();
$this->MIMEVersion = '1.0';
$this->ContentType = array('type' => 'text/plain', 'charset' => eZTextCodec::internalCharset(), 'transfer-encoding' => '8bit', 'disposition' => 'inline', 'boundary' => false);
$this->UserAgent = "eZ publish, Version {$version}";
$ini = eZINI::instance();
// HACK! Ignore system content type
//if ( $ini->hasVariable( 'MailSettings', 'ContentType' ) )
// $this->setContentType( $ini->variable( 'MailSettings', 'ContentType' ) );
if (!defined('EZ_MAIL_LINE_SEPARATOR')) {
$ini = eZINI::instance('site.ini');
$ending = $ini->variable('MailSettings', 'HeaderLineEnding');
if ($ending == 'auto') {
$sys = eZSys::instance();
// For windows we use \r\n which is the endline defined in RFC 2045
if ($sys->osType() == 'win32') {
$separator = "\r\n";
} else {
$separator = "\n";
}
} else {
$separator = urldecode($ending);
}
define('EZ_MAIL_LINE_SEPARATOR', $separator);
}
}
示例9: transformURI
/**
* Implementation of an 'ezurl' template operator
* Makes valid eZ Publish urls to use in links
*
* @param string &$href
* @param boolean $ignoreIndexDir
* @param string $serverURL full|relative
* @return string the link to use
*/
public static function transformURI(&$href, $ignoreIndexDir = false, $serverURL = null)
{
if ($serverURL === null) {
$serverURL = self::$transformURIMode;
}
if (preg_match("#^[a-zA-Z0-9]+:#", $href) || substr($href, 0, 2) == '//') {
return false;
}
if (strlen($href) == 0) {
$href = '/';
} else {
if ($href[0] == '#') {
$href = htmlspecialchars($href);
return true;
} else {
if ($href[0] != '/') {
$href = '/' . $href;
}
}
}
$sys = eZSys::instance();
$dir = !$ignoreIndexDir ? $sys->indexDir() : $sys->wwwDir();
$serverURL = $serverURL === 'full' ? $sys->serverURL() : '';
$href = $serverURL . $dir . $href;
if (!$ignoreIndexDir) {
$href = preg_replace("#^(//)#", "/", $href);
$href = preg_replace("#(^.*)(/+)\$#", "\$1", $href);
}
$href = str_replace('&amp;', '&', htmlspecialchars($href));
if ($href == "") {
$href = "/";
}
return true;
}
示例10: fetchNodeInfo
function fetchNodeInfo( &$node )
{
// When finished, we'll return an array of attributes/properties.
$entry = array();
// Grab settings from the ini file:
$webdavINI = eZINI::instance( eZWebDAVContentServer::WEBDAV_INI_FILE );
$iniSettings = $webdavINI->variable( 'DisplaySettings', 'FileAttribute' );
$classIdentifier = $node->attribute( 'class_identifier' );
$object = $node->attribute( 'object' );
// By default, everything is displayed as a folder:
// Trim the name of the node, it is in some cases whitespace in eZ Publish
$entry["name"] = trim( $node->attribute( 'name' ) );
$entry["size"] = 0;
$entry["mimetype"] = 'httpd/unix-directory';
$entry["ctime"] = $object->attribute( 'published' );
$entry["mtime"] = $object->attribute( 'modified' );
$upload = new eZContentUpload();
$info = $upload->objectFileInfo( $object );
$suffix = '';
$class = $object->contentClass();
$isObjectFolder = $this->isObjectFolder( $object, $class );
if ( $isObjectFolder )
{
// We do nothing, the default is to see it as a folder
}
else if ( $info )
{
$filePath = $info['filepath'];
$entry["mimetype"] = false;
$entry["size"] = false;
if ( isset( $info['filesize'] ) )
$entry['size'] = $info['filesize'];
if ( isset( $info['mime_type'] ) )
$entry['mimetype'] = $info['mime_type'];
// Fill in information from the actual file if they are missing.
$file = eZClusterFileHandler::instance( $filePath );
if ( !$entry['size'] and $file->exists() )
{
$entry["size"] = $file->size();
}
if ( !$entry['mimetype'] )
{
$mimeInfo = eZMimeType::findByURL( $filePath );
$entry["mimetype"] = $mimeInfo['name'];
$suffix = $mimeInfo['suffix'];
if ( strlen( $suffix ) > 0 )
$entry["name"] .= '.' . $suffix;
}
else
{
// eZMimeType returns first suffix in its list
// this could be another one than the original file extension
// so let's try to get the suffix from the file path first
$suffix = eZFile::suffix( $filePath );
if ( !$suffix )
{
$mimeInfo = eZMimeType::findByName( $entry['mimetype'] );
$suffix = $mimeInfo['suffix'];
}
if ( strlen( $suffix ) > 0 )
$entry["name"] .= '.' . $suffix;
}
if ( $file->exists() )
{
$entry["ctime"] = $file->mtime();
$entry["mtime"] = $file->mtime();
}
}
else
{
// Here we only show items as folders if they have
// is_container set to true, otherwise it's an unknown binary file
if ( !$class->attribute( 'is_container' ) )
{
$entry['mimetype'] = 'application/octet-stream';
}
}
$scriptURL = eZSys::instance()->RequestURI;
if ( strlen( $scriptURL ) > 0 and $scriptURL[ strlen( $scriptURL ) - 1 ] != "/" )
$scriptURL .= "/";
$trimmedScriptURL = trim( $scriptURL, '/' );
$scriptURLParts = explode( '/', $trimmedScriptURL );
$siteAccess = $scriptURLParts[0];
$virtualFolder = $scriptURLParts[1];
$startURL = '/' . $siteAccess . '/' . $virtualFolder . '/';
// Set the href attribute (note that it doesn't just equal the name).
if ( !isset( $entry['href'] ) )
//.........这里部分代码省略.........
示例11: lineSeparator
static function lineSeparator()
{
$ini = eZINI::instance( 'site.ini' );
$ending = $ini->variable( 'MailSettings', 'HeaderLineEnding' );
if ( $ending == 'auto' )
{
$sys = eZSys::instance();
// For windows we use \r\n which is the endline defined in RFC 2045
if ( $sys->osType() == 'win32' )
{
$separator = "\r\n";
}
else // for linux/unix/mac we use \n only due to some mail transfer agents destroying
// emails containing \r\n
{
$separator = "\n";
}
}
else
{
$separator = urldecode( $ending );
}
return $separator;
}
示例12: setInstance
/**
* Sets eZSys instance or clears it if left undefined.
*
* @param eZSys $instance
*/
public static function setInstance( eZSys $instance = null )
{
self::$instance = $instance;
}
示例13: generateTag
/**
* generateTag
* @param array $files
* @return string $html
*/
private function generateTag($files)
{
eZDebug::writeDebug($files, 'ezLessOperator::generateTag');
$html = $cssContent = '';
$ini = eZINI::instance('ezless.ini');
$compileMethod = trim($ini->variable('ezlessconfig', 'CompileMethod'));
$useOneFile = $ini->variable('ezlessconfig', 'useOneFile');
// ToDo: siteaccess as parameter
$bases = eZTemplateDesignResource::allDesignBases();
$triedFiles = array();
$importsTried = array();
if ($compileMethod === 'javascript') {
foreach ($files as $file) {
$match = eZTemplateDesignResource::fileMatch($bases, '', 'stylesheets/' . $file, $triedFiles);
if ($match) {
$path = "/{$match['path']}";
$html .= "<link rel=\"stylesheet/less\" type=\"text/css\" href=\"{$path}\">" . PHP_EOL;
}
}
$lessJSFilename = $ini->variable('ezlessconfig', 'LessJSFile');
$lookForLessJS = eZTemplateDesignResource::fileMatch($bases, '', 'javascript/' . $lessJSFilename, $triedFiles);
if (!$lookForLessJS) {
eZDebug::writeDebug("Using LessJS mode but unable to find less.js (LessJSFile={$lessJSFilename}).\nTried files : " . implode("\n", $triedFiles), __CLASS__ . "::" . __FUNCTION__);
} else {
$path = "/{$lookForLessJS['path']}";
$html .= "<script src=\"{$path}\" type=\"text/javascript\" ></script>" . PHP_EOL;
}
return $html;
} elseif ($compileMethod === 'lessphp') {
$sys = eZSys::instance();
$path = $sys->cacheDirectory() . '/public/stylesheets';
require_once dirname(__FILE__) . '/../lib/lessphp/lessc.inc.php';
$packerLevel = $this->getPackerLevel();
$less = new lessc();
foreach ($bases as $base) {
$less->importDir[] = $base . DIRECTORY_SEPARATOR . 'stylesheets';
}
$importContent = "";
$importCss = "";
if (count(self::$imports) > 0) {
foreach (self::$imports as $import) {
$match = eZTemplateDesignResource::fileMatch($bases, '', 'stylesheets/' . $import, $importsTried);
$importCss = file_get_contents($match['path']);
$importContent .= $importCss;
}
}
foreach ($files as $file) {
$match = eZTemplateDesignResource::fileMatch($bases, '', 'stylesheets/' . $file, $triedFiles);
$content = file_get_contents($match['path']);
$content = ezjscPacker::fixImgPaths($content, $match['path']);
if ($useOneFile == "true") {
$cssContent .= $content;
} else {
try {
$parsedContent = $less->parse($importContent . $content);
if ($packerLevel > 1) {
$parsedContent = $this->optimizeCSS($parsedContent, $packerLevel);
}
// $file = md5(uniqid(mt_rand(), true)) . ".css";
$file = substr($file, 0, -4) . 'css';
// we wan't to know what's the name of the less file on the browser
$file = $path . '/' . $file;
$clusterFile = eZClusterFileHandler::instance($file);
$clusterFile->storeContents($parsedContent, 'ezless', 'text/css');
eZURI::transformURI($file, true);
$html .= '<link rel="stylesheet" type="text/css" href="' . $file . '" />' . PHP_EOL;
} catch (Exception $e) {
eZDebug::writeError($e->getMessage(), 'ezLessOperator for ' . $match['path']);
}
}
}
if ($useOneFile == "true") {
$file = md5(uniqid(mt_rand(), true)) . ".css";
try {
$parsedContent = $less->parse($cssContent);
if ($packerLevel > 1) {
$parsedContent = $this->optimizeCSS($parsedContent, $packerLevel);
}
$file = $path . '/' . $file;
$clusterFile = eZClusterFileHandler::instance($file);
$clusterFile->storeContents($parsedContent, 'ezless', 'text/css');
eZURI::transformURI($file, true);
$html = '<link rel="stylesheet" type="text/css" href="' . $file . '" />' . PHP_EOL;
} catch (Exception $e) {
eZDebug::writeError($e->getMessage(), 'ezLessOperator parsing error');
}
}
return $html;
} else {
eZDebug::writeError("Unknown compile method : '{$compileMethod}'", __CLASS__ . "::" . __FUNCTION__);
}
}
示例14: deleteStoredObjectAttribute
function deleteStoredObjectAttribute( $contentObjectAttribute, $version = null )
{
$contentObjectAttributeID = $contentObjectAttribute->attribute( "id" );
$sys = eZSys::instance();
$storage_dir = $sys->storageDirectory();
if ( $version == null )
{
$binaryFiles = eZBinaryFile::fetch( $contentObjectAttributeID );
eZBinaryFile::removeByID( $contentObjectAttributeID, null );
foreach ( $binaryFiles as $binaryFile )
{
$mimeType = $binaryFile->attribute( "mime_type" );
list( $prefix, $suffix ) = explode('/', $mimeType );
$orig_dir = $storage_dir . '/original/' . $prefix;
$fileName = $binaryFile->attribute( "filename" );
// Check if there are any other records in ezbinaryfile that point to that fileName.
$binaryObjectsWithSameFileName = eZBinaryFile::fetchByFileName( $fileName );
$filePath = $orig_dir . "/" . $fileName;
$file = eZClusterFileHandler::instance( $filePath );
if ( $file->exists() and count( $binaryObjectsWithSameFileName ) < 1 )
$file->delete();
}
}
else
{
$count = 0;
$binaryFile = eZBinaryFile::fetch( $contentObjectAttributeID, $version );
if ( $binaryFile != null )
{
$mimeType = $binaryFile->attribute( "mime_type" );
list( $prefix, $suffix ) = explode('/', $mimeType );
$orig_dir = $storage_dir . "/original/" . $prefix;
$fileName = $binaryFile->attribute( "filename" );
eZBinaryFile::removeByID( $contentObjectAttributeID, $version );
// Check if there are any other records in ezbinaryfile that point to that fileName.
$binaryObjectsWithSameFileName = eZBinaryFile::fetchByFileName( $fileName );
$filePath = $orig_dir . "/" . $fileName;
$file = eZClusterFileHandler::instance( $filePath );
if ( $file->exists() and count( $binaryObjectsWithSameFileName ) < 1 )
$file->delete();
}
}
}
示例15: createFile
function createFile($message)
{
$sys = eZSys::instance();
$lineBreak = $sys->osType() == 'win32' ? "\r\n" : "\n";
$separator = $sys->osType() == 'win32' ? "\\" : "/";
$fname = time() . '-' . rand() . '.sms';
$qdir = eZSys::siteDir() . eZSys::varDirectory() . $separator . 'mailq';
$data = $message;
$data = preg_replace('/(\\r\\n|\\r|\\n)/', "\r\n", $data);
// echo 'eZFile::create('.$fname.', '.$qdir.', '.$data.');';
eZFile::create($fname, $qdir, $data);
}