repo stringlengths 6 63 | path stringlengths 5 140 | func_name stringlengths 3 151 | original_string stringlengths 84 13k | language stringclasses 1
value | code stringlengths 84 13k | code_tokens list | docstring stringlengths 3 47.2k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 91 247 | partition stringclasses 1
value |
|---|---|---|---|---|---|---|---|---|---|---|---|
ezsystems/ezpublish-legacy | extension/ezoe/ezxmltext/handlers/input/ezoexmlinput.php | eZOEXMLInput.sectionLevel | function sectionLevel( &$sectionLevel, $headerLevel, &$TagStack, &$currentNode, &$domDocument )
{
if ( $sectionLevel < $headerLevel )
{
if ( $this->IsStrictHeader )
{
$sectionLevel += 1;
}
else
{
if ( ( $sectionLevel + 1 ) == $headerLevel )
{
$sectionLevel += 1;
}
else
{
for ( $i = 1; $i <= ( $headerLevel - $sectionLevel - 1 ); $i++ )
{
// Add section tag
unset( $subNode );
$subNode = new DOMElemenetNode( 'section' );
$currentNode->appendChild( $subNode );
$childTag = $this->SectionArray;
$TagStack[] = array( 'TagName' => 'section',
'ParentNodeObject' => &$currentNode,
'ChildTag' => $childTag );
$currentNode = $subNode;
}
$sectionLevel = $headerLevel;
}
}
}
elseif ( $sectionLevel == $headerLevel )
{
$lastNodeArray = array_pop( $TagStack );
$lastNode = $lastNodeArray['ParentNodeObject'];
$currentNode = $lastNode;
$sectionLevel = $headerLevel;
}
else
{
for ( $i = 1; $i <= ( $sectionLevel - $headerLevel + 1 ); $i++ )
{
$lastNodeArray = array_pop( $TagStack );
$lastTag = $lastNodeArray['TagName'];
$lastNode = $lastNodeArray['ParentNodeObject'];
$lastChildTag = $lastNodeArray['ChildTag'];
$currentNode = $lastNode;
}
$sectionLevel = $headerLevel;
}
return $currentNode;
} | php | function sectionLevel( &$sectionLevel, $headerLevel, &$TagStack, &$currentNode, &$domDocument )
{
if ( $sectionLevel < $headerLevel )
{
if ( $this->IsStrictHeader )
{
$sectionLevel += 1;
}
else
{
if ( ( $sectionLevel + 1 ) == $headerLevel )
{
$sectionLevel += 1;
}
else
{
for ( $i = 1; $i <= ( $headerLevel - $sectionLevel - 1 ); $i++ )
{
// Add section tag
unset( $subNode );
$subNode = new DOMElemenetNode( 'section' );
$currentNode->appendChild( $subNode );
$childTag = $this->SectionArray;
$TagStack[] = array( 'TagName' => 'section',
'ParentNodeObject' => &$currentNode,
'ChildTag' => $childTag );
$currentNode = $subNode;
}
$sectionLevel = $headerLevel;
}
}
}
elseif ( $sectionLevel == $headerLevel )
{
$lastNodeArray = array_pop( $TagStack );
$lastNode = $lastNodeArray['ParentNodeObject'];
$currentNode = $lastNode;
$sectionLevel = $headerLevel;
}
else
{
for ( $i = 1; $i <= ( $sectionLevel - $headerLevel + 1 ); $i++ )
{
$lastNodeArray = array_pop( $TagStack );
$lastTag = $lastNodeArray['TagName'];
$lastNode = $lastNodeArray['ParentNodeObject'];
$lastChildTag = $lastNodeArray['ChildTag'];
$currentNode = $lastNode;
}
$sectionLevel = $headerLevel;
}
return $currentNode;
} | [
"function",
"sectionLevel",
"(",
"&",
"$",
"sectionLevel",
",",
"$",
"headerLevel",
",",
"&",
"$",
"TagStack",
",",
"&",
"$",
"currentNode",
",",
"&",
"$",
"domDocument",
")",
"{",
"if",
"(",
"$",
"sectionLevel",
"<",
"$",
"headerLevel",
")",
"{",
"if"... | Get section level and reset curent xml node according to input header. | [
"Get",
"section",
"level",
"and",
"reset",
"curent",
"xml",
"node",
"according",
"to",
"input",
"header",
"."
] | 2493420f527fbc829a8d5bdda402e05d64a20db7 | https://github.com/ezsystems/ezpublish-legacy/blob/2493420f527fbc829a8d5bdda402e05d64a20db7/extension/ezoe/ezxmltext/handlers/input/ezoexmlinput.php#L660-L712 | train |
ezsystems/ezpublish-legacy | extension/ezoe/ezxmltext/handlers/input/ezoexmlinput.php | eZOEXMLInput.customTagIsInline | public static function customTagIsInline( $name )
{
$ini = eZINI::instance( 'content.ini' );
$customInlineTagList = $ini->variable( 'CustomTagSettings', 'IsInline' );
$customInlineIconPath = array();
if ( $ini->hasVariable( 'CustomTagSettings', 'InlineImageIconPath' ) )
{
$customInlineIconPath = $ini->variable(
'CustomTagSettings', 'InlineImageIconPath'
);
}
if ( isset( $customInlineTagList[$name] ) )
{
if ( $customInlineTagList[$name] === 'true' )
{
return true;
}
else if ( $customInlineTagList[$name] === 'image' )
{
if ( isset( $customInlineIconPath[$name] ) )
return $customInlineIconPath[$name];
else
return 'images/tango/image-x-generic22.png';
}
}
return false;
} | php | public static function customTagIsInline( $name )
{
$ini = eZINI::instance( 'content.ini' );
$customInlineTagList = $ini->variable( 'CustomTagSettings', 'IsInline' );
$customInlineIconPath = array();
if ( $ini->hasVariable( 'CustomTagSettings', 'InlineImageIconPath' ) )
{
$customInlineIconPath = $ini->variable(
'CustomTagSettings', 'InlineImageIconPath'
);
}
if ( isset( $customInlineTagList[$name] ) )
{
if ( $customInlineTagList[$name] === 'true' )
{
return true;
}
else if ( $customInlineTagList[$name] === 'image' )
{
if ( isset( $customInlineIconPath[$name] ) )
return $customInlineIconPath[$name];
else
return 'images/tango/image-x-generic22.png';
}
}
return false;
} | [
"public",
"static",
"function",
"customTagIsInline",
"(",
"$",
"name",
")",
"{",
"$",
"ini",
"=",
"eZINI",
"::",
"instance",
"(",
"'content.ini'",
")",
";",
"$",
"customInlineTagList",
"=",
"$",
"ini",
"->",
"variable",
"(",
"'CustomTagSettings'",
",",
"'IsI... | Figgure out if a custom tag is inline or not based on content.ini settings
@param string $name Tag name
@return bool|string Return 'image' path if tag is inline image, otherwise true/false. | [
"Figgure",
"out",
"if",
"a",
"custom",
"tag",
"is",
"inline",
"or",
"not",
"based",
"on",
"content",
".",
"ini",
"settings"
] | 2493420f527fbc829a8d5bdda402e05d64a20db7 | https://github.com/ezsystems/ezpublish-legacy/blob/2493420f527fbc829a8d5bdda402e05d64a20db7/extension/ezoe/ezxmltext/handlers/input/ezoexmlinput.php#L1832-L1859 | train |
ezsystems/ezpublish-legacy | kernel/private/rest/classes/auth/auth_configuration.php | ezpRestAuthConfiguration.shallAuthenticate | private function shallAuthenticate()
{
$shallAuthenticate = true;
if ( eZINI::instance( 'rest.ini' )->variable( 'Authentication', 'RequireAuthentication' ) !== 'enabled' )
{
$shallAuthenticate = false;
}
else
{
$routeFilter = ezpRestRouteFilterInterface::getRouteFilter();
$shallAuthenticate = $routeFilter->shallDoActionWithRoute( $this->info );
}
return $shallAuthenticate;
} | php | private function shallAuthenticate()
{
$shallAuthenticate = true;
if ( eZINI::instance( 'rest.ini' )->variable( 'Authentication', 'RequireAuthentication' ) !== 'enabled' )
{
$shallAuthenticate = false;
}
else
{
$routeFilter = ezpRestRouteFilterInterface::getRouteFilter();
$shallAuthenticate = $routeFilter->shallDoActionWithRoute( $this->info );
}
return $shallAuthenticate;
} | [
"private",
"function",
"shallAuthenticate",
"(",
")",
"{",
"$",
"shallAuthenticate",
"=",
"true",
";",
"if",
"(",
"eZINI",
"::",
"instance",
"(",
"'rest.ini'",
")",
"->",
"variable",
"(",
"'Authentication'",
",",
"'RequireAuthentication'",
")",
"!==",
"'enabled'... | Checks if authentication should be requested or not
@return bool | [
"Checks",
"if",
"authentication",
"should",
"be",
"requested",
"or",
"not"
] | 2493420f527fbc829a8d5bdda402e05d64a20db7 | https://github.com/ezsystems/ezpublish-legacy/blob/2493420f527fbc829a8d5bdda402e05d64a20db7/kernel/private/rest/classes/auth/auth_configuration.php#L95-L109 | train |
ezsystems/ezpublish-legacy | kernel/classes/datatypes/ezbinaryfile/ezbinaryfiletype.php | eZBinaryFileType.isDeletingFile | private function isDeletingFile( eZHTTPTool $http, eZContentObjectAttribute $contentObjectAttribute )
{
$isDeletingFile = false;
if ( $http->hasPostVariable( 'CustomActionButton' ) )
{
$customActionArray = $http->postVariable( 'CustomActionButton' );
$attributeID = $contentObjectAttribute->attribute( 'id' );
if ( isset( $customActionArray[$attributeID . '_delete_binary'] ) )
{
$isDeletingFile = true;
}
}
return $isDeletingFile;
} | php | private function isDeletingFile( eZHTTPTool $http, eZContentObjectAttribute $contentObjectAttribute )
{
$isDeletingFile = false;
if ( $http->hasPostVariable( 'CustomActionButton' ) )
{
$customActionArray = $http->postVariable( 'CustomActionButton' );
$attributeID = $contentObjectAttribute->attribute( 'id' );
if ( isset( $customActionArray[$attributeID . '_delete_binary'] ) )
{
$isDeletingFile = true;
}
}
return $isDeletingFile;
} | [
"private",
"function",
"isDeletingFile",
"(",
"eZHTTPTool",
"$",
"http",
",",
"eZContentObjectAttribute",
"$",
"contentObjectAttribute",
")",
"{",
"$",
"isDeletingFile",
"=",
"false",
";",
"if",
"(",
"$",
"http",
"->",
"hasPostVariable",
"(",
"'CustomActionButton'",... | Checks if current HTTP request is asking for current binary file deletion
@param eZHTTPTool $http
@param eZContentObjectAttribute $contentObjectAttribute
@return bool | [
"Checks",
"if",
"current",
"HTTP",
"request",
"is",
"asking",
"for",
"current",
"binary",
"file",
"deletion"
] | 2493420f527fbc829a8d5bdda402e05d64a20db7 | https://github.com/ezsystems/ezpublish-legacy/blob/2493420f527fbc829a8d5bdda402e05d64a20db7/kernel/classes/datatypes/ezbinaryfile/ezbinaryfiletype.php#L753-L767 | train |
ezsystems/ezpublish-legacy | kernel/classes/datatypes/ezuser/ezuser.php | eZUser.store | public function store( $fieldFilters = null )
{
$this->Email = trim( $this->Email );
$userID = $this->attribute( 'contentobject_id' );
// Clear memory cache
unset( $GLOBALS['eZUserObject_' . $userID] );
$GLOBALS['eZUserObject_' . $userID] = $this;
self::purgeUserCacheByUserId( $userID );
if ( $this->Login )
{
parent::store( $fieldFilters );
}
} | php | public function store( $fieldFilters = null )
{
$this->Email = trim( $this->Email );
$userID = $this->attribute( 'contentobject_id' );
// Clear memory cache
unset( $GLOBALS['eZUserObject_' . $userID] );
$GLOBALS['eZUserObject_' . $userID] = $this;
self::purgeUserCacheByUserId( $userID );
if ( $this->Login )
{
parent::store( $fieldFilters );
}
} | [
"public",
"function",
"store",
"(",
"$",
"fieldFilters",
"=",
"null",
")",
"{",
"$",
"this",
"->",
"Email",
"=",
"trim",
"(",
"$",
"this",
"->",
"Email",
")",
";",
"$",
"userID",
"=",
"$",
"this",
"->",
"attribute",
"(",
"'contentobject_id'",
")",
";... | Only stores the entry if it has a Login value
@param mixed|null $fieldFilters | [
"Only",
"stores",
"the",
"entry",
"if",
"it",
"has",
"a",
"Login",
"value"
] | 2493420f527fbc829a8d5bdda402e05d64a20db7 | https://github.com/ezsystems/ezpublish-legacy/blob/2493420f527fbc829a8d5bdda402e05d64a20db7/kernel/classes/datatypes/ezuser/ezuser.php#L252-L265 | train |
ezsystems/ezpublish-legacy | kernel/classes/datatypes/ezuser/ezuser.php | eZUser.fetchUnactivated | static public function fetchUnactivated( $sort = false, $limit = 10, $offset = 0 )
{
$accountDef = eZUserAccountKey::definition();
$settingsDef = eZUserSetting::definition();
return eZPersistentObject::fetchObjectList(
eZUser::definition(), null, null, $sort,
array(
'limit' => $limit,
'offset' => $offset
),
true, false, null,
array( $accountDef['name'], $settingsDef['name'] ),
" WHERE contentobject_id = {$accountDef['name']}.user_id"
. " AND {$settingsDef['name']}.user_id = contentobject_id"
. " AND is_enabled = 0"
);
} | php | static public function fetchUnactivated( $sort = false, $limit = 10, $offset = 0 )
{
$accountDef = eZUserAccountKey::definition();
$settingsDef = eZUserSetting::definition();
return eZPersistentObject::fetchObjectList(
eZUser::definition(), null, null, $sort,
array(
'limit' => $limit,
'offset' => $offset
),
true, false, null,
array( $accountDef['name'], $settingsDef['name'] ),
" WHERE contentobject_id = {$accountDef['name']}.user_id"
. " AND {$settingsDef['name']}.user_id = contentobject_id"
. " AND is_enabled = 0"
);
} | [
"static",
"public",
"function",
"fetchUnactivated",
"(",
"$",
"sort",
"=",
"false",
",",
"$",
"limit",
"=",
"10",
",",
"$",
"offset",
"=",
"0",
")",
"{",
"$",
"accountDef",
"=",
"eZUserAccountKey",
"::",
"definition",
"(",
")",
";",
"$",
"settingsDef",
... | Return an array of unactivated eZUser object
@param array|false|null An associative array of sorting conditions,
if set to false ignores settings in $def, if set to null uses
settingss in $def.
@param int $limit
@param int $offset
@return array( eZUser ) | [
"Return",
"an",
"array",
"of",
"unactivated",
"eZUser",
"object"
] | 2493420f527fbc829a8d5bdda402e05d64a20db7 | https://github.com/ezsystems/ezpublish-legacy/blob/2493420f527fbc829a8d5bdda402e05d64a20db7/kernel/classes/datatypes/ezuser/ezuser.php#L385-L402 | train |
ezsystems/ezpublish-legacy | kernel/classes/datatypes/ezuser/ezuser.php | eZUser.fetchAnonymousCount | static function fetchAnonymousCount()
{
if ( isset( $GLOBALS['eZSiteBasics']['no-cache-adviced'] ) and
!$GLOBALS['eZSiteBasics']['no-cache-adviced'] and
isset( $GLOBALS['eZUserAnonymousCount'] ) )
return $GLOBALS['eZUserAnonymousCount'];
$db = eZDB::instance();
$time = time();
$ini = eZINI::instance();
$activityTimeout = $ini->variable( 'Session', 'ActivityTimeout' );
$sessionTimeout = $ini->variable( 'Session', 'SessionTimeout' );
$time = $time + $sessionTimeout - $activityTimeout;
$sql = "SELECT count( session_key ) as count
FROM ezsession
WHERE user_id = '" . self::anonymousId() . "' AND
expiration_time > '$time'";
$rows = $db->arrayQuery( $sql );
$count = isset( $rows[0] ) ? $rows[0]['count'] : 0;
$GLOBALS['eZUserAnonymousCount'] = $count;
return $count;
} | php | static function fetchAnonymousCount()
{
if ( isset( $GLOBALS['eZSiteBasics']['no-cache-adviced'] ) and
!$GLOBALS['eZSiteBasics']['no-cache-adviced'] and
isset( $GLOBALS['eZUserAnonymousCount'] ) )
return $GLOBALS['eZUserAnonymousCount'];
$db = eZDB::instance();
$time = time();
$ini = eZINI::instance();
$activityTimeout = $ini->variable( 'Session', 'ActivityTimeout' );
$sessionTimeout = $ini->variable( 'Session', 'SessionTimeout' );
$time = $time + $sessionTimeout - $activityTimeout;
$sql = "SELECT count( session_key ) as count
FROM ezsession
WHERE user_id = '" . self::anonymousId() . "' AND
expiration_time > '$time'";
$rows = $db->arrayQuery( $sql );
$count = isset( $rows[0] ) ? $rows[0]['count'] : 0;
$GLOBALS['eZUserAnonymousCount'] = $count;
return $count;
} | [
"static",
"function",
"fetchAnonymousCount",
"(",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"GLOBALS",
"[",
"'eZSiteBasics'",
"]",
"[",
"'no-cache-adviced'",
"]",
")",
"and",
"!",
"$",
"GLOBALS",
"[",
"'eZSiteBasics'",
"]",
"[",
"'no-cache-adviced'",
"]",
"and... | Return the number of anonymous users in the system.
@deprecated As of 4.4 since default session handler does not support this.
@return int | [
"Return",
"the",
"number",
"of",
"anonymous",
"users",
"in",
"the",
"system",
"."
] | 2493420f527fbc829a8d5bdda402e05d64a20db7 | https://github.com/ezsystems/ezpublish-legacy/blob/2493420f527fbc829a8d5bdda402e05d64a20db7/kernel/classes/datatypes/ezuser/ezuser.php#L547-L568 | train |
ezsystems/ezpublish-legacy | kernel/classes/datatypes/ezuser/ezuser.php | eZUser.loginUser | public static function loginUser( $login, $password, $authenticationMatch = false )
{
$user = self::_loginUser( $login, $password, $authenticationMatch );
if ( is_object( $user ) )
{
self::loginSucceeded( $user );
return $user;
}
else
{
self::loginFailed( $user, $login );
return false;
}
} | php | public static function loginUser( $login, $password, $authenticationMatch = false )
{
$user = self::_loginUser( $login, $password, $authenticationMatch );
if ( is_object( $user ) )
{
self::loginSucceeded( $user );
return $user;
}
else
{
self::loginFailed( $user, $login );
return false;
}
} | [
"public",
"static",
"function",
"loginUser",
"(",
"$",
"login",
",",
"$",
"password",
",",
"$",
"authenticationMatch",
"=",
"false",
")",
"{",
"$",
"user",
"=",
"self",
"::",
"_loginUser",
"(",
"$",
"login",
",",
"$",
"password",
",",
"$",
"authenticatio... | Logs in the user if applied username and password is valid.
@param string $login
@param string $password
@param bool $authenticationMatch
@return mixed eZUser on success, bool false on failure | [
"Logs",
"in",
"the",
"user",
"if",
"applied",
"username",
"and",
"password",
"is",
"valid",
"."
] | 2493420f527fbc829a8d5bdda402e05d64a20db7 | https://github.com/ezsystems/ezpublish-legacy/blob/2493420f527fbc829a8d5bdda402e05d64a20db7/kernel/classes/datatypes/ezuser/ezuser.php#L756-L770 | train |
ezsystems/ezpublish-legacy | kernel/classes/datatypes/ezuser/ezuser.php | eZUser.loginSucceeded | protected static function loginSucceeded( $user )
{
$userID = $user->attribute( 'contentobject_id' );
// if audit is enabled logins should be logged
eZAudit::writeAudit( 'user-login', array( 'User id' => $userID, 'User login' => $user->attribute( 'login' ) ) );
eZUser::updateLastVisit( $userID, true );
eZUser::setCurrentlyLoggedInUser( $user, $userID );
// Reset number of failed login attempts
eZUser::setFailedLoginAttempts( $userID, 0 );
} | php | protected static function loginSucceeded( $user )
{
$userID = $user->attribute( 'contentobject_id' );
// if audit is enabled logins should be logged
eZAudit::writeAudit( 'user-login', array( 'User id' => $userID, 'User login' => $user->attribute( 'login' ) ) );
eZUser::updateLastVisit( $userID, true );
eZUser::setCurrentlyLoggedInUser( $user, $userID );
// Reset number of failed login attempts
eZUser::setFailedLoginAttempts( $userID, 0 );
} | [
"protected",
"static",
"function",
"loginSucceeded",
"(",
"$",
"user",
")",
"{",
"$",
"userID",
"=",
"$",
"user",
"->",
"attribute",
"(",
"'contentobject_id'",
")",
";",
"// if audit is enabled logins should be logged",
"eZAudit",
"::",
"writeAudit",
"(",
"'user-log... | Does some house keeping work once a log in has succeeded.
@param eZUser $user | [
"Does",
"some",
"house",
"keeping",
"work",
"once",
"a",
"log",
"in",
"has",
"succeeded",
"."
] | 2493420f527fbc829a8d5bdda402e05d64a20db7 | https://github.com/ezsystems/ezpublish-legacy/blob/2493420f527fbc829a8d5bdda402e05d64a20db7/kernel/classes/datatypes/ezuser/ezuser.php#L777-L789 | train |
ezsystems/ezpublish-legacy | kernel/classes/datatypes/ezuser/ezuser.php | eZUser.loginFailed | protected static function loginFailed( $userID = false, $login )
{
$loginEscaped = eZDB::instance()->escapeString( $login );
// Failed login attempts should be logged
eZAudit::writeAudit( 'user-failed-login', array( 'User login' => $loginEscaped,
'Comment' => 'Failed login attempt: eZUser::loginUser()' ) );
// Increase number of failed login attempts.
if ( $userID )
eZUser::setFailedLoginAttempts( $userID );
} | php | protected static function loginFailed( $userID = false, $login )
{
$loginEscaped = eZDB::instance()->escapeString( $login );
// Failed login attempts should be logged
eZAudit::writeAudit( 'user-failed-login', array( 'User login' => $loginEscaped,
'Comment' => 'Failed login attempt: eZUser::loginUser()' ) );
// Increase number of failed login attempts.
if ( $userID )
eZUser::setFailedLoginAttempts( $userID );
} | [
"protected",
"static",
"function",
"loginFailed",
"(",
"$",
"userID",
"=",
"false",
",",
"$",
"login",
")",
"{",
"$",
"loginEscaped",
"=",
"eZDB",
"::",
"instance",
"(",
")",
"->",
"escapeString",
"(",
"$",
"login",
")",
";",
"// Failed login attempts should... | Does some house keeping work when a log in has failed.
@param mixed $userID
@param string $login | [
"Does",
"some",
"house",
"keeping",
"work",
"when",
"a",
"log",
"in",
"has",
"failed",
"."
] | 2493420f527fbc829a8d5bdda402e05d64a20db7 | https://github.com/ezsystems/ezpublish-legacy/blob/2493420f527fbc829a8d5bdda402e05d64a20db7/kernel/classes/datatypes/ezuser/ezuser.php#L797-L808 | train |
ezsystems/ezpublish-legacy | kernel/classes/datatypes/ezuser/ezuser.php | eZUser.getUserCache | public function getUserCache()
{
if ( $this->UserCache === null )
{
$this->setUserCache( self::getUserCacheByUserId( $this->ContentObjectID ) );
}
return $this->UserCache;
} | php | public function getUserCache()
{
if ( $this->UserCache === null )
{
$this->setUserCache( self::getUserCacheByUserId( $this->ContentObjectID ) );
}
return $this->UserCache;
} | [
"public",
"function",
"getUserCache",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"UserCache",
"===",
"null",
")",
"{",
"$",
"this",
"->",
"setUserCache",
"(",
"self",
"::",
"getUserCacheByUserId",
"(",
"$",
"this",
"->",
"ContentObjectID",
")",
")",
";... | Get User cache from cache file
@since 4.4
@return array( 'info' => array, 'groups' => array, 'roles' => array, 'role_limitations' => array, 'access_array' => array) | [
"Get",
"User",
"cache",
"from",
"cache",
"file"
] | 2493420f527fbc829a8d5bdda402e05d64a20db7 | https://github.com/ezsystems/ezpublish-legacy/blob/2493420f527fbc829a8d5bdda402e05d64a20db7/kernel/classes/datatypes/ezuser/ezuser.php#L1311-L1318 | train |
ezsystems/ezpublish-legacy | kernel/classes/datatypes/ezuser/ezuser.php | eZUser.purgeUserCacheByUserId | static public function purgeUserCacheByUserId( $userId )
{
if ( eZINI::instance()->variable( 'RoleSettings', 'EnableCaching' ) === 'true' )
{
$cacheFilePath = eZUser::getCacheDir( $userId ). "/user-data-{$userId}.cache.php" ;
eZClusterFileHandler::instance()->fileDelete( $cacheFilePath );
}
} | php | static public function purgeUserCacheByUserId( $userId )
{
if ( eZINI::instance()->variable( 'RoleSettings', 'EnableCaching' ) === 'true' )
{
$cacheFilePath = eZUser::getCacheDir( $userId ). "/user-data-{$userId}.cache.php" ;
eZClusterFileHandler::instance()->fileDelete( $cacheFilePath );
}
} | [
"static",
"public",
"function",
"purgeUserCacheByUserId",
"(",
"$",
"userId",
")",
"{",
"if",
"(",
"eZINI",
"::",
"instance",
"(",
")",
"->",
"variable",
"(",
"'RoleSettings'",
",",
"'EnableCaching'",
")",
"===",
"'true'",
")",
"{",
"$",
"cacheFilePath",
"="... | Delete User cache pr user
@since 4.4
@param int $userId | [
"Delete",
"User",
"cache",
"pr",
"user"
] | 2493420f527fbc829a8d5bdda402e05d64a20db7 | https://github.com/ezsystems/ezpublish-legacy/blob/2493420f527fbc829a8d5bdda402e05d64a20db7/kernel/classes/datatypes/ezuser/ezuser.php#L1360-L1367 | train |
ezsystems/ezpublish-legacy | kernel/classes/datatypes/ezuser/ezuser.php | eZUser.retrieveUserCacheFromFile | static function retrieveUserCacheFromFile( $filePath, $mtime, $userId )
{
$userCache = include( $filePath );
// check that the returned array is not corrupted
if ( is_array( $userCache )
&& isset( $userCache['info'] )
&& isset( $userCache['info'][$userId] )
&& is_numeric( $userCache['info'][$userId]['contentobject_id'] )
&& isset( $userCache['groups'] )
&& isset( $userCache['roles'] )
&& isset( $userCache['role_limitations'] )
&& isset( $userCache['access_array'] )
&& isset( $userCache['discount_rules'] ) )
{
return $userCache;
}
eZDebug::writeError( 'Cache file ' . $filePath . ' is corrupted, forcing generation.', __METHOD__ );
return new eZClusterFileFailure( 1, 'Cache file ' . $filePath . ' is corrupted, forcing generation.' );
} | php | static function retrieveUserCacheFromFile( $filePath, $mtime, $userId )
{
$userCache = include( $filePath );
// check that the returned array is not corrupted
if ( is_array( $userCache )
&& isset( $userCache['info'] )
&& isset( $userCache['info'][$userId] )
&& is_numeric( $userCache['info'][$userId]['contentobject_id'] )
&& isset( $userCache['groups'] )
&& isset( $userCache['roles'] )
&& isset( $userCache['role_limitations'] )
&& isset( $userCache['access_array'] )
&& isset( $userCache['discount_rules'] ) )
{
return $userCache;
}
eZDebug::writeError( 'Cache file ' . $filePath . ' is corrupted, forcing generation.', __METHOD__ );
return new eZClusterFileFailure( 1, 'Cache file ' . $filePath . ' is corrupted, forcing generation.' );
} | [
"static",
"function",
"retrieveUserCacheFromFile",
"(",
"$",
"filePath",
",",
"$",
"mtime",
",",
"$",
"userId",
")",
"{",
"$",
"userCache",
"=",
"include",
"(",
"$",
"filePath",
")",
";",
"// check that the returned array is not corrupted",
"if",
"(",
"is_array",
... | Callback which fetches user cache from local file.
@internal
@since 4.4
@see eZUser::getUserCacheByUserId() | [
"Callback",
"which",
"fetches",
"user",
"cache",
"from",
"local",
"file",
"."
] | 2493420f527fbc829a8d5bdda402e05d64a20db7 | https://github.com/ezsystems/ezpublish-legacy/blob/2493420f527fbc829a8d5bdda402e05d64a20db7/kernel/classes/datatypes/ezuser/ezuser.php#L1419-L1439 | train |
ezsystems/ezpublish-legacy | kernel/classes/datatypes/ezuser/ezuser.php | eZUser.generateUserCacheData | private static function generateUserCacheData( $userId )
{
$user = eZUser::fetch( $userId );
if ( !$user instanceof eZUser )
{
return null;
}
// user info (session: eZUserInfoCache)
$data['info'][$userId] = array( 'contentobject_id' => $user->attribute( 'contentobject_id' ),
'login' => $user->attribute( 'login' ),
'email' => $user->attribute( 'email' ),
'is_enabled' => $user->isEnabled( false ),
'password_hash' => $user->attribute( 'password_hash' ),
'password_hash_type' => $user->attribute( 'password_hash_type' ) );
// function groups relies on caching. The function generateUserCacheData relies on function groups.
// To avoid an infinitive loop, the code is disabling caching in function generateUserCacheData.
// At the end of this method flag is set to previous value again
$previousCachingState = $user->setCachingEnabled( false );
// user groups list (session: eZUserGroupsCache)
$groups = $user->groups();
$data['groups'] = $groups;
// role list (session: eZRoleIDList)
$groups[] = $userId;
$data['roles'] = eZRole::fetchIDListByUser( $groups );
// role limitation list (session: eZRoleLimitationValueList)
$limitList = $user->limitList();
foreach ( $limitList as $limit )
{
$data['role_limitations'][] = $limit['limit_value'];
}
// access array (session: AccessArray)
$data['access_array'] = $user->generateAccessArray();
// discount rules (session: eZUserDiscountRules<userId>)
$data['discount_rules'] = eZUserDiscountRule::generateIDListByUserID( $userId );
$user->setCachingEnabled( $previousCachingState );
return $data;
} | php | private static function generateUserCacheData( $userId )
{
$user = eZUser::fetch( $userId );
if ( !$user instanceof eZUser )
{
return null;
}
// user info (session: eZUserInfoCache)
$data['info'][$userId] = array( 'contentobject_id' => $user->attribute( 'contentobject_id' ),
'login' => $user->attribute( 'login' ),
'email' => $user->attribute( 'email' ),
'is_enabled' => $user->isEnabled( false ),
'password_hash' => $user->attribute( 'password_hash' ),
'password_hash_type' => $user->attribute( 'password_hash_type' ) );
// function groups relies on caching. The function generateUserCacheData relies on function groups.
// To avoid an infinitive loop, the code is disabling caching in function generateUserCacheData.
// At the end of this method flag is set to previous value again
$previousCachingState = $user->setCachingEnabled( false );
// user groups list (session: eZUserGroupsCache)
$groups = $user->groups();
$data['groups'] = $groups;
// role list (session: eZRoleIDList)
$groups[] = $userId;
$data['roles'] = eZRole::fetchIDListByUser( $groups );
// role limitation list (session: eZRoleLimitationValueList)
$limitList = $user->limitList();
foreach ( $limitList as $limit )
{
$data['role_limitations'][] = $limit['limit_value'];
}
// access array (session: AccessArray)
$data['access_array'] = $user->generateAccessArray();
// discount rules (session: eZUserDiscountRules<userId>)
$data['discount_rules'] = eZUserDiscountRule::generateIDListByUserID( $userId );
$user->setCachingEnabled( $previousCachingState );
return $data;
} | [
"private",
"static",
"function",
"generateUserCacheData",
"(",
"$",
"userId",
")",
"{",
"$",
"user",
"=",
"eZUser",
"::",
"fetch",
"(",
"$",
"userId",
")",
";",
"if",
"(",
"!",
"$",
"user",
"instanceof",
"eZUser",
")",
"{",
"return",
"null",
";",
"}",
... | Generate cache content
@since 5.3
@param int $userId
@return array|null | [
"Generate",
"cache",
"content"
] | 2493420f527fbc829a8d5bdda402e05d64a20db7 | https://github.com/ezsystems/ezpublish-legacy/blob/2493420f527fbc829a8d5bdda402e05d64a20db7/kernel/classes/datatypes/ezuser/ezuser.php#L1472-L1516 | train |
ezsystems/ezpublish-legacy | kernel/classes/datatypes/ezuser/ezuser.php | eZUser.generateUserCacheForFile | static function generateUserCacheForFile( $filePath, $userId )
{
$cacheData = self::generateUserCacheData( $userId );
if ( $cacheData !== null )
{
$cacheData = array( 'content' => $cacheData,
'scope' => 'user-info-cache',
'datatype' => 'php',
'store' => true );
}
return $cacheData;
} | php | static function generateUserCacheForFile( $filePath, $userId )
{
$cacheData = self::generateUserCacheData( $userId );
if ( $cacheData !== null )
{
$cacheData = array( 'content' => $cacheData,
'scope' => 'user-info-cache',
'datatype' => 'php',
'store' => true );
}
return $cacheData;
} | [
"static",
"function",
"generateUserCacheForFile",
"(",
"$",
"filePath",
",",
"$",
"userId",
")",
"{",
"$",
"cacheData",
"=",
"self",
"::",
"generateUserCacheData",
"(",
"$",
"userId",
")",
";",
"if",
"(",
"$",
"cacheData",
"!==",
"null",
")",
"{",
"$",
"... | Callback which generates user cache for user, returns null on invalid user
@internal
@since 4.4
@see eZUser::getUserCacheByUserId() | [
"Callback",
"which",
"generates",
"user",
"cache",
"for",
"user",
"returns",
"null",
"on",
"invalid",
"user"
] | 2493420f527fbc829a8d5bdda402e05d64a20db7 | https://github.com/ezsystems/ezpublish-legacy/blob/2493420f527fbc829a8d5bdda402e05d64a20db7/kernel/classes/datatypes/ezuser/ezuser.php#L1525-L1538 | train |
ezsystems/ezpublish-legacy | kernel/classes/datatypes/ezuser/ezuser.php | eZUser.loginCount | function loginCount()
{
$db = eZDB::instance();
$userVisitArray = $db->arrayQuery( "SELECT login_count FROM ezuservisit WHERE user_id=$this->ContentObjectID" );
if ( isset( $userVisitArray[0] ) )
{
return $userVisitArray[0]['login_count'];
}
else
{
return 0;
}
} | php | function loginCount()
{
$db = eZDB::instance();
$userVisitArray = $db->arrayQuery( "SELECT login_count FROM ezuservisit WHERE user_id=$this->ContentObjectID" );
if ( isset( $userVisitArray[0] ) )
{
return $userVisitArray[0]['login_count'];
}
else
{
return 0;
}
} | [
"function",
"loginCount",
"(",
")",
"{",
"$",
"db",
"=",
"eZDB",
"::",
"instance",
"(",
")",
";",
"$",
"userVisitArray",
"=",
"$",
"db",
"->",
"arrayQuery",
"(",
"\"SELECT login_count FROM ezuservisit WHERE user_id=$this->ContentObjectID\"",
")",
";",
"if",
"(",
... | Returns the login count for the current user.
@since Version 4.1
@return int Login count for current user. | [
"Returns",
"the",
"login",
"count",
"for",
"the",
"current",
"user",
"."
] | 2493420f527fbc829a8d5bdda402e05d64a20db7 | https://github.com/ezsystems/ezpublish-legacy/blob/2493420f527fbc829a8d5bdda402e05d64a20db7/kernel/classes/datatypes/ezuser/ezuser.php#L1590-L1602 | train |
ezsystems/ezpublish-legacy | kernel/classes/datatypes/ezuser/ezuser.php | eZUser.generateGroupIdList | protected function generateGroupIdList()
{
$db = eZDB::instance();
$userID = $this->ContentObjectID;
$userGroups = $db->arrayQuery( "SELECT c.contentobject_id as id,c.path_string
FROM ezcontentobject_tree b,
ezcontentobject_tree c
WHERE b.contentobject_id='$userID' AND
b.parent_node_id = c.node_id
ORDER BY c.contentobject_id ");
$pathArray = array();
$userGroupArray = array();
foreach ( $userGroups as $group )
{
$pathItems = explode( '/', $group["path_string"] );
array_pop( $pathItems );
array_pop( $pathItems );
foreach ( $pathItems as $pathItem )
{
if ( $pathItem != '' && $pathItem > 1 )
$pathArray[] = $pathItem;
}
$userGroupArray[] = $group['id'];
}
if ( !empty( $pathArray ) )
{
$pathArray = array_unique ($pathArray);
$extraGroups = $db->arrayQuery( "SELECT c.contentobject_id as id
FROM ezcontentobject_tree c,
ezcontentobject d
WHERE c.node_id in ( " . implode( ', ', $pathArray ) . " ) AND
d.id = c.contentobject_id
ORDER BY c.contentobject_id ");
foreach ( $extraGroups as $group )
{
$userGroupArray[] = $group['id'];
}
}
return $userGroupArray;
} | php | protected function generateGroupIdList()
{
$db = eZDB::instance();
$userID = $this->ContentObjectID;
$userGroups = $db->arrayQuery( "SELECT c.contentobject_id as id,c.path_string
FROM ezcontentobject_tree b,
ezcontentobject_tree c
WHERE b.contentobject_id='$userID' AND
b.parent_node_id = c.node_id
ORDER BY c.contentobject_id ");
$pathArray = array();
$userGroupArray = array();
foreach ( $userGroups as $group )
{
$pathItems = explode( '/', $group["path_string"] );
array_pop( $pathItems );
array_pop( $pathItems );
foreach ( $pathItems as $pathItem )
{
if ( $pathItem != '' && $pathItem > 1 )
$pathArray[] = $pathItem;
}
$userGroupArray[] = $group['id'];
}
if ( !empty( $pathArray ) )
{
$pathArray = array_unique ($pathArray);
$extraGroups = $db->arrayQuery( "SELECT c.contentobject_id as id
FROM ezcontentobject_tree c,
ezcontentobject d
WHERE c.node_id in ( " . implode( ', ', $pathArray ) . " ) AND
d.id = c.contentobject_id
ORDER BY c.contentobject_id ");
foreach ( $extraGroups as $group )
{
$userGroupArray[] = $group['id'];
}
}
return $userGroupArray;
} | [
"protected",
"function",
"generateGroupIdList",
"(",
")",
"{",
"$",
"db",
"=",
"eZDB",
"::",
"instance",
"(",
")",
";",
"$",
"userID",
"=",
"$",
"this",
"->",
"ContentObjectID",
";",
"$",
"userGroups",
"=",
"$",
"db",
"->",
"arrayQuery",
"(",
"\"SELECT ... | Generate list of group id's
@since 4.4
@return array | [
"Generate",
"list",
"of",
"group",
"id",
"s"
] | 2493420f527fbc829a8d5bdda402e05d64a20db7 | https://github.com/ezsystems/ezpublish-legacy/blob/2493420f527fbc829a8d5bdda402e05d64a20db7/kernel/classes/datatypes/ezuser/ezuser.php#L2620-L2660 | train |
ezsystems/ezpublish-legacy | kernel/classes/datatypes/ezuser/ezuser.php | eZUser.anonymousId | public static function anonymousId()
{
if ( self::$anonymousId === null )
{
$ini = eZINI::instance();
self::$anonymousId = (int)$ini->variable( 'UserSettings', 'AnonymousUserID' );
$GLOBALS['eZUserBuiltins'] = array( self::$anonymousId );
}
return self::$anonymousId;
} | php | public static function anonymousId()
{
if ( self::$anonymousId === null )
{
$ini = eZINI::instance();
self::$anonymousId = (int)$ini->variable( 'UserSettings', 'AnonymousUserID' );
$GLOBALS['eZUserBuiltins'] = array( self::$anonymousId );
}
return self::$anonymousId;
} | [
"public",
"static",
"function",
"anonymousId",
"(",
")",
"{",
"if",
"(",
"self",
"::",
"$",
"anonymousId",
"===",
"null",
")",
"{",
"$",
"ini",
"=",
"eZINI",
"::",
"instance",
"(",
")",
";",
"self",
"::",
"$",
"anonymousId",
"=",
"(",
"int",
")",
"... | Gets the id of the anonymous user.
@static
@return int User id of anonymous user. | [
"Gets",
"the",
"id",
"of",
"the",
"anonymous",
"user",
"."
] | 2493420f527fbc829a8d5bdda402e05d64a20db7 | https://github.com/ezsystems/ezpublish-legacy/blob/2493420f527fbc829a8d5bdda402e05d64a20db7/kernel/classes/datatypes/ezuser/ezuser.php#L2913-L2922 | train |
ezsystems/ezpublish-legacy | kernel/classes/datatypes/ezuser/ezuser.php | eZUser.fetchUserCacheIfNeeded | protected function fetchUserCacheIfNeeded()
{
if ( null === $this->UserCache && true === $this->CachingEnabled && 'true' === eZINI::instance()->variable( 'RoleSettings', 'EnableCaching' ))
{
$this->UserCache = $this->getUserCache();
}
} | php | protected function fetchUserCacheIfNeeded()
{
if ( null === $this->UserCache && true === $this->CachingEnabled && 'true' === eZINI::instance()->variable( 'RoleSettings', 'EnableCaching' ))
{
$this->UserCache = $this->getUserCache();
}
} | [
"protected",
"function",
"fetchUserCacheIfNeeded",
"(",
")",
"{",
"if",
"(",
"null",
"===",
"$",
"this",
"->",
"UserCache",
"&&",
"true",
"===",
"$",
"this",
"->",
"CachingEnabled",
"&&",
"'true'",
"===",
"eZINI",
"::",
"instance",
"(",
")",
"->",
"variabl... | Fetches user cache when given preconditions are met | [
"Fetches",
"user",
"cache",
"when",
"given",
"preconditions",
"are",
"met"
] | 2493420f527fbc829a8d5bdda402e05d64a20db7 | https://github.com/ezsystems/ezpublish-legacy/blob/2493420f527fbc829a8d5bdda402e05d64a20db7/kernel/classes/datatypes/ezuser/ezuser.php#L2981-L2987 | train |
ezsystems/ezpublish-legacy | lib/ezsession/classes/ezsession.php | eZSession.& | static private function &sessionArray()
{
if ( self::$namespace !== null )
{
if ( !isset( $_SESSION[self::$namespace] ) )
$_SESSION[self::$namespace] = array();
return $_SESSION[self::$namespace];
}
return $_SESSION;
} | php | static private function &sessionArray()
{
if ( self::$namespace !== null )
{
if ( !isset( $_SESSION[self::$namespace] ) )
$_SESSION[self::$namespace] = array();
return $_SESSION[self::$namespace];
}
return $_SESSION;
} | [
"static",
"private",
"function",
"&",
"sessionArray",
"(",
")",
"{",
"if",
"(",
"self",
"::",
"$",
"namespace",
"!==",
"null",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"_SESSION",
"[",
"self",
"::",
"$",
"namespace",
"]",
")",
")",
"$",
"_SESSI... | Returns the session array to use taking into account the namespace that
might have been injected.
@since 5.0
@return byRef session array to use | [
"Returns",
"the",
"session",
"array",
"to",
"use",
"taking",
"into",
"account",
"the",
"namespace",
"that",
"might",
"have",
"been",
"injected",
"."
] | 2493420f527fbc829a8d5bdda402e05d64a20db7 | https://github.com/ezsystems/ezpublish-legacy/blob/2493420f527fbc829a8d5bdda402e05d64a20db7/lib/ezsession/classes/ezsession.php#L122-L131 | train |
ezsystems/ezpublish-legacy | lib/ezsession/classes/ezsession.php | eZSession.stop | static public function stop()
{
if ( !self::$hasStarted )
{
return false;
}
session_write_close();
self::$hasStarted = false;
self::$handlerInstance = null;
return true;
} | php | static public function stop()
{
if ( !self::$hasStarted )
{
return false;
}
session_write_close();
self::$hasStarted = false;
self::$handlerInstance = null;
return true;
} | [
"static",
"public",
"function",
"stop",
"(",
")",
"{",
"if",
"(",
"!",
"self",
"::",
"$",
"hasStarted",
")",
"{",
"return",
"false",
";",
"}",
"session_write_close",
"(",
")",
";",
"self",
"::",
"$",
"hasStarted",
"=",
"false",
";",
"self",
"::",
"$"... | Writes session data and stops the session, if not already stopped.
@since 4.1
@return bool Depending on if session was stopped. | [
"Writes",
"session",
"data",
"and",
"stops",
"the",
"session",
"if",
"not",
"already",
"stopped",
"."
] | 2493420f527fbc829a8d5bdda402e05d64a20db7 | https://github.com/ezsystems/ezpublish-legacy/blob/2493420f527fbc829a8d5bdda402e05d64a20db7/lib/ezsession/classes/ezsession.php#L463-L473 | train |
ezsystems/ezpublish-legacy | lib/ezsession/classes/ezsession.php | eZSession.getHandlerInstance | static public function getHandlerInstance( ezpSessionHandler $handler = null )
{
if ( self::$handlerInstance === null )
{
if ( $handler === null )
{
$ini = eZINI::instance();
if ( $ini->variable( 'Session', 'Handler' ) !== '' )
{
$optionArray = array(
'iniFile' => 'site.ini',
'iniSection' => 'Session',
'iniVariable' => 'Handler',
'handlerParams' => array( self::$hasSessionCookie )
);
$options = new ezpExtensionOptions( $optionArray );
self::$handlerInstance = eZExtension::getHandlerClass( $options );
}
}
else
{
self::$handlerInstance = $handler;
}
if ( !self::$handlerInstance instanceof ezpSessionHandler )
{
self::$handlerInstance = new ezpSessionHandlerPHP( self::$hasSessionCookie );
}
}
return self::$handlerInstance;
} | php | static public function getHandlerInstance( ezpSessionHandler $handler = null )
{
if ( self::$handlerInstance === null )
{
if ( $handler === null )
{
$ini = eZINI::instance();
if ( $ini->variable( 'Session', 'Handler' ) !== '' )
{
$optionArray = array(
'iniFile' => 'site.ini',
'iniSection' => 'Session',
'iniVariable' => 'Handler',
'handlerParams' => array( self::$hasSessionCookie )
);
$options = new ezpExtensionOptions( $optionArray );
self::$handlerInstance = eZExtension::getHandlerClass( $options );
}
}
else
{
self::$handlerInstance = $handler;
}
if ( !self::$handlerInstance instanceof ezpSessionHandler )
{
self::$handlerInstance = new ezpSessionHandlerPHP( self::$hasSessionCookie );
}
}
return self::$handlerInstance;
} | [
"static",
"public",
"function",
"getHandlerInstance",
"(",
"ezpSessionHandler",
"$",
"handler",
"=",
"null",
")",
"{",
"if",
"(",
"self",
"::",
"$",
"handlerInstance",
"===",
"null",
")",
"{",
"if",
"(",
"$",
"handler",
"===",
"null",
")",
"{",
"$",
"ini... | Get curren session handler
@since 4.4
@return ezpSessionHandler | [
"Get",
"curren",
"session",
"handler"
] | 2493420f527fbc829a8d5bdda402e05d64a20db7 | https://github.com/ezsystems/ezpublish-legacy/blob/2493420f527fbc829a8d5bdda402e05d64a20db7/lib/ezsession/classes/ezsession.php#L579-L609 | train |
ezsystems/ezpublish-legacy | extension/ezjscore/classes/ezjscajaxcontent.php | ezjscAjaxContent.getHttpAccept | public static function getHttpAccept( $default = 'xhtml', $aliasList = array( 'html' => 'xhtml',
'json' => 'json',
'javascript' => 'json',
'xml' => 'xml',
'text' => 'text' ) )
{
$acceptList = array();
if ( isset($_POST['http_accept']) )
$acceptList = explode( ',', $_POST['http_accept'] );
else if ( isset($_POST['HTTP_ACCEPT']) )
$acceptList = explode( ',', $_POST['HTTP_ACCEPT'] );
else if ( isset($_GET['http_accept']) )
$acceptList = explode( ',', $_GET['http_accept'] );
else if ( isset($_GET['HTTP_ACCEPT']) )
$acceptList = explode( ',', $_GET['HTTP_ACCEPT'] );
else if ( isset($_SERVER['HTTP_ACCEPT']) )
$acceptList = explode( ',', $_SERVER['HTTP_ACCEPT'] );
foreach( $acceptList as $accept )
{
foreach( $aliasList as $alias => $returnType )
{
if ( strpos( $accept, $alias ) !== false )
{
$default = $returnType;
break 2;
}
}
}
return $default;
} | php | public static function getHttpAccept( $default = 'xhtml', $aliasList = array( 'html' => 'xhtml',
'json' => 'json',
'javascript' => 'json',
'xml' => 'xml',
'text' => 'text' ) )
{
$acceptList = array();
if ( isset($_POST['http_accept']) )
$acceptList = explode( ',', $_POST['http_accept'] );
else if ( isset($_POST['HTTP_ACCEPT']) )
$acceptList = explode( ',', $_POST['HTTP_ACCEPT'] );
else if ( isset($_GET['http_accept']) )
$acceptList = explode( ',', $_GET['http_accept'] );
else if ( isset($_GET['HTTP_ACCEPT']) )
$acceptList = explode( ',', $_GET['HTTP_ACCEPT'] );
else if ( isset($_SERVER['HTTP_ACCEPT']) )
$acceptList = explode( ',', $_SERVER['HTTP_ACCEPT'] );
foreach( $acceptList as $accept )
{
foreach( $aliasList as $alias => $returnType )
{
if ( strpos( $accept, $alias ) !== false )
{
$default = $returnType;
break 2;
}
}
}
return $default;
} | [
"public",
"static",
"function",
"getHttpAccept",
"(",
"$",
"default",
"=",
"'xhtml'",
",",
"$",
"aliasList",
"=",
"array",
"(",
"'html'",
"=>",
"'xhtml'",
",",
"'json'",
"=>",
"'json'",
",",
"'javascript'",
"=>",
"'json'",
",",
"'xml'",
"=>",
"'xml'",
",",... | Gets the first most prefered response type as defined by http_accept
uses post and get parameter if present, if not falls back to the one
defined in http header. First parameter lets you define fallback value
if none of the alternatives in second parameter is found. Second parameter
lets you limit the allowes types with a alias hash. xhtml, json, xml and
text are default allowed types.
@param string $default
@param array $aliasList
@return string | [
"Gets",
"the",
"first",
"most",
"prefered",
"response",
"type",
"as",
"defined",
"by",
"http_accept",
"uses",
"post",
"and",
"get",
"parameter",
"if",
"present",
"if",
"not",
"falls",
"back",
"to",
"the",
"one",
"defined",
"in",
"http",
"header",
".",
"Fir... | 2493420f527fbc829a8d5bdda402e05d64a20db7 | https://github.com/ezsystems/ezpublish-legacy/blob/2493420f527fbc829a8d5bdda402e05d64a20db7/extension/ezjscore/classes/ezjscajaxcontent.php#L63-L94 | train |
ezsystems/ezpublish-legacy | extension/ezjscore/classes/ezjscajaxcontent.php | ezjscAjaxContent.autoEncode | public static function autoEncode( $ret, $type = null )
{
if ( $type === null )
$type = self::getHttpAccept( );
if ( $type === 'xml' )
return self::xmlEncode( $ret );
else if ( $type === 'json' )
return json_encode( $ret );
else
return self::textEncode( $ret );
} | php | public static function autoEncode( $ret, $type = null )
{
if ( $type === null )
$type = self::getHttpAccept( );
if ( $type === 'xml' )
return self::xmlEncode( $ret );
else if ( $type === 'json' )
return json_encode( $ret );
else
return self::textEncode( $ret );
} | [
"public",
"static",
"function",
"autoEncode",
"(",
"$",
"ret",
",",
"$",
"type",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"type",
"===",
"null",
")",
"$",
"type",
"=",
"self",
"::",
"getHttpAccept",
"(",
")",
";",
"if",
"(",
"$",
"type",
"===",
"'x... | Encodes the content based on http accept values, more on
this on the getHttpAccept function.
Will simply implode the return value if array and not xml or
json is prefered return type.
@param mixed $ret
@param string $type
@return string | [
"Encodes",
"the",
"content",
"based",
"on",
"http",
"accept",
"values",
"more",
"on",
"this",
"on",
"the",
"getHttpAccept",
"function",
".",
"Will",
"simply",
"implode",
"the",
"return",
"value",
"if",
"array",
"and",
"not",
"xml",
"or",
"json",
"is",
"pre... | 2493420f527fbc829a8d5bdda402e05d64a20db7 | https://github.com/ezsystems/ezpublish-legacy/blob/2493420f527fbc829a8d5bdda402e05d64a20db7/extension/ezjscore/classes/ezjscajaxcontent.php#L106-L117 | train |
ezsystems/ezpublish-legacy | extension/ezjscore/classes/ezjscajaxcontent.php | ezjscAjaxContent.textEncode | public static function textEncode( $mix )
{
if ( is_array( $mix ) )
return implode(',', array_map( array('ezjscAjaxContent', 'textEncode'), array_filter( $mix ) ) );
return htmlspecialchars( $mix );
} | php | public static function textEncode( $mix )
{
if ( is_array( $mix ) )
return implode(',', array_map( array('ezjscAjaxContent', 'textEncode'), array_filter( $mix ) ) );
return htmlspecialchars( $mix );
} | [
"public",
"static",
"function",
"textEncode",
"(",
"$",
"mix",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"mix",
")",
")",
"return",
"implode",
"(",
"','",
",",
"array_map",
"(",
"array",
"(",
"'ezjscAjaxContent'",
",",
"'textEncode'",
")",
",",
"array_f... | Encodes mixed value to string or comma seperated list of strings
@param mixed $mix
@return string | [
"Encodes",
"mixed",
"value",
"to",
"string",
"or",
"comma",
"seperated",
"list",
"of",
"strings"
] | 2493420f527fbc829a8d5bdda402e05d64a20db7 | https://github.com/ezsystems/ezpublish-legacy/blob/2493420f527fbc829a8d5bdda402e05d64a20db7/extension/ezjscore/classes/ezjscajaxcontent.php#L125-L131 | train |
ezsystems/ezpublish-legacy | extension/ezjscore/classes/ezjscajaxcontent.php | ezjscAjaxContent.xmlEncode | public static function xmlEncode( $hash, $childName = 'child' )
{
$xml = new XmlWriter();
$xml->openMemory();
$xml->startDocument('1.0', 'UTF-8');
$xml->startElement('root');
self::xmlWrite( $xml, $hash, $childName );
$xml->endElement();
return $xml->outputMemory( true );
} | php | public static function xmlEncode( $hash, $childName = 'child' )
{
$xml = new XmlWriter();
$xml->openMemory();
$xml->startDocument('1.0', 'UTF-8');
$xml->startElement('root');
self::xmlWrite( $xml, $hash, $childName );
$xml->endElement();
return $xml->outputMemory( true );
} | [
"public",
"static",
"function",
"xmlEncode",
"(",
"$",
"hash",
",",
"$",
"childName",
"=",
"'child'",
")",
"{",
"$",
"xml",
"=",
"new",
"XmlWriter",
"(",
")",
";",
"$",
"xml",
"->",
"openMemory",
"(",
")",
";",
"$",
"xml",
"->",
"startDocument",
"(",... | Encodes simple multilevel array and hash values to valid xml string
@param mixed $hash
@param string $childName
@return string | [
"Encodes",
"simple",
"multilevel",
"array",
"and",
"hash",
"values",
"to",
"valid",
"xml",
"string"
] | 2493420f527fbc829a8d5bdda402e05d64a20db7 | https://github.com/ezsystems/ezpublish-legacy/blob/2493420f527fbc829a8d5bdda402e05d64a20db7/extension/ezjscore/classes/ezjscajaxcontent.php#L499-L511 | train |
ezsystems/ezpublish-legacy | extension/ezjscore/classes/ezjscajaxcontent.php | ezjscAjaxContent.xmlWrite | protected static function xmlWrite( XMLWriter $xml, $hash, $childName = 'child' )
{
foreach( $hash as $key => $value )
{
if( is_array( $value ) )
{
if ( is_numeric( $key ) )
$xml->startElement( $childName );
else
$xml->startElement( $key );
self::xmlWrite( $xml, $value );
$xml->endElement();
continue;
}
if ( is_numeric( $key ) )
{
$xml->writeElement( $childName, $value );
}
else
{
$xml->writeElement( $key, $value );
}
}
} | php | protected static function xmlWrite( XMLWriter $xml, $hash, $childName = 'child' )
{
foreach( $hash as $key => $value )
{
if( is_array( $value ) )
{
if ( is_numeric( $key ) )
$xml->startElement( $childName );
else
$xml->startElement( $key );
self::xmlWrite( $xml, $value );
$xml->endElement();
continue;
}
if ( is_numeric( $key ) )
{
$xml->writeElement( $childName, $value );
}
else
{
$xml->writeElement( $key, $value );
}
}
} | [
"protected",
"static",
"function",
"xmlWrite",
"(",
"XMLWriter",
"$",
"xml",
",",
"$",
"hash",
",",
"$",
"childName",
"=",
"'child'",
")",
"{",
"foreach",
"(",
"$",
"hash",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"if",
"(",
"is_array",
"(",
... | Recursive xmlWriter function called by xmlEncode
@param XMLWriter $xml
@param mixed $hash
@param string $childName | [
"Recursive",
"xmlWriter",
"function",
"called",
"by",
"xmlEncode"
] | 2493420f527fbc829a8d5bdda402e05d64a20db7 | https://github.com/ezsystems/ezpublish-legacy/blob/2493420f527fbc829a8d5bdda402e05d64a20db7/extension/ezjscore/classes/ezjscajaxcontent.php#L520-L543 | train |
ezsystems/ezpublish-legacy | kernel/classes/ezuserdiscountrule.php | eZUserDiscountRule.& | static function &fetchByUserIDArray( $idArray )
{
$db = eZDB::instance();
$inString = $db->generateSQLINStatement( $idArray, 'ezuser_discountrule.contentobject_id', false, false, 'int' );
$query = "SELECT DISTINCT ezdiscountrule.id,
ezdiscountrule.name
FROM ezdiscountrule,
ezuser_discountrule
WHERE $inString AND
ezuser_discountrule.discountrule_id = ezdiscountrule.id";
$ruleArray = $db->arrayQuery( $query );
$rules = array();
foreach ( $ruleArray as $ruleRow )
{
$rules[] = new eZDiscountRule( $ruleRow );
}
return $rules;
} | php | static function &fetchByUserIDArray( $idArray )
{
$db = eZDB::instance();
$inString = $db->generateSQLINStatement( $idArray, 'ezuser_discountrule.contentobject_id', false, false, 'int' );
$query = "SELECT DISTINCT ezdiscountrule.id,
ezdiscountrule.name
FROM ezdiscountrule,
ezuser_discountrule
WHERE $inString AND
ezuser_discountrule.discountrule_id = ezdiscountrule.id";
$ruleArray = $db->arrayQuery( $query );
$rules = array();
foreach ( $ruleArray as $ruleRow )
{
$rules[] = new eZDiscountRule( $ruleRow );
}
return $rules;
} | [
"static",
"function",
"&",
"fetchByUserIDArray",
"(",
"$",
"idArray",
")",
"{",
"$",
"db",
"=",
"eZDB",
"::",
"instance",
"(",
")",
";",
"$",
"inString",
"=",
"$",
"db",
"->",
"generateSQLINStatement",
"(",
"$",
"idArray",
",",
"'ezuser_discountrule.contento... | Fetches the eZDiscountRules matching an array of eZUserID
@param array(eZUserID) $idArray Array of user ID
@return array(eZDiscountRule) | [
"Fetches",
"the",
"eZDiscountRules",
"matching",
"an",
"array",
"of",
"eZUserID"
] | 2493420f527fbc829a8d5bdda402e05d64a20db7 | https://github.com/ezsystems/ezpublish-legacy/blob/2493420f527fbc829a8d5bdda402e05d64a20db7/kernel/classes/ezuserdiscountrule.php#L152-L170 | train |
ezsystems/ezpublish-legacy | kernel/classes/ezurlwildcard.php | eZURLWildcard.removeByIDs | public static function removeByIDs( $idList )
{
if ( !is_array( $idList ) )
return;
while ( count( $idList ) > 0 )
{
// remove by portion of 100 rows.
$ids = array_splice( $idList, 0, 100 );
$conditions = array( 'id' => array( $ids ) );
eZPersistentObject::removeObject( self::definition(),
$conditions );
}
} | php | public static function removeByIDs( $idList )
{
if ( !is_array( $idList ) )
return;
while ( count( $idList ) > 0 )
{
// remove by portion of 100 rows.
$ids = array_splice( $idList, 0, 100 );
$conditions = array( 'id' => array( $ids ) );
eZPersistentObject::removeObject( self::definition(),
$conditions );
}
} | [
"public",
"static",
"function",
"removeByIDs",
"(",
"$",
"idList",
")",
"{",
"if",
"(",
"!",
"is_array",
"(",
"$",
"idList",
")",
")",
"return",
";",
"while",
"(",
"count",
"(",
"$",
"idList",
")",
">",
"0",
")",
"{",
"// remove by portion of 100 rows.",... | Removes wildcards based on an ID list
@param array $idList array of numerical ID
@return void | [
"Removes",
"wildcards",
"based",
"on",
"an",
"ID",
"list"
] | 2493420f527fbc829a8d5bdda402e05d64a20db7 | https://github.com/ezsystems/ezpublish-legacy/blob/2493420f527fbc829a8d5bdda402e05d64a20db7/kernel/classes/ezurlwildcard.php#L131-L146 | train |
ezsystems/ezpublish-legacy | kernel/classes/ezurlwildcard.php | eZURLWildcard.fetchBySourceURL | public static function fetchBySourceURL( $url, $asObject = true )
{
return eZPersistentObject::fetchObject( self::definition(),
null,
array( "source_url" => $url ),
$asObject );
} | php | public static function fetchBySourceURL( $url, $asObject = true )
{
return eZPersistentObject::fetchObject( self::definition(),
null,
array( "source_url" => $url ),
$asObject );
} | [
"public",
"static",
"function",
"fetchBySourceURL",
"(",
"$",
"url",
",",
"$",
"asObject",
"=",
"true",
")",
"{",
"return",
"eZPersistentObject",
"::",
"fetchObject",
"(",
"self",
"::",
"definition",
"(",
")",
",",
"null",
",",
"array",
"(",
"\"source_url\""... | Fetches a wildcard by source url
@param string $url Source URL
@param bool $asObject
@return eZURLWildcard Null if no match was found | [
"Fetches",
"a",
"wildcard",
"by",
"source",
"url"
] | 2493420f527fbc829a8d5bdda402e05d64a20db7 | https://github.com/ezsystems/ezpublish-legacy/blob/2493420f527fbc829a8d5bdda402e05d64a20db7/kernel/classes/ezurlwildcard.php#L168-L174 | train |
ezsystems/ezpublish-legacy | kernel/classes/ezurlwildcard.php | eZURLWildcard.fetchList | public static function fetchList( $offset = false, $limit = false, $asObject = true )
{
return eZPersistentObject::fetchObjectList( self::definition(),
null,
null,
null,
array( 'offset' => $offset, 'length' => $limit ),
$asObject );
} | php | public static function fetchList( $offset = false, $limit = false, $asObject = true )
{
return eZPersistentObject::fetchObjectList( self::definition(),
null,
null,
null,
array( 'offset' => $offset, 'length' => $limit ),
$asObject );
} | [
"public",
"static",
"function",
"fetchList",
"(",
"$",
"offset",
"=",
"false",
",",
"$",
"limit",
"=",
"false",
",",
"$",
"asObject",
"=",
"true",
")",
"{",
"return",
"eZPersistentObject",
"::",
"fetchObjectList",
"(",
"self",
"::",
"definition",
"(",
")",... | Fetches the list of URL wildcards. By defaults, fetches all the wildcards
@param int $offset Offset to limit the list from
@param int $limit Limit to the number of fetched items
@param bool $asObject
@return array[eZURLWildcard] | [
"Fetches",
"the",
"list",
"of",
"URL",
"wildcards",
".",
"By",
"defaults",
"fetches",
"all",
"the",
"wildcards"
] | 2493420f527fbc829a8d5bdda402e05d64a20db7 | https://github.com/ezsystems/ezpublish-legacy/blob/2493420f527fbc829a8d5bdda402e05d64a20db7/kernel/classes/ezurlwildcard.php#L183-L191 | train |
ezsystems/ezpublish-legacy | kernel/classes/ezurlwildcard.php | eZURLWildcard.fetchListCount | public static function fetchListCount()
{
$rows = eZPersistentObject::fetchObjectList( self::definition(),
array(),
null,
false,
null,
false, false,
array( array( 'operation' => 'count( * )',
'name' => 'count' ) ) );
return $rows[0]['count'];
} | php | public static function fetchListCount()
{
$rows = eZPersistentObject::fetchObjectList( self::definition(),
array(),
null,
false,
null,
false, false,
array( array( 'operation' => 'count( * )',
'name' => 'count' ) ) );
return $rows[0]['count'];
} | [
"public",
"static",
"function",
"fetchListCount",
"(",
")",
"{",
"$",
"rows",
"=",
"eZPersistentObject",
"::",
"fetchObjectList",
"(",
"self",
"::",
"definition",
"(",
")",
",",
"array",
"(",
")",
",",
"null",
",",
"false",
",",
"null",
",",
"false",
","... | Returns the number of wildcards in the database without any filtering
@return int Number of wildcards in the database | [
"Returns",
"the",
"number",
"of",
"wildcards",
"in",
"the",
"database",
"without",
"any",
"filtering"
] | 2493420f527fbc829a8d5bdda402e05d64a20db7 | https://github.com/ezsystems/ezpublish-legacy/blob/2493420f527fbc829a8d5bdda402e05d64a20db7/kernel/classes/ezurlwildcard.php#L197-L208 | train |
ezsystems/ezpublish-legacy | kernel/classes/ezurlwildcard.php | eZURLWildcard.translate | public static function translate( &$uri )
{
$result = false;
// get uri string
$uriString = ( $uri instanceof eZURI ) ? $uri->elements() : $uri;
$uriString = eZURLAliasML::cleanURL( $uriString );
eZDebugSetting::writeDebug( 'kernel-urltranslator', "input uriString: '$uriString'", __METHOD__ );
if ( !$wildcards = self::wildcardsIndex() )
{
eZDebugSetting::writeDebug( 'kernel-urltranslator', "no match callbacks", __METHOD__ );
return false;
}
$ini = eZINI::instance();
$iteration = $ini->variable( 'URLTranslator', 'MaximumWildcardIterations' );
eZDebugSetting::writeDebug( 'kernel-urltranslator', "MaximumWildcardIterations: '$iteration'", __METHOD__ );
// translate
$urlTranslated = false;
while ( !$urlTranslated && $iteration >= 0 )
{
foreach ( $wildcards as $wildcardNum => $wildcard )
{
if ( preg_match( $wildcard, $uriString ) )
{
eZDebugSetting::writeDebug( 'kernel-urltranslator', "matched with: '$wildcard'", __METHOD__ );
// get new $uriString from wildcard
self::translateWithCache( $wildcardNum, $uriString, $wildcardInfo, $wildcard );
eZDebugSetting::writeDebug( 'kernel-urltranslator', "new uri string: '$uriString'", __METHOD__ );
// optimization: don't try further translation if wildcard type is 'forward'
if ( $wildcardInfo['type'] == self::TYPE_FORWARD )
{
$urlTranslated = true;
break;
}
// try to tranlsate
if ( $urlTranslated = eZURLAliasML::translate( $uriString ) )
{
// success
eZDebugSetting::writeDebug( 'kernel-urltranslator', "uri is translated to '$uriString' with result '$urlTranslated'", __METHOD__ );
break;
}
eZDebugSetting::writeDebug( 'kernel-urltranslator', "uri is not translated, trying another wildcard", __METHOD__ );
// translation failed. Try to match new $uriString with another wildcard.
--$iteration;
continue 2;
}
}
// we here if non of the wildcards is matched
break;
}
// check translation result
// NOTE: 'eZURLAliasML::translate'(see above) can return 'true', 'false' or new url(in case of 'error/301').
// $urlTranslated can also be 'false' if no wildcard is matched.
if ( $urlTranslated )
{
// check wildcard type and set appropriate $result and $uriString
$wildcardType = $wildcardInfo['type'];
eZDebugSetting::writeDebug( 'kernel-urltranslator', "wildcard type: $wildcardType", __METHOD__ );
switch ( $wildcardType )
{
case self::TYPE_FORWARD:
{
// do redirect:
// => set $result to translated uri
// => set uri string to a MOVED PERMANENTLY HTTP code
$result = $uriString;
$uriString = 'error/301';
}
break;
default:
{
eZDebug::writeError( 'Invalid wildcard type.', __METHOD__ );
// no break, using eZURLWildcard::TYPE_DIRECT as fallback
}
case self::TYPE_DIRECT:
{
$result = $urlTranslated;
// $uriString already has correct value
break;
}
}
}
else
{
// we are here if:
// - input url is not matched with any wildcard;
// - url is matched with wildcard and:
// - points to module
// - invalide url
eZDebugSetting::writeDebug( 'kernel-urltranslator', "wildcard is not translated", __METHOD__ );
$result = false;
}
// set value back to $uri
if ( $uri instanceof eZURI )
{
$uri->setURIString( $uriString, false );
}
else
{
$uri = $uriString;
}
eZDebugSetting::writeDebug( 'kernel-urltranslator', "finished with url '$uriString' and result '$result'", __METHOD__ );
return $result;
} | php | public static function translate( &$uri )
{
$result = false;
// get uri string
$uriString = ( $uri instanceof eZURI ) ? $uri->elements() : $uri;
$uriString = eZURLAliasML::cleanURL( $uriString );
eZDebugSetting::writeDebug( 'kernel-urltranslator', "input uriString: '$uriString'", __METHOD__ );
if ( !$wildcards = self::wildcardsIndex() )
{
eZDebugSetting::writeDebug( 'kernel-urltranslator', "no match callbacks", __METHOD__ );
return false;
}
$ini = eZINI::instance();
$iteration = $ini->variable( 'URLTranslator', 'MaximumWildcardIterations' );
eZDebugSetting::writeDebug( 'kernel-urltranslator', "MaximumWildcardIterations: '$iteration'", __METHOD__ );
// translate
$urlTranslated = false;
while ( !$urlTranslated && $iteration >= 0 )
{
foreach ( $wildcards as $wildcardNum => $wildcard )
{
if ( preg_match( $wildcard, $uriString ) )
{
eZDebugSetting::writeDebug( 'kernel-urltranslator', "matched with: '$wildcard'", __METHOD__ );
// get new $uriString from wildcard
self::translateWithCache( $wildcardNum, $uriString, $wildcardInfo, $wildcard );
eZDebugSetting::writeDebug( 'kernel-urltranslator', "new uri string: '$uriString'", __METHOD__ );
// optimization: don't try further translation if wildcard type is 'forward'
if ( $wildcardInfo['type'] == self::TYPE_FORWARD )
{
$urlTranslated = true;
break;
}
// try to tranlsate
if ( $urlTranslated = eZURLAliasML::translate( $uriString ) )
{
// success
eZDebugSetting::writeDebug( 'kernel-urltranslator', "uri is translated to '$uriString' with result '$urlTranslated'", __METHOD__ );
break;
}
eZDebugSetting::writeDebug( 'kernel-urltranslator', "uri is not translated, trying another wildcard", __METHOD__ );
// translation failed. Try to match new $uriString with another wildcard.
--$iteration;
continue 2;
}
}
// we here if non of the wildcards is matched
break;
}
// check translation result
// NOTE: 'eZURLAliasML::translate'(see above) can return 'true', 'false' or new url(in case of 'error/301').
// $urlTranslated can also be 'false' if no wildcard is matched.
if ( $urlTranslated )
{
// check wildcard type and set appropriate $result and $uriString
$wildcardType = $wildcardInfo['type'];
eZDebugSetting::writeDebug( 'kernel-urltranslator', "wildcard type: $wildcardType", __METHOD__ );
switch ( $wildcardType )
{
case self::TYPE_FORWARD:
{
// do redirect:
// => set $result to translated uri
// => set uri string to a MOVED PERMANENTLY HTTP code
$result = $uriString;
$uriString = 'error/301';
}
break;
default:
{
eZDebug::writeError( 'Invalid wildcard type.', __METHOD__ );
// no break, using eZURLWildcard::TYPE_DIRECT as fallback
}
case self::TYPE_DIRECT:
{
$result = $urlTranslated;
// $uriString already has correct value
break;
}
}
}
else
{
// we are here if:
// - input url is not matched with any wildcard;
// - url is matched with wildcard and:
// - points to module
// - invalide url
eZDebugSetting::writeDebug( 'kernel-urltranslator', "wildcard is not translated", __METHOD__ );
$result = false;
}
// set value back to $uri
if ( $uri instanceof eZURI )
{
$uri->setURIString( $uriString, false );
}
else
{
$uri = $uriString;
}
eZDebugSetting::writeDebug( 'kernel-urltranslator', "finished with url '$uriString' and result '$result'", __METHOD__ );
return $result;
} | [
"public",
"static",
"function",
"translate",
"(",
"&",
"$",
"uri",
")",
"{",
"$",
"result",
"=",
"false",
";",
"// get uri string",
"$",
"uriString",
"=",
"(",
"$",
"uri",
"instanceof",
"eZURI",
")",
"?",
"$",
"uri",
"->",
"elements",
"(",
")",
":",
... | Transforms the URI if there exists an alias for it.
@param eZURI|string $uri
@return mixed The translated URI if the resource has moved, or true|false
if translation was (un)successful | [
"Transforms",
"the",
"URI",
"if",
"there",
"exists",
"an",
"alias",
"for",
"it",
"."
] | 2493420f527fbc829a8d5bdda402e05d64a20db7 | https://github.com/ezsystems/ezpublish-legacy/blob/2493420f527fbc829a8d5bdda402e05d64a20db7/kernel/classes/ezurlwildcard.php#L217-L339 | train |
ezsystems/ezpublish-legacy | kernel/classes/ezurlwildcard.php | eZURLWildcard.cacheInfoDirectories | protected static function cacheInfoDirectories( &$wildcardCacheDir, &$wildcardCacheFile, &$wildcardCachePath, &$wildcardKeys )
{
$info = self::cacheInfo();
$wildcardCacheDir = $info['dir'];
$wildcardCacheFile = $info['file'];
$wildcardCachePath = $info['path'];
$wildcardKeys = $info['keys'];
} | php | protected static function cacheInfoDirectories( &$wildcardCacheDir, &$wildcardCacheFile, &$wildcardCachePath, &$wildcardKeys )
{
$info = self::cacheInfo();
$wildcardCacheDir = $info['dir'];
$wildcardCacheFile = $info['file'];
$wildcardCachePath = $info['path'];
$wildcardKeys = $info['keys'];
} | [
"protected",
"static",
"function",
"cacheInfoDirectories",
"(",
"&",
"$",
"wildcardCacheDir",
",",
"&",
"$",
"wildcardCacheFile",
",",
"&",
"$",
"wildcardCachePath",
",",
"&",
"$",
"wildcardKeys",
")",
"{",
"$",
"info",
"=",
"self",
"::",
"cacheInfo",
"(",
"... | Sets the various cache information to the parameters.
@private | [
"Sets",
"the",
"various",
"cache",
"information",
"to",
"the",
"parameters",
"."
] | 2493420f527fbc829a8d5bdda402e05d64a20db7 | https://github.com/ezsystems/ezpublish-legacy/blob/2493420f527fbc829a8d5bdda402e05d64a20db7/kernel/classes/ezurlwildcard.php#L378-L385 | train |
ezsystems/ezpublish-legacy | kernel/classes/ezurlwildcard.php | eZURLWildcard.expireCache | public static function expireCache()
{
$handler = eZExpiryHandler::instance();
$handler->setTimestamp( self::CACHE_SIGNATURE, time() );
$handler->store();
self::$wildcardsIndex = null;
} | php | public static function expireCache()
{
$handler = eZExpiryHandler::instance();
$handler->setTimestamp( self::CACHE_SIGNATURE, time() );
$handler->store();
self::$wildcardsIndex = null;
} | [
"public",
"static",
"function",
"expireCache",
"(",
")",
"{",
"$",
"handler",
"=",
"eZExpiryHandler",
"::",
"instance",
"(",
")",
";",
"$",
"handler",
"->",
"setTimestamp",
"(",
"self",
"::",
"CACHE_SIGNATURE",
",",
"time",
"(",
")",
")",
";",
"$",
"hand... | Expires the wildcard cache. This causes the wildcard cache to be
regenerated on the next page load.
@return void | [
"Expires",
"the",
"wildcard",
"cache",
".",
"This",
"causes",
"the",
"wildcard",
"cache",
"to",
"be",
"regenerated",
"on",
"the",
"next",
"page",
"load",
"."
] | 2493420f527fbc829a8d5bdda402e05d64a20db7 | https://github.com/ezsystems/ezpublish-legacy/blob/2493420f527fbc829a8d5bdda402e05d64a20db7/kernel/classes/ezurlwildcard.php#L392-L399 | train |
ezsystems/ezpublish-legacy | kernel/classes/ezurlwildcard.php | eZURLWildcard.expiryTimestamp | protected static function expiryTimestamp()
{
$handler = eZExpiryHandler::instance();
if ( $handler->hasTimestamp( self::CACHE_SIGNATURE ) )
{
$ret = $handler->timestamp( self::CACHE_SIGNATURE );
}
else
{
$ret = false;
}
return $ret;
} | php | protected static function expiryTimestamp()
{
$handler = eZExpiryHandler::instance();
if ( $handler->hasTimestamp( self::CACHE_SIGNATURE ) )
{
$ret = $handler->timestamp( self::CACHE_SIGNATURE );
}
else
{
$ret = false;
}
return $ret;
} | [
"protected",
"static",
"function",
"expiryTimestamp",
"(",
")",
"{",
"$",
"handler",
"=",
"eZExpiryHandler",
"::",
"instance",
"(",
")",
";",
"if",
"(",
"$",
"handler",
"->",
"hasTimestamp",
"(",
"self",
"::",
"CACHE_SIGNATURE",
")",
")",
"{",
"$",
"ret",
... | Returns the expiry timestamp for wildcard cache from eZExpiryHandler
@return int|bool the timestamp if set, false otherwise | [
"Returns",
"the",
"expiry",
"timestamp",
"for",
"wildcard",
"cache",
"from",
"eZExpiryHandler"
] | 2493420f527fbc829a8d5bdda402e05d64a20db7 | https://github.com/ezsystems/ezpublish-legacy/blob/2493420f527fbc829a8d5bdda402e05d64a20db7/kernel/classes/ezurlwildcard.php#L405-L417 | train |
ezsystems/ezpublish-legacy | kernel/classes/ezurlwildcard.php | eZURLWildcard.wildcardsIndex | protected static function wildcardsIndex()
{
if ( self::$wildcardsIndex === null )
{
$cacheIndexFile = self::loadCacheFile();
// if NULL is returned, the cache doesn't exist or isn't valid
self::$wildcardsIndex = $cacheIndexFile->processFile( array( __CLASS__, 'fetchCacheFile' ), self::expiryTimestamp() );
if ( self::$wildcardsIndex === null )
{
// This will generate and return the index, and store the cache
// files for the different wildcards for later use
self::$wildcardsIndex = self::createWildcardsIndex();
}
}
return self::$wildcardsIndex;
} | php | protected static function wildcardsIndex()
{
if ( self::$wildcardsIndex === null )
{
$cacheIndexFile = self::loadCacheFile();
// if NULL is returned, the cache doesn't exist or isn't valid
self::$wildcardsIndex = $cacheIndexFile->processFile( array( __CLASS__, 'fetchCacheFile' ), self::expiryTimestamp() );
if ( self::$wildcardsIndex === null )
{
// This will generate and return the index, and store the cache
// files for the different wildcards for later use
self::$wildcardsIndex = self::createWildcardsIndex();
}
}
return self::$wildcardsIndex;
} | [
"protected",
"static",
"function",
"wildcardsIndex",
"(",
")",
"{",
"if",
"(",
"self",
"::",
"$",
"wildcardsIndex",
"===",
"null",
")",
"{",
"$",
"cacheIndexFile",
"=",
"self",
"::",
"loadCacheFile",
"(",
")",
";",
"// if NULL is returned, the cache doesn't exist ... | Assign function names to input variables. Generates the wildcard cache if
expired.
@return array The wildcards index, as an array of regexps | [
"Assign",
"function",
"names",
"to",
"input",
"variables",
".",
"Generates",
"the",
"wildcard",
"cache",
"if",
"expired",
"."
] | 2493420f527fbc829a8d5bdda402e05d64a20db7 | https://github.com/ezsystems/ezpublish-legacy/blob/2493420f527fbc829a8d5bdda402e05d64a20db7/kernel/classes/ezurlwildcard.php#L425-L442 | train |
ezsystems/ezpublish-legacy | kernel/classes/ezurlwildcard.php | eZURLWildcard.createWildcardsIndex | protected static function createWildcardsIndex()
{
self::cacheInfoDirectories( $wildcardCacheDir, $wildcardCacheFile, $wildcardCachePath, $wildcardKeys );
if ( !file_exists( $wildcardCacheDir ) )
{
eZDir::mkdir( $wildcardCacheDir, false, true );
}
// Index file (wildcard_md5_index.php)
$wildcardsIndex = array();
$limit = self::WILDCARDS_PER_CACHE_FILE;
$offset = 0;
$cacheFilesCount = 0;
$wildcardNum = 0;
while( 1 )
{
$wildcards = self::fetchList( $offset, $limit, false );
if ( count( $wildcards ) === 0 )
{
break;
}
// sub cache file (wildcard_md5_<i>.php)
$wildcardDetails = array();
$currentSubCacheFile = self::loadCacheFile( $cacheFilesCount );
foreach ( $wildcards as $wildcard )
{
$wildcardsIndex[] = self::matchRegexpCode( $wildcard );
$wildcardDetails[$wildcardNum] = self::matchReplaceCode( $wildcard );
++$wildcardNum;
}
$binaryData = "<" . "?php\nreturn ". var_export( $wildcardDetails, true ) . ";\n?" . ">\n";
$currentSubCacheFile->storeContents( $binaryData, "wildcard-cache-$cacheFilesCount", 'php', true );
$offset += $limit;
++$cacheFilesCount;
}
$indexCacheFile = self::loadCacheFile();
$indexBinaryData = "<" . "?php\nreturn ". var_export( $wildcardsIndex, true ) . ";\n?" . ">\n";
$indexCacheFile->storeContents( $indexBinaryData, "wildcard-cache-index", 'php', true );
return $wildcardsIndex;
// end index cache file
} | php | protected static function createWildcardsIndex()
{
self::cacheInfoDirectories( $wildcardCacheDir, $wildcardCacheFile, $wildcardCachePath, $wildcardKeys );
if ( !file_exists( $wildcardCacheDir ) )
{
eZDir::mkdir( $wildcardCacheDir, false, true );
}
// Index file (wildcard_md5_index.php)
$wildcardsIndex = array();
$limit = self::WILDCARDS_PER_CACHE_FILE;
$offset = 0;
$cacheFilesCount = 0;
$wildcardNum = 0;
while( 1 )
{
$wildcards = self::fetchList( $offset, $limit, false );
if ( count( $wildcards ) === 0 )
{
break;
}
// sub cache file (wildcard_md5_<i>.php)
$wildcardDetails = array();
$currentSubCacheFile = self::loadCacheFile( $cacheFilesCount );
foreach ( $wildcards as $wildcard )
{
$wildcardsIndex[] = self::matchRegexpCode( $wildcard );
$wildcardDetails[$wildcardNum] = self::matchReplaceCode( $wildcard );
++$wildcardNum;
}
$binaryData = "<" . "?php\nreturn ". var_export( $wildcardDetails, true ) . ";\n?" . ">\n";
$currentSubCacheFile->storeContents( $binaryData, "wildcard-cache-$cacheFilesCount", 'php', true );
$offset += $limit;
++$cacheFilesCount;
}
$indexCacheFile = self::loadCacheFile();
$indexBinaryData = "<" . "?php\nreturn ". var_export( $wildcardsIndex, true ) . ";\n?" . ">\n";
$indexCacheFile->storeContents( $indexBinaryData, "wildcard-cache-index", 'php', true );
return $wildcardsIndex;
// end index cache file
} | [
"protected",
"static",
"function",
"createWildcardsIndex",
"(",
")",
"{",
"self",
"::",
"cacheInfoDirectories",
"(",
"$",
"wildcardCacheDir",
",",
"$",
"wildcardCacheFile",
",",
"$",
"wildcardCachePath",
",",
"$",
"wildcardKeys",
")",
";",
"if",
"(",
"!",
"file_... | Create the wildcard cache
The wildcard caches are splitted between several files:
'wildcard_<md5>_index.php': contains regexps for wildcards
'wildcard_<md5>_0.php',
'wildcard_<md5>_1.php',
...
'wildcard_<md5>_N.php': contains cached wildcards.
Each file has info about eZURLWildcard::WILDCARDS_PER_CACHE_FILE wildcards.
@return array | [
"Create",
"the",
"wildcard",
"cache"
] | 2493420f527fbc829a8d5bdda402e05d64a20db7 | https://github.com/ezsystems/ezpublish-legacy/blob/2493420f527fbc829a8d5bdda402e05d64a20db7/kernel/classes/ezurlwildcard.php#L457-L503 | train |
ezsystems/ezpublish-legacy | kernel/classes/ezurlwildcard.php | eZURLWildcard.loadCacheFile | protected static function loadCacheFile( $cacheID = 'index' )
{
if ( isset( self::$cacheFiles[$cacheID] ) )
{
return self::$cacheFiles[$cacheID];
}
$info = self::cacheInfo();
$cacheFileName = $info['path'] . '_' . $cacheID . '.php';
self::$cacheFiles[$cacheID] = eZClusterFileHandler::instance( $cacheFileName );
return self::$cacheFiles[$cacheID];
} | php | protected static function loadCacheFile( $cacheID = 'index' )
{
if ( isset( self::$cacheFiles[$cacheID] ) )
{
return self::$cacheFiles[$cacheID];
}
$info = self::cacheInfo();
$cacheFileName = $info['path'] . '_' . $cacheID . '.php';
self::$cacheFiles[$cacheID] = eZClusterFileHandler::instance( $cacheFileName );
return self::$cacheFiles[$cacheID];
} | [
"protected",
"static",
"function",
"loadCacheFile",
"(",
"$",
"cacheID",
"=",
"'index'",
")",
"{",
"if",
"(",
"isset",
"(",
"self",
"::",
"$",
"cacheFiles",
"[",
"$",
"cacheID",
"]",
")",
")",
"{",
"return",
"self",
"::",
"$",
"cacheFiles",
"[",
"$",
... | Loads and returns the cluster handler instance for the requested cache file.
The instance will be returned even if the file doesn't exist
@param $cacheID Cache file number. Will load the index if not provided.
@return eZClusterFileHandlerInterface | [
"Loads",
"and",
"returns",
"the",
"cluster",
"handler",
"instance",
"for",
"the",
"requested",
"cache",
"file",
".",
"The",
"instance",
"will",
"be",
"returned",
"even",
"if",
"the",
"file",
"doesn",
"t",
"exist"
] | 2493420f527fbc829a8d5bdda402e05d64a20db7 | https://github.com/ezsystems/ezpublish-legacy/blob/2493420f527fbc829a8d5bdda402e05d64a20db7/kernel/classes/ezurlwildcard.php#L620-L632 | train |
ezsystems/ezpublish-legacy | lib/ezutils/classes/ezoperationhandler.php | eZOperationHandler.moduleOperationInfo | static function moduleOperationInfo( $moduleName, $useTriggers = true )
{
if ( !isset( $GLOBALS['eZGlobalModuleOperationList'] ) )
{
$GLOBALS['eZGlobalModuleOperationList'] = array();
}
if ( isset( $GLOBALS['eZGlobalModuleOperationList'][$moduleName] ) )
{
return $GLOBALS['eZGlobalModuleOperationList'][$moduleName];
}
$moduleOperationInfo = new eZModuleOperationInfo( $moduleName, $useTriggers );
$moduleOperationInfo->loadDefinition();
return $GLOBALS['eZGlobalModuleOperationList'][$moduleName] = $moduleOperationInfo;
} | php | static function moduleOperationInfo( $moduleName, $useTriggers = true )
{
if ( !isset( $GLOBALS['eZGlobalModuleOperationList'] ) )
{
$GLOBALS['eZGlobalModuleOperationList'] = array();
}
if ( isset( $GLOBALS['eZGlobalModuleOperationList'][$moduleName] ) )
{
return $GLOBALS['eZGlobalModuleOperationList'][$moduleName];
}
$moduleOperationInfo = new eZModuleOperationInfo( $moduleName, $useTriggers );
$moduleOperationInfo->loadDefinition();
return $GLOBALS['eZGlobalModuleOperationList'][$moduleName] = $moduleOperationInfo;
} | [
"static",
"function",
"moduleOperationInfo",
"(",
"$",
"moduleName",
",",
"$",
"useTriggers",
"=",
"true",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"GLOBALS",
"[",
"'eZGlobalModuleOperationList'",
"]",
")",
")",
"{",
"$",
"GLOBALS",
"[",
"'eZGlobalModule... | Factory for modules' moduleOperationInfo objects.
@param string $moduleName
@param bool $useTriggers*
@return eZModuleOperationInfo | [
"Factory",
"for",
"modules",
"moduleOperationInfo",
"objects",
"."
] | 2493420f527fbc829a8d5bdda402e05d64a20db7 | https://github.com/ezsystems/ezpublish-legacy/blob/2493420f527fbc829a8d5bdda402e05d64a20db7/lib/ezutils/classes/ezoperationhandler.php#L27-L40 | train |
ezsystems/ezpublish-legacy | kernel/private/classes/ezpcontentpublishingprocess.php | ezpContentPublishingProcess.version | public function version()
{
if ( $this->versionObject === null )
$this->versionObject = eZContentObjectVersion::fetch( $this->attribute( 'ezcontentobject_version_id' ) );
return $this->versionObject;
} | php | public function version()
{
if ( $this->versionObject === null )
$this->versionObject = eZContentObjectVersion::fetch( $this->attribute( 'ezcontentobject_version_id' ) );
return $this->versionObject;
} | [
"public",
"function",
"version",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"versionObject",
"===",
"null",
")",
"$",
"this",
"->",
"versionObject",
"=",
"eZContentObjectVersion",
"::",
"fetch",
"(",
"$",
"this",
"->",
"attribute",
"(",
"'ezcontentobject_v... | Returns the version object the process is linked to
@return eZContentObjectVersion | [
"Returns",
"the",
"version",
"object",
"the",
"process",
"is",
"linked",
"to"
] | 2493420f527fbc829a8d5bdda402e05d64a20db7 | https://github.com/ezsystems/ezpublish-legacy/blob/2493420f527fbc829a8d5bdda402e05d64a20db7/kernel/private/classes/ezpcontentpublishingprocess.php#L80-L86 | train |
ezsystems/ezpublish-legacy | kernel/private/classes/ezpcontentpublishingprocess.php | ezpContentPublishingProcess.fetchByContentObjectVersion | public static function fetchByContentObjectVersion( $contentObjectId, $version )
{
$contentObjectVersion = eZContentObjectVersion::fetchVersion( $version, $contentObjectId );
if ( $contentObjectVersion instanceof eZContentObjectVersion )
{
$return = self::fetchByContentVersionId( $contentObjectVersion->attribute( 'id' ) );
return $return;
}
else
{
return false;
}
} | php | public static function fetchByContentObjectVersion( $contentObjectId, $version )
{
$contentObjectVersion = eZContentObjectVersion::fetchVersion( $version, $contentObjectId );
if ( $contentObjectVersion instanceof eZContentObjectVersion )
{
$return = self::fetchByContentVersionId( $contentObjectVersion->attribute( 'id' ) );
return $return;
}
else
{
return false;
}
} | [
"public",
"static",
"function",
"fetchByContentObjectVersion",
"(",
"$",
"contentObjectId",
",",
"$",
"version",
")",
"{",
"$",
"contentObjectVersion",
"=",
"eZContentObjectVersion",
"::",
"fetchVersion",
"(",
"$",
"version",
",",
"$",
"contentObjectId",
")",
";",
... | Fetches a process by its content object ID + version
@param int $contentObjectId
@param int $version
@return ezpContentPublishingProcess | [
"Fetches",
"a",
"process",
"by",
"its",
"content",
"object",
"ID",
"+",
"version"
] | 2493420f527fbc829a8d5bdda402e05d64a20db7 | https://github.com/ezsystems/ezpublish-legacy/blob/2493420f527fbc829a8d5bdda402e05d64a20db7/kernel/private/classes/ezpcontentpublishingprocess.php#L108-L120 | train |
ezsystems/ezpublish-legacy | kernel/private/classes/ezpcontentpublishingprocess.php | ezpContentPublishingProcess.isProcessing | public static function isProcessing( eZContentObjectVersion $versionObject )
{
$count = parent::count(
self::definition(),
array(
'ezcontentobject_version_id' => $versionObject->attribute( 'id' ),
// 'status' => self::STATUS_WORKING // not used yet
)
);
return ( $count != 0 );
} | php | public static function isProcessing( eZContentObjectVersion $versionObject )
{
$count = parent::count(
self::definition(),
array(
'ezcontentobject_version_id' => $versionObject->attribute( 'id' ),
// 'status' => self::STATUS_WORKING // not used yet
)
);
return ( $count != 0 );
} | [
"public",
"static",
"function",
"isProcessing",
"(",
"eZContentObjectVersion",
"$",
"versionObject",
")",
"{",
"$",
"count",
"=",
"parent",
"::",
"count",
"(",
"self",
"::",
"definition",
"(",
")",
",",
"array",
"(",
"'ezcontentobject_version_id'",
"=>",
"$",
... | Checks if an object is already being processed
@param eZContentObjectVersion $versionObject
@return bool | [
"Checks",
"if",
"an",
"object",
"is",
"already",
"being",
"processed"
] | 2493420f527fbc829a8d5bdda402e05d64a20db7 | https://github.com/ezsystems/ezpublish-legacy/blob/2493420f527fbc829a8d5bdda402e05d64a20db7/kernel/private/classes/ezpcontentpublishingprocess.php#L136-L146 | train |
ezsystems/ezpublish-legacy | kernel/private/classes/ezpcontentpublishingprocess.php | ezpContentPublishingProcess.queue | public static function queue( eZContentObjectVersion $version )
{
$row = array(
'ezcontentobject_version_id' => $version->attribute( 'id' ),
'created' => time(),
'status' => self::STATUS_PENDING,
);
$processObject = new self( $row );
$processObject->store();
return $processObject;
} | php | public static function queue( eZContentObjectVersion $version )
{
$row = array(
'ezcontentobject_version_id' => $version->attribute( 'id' ),
'created' => time(),
'status' => self::STATUS_PENDING,
);
$processObject = new self( $row );
$processObject->store();
return $processObject;
} | [
"public",
"static",
"function",
"queue",
"(",
"eZContentObjectVersion",
"$",
"version",
")",
"{",
"$",
"row",
"=",
"array",
"(",
"'ezcontentobject_version_id'",
"=>",
"$",
"version",
"->",
"attribute",
"(",
"'id'",
")",
",",
"'created'",
"=>",
"time",
"(",
"... | Adds a version to the publishing queue
@param eZContentObjectVersion $version
@return ezpContentPublishingProcess | [
"Adds",
"a",
"version",
"to",
"the",
"publishing",
"queue"
] | 2493420f527fbc829a8d5bdda402e05d64a20db7 | https://github.com/ezsystems/ezpublish-legacy/blob/2493420f527fbc829a8d5bdda402e05d64a20db7/kernel/private/classes/ezpcontentpublishingprocess.php#L279-L290 | train |
ezsystems/ezpublish-legacy | kernel/private/classes/ezpcontentpublishingprocess.php | ezpContentPublishingProcess.fetchProcesses | public static function fetchProcesses( $status )
{
if ( !in_array( $status, array( self::STATUS_FINISHED, self::STATUS_PENDING, self::STATUS_WORKING ) ) )
throw new ezcBaseValueException( '$status', $status, array( self::STATUS_FINISHED, self::STATUS_PENDING, self::STATUS_WORKING ), 'parameter' );
return parent::fetchObjectList( self::definition(), false,
array( 'status' => $status ),
array( 'created' => 'asc' ) );
} | php | public static function fetchProcesses( $status )
{
if ( !in_array( $status, array( self::STATUS_FINISHED, self::STATUS_PENDING, self::STATUS_WORKING ) ) )
throw new ezcBaseValueException( '$status', $status, array( self::STATUS_FINISHED, self::STATUS_PENDING, self::STATUS_WORKING ), 'parameter' );
return parent::fetchObjectList( self::definition(), false,
array( 'status' => $status ),
array( 'created' => 'asc' ) );
} | [
"public",
"static",
"function",
"fetchProcesses",
"(",
"$",
"status",
")",
"{",
"if",
"(",
"!",
"in_array",
"(",
"$",
"status",
",",
"array",
"(",
"self",
"::",
"STATUS_FINISHED",
",",
"self",
"::",
"STATUS_PENDING",
",",
"self",
"::",
"STATUS_WORKING",
")... | Fetches processes, filtered by status
@param int $status One of ezpContentPublishingProcess::STATUS_*
@return array( ezpContentPublishingProcess ) | [
"Fetches",
"processes",
"filtered",
"by",
"status"
] | 2493420f527fbc829a8d5bdda402e05d64a20db7 | https://github.com/ezsystems/ezpublish-legacy/blob/2493420f527fbc829a8d5bdda402e05d64a20db7/kernel/private/classes/ezpcontentpublishingprocess.php#L297-L305 | train |
ezsystems/ezpublish-legacy | kernel/private/classes/ezpcontentpublishingprocess.php | ezpContentPublishingProcess.isAlive | public function isAlive()
{
if ( $this->attribute( 'status' ) != self::STATUS_WORKING )
throw new Exception( 'The process\'s status isn\'t \'working\'' );
// sending 0 only checks if the process is alive (and if the current process is allowed to send signals to it)
$return = ( posix_kill( $this->attribute( 'pid' ), 0 ) === true );
return $return;
} | php | public function isAlive()
{
if ( $this->attribute( 'status' ) != self::STATUS_WORKING )
throw new Exception( 'The process\'s status isn\'t \'working\'' );
// sending 0 only checks if the process is alive (and if the current process is allowed to send signals to it)
$return = ( posix_kill( $this->attribute( 'pid' ), 0 ) === true );
return $return;
} | [
"public",
"function",
"isAlive",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"attribute",
"(",
"'status'",
")",
"!=",
"self",
"::",
"STATUS_WORKING",
")",
"throw",
"new",
"Exception",
"(",
"'The process\\'s status isn\\'t \\'working\\''",
")",
";",
"// sending ... | Checks if the system process is running
@return bool
@throws Exception if the process isn't in WORKING status | [
"Checks",
"if",
"the",
"system",
"process",
"is",
"running"
] | 2493420f527fbc829a8d5bdda402e05d64a20db7 | https://github.com/ezsystems/ezpublish-legacy/blob/2493420f527fbc829a8d5bdda402e05d64a20db7/kernel/private/classes/ezpcontentpublishingprocess.php#L313-L321 | train |
ezsystems/ezpublish-legacy | kernel/private/classes/ezpcontentpublishingprocess.php | ezpContentPublishingProcess.reset | public function reset( $message )
{
$this->setStatus( self::STATUS_PENDING, false, "::reset() with message '$message'" );
$this->setAttribute( 'pid', 0 );
$this->store( array( 'status', 'pid' ) );
} | php | public function reset( $message )
{
$this->setStatus( self::STATUS_PENDING, false, "::reset() with message '$message'" );
$this->setAttribute( 'pid', 0 );
$this->store( array( 'status', 'pid' ) );
} | [
"public",
"function",
"reset",
"(",
"$",
"message",
")",
"{",
"$",
"this",
"->",
"setStatus",
"(",
"self",
"::",
"STATUS_PENDING",
",",
"false",
",",
"\"::reset() with message '$message'\"",
")",
";",
"$",
"this",
"->",
"setAttribute",
"(",
"'pid'",
",",
"0"... | Resets the current process to the PENDING state
@todo Monitor the reset operation, using some kind of counter. The process must NOT get high priority, as it
might block a slot if it fails constantly
Maybe use a STATUS_RESET status, that gives lower priority to the item | [
"Resets",
"the",
"current",
"process",
"to",
"the",
"PENDING",
"state"
] | 2493420f527fbc829a8d5bdda402e05d64a20db7 | https://github.com/ezsystems/ezpublish-legacy/blob/2493420f527fbc829a8d5bdda402e05d64a20db7/kernel/private/classes/ezpcontentpublishingprocess.php#L330-L335 | train |
ezsystems/ezpublish-legacy | kernel/private/classes/ezpcontentpublishingprocess.php | ezpContentPublishingProcess.logStatusChange | private function logStatusChange( $status, $reason = null )
{
$contentObjectId = $this->version()->attribute( 'contentobject_id' );
$versionNumber = $this->version()->attribute( 'version' );
eZDebugSetting::writeDebug(
'kernel-content-publish',
sprintf(
"process #%d, content %d.%d, status changed to %s (reason: %s)",
$this->attribute( 'ezcontentobject_version_id' ),
$contentObjectId,
$versionNumber,
$this->getStatusString( $status ),
$reason ?: "none given"
),
'Asynchronous publishing process status changed'
);
} | php | private function logStatusChange( $status, $reason = null )
{
$contentObjectId = $this->version()->attribute( 'contentobject_id' );
$versionNumber = $this->version()->attribute( 'version' );
eZDebugSetting::writeDebug(
'kernel-content-publish',
sprintf(
"process #%d, content %d.%d, status changed to %s (reason: %s)",
$this->attribute( 'ezcontentobject_version_id' ),
$contentObjectId,
$versionNumber,
$this->getStatusString( $status ),
$reason ?: "none given"
),
'Asynchronous publishing process status changed'
);
} | [
"private",
"function",
"logStatusChange",
"(",
"$",
"status",
",",
"$",
"reason",
"=",
"null",
")",
"{",
"$",
"contentObjectId",
"=",
"$",
"this",
"->",
"version",
"(",
")",
"->",
"attribute",
"(",
"'contentobject_id'",
")",
";",
"$",
"versionNumber",
"=",... | Logs a debug message when the process' status is updated
@param string $status New status
@param null $reason Optional reason | [
"Logs",
"a",
"debug",
"message",
"when",
"the",
"process",
"status",
"is",
"updated"
] | 2493420f527fbc829a8d5bdda402e05d64a20db7 | https://github.com/ezsystems/ezpublish-legacy/blob/2493420f527fbc829a8d5bdda402e05d64a20db7/kernel/private/classes/ezpcontentpublishingprocess.php#L358-L374 | train |
ezsystems/ezpublish-legacy | kernel/classes/ezvatmanager.php | eZVATManager.getVAT | static function getVAT( $object, $country )
{
// Load VAT handler.
if ( !is_object( $handler = eZVATManager::loadVATHandler() ) )
{
if ( $handler === true )
{
eZDebug::writeWarning( "No VAT handler specified but dynamic VAT charging is used." );
}
return null;
}
// Check if user country must be specified.
$requireUserCountry = eZVATManager::isUserCountryRequired();
// Determine user country if it's not specified
if ( $country === false )
$country = eZVATManager::getUserCountry();
if ( !$country && $requireUserCountry )
{
eZDebug::writeNotice( "User country is not specified." );
}
return $handler->getVatPercent( $object, $country );
} | php | static function getVAT( $object, $country )
{
// Load VAT handler.
if ( !is_object( $handler = eZVATManager::loadVATHandler() ) )
{
if ( $handler === true )
{
eZDebug::writeWarning( "No VAT handler specified but dynamic VAT charging is used." );
}
return null;
}
// Check if user country must be specified.
$requireUserCountry = eZVATManager::isUserCountryRequired();
// Determine user country if it's not specified
if ( $country === false )
$country = eZVATManager::getUserCountry();
if ( !$country && $requireUserCountry )
{
eZDebug::writeNotice( "User country is not specified." );
}
return $handler->getVatPercent( $object, $country );
} | [
"static",
"function",
"getVAT",
"(",
"$",
"object",
",",
"$",
"country",
")",
"{",
"// Load VAT handler.",
"if",
"(",
"!",
"is_object",
"(",
"$",
"handler",
"=",
"eZVATManager",
"::",
"loadVATHandler",
"(",
")",
")",
")",
"{",
"if",
"(",
"$",
"handler",
... | Get percentage of VAT type corresponding to the given product and country the user is from.
\return Percentage, or null on error.
\public
\static | [
"Get",
"percentage",
"of",
"VAT",
"type",
"corresponding",
"to",
"the",
"given",
"product",
"and",
"country",
"the",
"user",
"is",
"from",
"."
] | 2493420f527fbc829a8d5bdda402e05d64a20db7 | https://github.com/ezsystems/ezpublish-legacy/blob/2493420f527fbc829a8d5bdda402e05d64a20db7/kernel/classes/ezvatmanager.php#L26-L52 | train |
ezsystems/ezpublish-legacy | kernel/classes/ezvatmanager.php | eZVATManager.isUserCountryRequired | static function isUserCountryRequired()
{
// Check if user country must be specified.
$requireUserCountry = true;
$shopINI = eZINI::instance( 'shop.ini' );
if ( $shopINI->hasVariable( 'VATSettings', 'RequireUserCountry' ) )
$requireUserCountry = ( $shopINI->variable( 'VATSettings', 'RequireUserCountry' ) == 'true' );
return $requireUserCountry;
} | php | static function isUserCountryRequired()
{
// Check if user country must be specified.
$requireUserCountry = true;
$shopINI = eZINI::instance( 'shop.ini' );
if ( $shopINI->hasVariable( 'VATSettings', 'RequireUserCountry' ) )
$requireUserCountry = ( $shopINI->variable( 'VATSettings', 'RequireUserCountry' ) == 'true' );
return $requireUserCountry;
} | [
"static",
"function",
"isUserCountryRequired",
"(",
")",
"{",
"// Check if user country must be specified.",
"$",
"requireUserCountry",
"=",
"true",
";",
"$",
"shopINI",
"=",
"eZINI",
"::",
"instance",
"(",
"'shop.ini'",
")",
";",
"if",
"(",
"$",
"shopINI",
"->",
... | Check if users must have country specified.
\public
\static | [
"Check",
"if",
"users",
"must",
"have",
"country",
"specified",
"."
] | 2493420f527fbc829a8d5bdda402e05d64a20db7 | https://github.com/ezsystems/ezpublish-legacy/blob/2493420f527fbc829a8d5bdda402e05d64a20db7/kernel/classes/ezvatmanager.php#L60-L68 | train |
ezsystems/ezpublish-legacy | kernel/classes/ezvatmanager.php | eZVATManager.getUserCountryAttributeName | static function getUserCountryAttributeName( $requireUserCountry )
{
$ini = eZINI::instance( 'shop.ini' );
if ( !$ini->hasVariable( 'VATSettings', 'UserCountryAttribute' ) )
{
if ( $requireUserCountry )
{
eZDebug::writeError( "Cannot find user country: please specify its attribute identifier " .
"in the following setting: shop.ini.[VATSettings].UserCountryAttribute",
__METHOD__ );
}
return null;
}
$countryAttributeName = $ini->variable( 'VATSettings', 'UserCountryAttribute' );
if ( !$countryAttributeName )
{
if ( $requireUserCountry )
{
eZDebug::writeError( "Cannot find user country: empty attribute name specified " .
"in the following setting: shop.ini.[VATSettings].UserCountryAttribute",
__METHOD__ );
}
return null;
}
return $countryAttributeName;
} | php | static function getUserCountryAttributeName( $requireUserCountry )
{
$ini = eZINI::instance( 'shop.ini' );
if ( !$ini->hasVariable( 'VATSettings', 'UserCountryAttribute' ) )
{
if ( $requireUserCountry )
{
eZDebug::writeError( "Cannot find user country: please specify its attribute identifier " .
"in the following setting: shop.ini.[VATSettings].UserCountryAttribute",
__METHOD__ );
}
return null;
}
$countryAttributeName = $ini->variable( 'VATSettings', 'UserCountryAttribute' );
if ( !$countryAttributeName )
{
if ( $requireUserCountry )
{
eZDebug::writeError( "Cannot find user country: empty attribute name specified " .
"in the following setting: shop.ini.[VATSettings].UserCountryAttribute",
__METHOD__ );
}
return null;
}
return $countryAttributeName;
} | [
"static",
"function",
"getUserCountryAttributeName",
"(",
"$",
"requireUserCountry",
")",
"{",
"$",
"ini",
"=",
"eZINI",
"::",
"instance",
"(",
"'shop.ini'",
")",
";",
"if",
"(",
"!",
"$",
"ini",
"->",
"hasVariable",
"(",
"'VATSettings'",
",",
"'UserCountryAtt... | Determine name of content attribute that contains user's country.
\private
\static | [
"Determine",
"name",
"of",
"content",
"attribute",
"that",
"contains",
"user",
"s",
"country",
"."
] | 2493420f527fbc829a8d5bdda402e05d64a20db7 | https://github.com/ezsystems/ezpublish-legacy/blob/2493420f527fbc829a8d5bdda402e05d64a20db7/kernel/classes/ezvatmanager.php#L76-L104 | train |
ezsystems/ezpublish-legacy | kernel/classes/ezvatmanager.php | eZVATManager.getUserCountry | static function getUserCountry( $user = false, $considerPreferedCountry = true )
{
$requireUserCountry = eZVATManager::isUserCountryRequired();
// If current user has set his/her preferred country via the toolbar
if ( $considerPreferedCountry )
{
// return it
$country = eZShopFunctions::getPreferredUserCountry();
if ( $country )
{
eZDebug::writeDebug( "Applying user's preferred country <$country> while charging VAT" );
return $country;
}
}
// Otherwise fetch country saved in the user object.
if ( $user === false )
{
$user = eZUser::currentUser();
}
$userObject = $user->attribute( 'contentobject' );
$countryAttributeName = eZVATManager::getUserCountryAttributeName( $requireUserCountry );
if ( $countryAttributeName === null )
return null;
$userDataMap = $userObject->attribute( 'data_map' );
if ( !isset( $userDataMap[$countryAttributeName] ) )
{
if ( $requireUserCountry )
{
eZDebug::writeError( "Cannot find user country: there is no attribute '$countryAttributeName' in object '" .
$userObject->attribute( 'name' ) .
"' of class '" .
$userObject->attribute( 'class_name' ) . "'.",
__METHOD__ );
}
return null;
}
$countryAttribute = $userDataMap[$countryAttributeName];
$countryContent = $countryAttribute->attribute( 'content' );
if ( $countryContent === null )
{
if ( $requireUserCountry )
{
eZDebug::writeError( "User country is not specified in object '" .
$userObject->attribute( 'name' ) .
"' of class '" .
$userObject->attribute( 'class_name' ) . "'." ,
__METHOD__ );
}
return null;
}
if ( is_object( $countryContent ) )
$country = $countryContent->attribute( 'value' );
elseif ( is_array( $countryContent ) )
{
if ( is_array( $countryContent['value'] ) )
{
foreach ( $countryContent['value'] as $item )
{
$country = $item['Alpha2'];
break;
}
}
else
{
$country = $countryContent['value'];
}
}
else
{
if ( $requireUserCountry )
{
eZDebug::writeError( "User country is not specified or specified incorrectly in object '" .
$userObject->attribute( 'name' ) .
"' of class '" .
$userObject->attribute( 'class_name' ) . "'." ,
__METHOD__ );
}
return null;
}
return $country;
} | php | static function getUserCountry( $user = false, $considerPreferedCountry = true )
{
$requireUserCountry = eZVATManager::isUserCountryRequired();
// If current user has set his/her preferred country via the toolbar
if ( $considerPreferedCountry )
{
// return it
$country = eZShopFunctions::getPreferredUserCountry();
if ( $country )
{
eZDebug::writeDebug( "Applying user's preferred country <$country> while charging VAT" );
return $country;
}
}
// Otherwise fetch country saved in the user object.
if ( $user === false )
{
$user = eZUser::currentUser();
}
$userObject = $user->attribute( 'contentobject' );
$countryAttributeName = eZVATManager::getUserCountryAttributeName( $requireUserCountry );
if ( $countryAttributeName === null )
return null;
$userDataMap = $userObject->attribute( 'data_map' );
if ( !isset( $userDataMap[$countryAttributeName] ) )
{
if ( $requireUserCountry )
{
eZDebug::writeError( "Cannot find user country: there is no attribute '$countryAttributeName' in object '" .
$userObject->attribute( 'name' ) .
"' of class '" .
$userObject->attribute( 'class_name' ) . "'.",
__METHOD__ );
}
return null;
}
$countryAttribute = $userDataMap[$countryAttributeName];
$countryContent = $countryAttribute->attribute( 'content' );
if ( $countryContent === null )
{
if ( $requireUserCountry )
{
eZDebug::writeError( "User country is not specified in object '" .
$userObject->attribute( 'name' ) .
"' of class '" .
$userObject->attribute( 'class_name' ) . "'." ,
__METHOD__ );
}
return null;
}
if ( is_object( $countryContent ) )
$country = $countryContent->attribute( 'value' );
elseif ( is_array( $countryContent ) )
{
if ( is_array( $countryContent['value'] ) )
{
foreach ( $countryContent['value'] as $item )
{
$country = $item['Alpha2'];
break;
}
}
else
{
$country = $countryContent['value'];
}
}
else
{
if ( $requireUserCountry )
{
eZDebug::writeError( "User country is not specified or specified incorrectly in object '" .
$userObject->attribute( 'name' ) .
"' of class '" .
$userObject->attribute( 'class_name' ) . "'." ,
__METHOD__ );
}
return null;
}
return $country;
} | [
"static",
"function",
"getUserCountry",
"(",
"$",
"user",
"=",
"false",
",",
"$",
"considerPreferedCountry",
"=",
"true",
")",
"{",
"$",
"requireUserCountry",
"=",
"eZVATManager",
"::",
"isUserCountryRequired",
"(",
")",
";",
"// If current user has set his/her prefer... | Determine user's country.
\public
\static | [
"Determine",
"user",
"s",
"country",
"."
] | 2493420f527fbc829a8d5bdda402e05d64a20db7 | https://github.com/ezsystems/ezpublish-legacy/blob/2493420f527fbc829a8d5bdda402e05d64a20db7/kernel/classes/ezvatmanager.php#L112-L202 | train |
ezsystems/ezpublish-legacy | kernel/classes/ezvatmanager.php | eZVATManager.setUserCountry | static function setUserCountry( $user, $country )
{
$userObject = $user->attribute( 'contentobject' );
$requireUserCountry = eZVATManager::isUserCountryRequired();
$countryAttributeName = eZVATManager::getUserCountryAttributeName( $requireUserCountry );
if ( $countryAttributeName === null )
{
return false;
}
$userDataMap = $userObject->attribute( 'data_map' );
if ( !isset( $userDataMap[$countryAttributeName] ) )
{
if ( $requireUserCountry )
{
eZDebug::writeError( "Cannot set user country: there is no attribute '$countryAttributeName' in object '" .
$userObject->attribute( 'name' ) .
"' of class '" .
$userObject->attribute( 'class_name' ) . "'.",
__METHOD__ );
}
return false;
}
eZDebug::writeNotice( sprintf( "Saving country '%s' for user '%s'",
$country, $user->attribute( 'login' ) ) );
$countryAttribute = $userDataMap[$countryAttributeName];
$countryAttributeContent = $countryAttribute->content();
if ( is_array( $countryAttributeContent ) )
$countryAttributeContent['value'] = $country;
elseif ( is_object( $countryAttributeContent ) )
$countryAttributeContent->setAttribute( 'value', $country );
// not sure that this line is needed since content is returned by reference
$countryAttribute->setContent( $countryAttributeContent );
$countryAttribute->store();
return true;
} | php | static function setUserCountry( $user, $country )
{
$userObject = $user->attribute( 'contentobject' );
$requireUserCountry = eZVATManager::isUserCountryRequired();
$countryAttributeName = eZVATManager::getUserCountryAttributeName( $requireUserCountry );
if ( $countryAttributeName === null )
{
return false;
}
$userDataMap = $userObject->attribute( 'data_map' );
if ( !isset( $userDataMap[$countryAttributeName] ) )
{
if ( $requireUserCountry )
{
eZDebug::writeError( "Cannot set user country: there is no attribute '$countryAttributeName' in object '" .
$userObject->attribute( 'name' ) .
"' of class '" .
$userObject->attribute( 'class_name' ) . "'.",
__METHOD__ );
}
return false;
}
eZDebug::writeNotice( sprintf( "Saving country '%s' for user '%s'",
$country, $user->attribute( 'login' ) ) );
$countryAttribute = $userDataMap[$countryAttributeName];
$countryAttributeContent = $countryAttribute->content();
if ( is_array( $countryAttributeContent ) )
$countryAttributeContent['value'] = $country;
elseif ( is_object( $countryAttributeContent ) )
$countryAttributeContent->setAttribute( 'value', $country );
// not sure that this line is needed since content is returned by reference
$countryAttribute->setContent( $countryAttributeContent );
$countryAttribute->store();
return true;
} | [
"static",
"function",
"setUserCountry",
"(",
"$",
"user",
",",
"$",
"country",
")",
"{",
"$",
"userObject",
"=",
"$",
"user",
"->",
"attribute",
"(",
"'contentobject'",
")",
";",
"$",
"requireUserCountry",
"=",
"eZVATManager",
"::",
"isUserCountryRequired",
"(... | Set user's country.
\public
\static | [
"Set",
"user",
"s",
"country",
"."
] | 2493420f527fbc829a8d5bdda402e05d64a20db7 | https://github.com/ezsystems/ezpublish-legacy/blob/2493420f527fbc829a8d5bdda402e05d64a20db7/kernel/classes/ezvatmanager.php#L210-L249 | train |
ezsystems/ezpublish-legacy | kernel/classes/ezviewcounter.php | eZViewCounter.increase | public function increase( $count = 1 )
{
// The attribute is naively incremented, despite possible updates in the DB.
$this->setAttribute( 'count', $this->attribute( 'count' ) + $count );
// However, we are not using ->store() here so that we atomatically update
// the value of the counter in case it has been updated in parallel.
eZDB::instance()->query(
"UPDATE ezview_counter " .
"SET count = count + " . (int)$count . " " .
"WHERE node_id=" . $this->attribute( "node_id" )
);
} | php | public function increase( $count = 1 )
{
// The attribute is naively incremented, despite possible updates in the DB.
$this->setAttribute( 'count', $this->attribute( 'count' ) + $count );
// However, we are not using ->store() here so that we atomatically update
// the value of the counter in case it has been updated in parallel.
eZDB::instance()->query(
"UPDATE ezview_counter " .
"SET count = count + " . (int)$count . " " .
"WHERE node_id=" . $this->attribute( "node_id" )
);
} | [
"public",
"function",
"increase",
"(",
"$",
"count",
"=",
"1",
")",
"{",
"// The attribute is naively incremented, despite possible updates in the DB.",
"$",
"this",
"->",
"setAttribute",
"(",
"'count'",
",",
"$",
"this",
"->",
"attribute",
"(",
"'count'",
")",
"+",... | Increase the counter.
@param int $count Number of times to increase the counter, by default: 1. | [
"Increase",
"the",
"counter",
"."
] | 2493420f527fbc829a8d5bdda402e05d64a20db7 | https://github.com/ezsystems/ezpublish-legacy/blob/2493420f527fbc829a8d5bdda402e05d64a20db7/kernel/classes/ezviewcounter.php#L70-L81 | train |
ezsystems/ezpublish-legacy | kernel/classes/ezorder.php | eZOrder.productItems | function productItems( $asObject = true, array $sorts = null )
{
$productItems = eZPersistentObject::fetchObjectList( eZProductCollectionItem::definition(),
null,
array( 'productcollection_id' => $this->ProductCollectionID ),
$sorts,
null,
$asObject );
$addedProducts = array();
foreach ( $productItems as $productItem )
{
$contentObject = $productItem->attribute( 'contentobject' );
if ( $this->IgnoreVAT == true )
{
$vatValue = 0;
}
else
{
$vatValue = $productItem->attribute( 'vat_value' );
}
if ( $contentObject )
{
$nodeID = $contentObject->attribute( 'main_node_id' );
$objectName = $contentObject->attribute( 'name' );
}
else
{
$nodeID = false;
$objectName = $productItem->attribute( 'name' );
}
$price = $productItem->attribute( 'price' );
if ( $productItem->attribute( 'is_vat_inc' ) )
{
$priceExVAT = $price / ( 100 + $vatValue ) * 100;
$priceIncVAT = $price;
}
else
{
$priceExVAT = $price;
$priceIncVAT = $price * ( 100 + $vatValue ) / 100;
}
$count = $productItem->attribute( 'item_count' );
$discountPercent = $productItem->attribute( 'discount' );
$realPricePercent = ( 100 - $discountPercent ) / 100;
$addedProducts[] = array( "id" => $productItem->attribute( 'id' ),
"vat_value" => $vatValue,
"item_count" => $count,
"node_id" => $nodeID,
"object_name" => $objectName,
"price_ex_vat" => $priceExVAT,
"price_inc_vat" => $priceIncVAT,
"discount_percent" => $discountPercent,
"total_price_ex_vat" => round( $count * $priceExVAT * $realPricePercent, 2 ),
"total_price_inc_vat" => round( $count * $priceIncVAT * $realPricePercent, 2 ),
'item_object' => $productItem );
}
return $addedProducts;
} | php | function productItems( $asObject = true, array $sorts = null )
{
$productItems = eZPersistentObject::fetchObjectList( eZProductCollectionItem::definition(),
null,
array( 'productcollection_id' => $this->ProductCollectionID ),
$sorts,
null,
$asObject );
$addedProducts = array();
foreach ( $productItems as $productItem )
{
$contentObject = $productItem->attribute( 'contentobject' );
if ( $this->IgnoreVAT == true )
{
$vatValue = 0;
}
else
{
$vatValue = $productItem->attribute( 'vat_value' );
}
if ( $contentObject )
{
$nodeID = $contentObject->attribute( 'main_node_id' );
$objectName = $contentObject->attribute( 'name' );
}
else
{
$nodeID = false;
$objectName = $productItem->attribute( 'name' );
}
$price = $productItem->attribute( 'price' );
if ( $productItem->attribute( 'is_vat_inc' ) )
{
$priceExVAT = $price / ( 100 + $vatValue ) * 100;
$priceIncVAT = $price;
}
else
{
$priceExVAT = $price;
$priceIncVAT = $price * ( 100 + $vatValue ) / 100;
}
$count = $productItem->attribute( 'item_count' );
$discountPercent = $productItem->attribute( 'discount' );
$realPricePercent = ( 100 - $discountPercent ) / 100;
$addedProducts[] = array( "id" => $productItem->attribute( 'id' ),
"vat_value" => $vatValue,
"item_count" => $count,
"node_id" => $nodeID,
"object_name" => $objectName,
"price_ex_vat" => $priceExVAT,
"price_inc_vat" => $priceIncVAT,
"discount_percent" => $discountPercent,
"total_price_ex_vat" => round( $count * $priceExVAT * $realPricePercent, 2 ),
"total_price_inc_vat" => round( $count * $priceIncVAT * $realPricePercent, 2 ),
'item_object' => $productItem );
}
return $addedProducts;
} | [
"function",
"productItems",
"(",
"$",
"asObject",
"=",
"true",
",",
"array",
"$",
"sorts",
"=",
"null",
")",
"{",
"$",
"productItems",
"=",
"eZPersistentObject",
"::",
"fetchObjectList",
"(",
"eZProductCollectionItem",
"::",
"definition",
"(",
")",
",",
"null"... | Fetch product items that bellongs ot the order
@param bool $asObject
@param array|null $sorts Array with sort data sent directly to {@link eZPersistentObject::fetchObjectList()} | [
"Fetch",
"product",
"items",
"that",
"bellongs",
"ot",
"the",
"order"
] | 2493420f527fbc829a8d5bdda402e05d64a20db7 | https://github.com/ezsystems/ezpublish-legacy/blob/2493420f527fbc829a8d5bdda402e05d64a20db7/kernel/classes/ezorder.php#L761-L823 | train |
ezsystems/ezpublish-legacy | kernel/classes/ezorder.php | eZOrder.getNewID | function getNewID()
{
$db = eZDB::instance();
if( $db->supportsDefaultValuesInsertion() )
{
$db->query( 'INSERT INTO ezorder_nr_incr DEFAULT VALUES' );
}
else
{
$db->query( 'INSERT INTO ezorder_nr_incr(id) VALUES(DEFAULT)' );
}
return $db->lastSerialID( 'ezorder_nr_incr', 'id' );
} | php | function getNewID()
{
$db = eZDB::instance();
if( $db->supportsDefaultValuesInsertion() )
{
$db->query( 'INSERT INTO ezorder_nr_incr DEFAULT VALUES' );
}
else
{
$db->query( 'INSERT INTO ezorder_nr_incr(id) VALUES(DEFAULT)' );
}
return $db->lastSerialID( 'ezorder_nr_incr', 'id' );
} | [
"function",
"getNewID",
"(",
")",
"{",
"$",
"db",
"=",
"eZDB",
"::",
"instance",
"(",
")",
";",
"if",
"(",
"$",
"db",
"->",
"supportsDefaultValuesInsertion",
"(",
")",
")",
"{",
"$",
"db",
"->",
"query",
"(",
"'INSERT INTO ezorder_nr_incr DEFAULT VALUES'",
... | Get a new auto_increment id from a separate table ezorder_nr_incr.
@return int the inserted id | [
"Get",
"a",
"new",
"auto_increment",
"id",
"from",
"a",
"separate",
"table",
"ezorder_nr_incr",
"."
] | 2493420f527fbc829a8d5bdda402e05d64a20db7 | https://github.com/ezsystems/ezpublish-legacy/blob/2493420f527fbc829a8d5bdda402e05d64a20db7/kernel/classes/ezorder.php#L1311-L1324 | train |
ezsystems/ezpublish-legacy | kernel/classes/ezsection.php | eZSection.fetchByIdentifier | static function fetchByIdentifier( $sectionIdentifier, $asObject = true )
{
global $eZContentSectionObjectCache;
if( !isset( $eZContentSectionObjectCache[$sectionIdentifier] ) || $asObject === false )
{
$sectionFetched = eZPersistentObject::fetchObject( eZSection::definition(),
null,
array( "identifier" => $sectionIdentifier ),
$asObject );
if( !$sectionFetched )
{
return null;
}
if( $asObject )
{
// the section identifier index refers to the id index object
$sectionID = $sectionFetched->attribute( 'id' );
if( !isset( $eZContentSectionObjectCache[$sectionID] ) )
{
$eZContentSectionObjectCache[$sectionID] = $sectionFetched;
}
$eZContentSectionObjectCache[$sectionIdentifier] = $eZContentSectionObjectCache[$sectionID];
}
else
{
return $sectionFetched;
}
}
$section = $eZContentSectionObjectCache[$sectionIdentifier];
return $section;
} | php | static function fetchByIdentifier( $sectionIdentifier, $asObject = true )
{
global $eZContentSectionObjectCache;
if( !isset( $eZContentSectionObjectCache[$sectionIdentifier] ) || $asObject === false )
{
$sectionFetched = eZPersistentObject::fetchObject( eZSection::definition(),
null,
array( "identifier" => $sectionIdentifier ),
$asObject );
if( !$sectionFetched )
{
return null;
}
if( $asObject )
{
// the section identifier index refers to the id index object
$sectionID = $sectionFetched->attribute( 'id' );
if( !isset( $eZContentSectionObjectCache[$sectionID] ) )
{
$eZContentSectionObjectCache[$sectionID] = $sectionFetched;
}
$eZContentSectionObjectCache[$sectionIdentifier] = $eZContentSectionObjectCache[$sectionID];
}
else
{
return $sectionFetched;
}
}
$section = $eZContentSectionObjectCache[$sectionIdentifier];
return $section;
} | [
"static",
"function",
"fetchByIdentifier",
"(",
"$",
"sectionIdentifier",
",",
"$",
"asObject",
"=",
"true",
")",
"{",
"global",
"$",
"eZContentSectionObjectCache",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"eZContentSectionObjectCache",
"[",
"$",
"sectionIdentifier... | fetch object by section identifier
@param string $sectionIdentifier
@param boolean $asObject
@return object|null | [
"fetch",
"object",
"by",
"section",
"identifier"
] | 2493420f527fbc829a8d5bdda402e05d64a20db7 | https://github.com/ezsystems/ezpublish-legacy/blob/2493420f527fbc829a8d5bdda402e05d64a20db7/kernel/classes/ezsection.php#L94-L125 | train |
ezsystems/ezpublish-legacy | extension/ezjscore/classes/ajaxuploader/ezprelationlistajaxuploader.php | ezpRelationListAjaxUploader.canUpload | public function canUpload()
{
$access = eZUser::instance()->hasAccessTo( 'content', 'create' );
if ( $access['accessWord'] === 'no' )
{
return false;
}
$ini = eZINI::instance( 'upload.ini' );
$uploadableClassList = $ini->variable( 'CreateSettings', 'MimeClassMap' );
$uploadableClassList[] = $ini->variable( 'CreateSettings', 'DefaultClass' );
$classContent = $this->attribute->attribute( 'class_content' );
$intersect = array_intersect( $classContent['class_constraint_list'], $uploadableClassList );
if ( !empty( $classContent['class_constraint_list'] ) && empty( $intersect ) )
{
return false;
}
return true;
} | php | public function canUpload()
{
$access = eZUser::instance()->hasAccessTo( 'content', 'create' );
if ( $access['accessWord'] === 'no' )
{
return false;
}
$ini = eZINI::instance( 'upload.ini' );
$uploadableClassList = $ini->variable( 'CreateSettings', 'MimeClassMap' );
$uploadableClassList[] = $ini->variable( 'CreateSettings', 'DefaultClass' );
$classContent = $this->attribute->attribute( 'class_content' );
$intersect = array_intersect( $classContent['class_constraint_list'], $uploadableClassList );
if ( !empty( $classContent['class_constraint_list'] ) && empty( $intersect ) )
{
return false;
}
return true;
} | [
"public",
"function",
"canUpload",
"(",
")",
"{",
"$",
"access",
"=",
"eZUser",
"::",
"instance",
"(",
")",
"->",
"hasAccessTo",
"(",
"'content'",
",",
"'create'",
")",
";",
"if",
"(",
"$",
"access",
"[",
"'accessWord'",
"]",
"===",
"'no'",
")",
"{",
... | Checks if a file can be uploaded
@return boolean | [
"Checks",
"if",
"a",
"file",
"can",
"be",
"uploaded"
] | 2493420f527fbc829a8d5bdda402e05d64a20db7 | https://github.com/ezsystems/ezpublish-legacy/blob/2493420f527fbc829a8d5bdda402e05d64a20db7/extension/ezjscore/classes/ajaxuploader/ezprelationlistajaxuploader.php#L54-L72 | train |
ezsystems/ezpublish-legacy | extension/ezjscore/classes/ajaxuploader/ezprelationlistajaxuploader.php | ezpRelationListAjaxUploader.getFileInfo | public function getFileInfo()
{
$upload = new eZContentUpload();
$errors = array();
$mimeData = $file = '';
$result = $upload->fetchHTTPFile( 'UploadFile', $errors, $file, $mimeData );
if ( $result === false )
{
throw new RuntimeException(
ezpI18n::tr(
'extension/ezjscore/ajaxuploader',
'Unable to retrieve the uploaded file: %message',
null, array( '%message' => $errors[0]['description'] )
)
);
}
return array(
'file' => $file,
'mime' => $mimeData
);
} | php | public function getFileInfo()
{
$upload = new eZContentUpload();
$errors = array();
$mimeData = $file = '';
$result = $upload->fetchHTTPFile( 'UploadFile', $errors, $file, $mimeData );
if ( $result === false )
{
throw new RuntimeException(
ezpI18n::tr(
'extension/ezjscore/ajaxuploader',
'Unable to retrieve the uploaded file: %message',
null, array( '%message' => $errors[0]['description'] )
)
);
}
return array(
'file' => $file,
'mime' => $mimeData
);
} | [
"public",
"function",
"getFileInfo",
"(",
")",
"{",
"$",
"upload",
"=",
"new",
"eZContentUpload",
"(",
")",
";",
"$",
"errors",
"=",
"array",
"(",
")",
";",
"$",
"mimeData",
"=",
"$",
"file",
"=",
"''",
";",
"$",
"result",
"=",
"$",
"upload",
"->",... | Returns infos on the uploaded file
@return array( 'mime' => array(), 'file' => eZHTTPFile )
@throw RuntimeException if the uploaded file can not be found | [
"Returns",
"infos",
"on",
"the",
"uploaded",
"file"
] | 2493420f527fbc829a8d5bdda402e05d64a20db7 | https://github.com/ezsystems/ezpublish-legacy/blob/2493420f527fbc829a8d5bdda402e05d64a20db7/extension/ezjscore/classes/ajaxuploader/ezprelationlistajaxuploader.php#L79-L100 | train |
ezsystems/ezpublish-legacy | extension/ezjscore/classes/ajaxuploader/ezprelationlistajaxuploader.php | ezpRelationListAjaxUploader.getContentClass | public function getContentClass( array $mimeData )
{
$upload = new eZContentUpload();
$classIdentifier = $upload->detectClassIdentifier( $mimeData['name'] );
$class = eZContentClass::fetchByIdentifier( $classIdentifier );
if ( !$class instanceof eZContentClass )
{
throw new RuntimeException(
ezpI18n::tr(
'extension/ezjscore/ajaxuploader',
'Unable to load the class which identifier is "%class",' .
' this is probably a configuration issue in upload.ini.',
null, array( '%class' => $classIdentifier )
)
);
}
$classContent = $this->attribute->attribute( 'class_content' );
if ( !empty( $classContent['class_constraint_list'] )
&& !in_array( $classIdentifier, $classContent['class_constraint_list'] ) )
{
throw new DomainException(
ezpI18n::tr(
'extension/ezjscore/ajaxuploader', 'The file cannot be processed because' .
' it would result in a \'%class\' object and this relation' .
' does not accept this type of object.',
null, array( '%class' => $class->attribute( 'name' ) )
)
);
}
return $class;
} | php | public function getContentClass( array $mimeData )
{
$upload = new eZContentUpload();
$classIdentifier = $upload->detectClassIdentifier( $mimeData['name'] );
$class = eZContentClass::fetchByIdentifier( $classIdentifier );
if ( !$class instanceof eZContentClass )
{
throw new RuntimeException(
ezpI18n::tr(
'extension/ezjscore/ajaxuploader',
'Unable to load the class which identifier is "%class",' .
' this is probably a configuration issue in upload.ini.',
null, array( '%class' => $classIdentifier )
)
);
}
$classContent = $this->attribute->attribute( 'class_content' );
if ( !empty( $classContent['class_constraint_list'] )
&& !in_array( $classIdentifier, $classContent['class_constraint_list'] ) )
{
throw new DomainException(
ezpI18n::tr(
'extension/ezjscore/ajaxuploader', 'The file cannot be processed because' .
' it would result in a \'%class\' object and this relation' .
' does not accept this type of object.',
null, array( '%class' => $class->attribute( 'name' ) )
)
);
}
return $class;
} | [
"public",
"function",
"getContentClass",
"(",
"array",
"$",
"mimeData",
")",
"{",
"$",
"upload",
"=",
"new",
"eZContentUpload",
"(",
")",
";",
"$",
"classIdentifier",
"=",
"$",
"upload",
"->",
"detectClassIdentifier",
"(",
"$",
"mimeData",
"[",
"'name'",
"]"... | Returns the content class to use when creating the content object from
the file
@param array $mimeData
@return eZContentClass
@throw RuntimeException if the found class identifier does not exists
@throw DomainException if objects of the found class are not allowed | [
"Returns",
"the",
"content",
"class",
"to",
"use",
"when",
"creating",
"the",
"content",
"object",
"from",
"the",
"file"
] | 2493420f527fbc829a8d5bdda402e05d64a20db7 | https://github.com/ezsystems/ezpublish-legacy/blob/2493420f527fbc829a8d5bdda402e05d64a20db7/extension/ezjscore/classes/ajaxuploader/ezprelationlistajaxuploader.php#L111-L144 | train |
ezsystems/ezpublish-legacy | extension/ezjscore/classes/ajaxuploader/ezprelationlistajaxuploader.php | ezpRelationListAjaxUploader.getDefaultParentNodeId | public function getDefaultParentNodeId( eZContentClass $class )
{
$parentNodes = array();
$parentMainNode = null;
$upload = new eZContentUpload();
$upload->detectLocations(
$class->attribute( 'identifier' ), $class, 'auto',
$parentNodes, $parentMainNode
);
return $parentMainNode;
} | php | public function getDefaultParentNodeId( eZContentClass $class )
{
$parentNodes = array();
$parentMainNode = null;
$upload = new eZContentUpload();
$upload->detectLocations(
$class->attribute( 'identifier' ), $class, 'auto',
$parentNodes, $parentMainNode
);
return $parentMainNode;
} | [
"public",
"function",
"getDefaultParentNodeId",
"(",
"eZContentClass",
"$",
"class",
")",
"{",
"$",
"parentNodes",
"=",
"array",
"(",
")",
";",
"$",
"parentMainNode",
"=",
"null",
";",
"$",
"upload",
"=",
"new",
"eZContentUpload",
"(",
")",
";",
"$",
"uplo... | Returns the node id of the default location of the future object
@param eZContentClass $class
@return int | [
"Returns",
"the",
"node",
"id",
"of",
"the",
"default",
"location",
"of",
"the",
"future",
"object"
] | 2493420f527fbc829a8d5bdda402e05d64a20db7 | https://github.com/ezsystems/ezpublish-legacy/blob/2493420f527fbc829a8d5bdda402e05d64a20db7/extension/ezjscore/classes/ajaxuploader/ezprelationlistajaxuploader.php#L152-L162 | train |
ezsystems/ezpublish-legacy | extension/ezjscore/classes/ajaxuploader/ezprelationlistajaxuploader.php | ezpRelationListAjaxUploader.createObject | public function createObject( $file, $parentNodeId, $name = '' )
{
$result = array();
$parentNode = eZContentObjectTreeNode::fetch( $parentNodeId );
if ( !$parentNode instanceof eZContentObjectTreeNode )
{
throw new InvalidArgumentException(
ezpI18n::tr(
'extension/ezjscore/ajaxuploader', 'Location not found.'
)
);
}
$upload = new eZContentUpload();
$r = $upload->handleLocalFile(
$result, $file, $parentNodeId, null, $name,
$this->attribute->attribute( 'language_code' )
);
if ( !$r || !$result['contentobject'] instanceof eZContentObject )
{
throw new RuntimeException(
ezpI18n::tr(
'extension/ezjscore/ajaxuploader',
'Unable to create the content object to add to the relation: %detail',
null, array( '%detail' => $result['errors'][0]['description'] )
)
);
}
return $result['contentobject'];
} | php | public function createObject( $file, $parentNodeId, $name = '' )
{
$result = array();
$parentNode = eZContentObjectTreeNode::fetch( $parentNodeId );
if ( !$parentNode instanceof eZContentObjectTreeNode )
{
throw new InvalidArgumentException(
ezpI18n::tr(
'extension/ezjscore/ajaxuploader', 'Location not found.'
)
);
}
$upload = new eZContentUpload();
$r = $upload->handleLocalFile(
$result, $file, $parentNodeId, null, $name,
$this->attribute->attribute( 'language_code' )
);
if ( !$r || !$result['contentobject'] instanceof eZContentObject )
{
throw new RuntimeException(
ezpI18n::tr(
'extension/ezjscore/ajaxuploader',
'Unable to create the content object to add to the relation: %detail',
null, array( '%detail' => $result['errors'][0]['description'] )
)
);
}
return $result['contentobject'];
} | [
"public",
"function",
"createObject",
"(",
"$",
"file",
",",
"$",
"parentNodeId",
",",
"$",
"name",
"=",
"''",
")",
"{",
"$",
"result",
"=",
"array",
"(",
")",
";",
"$",
"parentNode",
"=",
"eZContentObjectTreeNode",
"::",
"fetch",
"(",
"$",
"parentNodeId... | Creates the eZContentObject from the uploaded file
@param eZHTTPFile $file
@param eZContentObjectTreeNode $location
@param string $name
@return eZContentObject
@throw InvalidArgumentException if the parent location does not exists
@throw RuntimeException if the object can not be created | [
"Creates",
"the",
"eZContentObject",
"from",
"the",
"uploaded",
"file"
] | 2493420f527fbc829a8d5bdda402e05d64a20db7 | https://github.com/ezsystems/ezpublish-legacy/blob/2493420f527fbc829a8d5bdda402e05d64a20db7/extension/ezjscore/classes/ajaxuploader/ezprelationlistajaxuploader.php#L174-L203 | train |
ezsystems/ezpublish-legacy | extension/ezjscore/classes/ajaxuploader/ezprelationlistajaxuploader.php | ezpRelationListAjaxUploader.serializeObject | public function serializeObject( eZContentObject $contentObject )
{
$section = eZSection::fetch( $contentObject->attribute( 'section_id' ) );
return array(
'object_info' => array(
'id' => $contentObject->attribute( 'id' ),
'name' => $contentObject->attribute( 'name' ),
'class_name' => $contentObject->attribute( 'class_name' ),
'section_name' => $section->attribute( 'name' ),
'published' => ezpI18n::tr( 'design/standard/content/datatype', 'Yes' ),
)
);
} | php | public function serializeObject( eZContentObject $contentObject )
{
$section = eZSection::fetch( $contentObject->attribute( 'section_id' ) );
return array(
'object_info' => array(
'id' => $contentObject->attribute( 'id' ),
'name' => $contentObject->attribute( 'name' ),
'class_name' => $contentObject->attribute( 'class_name' ),
'section_name' => $section->attribute( 'name' ),
'published' => ezpI18n::tr( 'design/standard/content/datatype', 'Yes' ),
)
);
} | [
"public",
"function",
"serializeObject",
"(",
"eZContentObject",
"$",
"contentObject",
")",
"{",
"$",
"section",
"=",
"eZSection",
"::",
"fetch",
"(",
"$",
"contentObject",
"->",
"attribute",
"(",
"'section_id'",
")",
")",
";",
"return",
"array",
"(",
"'object... | Serialize the eZContentObject to be used to build the result in
JavaScript
@param eZContentObject $object
@return array | [
"Serialize",
"the",
"eZContentObject",
"to",
"be",
"used",
"to",
"build",
"the",
"result",
"in",
"JavaScript"
] | 2493420f527fbc829a8d5bdda402e05d64a20db7 | https://github.com/ezsystems/ezpublish-legacy/blob/2493420f527fbc829a8d5bdda402e05d64a20db7/extension/ezjscore/classes/ajaxuploader/ezprelationlistajaxuploader.php#L212-L224 | train |
ezsystems/ezpublish-legacy | kernel/classes/ezcontentclassattribute.php | eZContentClassAttribute.storeVersioned | function storeVersioned( $version )
{
$dataType = $this->dataType();
if ( !$dataType )
{
return false;
}
self::expireCache( $this->ID, $this->attribute( 'contentclass_id' ) );
$db = eZDB::instance();
$db->begin();
$dataType->preStoreVersionedClassAttribute( $this, $version );
$this->setAttribute( 'serialized_name_list', $this->NameList->serializeNames() );
$this->setAttribute( 'serialized_description_list', $this->DescriptionList->serializeNames() );
$this->setAttribute( 'serialized_data_text', $this->DataTextI18nList->serializeNames() );
parent::store();
// store the content data for this attribute
$dataType->storeVersionedClassAttribute( $this, $version );
$db->commit();
} | php | function storeVersioned( $version )
{
$dataType = $this->dataType();
if ( !$dataType )
{
return false;
}
self::expireCache( $this->ID, $this->attribute( 'contentclass_id' ) );
$db = eZDB::instance();
$db->begin();
$dataType->preStoreVersionedClassAttribute( $this, $version );
$this->setAttribute( 'serialized_name_list', $this->NameList->serializeNames() );
$this->setAttribute( 'serialized_description_list', $this->DescriptionList->serializeNames() );
$this->setAttribute( 'serialized_data_text', $this->DataTextI18nList->serializeNames() );
parent::store();
// store the content data for this attribute
$dataType->storeVersionedClassAttribute( $this, $version );
$db->commit();
} | [
"function",
"storeVersioned",
"(",
"$",
"version",
")",
"{",
"$",
"dataType",
"=",
"$",
"this",
"->",
"dataType",
"(",
")",
";",
"if",
"(",
"!",
"$",
"dataType",
")",
"{",
"return",
"false",
";",
"}",
"self",
"::",
"expireCache",
"(",
"$",
"this",
... | Store the content class in the specified version status.
@note Transaction unsafe. If you call several transaction unsafe methods you must enclose
the calls within a db transaction; thus within db->begin and db->commit.
@param int $version version status
@since Version 4.3
@return null|false false if the operation failed | [
"Store",
"the",
"content",
"class",
"in",
"the",
"specified",
"version",
"status",
"."
] | 2493420f527fbc829a8d5bdda402e05d64a20db7 | https://github.com/ezsystems/ezpublish-legacy/blob/2493420f527fbc829a8d5bdda402e05d64a20db7/kernel/classes/ezcontentclassattribute.php#L327-L350 | train |
ezsystems/ezpublish-legacy | kernel/classes/ezcontentclassattribute.php | eZContentClassAttribute.expireCache | public static function expireCache( $contentClassAttributeID = false, $contentClassID = false)
{
unset( $GLOBALS['eZContentClassAttributeCacheListFull'] );
if ( $contentClassID !== false )
{
if ( isset( $GLOBALS['eZContentClassAttributeCacheList'][$contentClassID] ) )
{
unset( $GLOBALS['eZContentClassAttributeCacheList'][$contentClassID] );
}
}
else
{
unset( $GLOBALS['eZContentClassAttributeCacheList'] );
}
if ( $contentClassAttributeID !== false )
{
if ( isset( $GLOBALS['eZContentClassAttributeCache'][$contentClassAttributeID] ) )
{
unset( $GLOBALS['eZContentClassAttributeCache'][$contentClassAttributeID] );
}
}
else
{
unset( $GLOBALS['eZContentClassAttributeCache'] );
}
// expire cache file by timestamp
$handler = eZExpiryHandler::instance();
$handler->setTimestamp( 'class-identifier-cache', time() + 1 );
$handler->store();
// expire local, in-memory cache
self::$identifierHash = null;
} | php | public static function expireCache( $contentClassAttributeID = false, $contentClassID = false)
{
unset( $GLOBALS['eZContentClassAttributeCacheListFull'] );
if ( $contentClassID !== false )
{
if ( isset( $GLOBALS['eZContentClassAttributeCacheList'][$contentClassID] ) )
{
unset( $GLOBALS['eZContentClassAttributeCacheList'][$contentClassID] );
}
}
else
{
unset( $GLOBALS['eZContentClassAttributeCacheList'] );
}
if ( $contentClassAttributeID !== false )
{
if ( isset( $GLOBALS['eZContentClassAttributeCache'][$contentClassAttributeID] ) )
{
unset( $GLOBALS['eZContentClassAttributeCache'][$contentClassAttributeID] );
}
}
else
{
unset( $GLOBALS['eZContentClassAttributeCache'] );
}
// expire cache file by timestamp
$handler = eZExpiryHandler::instance();
$handler->setTimestamp( 'class-identifier-cache', time() + 1 );
$handler->store();
// expire local, in-memory cache
self::$identifierHash = null;
} | [
"public",
"static",
"function",
"expireCache",
"(",
"$",
"contentClassAttributeID",
"=",
"false",
",",
"$",
"contentClassID",
"=",
"false",
")",
"{",
"unset",
"(",
"$",
"GLOBALS",
"[",
"'eZContentClassAttributeCacheListFull'",
"]",
")",
";",
"if",
"(",
"$",
"c... | Clears all content class attribute related caches
@param int $contentClassAttributeID Specific attribute ID to clear cache for
@param int $contentClassID Specific attribute ID to clear cache for
@return void
@since 4.2 | [
"Clears",
"all",
"content",
"class",
"attribute",
"related",
"caches"
] | 2493420f527fbc829a8d5bdda402e05d64a20db7 | https://github.com/ezsystems/ezpublish-legacy/blob/2493420f527fbc829a8d5bdda402e05d64a20db7/kernel/classes/ezcontentclassattribute.php#L1084-L1117 | train |
ezsystems/ezpublish-legacy | kernel/classes/ezproductcollectionitem.php | eZProductCollectionItem.cleanupList | static function cleanupList( $productCollectionIDList )
{
$db = eZDB::instance();
$db->begin();
$inText = $db->generateSQLINStatement( $productCollectionIDList, 'productcollection_id', false, false, 'int' );
$rows = $db->arrayQuery( "SELECT id FROM ezproductcollection_item WHERE $inText" );
if ( count( $rows ) > 0 )
{
$itemIDList = array();
foreach ( $rows as $row )
{
$itemIDList[] = $row['id'];
}
eZProductCollectionItemOption::cleanupList( $itemIDList );
}
$db->query( "DELETE FROM ezproductcollection_item WHERE $inText" );
$db->commit();
} | php | static function cleanupList( $productCollectionIDList )
{
$db = eZDB::instance();
$db->begin();
$inText = $db->generateSQLINStatement( $productCollectionIDList, 'productcollection_id', false, false, 'int' );
$rows = $db->arrayQuery( "SELECT id FROM ezproductcollection_item WHERE $inText" );
if ( count( $rows ) > 0 )
{
$itemIDList = array();
foreach ( $rows as $row )
{
$itemIDList[] = $row['id'];
}
eZProductCollectionItemOption::cleanupList( $itemIDList );
}
$db->query( "DELETE FROM ezproductcollection_item WHERE $inText" );
$db->commit();
} | [
"static",
"function",
"cleanupList",
"(",
"$",
"productCollectionIDList",
")",
"{",
"$",
"db",
"=",
"eZDB",
"::",
"instance",
"(",
")",
";",
"$",
"db",
"->",
"begin",
"(",
")",
";",
"$",
"inText",
"=",
"$",
"db",
"->",
"generateSQLINStatement",
"(",
"$... | Removes all product collection items which related to the product
collections specified in the parameter array
@param array $productCollectionIDList array of eZProductCollection IDs
@return void | [
"Removes",
"all",
"product",
"collection",
"items",
"which",
"related",
"to",
"the",
"product",
"collections",
"specified",
"in",
"the",
"parameter",
"array"
] | 2493420f527fbc829a8d5bdda402e05d64a20db7 | https://github.com/ezsystems/ezpublish-legacy/blob/2493420f527fbc829a8d5bdda402e05d64a20db7/kernel/classes/ezproductcollectionitem.php#L277-L294 | train |
ezsystems/ezpublish-legacy | kernel/private/rest/classes/router.php | ezpRestRouter.doCreateRoutes | protected function doCreateRoutes()
{
$providerRoutes = ezpRestProvider::getProvider( ezpRestPrefixFilterInterface::getApiProviderName() )->getRoutes();
$providerRoutes['fatal'] = new ezpMvcRailsRoute( '/fatal', 'ezpRestErrorController', 'show' );
return ezcMvcRouter::prefix(
eZINI::instance( 'rest.ini' )->variable( 'System', 'ApiPrefix' ),
$providerRoutes
);
} | php | protected function doCreateRoutes()
{
$providerRoutes = ezpRestProvider::getProvider( ezpRestPrefixFilterInterface::getApiProviderName() )->getRoutes();
$providerRoutes['fatal'] = new ezpMvcRailsRoute( '/fatal', 'ezpRestErrorController', 'show' );
return ezcMvcRouter::prefix(
eZINI::instance( 'rest.ini' )->variable( 'System', 'ApiPrefix' ),
$providerRoutes
);
} | [
"protected",
"function",
"doCreateRoutes",
"(",
")",
"{",
"$",
"providerRoutes",
"=",
"ezpRestProvider",
"::",
"getProvider",
"(",
"ezpRestPrefixFilterInterface",
"::",
"getApiProviderName",
"(",
")",
")",
"->",
"getRoutes",
"(",
")",
";",
"$",
"providerRoutes",
"... | Do create the REST routes
@return array The route objects | [
"Do",
"create",
"the",
"REST",
"routes"
] | 2493420f527fbc829a8d5bdda402e05d64a20db7 | https://github.com/ezsystems/ezpublish-legacy/blob/2493420f527fbc829a8d5bdda402e05d64a20db7/kernel/private/rest/classes/router.php#L49-L58 | train |
ezsystems/ezpublish-legacy | kernel/private/rest/classes/router.php | ezpRestRouter.getCachedRoutes | protected function getCachedRoutes()
{
$ttl = (int)eZINI::instance( 'rest.ini' )->variable( 'CacheSettings', 'RouteApcCacheTTL' );
if( self::$isRouteCacheCreated === false )
{
$options = array( 'ttl' => $ttl );
ezcCacheManager::createCache( self::ROUTE_CACHE_ID, self::ROUTE_CACHE_PATH, 'ezpRestCacheStorageApcCluster', $options );
self::$isRouteCacheCreated = true;
}
$cache = ezcCacheManager::getCache( self::ROUTE_CACHE_ID );
$cacheKey = self::ROUTE_CACHE_KEY . '_' . ezpRestPrefixFilterInterface::getApiProviderName();
if( ( $prefixedRoutes = $cache->restore( $cacheKey ) ) === false )
{
try
{
$prefixedRoutes = $this->doCreateRoutes();
$cache->store( $cacheKey, $prefixedRoutes );
}
catch( Exception $e )
{
// Sometimes APC can miss a write. No big deal, just log it.
// Cache will be regenerated next time
ezpRestDebug::getInstance()->log( $e->getMessage(), ezcLog::ERROR );
}
}
return $prefixedRoutes;
} | php | protected function getCachedRoutes()
{
$ttl = (int)eZINI::instance( 'rest.ini' )->variable( 'CacheSettings', 'RouteApcCacheTTL' );
if( self::$isRouteCacheCreated === false )
{
$options = array( 'ttl' => $ttl );
ezcCacheManager::createCache( self::ROUTE_CACHE_ID, self::ROUTE_CACHE_PATH, 'ezpRestCacheStorageApcCluster', $options );
self::$isRouteCacheCreated = true;
}
$cache = ezcCacheManager::getCache( self::ROUTE_CACHE_ID );
$cacheKey = self::ROUTE_CACHE_KEY . '_' . ezpRestPrefixFilterInterface::getApiProviderName();
if( ( $prefixedRoutes = $cache->restore( $cacheKey ) ) === false )
{
try
{
$prefixedRoutes = $this->doCreateRoutes();
$cache->store( $cacheKey, $prefixedRoutes );
}
catch( Exception $e )
{
// Sometimes APC can miss a write. No big deal, just log it.
// Cache will be regenerated next time
ezpRestDebug::getInstance()->log( $e->getMessage(), ezcLog::ERROR );
}
}
return $prefixedRoutes;
} | [
"protected",
"function",
"getCachedRoutes",
"(",
")",
"{",
"$",
"ttl",
"=",
"(",
"int",
")",
"eZINI",
"::",
"instance",
"(",
"'rest.ini'",
")",
"->",
"variable",
"(",
"'CacheSettings'",
",",
"'RouteApcCacheTTL'",
")",
";",
"if",
"(",
"self",
"::",
"$",
"... | Extract REST routes from APC cache.
Cache is generated if needed
@return array The route objects | [
"Extract",
"REST",
"routes",
"from",
"APC",
"cache",
".",
"Cache",
"is",
"generated",
"if",
"needed"
] | 2493420f527fbc829a8d5bdda402e05d64a20db7 | https://github.com/ezsystems/ezpublish-legacy/blob/2493420f527fbc829a8d5bdda402e05d64a20db7/kernel/private/rest/classes/router.php#L65-L94 | train |
ezsystems/ezpublish-legacy | kernel/private/oauth/classes/restclient.php | ezpRestClient.attribute | public function attribute( $attributeName )
{
if ( property_exists( $this, $attributeName ) )
return $this->$attributeName;
elseif ( $this->__isset( $attributeName ) )
return $this->__get( $attributeName );
else
eZDebug::writeError( "Attribute '$attributeName' does not exist", __METHOD__ );
} | php | public function attribute( $attributeName )
{
if ( property_exists( $this, $attributeName ) )
return $this->$attributeName;
elseif ( $this->__isset( $attributeName ) )
return $this->__get( $attributeName );
else
eZDebug::writeError( "Attribute '$attributeName' does not exist", __METHOD__ );
} | [
"public",
"function",
"attribute",
"(",
"$",
"attributeName",
")",
"{",
"if",
"(",
"property_exists",
"(",
"$",
"this",
",",
"$",
"attributeName",
")",
")",
"return",
"$",
"this",
"->",
"$",
"attributeName",
";",
"elseif",
"(",
"$",
"this",
"->",
"__isse... | eZPersistentObject wrapper method
@param string $attributeName
@return mixed | [
"eZPersistentObject",
"wrapper",
"method"
] | 2493420f527fbc829a8d5bdda402e05d64a20db7 | https://github.com/ezsystems/ezpublish-legacy/blob/2493420f527fbc829a8d5bdda402e05d64a20db7/kernel/private/oauth/classes/restclient.php#L101-L109 | train |
ezsystems/ezpublish-legacy | kernel/private/oauth/classes/restclient.php | ezpRestClient._owner | protected function _owner()
{
static $owner = false;
if ( $owner === false )
{
$owner = eZUser::fetch( $this->owner_id );
}
return $owner;
} | php | protected function _owner()
{
static $owner = false;
if ( $owner === false )
{
$owner = eZUser::fetch( $this->owner_id );
}
return $owner;
} | [
"protected",
"function",
"_owner",
"(",
")",
"{",
"static",
"$",
"owner",
"=",
"false",
";",
"if",
"(",
"$",
"owner",
"===",
"false",
")",
"{",
"$",
"owner",
"=",
"eZUser",
"::",
"fetch",
"(",
"$",
"this",
"->",
"owner_id",
")",
";",
"}",
"return",... | Returns the eZUser who owns the object
@return eZUser | [
"Returns",
"the",
"eZUser",
"who",
"owns",
"the",
"object"
] | 2493420f527fbc829a8d5bdda402e05d64a20db7 | https://github.com/ezsystems/ezpublish-legacy/blob/2493420f527fbc829a8d5bdda402e05d64a20db7/kernel/private/oauth/classes/restclient.php#L145-L155 | train |
ezsystems/ezpublish-legacy | kernel/private/oauth/classes/restclient.php | ezpRestClient.authorizeApplication | public static function authorizeApplication( $clientId, $endPointUri, $clientSecret = null )
{
$client = self::fetchByClientId( $clientId );
// no client found with this ID
if ( $client === false )
return false;
if ( $clientSecret !== null && ( $clientSecret !== $client->client_secret ) )
return false;
if ( ( $client->endpoint_uri !== '' ) && ( $endPointUri !== $client->endpoint_uri ) )
return false;
return true;
} | php | public static function authorizeApplication( $clientId, $endPointUri, $clientSecret = null )
{
$client = self::fetchByClientId( $clientId );
// no client found with this ID
if ( $client === false )
return false;
if ( $clientSecret !== null && ( $clientSecret !== $client->client_secret ) )
return false;
if ( ( $client->endpoint_uri !== '' ) && ( $endPointUri !== $client->endpoint_uri ) )
return false;
return true;
} | [
"public",
"static",
"function",
"authorizeApplication",
"(",
"$",
"clientId",
",",
"$",
"endPointUri",
",",
"$",
"clientSecret",
"=",
"null",
")",
"{",
"$",
"client",
"=",
"self",
"::",
"fetchByClientId",
"(",
"$",
"clientId",
")",
";",
"// no client found wit... | Validates an authorization request by an application using the ID, redirection URI and secret if provided.
@var string $clientId
@var string $endPointUri
@var string $clientSecret
@return bool True if the app is valid, false if it isn't
@todo Enhance the return variable, as several status would be required. Exceptions, or constants ? | [
"Validates",
"an",
"authorization",
"request",
"by",
"an",
"application",
"using",
"the",
"ID",
"redirection",
"URI",
"and",
"secret",
"if",
"provided",
"."
] | 2493420f527fbc829a8d5bdda402e05d64a20db7 | https://github.com/ezsystems/ezpublish-legacy/blob/2493420f527fbc829a8d5bdda402e05d64a20db7/kernel/private/oauth/classes/restclient.php#L172-L187 | train |
ezsystems/ezpublish-legacy | kernel/private/oauth/classes/restclient.php | ezpRestClient.fetchByClientId | public static function fetchByClientId( $clientId )
{
$session = ezcPersistentSessionInstance::get();
$q = $session->createFindQuery( __CLASS__ );
$q->where( $q->expr->eq( 'client_id', $q->bindValue( $clientId ) ) );
$results = $session->find( $q, __CLASS__ );
if ( count( $results ) != 1 )
return false;
else
return array_shift( $results );
} | php | public static function fetchByClientId( $clientId )
{
$session = ezcPersistentSessionInstance::get();
$q = $session->createFindQuery( __CLASS__ );
$q->where( $q->expr->eq( 'client_id', $q->bindValue( $clientId ) ) );
$results = $session->find( $q, __CLASS__ );
if ( count( $results ) != 1 )
return false;
else
return array_shift( $results );
} | [
"public",
"static",
"function",
"fetchByClientId",
"(",
"$",
"clientId",
")",
"{",
"$",
"session",
"=",
"ezcPersistentSessionInstance",
"::",
"get",
"(",
")",
";",
"$",
"q",
"=",
"$",
"session",
"->",
"createFindQuery",
"(",
"__CLASS__",
")",
";",
"$",
"q"... | Fetches a rest application using a client Id
@param string $clientId
@return ezpRestClient | [
"Fetches",
"a",
"rest",
"application",
"using",
"a",
"client",
"Id"
] | 2493420f527fbc829a8d5bdda402e05d64a20db7 | https://github.com/ezsystems/ezpublish-legacy/blob/2493420f527fbc829a8d5bdda402e05d64a20db7/kernel/private/oauth/classes/restclient.php#L194-L205 | train |
ezsystems/ezpublish-legacy | kernel/private/oauth/classes/restclient.php | ezpRestClient.isAuthorizedByUser | public function isAuthorizedByUser( $scope, $user = null )
{
if ( $user === null )
$user = eZUser::currentUser();
if ( !$user->isRegistered() )
throw new Exception( "Anonymous user can not authorize an application" );
$authorized = ezpRestAuthorizedClient::fetchForClientUser( $this, $user );
return ( $authorized instanceof ezpRestAuthorizedClient );
} | php | public function isAuthorizedByUser( $scope, $user = null )
{
if ( $user === null )
$user = eZUser::currentUser();
if ( !$user->isRegistered() )
throw new Exception( "Anonymous user can not authorize an application" );
$authorized = ezpRestAuthorizedClient::fetchForClientUser( $this, $user );
return ( $authorized instanceof ezpRestAuthorizedClient );
} | [
"public",
"function",
"isAuthorizedByUser",
"(",
"$",
"scope",
",",
"$",
"user",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"user",
"===",
"null",
")",
"$",
"user",
"=",
"eZUser",
"::",
"currentUser",
"(",
")",
";",
"if",
"(",
"!",
"$",
"user",
"->",
... | Checks if this application has been authorized by the current user
@param mixed $scope The requested security scope
@param eZUser $user The user to check authorization for. Will check for current user if not given.
@return bool
@todo Handle non-authorization using | [
"Checks",
"if",
"this",
"application",
"has",
"been",
"authorized",
"by",
"the",
"current",
"user"
] | 2493420f527fbc829a8d5bdda402e05d64a20db7 | https://github.com/ezsystems/ezpublish-legacy/blob/2493420f527fbc829a8d5bdda402e05d64a20db7/kernel/private/oauth/classes/restclient.php#L228-L238 | train |
ezsystems/ezpublish-legacy | kernel/private/oauth/classes/restclient.php | ezpRestClient.authorizeFor | public function authorizeFor( $user = null )
{
$authorization = new ezpRestAuthorizedClient();
$authorization->rest_client_id = $this->id;
$authorization->user_id = $user->attribute( 'contentobject_id' );
$session = ezcPersistentSessionInstance::get();
$session->save( $authorization );
} | php | public function authorizeFor( $user = null )
{
$authorization = new ezpRestAuthorizedClient();
$authorization->rest_client_id = $this->id;
$authorization->user_id = $user->attribute( 'contentobject_id' );
$session = ezcPersistentSessionInstance::get();
$session->save( $authorization );
} | [
"public",
"function",
"authorizeFor",
"(",
"$",
"user",
"=",
"null",
")",
"{",
"$",
"authorization",
"=",
"new",
"ezpRestAuthorizedClient",
"(",
")",
";",
"$",
"authorization",
"->",
"rest_client_id",
"=",
"$",
"this",
"->",
"id",
";",
"$",
"authorization",
... | Authorizes this application for a user
@param eZUser $user
@return void | [
"Authorizes",
"this",
"application",
"for",
"a",
"user"
] | 2493420f527fbc829a8d5bdda402e05d64a20db7 | https://github.com/ezsystems/ezpublish-legacy/blob/2493420f527fbc829a8d5bdda402e05d64a20db7/kernel/private/oauth/classes/restclient.php#L245-L253 | train |
ezsystems/ezpublish-legacy | kernel/classes/ezvattype.php | eZVatType.dynamicVatTypeName | static function dynamicVatTypeName()
{
if ( !isset( $GLOBALS['eZVatType_dynamicVatTypeName'] ) )
{
$shopINI = eZINI::instance( 'shop.ini' );
$desc = $shopINI->variable( 'VATSettings', 'DynamicVatTypeName' );
$GLOBALS['eZVatType_dynamicVatTypeName'] = $desc;
}
return $GLOBALS['eZVatType_dynamicVatTypeName'];
} | php | static function dynamicVatTypeName()
{
if ( !isset( $GLOBALS['eZVatType_dynamicVatTypeName'] ) )
{
$shopINI = eZINI::instance( 'shop.ini' );
$desc = $shopINI->variable( 'VATSettings', 'DynamicVatTypeName' );
$GLOBALS['eZVatType_dynamicVatTypeName'] = $desc;
}
return $GLOBALS['eZVatType_dynamicVatTypeName'];
} | [
"static",
"function",
"dynamicVatTypeName",
"(",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"GLOBALS",
"[",
"'eZVatType_dynamicVatTypeName'",
"]",
")",
")",
"{",
"$",
"shopINI",
"=",
"eZINI",
"::",
"instance",
"(",
"'shop.ini'",
")",
";",
"$",
"desc",
... | Return name of the "fake" dynamic VAT type.
\private
\static | [
"Return",
"name",
"of",
"the",
"fake",
"dynamic",
"VAT",
"type",
"."
] | 2493420f527fbc829a8d5bdda402e05d64a20db7 | https://github.com/ezsystems/ezpublish-legacy/blob/2493420f527fbc829a8d5bdda402e05d64a20db7/kernel/classes/ezvattype.php#L73-L83 | train |
ezsystems/ezpublish-legacy | kernel/classes/ezvattype.php | eZVatType.fetchDependentProductsCount | static function fetchDependentProductsCount( $vatID )
{
$vatID = (int) $vatID; // prevent SQL injection
// We need DISTINCT here since there might be several object translations.
$query = "SELECT COUNT(DISTINCT coa.contentobject_id) AS count " .
"FROM ezcontentobject_attribute coa, ezcontentobject co " .
"WHERE " .
"coa.contentobject_id=co.id AND " .
"coa.version=co.current_version AND " .
"data_type_string IN ('ezprice', 'ezmultiprice') " .
"AND data_text LIKE '$vatID,%'";
$db = eZDB::instance();
$rslt = $db->arrayQuery( $query );
$nProducts = $rslt[0]['count'];
return $nProducts;
} | php | static function fetchDependentProductsCount( $vatID )
{
$vatID = (int) $vatID; // prevent SQL injection
// We need DISTINCT here since there might be several object translations.
$query = "SELECT COUNT(DISTINCT coa.contentobject_id) AS count " .
"FROM ezcontentobject_attribute coa, ezcontentobject co " .
"WHERE " .
"coa.contentobject_id=co.id AND " .
"coa.version=co.current_version AND " .
"data_type_string IN ('ezprice', 'ezmultiprice') " .
"AND data_text LIKE '$vatID,%'";
$db = eZDB::instance();
$rslt = $db->arrayQuery( $query );
$nProducts = $rslt[0]['count'];
return $nProducts;
} | [
"static",
"function",
"fetchDependentProductsCount",
"(",
"$",
"vatID",
")",
"{",
"$",
"vatID",
"=",
"(",
"int",
")",
"$",
"vatID",
";",
"// prevent SQL injection",
"// We need DISTINCT here since there might be several object translations.",
"$",
"query",
"=",
"\"SELECT ... | Fetches number of products using given VAT type.
\public
\static
\param $vatID id of VAT type to count dependent products for.
\return Number of dependent products. | [
"Fetches",
"number",
"of",
"products",
"using",
"given",
"VAT",
"type",
"."
] | 2493420f527fbc829a8d5bdda402e05d64a20db7 | https://github.com/ezsystems/ezpublish-legacy/blob/2493420f527fbc829a8d5bdda402e05d64a20db7/kernel/classes/ezvattype.php#L131-L148 | train |
ezsystems/ezpublish-legacy | kernel/classes/ezvattype.php | eZVatType.fetchDependentClassesCount | static function fetchDependentClassesCount( $vatID )
{
$vatID = (int) $vatID; // prevent SQL injection
$query = "SELECT COUNT(DISTINCT cc.id) AS count " .
"FROM ezcontentclass cc, ezcontentclass_attribute cca " .
"WHERE cc.id=cca.contentclass_id AND " .
"cca.data_type_string IN ('ezprice', 'ezmultiprice') AND data_float1=$vatID";
$db = eZDB::instance();
$rslt = $db->arrayQuery( $query );
$nClasses = $rslt[0]['count'];
return $nClasses;
} | php | static function fetchDependentClassesCount( $vatID )
{
$vatID = (int) $vatID; // prevent SQL injection
$query = "SELECT COUNT(DISTINCT cc.id) AS count " .
"FROM ezcontentclass cc, ezcontentclass_attribute cca " .
"WHERE cc.id=cca.contentclass_id AND " .
"cca.data_type_string IN ('ezprice', 'ezmultiprice') AND data_float1=$vatID";
$db = eZDB::instance();
$rslt = $db->arrayQuery( $query );
$nClasses = $rslt[0]['count'];
return $nClasses;
} | [
"static",
"function",
"fetchDependentClassesCount",
"(",
"$",
"vatID",
")",
"{",
"$",
"vatID",
"=",
"(",
"int",
")",
"$",
"vatID",
";",
"// prevent SQL injection",
"$",
"query",
"=",
"\"SELECT COUNT(DISTINCT cc.id) AS count \"",
".",
"\"FROM ezcontentclass cc, ezcontent... | Fetches number of product classes having given VAT type set as default.
\public
\static
\return Number of dependent product classes. | [
"Fetches",
"number",
"of",
"product",
"classes",
"having",
"given",
"VAT",
"type",
"set",
"as",
"default",
"."
] | 2493420f527fbc829a8d5bdda402e05d64a20db7 | https://github.com/ezsystems/ezpublish-legacy/blob/2493420f527fbc829a8d5bdda402e05d64a20db7/kernel/classes/ezvattype.php#L157-L170 | train |
ezsystems/ezpublish-legacy | kernel/classes/ezvattype.php | eZVatType.removeThis | function removeThis()
{
$vatID = $this->ID;
$db = eZDB::instance();
$db->begin();
// remove dependent VAT rules
$dependentRules = eZVatRule::fetchByVatType( $vatID );
foreach ( $dependentRules as $rule )
{
eZVatRule::removeVatRule( $rule->attribute( 'id' ) );
}
// replace VAT type in dependent products.
eZVatType::resetToDefaultInProducts( $vatID );
// Remove the VAT type itself.
eZPersistentObject::removeObject( eZVatType::definition(),
array( "id" => $vatID ) );
$db->commit();
} | php | function removeThis()
{
$vatID = $this->ID;
$db = eZDB::instance();
$db->begin();
// remove dependent VAT rules
$dependentRules = eZVatRule::fetchByVatType( $vatID );
foreach ( $dependentRules as $rule )
{
eZVatRule::removeVatRule( $rule->attribute( 'id' ) );
}
// replace VAT type in dependent products.
eZVatType::resetToDefaultInProducts( $vatID );
// Remove the VAT type itself.
eZPersistentObject::removeObject( eZVatType::definition(),
array( "id" => $vatID ) );
$db->commit();
} | [
"function",
"removeThis",
"(",
")",
"{",
"$",
"vatID",
"=",
"$",
"this",
"->",
"ID",
";",
"$",
"db",
"=",
"eZDB",
"::",
"instance",
"(",
")",
";",
"$",
"db",
"->",
"begin",
"(",
")",
";",
"// remove dependent VAT rules",
"$",
"dependentRules",
"=",
"... | Remove given VAT type and all references to it.
Drops VAT charging rules referencing the VAT type.
Resets VAT type in associated products to its default value for a product class.
\param $vatID id of VAT type to remove.
\public
\static | [
"Remove",
"given",
"VAT",
"type",
"and",
"all",
"references",
"to",
"it",
"."
] | 2493420f527fbc829a8d5bdda402e05d64a20db7 | https://github.com/ezsystems/ezpublish-legacy/blob/2493420f527fbc829a8d5bdda402e05d64a20db7/kernel/classes/ezvattype.php#L238-L259 | train |
ezsystems/ezpublish-legacy | kernel/private/rest/classes/routes/regexp.php | ezpMvcRegexpRoute.prefix | public function prefix( $prefix )
{
// Detect the Regexp delimiter
$patternDelim = $this->pattern[0];
// Add the Regexp delimiter to the prefix
$prefix = $patternDelim . $prefix . $patternDelim;
parent::prefix( $prefix );
} | php | public function prefix( $prefix )
{
// Detect the Regexp delimiter
$patternDelim = $this->pattern[0];
// Add the Regexp delimiter to the prefix
$prefix = $patternDelim . $prefix . $patternDelim;
parent::prefix( $prefix );
} | [
"public",
"function",
"prefix",
"(",
"$",
"prefix",
")",
"{",
"// Detect the Regexp delimiter",
"$",
"patternDelim",
"=",
"$",
"this",
"->",
"pattern",
"[",
"0",
"]",
";",
"// Add the Regexp delimiter to the prefix",
"$",
"prefix",
"=",
"$",
"patternDelim",
".",
... | Little fix to allow mixed regexp and rails routes in the router
@see lib/ezc/MvcTools/src/routes/ezcMvcRegexpRoute::prefix() | [
"Little",
"fix",
"to",
"allow",
"mixed",
"regexp",
"and",
"rails",
"routes",
"in",
"the",
"router"
] | 2493420f527fbc829a8d5bdda402e05d64a20db7 | https://github.com/ezsystems/ezpublish-legacy/blob/2493420f527fbc829a8d5bdda402e05d64a20db7/kernel/private/rest/classes/routes/regexp.php#L68-L76 | train |
ezsystems/ezpublish-legacy | kernel/private/rest/classes/routes/regexp.php | ezpMvcRegexpRoute.matches | public function matches( ezcMvcRequest $request )
{
if ( $this->pregMatch( $request, $matches ) )
{
foreach ( $matches as $key => $match )
{
if ( is_numeric( $key ) )
{
unset( $matches[$key] );
}
}
if ( !isset( $this->protocolActionMap[$request->protocol] ) )
{
throw new ezpRouteMethodNotAllowedException( $this->getSupportedHTTPMethods() );
}
$request->variables = array_merge( $this->defaultValues, $request->variables, $matches );
if ( $request->protocol === 'http-options' )
{
$request->variables['supported_http_methods'] = $this->getSupportedHTTPMethods();
}
return new ezcMvcRoutingInformation( $this->pattern, $this->controllerClassName, $this->protocolActionMap[$request->protocol] );
}
return null;
} | php | public function matches( ezcMvcRequest $request )
{
if ( $this->pregMatch( $request, $matches ) )
{
foreach ( $matches as $key => $match )
{
if ( is_numeric( $key ) )
{
unset( $matches[$key] );
}
}
if ( !isset( $this->protocolActionMap[$request->protocol] ) )
{
throw new ezpRouteMethodNotAllowedException( $this->getSupportedHTTPMethods() );
}
$request->variables = array_merge( $this->defaultValues, $request->variables, $matches );
if ( $request->protocol === 'http-options' )
{
$request->variables['supported_http_methods'] = $this->getSupportedHTTPMethods();
}
return new ezcMvcRoutingInformation( $this->pattern, $this->controllerClassName, $this->protocolActionMap[$request->protocol] );
}
return null;
} | [
"public",
"function",
"matches",
"(",
"ezcMvcRequest",
"$",
"request",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"pregMatch",
"(",
"$",
"request",
",",
"$",
"matches",
")",
")",
"{",
"foreach",
"(",
"$",
"matches",
"as",
"$",
"key",
"=>",
"$",
"match",... | Evaluates the URI against this route and allowed protocols
The method first runs the match. If the regular expression matches, it
cleans up the variables to only include named parameters. it then
creates an object containing routing information and returns it. If the
route's pattern did not match it returns null.
@param ezcMvcRequest $request
@return null|ezcMvcRoutingInformation | [
"Evaluates",
"the",
"URI",
"against",
"this",
"route",
"and",
"allowed",
"protocols"
] | 2493420f527fbc829a8d5bdda402e05d64a20db7 | https://github.com/ezsystems/ezpublish-legacy/blob/2493420f527fbc829a8d5bdda402e05d64a20db7/kernel/private/rest/classes/routes/regexp.php#L90-L113 | train |
ezsystems/ezpublish-legacy | kernel/classes/datatypes/ezauthor/ezauthor.php | eZAuthor.addAuthor | function addAuthor( $id, $name, $email )
{
if ( $id == -1 )
{
if ( isset( $this->Authors[$this->AuthorCount - 1] ) )
$id = $this->Authors[$this->AuthorCount - 1]['id'] + 1;
else
$id = 1;
}
$this->Authors[] = array( "id" => $id,
"name" => $name,
"email" => $email,
"is_default" => false );
$this->AuthorCount ++;
} | php | function addAuthor( $id, $name, $email )
{
if ( $id == -1 )
{
if ( isset( $this->Authors[$this->AuthorCount - 1] ) )
$id = $this->Authors[$this->AuthorCount - 1]['id'] + 1;
else
$id = 1;
}
$this->Authors[] = array( "id" => $id,
"name" => $name,
"email" => $email,
"is_default" => false );
$this->AuthorCount ++;
} | [
"function",
"addAuthor",
"(",
"$",
"id",
",",
"$",
"name",
",",
"$",
"email",
")",
"{",
"if",
"(",
"$",
"id",
"==",
"-",
"1",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"Authors",
"[",
"$",
"this",
"->",
"AuthorCount",
"-",
"1",
"]... | Add an author
@param int $id
@param string $name
@param string $email | [
"Add",
"an",
"author"
] | 2493420f527fbc829a8d5bdda402e05d64a20db7 | https://github.com/ezsystems/ezpublish-legacy/blob/2493420f527fbc829a8d5bdda402e05d64a20db7/kernel/classes/datatypes/ezauthor/ezauthor.php#L59-L75 | train |
ezsystems/ezpublish-legacy | kernel/classes/datatypes/ezurl/ezurlobjectlink.php | eZURLObjectLink.fetchLinkObjectList | static public function fetchLinkObjectList( $contentObjectAttributeID, $contentObjectAttributeVersion, $asObject = true )
{
$conditions = array( 'contentobject_attribute_id' => $contentObjectAttributeID );
if ( $contentObjectAttributeVersion !== false )
{
$conditions['contentobject_attribute_version'] = $contentObjectAttributeVersion;
}
return eZPersistentObject::fetchObjectList(
eZURLObjectLink::definition(),
null,
$conditions,
null,
null,
$asObject
);
} | php | static public function fetchLinkObjectList( $contentObjectAttributeID, $contentObjectAttributeVersion, $asObject = true )
{
$conditions = array( 'contentobject_attribute_id' => $contentObjectAttributeID );
if ( $contentObjectAttributeVersion !== false )
{
$conditions['contentobject_attribute_version'] = $contentObjectAttributeVersion;
}
return eZPersistentObject::fetchObjectList(
eZURLObjectLink::definition(),
null,
$conditions,
null,
null,
$asObject
);
} | [
"static",
"public",
"function",
"fetchLinkObjectList",
"(",
"$",
"contentObjectAttributeID",
",",
"$",
"contentObjectAttributeVersion",
",",
"$",
"asObject",
"=",
"true",
")",
"{",
"$",
"conditions",
"=",
"array",
"(",
"'contentobject_attribute_id'",
"=>",
"$",
"con... | Fetches an array of eZURLObjectLink
@param $contentObjectAttributeID
@param $contentObjectAttributeVersion : if all links object for all versions are returned
@param bool $asObject
@return array|eZURLObjectLink[]|null | [
"Fetches",
"an",
"array",
"of",
"eZURLObjectLink"
] | 2493420f527fbc829a8d5bdda402e05d64a20db7 | https://github.com/ezsystems/ezpublish-legacy/blob/2493420f527fbc829a8d5bdda402e05d64a20db7/kernel/classes/datatypes/ezurl/ezurlobjectlink.php#L190-L207 | train |
ezsystems/ezpublish-legacy | kernel/classes/ezcontentclass.php | eZContentClass.storeVersioned | public function storeVersioned( $attributes, $version )
{
$previousVersion = $this->attribute( 'version' );
$db = eZDB::instance();
$db->begin();
// Before removing anything from the attributes, load attribute information
// which might otherwise not accessible when recreating them below.
// See issue #18164
foreach ( $attributes as $attribute )
{
$attribute->content();
}
$this->removeAttributes( false, $version );
$this->removeAttributes( false, $previousVersion );
$this->remove( false );
$this->setVersion( $version, $attributes );
$this->setAttribute( "modifier_id", eZUser::currentUser()->attribute( "contentobject_id" ) );
$this->setAttribute( "modified", time() );
$this->adjustAttributePlacements( $attributes );
foreach( $attributes as $attribute )
{
$attribute->storeVersioned( $version );
}
// Set contentobject_name to something sensible if it is missing
if ( count( $attributes ) > 0 && trim( $this->attribute( 'contentobject_name' ) ) == '' )
{
$this->setAttribute( 'contentobject_name', '<' . $attributes[0]->attribute( 'identifier' ) . '>' );
}
// Recreate class member entries
eZContentClassClassGroup::removeClassMembers( $this->ID, $version );
foreach( eZContentClassClassGroup::fetchGroupList( $this->ID, $previousVersion ) as $classgroup )
{
$classgroup->setAttribute( 'contentclass_version', $version );
$classgroup->store();
}
eZContentClassClassGroup::removeClassMembers( $this->ID, $previousVersion );
$handler = eZExpiryHandler::instance();
$time = time();
$handler->setTimestamp( 'user-class-cache', $time );
$handler->setTimestamp( 'class-identifier-cache', $time );
$handler->setTimestamp( 'sort-key-cache', $time );
$handler->store();
$this->setAttribute( 'serialized_name_list', $this->NameList->serializeNames() );
$this->setAttribute( 'serialized_description_list', $this->DescriptionList->serializeNames() );
parent::store();
$this->NameList->store( $this );
$db->commit();
eZContentCacheManager::clearAllContentCache();
} | php | public function storeVersioned( $attributes, $version )
{
$previousVersion = $this->attribute( 'version' );
$db = eZDB::instance();
$db->begin();
// Before removing anything from the attributes, load attribute information
// which might otherwise not accessible when recreating them below.
// See issue #18164
foreach ( $attributes as $attribute )
{
$attribute->content();
}
$this->removeAttributes( false, $version );
$this->removeAttributes( false, $previousVersion );
$this->remove( false );
$this->setVersion( $version, $attributes );
$this->setAttribute( "modifier_id", eZUser::currentUser()->attribute( "contentobject_id" ) );
$this->setAttribute( "modified", time() );
$this->adjustAttributePlacements( $attributes );
foreach( $attributes as $attribute )
{
$attribute->storeVersioned( $version );
}
// Set contentobject_name to something sensible if it is missing
if ( count( $attributes ) > 0 && trim( $this->attribute( 'contentobject_name' ) ) == '' )
{
$this->setAttribute( 'contentobject_name', '<' . $attributes[0]->attribute( 'identifier' ) . '>' );
}
// Recreate class member entries
eZContentClassClassGroup::removeClassMembers( $this->ID, $version );
foreach( eZContentClassClassGroup::fetchGroupList( $this->ID, $previousVersion ) as $classgroup )
{
$classgroup->setAttribute( 'contentclass_version', $version );
$classgroup->store();
}
eZContentClassClassGroup::removeClassMembers( $this->ID, $previousVersion );
$handler = eZExpiryHandler::instance();
$time = time();
$handler->setTimestamp( 'user-class-cache', $time );
$handler->setTimestamp( 'class-identifier-cache', $time );
$handler->setTimestamp( 'sort-key-cache', $time );
$handler->store();
$this->setAttribute( 'serialized_name_list', $this->NameList->serializeNames() );
$this->setAttribute( 'serialized_description_list', $this->DescriptionList->serializeNames() );
parent::store();
$this->NameList->store( $this );
$db->commit();
eZContentCacheManager::clearAllContentCache();
} | [
"public",
"function",
"storeVersioned",
"(",
"$",
"attributes",
",",
"$",
"version",
")",
"{",
"$",
"previousVersion",
"=",
"$",
"this",
"->",
"attribute",
"(",
"'version'",
")",
";",
"$",
"db",
"=",
"eZDB",
"::",
"instance",
"(",
")",
";",
"$",
"db",
... | Stores the current class as a modified version, updates the contentobject_name
attribute and recreates the class group entries.
@note It will remove classes in the previous and specified version before storing.
@param array $attributes array of attributes
@param int $version version status
@since Version 4.3 | [
"Stores",
"the",
"current",
"class",
"as",
"a",
"modified",
"version",
"updates",
"the",
"contentobject_name",
"attribute",
"and",
"recreates",
"the",
"class",
"group",
"entries",
"."
] | 2493420f527fbc829a8d5bdda402e05d64a20db7 | https://github.com/ezsystems/ezpublish-legacy/blob/2493420f527fbc829a8d5bdda402e05d64a20db7/kernel/classes/ezcontentclass.php#L1007-L1065 | train |
ezsystems/ezpublish-legacy | kernel/classes/ezcontentclass.php | eZContentClass.versionHistoryLimit | public static function versionHistoryLimit( $class )
{
// default version limit
$contentINI = eZINI::instance( 'content.ini' );
$versionLimit = $contentINI->variable( 'VersionManagement', 'DefaultVersionHistoryLimit' );
// version limit can't be < 2
if ( $versionLimit < 2 )
{
eZDebug::writeWarning( "Global version history limit must be equal to or higher than 2", __METHOD__ );
$versionLimit = 2;
}
// we need to take $class down to a class ID
if ( is_numeric( $class ) )
{
if (!eZContentClass::classIdentifierByID( $class ) )
{
eZDebug::writeWarning( "class integer parameter doesn't match any content class ID", __METHOD__ );
return $versionLimit;
}
$classID = (int)$class;
}
// literal identifier
elseif ( is_string( $class ) )
{
$classID = eZContentClass::classIDByIdentifier( $class );
if ( !$classID )
{
eZDebug::writeWarning( "class string parameter doesn't match any content class identifier", __METHOD__ );
return $versionLimit;
}
}
// eZContentClass object
elseif ( is_object( $class ) )
{
if ( !$class instanceof eZContentClass )
{
eZDebug::writeWarning( "class object parameter is not an eZContentClass", __METHOD__ );
return $versionLimit;
}
else
{
$classID = $class->attribute( 'id' );
}
}
$classLimitSetting = $contentINI->variable( 'VersionManagement', 'VersionHistoryClass' );
$classArray = array_keys( $classLimitSetting );
$limitsArray = array_values( $classLimitSetting );
$classArray = eZContentClass::classIDByIdentifier( $classArray );
foreach ( $classArray as $index => $id )
{
if ( $id == $classID )
{
$limit = $limitsArray[$index];
// version limit can't be < 2
if ( $limit < 2 )
{
$classIdentifier = eZContentClass::classIdentifierByID( $classID );
eZDebug::writeWarning( "Version history limit for class {$classIdentifier} must be equal to or higher than 2", __METHOD__ );
$limit = 2;
}
$versionLimit = $limit;
}
}
return $versionLimit;
} | php | public static function versionHistoryLimit( $class )
{
// default version limit
$contentINI = eZINI::instance( 'content.ini' );
$versionLimit = $contentINI->variable( 'VersionManagement', 'DefaultVersionHistoryLimit' );
// version limit can't be < 2
if ( $versionLimit < 2 )
{
eZDebug::writeWarning( "Global version history limit must be equal to or higher than 2", __METHOD__ );
$versionLimit = 2;
}
// we need to take $class down to a class ID
if ( is_numeric( $class ) )
{
if (!eZContentClass::classIdentifierByID( $class ) )
{
eZDebug::writeWarning( "class integer parameter doesn't match any content class ID", __METHOD__ );
return $versionLimit;
}
$classID = (int)$class;
}
// literal identifier
elseif ( is_string( $class ) )
{
$classID = eZContentClass::classIDByIdentifier( $class );
if ( !$classID )
{
eZDebug::writeWarning( "class string parameter doesn't match any content class identifier", __METHOD__ );
return $versionLimit;
}
}
// eZContentClass object
elseif ( is_object( $class ) )
{
if ( !$class instanceof eZContentClass )
{
eZDebug::writeWarning( "class object parameter is not an eZContentClass", __METHOD__ );
return $versionLimit;
}
else
{
$classID = $class->attribute( 'id' );
}
}
$classLimitSetting = $contentINI->variable( 'VersionManagement', 'VersionHistoryClass' );
$classArray = array_keys( $classLimitSetting );
$limitsArray = array_values( $classLimitSetting );
$classArray = eZContentClass::classIDByIdentifier( $classArray );
foreach ( $classArray as $index => $id )
{
if ( $id == $classID )
{
$limit = $limitsArray[$index];
// version limit can't be < 2
if ( $limit < 2 )
{
$classIdentifier = eZContentClass::classIdentifierByID( $classID );
eZDebug::writeWarning( "Version history limit for class {$classIdentifier} must be equal to or higher than 2", __METHOD__ );
$limit = 2;
}
$versionLimit = $limit;
}
}
return $versionLimit;
} | [
"public",
"static",
"function",
"versionHistoryLimit",
"(",
"$",
"class",
")",
"{",
"// default version limit",
"$",
"contentINI",
"=",
"eZINI",
"::",
"instance",
"(",
"'content.ini'",
")",
";",
"$",
"versionLimit",
"=",
"$",
"contentINI",
"->",
"variable",
"(",... | Computes the version history limit for a content class
@param mixed $class
Content class ID, content class identifier or content class object
@return int
@since 4.2 | [
"Computes",
"the",
"version",
"history",
"limit",
"for",
"a",
"content",
"class"
] | 2493420f527fbc829a8d5bdda402e05d64a20db7 | https://github.com/ezsystems/ezpublish-legacy/blob/2493420f527fbc829a8d5bdda402e05d64a20db7/kernel/classes/ezcontentclass.php#L1926-L1996 | train |
ezsystems/ezpublish-legacy | kernel/private/rest/classes/request/rest_request.php | ezpRestRequest.getHostURI | public function getHostURI()
{
$protIndex = strpos( $this->protocol, '-' );
$protocol = substr( $this->protocol, 0, $protIndex );
$hostUri = $protocol.'://'.$this->host;
return $hostUri;
} | php | public function getHostURI()
{
$protIndex = strpos( $this->protocol, '-' );
$protocol = substr( $this->protocol, 0, $protIndex );
$hostUri = $protocol.'://'.$this->host;
return $hostUri;
} | [
"public",
"function",
"getHostURI",
"(",
")",
"{",
"$",
"protIndex",
"=",
"strpos",
"(",
"$",
"this",
"->",
"protocol",
",",
"'-'",
")",
";",
"$",
"protocol",
"=",
"substr",
"(",
"$",
"this",
"->",
"protocol",
",",
"0",
",",
"$",
"protIndex",
")",
... | Returns the host with the protocol
@return string | [
"Returns",
"the",
"host",
"with",
"the",
"protocol"
] | 2493420f527fbc829a8d5bdda402e05d64a20db7 | https://github.com/ezsystems/ezpublish-legacy/blob/2493420f527fbc829a8d5bdda402e05d64a20db7/kernel/private/rest/classes/request/rest_request.php#L155-L162 | train |
ezsystems/ezpublish-legacy | kernel/private/rest/classes/request/rest_request.php | ezpRestRequest.getParsedBody | public function getParsedBody()
{
if ( $this->originalProtocol === 'http-post' )
{
if ( strpos( $this->raw['CONTENT_TYPE'], 'application/json' ) === 0 )
{
return json_decode( $this->body, true );
}
return $this->post;
}
if ( !isset( $this->raw['CONTENT_TYPE'] ) )
return null;
if ( empty( $this->body ) )
return array();
if ( strpos( $this->raw['CONTENT_TYPE'], 'application/x-www-form-urlencoded' ) === 0 )
{
parse_str( $this->body, $parsedBody );
return $parsedBody;
}
else if ( strpos( $this->raw['CONTENT_TYPE'], 'application/json' ) === 0 )
{
return json_decode( $this->body, true );
}
return null;
} | php | public function getParsedBody()
{
if ( $this->originalProtocol === 'http-post' )
{
if ( strpos( $this->raw['CONTENT_TYPE'], 'application/json' ) === 0 )
{
return json_decode( $this->body, true );
}
return $this->post;
}
if ( !isset( $this->raw['CONTENT_TYPE'] ) )
return null;
if ( empty( $this->body ) )
return array();
if ( strpos( $this->raw['CONTENT_TYPE'], 'application/x-www-form-urlencoded' ) === 0 )
{
parse_str( $this->body, $parsedBody );
return $parsedBody;
}
else if ( strpos( $this->raw['CONTENT_TYPE'], 'application/json' ) === 0 )
{
return json_decode( $this->body, true );
}
return null;
} | [
"public",
"function",
"getParsedBody",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"originalProtocol",
"===",
"'http-post'",
")",
"{",
"if",
"(",
"strpos",
"(",
"$",
"this",
"->",
"raw",
"[",
"'CONTENT_TYPE'",
"]",
",",
"'application/json'",
")",
"===",
... | Get parsed request body based on content type as a php hash.
Only supports application/x-www-form-urlencoded and application/json,
for anything else use ->body atm. If POST then ->post is returned.
@todo Add some sort of configurable lazy loaded request body handler for parsing misc content type.
@return array|null Null on unsupported content type. | [
"Get",
"parsed",
"request",
"body",
"based",
"on",
"content",
"type",
"as",
"a",
"php",
"hash",
"."
] | 2493420f527fbc829a8d5bdda402e05d64a20db7 | https://github.com/ezsystems/ezpublish-legacy/blob/2493420f527fbc829a8d5bdda402e05d64a20db7/kernel/private/rest/classes/request/rest_request.php#L197-L223 | train |
ezsystems/ezpublish-legacy | lib/ezfile/classes/ezfile.php | eZFile.downloadHeaders | public static function downloadHeaders( $file, $isAttachedDownload = true, $overrideFilename = false, $startOffset = 0, $length = false, $fileSize = false )
{
if ( $fileSize === false )
{
if ( !file_exists( $file ) )
{
eZDebug::writeError( "\$fileSize not given, and file not found", __METHOD__ );
return false;
}
$fileSize = filesize( $file );
}
header( 'X-Powered-By: eZ Publish' );
$mimeinfo = eZMimeType::findByURL( $file );
header( "Content-Type: {$mimeinfo['name']}" );
// Fixes problems with IE when opening a file directly
header( "Pragma: " );
header( "Cache-Control: " );
// Last-Modified header cannot be set, otherwise browser like FF will fail while resuming a paused download
// because it compares the value of Last-Modified headers between requests.
header( "Last-Modified: " );
/* Set cache time out to 10 minutes, this should be good enough to work
around an IE bug */
header( "Expires: ". gmdate( 'D, d M Y H:i:s', time() + 600 ) . ' GMT' );
header(
"Content-Disposition: " .
( $isAttachedDownload ? 'attachment' : 'inline' ) .
( $overrideFilename !== false ? "; filename={$overrideFilename}" : '' )
);
// partial download (HTTP 'Range' header)
if ( $startOffset !== 0 )
{
$endOffset = ( $length !== false ) ? ( $length + $startOffset - 1 ) : $fileSize - 1;
header( "Content-Length: " . ( $endOffset - $startOffset + 1 ) );
header( "Content-Range: bytes {$startOffset}-{$endOffset}/{$fileSize}" );
header( "HTTP/1.1 206 Partial Content" );
}
else
{
header( "Content-Length: $fileSize" );
}
header( 'Content-Transfer-Encoding: binary' );
header( 'Accept-Ranges: bytes' );
} | php | public static function downloadHeaders( $file, $isAttachedDownload = true, $overrideFilename = false, $startOffset = 0, $length = false, $fileSize = false )
{
if ( $fileSize === false )
{
if ( !file_exists( $file ) )
{
eZDebug::writeError( "\$fileSize not given, and file not found", __METHOD__ );
return false;
}
$fileSize = filesize( $file );
}
header( 'X-Powered-By: eZ Publish' );
$mimeinfo = eZMimeType::findByURL( $file );
header( "Content-Type: {$mimeinfo['name']}" );
// Fixes problems with IE when opening a file directly
header( "Pragma: " );
header( "Cache-Control: " );
// Last-Modified header cannot be set, otherwise browser like FF will fail while resuming a paused download
// because it compares the value of Last-Modified headers between requests.
header( "Last-Modified: " );
/* Set cache time out to 10 minutes, this should be good enough to work
around an IE bug */
header( "Expires: ". gmdate( 'D, d M Y H:i:s', time() + 600 ) . ' GMT' );
header(
"Content-Disposition: " .
( $isAttachedDownload ? 'attachment' : 'inline' ) .
( $overrideFilename !== false ? "; filename={$overrideFilename}" : '' )
);
// partial download (HTTP 'Range' header)
if ( $startOffset !== 0 )
{
$endOffset = ( $length !== false ) ? ( $length + $startOffset - 1 ) : $fileSize - 1;
header( "Content-Length: " . ( $endOffset - $startOffset + 1 ) );
header( "Content-Range: bytes {$startOffset}-{$endOffset}/{$fileSize}" );
header( "HTTP/1.1 206 Partial Content" );
}
else
{
header( "Content-Length: $fileSize" );
}
header( 'Content-Transfer-Encoding: binary' );
header( 'Accept-Ranges: bytes' );
} | [
"public",
"static",
"function",
"downloadHeaders",
"(",
"$",
"file",
",",
"$",
"isAttachedDownload",
"=",
"true",
",",
"$",
"overrideFilename",
"=",
"false",
",",
"$",
"startOffset",
"=",
"0",
",",
"$",
"length",
"=",
"false",
",",
"$",
"fileSize",
"=",
... | Handles the header part of a file transfer to the client
@see download()
@param string $file Path to the local file
@param bool $isAttachedDownload Determines weather to download the file as an attachment ( download popup box ) or not.
@param string $overrideFilename Filename to send in headers instead of the actual file's name
@param int $startOffset Offset to start transfer from, in bytes
@param int $length Data size to transfer
@param string $fileSize The file's size. If not given, actual filesize will be queried. Required to work with clusterized files... | [
"Handles",
"the",
"header",
"part",
"of",
"a",
"file",
"transfer",
"to",
"the",
"client"
] | 2493420f527fbc829a8d5bdda402e05d64a20db7 | https://github.com/ezsystems/ezpublish-legacy/blob/2493420f527fbc829a8d5bdda402e05d64a20db7/lib/ezfile/classes/ezfile.php#L220-L266 | train |
ezsystems/ezpublish-legacy | lib/ezfile/classes/ezfile.php | eZFile.downloadContent | public static function downloadContent( $file, $startOffset = 0, $length = false )
{
if ( !file_exists( $file ) )
{
eZDebug::writeError( "'$file' does not exist", __METHOD__ );
return false;
}
if ( ( $fp = fopen( $file, 'rb' ) ) === false )
{
eZDebug::writeError( "An error occured opening '$file' for reading", __METHOD__ );
return false;
}
$fileSize = filesize( $file );
// an offset has been given: move the pointer to that offset if it seems valid
if ( $startOffset !== false && $startOffset <= $fileSize && fseek( $fp, $startOffset ) === -1 )
{
eZDebug::writeError( "Error while setting offset on '{$file}'", __METHOD__ );
return false;
}
$transferred = $startOffset;
$packetSize = self::READ_PACKET_SIZE;
$endOffset = ( $length === false ) ? $fileSize - 1 : $length + $startOffset - 1;
while ( !feof( $fp ) && $transferred < $endOffset + 1 )
{
if ( $transferred + $packetSize > $endOffset + 1 )
{
$packetSize = $endOffset + 1 - $transferred;
}
echo fread( $fp, $packetSize );
$transferred += $packetSize;
}
fclose( $fp );
return true;
} | php | public static function downloadContent( $file, $startOffset = 0, $length = false )
{
if ( !file_exists( $file ) )
{
eZDebug::writeError( "'$file' does not exist", __METHOD__ );
return false;
}
if ( ( $fp = fopen( $file, 'rb' ) ) === false )
{
eZDebug::writeError( "An error occured opening '$file' for reading", __METHOD__ );
return false;
}
$fileSize = filesize( $file );
// an offset has been given: move the pointer to that offset if it seems valid
if ( $startOffset !== false && $startOffset <= $fileSize && fseek( $fp, $startOffset ) === -1 )
{
eZDebug::writeError( "Error while setting offset on '{$file}'", __METHOD__ );
return false;
}
$transferred = $startOffset;
$packetSize = self::READ_PACKET_SIZE;
$endOffset = ( $length === false ) ? $fileSize - 1 : $length + $startOffset - 1;
while ( !feof( $fp ) && $transferred < $endOffset + 1 )
{
if ( $transferred + $packetSize > $endOffset + 1 )
{
$packetSize = $endOffset + 1 - $transferred;
}
echo fread( $fp, $packetSize );
$transferred += $packetSize;
}
fclose( $fp );
return true;
} | [
"public",
"static",
"function",
"downloadContent",
"(",
"$",
"file",
",",
"$",
"startOffset",
"=",
"0",
",",
"$",
"length",
"=",
"false",
")",
"{",
"if",
"(",
"!",
"file_exists",
"(",
"$",
"file",
")",
")",
"{",
"eZDebug",
"::",
"writeError",
"(",
"\... | Handles the data part of a file transfer to the client
@see download()
@param string $file Path to the local file
@param int $startOffset Offset to start transfer from, in bytes
@param int $length Data size to transfer | [
"Handles",
"the",
"data",
"part",
"of",
"a",
"file",
"transfer",
"to",
"the",
"client"
] | 2493420f527fbc829a8d5bdda402e05d64a20db7 | https://github.com/ezsystems/ezpublish-legacy/blob/2493420f527fbc829a8d5bdda402e05d64a20db7/lib/ezfile/classes/ezfile.php#L277-L315 | train |
ezsystems/ezpublish-legacy | kernel/classes/ezclusterfilehandler.php | eZClusterFileHandler.instance | static function instance( $filename = false )
{
if ( self::$isShutdownFunctionRegistered !== true )
{
eZExecution::addCleanupHandler( array( __CLASS__, 'cleanupGeneratingFiles' ) );
self::$isShutdownFunctionRegistered = true;
}
if( $filename !== false )
{
$optionArray = array( 'iniFile' => 'file.ini',
'iniSection' => 'ClusteringSettings',
'iniVariable' => 'FileHandler',
'handlerParams'=> array( $filename ) );
$options = new ezpExtensionOptions( $optionArray );
$handler = eZExtension::getHandlerClass( $options );
return $handler;
}
else
{
// return Filehandler from GLOBALS based on ini setting.
if ( self::$globalHandler === null )
{
$optionArray = array( 'iniFile' => 'file.ini',
'iniSection' => 'ClusteringSettings',
'iniVariable' => 'FileHandler' );
$options = new ezpExtensionOptions( $optionArray );
$handler = eZExtension::getHandlerClass( $options );
self::$globalHandler = $handler;
}
else
$handler = self::$globalHandler;
return $handler;
}
} | php | static function instance( $filename = false )
{
if ( self::$isShutdownFunctionRegistered !== true )
{
eZExecution::addCleanupHandler( array( __CLASS__, 'cleanupGeneratingFiles' ) );
self::$isShutdownFunctionRegistered = true;
}
if( $filename !== false )
{
$optionArray = array( 'iniFile' => 'file.ini',
'iniSection' => 'ClusteringSettings',
'iniVariable' => 'FileHandler',
'handlerParams'=> array( $filename ) );
$options = new ezpExtensionOptions( $optionArray );
$handler = eZExtension::getHandlerClass( $options );
return $handler;
}
else
{
// return Filehandler from GLOBALS based on ini setting.
if ( self::$globalHandler === null )
{
$optionArray = array( 'iniFile' => 'file.ini',
'iniSection' => 'ClusteringSettings',
'iniVariable' => 'FileHandler' );
$options = new ezpExtensionOptions( $optionArray );
$handler = eZExtension::getHandlerClass( $options );
self::$globalHandler = $handler;
}
else
$handler = self::$globalHandler;
return $handler;
}
} | [
"static",
"function",
"instance",
"(",
"$",
"filename",
"=",
"false",
")",
"{",
"if",
"(",
"self",
"::",
"$",
"isShutdownFunctionRegistered",
"!==",
"true",
")",
"{",
"eZExecution",
"::",
"addCleanupHandler",
"(",
"array",
"(",
"__CLASS__",
",",
"'cleanupGener... | Returns the configured instance of an eZClusterFileHandlerInterface
See ClusteringSettings.FileHandler in file.ini
@param string|bool $filename
Optional filename the handler should be initialized with
@return eZClusterFileHandlerInterface | [
"Returns",
"the",
"configured",
"instance",
"of",
"an",
"eZClusterFileHandlerInterface",
"See",
"ClusteringSettings",
".",
"FileHandler",
"in",
"file",
".",
"ini"
] | 2493420f527fbc829a8d5bdda402e05d64a20db7 | https://github.com/ezsystems/ezpublish-legacy/blob/2493420f527fbc829a8d5bdda402e05d64a20db7/kernel/classes/ezclusterfilehandler.php#L21-L62 | train |
ezsystems/ezpublish-legacy | kernel/classes/ezclusterfilehandler.php | eZClusterFileHandler.cleanupGeneratingFiles | static function cleanupGeneratingFiles()
{
if ( count( self::$generatingFiles ) === 0 )
{
return false;
}
else
{
eZDebug::writeWarning( "Execution was stopped while one or more files were generating. This should not happen.", __METHOD__ );
foreach( self::$generatingFiles as $generatingFile )
{
$generatingFile->abortCacheGeneration();
self::removeGeneratingFile( $generatingFile );
}
return true;
}
} | php | static function cleanupGeneratingFiles()
{
if ( count( self::$generatingFiles ) === 0 )
{
return false;
}
else
{
eZDebug::writeWarning( "Execution was stopped while one or more files were generating. This should not happen.", __METHOD__ );
foreach( self::$generatingFiles as $generatingFile )
{
$generatingFile->abortCacheGeneration();
self::removeGeneratingFile( $generatingFile );
}
return true;
}
} | [
"static",
"function",
"cleanupGeneratingFiles",
"(",
")",
"{",
"if",
"(",
"count",
"(",
"self",
"::",
"$",
"generatingFiles",
")",
"===",
"0",
")",
"{",
"return",
"false",
";",
"}",
"else",
"{",
"eZDebug",
"::",
"writeWarning",
"(",
"\"Execution was stopped ... | Cluster shutdown handler. Terminates generation for unterminated files.
This situation doesn't happen by default, but may with custom code that doesn't follow recommendations. | [
"Cluster",
"shutdown",
"handler",
".",
"Terminates",
"generation",
"for",
"unterminated",
"files",
".",
"This",
"situation",
"doesn",
"t",
"happen",
"by",
"default",
"but",
"may",
"with",
"custom",
"code",
"that",
"doesn",
"t",
"follow",
"recommendations",
"."
] | 2493420f527fbc829a8d5bdda402e05d64a20db7 | https://github.com/ezsystems/ezpublish-legacy/blob/2493420f527fbc829a8d5bdda402e05d64a20db7/kernel/classes/ezclusterfilehandler.php#L77-L93 | train |
ezsystems/ezpublish-legacy | kernel/classes/ezclusterfilehandler.php | eZClusterFileHandler.cleanupEmptyDirectories | public static function cleanupEmptyDirectories( $path )
{
$dirpath = eZDir::dirpath( $path );
eZDebugSetting::writeDebug( 'kernel-clustering', "eZClusterFileHandler::cleanupEmptyDirectories( '{$dirpath}' )" );
if ( is_dir( $dirpath ) )
{
eZDir::cleanupEmptyDirectories( $dirpath );
}
} | php | public static function cleanupEmptyDirectories( $path )
{
$dirpath = eZDir::dirpath( $path );
eZDebugSetting::writeDebug( 'kernel-clustering', "eZClusterFileHandler::cleanupEmptyDirectories( '{$dirpath}' )" );
if ( is_dir( $dirpath ) )
{
eZDir::cleanupEmptyDirectories( $dirpath );
}
} | [
"public",
"static",
"function",
"cleanupEmptyDirectories",
"(",
"$",
"path",
")",
"{",
"$",
"dirpath",
"=",
"eZDir",
"::",
"dirpath",
"(",
"$",
"path",
")",
";",
"eZDebugSetting",
"::",
"writeDebug",
"(",
"'kernel-clustering'",
",",
"\"eZClusterFileHandler::cleanu... | Goes trough the directory path and removes empty directories, starting at
the leaf and deleting down until a non empty directory is reached.
If the path is not a directory, nothing will happen.
@param string $path | [
"Goes",
"trough",
"the",
"directory",
"path",
"and",
"removes",
"empty",
"directories",
"starting",
"at",
"the",
"leaf",
"and",
"deleting",
"down",
"until",
"a",
"non",
"empty",
"directory",
"is",
"reached",
".",
"If",
"the",
"path",
"is",
"not",
"a",
"dir... | 2493420f527fbc829a8d5bdda402e05d64a20db7 | https://github.com/ezsystems/ezpublish-legacy/blob/2493420f527fbc829a8d5bdda402e05d64a20db7/kernel/classes/ezclusterfilehandler.php#L102-L112 | train |
ezsystems/ezpublish-legacy | kernel/classes/ezclusterfilehandler.php | eZClusterFileHandler.addGeneratingFile | public static function addGeneratingFile( $file )
{
if ( !( $file instanceof eZDFSFileHandler ) )
return false; // @todo Exception
self::$generatingFiles[$file->filePath] = $file;
} | php | public static function addGeneratingFile( $file )
{
if ( !( $file instanceof eZDFSFileHandler ) )
return false; // @todo Exception
self::$generatingFiles[$file->filePath] = $file;
} | [
"public",
"static",
"function",
"addGeneratingFile",
"(",
"$",
"file",
")",
"{",
"if",
"(",
"!",
"(",
"$",
"file",
"instanceof",
"eZDFSFileHandler",
")",
")",
"return",
"false",
";",
"// @todo Exception",
"self",
"::",
"$",
"generatingFiles",
"[",
"$",
"file... | Adds a file to the generating list
@param eZDFSFileHandler|eZDFSFileHandler $file
Cluster file handler instance
Note that this method expect a version of the handler where the filePath is the REAL one, not the .generating | [
"Adds",
"a",
"file",
"to",
"the",
"generating",
"list"
] | 2493420f527fbc829a8d5bdda402e05d64a20db7 | https://github.com/ezsystems/ezpublish-legacy/blob/2493420f527fbc829a8d5bdda402e05d64a20db7/kernel/classes/ezclusterfilehandler.php#L121-L127 | train |
ezsystems/ezpublish-legacy | kernel/classes/ezclusterfilehandler.php | eZClusterFileHandler.preFork | public static function preFork()
{
$clusterHandler = self::instance();
// disconnect DB based cluster handlers from the database
if ( $clusterHandler instanceof ezpDatabaseBasedClusterFileHandler )
{
$clusterHandler->disconnect();
// destroy the current handler so that it reconnects when instanciated again
self::$globalHandler = null;
}
} | php | public static function preFork()
{
$clusterHandler = self::instance();
// disconnect DB based cluster handlers from the database
if ( $clusterHandler instanceof ezpDatabaseBasedClusterFileHandler )
{
$clusterHandler->disconnect();
// destroy the current handler so that it reconnects when instanciated again
self::$globalHandler = null;
}
} | [
"public",
"static",
"function",
"preFork",
"(",
")",
"{",
"$",
"clusterHandler",
"=",
"self",
"::",
"instance",
"(",
")",
";",
"// disconnect DB based cluster handlers from the database",
"if",
"(",
"$",
"clusterHandler",
"instanceof",
"ezpDatabaseBasedClusterFileHandler"... | Performs required operations before forking a process
- disconnects DB based cluster handlers from the database | [
"Performs",
"required",
"operations",
"before",
"forking",
"a",
"process"
] | 2493420f527fbc829a8d5bdda402e05d64a20db7 | https://github.com/ezsystems/ezpublish-legacy/blob/2493420f527fbc829a8d5bdda402e05d64a20db7/kernel/classes/ezclusterfilehandler.php#L151-L163 | train |
ezsystems/ezpublish-legacy | extension/ezjscore/classes/ezjsccssoptimizer.php | ezjscCssOptimizer.optimize | public static function optimize( $css, $packLevel = 2 )
{
// Normalize line feeds
$css = str_replace( array( "\r\n", "\r" ), "\n", $css );
// Remove multiline comments
$css = preg_replace( '!(?:\n|\s|^)/\*[^*]*\*+([^/][^*]*\*+)*/!', '', $css );
$css = preg_replace( '!(?:;)/\*[^*]*\*+([^/][^*]*\*+)*/!', ';', $css );
// Remove whitespace from start and end of line + multiple linefeeds
$css = preg_replace( array( '/\n\s+/', '/\s+\n/', '/\n+/' ), "\n", $css );
if ( $packLevel > 2 )
{
// Remove space around ':' and ','
$css = preg_replace( array( '/:\s+/', '/\s+:/' ), ':', $css );
$css = preg_replace( array( '/,\s+/', '/\s+,/' ), ',', $css );
// Remove unnecessary line breaks...
$css = str_replace( array( ";\n", '; ' ), ';', $css );
$css = str_replace( array( "}\n", "\n}", ';}' ), '}', $css );
$css = str_replace( array( "{\n", "\n{", '{;' ), '{', $css );
// ... and spaces as well
$css = str_replace(array('\s{\s', '\s{', '{\s' ), '{', $css );
$css = str_replace(array('\s}\s', '\s}', '}\s' ), '}', $css );
// Optimize css
$css = str_replace( array( ' 0em', ' 0px', ' 0pt', ' 0pc' ), ' 0', $css );
$css = str_replace( array( ':0em', ':0px', ':0pt', ':0pc' ), ':0', $css );
$css = str_replace( ' 0 0 0 0;', ' 0;', $css );
$css = str_replace( ':0 0 0 0;', ':0;', $css );
// Optimize hex colors from #bbbbbb to #bbb
$css = preg_replace( "/color:#([0-9a-fA-F])\\1([0-9a-fA-F])\\2([0-9a-fA-F])\\3/", "color:#\\1\\2\\3", $css );
}
return $css;
} | php | public static function optimize( $css, $packLevel = 2 )
{
// Normalize line feeds
$css = str_replace( array( "\r\n", "\r" ), "\n", $css );
// Remove multiline comments
$css = preg_replace( '!(?:\n|\s|^)/\*[^*]*\*+([^/][^*]*\*+)*/!', '', $css );
$css = preg_replace( '!(?:;)/\*[^*]*\*+([^/][^*]*\*+)*/!', ';', $css );
// Remove whitespace from start and end of line + multiple linefeeds
$css = preg_replace( array( '/\n\s+/', '/\s+\n/', '/\n+/' ), "\n", $css );
if ( $packLevel > 2 )
{
// Remove space around ':' and ','
$css = preg_replace( array( '/:\s+/', '/\s+:/' ), ':', $css );
$css = preg_replace( array( '/,\s+/', '/\s+,/' ), ',', $css );
// Remove unnecessary line breaks...
$css = str_replace( array( ";\n", '; ' ), ';', $css );
$css = str_replace( array( "}\n", "\n}", ';}' ), '}', $css );
$css = str_replace( array( "{\n", "\n{", '{;' ), '{', $css );
// ... and spaces as well
$css = str_replace(array('\s{\s', '\s{', '{\s' ), '{', $css );
$css = str_replace(array('\s}\s', '\s}', '}\s' ), '}', $css );
// Optimize css
$css = str_replace( array( ' 0em', ' 0px', ' 0pt', ' 0pc' ), ' 0', $css );
$css = str_replace( array( ':0em', ':0px', ':0pt', ':0pc' ), ':0', $css );
$css = str_replace( ' 0 0 0 0;', ' 0;', $css );
$css = str_replace( ':0 0 0 0;', ':0;', $css );
// Optimize hex colors from #bbbbbb to #bbb
$css = preg_replace( "/color:#([0-9a-fA-F])\\1([0-9a-fA-F])\\2([0-9a-fA-F])\\3/", "color:#\\1\\2\\3", $css );
}
return $css;
} | [
"public",
"static",
"function",
"optimize",
"(",
"$",
"css",
",",
"$",
"packLevel",
"=",
"2",
")",
"{",
"// Normalize line feeds",
"$",
"css",
"=",
"str_replace",
"(",
"array",
"(",
"\"\\r\\n\"",
",",
"\"\\r\"",
")",
",",
"\"\\n\"",
",",
"$",
"css",
")",... | 'compress' css code by removing whitespace
@param string $css Concated Css string
@param int $packLevel Level of packing, values: 2-3
@return string | [
"compress",
"css",
"code",
"by",
"removing",
"whitespace"
] | 2493420f527fbc829a8d5bdda402e05d64a20db7 | https://github.com/ezsystems/ezpublish-legacy/blob/2493420f527fbc829a8d5bdda402e05d64a20db7/extension/ezjscore/classes/ezjsccssoptimizer.php#L40-L76 | train |
ezsystems/ezpublish-legacy | kernel/classes/ezsearch.php | eZSearch.getEngine | static public function getEngine()
{
// Get instance if already created.
$instanceName = "eZSearchPlugin_" . $GLOBALS["eZCurrentAccess"]["name"];
if ( isset( $GLOBALS[$instanceName] ) )
{
return $GLOBALS[$instanceName];
}
$ini = eZINI::instance();
$searchEngineString = 'ezsearch';
if ( $ini->hasVariable( 'SearchSettings', 'SearchEngine' ) == true )
{
$searchEngineString = $ini->variable( 'SearchSettings', 'SearchEngine' );
}
$directoryList = array();
if ( $ini->hasVariable( 'SearchSettings', 'ExtensionDirectories' ) )
{
$extensionDirectories = $ini->variable( 'SearchSettings', 'ExtensionDirectories' );
if ( is_array( $extensionDirectories ) )
{
$directoryList = eZExtension::expandedPathList( $extensionDirectories, 'search/plugins' );
}
}
$kernelDir = array( 'kernel/search/plugins' );
$directoryList = array_merge( $kernelDir, $directoryList );
foreach( $directoryList as $directory )
{
$searchEngineFile = implode( '/', array( $directory, strtolower( $searchEngineString ), strtolower( $searchEngineString ) ) ) . '.php';
if ( file_exists( $searchEngineFile ) )
{
eZDebugSetting::writeDebug( 'kernel-search-ezsearch', 'Loading search engine from ' . $searchEngineFile, 'eZSearch::getEngine' );
include_once( $searchEngineFile );
$GLOBALS[$instanceName] = new $searchEngineString();
return $GLOBALS[$instanceName];
}
}
eZDebug::writeDebug( 'Unable to find the search engine:' . $searchEngineString, 'eZSearch' );
eZDebug::writeDebug( 'Tried paths: ' . implode( ', ', $directoryList ), 'eZSearch' );
return false;
} | php | static public function getEngine()
{
// Get instance if already created.
$instanceName = "eZSearchPlugin_" . $GLOBALS["eZCurrentAccess"]["name"];
if ( isset( $GLOBALS[$instanceName] ) )
{
return $GLOBALS[$instanceName];
}
$ini = eZINI::instance();
$searchEngineString = 'ezsearch';
if ( $ini->hasVariable( 'SearchSettings', 'SearchEngine' ) == true )
{
$searchEngineString = $ini->variable( 'SearchSettings', 'SearchEngine' );
}
$directoryList = array();
if ( $ini->hasVariable( 'SearchSettings', 'ExtensionDirectories' ) )
{
$extensionDirectories = $ini->variable( 'SearchSettings', 'ExtensionDirectories' );
if ( is_array( $extensionDirectories ) )
{
$directoryList = eZExtension::expandedPathList( $extensionDirectories, 'search/plugins' );
}
}
$kernelDir = array( 'kernel/search/plugins' );
$directoryList = array_merge( $kernelDir, $directoryList );
foreach( $directoryList as $directory )
{
$searchEngineFile = implode( '/', array( $directory, strtolower( $searchEngineString ), strtolower( $searchEngineString ) ) ) . '.php';
if ( file_exists( $searchEngineFile ) )
{
eZDebugSetting::writeDebug( 'kernel-search-ezsearch', 'Loading search engine from ' . $searchEngineFile, 'eZSearch::getEngine' );
include_once( $searchEngineFile );
$GLOBALS[$instanceName] = new $searchEngineString();
return $GLOBALS[$instanceName];
}
}
eZDebug::writeDebug( 'Unable to find the search engine:' . $searchEngineString, 'eZSearch' );
eZDebug::writeDebug( 'Tried paths: ' . implode( ', ', $directoryList ), 'eZSearch' );
return false;
} | [
"static",
"public",
"function",
"getEngine",
"(",
")",
"{",
"// Get instance if already created.",
"$",
"instanceName",
"=",
"\"eZSearchPlugin_\"",
".",
"$",
"GLOBALS",
"[",
"\"eZCurrentAccess\"",
"]",
"[",
"\"name\"",
"]",
";",
"if",
"(",
"isset",
"(",
"$",
"GL... | Get object instance of eZSearch engine to use.
@return \ezpSearchEngine|bool Returns false (+ writes debug) if no engine was found | [
"Get",
"object",
"instance",
"of",
"eZSearch",
"engine",
"to",
"use",
"."
] | 2493420f527fbc829a8d5bdda402e05d64a20db7 | https://github.com/ezsystems/ezpublish-legacy/blob/2493420f527fbc829a8d5bdda402e05d64a20db7/kernel/classes/ezsearch.php#L447-L494 | train |
ezsystems/ezpublish-legacy | kernel/classes/ezsearch.php | eZSearch.updateObjectsSection | public static function updateObjectsSection( array $objectIDs, $sectionID )
{
$searchEngine = eZSearch::getEngine();
if ( $searchEngine instanceof ezpSearchEngine && method_exists( $searchEngine, 'updateObjectsSection' ) )
{
return $searchEngine->updateObjectsSection( $objectIDs, $sectionID );
}
return false;
} | php | public static function updateObjectsSection( array $objectIDs, $sectionID )
{
$searchEngine = eZSearch::getEngine();
if ( $searchEngine instanceof ezpSearchEngine && method_exists( $searchEngine, 'updateObjectsSection' ) )
{
return $searchEngine->updateObjectsSection( $objectIDs, $sectionID );
}
return false;
} | [
"public",
"static",
"function",
"updateObjectsSection",
"(",
"array",
"$",
"objectIDs",
",",
"$",
"sectionID",
")",
"{",
"$",
"searchEngine",
"=",
"eZSearch",
"::",
"getEngine",
"(",
")",
";",
"if",
"(",
"$",
"searchEngine",
"instanceof",
"ezpSearchEngine",
"&... | Notifies search engine about the change of section of a set of objects
@since 4.6
@param array $objectIDs
@param int $sectionID
@return false|mixed false in case method is undefined, otherwise return the result of the search engine call | [
"Notifies",
"search",
"engine",
"about",
"the",
"change",
"of",
"section",
"of",
"a",
"set",
"of",
"objects"
] | 2493420f527fbc829a8d5bdda402e05d64a20db7 | https://github.com/ezsystems/ezpublish-legacy/blob/2493420f527fbc829a8d5bdda402e05d64a20db7/kernel/classes/ezsearch.php#L504-L512 | train |
ezsystems/ezpublish-legacy | kernel/classes/ezsearch.php | eZSearch.updateNodeSection | public static function updateNodeSection( $nodeID, $sectionID )
{
$searchEngine = eZSearch::getEngine();
if ( $searchEngine instanceof ezpSearchEngine && method_exists( $searchEngine, 'updateNodeSection' ) )
{
return $searchEngine->updateNodeSection( $nodeID, $sectionID );
}
return false;
} | php | public static function updateNodeSection( $nodeID, $sectionID )
{
$searchEngine = eZSearch::getEngine();
if ( $searchEngine instanceof ezpSearchEngine && method_exists( $searchEngine, 'updateNodeSection' ) )
{
return $searchEngine->updateNodeSection( $nodeID, $sectionID );
}
return false;
} | [
"public",
"static",
"function",
"updateNodeSection",
"(",
"$",
"nodeID",
",",
"$",
"sectionID",
")",
"{",
"$",
"searchEngine",
"=",
"eZSearch",
"::",
"getEngine",
"(",
")",
";",
"if",
"(",
"$",
"searchEngine",
"instanceof",
"ezpSearchEngine",
"&&",
"method_exi... | Notifies search engine about section changes
@since 4.1
@param int $nodeID
@param int $sectionID
@return false|mixed False in case method is undefined, otherwise return the result of the search engine call | [
"Notifies",
"search",
"engine",
"about",
"section",
"changes"
] | 2493420f527fbc829a8d5bdda402e05d64a20db7 | https://github.com/ezsystems/ezpublish-legacy/blob/2493420f527fbc829a8d5bdda402e05d64a20db7/kernel/classes/ezsearch.php#L522-L532 | train |
ezsystems/ezpublish-legacy | kernel/classes/ezsearch.php | eZSearch.updateNodeVisibility | public static function updateNodeVisibility( $nodeID, $action )
{
$searchEngine = eZSearch::getEngine();
if ( $searchEngine instanceof ezpSearchEngine && method_exists( $searchEngine, 'updateNodeVisibility' ) )
{
return $searchEngine->updateNodeVisibility( $nodeID, $action );
}
return false;
} | php | public static function updateNodeVisibility( $nodeID, $action )
{
$searchEngine = eZSearch::getEngine();
if ( $searchEngine instanceof ezpSearchEngine && method_exists( $searchEngine, 'updateNodeVisibility' ) )
{
return $searchEngine->updateNodeVisibility( $nodeID, $action );
}
return false;
} | [
"public",
"static",
"function",
"updateNodeVisibility",
"(",
"$",
"nodeID",
",",
"$",
"action",
")",
"{",
"$",
"searchEngine",
"=",
"eZSearch",
"::",
"getEngine",
"(",
")",
";",
"if",
"(",
"$",
"searchEngine",
"instanceof",
"ezpSearchEngine",
"&&",
"method_exi... | Notifies search engine about node visibility changes
@since 4.1
@param int $nodeID
@param string $action "hide" or "show"
@return false|mixed False in case method is undefined, otherwise return the result of the search engine call | [
"Notifies",
"search",
"engine",
"about",
"node",
"visibility",
"changes"
] | 2493420f527fbc829a8d5bdda402e05d64a20db7 | https://github.com/ezsystems/ezpublish-legacy/blob/2493420f527fbc829a8d5bdda402e05d64a20db7/kernel/classes/ezsearch.php#L542-L552 | train |
ezsystems/ezpublish-legacy | kernel/classes/ezsearch.php | eZSearch.addNodeAssignment | public static function addNodeAssignment( $mainNodeID, $objectID, $nodeAssignmentIDList, $isMoved = false )
{
$searchEngine = eZSearch::getEngine();
if ( $searchEngine instanceof ezpSearchEngine && method_exists( $searchEngine, 'addNodeAssignment' ) )
{
return $searchEngine->addNodeAssignment( $mainNodeID, $objectID, $nodeAssignmentIDList, $isMoved );
}
return false;
} | php | public static function addNodeAssignment( $mainNodeID, $objectID, $nodeAssignmentIDList, $isMoved = false )
{
$searchEngine = eZSearch::getEngine();
if ( $searchEngine instanceof ezpSearchEngine && method_exists( $searchEngine, 'addNodeAssignment' ) )
{
return $searchEngine->addNodeAssignment( $mainNodeID, $objectID, $nodeAssignmentIDList, $isMoved );
}
return false;
} | [
"public",
"static",
"function",
"addNodeAssignment",
"(",
"$",
"mainNodeID",
",",
"$",
"objectID",
",",
"$",
"nodeAssignmentIDList",
",",
"$",
"isMoved",
"=",
"false",
")",
"{",
"$",
"searchEngine",
"=",
"eZSearch",
"::",
"getEngine",
"(",
")",
";",
"if",
... | Notifies search engine about new node assignments added
@since 4.1
@param int $mainNodeID
@param int $objectID
@param array $nodeAssignmentIDList
@param bool $isMoved true if node is being moved
@return false|mixed False in case method is undefined, otherwise return the result of the search engine call | [
"Notifies",
"search",
"engine",
"about",
"new",
"node",
"assignments",
"added"
] | 2493420f527fbc829a8d5bdda402e05d64a20db7 | https://github.com/ezsystems/ezpublish-legacy/blob/2493420f527fbc829a8d5bdda402e05d64a20db7/kernel/classes/ezsearch.php#L564-L574 | train |
ezsystems/ezpublish-legacy | kernel/classes/ezsearch.php | eZSearch.removeNodes | public static function removeNodes( array $nodeIdList )
{
$searchEngine = self::getEngine();
if ( $searchEngine instanceof ezpSearchEngine && method_exists( $searchEngine, 'removeNodes' ) )
{
return $searchEngine->removeNodes( $nodeIdList );
}
return false;
} | php | public static function removeNodes( array $nodeIdList )
{
$searchEngine = self::getEngine();
if ( $searchEngine instanceof ezpSearchEngine && method_exists( $searchEngine, 'removeNodes' ) )
{
return $searchEngine->removeNodes( $nodeIdList );
}
return false;
} | [
"public",
"static",
"function",
"removeNodes",
"(",
"array",
"$",
"nodeIdList",
")",
"{",
"$",
"searchEngine",
"=",
"self",
"::",
"getEngine",
"(",
")",
";",
"if",
"(",
"$",
"searchEngine",
"instanceof",
"ezpSearchEngine",
"&&",
"method_exists",
"(",
"$",
"s... | Notifies search engine about nodes being removed
@since 4.1
@param array $nodeIdList Array of node ID to remove.
@return false|mixed False in case method is undefined, otherwise return the result of the search engine call | [
"Notifies",
"search",
"engine",
"about",
"nodes",
"being",
"removed"
] | 2493420f527fbc829a8d5bdda402e05d64a20db7 | https://github.com/ezsystems/ezpublish-legacy/blob/2493420f527fbc829a8d5bdda402e05d64a20db7/kernel/classes/ezsearch.php#L605-L615 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.