本文整理汇总了PHP中eZSys类的典型用法代码示例。如果您正苦于以下问题:PHP eZSys类的具体用法?PHP eZSys怎么用?PHP eZSys使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了eZSys类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: writeAudit
/**
* Writes $auditName with $auditAttributes as content
* to file name that will be fetched from ini settings by auditNameSettings() for logging.
*
* @param string $auditName
* @param array $auditAttributes
* @return bool
*/
static function writeAudit( $auditName, $auditAttributes = array() )
{
$enabled = eZAudit::isAuditEnabled();
if ( !$enabled )
return false;
$auditNameSettings = eZAudit::auditNameSettings();
if ( !isset( $auditNameSettings[$auditName] ) )
return false;
$ip = eZSys::clientIP();
if ( !$ip )
$ip = eZSys::serverVariable( 'HOSTNAME', true );
$user = eZUser::currentUser();
$userID = $user->attribute( 'contentobject_id' );
$userLogin = $user->attribute( 'login' );
$message = "[$ip] [$userLogin:$userID]\n";
foreach ( array_keys( $auditAttributes ) as $attributeKey )
{
$attributeValue = $auditAttributes[$attributeKey];
$message .= "$attributeKey: $attributeValue\n";
}
$logName = $auditNameSettings[$auditName]['file_name'];
$dir = $auditNameSettings[$auditName]['dir'];
eZLog::write( $message, $logName, $dir );
return true;
}
示例2: __construct
public function __construct()
{
$this->cacheSettings = array('path' => eZSys::cacheDirectory() . '/' . static::$cacheDirectory . '/', 'ttl' => 60);
$this->debugAccumulatorGroup = 'nxc_social_networks_feed_';
$this->debugAccumulatorGroup .= strtolower(str_replace(__CLASS__, '', get_called_class()));
eZDebug::createAccumulatorGroup($this->debugAccumulatorGroup, static::$debugMessagesGroup);
}
示例3: getDataMember
/**
* Returns part of the data for the attribute
*
* @param string $dataMember
*
* @return string
*/
public function getDataMember($dataMember)
{
if ($dataMember === 'related_images') {
$images = array();
$relations = $this->ContentObjectAttribute->attribute('content');
foreach ($relations['relation_list'] as $relation) {
$object = eZContentObject::fetch($relation['contentobject_id']);
if ($object instanceof eZContentObject) {
$dataMap = $object->attribute('data_map');
foreach ($dataMap as $attribute) {
/** @var eZContentObjectAttribute $attribute */
if ($attribute->attribute('data_type_string') !== eZImageType::DATA_TYPE_STRING) {
continue;
}
if ($attribute->hasContent()) {
$imageAliasHandler = $attribute->attribute('content');
$imageAlias = $imageAliasHandler->imageAlias('opengraph');
if ($imageAlias['is_valid'] == 1) {
$images[] = eZSys::serverURL() . '/' . $imageAlias['full_path'];
}
}
}
}
}
if (empty($images)) {
$images[] = eZSys::serverURL() . eZURLOperator::eZImage(null, 'opengraph_default_image.png', '');
}
return $images;
}
return $this->getData();
}
示例4: sendConfirmation
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);
}
示例5: eZTemplateImageOperator
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;
}
示例6: filePathForBinaryFile
function filePathForBinaryFile($fileName, $mimeType)
{
$storageDir = eZSys::storageDirectory();
list($group, $type) = explode('/', $mimeType);
$filePath = $storageDir . '/original/' . $group . '/' . $fileName;
return $filePath;
}
示例7: reCAPTCHAValidate
static function reCAPTCHAValidate($http)
{
// check if the current user is able to bypass filling in the captcha and
// return true without checking if so
$currentUser = eZUser::currentUser();
$accessAllowed = $currentUser->hasAccessTo('recaptcha', 'bypass_captcha');
if ($accessAllowed["accessWord"] == 'yes') {
return true;
}
$ini = eZINI::instance('recaptcha.ini');
// If PrivateKey is an array try and find a match for the current host
$privatekey = $ini->variable('Keys', 'PrivateKey');
if (is_array($privatekey)) {
$hostname = eZSys::hostname();
if (isset($privatekey[$hostname])) {
$privatekey = $privatekey[$hostname];
} else {
// try our luck with the first entry
$privatekey = array_shift($privatekey);
}
}
$recaptcha_challenge_field = $http->postVariable('recaptcha_challenge_field');
$recaptcha_response_field = $http->postVariable('recaptcha_response_field');
$resp = recaptcha_check_answer($privatekey, $_SERVER["REMOTE_ADDR"], $recaptcha_challenge_field, $recaptcha_response_field);
return $resp->is_valid;
}
示例8: eZSurveyFile
function eZSurveyFile($row = false)
{
$bfsf_ini = eZINI::instance('bfsurveyfile.ini');
$varPath = eZSys::storageDirectory();
$survey_object_id = 0;
//get survey object (lookup object ID, as the survey_id changes with each edit)
$survey = new eZSurveyType();
$surveyObject = $survey->fetchSurveyByID($row['survey_id']);
if ($surveyObject) {
$survey_object_id = $surveyObject->attribute('contentobject_id');
}
//set directory paths
$surveyUploadDir = self::UPLOAD_DIR_BASE . '/' . self::UPLOAD_DIR_PREFIX . $survey_object_id . '/';
// syntax example: surveryfiles/survey_123/
$this->uploadPath = $varPath . '/' . $surveyUploadDir;
//create directory if NOT exists
if (!is_dir($this->uploadPath)) {
mkdir($this->uploadPath, 0777, true);
}
//TODO: error if directory cannot be created
//set allowed file extensions
$allowedExtensions = $bfsf_ini->variable('SurveyFile', 'AllowedExtensions');
if (isset($allowedExtensions)) {
$this->allowedExtensions = $allowedExtensions;
}
//set max file size
$sizeLimit = $bfsf_ini->variable('SurveyFile', 'MaxFileSize');
$row['type'] = 'File';
if (!isset($row['mandatory'])) {
$row['mandatory'] = 0;
}
$this->eZSurveyQuestion($row);
}
示例9: 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');
}
}
示例10: getPHPCreatorInstance
/**
* @deprecated since 2.1
* Get instance of PHPCreator to use for storing and loading
* look up table.
*
* @return eZPHPCreator return instance of eZPHPCreator
* @todo Refactor with ezcPhpGenerator
* http://ezcomponents.org/docs/api/trunk/classtrees_PhpGenerator.html
*/
protected function getPHPCreatorInstance()
{
if (empty(self::$PHPCreator)) {
self::$PHPCreator = new eZPHPCreator(eZDIR::path(array(eZSys::storageDirectory(), ezfSolrDocumentFieldName::LOOKUP_FILEDIR)), ezfSolrDocumentFieldName::LOOKUP_FILENAME);
}
return self::$PHPCreator;
}
示例11: modify
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;
}
}
示例12: modify
function modify(&$tpl, &$operatorName, &$operatorParameters, &$rootNamespace, &$currentNamespace, &$operatorValue, &$namedParameters)
{
switch ($operatorName) {
case 'recaptcha_get_html':
include_once 'extension/recaptcha/classes/recaptchalib.php';
// Retrieve the reCAPTCHA public key from the ini file
$ini = eZINI::instance('recaptcha.ini');
$key = $ini->variable('Keys', 'PublicKey');
if (is_array($key)) {
$hostname = eZSys::hostname();
if (isset($key[$hostname])) {
$key = $key[$hostname];
} else {
// try our luck with the first entry
$key = array_shift($key);
}
}
// check if the current user is able to bypass filling in the captcha and
// return nothing so that no captcha is displayed
$currentUser = eZUser::currentUser();
$accessAllowed = $currentUser->hasAccessTo('recaptcha', 'bypass_captcha');
if ($accessAllowed["accessWord"] == 'yes') {
$operatorValue = 'User bypasses CAPTCHA';
} else {
// Run the HTML generation code from the reCAPTCHA PHP library
$operatorValue = recaptcha_get_html($key);
}
break;
}
}
示例13: extension_path
/**
* 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;
}
示例14: 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;
}
示例15: __construct
/**
* Constructor
*/
function __construct()
{
$this->Timestamps = array();
$this->IsModified = false;
$cacheDirectory = eZSys::cacheDirectory();
$this->CacheFile = eZClusterFileHandler::instance($cacheDirectory . '/' . 'expiry.php');
$this->restore();
}