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 | kernel/private/classes/ezpmobiledevicedetectfilter.php | ezpMobileDeviceDetectFilter.getFilter | public static function getFilter()
{
$mobileDeviceFilterClass = eZINI::instance()->variable( 'SiteAccessSettings', 'MobileDeviceFilterClass' );
$mobileDeviceDetectFilter = class_exists( $mobileDeviceFilterClass) ? new $mobileDeviceFilterClass : null;
if ( $mobileDeviceDetectFilter instanceof ezpMobileDeviceDetectFilterInterface )
return $mobileDeviceDetectFilter;
return null;
} | php | public static function getFilter()
{
$mobileDeviceFilterClass = eZINI::instance()->variable( 'SiteAccessSettings', 'MobileDeviceFilterClass' );
$mobileDeviceDetectFilter = class_exists( $mobileDeviceFilterClass) ? new $mobileDeviceFilterClass : null;
if ( $mobileDeviceDetectFilter instanceof ezpMobileDeviceDetectFilterInterface )
return $mobileDeviceDetectFilter;
return null;
} | [
"public",
"static",
"function",
"getFilter",
"(",
")",
"{",
"$",
"mobileDeviceFilterClass",
"=",
"eZINI",
"::",
"instance",
"(",
")",
"->",
"variable",
"(",
"'SiteAccessSettings'",
",",
"'MobileDeviceFilterClass'",
")",
";",
"$",
"mobileDeviceDetectFilter",
"=",
"... | Returns an instance of the ezpMobileDeviceDetectFilterInterface class
@static
@return ezpMobileDeviceDetectFilterInterface|null | [
"Returns",
"an",
"instance",
"of",
"the",
"ezpMobileDeviceDetectFilterInterface",
"class"
] | 2493420f527fbc829a8d5bdda402e05d64a20db7 | https://github.com/ezsystems/ezpublish-legacy/blob/2493420f527fbc829a8d5bdda402e05d64a20db7/kernel/private/classes/ezpmobiledevicedetectfilter.php#L19-L29 | train |
ezsystems/ezpublish-legacy | kernel/classes/ezproductcollectionitemoption.php | eZProductCollectionItemOption.create | static function create( $productCollectionItemID, $optionItemID, $optionName, $optionValue, $optionPrice, $attributeID )
{
$row = array( 'item_id' => $productCollectionItemID,
'option_item_id' => $optionItemID,
'name' => $optionName,
'value' => $optionValue,
'price' => $optionPrice,
'object_attribute_id' => $attributeID );
return new eZProductCollectionItemOption( $row );
} | php | static function create( $productCollectionItemID, $optionItemID, $optionName, $optionValue, $optionPrice, $attributeID )
{
$row = array( 'item_id' => $productCollectionItemID,
'option_item_id' => $optionItemID,
'name' => $optionName,
'value' => $optionValue,
'price' => $optionPrice,
'object_attribute_id' => $attributeID );
return new eZProductCollectionItemOption( $row );
} | [
"static",
"function",
"create",
"(",
"$",
"productCollectionItemID",
",",
"$",
"optionItemID",
",",
"$",
"optionName",
",",
"$",
"optionValue",
",",
"$",
"optionPrice",
",",
"$",
"attributeID",
")",
"{",
"$",
"row",
"=",
"array",
"(",
"'item_id'",
"=>",
"$... | Creates an eZProductCollectionItem
@param int $productCollectionItemID
@param int $optionItemID
@param string $optionName
@param string $optionValue
@param string $optionPrice
@param int $attributeID | [
"Creates",
"an",
"eZProductCollectionItem"
] | 2493420f527fbc829a8d5bdda402e05d64a20db7 | https://github.com/ezsystems/ezpublish-legacy/blob/2493420f527fbc829a8d5bdda402e05d64a20db7/kernel/classes/ezproductcollectionitemoption.php#L68-L77 | train |
ezsystems/ezpublish-legacy | kernel/classes/ezproductcollectionitemoption.php | eZProductCollectionItemOption.fetchList | static function fetchList( $productCollectionItemID, $asObject = true )
{
return eZPersistentObject::fetchObjectList( eZProductCollectionItemOption::definition(),
null, array( "item_id" => $productCollectionItemID ),
array( "id" => "ASC" ),
null,
$asObject );
} | php | static function fetchList( $productCollectionItemID, $asObject = true )
{
return eZPersistentObject::fetchObjectList( eZProductCollectionItemOption::definition(),
null, array( "item_id" => $productCollectionItemID ),
array( "id" => "ASC" ),
null,
$asObject );
} | [
"static",
"function",
"fetchList",
"(",
"$",
"productCollectionItemID",
",",
"$",
"asObject",
"=",
"true",
")",
"{",
"return",
"eZPersistentObject",
"::",
"fetchObjectList",
"(",
"eZProductCollectionItemOption",
"::",
"definition",
"(",
")",
",",
"null",
",",
"arr... | Fetches eZProductCollectionItemOption items that match the given item ID,
sorted by ascending order of option ID
@param int $productCollectionItemID
@param bool $asObject
@return array(eZProductCollectionItemOption) | [
"Fetches",
"eZProductCollectionItemOption",
"items",
"that",
"match",
"the",
"given",
"item",
"ID",
"sorted",
"by",
"ascending",
"order",
"of",
"option",
"ID"
] | 2493420f527fbc829a8d5bdda402e05d64a20db7 | https://github.com/ezsystems/ezpublish-legacy/blob/2493420f527fbc829a8d5bdda402e05d64a20db7/kernel/classes/ezproductcollectionitemoption.php#L113-L120 | train |
ezsystems/ezpublish-legacy | kernel/classes/ezproductcollectionitemoption.php | eZProductCollectionItemOption.cleanupList | static function cleanupList( $itemIDList )
{
$db = eZDB::instance();
$inText = $db->generateSQLINStatement( $itemIDList, 'item_id', false, false, 'int' );
$db->query( $q = "DELETE FROM ezproductcollection_item_opt WHERE $inText" );
} | php | static function cleanupList( $itemIDList )
{
$db = eZDB::instance();
$inText = $db->generateSQLINStatement( $itemIDList, 'item_id', false, false, 'int' );
$db->query( $q = "DELETE FROM ezproductcollection_item_opt WHERE $inText" );
} | [
"static",
"function",
"cleanupList",
"(",
"$",
"itemIDList",
")",
"{",
"$",
"db",
"=",
"eZDB",
"::",
"instance",
"(",
")",
";",
"$",
"inText",
"=",
"$",
"db",
"->",
"generateSQLINStatement",
"(",
"$",
"itemIDList",
",",
"'item_id'",
",",
"false",
",",
... | Removes all product collections options which are related to the
collection items specified in the parameter array
@param array $itemIDList Array of eZProductCollectionItem IDs
@return void | [
"Removes",
"all",
"product",
"collections",
"options",
"which",
"are",
"related",
"to",
"the",
"collection",
"items",
"specified",
"in",
"the",
"parameter",
"array"
] | 2493420f527fbc829a8d5bdda402e05d64a20db7 | https://github.com/ezsystems/ezpublish-legacy/blob/2493420f527fbc829a8d5bdda402e05d64a20db7/kernel/classes/ezproductcollectionitemoption.php#L130-L135 | train |
ezsystems/ezpublish-legacy | kernel/private/classes/ezpmobiledeviceregexpfilter.php | ezpMobileDeviceRegexpFilter.redirect | public function redirect()
{
$http = eZHTTPTool::instance();
$currentSiteAccess = eZSiteAccess::current();
if ( $http->hasGetVariable( 'notmobile' ) )
{
setcookie( 'eZMobileDeviceDetect', 1, time() + (int)eZINI::instance()->variable( 'SiteAccessSettings', 'MobileDeviceDetectCookieTimeout' ), '/' );
$http->redirect( eZSys::indexDir() );
eZExecution::cleanExit();
}
if ( !isset( $_COOKIE['eZMobileDeviceDetect'] )
&& !in_array( $currentSiteAccess['name'], eZINI::instance()->variable( 'SiteAccessSettings', 'MobileSiteAccessList' ) ) )
{
$currentUrl = eZSys::serverURL() . eZSys::requestURI();
$redirectUrl = eZINI::instance()->variable( 'SiteAccessSettings', 'MobileSiteAccessURL' );
// Do not redirect if already on the redirect url
if ( strpos( $currentUrl, $redirectUrl ) !== 0 )
{
// Default siteaccess name needs to be removed from the uri when redirecting
$uri = explode( '/', ltrim( eZSys::requestURI(), '/' ) );
if ( array_shift( $uri ) == $currentSiteAccess['name'] )
{
$http->redirect( $redirectUrl . '/' . implode( '/', $uri ) . eZSys::queryString() );
}
else
{
$http->redirect( $redirectUrl . eZSys::requestURI() . eZSys::queryString() );
}
}
eZExecution::cleanExit();
}
} | php | public function redirect()
{
$http = eZHTTPTool::instance();
$currentSiteAccess = eZSiteAccess::current();
if ( $http->hasGetVariable( 'notmobile' ) )
{
setcookie( 'eZMobileDeviceDetect', 1, time() + (int)eZINI::instance()->variable( 'SiteAccessSettings', 'MobileDeviceDetectCookieTimeout' ), '/' );
$http->redirect( eZSys::indexDir() );
eZExecution::cleanExit();
}
if ( !isset( $_COOKIE['eZMobileDeviceDetect'] )
&& !in_array( $currentSiteAccess['name'], eZINI::instance()->variable( 'SiteAccessSettings', 'MobileSiteAccessList' ) ) )
{
$currentUrl = eZSys::serverURL() . eZSys::requestURI();
$redirectUrl = eZINI::instance()->variable( 'SiteAccessSettings', 'MobileSiteAccessURL' );
// Do not redirect if already on the redirect url
if ( strpos( $currentUrl, $redirectUrl ) !== 0 )
{
// Default siteaccess name needs to be removed from the uri when redirecting
$uri = explode( '/', ltrim( eZSys::requestURI(), '/' ) );
if ( array_shift( $uri ) == $currentSiteAccess['name'] )
{
$http->redirect( $redirectUrl . '/' . implode( '/', $uri ) . eZSys::queryString() );
}
else
{
$http->redirect( $redirectUrl . eZSys::requestURI() . eZSys::queryString() );
}
}
eZExecution::cleanExit();
}
} | [
"public",
"function",
"redirect",
"(",
")",
"{",
"$",
"http",
"=",
"eZHTTPTool",
"::",
"instance",
"(",
")",
";",
"$",
"currentSiteAccess",
"=",
"eZSiteAccess",
"::",
"current",
"(",
")",
";",
"if",
"(",
"$",
"http",
"->",
"hasGetVariable",
"(",
"'notmob... | Handles redirection to the mobile optimized interface | [
"Handles",
"redirection",
"to",
"the",
"mobile",
"optimized",
"interface"
] | 2493420f527fbc829a8d5bdda402e05d64a20db7 | https://github.com/ezsystems/ezpublish-legacy/blob/2493420f527fbc829a8d5bdda402e05d64a20db7/kernel/private/classes/ezpmobiledeviceregexpfilter.php#L104-L142 | train |
ezsystems/ezpublish-legacy | kernel/private/api/content/content.php | ezpContent.fromNode | public static function fromNode( eZContentObjectTreeNode $node, $checkAccess = true )
{
$object = $node->object();
if ( $checkAccess && !$object->attribute( 'can_read' ) )
{
throw new ezpContentAccessDeniedException( $object->attribute( 'id' ) );
}
$content = new ezpContent();
$content->fields = ezpContentFieldSet::fromContentObject( $object );
$content->object = $object;
$content->locations = ezpContentLocation::fromNode( $node );
return $content;
} | php | public static function fromNode( eZContentObjectTreeNode $node, $checkAccess = true )
{
$object = $node->object();
if ( $checkAccess && !$object->attribute( 'can_read' ) )
{
throw new ezpContentAccessDeniedException( $object->attribute( 'id' ) );
}
$content = new ezpContent();
$content->fields = ezpContentFieldSet::fromContentObject( $object );
$content->object = $object;
$content->locations = ezpContentLocation::fromNode( $node );
return $content;
} | [
"public",
"static",
"function",
"fromNode",
"(",
"eZContentObjectTreeNode",
"$",
"node",
",",
"$",
"checkAccess",
"=",
"true",
")",
"{",
"$",
"object",
"=",
"$",
"node",
"->",
"object",
"(",
")",
";",
"if",
"(",
"$",
"checkAccess",
"&&",
"!",
"$",
"obj... | Instanciates an ezpContent from an eZContentObjectTreeNode
@param eZContentObjectTreeNode $node
@return ezpContent | [
"Instanciates",
"an",
"ezpContent",
"from",
"an",
"eZContentObjectTreeNode"
] | 2493420f527fbc829a8d5bdda402e05d64a20db7 | https://github.com/ezsystems/ezpublish-legacy/blob/2493420f527fbc829a8d5bdda402e05d64a20db7/kernel/private/api/content/content.php#L72-L86 | train |
ezsystems/ezpublish-legacy | kernel/private/api/content/content.php | ezpContent.fromNodeId | public static function fromNodeId( $nodeId, $checkAccess = true )
{
$node = eZContentObjectTreeNode::fetch( $nodeId );
if ( $node instanceof eZContentObjectTreeNode )
return self::fromNode( $node, $checkAccess );
else
throw new ezpContentNotFoundException( "Unable to find node with ID $nodeId" );
} | php | public static function fromNodeId( $nodeId, $checkAccess = true )
{
$node = eZContentObjectTreeNode::fetch( $nodeId );
if ( $node instanceof eZContentObjectTreeNode )
return self::fromNode( $node, $checkAccess );
else
throw new ezpContentNotFoundException( "Unable to find node with ID $nodeId" );
} | [
"public",
"static",
"function",
"fromNodeId",
"(",
"$",
"nodeId",
",",
"$",
"checkAccess",
"=",
"true",
")",
"{",
"$",
"node",
"=",
"eZContentObjectTreeNode",
"::",
"fetch",
"(",
"$",
"nodeId",
")",
";",
"if",
"(",
"$",
"node",
"instanceof",
"eZContentObje... | Instanciates an ezpContent from an eZContentObjectTreenode Id
@param int $nodeId
@return ezpContent | [
"Instanciates",
"an",
"ezpContent",
"from",
"an",
"eZContentObjectTreenode",
"Id"
] | 2493420f527fbc829a8d5bdda402e05d64a20db7 | https://github.com/ezsystems/ezpublish-legacy/blob/2493420f527fbc829a8d5bdda402e05d64a20db7/kernel/private/api/content/content.php#L93-L100 | train |
ezsystems/ezpublish-legacy | kernel/private/api/content/content.php | ezpContent.fromObjectId | public static function fromObjectId( $objectId, $checkAccess = true )
{
$object = eZContentObject::fetch( $objectId );
if ( $object instanceof eZContentObject )
return self::fromObject( $object, $checkAccess );
else
throw new ezpContentNotFoundException( "Unable to find an eZContentObject with ID $objectId" );
} | php | public static function fromObjectId( $objectId, $checkAccess = true )
{
$object = eZContentObject::fetch( $objectId );
if ( $object instanceof eZContentObject )
return self::fromObject( $object, $checkAccess );
else
throw new ezpContentNotFoundException( "Unable to find an eZContentObject with ID $objectId" );
} | [
"public",
"static",
"function",
"fromObjectId",
"(",
"$",
"objectId",
",",
"$",
"checkAccess",
"=",
"true",
")",
"{",
"$",
"object",
"=",
"eZContentObject",
"::",
"fetch",
"(",
"$",
"objectId",
")",
";",
"if",
"(",
"$",
"object",
"instanceof",
"eZContentOb... | Instanciates an ezpContent from an eZContentObject Id
@param int $objectId
@return ezpContent | [
"Instanciates",
"an",
"ezpContent",
"from",
"an",
"eZContentObject",
"Id"
] | 2493420f527fbc829a8d5bdda402e05d64a20db7 | https://github.com/ezsystems/ezpublish-legacy/blob/2493420f527fbc829a8d5bdda402e05d64a20db7/kernel/private/api/content/content.php#L107-L114 | train |
ezsystems/ezpublish-legacy | kernel/private/api/content/content.php | ezpContent.fromObject | public static function fromObject( eZContentObject $object, $checkAccess = true )
{
if ( $checkAccess && !$object->attribute( 'can_read' ) )
{
throw new ezpContentAccessDeniedException( $object->attribute( 'id' ) );
}
$content = new ezpContent();
$content->fields = ezpContentFieldSet::fromContentObject( $object );
$content->object = $object;
return $content;
} | php | public static function fromObject( eZContentObject $object, $checkAccess = true )
{
if ( $checkAccess && !$object->attribute( 'can_read' ) )
{
throw new ezpContentAccessDeniedException( $object->attribute( 'id' ) );
}
$content = new ezpContent();
$content->fields = ezpContentFieldSet::fromContentObject( $object );
$content->object = $object;
return $content;
} | [
"public",
"static",
"function",
"fromObject",
"(",
"eZContentObject",
"$",
"object",
",",
"$",
"checkAccess",
"=",
"true",
")",
"{",
"if",
"(",
"$",
"checkAccess",
"&&",
"!",
"$",
"object",
"->",
"attribute",
"(",
"'can_read'",
")",
")",
"{",
"throw",
"n... | Instanciates an ezpContent from an eZContentObject
@param eZContentObject $objectId
@return ezpContent | [
"Instanciates",
"an",
"ezpContent",
"from",
"an",
"eZContentObject"
] | 2493420f527fbc829a8d5bdda402e05d64a20db7 | https://github.com/ezsystems/ezpublish-legacy/blob/2493420f527fbc829a8d5bdda402e05d64a20db7/kernel/private/api/content/content.php#L121-L134 | train |
ezsystems/ezpublish-legacy | kernel/private/rest/classes/dispatcher.php | ezpMvcConfigurableDispatcher.run | public function run()
{
// initialize infinite loop counter
$redirects = 0;
// create the request
$requestParser = $this->getRequestParser();
$request = $requestParser->createRequest();
// start of the request loop
do
{
// do the infinite loop check
$this->checkRedirectLimit( $redirects );
$continue = false;
// run pre-routing filters
$this->configuration->runPreRoutingFilters( $request );
// create the router from the configuration
$router = $this->getRouter( $request );
// router creates routing information
try
{
$routingInformation = $router->getRoutingInformation();
}
catch ( ezcMvcRouteNotFoundException $e )
{
$request = $this->getFatalRedirectRequest( $request, new ezcMvcResult, $e );
$continue = true;
continue;
}
// here's the reason to override ezcMvcConfigurableDispatcher::run()
catch ( ezpRouteMethodNotAllowedException $e )
{
$request = $this->getFatalRedirectRequest( $request, new ezcMvcResult, $e );
$continue = true;
continue;
}
// end diff
// run request filters
$filterResult = $this->configuration->runRequestFilters( $routingInformation, $request );
if ( $filterResult instanceof ezcMvcInternalRedirect )
{
$request = $filterResult->request;
$continue = true;
continue;
}
// create the controller
$controller = $this->getController( $routingInformation, $request );
// run the controller
try
{
$result = $controller->createResult();
}
catch ( Exception $e )
{
$request = $this->getFatalRedirectRequest( $request, new ezcMvcResult, $e );
$continue = true;
continue;
}
if ( $result instanceof ezcMvcInternalRedirect )
{
$request = $result->request;
$continue = true;
continue;
}
if ( !$result instanceof ezcMvcResult )
{
throw new ezcMvcControllerException( "The action '{$routingInformation->action}' of controller '{$routingInformation->controllerClass}' did not return an ezcMvcResult object." );
}
$this->configuration->runResultFilters( $routingInformation, $request, $result );
if ( $result->status !== 0 )
{
$response = new ezcMvcResponse;
$response->status = $result->status;
}
else
{
// want the view manager to use my filters
$view = $this->getView( $routingInformation, $request, $result );
// create the response
try
{
$response = $view->createResponse();
}
catch ( Exception $e )
{
$request = $this->getFatalRedirectRequest( $request, $result, $e );
$continue = true;
continue;
}
}
$this->configuration->runResponseFilters( $routingInformation, $request, $result, $response );
// create the response writer
$responseWriter = $this->getResponseWriter( $routingInformation, $request, $result, $response );
// handle the response
$responseWriter->handleResponse();
}
while ( $continue );
} | php | public function run()
{
// initialize infinite loop counter
$redirects = 0;
// create the request
$requestParser = $this->getRequestParser();
$request = $requestParser->createRequest();
// start of the request loop
do
{
// do the infinite loop check
$this->checkRedirectLimit( $redirects );
$continue = false;
// run pre-routing filters
$this->configuration->runPreRoutingFilters( $request );
// create the router from the configuration
$router = $this->getRouter( $request );
// router creates routing information
try
{
$routingInformation = $router->getRoutingInformation();
}
catch ( ezcMvcRouteNotFoundException $e )
{
$request = $this->getFatalRedirectRequest( $request, new ezcMvcResult, $e );
$continue = true;
continue;
}
// here's the reason to override ezcMvcConfigurableDispatcher::run()
catch ( ezpRouteMethodNotAllowedException $e )
{
$request = $this->getFatalRedirectRequest( $request, new ezcMvcResult, $e );
$continue = true;
continue;
}
// end diff
// run request filters
$filterResult = $this->configuration->runRequestFilters( $routingInformation, $request );
if ( $filterResult instanceof ezcMvcInternalRedirect )
{
$request = $filterResult->request;
$continue = true;
continue;
}
// create the controller
$controller = $this->getController( $routingInformation, $request );
// run the controller
try
{
$result = $controller->createResult();
}
catch ( Exception $e )
{
$request = $this->getFatalRedirectRequest( $request, new ezcMvcResult, $e );
$continue = true;
continue;
}
if ( $result instanceof ezcMvcInternalRedirect )
{
$request = $result->request;
$continue = true;
continue;
}
if ( !$result instanceof ezcMvcResult )
{
throw new ezcMvcControllerException( "The action '{$routingInformation->action}' of controller '{$routingInformation->controllerClass}' did not return an ezcMvcResult object." );
}
$this->configuration->runResultFilters( $routingInformation, $request, $result );
if ( $result->status !== 0 )
{
$response = new ezcMvcResponse;
$response->status = $result->status;
}
else
{
// want the view manager to use my filters
$view = $this->getView( $routingInformation, $request, $result );
// create the response
try
{
$response = $view->createResponse();
}
catch ( Exception $e )
{
$request = $this->getFatalRedirectRequest( $request, $result, $e );
$continue = true;
continue;
}
}
$this->configuration->runResponseFilters( $routingInformation, $request, $result, $response );
// create the response writer
$responseWriter = $this->getResponseWriter( $routingInformation, $request, $result, $response );
// handle the response
$responseWriter->handleResponse();
}
while ( $continue );
} | [
"public",
"function",
"run",
"(",
")",
"{",
"// initialize infinite loop counter",
"$",
"redirects",
"=",
"0",
";",
"// create the request",
"$",
"requestParser",
"=",
"$",
"this",
"->",
"getRequestParser",
"(",
")",
";",
"$",
"request",
"=",
"$",
"requestParser... | Runs through the request, by using the configuration to obtain correct handlers.
Override ezcMvcConfigurableDispatcher::run() to handle
ezpRouteMethodNotAllowedException exception thrown when a route was
found but an unexpected method is used. | [
"Runs",
"through",
"the",
"request",
"by",
"using",
"the",
"configuration",
"to",
"obtain",
"correct",
"handlers",
"."
] | 2493420f527fbc829a8d5bdda402e05d64a20db7 | https://github.com/ezsystems/ezpublish-legacy/blob/2493420f527fbc829a8d5bdda402e05d64a20db7/kernel/private/rest/classes/dispatcher.php#L21-L133 | train |
ezsystems/ezpublish-legacy | kernel/content/ezcontentoperationcollection.php | eZContentOperationCollection.resetNodeassignmentOpcodes | static public function resetNodeassignmentOpcodes( $objectID, $versionNum )
{
$object = eZContentObject::fetch( $objectID );
$version = $object->version( $versionNum );
$nodeAssignments = $version->attribute( 'node_assignments' );
foreach ( $nodeAssignments as $nodeAssignment )
{
if ( ( $nodeAssignment->attribute( 'op_code' ) & 1 ) == eZNodeAssignment::OP_CODE_EXECUTE )
{
$nodeAssignment->setAttribute( 'op_code', ( $nodeAssignment->attribute( 'op_code' ) & ~1 ) );
$nodeAssignment->store();
}
}
} | php | static public function resetNodeassignmentOpcodes( $objectID, $versionNum )
{
$object = eZContentObject::fetch( $objectID );
$version = $object->version( $versionNum );
$nodeAssignments = $version->attribute( 'node_assignments' );
foreach ( $nodeAssignments as $nodeAssignment )
{
if ( ( $nodeAssignment->attribute( 'op_code' ) & 1 ) == eZNodeAssignment::OP_CODE_EXECUTE )
{
$nodeAssignment->setAttribute( 'op_code', ( $nodeAssignment->attribute( 'op_code' ) & ~1 ) );
$nodeAssignment->store();
}
}
} | [
"static",
"public",
"function",
"resetNodeassignmentOpcodes",
"(",
"$",
"objectID",
",",
"$",
"versionNum",
")",
"{",
"$",
"object",
"=",
"eZContentObject",
"::",
"fetch",
"(",
"$",
"objectID",
")",
";",
"$",
"version",
"=",
"$",
"object",
"->",
"version",
... | New function which resets the op_code field when the object is published. | [
"New",
"function",
"which",
"resets",
"the",
"op_code",
"field",
"when",
"the",
"object",
"is",
"published",
"."
] | 2493420f527fbc829a8d5bdda402e05d64a20db7 | https://github.com/ezsystems/ezpublish-legacy/blob/2493420f527fbc829a8d5bdda402e05d64a20db7/kernel/content/ezcontentoperationcollection.php#L560-L573 | train |
ezsystems/ezpublish-legacy | kernel/content/ezcontentoperationcollection.php | eZContentOperationCollection.registerSearchObject | static public function registerSearchObject( $objectID, $version = null, $isMoved = false )
{
$objectID = (int)$objectID;
eZDebug::createAccumulatorGroup( 'search_total', 'Search Total' );
$ini = eZINI::instance( 'site.ini' );
$insertPendingAction = false;
$object = null;
switch ( $ini->variable( 'SearchSettings', 'DelayedIndexing' ) )
{
case 'enabled':
$insertPendingAction = true;
break;
case 'classbased':
$classList = $ini->variable( 'SearchSettings', 'DelayedIndexingClassList' );
$object = eZContentObject::fetch( $objectID );
if ( is_array( $classList ) && in_array( $object->attribute( 'class_identifier' ), $classList ) )
{
$insertPendingAction = true;
}
}
if ( $insertPendingAction )
{
$action = $isMoved ? 'index_moved_node' : 'index_object';
eZDB::instance()->query( "INSERT INTO ezpending_actions( action, param ) VALUES ( '$action', '$objectID' )" );
return;
}
if ( $object === null )
$object = eZContentObject::fetch( $objectID );
// Register the object in the search engine.
$needCommit = eZSearch::needCommit();
if ( eZSearch::needRemoveWithUpdate() )
{
eZDebug::accumulatorStart( 'remove_object', 'search_total', 'remove object' );
eZSearch::removeObjectById( $objectID );
eZDebug::accumulatorStop( 'remove_object' );
}
eZDebug::accumulatorStart( 'add_object', 'search_total', 'add object' );
if ( !eZSearch::addObject( $object, $needCommit ) )
{
eZDebug::writeError( "Failed adding object ID {$object->attribute( 'id' )} in the search engine", __METHOD__ );
}
eZDebug::accumulatorStop( 'add_object' );
} | php | static public function registerSearchObject( $objectID, $version = null, $isMoved = false )
{
$objectID = (int)$objectID;
eZDebug::createAccumulatorGroup( 'search_total', 'Search Total' );
$ini = eZINI::instance( 'site.ini' );
$insertPendingAction = false;
$object = null;
switch ( $ini->variable( 'SearchSettings', 'DelayedIndexing' ) )
{
case 'enabled':
$insertPendingAction = true;
break;
case 'classbased':
$classList = $ini->variable( 'SearchSettings', 'DelayedIndexingClassList' );
$object = eZContentObject::fetch( $objectID );
if ( is_array( $classList ) && in_array( $object->attribute( 'class_identifier' ), $classList ) )
{
$insertPendingAction = true;
}
}
if ( $insertPendingAction )
{
$action = $isMoved ? 'index_moved_node' : 'index_object';
eZDB::instance()->query( "INSERT INTO ezpending_actions( action, param ) VALUES ( '$action', '$objectID' )" );
return;
}
if ( $object === null )
$object = eZContentObject::fetch( $objectID );
// Register the object in the search engine.
$needCommit = eZSearch::needCommit();
if ( eZSearch::needRemoveWithUpdate() )
{
eZDebug::accumulatorStart( 'remove_object', 'search_total', 'remove object' );
eZSearch::removeObjectById( $objectID );
eZDebug::accumulatorStop( 'remove_object' );
}
eZDebug::accumulatorStart( 'add_object', 'search_total', 'add object' );
if ( !eZSearch::addObject( $object, $needCommit ) )
{
eZDebug::writeError( "Failed adding object ID {$object->attribute( 'id' )} in the search engine", __METHOD__ );
}
eZDebug::accumulatorStop( 'add_object' );
} | [
"static",
"public",
"function",
"registerSearchObject",
"(",
"$",
"objectID",
",",
"$",
"version",
"=",
"null",
",",
"$",
"isMoved",
"=",
"false",
")",
"{",
"$",
"objectID",
"=",
"(",
"int",
")",
"$",
"objectID",
";",
"eZDebug",
"::",
"createAccumulatorGro... | Registers the object in search engine.
@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 $objectID Id of the object.
@param int $version Operation collection passes this default param. Not used in the method
@param bool $isMoved true if node is being moved | [
"Registers",
"the",
"object",
"in",
"search",
"engine",
"."
] | 2493420f527fbc829a8d5bdda402e05d64a20db7 | https://github.com/ezsystems/ezpublish-legacy/blob/2493420f527fbc829a8d5bdda402e05d64a20db7/kernel/content/ezcontentoperationcollection.php#L585-L634 | train |
ezsystems/ezpublish-legacy | kernel/content/ezcontentoperationcollection.php | eZContentOperationCollection.moveNode | static public function moveNode( $nodeID, $objectID, $newParentNodeID )
{
if( !eZContentObjectTreeNodeOperations::move( $nodeID, $newParentNodeID ) )
{
eZDebug::writeError( "Failed to move node $nodeID as child of parent node $newParentNodeID",
__METHOD__ );
return array( 'status' => false );
}
eZContentObject::fixReverseRelations( $objectID, 'move' );
if ( !eZSearch::getEngine() instanceof eZSearchEngine )
{
eZContentOperationCollection::registerSearchObject( $objectID );
}
return array( 'status' => true );
} | php | static public function moveNode( $nodeID, $objectID, $newParentNodeID )
{
if( !eZContentObjectTreeNodeOperations::move( $nodeID, $newParentNodeID ) )
{
eZDebug::writeError( "Failed to move node $nodeID as child of parent node $newParentNodeID",
__METHOD__ );
return array( 'status' => false );
}
eZContentObject::fixReverseRelations( $objectID, 'move' );
if ( !eZSearch::getEngine() instanceof eZSearchEngine )
{
eZContentOperationCollection::registerSearchObject( $objectID );
}
return array( 'status' => true );
} | [
"static",
"public",
"function",
"moveNode",
"(",
"$",
"nodeID",
",",
"$",
"objectID",
",",
"$",
"newParentNodeID",
")",
"{",
"if",
"(",
"!",
"eZContentObjectTreeNodeOperations",
"::",
"move",
"(",
"$",
"nodeID",
",",
"$",
"newParentNodeID",
")",
")",
"{",
... | Moves a node
@param int $nodeID
@param int $objectID
@param int $newParentNodeID
@return array An array with operation status, always true | [
"Moves",
"a",
"node"
] | 2493420f527fbc829a8d5bdda402e05d64a20db7 | https://github.com/ezsystems/ezpublish-legacy/blob/2493420f527fbc829a8d5bdda402e05d64a20db7/kernel/content/ezcontentoperationcollection.php#L741-L759 | train |
ezsystems/ezpublish-legacy | kernel/content/ezcontentoperationcollection.php | eZContentOperationCollection.addAssignment | static public function addAssignment( $nodeID, $objectID, $selectedNodeIDArray )
{
$userClassIDArray = eZUser::contentClassIDs();
$object = eZContentObject::fetch( $objectID );
$class = $object->contentClass();
$nodeAssignmentList = eZNodeAssignment::fetchForObject( $objectID, $object->attribute( 'current_version' ), 0, false );
$assignedNodes = $object->assignedNodes();
$parentNodeIDArray = array();
foreach ( $assignedNodes as $assignedNode )
{
$append = false;
foreach ( $nodeAssignmentList as $nodeAssignment )
{
if ( $nodeAssignment['parent_node'] == $assignedNode->attribute( 'parent_node_id' ) )
{
$append = true;
break;
}
}
if ( $append )
{
$parentNodeIDArray[] = $assignedNode->attribute( 'parent_node_id' );
}
}
$db = eZDB::instance();
$db->begin();
$locationAdded = false;
$node = eZContentObjectTreeNode::fetch( $nodeID );
foreach ( $selectedNodeIDArray as $selectedNodeID )
{
if ( !in_array( $selectedNodeID, $parentNodeIDArray ) )
{
$parentNode = eZContentObjectTreeNode::fetch( $selectedNodeID );
$parentNodeObject = $parentNode->attribute( 'object' );
$canCreate = ( ( $parentNode->checkAccess( 'create', $class->attribute( 'id' ), $parentNodeObject->attribute( 'contentclass_id' ) ) == 1 ) ||
( $parentNode->canAddLocation() && $node->canRead() ) );
if ( $canCreate )
{
$insertedNode = $object->addLocation( $selectedNodeID, true );
// Now set is as published and fix main_node_id
$insertedNode->setAttribute( 'contentobject_is_published', 1 );
$insertedNode->setAttribute( 'main_node_id', $node->attribute( 'main_node_id' ) );
$insertedNode->setAttribute( 'contentobject_version', $node->attribute( 'contentobject_version' ) );
// Make sure the url alias is set updated.
$insertedNode->updateSubTreePath();
$insertedNode->sync();
$locationAdded = true;
}
}
}
if ( $locationAdded )
{
//call appropriate method from search engine
eZSearch::addNodeAssignment( $nodeID, $objectID, $selectedNodeIDArray );
// clear user policy cache if this was a user object
if ( in_array( $object->attribute( 'contentclass_id' ), $userClassIDArray ) )
{
eZUser::purgeUserCacheByUserId( $object->attribute( 'id' ) );
}
}
$db->commit();
eZContentCacheManager::clearContentCacheIfNeeded( $objectID );
if ( !eZSearch::getEngine() instanceof eZSearchEngine )
{
eZContentOperationCollection::registerSearchObject( $objectID );
}
return array( 'status' => true );
} | php | static public function addAssignment( $nodeID, $objectID, $selectedNodeIDArray )
{
$userClassIDArray = eZUser::contentClassIDs();
$object = eZContentObject::fetch( $objectID );
$class = $object->contentClass();
$nodeAssignmentList = eZNodeAssignment::fetchForObject( $objectID, $object->attribute( 'current_version' ), 0, false );
$assignedNodes = $object->assignedNodes();
$parentNodeIDArray = array();
foreach ( $assignedNodes as $assignedNode )
{
$append = false;
foreach ( $nodeAssignmentList as $nodeAssignment )
{
if ( $nodeAssignment['parent_node'] == $assignedNode->attribute( 'parent_node_id' ) )
{
$append = true;
break;
}
}
if ( $append )
{
$parentNodeIDArray[] = $assignedNode->attribute( 'parent_node_id' );
}
}
$db = eZDB::instance();
$db->begin();
$locationAdded = false;
$node = eZContentObjectTreeNode::fetch( $nodeID );
foreach ( $selectedNodeIDArray as $selectedNodeID )
{
if ( !in_array( $selectedNodeID, $parentNodeIDArray ) )
{
$parentNode = eZContentObjectTreeNode::fetch( $selectedNodeID );
$parentNodeObject = $parentNode->attribute( 'object' );
$canCreate = ( ( $parentNode->checkAccess( 'create', $class->attribute( 'id' ), $parentNodeObject->attribute( 'contentclass_id' ) ) == 1 ) ||
( $parentNode->canAddLocation() && $node->canRead() ) );
if ( $canCreate )
{
$insertedNode = $object->addLocation( $selectedNodeID, true );
// Now set is as published and fix main_node_id
$insertedNode->setAttribute( 'contentobject_is_published', 1 );
$insertedNode->setAttribute( 'main_node_id', $node->attribute( 'main_node_id' ) );
$insertedNode->setAttribute( 'contentobject_version', $node->attribute( 'contentobject_version' ) );
// Make sure the url alias is set updated.
$insertedNode->updateSubTreePath();
$insertedNode->sync();
$locationAdded = true;
}
}
}
if ( $locationAdded )
{
//call appropriate method from search engine
eZSearch::addNodeAssignment( $nodeID, $objectID, $selectedNodeIDArray );
// clear user policy cache if this was a user object
if ( in_array( $object->attribute( 'contentclass_id' ), $userClassIDArray ) )
{
eZUser::purgeUserCacheByUserId( $object->attribute( 'id' ) );
}
}
$db->commit();
eZContentCacheManager::clearContentCacheIfNeeded( $objectID );
if ( !eZSearch::getEngine() instanceof eZSearchEngine )
{
eZContentOperationCollection::registerSearchObject( $objectID );
}
return array( 'status' => true );
} | [
"static",
"public",
"function",
"addAssignment",
"(",
"$",
"nodeID",
",",
"$",
"objectID",
",",
"$",
"selectedNodeIDArray",
")",
"{",
"$",
"userClassIDArray",
"=",
"eZUser",
"::",
"contentClassIDs",
"(",
")",
";",
"$",
"object",
"=",
"eZContentObject",
"::",
... | Adds a new nodeAssignment
@param int $nodeID
@param int $objectId
@param array $selectedNodeIDArray
@return array An array with operation status, always true | [
"Adds",
"a",
"new",
"nodeAssignment"
] | 2493420f527fbc829a8d5bdda402e05d64a20db7 | https://github.com/ezsystems/ezpublish-legacy/blob/2493420f527fbc829a8d5bdda402e05d64a20db7/kernel/content/ezcontentoperationcollection.php#L770-L853 | train |
ezsystems/ezpublish-legacy | kernel/content/ezcontentoperationcollection.php | eZContentOperationCollection.deleteObject | static public function deleteObject( $deleteIDArray, $moveToTrash = false )
{
$ini = eZINI::instance();
$aNodes = eZContentObjectTreeNode::fetch( $deleteIDArray );
if( !is_array( $aNodes ) )
{
$aNodes = array( $aNodes );
}
$delayedIndexingValue = $ini->variable( 'SearchSettings', 'DelayedIndexing' );
if ( $delayedIndexingValue === 'enabled' || $delayedIndexingValue === 'classbased' )
{
$pendingActionsToDelete = array();
$classList = $ini->variable( 'SearchSettings', 'DelayedIndexingClassList' ); // Will be used below if DelayedIndexing is classbased
$assignedNodesByObject = array();
$nodesToDeleteByObject = array();
foreach ( $aNodes as $node )
{
$object = $node->object();
$objectID = $object->attribute( 'id' );
$assignedNodes = $object->attribute( 'assigned_nodes' );
// Only delete pending action if this is the last object's node that is requested for deletion
// But $deleteIDArray can also contain all the object's node (mainly if this method is called programmatically)
// So if this is not the last node, then store its id in a temp array
// This temp array will then be compared to the whole object's assigned nodes array
if ( count( $assignedNodes ) > 1 )
{
// $assignedNodesByObject will be used as a referent to check if we want to delete all lasting nodes
if ( !isset( $assignedNodesByObject[$objectID] ) )
{
$assignedNodesByObject[$objectID] = array();
foreach ( $assignedNodes as $assignedNode )
{
$assignedNodesByObject[$objectID][] = $assignedNode->attribute( 'node_id' );
}
}
// Store the node assignment we want to delete
// Then compare the array to the referent node assignment array
$nodesToDeleteByObject[$objectID][] = $node->attribute( 'node_id' );
$diff = array_diff( $assignedNodesByObject[$objectID], $nodesToDeleteByObject[$objectID] );
if ( !empty( $diff ) ) // We still have more node assignments for object, pending action is not to be deleted considering this iteration
{
continue;
}
}
if ( $delayedIndexingValue !== 'classbased' ||
( is_array( $classList ) && in_array( $object->attribute( 'class_identifier' ), $classList ) ) )
{
$pendingActionsToDelete[] = $objectID;
}
}
if ( !empty( $pendingActionsToDelete ) )
{
$filterConds = array( 'param' => array ( $pendingActionsToDelete ) );
eZPendingActions::removeByAction( 'index_object', $filterConds );
}
}
// Add assigned nodes to the clear cache list
// This allows to clear assigned nodes separately (e.g. in reverse proxies)
// as once content is removed, there is no more assigned nodes, and http cache clear is not possible any more.
// See https://jira.ez.no/browse/EZP-22447
foreach ( $aNodes as $node )
{
eZContentCacheManager::addAdditionalNodeIDPerObject( $node->attribute( 'contentobject_id' ), $node->attribute( 'node_id' ) );
}
eZContentObjectTreeNode::removeSubtrees( $deleteIDArray, $moveToTrash );
return array( 'status' => true );
} | php | static public function deleteObject( $deleteIDArray, $moveToTrash = false )
{
$ini = eZINI::instance();
$aNodes = eZContentObjectTreeNode::fetch( $deleteIDArray );
if( !is_array( $aNodes ) )
{
$aNodes = array( $aNodes );
}
$delayedIndexingValue = $ini->variable( 'SearchSettings', 'DelayedIndexing' );
if ( $delayedIndexingValue === 'enabled' || $delayedIndexingValue === 'classbased' )
{
$pendingActionsToDelete = array();
$classList = $ini->variable( 'SearchSettings', 'DelayedIndexingClassList' ); // Will be used below if DelayedIndexing is classbased
$assignedNodesByObject = array();
$nodesToDeleteByObject = array();
foreach ( $aNodes as $node )
{
$object = $node->object();
$objectID = $object->attribute( 'id' );
$assignedNodes = $object->attribute( 'assigned_nodes' );
// Only delete pending action if this is the last object's node that is requested for deletion
// But $deleteIDArray can also contain all the object's node (mainly if this method is called programmatically)
// So if this is not the last node, then store its id in a temp array
// This temp array will then be compared to the whole object's assigned nodes array
if ( count( $assignedNodes ) > 1 )
{
// $assignedNodesByObject will be used as a referent to check if we want to delete all lasting nodes
if ( !isset( $assignedNodesByObject[$objectID] ) )
{
$assignedNodesByObject[$objectID] = array();
foreach ( $assignedNodes as $assignedNode )
{
$assignedNodesByObject[$objectID][] = $assignedNode->attribute( 'node_id' );
}
}
// Store the node assignment we want to delete
// Then compare the array to the referent node assignment array
$nodesToDeleteByObject[$objectID][] = $node->attribute( 'node_id' );
$diff = array_diff( $assignedNodesByObject[$objectID], $nodesToDeleteByObject[$objectID] );
if ( !empty( $diff ) ) // We still have more node assignments for object, pending action is not to be deleted considering this iteration
{
continue;
}
}
if ( $delayedIndexingValue !== 'classbased' ||
( is_array( $classList ) && in_array( $object->attribute( 'class_identifier' ), $classList ) ) )
{
$pendingActionsToDelete[] = $objectID;
}
}
if ( !empty( $pendingActionsToDelete ) )
{
$filterConds = array( 'param' => array ( $pendingActionsToDelete ) );
eZPendingActions::removeByAction( 'index_object', $filterConds );
}
}
// Add assigned nodes to the clear cache list
// This allows to clear assigned nodes separately (e.g. in reverse proxies)
// as once content is removed, there is no more assigned nodes, and http cache clear is not possible any more.
// See https://jira.ez.no/browse/EZP-22447
foreach ( $aNodes as $node )
{
eZContentCacheManager::addAdditionalNodeIDPerObject( $node->attribute( 'contentobject_id' ), $node->attribute( 'node_id' ) );
}
eZContentObjectTreeNode::removeSubtrees( $deleteIDArray, $moveToTrash );
return array( 'status' => true );
} | [
"static",
"public",
"function",
"deleteObject",
"(",
"$",
"deleteIDArray",
",",
"$",
"moveToTrash",
"=",
"false",
")",
"{",
"$",
"ini",
"=",
"eZINI",
"::",
"instance",
"(",
")",
";",
"$",
"aNodes",
"=",
"eZContentObjectTreeNode",
"::",
"fetch",
"(",
"$",
... | Deletes a content object, or a list of content objects
@param array $deleteIDArray
@param bool $moveToTrash
@return array An array with operation status, always true | [
"Deletes",
"a",
"content",
"object",
"or",
"a",
"list",
"of",
"content",
"objects"
] | 2493420f527fbc829a8d5bdda402e05d64a20db7 | https://github.com/ezsystems/ezpublish-legacy/blob/2493420f527fbc829a8d5bdda402e05d64a20db7/kernel/content/ezcontentoperationcollection.php#L955-L1028 | train |
ezsystems/ezpublish-legacy | kernel/content/ezcontentoperationcollection.php | eZContentOperationCollection.changeHideStatus | static public function changeHideStatus( $nodeID )
{
$action = 'hide';
$curNode = eZContentObjectTreeNode::fetch( $nodeID );
if ( is_object( $curNode ) )
{
if ( $curNode->attribute( 'is_hidden' ) )
{
eZContentObjectTreeNode::unhideSubTree( $curNode );
$action = 'show';
}
else
{
eZContentObjectTreeNode::hideSubTree( $curNode );
}
// Notify cache system about visibility change
ezpEvent::getInstance()->notify('content/cache', [
[(int)$nodeID],
[(int)$curNode->attribute('contentobject_id')]
]);
}
//call appropriate method from search engine
eZSearch::updateNodeVisibility( $nodeID, $action );
return array( 'status' => true );
} | php | static public function changeHideStatus( $nodeID )
{
$action = 'hide';
$curNode = eZContentObjectTreeNode::fetch( $nodeID );
if ( is_object( $curNode ) )
{
if ( $curNode->attribute( 'is_hidden' ) )
{
eZContentObjectTreeNode::unhideSubTree( $curNode );
$action = 'show';
}
else
{
eZContentObjectTreeNode::hideSubTree( $curNode );
}
// Notify cache system about visibility change
ezpEvent::getInstance()->notify('content/cache', [
[(int)$nodeID],
[(int)$curNode->attribute('contentobject_id')]
]);
}
//call appropriate method from search engine
eZSearch::updateNodeVisibility( $nodeID, $action );
return array( 'status' => true );
} | [
"static",
"public",
"function",
"changeHideStatus",
"(",
"$",
"nodeID",
")",
"{",
"$",
"action",
"=",
"'hide'",
";",
"$",
"curNode",
"=",
"eZContentObjectTreeNode",
"::",
"fetch",
"(",
"$",
"nodeID",
")",
";",
"if",
"(",
"is_object",
"(",
"$",
"curNode",
... | Changes an contentobject's status
@param int $nodeID
@return array An array with operation status, always true | [
"Changes",
"an",
"contentobject",
"s",
"status"
] | 2493420f527fbc829a8d5bdda402e05d64a20db7 | https://github.com/ezsystems/ezpublish-legacy/blob/2493420f527fbc829a8d5bdda402e05d64a20db7/kernel/content/ezcontentoperationcollection.php#L1037-L1065 | train |
ezsystems/ezpublish-legacy | kernel/content/ezcontentoperationcollection.php | eZContentOperationCollection.updateSection | static public function updateSection( $nodeID, $selectedSectionID, $updateSearchIndexes = true )
{
eZContentObjectTreeNode::assignSectionToSubTree( $nodeID, $selectedSectionID, false, $updateSearchIndexes );
} | php | static public function updateSection( $nodeID, $selectedSectionID, $updateSearchIndexes = true )
{
eZContentObjectTreeNode::assignSectionToSubTree( $nodeID, $selectedSectionID, false, $updateSearchIndexes );
} | [
"static",
"public",
"function",
"updateSection",
"(",
"$",
"nodeID",
",",
"$",
"selectedSectionID",
",",
"$",
"updateSearchIndexes",
"=",
"true",
")",
"{",
"eZContentObjectTreeNode",
"::",
"assignSectionToSubTree",
"(",
"$",
"nodeID",
",",
"$",
"selectedSectionID",
... | Assigns a node to a section
@param int $nodeID
@param int $selectedSectionID
@param bool $updateSearchIndexes
@return void | [
"Assigns",
"a",
"node",
"to",
"a",
"section"
] | 2493420f527fbc829a8d5bdda402e05d64a20db7 | https://github.com/ezsystems/ezpublish-legacy/blob/2493420f527fbc829a8d5bdda402e05d64a20db7/kernel/content/ezcontentoperationcollection.php#L1188-L1191 | train |
ezsystems/ezpublish-legacy | kernel/content/ezcontentoperationcollection.php | eZContentOperationCollection.changeTranslationAvailableStatus | static public function changeTranslationAvailableStatus( $objectID, $status = false )
{
$object = eZContentObject::fetch( $objectID );
if ( !$object->canEdit() )
{
return array( 'status' => false );
}
if ( $object->isAlwaysAvailable() & $status == false )
{
$object->setAlwaysAvailableLanguageID( false );
eZContentCacheManager::clearContentCacheIfNeeded( $objectID );
}
else if ( !$object->isAlwaysAvailable() & $status == true )
{
$object->setAlwaysAvailableLanguageID( $object->attribute( 'initial_language_id' ) );
eZContentCacheManager::clearContentCacheIfNeeded( $objectID );
}
return array( 'status' => true );
} | php | static public function changeTranslationAvailableStatus( $objectID, $status = false )
{
$object = eZContentObject::fetch( $objectID );
if ( !$object->canEdit() )
{
return array( 'status' => false );
}
if ( $object->isAlwaysAvailable() & $status == false )
{
$object->setAlwaysAvailableLanguageID( false );
eZContentCacheManager::clearContentCacheIfNeeded( $objectID );
}
else if ( !$object->isAlwaysAvailable() & $status == true )
{
$object->setAlwaysAvailableLanguageID( $object->attribute( 'initial_language_id' ) );
eZContentCacheManager::clearContentCacheIfNeeded( $objectID );
}
return array( 'status' => true );
} | [
"static",
"public",
"function",
"changeTranslationAvailableStatus",
"(",
"$",
"objectID",
",",
"$",
"status",
"=",
"false",
")",
"{",
"$",
"object",
"=",
"eZContentObject",
"::",
"fetch",
"(",
"$",
"objectID",
")",
";",
"if",
"(",
"!",
"$",
"object",
"->",... | Changes the status of a translation
@param int $objectID
@param int $status
@return array An array with operation status, always true | [
"Changes",
"the",
"status",
"of",
"a",
"translation"
] | 2493420f527fbc829a8d5bdda402e05d64a20db7 | https://github.com/ezsystems/ezpublish-legacy/blob/2493420f527fbc829a8d5bdda402e05d64a20db7/kernel/content/ezcontentoperationcollection.php#L1201-L1219 | train |
ezsystems/ezpublish-legacy | kernel/content/ezcontentoperationcollection.php | eZContentOperationCollection.changeSortOrder | static public function changeSortOrder( $nodeID, $sortingField, $sortingOrder = false )
{
$curNode = eZContentObjectTreeNode::fetch( $nodeID );
if ( is_object( $curNode ) )
{
$db = eZDB::instance();
$db->begin();
$curNode->setAttribute( 'sort_field', $sortingField );
$curNode->setAttribute( 'sort_order', $sortingOrder );
$curNode->store();
$db->commit();
$object = $curNode->object();
eZContentCacheManager::clearContentCacheIfNeeded( $object->attribute( 'id' ) );
}
return array( 'status' => true );
} | php | static public function changeSortOrder( $nodeID, $sortingField, $sortingOrder = false )
{
$curNode = eZContentObjectTreeNode::fetch( $nodeID );
if ( is_object( $curNode ) )
{
$db = eZDB::instance();
$db->begin();
$curNode->setAttribute( 'sort_field', $sortingField );
$curNode->setAttribute( 'sort_order', $sortingOrder );
$curNode->store();
$db->commit();
$object = $curNode->object();
eZContentCacheManager::clearContentCacheIfNeeded( $object->attribute( 'id' ) );
}
return array( 'status' => true );
} | [
"static",
"public",
"function",
"changeSortOrder",
"(",
"$",
"nodeID",
",",
"$",
"sortingField",
",",
"$",
"sortingOrder",
"=",
"false",
")",
"{",
"$",
"curNode",
"=",
"eZContentObjectTreeNode",
"::",
"fetch",
"(",
"$",
"nodeID",
")",
";",
"if",
"(",
"is_o... | Changes the sort order for a node
@param int $nodeID
@param string $sortingField
@param bool $sortingOrder
@return array An array with operation status, always true | [
"Changes",
"the",
"sort",
"order",
"for",
"a",
"node"
] | 2493420f527fbc829a8d5bdda402e05d64a20db7 | https://github.com/ezsystems/ezpublish-legacy/blob/2493420f527fbc829a8d5bdda402e05d64a20db7/kernel/content/ezcontentoperationcollection.php#L1230-L1245 | train |
ezsystems/ezpublish-legacy | kernel/content/ezcontentoperationcollection.php | eZContentOperationCollection.updatePriority | static public function updatePriority( $parentNodeID, $priorityArray = array(), $priorityIDArray = array() )
{
$curNode = eZContentObjectTreeNode::fetch( $parentNodeID );
if ( $curNode instanceof eZContentObjectTreeNode )
{
$objectIDs = array();
$db = eZDB::instance();
$db->begin();
for ( $i = 0, $l = count( $priorityArray ); $i < $l; $i++ )
{
$priority = (int) $priorityArray[$i];
$nodeID = (int) $priorityIDArray[$i];
$node = eZContentObjectTreeNode::fetch( $nodeID );
if ( !$node instanceof eZContentObjectTreeNode )
{
continue;
}
$objectIDs[] = $node->attribute( 'contentobject_id' );
$db->query( "UPDATE
ezcontentobject_tree
SET
priority={$priority}
WHERE
node_id={$nodeID} AND parent_node_id={$parentNodeID}" );
}
$curNode->updateAndStoreModified();
$db->commit();
if ( !eZSearch::getEngine() instanceof eZSearchEngine )
{
eZContentCacheManager::clearContentCacheIfNeeded( $objectIDs );
foreach ( $objectIDs as $objectID )
{
eZContentOperationCollection::registerSearchObject( $objectID );
}
}
}
return array( 'status' => true );
} | php | static public function updatePriority( $parentNodeID, $priorityArray = array(), $priorityIDArray = array() )
{
$curNode = eZContentObjectTreeNode::fetch( $parentNodeID );
if ( $curNode instanceof eZContentObjectTreeNode )
{
$objectIDs = array();
$db = eZDB::instance();
$db->begin();
for ( $i = 0, $l = count( $priorityArray ); $i < $l; $i++ )
{
$priority = (int) $priorityArray[$i];
$nodeID = (int) $priorityIDArray[$i];
$node = eZContentObjectTreeNode::fetch( $nodeID );
if ( !$node instanceof eZContentObjectTreeNode )
{
continue;
}
$objectIDs[] = $node->attribute( 'contentobject_id' );
$db->query( "UPDATE
ezcontentobject_tree
SET
priority={$priority}
WHERE
node_id={$nodeID} AND parent_node_id={$parentNodeID}" );
}
$curNode->updateAndStoreModified();
$db->commit();
if ( !eZSearch::getEngine() instanceof eZSearchEngine )
{
eZContentCacheManager::clearContentCacheIfNeeded( $objectIDs );
foreach ( $objectIDs as $objectID )
{
eZContentOperationCollection::registerSearchObject( $objectID );
}
}
}
return array( 'status' => true );
} | [
"static",
"public",
"function",
"updatePriority",
"(",
"$",
"parentNodeID",
",",
"$",
"priorityArray",
"=",
"array",
"(",
")",
",",
"$",
"priorityIDArray",
"=",
"array",
"(",
")",
")",
"{",
"$",
"curNode",
"=",
"eZContentObjectTreeNode",
"::",
"fetch",
"(",
... | Updates the priority of a node
@param int $parentNodeID
@param array $priorityArray
@param array $priorityIDArray
@return array An array with operation status, always true | [
"Updates",
"the",
"priority",
"of",
"a",
"node"
] | 2493420f527fbc829a8d5bdda402e05d64a20db7 | https://github.com/ezsystems/ezpublish-legacy/blob/2493420f527fbc829a8d5bdda402e05d64a20db7/kernel/content/ezcontentoperationcollection.php#L1256-L1294 | train |
ezsystems/ezpublish-legacy | kernel/content/ezcontentoperationcollection.php | eZContentOperationCollection.updateMainAssignment | static public function updateMainAssignment( $mainAssignmentID, $objectID, $mainAssignmentParentID )
{
eZContentObjectTreeNode::updateMainNodeID( $mainAssignmentID, $objectID, false, $mainAssignmentParentID );
eZContentCacheManager::clearContentCacheIfNeeded( $objectID );
if ( !eZSearch::getEngine() instanceof eZSearchEngine )
{
eZContentOperationCollection::registerSearchObject( $objectID );
}
return array( 'status' => true );
} | php | static public function updateMainAssignment( $mainAssignmentID, $objectID, $mainAssignmentParentID )
{
eZContentObjectTreeNode::updateMainNodeID( $mainAssignmentID, $objectID, false, $mainAssignmentParentID );
eZContentCacheManager::clearContentCacheIfNeeded( $objectID );
if ( !eZSearch::getEngine() instanceof eZSearchEngine )
{
eZContentOperationCollection::registerSearchObject( $objectID );
}
return array( 'status' => true );
} | [
"static",
"public",
"function",
"updateMainAssignment",
"(",
"$",
"mainAssignmentID",
",",
"$",
"objectID",
",",
"$",
"mainAssignmentParentID",
")",
"{",
"eZContentObjectTreeNode",
"::",
"updateMainNodeID",
"(",
"$",
"mainAssignmentID",
",",
"$",
"objectID",
",",
"f... | Update a node's main assignment
@param int $mainAssignmentID
@param int $objectID
@param int $mainAssignmentParentID
@return array An array with operation status, always true | [
"Update",
"a",
"node",
"s",
"main",
"assignment"
] | 2493420f527fbc829a8d5bdda402e05d64a20db7 | https://github.com/ezsystems/ezpublish-legacy/blob/2493420f527fbc829a8d5bdda402e05d64a20db7/kernel/content/ezcontentoperationcollection.php#L1305-L1315 | train |
ezsystems/ezpublish-legacy | kernel/content/ezcontentoperationcollection.php | eZContentOperationCollection.updateInitialLanguage | static public function updateInitialLanguage( $objectID, $newInitialLanguageID )
{
$object = eZContentObject::fetch( $objectID );
$language = eZContentLanguage::fetch( $newInitialLanguageID );
if ( $language and !$language->attribute( 'disabled' ) )
{
$object->setAttribute( 'initial_language_id', $newInitialLanguageID );
$objectName = $object->name( false, $language->attribute( 'locale' ) );
$object->setAttribute( 'name', $objectName );
$object->store();
if ( $object->isAlwaysAvailable() )
{
$object->setAlwaysAvailableLanguageID( $newInitialLanguageID );
}
$nodes = $object->assignedNodes();
foreach ( $nodes as $node )
{
$node->updateSubTreePath();
}
}
eZContentCacheManager::clearContentCacheIfNeeded( $objectID );
return array( 'status' => true );
} | php | static public function updateInitialLanguage( $objectID, $newInitialLanguageID )
{
$object = eZContentObject::fetch( $objectID );
$language = eZContentLanguage::fetch( $newInitialLanguageID );
if ( $language and !$language->attribute( 'disabled' ) )
{
$object->setAttribute( 'initial_language_id', $newInitialLanguageID );
$objectName = $object->name( false, $language->attribute( 'locale' ) );
$object->setAttribute( 'name', $objectName );
$object->store();
if ( $object->isAlwaysAvailable() )
{
$object->setAlwaysAvailableLanguageID( $newInitialLanguageID );
}
$nodes = $object->assignedNodes();
foreach ( $nodes as $node )
{
$node->updateSubTreePath();
}
}
eZContentCacheManager::clearContentCacheIfNeeded( $objectID );
return array( 'status' => true );
} | [
"static",
"public",
"function",
"updateInitialLanguage",
"(",
"$",
"objectID",
",",
"$",
"newInitialLanguageID",
")",
"{",
"$",
"object",
"=",
"eZContentObject",
"::",
"fetch",
"(",
"$",
"objectID",
")",
";",
"$",
"language",
"=",
"eZContentLanguage",
"::",
"f... | Updates an contentobject's initial language
@param int $objectID
@param int $newInitialLanguageID
@return array An array with operation status, always true | [
"Updates",
"an",
"contentobject",
"s",
"initial",
"language"
] | 2493420f527fbc829a8d5bdda402e05d64a20db7 | https://github.com/ezsystems/ezpublish-legacy/blob/2493420f527fbc829a8d5bdda402e05d64a20db7/kernel/content/ezcontentoperationcollection.php#L1325-L1351 | train |
ezsystems/ezpublish-legacy | kernel/content/ezcontentoperationcollection.php | eZContentOperationCollection.updateAlwaysAvailable | static public function updateAlwaysAvailable( $objectID, $newAlwaysAvailable )
{
$object = eZContentObject::fetch( $objectID );
$change = false;
if ( $object->isAlwaysAvailable() & $newAlwaysAvailable == false )
{
$object->setAlwaysAvailableLanguageID( false );
$change = true;
}
else if ( !$object->isAlwaysAvailable() & $newAlwaysAvailable == true )
{
$object->setAlwaysAvailableLanguageID( $object->attribute( 'initial_language_id' ) );
$change = true;
}
if ( $change )
{
eZContentCacheManager::clearContentCacheIfNeeded( $objectID );
if ( !eZSearch::getEngine() instanceof eZSearchEngine )
{
eZContentOperationCollection::registerSearchObject( $objectID );
}
}
return array( 'status' => true );
} | php | static public function updateAlwaysAvailable( $objectID, $newAlwaysAvailable )
{
$object = eZContentObject::fetch( $objectID );
$change = false;
if ( $object->isAlwaysAvailable() & $newAlwaysAvailable == false )
{
$object->setAlwaysAvailableLanguageID( false );
$change = true;
}
else if ( !$object->isAlwaysAvailable() & $newAlwaysAvailable == true )
{
$object->setAlwaysAvailableLanguageID( $object->attribute( 'initial_language_id' ) );
$change = true;
}
if ( $change )
{
eZContentCacheManager::clearContentCacheIfNeeded( $objectID );
if ( !eZSearch::getEngine() instanceof eZSearchEngine )
{
eZContentOperationCollection::registerSearchObject( $objectID );
}
}
return array( 'status' => true );
} | [
"static",
"public",
"function",
"updateAlwaysAvailable",
"(",
"$",
"objectID",
",",
"$",
"newAlwaysAvailable",
")",
"{",
"$",
"object",
"=",
"eZContentObject",
"::",
"fetch",
"(",
"$",
"objectID",
")",
";",
"$",
"change",
"=",
"false",
";",
"if",
"(",
"$",... | Set the always available flag for a content object
@param int $objectID
@param int $newAlwaysAvailable
@return array An array with operation status, always true | [
"Set",
"the",
"always",
"available",
"flag",
"for",
"a",
"content",
"object"
] | 2493420f527fbc829a8d5bdda402e05d64a20db7 | https://github.com/ezsystems/ezpublish-legacy/blob/2493420f527fbc829a8d5bdda402e05d64a20db7/kernel/content/ezcontentoperationcollection.php#L1360-L1385 | train |
ezsystems/ezpublish-legacy | kernel/content/ezcontentoperationcollection.php | eZContentOperationCollection.removeTranslation | static public function removeTranslation( $objectID, $languageIDArray )
{
$object = eZContentObject::fetch( $objectID );
foreach( $languageIDArray as $languageID )
{
if ( !$object->removeTranslation( $languageID ) )
{
eZDebug::writeError( "Object with id $objectID: cannot remove the translation with language id $languageID!",
__METHOD__ );
}
}
eZContentOperationCollection::registerSearchObject( $objectID );
eZContentCacheManager::clearContentCacheIfNeeded( $objectID );
return array( 'status' => true );
} | php | static public function removeTranslation( $objectID, $languageIDArray )
{
$object = eZContentObject::fetch( $objectID );
foreach( $languageIDArray as $languageID )
{
if ( !$object->removeTranslation( $languageID ) )
{
eZDebug::writeError( "Object with id $objectID: cannot remove the translation with language id $languageID!",
__METHOD__ );
}
}
eZContentOperationCollection::registerSearchObject( $objectID );
eZContentCacheManager::clearContentCacheIfNeeded( $objectID );
return array( 'status' => true );
} | [
"static",
"public",
"function",
"removeTranslation",
"(",
"$",
"objectID",
",",
"$",
"languageIDArray",
")",
"{",
"$",
"object",
"=",
"eZContentObject",
"::",
"fetch",
"(",
"$",
"objectID",
")",
";",
"foreach",
"(",
"$",
"languageIDArray",
"as",
"$",
"langua... | Removes a translation for a contentobject
@param int $objectID
@param array
@return array An array with operation status, always true | [
"Removes",
"a",
"translation",
"for",
"a",
"contentobject"
] | 2493420f527fbc829a8d5bdda402e05d64a20db7 | https://github.com/ezsystems/ezpublish-legacy/blob/2493420f527fbc829a8d5bdda402e05d64a20db7/kernel/content/ezcontentoperationcollection.php#L1394-L1412 | train |
ezsystems/ezpublish-legacy | kernel/content/ezcontentoperationcollection.php | eZContentOperationCollection.updateObjectState | static public function updateObjectState( $objectID, $selectedStateIDList )
{
$object = eZContentObject::fetch( $objectID );
// we don't need to re-assign states the object currently already has assigned
$currentStateIDArray = $object->attribute( 'state_id_array' );
$selectedStateIDList = array_diff( $selectedStateIDList, $currentStateIDArray );
// filter out any states the current user is not allowed to assign
$canAssignStateIDList = $object->attribute( 'allowed_assign_state_id_list' );
$selectedStateIDList = array_intersect( $selectedStateIDList, $canAssignStateIDList );
foreach ( $selectedStateIDList as $selectedStateID )
{
$state = eZContentObjectState::fetchById( $selectedStateID );
$object->assignState( $state );
}
eZAudit::writeAudit( 'state-assign', array( 'Content object ID' => $object->attribute( 'id' ),
'Content object name' => $object->attribute( 'name' ),
'Selected State ID Array' => implode( ', ' , $selectedStateIDList ),
'Comment' => 'Updated states of the current object: eZContentOperationCollection::updateObjectState()' ) );
//call appropriate method from search engine
eZSearch::updateObjectState($objectID, $selectedStateIDList);
// Triggering content/state/assign event for persistence cache purge
ezpEvent::getInstance()->notify( 'content/state/assign', array( $objectID, $selectedStateIDList ) );
eZContentCacheManager::clearContentCacheIfNeeded( $objectID );
return array( 'status' => true );
} | php | static public function updateObjectState( $objectID, $selectedStateIDList )
{
$object = eZContentObject::fetch( $objectID );
// we don't need to re-assign states the object currently already has assigned
$currentStateIDArray = $object->attribute( 'state_id_array' );
$selectedStateIDList = array_diff( $selectedStateIDList, $currentStateIDArray );
// filter out any states the current user is not allowed to assign
$canAssignStateIDList = $object->attribute( 'allowed_assign_state_id_list' );
$selectedStateIDList = array_intersect( $selectedStateIDList, $canAssignStateIDList );
foreach ( $selectedStateIDList as $selectedStateID )
{
$state = eZContentObjectState::fetchById( $selectedStateID );
$object->assignState( $state );
}
eZAudit::writeAudit( 'state-assign', array( 'Content object ID' => $object->attribute( 'id' ),
'Content object name' => $object->attribute( 'name' ),
'Selected State ID Array' => implode( ', ' , $selectedStateIDList ),
'Comment' => 'Updated states of the current object: eZContentOperationCollection::updateObjectState()' ) );
//call appropriate method from search engine
eZSearch::updateObjectState($objectID, $selectedStateIDList);
// Triggering content/state/assign event for persistence cache purge
ezpEvent::getInstance()->notify( 'content/state/assign', array( $objectID, $selectedStateIDList ) );
eZContentCacheManager::clearContentCacheIfNeeded( $objectID );
return array( 'status' => true );
} | [
"static",
"public",
"function",
"updateObjectState",
"(",
"$",
"objectID",
",",
"$",
"selectedStateIDList",
")",
"{",
"$",
"object",
"=",
"eZContentObject",
"::",
"fetch",
"(",
"$",
"objectID",
")",
";",
"// we don't need to re-assign states the object currently already... | Update a contentobject's state
@param int $objectID
@param int $selectedStateIDList
@return array An array with operation status, always true | [
"Update",
"a",
"contentobject",
"s",
"state"
] | 2493420f527fbc829a8d5bdda402e05d64a20db7 | https://github.com/ezsystems/ezpublish-legacy/blob/2493420f527fbc829a8d5bdda402e05d64a20db7/kernel/content/ezcontentoperationcollection.php#L1422-L1452 | train |
ezsystems/ezpublish-legacy | kernel/classes/ezproductcollection.php | eZProductCollection.copy | function copy()
{
$collection = clone $this;
$db = eZDB::instance();
$db->begin();
$collection->store();
$oldItems = $this->itemList();
foreach ( $oldItems as $oldItem )
{
$item = $oldItem->copy( $collection->attribute( 'id' ) );
}
$db->commit();
return $collection;
} | php | function copy()
{
$collection = clone $this;
$db = eZDB::instance();
$db->begin();
$collection->store();
$oldItems = $this->itemList();
foreach ( $oldItems as $oldItem )
{
$item = $oldItem->copy( $collection->attribute( 'id' ) );
}
$db->commit();
return $collection;
} | [
"function",
"copy",
"(",
")",
"{",
"$",
"collection",
"=",
"clone",
"$",
"this",
";",
"$",
"db",
"=",
"eZDB",
"::",
"instance",
"(",
")",
";",
"$",
"db",
"->",
"begin",
"(",
")",
";",
"$",
"collection",
"->",
"store",
"(",
")",
";",
"$",
"oldIt... | Copies the collection object, the collection items and options.
@note The new collection will already be present in the database.
@return eZProductCollection The new collection object. | [
"Copies",
"the",
"collection",
"object",
"the",
"collection",
"items",
"and",
"options",
"."
] | 2493420f527fbc829a8d5bdda402e05d64a20db7 | https://github.com/ezsystems/ezpublish-legacy/blob/2493420f527fbc829a8d5bdda402e05d64a20db7/kernel/classes/ezproductcollection.php#L64-L79 | train |
ezsystems/ezpublish-legacy | kernel/classes/ezproductcollection.php | eZProductCollection.fetch | static function fetch( $productCollectionID, $asObject = true )
{
return eZPersistentObject::fetchObject( eZProductCollection::definition(),
null,
array( 'id' => $productCollectionID ),
$asObject );
} | php | static function fetch( $productCollectionID, $asObject = true )
{
return eZPersistentObject::fetchObject( eZProductCollection::definition(),
null,
array( 'id' => $productCollectionID ),
$asObject );
} | [
"static",
"function",
"fetch",
"(",
"$",
"productCollectionID",
",",
"$",
"asObject",
"=",
"true",
")",
"{",
"return",
"eZPersistentObject",
"::",
"fetchObject",
"(",
"eZProductCollection",
"::",
"definition",
"(",
")",
",",
"null",
",",
"array",
"(",
"'id'",
... | Fetches an eZProductCollection based on its ID
@param int $productCollectionID
@param bool $asObject
If true, return an object. if false, returns an array
@return array|eZProductCollection | [
"Fetches",
"an",
"eZProductCollection",
"based",
"on",
"its",
"ID"
] | 2493420f527fbc829a8d5bdda402e05d64a20db7 | https://github.com/ezsystems/ezpublish-legacy/blob/2493420f527fbc829a8d5bdda402e05d64a20db7/kernel/classes/ezproductcollection.php#L90-L96 | train |
ezsystems/ezpublish-legacy | kernel/classes/ezproductcollection.php | eZProductCollection.itemList | function itemList( $asObject = true )
{
return eZPersistentObject::fetchObjectList( eZProductCollectionItem::definition(),
null, array( "productcollection_id" => $this->ID ),
null,
null,
$asObject );
} | php | function itemList( $asObject = true )
{
return eZPersistentObject::fetchObjectList( eZProductCollectionItem::definition(),
null, array( "productcollection_id" => $this->ID ),
null,
null,
$asObject );
} | [
"function",
"itemList",
"(",
"$",
"asObject",
"=",
"true",
")",
"{",
"return",
"eZPersistentObject",
"::",
"fetchObjectList",
"(",
"eZProductCollectionItem",
"::",
"definition",
"(",
")",
",",
"null",
",",
"array",
"(",
"\"productcollection_id\"",
"=>",
"$",
"th... | Returns all production collection items as an array.
@param bool $asObject
If true, return an object. if false, returns an array
@return array(eZProductCollection|array) | [
"Returns",
"all",
"production",
"collection",
"items",
"as",
"an",
"array",
"."
] | 2493420f527fbc829a8d5bdda402e05d64a20db7 | https://github.com/ezsystems/ezpublish-legacy/blob/2493420f527fbc829a8d5bdda402e05d64a20db7/kernel/classes/ezproductcollection.php#L106-L113 | train |
ezsystems/ezpublish-legacy | kernel/classes/ezproductcollection.php | eZProductCollection.cleanupList | static function cleanupList( $productCollectionIDList )
{
$db = eZDB::instance();
$db->begin();
// Purge shipping information associated with product collections being removed.
foreach ( $productCollectionIDList as $productCollectionID )
eZShippingManager::purgeShippingInfo( $productCollectionID );
eZProductCollectionItem::cleanupList( $productCollectionIDList );
$where = $db->generateSQLINStatement( $productCollectionIDList, 'id', false, false, 'int' );
$db->query( "DELETE FROM ezproductcollection WHERE {$where}" );
$db->commit();
} | php | static function cleanupList( $productCollectionIDList )
{
$db = eZDB::instance();
$db->begin();
// Purge shipping information associated with product collections being removed.
foreach ( $productCollectionIDList as $productCollectionID )
eZShippingManager::purgeShippingInfo( $productCollectionID );
eZProductCollectionItem::cleanupList( $productCollectionIDList );
$where = $db->generateSQLINStatement( $productCollectionIDList, 'id', false, false, 'int' );
$db->query( "DELETE FROM ezproductcollection WHERE {$where}" );
$db->commit();
} | [
"static",
"function",
"cleanupList",
"(",
"$",
"productCollectionIDList",
")",
"{",
"$",
"db",
"=",
"eZDB",
"::",
"instance",
"(",
")",
";",
"$",
"db",
"->",
"begin",
"(",
")",
";",
"// Purge shipping information associated with product collections being removed.",
... | Removes all product collections based on a product collection ID list
Will also remove the product collection items.
@param array $productCollectionIDList array of eZProductCollection IDs
@return void | [
"Removes",
"all",
"product",
"collections",
"based",
"on",
"a",
"product",
"collection",
"ID",
"list",
"Will",
"also",
"remove",
"the",
"product",
"collection",
"items",
"."
] | 2493420f527fbc829a8d5bdda402e05d64a20db7 | https://github.com/ezsystems/ezpublish-legacy/blob/2493420f527fbc829a8d5bdda402e05d64a20db7/kernel/classes/ezproductcollection.php#L153-L166 | train |
ezsystems/ezpublish-legacy | kernel/private/classes/ezpcontentpublishingqueueprocessor.php | ezpContentPublishingQueueProcessor.instance | public static function instance()
{
if ( !self::$instance instanceof ezpContentPublishingQueueProcessor )
{
self::$instance = new ezpContentPublishingQueueProcessor();
// signal handler for children termination signal
self::$instance->registerSignalHandler();
}
return self::$instance;
} | php | public static function instance()
{
if ( !self::$instance instanceof ezpContentPublishingQueueProcessor )
{
self::$instance = new ezpContentPublishingQueueProcessor();
// signal handler for children termination signal
self::$instance->registerSignalHandler();
}
return self::$instance;
} | [
"public",
"static",
"function",
"instance",
"(",
")",
"{",
"if",
"(",
"!",
"self",
"::",
"$",
"instance",
"instanceof",
"ezpContentPublishingQueueProcessor",
")",
"{",
"self",
"::",
"$",
"instance",
"=",
"new",
"ezpContentPublishingQueueProcessor",
"(",
")",
";"... | Singleton class loader
@return ezpContentPublishingQueueProcessor | [
"Singleton",
"class",
"loader"
] | 2493420f527fbc829a8d5bdda402e05d64a20db7 | https://github.com/ezsystems/ezpublish-legacy/blob/2493420f527fbc829a8d5bdda402e05d64a20db7/kernel/private/classes/ezpcontentpublishingqueueprocessor.php#L52-L62 | train |
ezsystems/ezpublish-legacy | kernel/private/classes/ezpcontentpublishingqueueprocessor.php | ezpContentPublishingQueueProcessor.cleanupDeadProcesses | private function cleanupDeadProcesses()
{
$processes = ezpContentPublishingProcess::fetchProcesses( ezpContentPublishingProcess::STATUS_WORKING );
foreach( $processes as $process )
{
if ( !$process->isAlive() )
{
$process->reset();
}
}
} | php | private function cleanupDeadProcesses()
{
$processes = ezpContentPublishingProcess::fetchProcesses( ezpContentPublishingProcess::STATUS_WORKING );
foreach( $processes as $process )
{
if ( !$process->isAlive() )
{
$process->reset();
}
}
} | [
"private",
"function",
"cleanupDeadProcesses",
"(",
")",
"{",
"$",
"processes",
"=",
"ezpContentPublishingProcess",
"::",
"fetchProcesses",
"(",
"ezpContentPublishingProcess",
"::",
"STATUS_WORKING",
")",
";",
"foreach",
"(",
"$",
"processes",
"as",
"$",
"process",
... | Checks WORKING processes, and removes from the queue those who are dead
@return void | [
"Checks",
"WORKING",
"processes",
"and",
"removes",
"from",
"the",
"queue",
"those",
"who",
"are",
"dead"
] | 2493420f527fbc829a8d5bdda402e05d64a20db7 | https://github.com/ezsystems/ezpublish-legacy/blob/2493420f527fbc829a8d5bdda402e05d64a20db7/kernel/private/classes/ezpcontentpublishingqueueprocessor.php#L167-L177 | train |
ezsystems/ezpublish-legacy | kernel/private/classes/ezpcontentpublishingqueueprocessor.php | ezpContentPublishingQueueProcessor.childSignalHandler | public function childSignalHandler( $signo, $pid = null, $status = null )
{
// If no pid is provided, that means we're getting the signal from the system. Let's figure out
// which child process ended
if( $pid === null )
{
$pid = pcntl_waitpid( -1, $status, WNOHANG );
}
//Make sure we get all of the exited children
while( $pid > 0 )
{
if( $pid && isset( $this->currentJobs[$pid] ) )
{
$exitCode = pcntl_wexitstatus( $status );
if ( $exitCode != 0 )
{
$this->out->write( "Process #{$pid} of object version #".$this->currentJobs[$pid]->attribute( 'ezcontentobject_version_id' ) . " exited with status {$exitCode}" );
// this is required as the MySQL connection might be closed anytime by a fork
// this method is asynchronous, and might be triggered by any signal
// the only way is to use a dedicated DB connection, and close it afterwards
eZDB::setInstance( eZDB::instance( false, false, true ) );
$this->currentJobs[$pid]->reset();
eZDB::instance()->close();
eZDB::setInstance( null );
}
unset( $this->currentJobs[$pid] );
}
// A job has finished before the parent process could even note that it had been launched
// Let's make note of it and handle it when the parent process is ready for it
// echo "..... Adding $pid to the signal queue ..... \n";
elseif( $pid )
{
$this->signalQueue[$pid] = $status;
}
$pid = pcntl_waitpid( -1, $status, WNOHANG );
}
return true;
} | php | public function childSignalHandler( $signo, $pid = null, $status = null )
{
// If no pid is provided, that means we're getting the signal from the system. Let's figure out
// which child process ended
if( $pid === null )
{
$pid = pcntl_waitpid( -1, $status, WNOHANG );
}
//Make sure we get all of the exited children
while( $pid > 0 )
{
if( $pid && isset( $this->currentJobs[$pid] ) )
{
$exitCode = pcntl_wexitstatus( $status );
if ( $exitCode != 0 )
{
$this->out->write( "Process #{$pid} of object version #".$this->currentJobs[$pid]->attribute( 'ezcontentobject_version_id' ) . " exited with status {$exitCode}" );
// this is required as the MySQL connection might be closed anytime by a fork
// this method is asynchronous, and might be triggered by any signal
// the only way is to use a dedicated DB connection, and close it afterwards
eZDB::setInstance( eZDB::instance( false, false, true ) );
$this->currentJobs[$pid]->reset();
eZDB::instance()->close();
eZDB::setInstance( null );
}
unset( $this->currentJobs[$pid] );
}
// A job has finished before the parent process could even note that it had been launched
// Let's make note of it and handle it when the parent process is ready for it
// echo "..... Adding $pid to the signal queue ..... \n";
elseif( $pid )
{
$this->signalQueue[$pid] = $status;
}
$pid = pcntl_waitpid( -1, $status, WNOHANG );
}
return true;
} | [
"public",
"function",
"childSignalHandler",
"(",
"$",
"signo",
",",
"$",
"pid",
"=",
"null",
",",
"$",
"status",
"=",
"null",
")",
"{",
"// If no pid is provided, that means we're getting the signal from the system. Let's figure out",
"// which child process ended",
"if",
... | Child process signal handler | [
"Child",
"process",
"signal",
"handler"
] | 2493420f527fbc829a8d5bdda402e05d64a20db7 | https://github.com/ezsystems/ezpublish-legacy/blob/2493420f527fbc829a8d5bdda402e05d64a20db7/kernel/private/classes/ezpcontentpublishingqueueprocessor.php#L218-L258 | train |
ezsystems/ezpublish-legacy | kernel/classes/clusterfilehandlers/ezfsfilehandler.php | eZFSFileHandler.fileStore | function fileStore( $filePath, $scope = false, $delete = false, $datatype = false )
{
eZDebugSetting::writeDebug( 'kernel-clustering', "fs::fileStore( '$filePath' )", __METHOD__ );
} | php | function fileStore( $filePath, $scope = false, $delete = false, $datatype = false )
{
eZDebugSetting::writeDebug( 'kernel-clustering', "fs::fileStore( '$filePath' )", __METHOD__ );
} | [
"function",
"fileStore",
"(",
"$",
"filePath",
",",
"$",
"scope",
"=",
"false",
",",
"$",
"delete",
"=",
"false",
",",
"$",
"datatype",
"=",
"false",
")",
"{",
"eZDebugSetting",
"::",
"writeDebug",
"(",
"'kernel-clustering'",
",",
"\"fs::fileStore( '$filePath'... | Store file.
In case of storing to filesystem does nothing.
@param string $filePath Path to the file being stored.
@param string $scope Means something like "file category". May be used to clean caches of a certain type.
@param string $delete true if the file should be deleted after storing. | [
"Store",
"file",
"."
] | 2493420f527fbc829a8d5bdda402e05d64a20db7 | https://github.com/ezsystems/ezpublish-legacy/blob/2493420f527fbc829a8d5bdda402e05d64a20db7/kernel/classes/clusterfilehandlers/ezfsfilehandler.php#L169-L172 | train |
ezsystems/ezpublish-legacy | kernel/classes/clusterfilehandlers/ezfsfilehandler.php | eZFSFileHandler.fileStoreContents | function fileStoreContents( $filePath, $contents, $scope = false, $datatype = false )
{
eZDebugSetting::writeDebug( 'kernel-clustering', "fs::fileStoreContents( '$filePath' )", __METHOD__ );
eZDebug::accumulatorStart( 'dbfile', false, 'dbfile' );
eZFile::create( basename( $filePath ), dirname( $filePath ), $contents, true );
$perm = eZINI::instance()->variable( 'FileSettings', 'StorageFilePermissions' );
chmod( $filePath, octdec( $perm ) );
eZDebug::accumulatorStop( 'dbfile' );
} | php | function fileStoreContents( $filePath, $contents, $scope = false, $datatype = false )
{
eZDebugSetting::writeDebug( 'kernel-clustering', "fs::fileStoreContents( '$filePath' )", __METHOD__ );
eZDebug::accumulatorStart( 'dbfile', false, 'dbfile' );
eZFile::create( basename( $filePath ), dirname( $filePath ), $contents, true );
$perm = eZINI::instance()->variable( 'FileSettings', 'StorageFilePermissions' );
chmod( $filePath, octdec( $perm ) );
eZDebug::accumulatorStop( 'dbfile' );
} | [
"function",
"fileStoreContents",
"(",
"$",
"filePath",
",",
"$",
"contents",
",",
"$",
"scope",
"=",
"false",
",",
"$",
"datatype",
"=",
"false",
")",
"{",
"eZDebugSetting",
"::",
"writeDebug",
"(",
"'kernel-clustering'",
",",
"\"fs::fileStoreContents( '$filePath'... | Store file contents.
\public
\static | [
"Store",
"file",
"contents",
"."
] | 2493420f527fbc829a8d5bdda402e05d64a20db7 | https://github.com/ezsystems/ezpublish-legacy/blob/2493420f527fbc829a8d5bdda402e05d64a20db7/kernel/classes/clusterfilehandlers/ezfsfilehandler.php#L180-L192 | train |
ezsystems/ezpublish-legacy | kernel/classes/clusterfilehandlers/ezfsfilehandler.php | eZFSFileHandler.fileDeleteByWildcard | function fileDeleteByWildcard( $wildcard )
{
eZDebugSetting::writeDebug( 'kernel-clustering', "fs::fileDeleteByWildcard( '$wildcard' )", __METHOD__ );
eZDebug::accumulatorStart( 'dbfile', false, 'dbfile' );
$unlinkArray = eZSys::globBrace( $wildcard );
if ( $unlinkArray !== false and ( count( $unlinkArray ) > 0 ) )
{
array_map( 'unlink', $unlinkArray );
}
eZDebug::accumulatorStop( 'dbfile' );
} | php | function fileDeleteByWildcard( $wildcard )
{
eZDebugSetting::writeDebug( 'kernel-clustering', "fs::fileDeleteByWildcard( '$wildcard' )", __METHOD__ );
eZDebug::accumulatorStart( 'dbfile', false, 'dbfile' );
$unlinkArray = eZSys::globBrace( $wildcard );
if ( $unlinkArray !== false and ( count( $unlinkArray ) > 0 ) )
{
array_map( 'unlink', $unlinkArray );
}
eZDebug::accumulatorStop( 'dbfile' );
} | [
"function",
"fileDeleteByWildcard",
"(",
"$",
"wildcard",
")",
"{",
"eZDebugSetting",
"::",
"writeDebug",
"(",
"'kernel-clustering'",
",",
"\"fs::fileDeleteByWildcard( '$wildcard' )\"",
",",
"__METHOD__",
")",
";",
"eZDebug",
"::",
"accumulatorStart",
"(",
"'dbfile'",
"... | Delete files matching given wildcard.
\public
\static | [
"Delete",
"files",
"matching",
"given",
"wildcard",
"."
] | 2493420f527fbc829a8d5bdda402e05d64a20db7 | https://github.com/ezsystems/ezpublish-legacy/blob/2493420f527fbc829a8d5bdda402e05d64a20db7/kernel/classes/clusterfilehandlers/ezfsfilehandler.php#L614-L625 | train |
ezsystems/ezpublish-legacy | kernel/classes/clusterfilehandlers/ezfsfilehandler.php | eZFSFileHandler.fileDeleteByDirList | function fileDeleteByDirList( $dirList, $commonPath, $commonSuffix )
{
eZDebugSetting::writeDebug( 'kernel-clustering', "fs::fileDeleteByDirList( '" . implode( ",", $dirList ) . "', '$commonPath', '$commonSuffix' )", __METHOD__ );
eZDebug::accumulatorStart( 'dbfile', false, 'dbfile' );
foreach ( $dirList as $dir )
{
$unlinkArray = eZSys::globBrace( "$commonPath/$dir/$commonSuffix*" );
if ( $unlinkArray !== false )
{
array_map( 'unlink', $unlinkArray );
}
}
eZDebug::accumulatorStop( 'dbfile' );
} | php | function fileDeleteByDirList( $dirList, $commonPath, $commonSuffix )
{
eZDebugSetting::writeDebug( 'kernel-clustering', "fs::fileDeleteByDirList( '" . implode( ",", $dirList ) . "', '$commonPath', '$commonSuffix' )", __METHOD__ );
eZDebug::accumulatorStart( 'dbfile', false, 'dbfile' );
foreach ( $dirList as $dir )
{
$unlinkArray = eZSys::globBrace( "$commonPath/$dir/$commonSuffix*" );
if ( $unlinkArray !== false )
{
array_map( 'unlink', $unlinkArray );
}
}
eZDebug::accumulatorStop( 'dbfile' );
} | [
"function",
"fileDeleteByDirList",
"(",
"$",
"dirList",
",",
"$",
"commonPath",
",",
"$",
"commonSuffix",
")",
"{",
"eZDebugSetting",
"::",
"writeDebug",
"(",
"'kernel-clustering'",
",",
"\"fs::fileDeleteByDirList( '\"",
".",
"implode",
"(",
"\",\"",
",",
"$",
"di... | Delete files located in a directories from dirList, with common prefix specified by
commonPath, and common suffix with added wildcard at the end
\public
\static | [
"Delete",
"files",
"located",
"in",
"a",
"directories",
"from",
"dirList",
"with",
"common",
"prefix",
"specified",
"by",
"commonPath",
"and",
"common",
"suffix",
"with",
"added",
"wildcard",
"at",
"the",
"end"
] | 2493420f527fbc829a8d5bdda402e05d64a20db7 | https://github.com/ezsystems/ezpublish-legacy/blob/2493420f527fbc829a8d5bdda402e05d64a20db7/kernel/classes/clusterfilehandlers/ezfsfilehandler.php#L635-L651 | train |
ezsystems/ezpublish-legacy | kernel/classes/notification/eznotificationevent.php | eZNotificationEvent.fetchList | static function fetchList( $limit = null )
{
return eZPersistentObject::fetchObjectList( eZNotificationEvent::definition(),
null, null, null, $limit,
true );
} | php | static function fetchList( $limit = null )
{
return eZPersistentObject::fetchObjectList( eZNotificationEvent::definition(),
null, null, null, $limit,
true );
} | [
"static",
"function",
"fetchList",
"(",
"$",
"limit",
"=",
"null",
")",
"{",
"return",
"eZPersistentObject",
"::",
"fetchObjectList",
"(",
"eZNotificationEvent",
"::",
"definition",
"(",
")",
",",
"null",
",",
"null",
",",
"null",
",",
"$",
"limit",
",",
"... | Fetches notification events as objects, and returns them in an array.
The optional $limit can be used to set an offset and a limit for the fetch. It is
passed to {@link eZPersistentObject::fetchObjectList()} and should be used in the same way.
@static
@param array $limit An associative array with limitiations, can contain
- offset - Numerical value defining the start offset for the fetch
- length - Numerical value defining the max number of items to return
@return array An array of eZNotificationEvent objects | [
"Fetches",
"notification",
"events",
"as",
"objects",
"and",
"returns",
"them",
"in",
"an",
"array",
"."
] | 2493420f527fbc829a8d5bdda402e05d64a20db7 | https://github.com/ezsystems/ezpublish-legacy/blob/2493420f527fbc829a8d5bdda402e05d64a20db7/kernel/classes/notification/eznotificationevent.php#L150-L155 | train |
ezsystems/ezpublish-legacy | kernel/classes/notification/eznotificationevent.php | eZNotificationEvent.fetchUnhandledList | static function fetchUnhandledList( $limit = null )
{
return eZPersistentObject::fetchObjectList( eZNotificationEvent::definition(),
null, array( 'status' => self::STATUS_CREATED ), null, $limit,
true );
} | php | static function fetchUnhandledList( $limit = null )
{
return eZPersistentObject::fetchObjectList( eZNotificationEvent::definition(),
null, array( 'status' => self::STATUS_CREATED ), null, $limit,
true );
} | [
"static",
"function",
"fetchUnhandledList",
"(",
"$",
"limit",
"=",
"null",
")",
"{",
"return",
"eZPersistentObject",
"::",
"fetchObjectList",
"(",
"eZNotificationEvent",
"::",
"definition",
"(",
")",
",",
"null",
",",
"array",
"(",
"'status'",
"=>",
"self",
"... | Fetches unhandled notification events as objects, and returns them in an array.
The optional $limit can be used to set an offset and a limit for the fetch. It is
passed to {@link eZPersistentObject::fetchObjectList()} and should be used in the same way.
@static
@param array $limit An associative array with limitiations, can contain
- offset - Numerical value defining the start offset for the fetch
- length - Numerical value defining the max number of items to return
@return array An array of eZNotificationEvent objects | [
"Fetches",
"unhandled",
"notification",
"events",
"as",
"objects",
"and",
"returns",
"them",
"in",
"an",
"array",
"."
] | 2493420f527fbc829a8d5bdda402e05d64a20db7 | https://github.com/ezsystems/ezpublish-legacy/blob/2493420f527fbc829a8d5bdda402e05d64a20db7/kernel/classes/notification/eznotificationevent.php#L176-L181 | train |
ezsystems/ezpublish-legacy | extension/ezjscore/classes/ezjscserverrouter.php | ezjscServerRouter.getInstance | public static function getInstance( $arguments, $requireIniGroupe = true, $checkFunctionExistence = false )
{
if ( !is_array( $arguments ) || !isset( $arguments[1] ) )
{
// return null if arguments are invalid
return null;
}
$className = $callClassName = array_shift( $arguments );
$functionName = array_shift( $arguments );
$isTemplateFunction = false;
$permissionFunctions = false;
$permissionPrFunction = false;
$ezjscoreIni = eZINI::instance( 'ezjscore.ini' );
if ( $ezjscoreIni->hasGroup( 'ezjscServer_' . $callClassName ) )
{
// load file if defined, else use autoload
if ( $ezjscoreIni->hasVariable( 'ezjscServer_' . $callClassName, 'File' ) )
include_once( $ezjscoreIni->variable( 'ezjscServer_' . $callClassName, 'File' ) );
if ( $ezjscoreIni->hasVariable( 'ezjscServer_' . $callClassName, 'TemplateFunction' ) )
$isTemplateFunction = $ezjscoreIni->variable( 'ezjscServer_' . $callClassName, 'TemplateFunction' ) === 'true';
// check permissions
if ( $ezjscoreIni->hasVariable( 'ezjscServer_' . $callClassName, 'Functions' ) )
$permissionFunctions = $ezjscoreIni->variable( 'ezjscServer_' . $callClassName, 'Functions' );
// check permissions
if ( $ezjscoreIni->hasVariable( 'ezjscServer_' . $callClassName, 'PermissionPrFunction' ) )
$permissionPrFunction = $ezjscoreIni->variable( 'ezjscServer_' . $callClassName, 'PermissionPrFunction' ) === 'enabled';
// get class name if defined, else use first argument as class name
if ( $ezjscoreIni->hasVariable( 'ezjscServer_' . $callClassName, 'Class' ) )
$className = $ezjscoreIni->variable( 'ezjscServer_' . $callClassName, 'Class' );
}
else if ( $requireIniGroupe )
{
// return null if ini is not defined as a safety measure
// to avoid letting user call all eZ Publish classes
return null;
}
if ( $checkFunctionExistence && !self::staticHasFunction( $className, $functionName, $isTemplateFunction ) )
{
return null;
}
if ( $permissionFunctions !== false )
{
if ( !self::hasAccess( $permissionFunctions, ( $permissionPrFunction ? $functionName : null ) ) )
{
return null;
}
}
return new ezjscServerRouter( $className, $functionName, $arguments, $isTemplateFunction );
} | php | public static function getInstance( $arguments, $requireIniGroupe = true, $checkFunctionExistence = false )
{
if ( !is_array( $arguments ) || !isset( $arguments[1] ) )
{
// return null if arguments are invalid
return null;
}
$className = $callClassName = array_shift( $arguments );
$functionName = array_shift( $arguments );
$isTemplateFunction = false;
$permissionFunctions = false;
$permissionPrFunction = false;
$ezjscoreIni = eZINI::instance( 'ezjscore.ini' );
if ( $ezjscoreIni->hasGroup( 'ezjscServer_' . $callClassName ) )
{
// load file if defined, else use autoload
if ( $ezjscoreIni->hasVariable( 'ezjscServer_' . $callClassName, 'File' ) )
include_once( $ezjscoreIni->variable( 'ezjscServer_' . $callClassName, 'File' ) );
if ( $ezjscoreIni->hasVariable( 'ezjscServer_' . $callClassName, 'TemplateFunction' ) )
$isTemplateFunction = $ezjscoreIni->variable( 'ezjscServer_' . $callClassName, 'TemplateFunction' ) === 'true';
// check permissions
if ( $ezjscoreIni->hasVariable( 'ezjscServer_' . $callClassName, 'Functions' ) )
$permissionFunctions = $ezjscoreIni->variable( 'ezjscServer_' . $callClassName, 'Functions' );
// check permissions
if ( $ezjscoreIni->hasVariable( 'ezjscServer_' . $callClassName, 'PermissionPrFunction' ) )
$permissionPrFunction = $ezjscoreIni->variable( 'ezjscServer_' . $callClassName, 'PermissionPrFunction' ) === 'enabled';
// get class name if defined, else use first argument as class name
if ( $ezjscoreIni->hasVariable( 'ezjscServer_' . $callClassName, 'Class' ) )
$className = $ezjscoreIni->variable( 'ezjscServer_' . $callClassName, 'Class' );
}
else if ( $requireIniGroupe )
{
// return null if ini is not defined as a safety measure
// to avoid letting user call all eZ Publish classes
return null;
}
if ( $checkFunctionExistence && !self::staticHasFunction( $className, $functionName, $isTemplateFunction ) )
{
return null;
}
if ( $permissionFunctions !== false )
{
if ( !self::hasAccess( $permissionFunctions, ( $permissionPrFunction ? $functionName : null ) ) )
{
return null;
}
}
return new ezjscServerRouter( $className, $functionName, $arguments, $isTemplateFunction );
} | [
"public",
"static",
"function",
"getInstance",
"(",
"$",
"arguments",
",",
"$",
"requireIniGroupe",
"=",
"true",
",",
"$",
"checkFunctionExistence",
"=",
"false",
")",
"{",
"if",
"(",
"!",
"is_array",
"(",
"$",
"arguments",
")",
"||",
"!",
"isset",
"(",
... | Gets instance of ezjscServerRouter, IF arguments validates and user has access
@param array $arguments
@param bool $requireIniGroupe Make sure this is true if $arguments comes from user input
@param bool $checkFunctionExistence
@return ezjscServerRouter|null | [
"Gets",
"instance",
"of",
"ezjscServerRouter",
"IF",
"arguments",
"validates",
"and",
"user",
"has",
"access"
] | 2493420f527fbc829a8d5bdda402e05d64a20db7 | https://github.com/ezsystems/ezpublish-legacy/blob/2493420f527fbc829a8d5bdda402e05d64a20db7/extension/ezjscore/classes/ezjscserverrouter.php#L59-L116 | train |
ezsystems/ezpublish-legacy | extension/ezjscore/classes/ezjscserverrouter.php | ezjscServerRouter.staticHasFunction | public static function staticHasFunction( $className, $functionName, $isTemplateFunction = false )
{
if ( $isTemplateFunction )
{
return true;//@todo: find a way to look for templates
}
else
{
return is_callable( array( $className, $functionName ) );
}
} | php | public static function staticHasFunction( $className, $functionName, $isTemplateFunction = false )
{
if ( $isTemplateFunction )
{
return true;//@todo: find a way to look for templates
}
else
{
return is_callable( array( $className, $functionName ) );
}
} | [
"public",
"static",
"function",
"staticHasFunction",
"(",
"$",
"className",
",",
"$",
"functionName",
",",
"$",
"isTemplateFunction",
"=",
"false",
")",
"{",
"if",
"(",
"$",
"isTemplateFunction",
")",
"{",
"return",
"true",
";",
"//@todo: find a way to look for te... | Checks if function actually exits on the requested ezjscServerFunctions
@return bool | [
"Checks",
"if",
"function",
"actually",
"exits",
"on",
"the",
"requested",
"ezjscServerFunctions"
] | 2493420f527fbc829a8d5bdda402e05d64a20db7 | https://github.com/ezsystems/ezpublish-legacy/blob/2493420f527fbc829a8d5bdda402e05d64a20db7/extension/ezjscore/classes/ezjscserverrouter.php#L192-L202 | train |
ezsystems/ezpublish-legacy | extension/ezjscore/classes/ezjscserverrouter.php | ezjscServerRouter.call | public function call( &$environmentArguments = array(), $isPackeStage = false )
{
if ( $this->isTemplateFunction )
{
$tpl = eZTemplate::factory();
$tpl->setVariable( 'arguments', $this->functionArguments );
$tpl->setVariable( 'environment', $environmentArguments );
return $tpl->fetch( 'design:' . $this->className . '/' . $this->functionName . '.tpl' );
}
else
{
return call_user_func_array( array( $this->className, $this->functionName ), array( $this->functionArguments, &$environmentArguments, $isPackeStage ) );
}
} | php | public function call( &$environmentArguments = array(), $isPackeStage = false )
{
if ( $this->isTemplateFunction )
{
$tpl = eZTemplate::factory();
$tpl->setVariable( 'arguments', $this->functionArguments );
$tpl->setVariable( 'environment', $environmentArguments );
return $tpl->fetch( 'design:' . $this->className . '/' . $this->functionName . '.tpl' );
}
else
{
return call_user_func_array( array( $this->className, $this->functionName ), array( $this->functionArguments, &$environmentArguments, $isPackeStage ) );
}
} | [
"public",
"function",
"call",
"(",
"&",
"$",
"environmentArguments",
"=",
"array",
"(",
")",
",",
"$",
"isPackeStage",
"=",
"false",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"isTemplateFunction",
")",
"{",
"$",
"tpl",
"=",
"eZTemplate",
"::",
"factory",
... | Call the defined function on requested ezjscServerFunctions class
@param array $environmentArguments
@return mixed | [
"Call",
"the",
"defined",
"function",
"on",
"requested",
"ezjscServerFunctions",
"class"
] | 2493420f527fbc829a8d5bdda402e05d64a20db7 | https://github.com/ezsystems/ezpublish-legacy/blob/2493420f527fbc829a8d5bdda402e05d64a20db7/extension/ezjscore/classes/ezjscserverrouter.php#L210-L223 | train |
ezsystems/ezpublish-legacy | kernel/private/rest/classes/auth/styles/oauth.php | ezpRestOauthAuthenticationStyle.processLoginRequired | function processLoginRequired( ezcMvcResult $res, $reasons, $errorMap = null )
{
$reasonText = array();
if ( $errorMap === null )
{
$errorMap = array(
'ezpOauthFilter' => array(
ezpOauthFilter::STATUS_TOKEN_INVALID => 'Token has expired.',
ezpOauthFilter::STATUS_TOKEN_EXPIRED => 'Token has expired, please refresh it.',
ezpOauthFilter::STATUS_TOKEN_INSUFFICIENT_SCOPE => 'You do have do have sufficient scope to access this resource.',
),
);
}
foreach ( $reasons as $line )
{
$reasonText[] = $errorMap[key( $line )][current( $line )];
}
$res->variables['ezcAuth_reasons'] = $reasonText;
} | php | function processLoginRequired( ezcMvcResult $res, $reasons, $errorMap = null )
{
$reasonText = array();
if ( $errorMap === null )
{
$errorMap = array(
'ezpOauthFilter' => array(
ezpOauthFilter::STATUS_TOKEN_INVALID => 'Token has expired.',
ezpOauthFilter::STATUS_TOKEN_EXPIRED => 'Token has expired, please refresh it.',
ezpOauthFilter::STATUS_TOKEN_INSUFFICIENT_SCOPE => 'You do have do have sufficient scope to access this resource.',
),
);
}
foreach ( $reasons as $line )
{
$reasonText[] = $errorMap[key( $line )][current( $line )];
}
$res->variables['ezcAuth_reasons'] = $reasonText;
} | [
"function",
"processLoginRequired",
"(",
"ezcMvcResult",
"$",
"res",
",",
"$",
"reasons",
",",
"$",
"errorMap",
"=",
"null",
")",
"{",
"$",
"reasonText",
"=",
"array",
"(",
")",
";",
"if",
"(",
"$",
"errorMap",
"===",
"null",
")",
"{",
"$",
"errorMap",... | Method extracted from MvcAuthenticationTiein
Checks the status from the authentication run and adds the reasons as
variable to the $result.
This method uses the information that is set by the
runAuthRequiredFilter() filter to generate an user-readable text of the
found $reasons and sets these as the variable ezcAuth_reasons in
the $result. You can supply your own mapping from status codes to
messages, but a default is provided. Please refer to the Authentication
tutorial for information about status codes.
@param ezcMvcResult $result
@param array(string) $reasons
@param array(string=>array(int=>string) $errorMap | [
"Method",
"extracted",
"from",
"MvcAuthenticationTiein"
] | 2493420f527fbc829a8d5bdda402e05d64a20db7 | https://github.com/ezsystems/ezpublish-legacy/blob/2493420f527fbc829a8d5bdda402e05d64a20db7/kernel/private/rest/classes/auth/styles/oauth.php#L79-L99 | train |
ezsystems/ezpublish-legacy | kernel/private/classes/clusterfilehandlers/ezdfsfilehandlerbackendfactory.php | eZDFSFileHandlerBackendFactory.build | public static function build()
{
if ( !isset( self::$instance ) )
{
self::$instance = self::buildHandler(
eZINI::instance( 'file.ini' )->variable( 'eZDFSClusteringSettings', 'DFSBackend' )
);
}
return self::$instance;
} | php | public static function build()
{
if ( !isset( self::$instance ) )
{
self::$instance = self::buildHandler(
eZINI::instance( 'file.ini' )->variable( 'eZDFSClusteringSettings', 'DFSBackend' )
);
}
return self::$instance;
} | [
"public",
"static",
"function",
"build",
"(",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"self",
"::",
"$",
"instance",
")",
")",
"{",
"self",
"::",
"$",
"instance",
"=",
"self",
"::",
"buildHandler",
"(",
"eZINI",
"::",
"instance",
"(",
"'file.ini'",
"... | Builds the configured DFSBackend handler
@return eZDFSFileHandlerDFSBackendInterface | [
"Builds",
"the",
"configured",
"DFSBackend",
"handler"
] | 2493420f527fbc829a8d5bdda402e05d64a20db7 | https://github.com/ezsystems/ezpublish-legacy/blob/2493420f527fbc829a8d5bdda402e05d64a20db7/kernel/private/classes/clusterfilehandlers/ezdfsfilehandlerbackendfactory.php#L21-L31 | train |
ezsystems/ezpublish-legacy | kernel/private/rest/classes/status/oauth_required.php | ezpOauthRequired.createErrorString | protected function createErrorString()
{
$str = '';
if ( $this->errorType !== null )
{
$str .= ", error='{$this->errorType}'";
}
if ( $this->errorMessage !== null )
{
$str .= ", error_description='{$this->errorMessage}'";
}
return $str;
} | php | protected function createErrorString()
{
$str = '';
if ( $this->errorType !== null )
{
$str .= ", error='{$this->errorType}'";
}
if ( $this->errorMessage !== null )
{
$str .= ", error_description='{$this->errorMessage}'";
}
return $str;
} | [
"protected",
"function",
"createErrorString",
"(",
")",
"{",
"$",
"str",
"=",
"''",
";",
"if",
"(",
"$",
"this",
"->",
"errorType",
"!==",
"null",
")",
"{",
"$",
"str",
".=",
"\", error='{$this->errorType}'\"",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"... | Creates for use in authentcation challenge header
@return string | [
"Creates",
"for",
"use",
"in",
"authentcation",
"challenge",
"header"
] | 2493420f527fbc829a8d5bdda402e05d64a20db7 | https://github.com/ezsystems/ezpublish-legacy/blob/2493420f527fbc829a8d5bdda402e05d64a20db7/kernel/private/rest/classes/status/oauth_required.php#L76-L89 | train |
ezsystems/ezpublish-legacy | kernel/private/rest/classes/controllers/oauth_token.php | ezpRestOauthTokenController.doHandleRequest | public function doHandleRequest()
{
// Check that the correct params are present
// Params for token endpoint per section 4
// REQUIRED: grant_type, client_id, client_secret
// OPTIONAL: scope
//
// Supported grant types are: authorization_code and refresh_token
//
// Additional params for 'authorization_code', Section 4.1.1
// REQUIRED: code, redirect_uri
//
// Additional param for 'refresh_token", Section 4.1.4
// REQUIRED: refresh_token
// Defining the required params for each stage of operation
$initialRequiredParams = array( 'grant_type', 'client_id', 'client_secret' );
// params for grant_type=authorization_code
$codeRequiredParams = array( 'code', 'redirect_uri' );
// params for grant_type=refresh_token
$refreshRequiredParams = array( 'refresh_token' );
$this->checkParams( $initialRequiredParams );
// We can get the first set of required params
$grant_type = $this->request->post['grant_type'];
$client_id = $this->request->post['client_id'];
$client_secret = $this->request->post['client_secret'];
$tokenTTL = (int)eZINI::instance( 'rest.ini' )->variable( 'OAuthSettings', 'TokenTTL' );
if ( !$this->validateGrantType( $grant_type ) )
{
throw new ezpOauthInvalidRequestException( ezpOauthTokenEndpointErrorType::UNSUPPORTED_GRANT_TYPE );
}
$result = new ezcMvcResult();
$newToken = null;
switch ( $grant_type )
{
case 'authorization_code':
$this->checkParams( $codeRequiredParams );
$newToken = ezpOauthUtility::doRefreshTokenWithAuthorizationCode( $client_id, $client_secret, $this->request->post['code'], $this->request->post['redirect_uri']);
break;
case 'refresh_token':
$this->checkParams( $refreshRequiredParams );
$newToken = ezpOauthUtility::doRefreshToken( $client_id, $client_secret, $this->request->post['refresh_token'] );
break;
}
if ( !$newToken instanceof ezpRestToken )
{
throw new ezpOauthInvalidTokenException( ezpOauthTokenEndpointErrorType::INVALID_REQUEST );
}
$result->variables['access_token'] = $newToken->id;
$result->variables['refresh_token'] = $newToken->refresh_token;
$result->variables['expires_in'] = $tokenTTL;
return $result;
} | php | public function doHandleRequest()
{
// Check that the correct params are present
// Params for token endpoint per section 4
// REQUIRED: grant_type, client_id, client_secret
// OPTIONAL: scope
//
// Supported grant types are: authorization_code and refresh_token
//
// Additional params for 'authorization_code', Section 4.1.1
// REQUIRED: code, redirect_uri
//
// Additional param for 'refresh_token", Section 4.1.4
// REQUIRED: refresh_token
// Defining the required params for each stage of operation
$initialRequiredParams = array( 'grant_type', 'client_id', 'client_secret' );
// params for grant_type=authorization_code
$codeRequiredParams = array( 'code', 'redirect_uri' );
// params for grant_type=refresh_token
$refreshRequiredParams = array( 'refresh_token' );
$this->checkParams( $initialRequiredParams );
// We can get the first set of required params
$grant_type = $this->request->post['grant_type'];
$client_id = $this->request->post['client_id'];
$client_secret = $this->request->post['client_secret'];
$tokenTTL = (int)eZINI::instance( 'rest.ini' )->variable( 'OAuthSettings', 'TokenTTL' );
if ( !$this->validateGrantType( $grant_type ) )
{
throw new ezpOauthInvalidRequestException( ezpOauthTokenEndpointErrorType::UNSUPPORTED_GRANT_TYPE );
}
$result = new ezcMvcResult();
$newToken = null;
switch ( $grant_type )
{
case 'authorization_code':
$this->checkParams( $codeRequiredParams );
$newToken = ezpOauthUtility::doRefreshTokenWithAuthorizationCode( $client_id, $client_secret, $this->request->post['code'], $this->request->post['redirect_uri']);
break;
case 'refresh_token':
$this->checkParams( $refreshRequiredParams );
$newToken = ezpOauthUtility::doRefreshToken( $client_id, $client_secret, $this->request->post['refresh_token'] );
break;
}
if ( !$newToken instanceof ezpRestToken )
{
throw new ezpOauthInvalidTokenException( ezpOauthTokenEndpointErrorType::INVALID_REQUEST );
}
$result->variables['access_token'] = $newToken->id;
$result->variables['refresh_token'] = $newToken->refresh_token;
$result->variables['expires_in'] = $tokenTTL;
return $result;
} | [
"public",
"function",
"doHandleRequest",
"(",
")",
"{",
"// Check that the correct params are present",
"// Params for token endpoint per section 4",
"// REQUIRED: grant_type, client_id, client_secret",
"// OPTIONAL: scope",
"//",
"// Supported grant types are: authorization_code and refresh_t... | Handles the POST request which is sent to obtain token data.
Currently only authorization code access grant is supported, section 4.1.1
@return ezcMvcResult | [
"Handles",
"the",
"POST",
"request",
"which",
"is",
"sent",
"to",
"obtain",
"token",
"data",
"."
] | 2493420f527fbc829a8d5bdda402e05d64a20db7 | https://github.com/ezsystems/ezpublish-legacy/blob/2493420f527fbc829a8d5bdda402e05d64a20db7/kernel/private/rest/classes/controllers/oauth_token.php#L26-L88 | train |
ezsystems/ezpublish-legacy | kernel/classes/eznodeviewfunctions.php | eZNodeviewfunctions.generateNodeView | static function generateNodeView( $tpl, $node, $object, $languageCode, $viewMode, $offset,
$cacheDir, $cachePath, $viewCacheEnabled,
$viewParameters = array( 'offset' => 0, 'year' => false, 'month' => false, 'day' => false ),
$collectionAttributes = false, $validation = false )
{
$cacheFile = eZClusterFileHandler::instance( $cachePath );
$args = compact( "tpl", "node", "object", "languageCode", "viewMode", "offset",
"viewCacheEnabled",
"viewParameters",
"collectionAttributes", "validation" );
$Result = $cacheFile->processCache( null, // no retrieve, only generate is called
array( 'eZNodeviewfunctions', 'generateCallback' ),
null,
null,
$args );
return $Result;
} | php | static function generateNodeView( $tpl, $node, $object, $languageCode, $viewMode, $offset,
$cacheDir, $cachePath, $viewCacheEnabled,
$viewParameters = array( 'offset' => 0, 'year' => false, 'month' => false, 'day' => false ),
$collectionAttributes = false, $validation = false )
{
$cacheFile = eZClusterFileHandler::instance( $cachePath );
$args = compact( "tpl", "node", "object", "languageCode", "viewMode", "offset",
"viewCacheEnabled",
"viewParameters",
"collectionAttributes", "validation" );
$Result = $cacheFile->processCache( null, // no retrieve, only generate is called
array( 'eZNodeviewfunctions', 'generateCallback' ),
null,
null,
$args );
return $Result;
} | [
"static",
"function",
"generateNodeView",
"(",
"$",
"tpl",
",",
"$",
"node",
",",
"$",
"object",
",",
"$",
"languageCode",
",",
"$",
"viewMode",
",",
"$",
"offset",
",",
"$",
"cacheDir",
",",
"$",
"cachePath",
",",
"$",
"viewCacheEnabled",
",",
"$",
"v... | Deprecated function for generating the view cache | [
"Deprecated",
"function",
"for",
"generating",
"the",
"view",
"cache"
] | 2493420f527fbc829a8d5bdda402e05d64a20db7 | https://github.com/ezsystems/ezpublish-legacy/blob/2493420f527fbc829a8d5bdda402e05d64a20db7/kernel/classes/eznodeviewfunctions.php#L20-L36 | train |
ezsystems/ezpublish-legacy | kernel/classes/eznodeviewfunctions.php | eZNodeviewfunctions.generateCallback | static function generateCallback( $file, $args )
{
extract( $args );
$res = eZNodeViewFunctions::generateNodeViewData( $tpl, $node, $object, $languageCode, $viewMode, $offset,
$viewParameters, $collectionAttributes, $validation );
// Check if cache time = 0 (viewcache disabled)
$store = $res['cache_ttl'] != 0;
// or if explicitly turned off
if ( !$viewCacheEnabled )
$store = false;
$retval = array( 'content' => $res,
'scope' => 'viewcache',
'store' => $store );
if ( $store )
$retval['binarydata'] = serialize( $res );
return $retval;
} | php | static function generateCallback( $file, $args )
{
extract( $args );
$res = eZNodeViewFunctions::generateNodeViewData( $tpl, $node, $object, $languageCode, $viewMode, $offset,
$viewParameters, $collectionAttributes, $validation );
// Check if cache time = 0 (viewcache disabled)
$store = $res['cache_ttl'] != 0;
// or if explicitly turned off
if ( !$viewCacheEnabled )
$store = false;
$retval = array( 'content' => $res,
'scope' => 'viewcache',
'store' => $store );
if ( $store )
$retval['binarydata'] = serialize( $res );
return $retval;
} | [
"static",
"function",
"generateCallback",
"(",
"$",
"file",
",",
"$",
"args",
")",
"{",
"extract",
"(",
"$",
"args",
")",
";",
"$",
"res",
"=",
"eZNodeViewFunctions",
"::",
"generateNodeViewData",
"(",
"$",
"tpl",
",",
"$",
"node",
",",
"$",
"object",
... | back to eZClusterFileHandler for processing. | [
"back",
"to",
"eZClusterFileHandler",
"for",
"processing",
"."
] | 2493420f527fbc829a8d5bdda402e05d64a20db7 | https://github.com/ezsystems/ezpublish-legacy/blob/2493420f527fbc829a8d5bdda402e05d64a20db7/kernel/classes/eznodeviewfunctions.php#L40-L60 | train |
ezsystems/ezpublish-legacy | kernel/classes/eznodeviewfunctions.php | eZNodeviewfunctions.contentViewGenerate | static public function contentViewGenerate( $file, $args )
{
extract( $args );
$node = eZContentObjectTreeNode::fetch( $NodeID );
if ( !$node instanceof eZContentObjectTreeNode )
{
if ( !eZDB::instance()->isConnected())
{
return self::contentViewGenerateError( $Module, eZError::KERNEL_NO_DB_CONNECTION, false );
}
return self::contentViewGenerateError( $Module, eZError::KERNEL_NOT_AVAILABLE );
}
$object = $node->attribute( 'object' );
if ( !$object instanceof eZContentObject )
{
return self::contentViewGenerateError( $Module, eZError::KERNEL_NOT_AVAILABLE );
}
if ( $node->attribute( 'is_invisible' ) && !eZContentObjectTreeNode::showInvisibleNodes() )
{
return self::contentViewGenerateError( $Module, eZError::KERNEL_ACCESS_DENIED );
}
if ( !$node->canRead() )
{
return self::contentViewGenerateError(
$Module,
eZError::KERNEL_ACCESS_DENIED,
true,
array( 'AccessList' => $node->checkAccess( 'read', false, false, true ) )
);
}
$result = self::generateNodeViewData(
$tpl,
$node,
$object,
$LanguageCode,
$ViewMode,
$Offset,
$viewParameters,
$collectionAttributes,
$validation
);
// 'store' depends on noCache: if $noCache is set, this means that retrieve
// returned it, and the noCache fake cache file is already stored
// and should not be stored again
$retval = array( 'content' => $result,
'scope' => 'viewcache',
'store' => !( isset( $noCache ) and $noCache ) );
if ( $file !== false && $retval['store'] )
$retval['binarydata'] = serialize( $result );
return $retval;
} | php | static public function contentViewGenerate( $file, $args )
{
extract( $args );
$node = eZContentObjectTreeNode::fetch( $NodeID );
if ( !$node instanceof eZContentObjectTreeNode )
{
if ( !eZDB::instance()->isConnected())
{
return self::contentViewGenerateError( $Module, eZError::KERNEL_NO_DB_CONNECTION, false );
}
return self::contentViewGenerateError( $Module, eZError::KERNEL_NOT_AVAILABLE );
}
$object = $node->attribute( 'object' );
if ( !$object instanceof eZContentObject )
{
return self::contentViewGenerateError( $Module, eZError::KERNEL_NOT_AVAILABLE );
}
if ( $node->attribute( 'is_invisible' ) && !eZContentObjectTreeNode::showInvisibleNodes() )
{
return self::contentViewGenerateError( $Module, eZError::KERNEL_ACCESS_DENIED );
}
if ( !$node->canRead() )
{
return self::contentViewGenerateError(
$Module,
eZError::KERNEL_ACCESS_DENIED,
true,
array( 'AccessList' => $node->checkAccess( 'read', false, false, true ) )
);
}
$result = self::generateNodeViewData(
$tpl,
$node,
$object,
$LanguageCode,
$ViewMode,
$Offset,
$viewParameters,
$collectionAttributes,
$validation
);
// 'store' depends on noCache: if $noCache is set, this means that retrieve
// returned it, and the noCache fake cache file is already stored
// and should not be stored again
$retval = array( 'content' => $result,
'scope' => 'viewcache',
'store' => !( isset( $noCache ) and $noCache ) );
if ( $file !== false && $retval['store'] )
$retval['binarydata'] = serialize( $result );
return $retval;
} | [
"static",
"public",
"function",
"contentViewGenerate",
"(",
"$",
"file",
",",
"$",
"args",
")",
"{",
"extract",
"(",
"$",
"args",
")",
";",
"$",
"node",
"=",
"eZContentObjectTreeNode",
"::",
"fetch",
"(",
"$",
"NodeID",
")",
";",
"if",
"(",
"!",
"$",
... | Generate convent view data
@see contentViewRetrieve()
@param string|false $file File in which the result will be cached
@param array $args Hash containing arguments, the used ones are:
- NodeID
- Module
- tpl
- LanguageCode
- ViewMode
- Offset
- viewParameters
- collectionAttributes
- validation
- noCache (optional)
@return array | [
"Generate",
"convent",
"view",
"data"
] | 2493420f527fbc829a8d5bdda402e05d64a20db7 | https://github.com/ezsystems/ezpublish-legacy/blob/2493420f527fbc829a8d5bdda402e05d64a20db7/kernel/classes/eznodeviewfunctions.php#L567-L623 | train |
ezsystems/ezpublish-legacy | kernel/private/eztemplate/ezpattributeoperatorformatter.php | ezpAttributeOperatorFormatter.getType | protected function getType( $item )
{
$type = gettype( $item );
if ( is_object( $item ) )
$type .= "[" . get_class( $item ) . "]";
return $type;
} | php | protected function getType( $item )
{
$type = gettype( $item );
if ( is_object( $item ) )
$type .= "[" . get_class( $item ) . "]";
return $type;
} | [
"protected",
"function",
"getType",
"(",
"$",
"item",
")",
"{",
"$",
"type",
"=",
"gettype",
"(",
"$",
"item",
")",
";",
"if",
"(",
"is_object",
"(",
"$",
"item",
")",
")",
"$",
"type",
".=",
"\"[\"",
".",
"get_class",
"(",
"$",
"item",
")",
".",... | Returns type for given item
@param mixed $item
@return string | [
"Returns",
"type",
"for",
"given",
"item"
] | 2493420f527fbc829a8d5bdda402e05d64a20db7 | https://github.com/ezsystems/ezpublish-legacy/blob/2493420f527fbc829a8d5bdda402e05d64a20db7/kernel/private/eztemplate/ezpattributeoperatorformatter.php#L19-L26 | train |
ezsystems/ezpublish-legacy | kernel/private/eztemplate/ezpattributeoperatorformatter.php | ezpAttributeOperatorFormatter.getValue | protected function getValue( $item )
{
if ( is_bool( $item ) )
$value = $item ? "true" : "false";
else if ( is_array( $item ) )
$value = 'Array(' . count( $item ) . ')';
else if ( is_numeric( $item ) )
$value = $item;
else if ( is_string( $item ) )
$value = "'" . $item . "'";
else if ( is_object( $item ) )
$value = method_exists( $item, '__toString' ) ? (string)$item : 'Object';
else
$value = $item;
return $value;
} | php | protected function getValue( $item )
{
if ( is_bool( $item ) )
$value = $item ? "true" : "false";
else if ( is_array( $item ) )
$value = 'Array(' . count( $item ) . ')';
else if ( is_numeric( $item ) )
$value = $item;
else if ( is_string( $item ) )
$value = "'" . $item . "'";
else if ( is_object( $item ) )
$value = method_exists( $item, '__toString' ) ? (string)$item : 'Object';
else
$value = $item;
return $value;
} | [
"protected",
"function",
"getValue",
"(",
"$",
"item",
")",
"{",
"if",
"(",
"is_bool",
"(",
"$",
"item",
")",
")",
"$",
"value",
"=",
"$",
"item",
"?",
"\"true\"",
":",
"\"false\"",
";",
"else",
"if",
"(",
"is_array",
"(",
"$",
"item",
")",
")",
... | Returns value for given item
@param mixed $item
@return string | [
"Returns",
"value",
"for",
"given",
"item"
] | 2493420f527fbc829a8d5bdda402e05d64a20db7 | https://github.com/ezsystems/ezpublish-legacy/blob/2493420f527fbc829a8d5bdda402e05d64a20db7/kernel/private/eztemplate/ezpattributeoperatorformatter.php#L34-L50 | train |
ezsystems/ezpublish-legacy | kernel/private/rest/classes/debug/debug.php | ezpRestDebug.getReport | public function getReport()
{
$report = array();
$report['restDebug'] = $this->debug->generateOutput();
$reportEZDebug = $this->eZDebug->printReportInternal( false );
$report['eZDebug'] = explode( "\n", $reportEZDebug );
return $report;
} | php | public function getReport()
{
$report = array();
$report['restDebug'] = $this->debug->generateOutput();
$reportEZDebug = $this->eZDebug->printReportInternal( false );
$report['eZDebug'] = explode( "\n", $reportEZDebug );
return $report;
} | [
"public",
"function",
"getReport",
"(",
")",
"{",
"$",
"report",
"=",
"array",
"(",
")",
";",
"$",
"report",
"[",
"'restDebug'",
"]",
"=",
"$",
"this",
"->",
"debug",
"->",
"generateOutput",
"(",
")",
";",
"$",
"reportEZDebug",
"=",
"$",
"this",
"->"... | Returns debug report | [
"Returns",
"debug",
"report"
] | 2493420f527fbc829a8d5bdda402e05d64a20db7 | https://github.com/ezsystems/ezpublish-legacy/blob/2493420f527fbc829a8d5bdda402e05d64a20db7/kernel/private/rest/classes/debug/debug.php#L82-L93 | train |
ezsystems/ezpublish-legacy | kernel/classes/ezcontentlanguage.php | eZContentLanguage.addLanguage | static function addLanguage( $locale, $name = null )
{
$localeObject = eZLocale::instance( $locale );
if ( !$localeObject )
{
eZDebug::writeError( "No such locale $locale!", __METHOD__ );
return false;
}
if ( $name === null )
{
$name = $localeObject->attribute( 'intl_language_name' );
}
$db = eZDB::instance();
$languages = eZContentLanguage::fetchList( true );
if ( ( $existingLanguage = eZContentLanguage::fetchByLocale( $locale ) ) )
{
eZDebug::writeWarning( "Language '$locale' already exists!", __METHOD__ );
return $existingLanguage;
}
if ( count( $languages ) >= self::maxCount() )
{
eZDebug::writeError( 'Too many languages, cannot add more!', __METHOD__ );
return false;
}
$db->lock( 'ezcontent_language' );
$idSum = 0;
foreach( $languages as $language )
{
$idSum += $language->attribute( 'id' );
}
// ID 1 is reserved
$candidateId = 2;
while ( $idSum & $candidateId )
{
$candidateId *= 2;
}
$newLanguage = new eZContentLanguage( array(
'id' => $candidateId,
'locale' => $locale,
'name' => $name,
'disabled' => 0 ) );
$newLanguage->store();
$db->unlock();
eZContentLanguage::fetchList( true );
// clear the cache
eZContentCacheManager::clearAllContentCache();
return $newLanguage;
} | php | static function addLanguage( $locale, $name = null )
{
$localeObject = eZLocale::instance( $locale );
if ( !$localeObject )
{
eZDebug::writeError( "No such locale $locale!", __METHOD__ );
return false;
}
if ( $name === null )
{
$name = $localeObject->attribute( 'intl_language_name' );
}
$db = eZDB::instance();
$languages = eZContentLanguage::fetchList( true );
if ( ( $existingLanguage = eZContentLanguage::fetchByLocale( $locale ) ) )
{
eZDebug::writeWarning( "Language '$locale' already exists!", __METHOD__ );
return $existingLanguage;
}
if ( count( $languages ) >= self::maxCount() )
{
eZDebug::writeError( 'Too many languages, cannot add more!', __METHOD__ );
return false;
}
$db->lock( 'ezcontent_language' );
$idSum = 0;
foreach( $languages as $language )
{
$idSum += $language->attribute( 'id' );
}
// ID 1 is reserved
$candidateId = 2;
while ( $idSum & $candidateId )
{
$candidateId *= 2;
}
$newLanguage = new eZContentLanguage( array(
'id' => $candidateId,
'locale' => $locale,
'name' => $name,
'disabled' => 0 ) );
$newLanguage->store();
$db->unlock();
eZContentLanguage::fetchList( true );
// clear the cache
eZContentCacheManager::clearAllContentCache();
return $newLanguage;
} | [
"static",
"function",
"addLanguage",
"(",
"$",
"locale",
",",
"$",
"name",
"=",
"null",
")",
"{",
"$",
"localeObject",
"=",
"eZLocale",
"::",
"instance",
"(",
"$",
"locale",
")",
";",
"if",
"(",
"!",
"$",
"localeObject",
")",
"{",
"eZDebug",
"::",
"w... | Adds new language to the site.
\param locale Locale code (e.g. 'slk-SK') of language to add.
\param name Optional. Name of the language. If not specified, the international language name for the $locale locale
will be used.
\return eZContentLanguage object of the added language (or the existing one if specified language has been already used)
or false in case of any error (invalid locale code or already reached eZContentLanguage::maxCount() languages).
\static | [
"Adds",
"new",
"language",
"to",
"the",
"site",
"."
] | 2493420f527fbc829a8d5bdda402e05d64a20db7 | https://github.com/ezsystems/ezpublish-legacy/blob/2493420f527fbc829a8d5bdda402e05d64a20db7/kernel/classes/ezcontentlanguage.php#L52-L112 | train |
ezsystems/ezpublish-legacy | kernel/classes/ezcontentlanguage.php | eZContentLanguage.removeLanguage | static function removeLanguage( $id )
{
$language = eZContentLanguage::fetch( $id );
if ( $language )
{
return $language->removeThis();
}
else
{
return false;
}
} | php | static function removeLanguage( $id )
{
$language = eZContentLanguage::fetch( $id );
if ( $language )
{
return $language->removeThis();
}
else
{
return false;
}
} | [
"static",
"function",
"removeLanguage",
"(",
"$",
"id",
")",
"{",
"$",
"language",
"=",
"eZContentLanguage",
"::",
"fetch",
"(",
"$",
"id",
")",
";",
"if",
"(",
"$",
"language",
")",
"{",
"return",
"$",
"language",
"->",
"removeThis",
"(",
")",
";",
... | Removes the language specified by ID.
\param id ID of the language to be removed.
\return True if the language was removed from the site, false otherwise.
\static | [
"Removes",
"the",
"language",
"specified",
"by",
"ID",
"."
] | 2493420f527fbc829a8d5bdda402e05d64a20db7 | https://github.com/ezsystems/ezpublish-legacy/blob/2493420f527fbc829a8d5bdda402e05d64a20db7/kernel/classes/ezcontentlanguage.php#L121-L132 | train |
ezsystems/ezpublish-legacy | kernel/classes/ezcontentlanguage.php | eZContentLanguage.removeThis | function removeThis()
{
if ( ($this->objectCount() > 0) or ($this->classCount() > 0) )
{
return false;
}
$this->remove();
eZContentCacheManager::clearAllContentCache();
eZContentLanguage::fetchList( true );
return true;
} | php | function removeThis()
{
if ( ($this->objectCount() > 0) or ($this->classCount() > 0) )
{
return false;
}
$this->remove();
eZContentCacheManager::clearAllContentCache();
eZContentLanguage::fetchList( true );
return true;
} | [
"function",
"removeThis",
"(",
")",
"{",
"if",
"(",
"(",
"$",
"this",
"->",
"objectCount",
"(",
")",
">",
"0",
")",
"or",
"(",
"$",
"this",
"->",
"classCount",
"(",
")",
">",
"0",
")",
")",
"{",
"return",
"false",
";",
"}",
"$",
"this",
"->",
... | Removes the language if there is no object having translation in it.
\return True if the language was removed from the site, false otherwise. | [
"Removes",
"the",
"language",
"if",
"there",
"is",
"no",
"object",
"having",
"translation",
"in",
"it",
"."
] | 2493420f527fbc829a8d5bdda402e05d64a20db7 | https://github.com/ezsystems/ezpublish-legacy/blob/2493420f527fbc829a8d5bdda402e05d64a20db7/kernel/classes/ezcontentlanguage.php#L139-L153 | train |
ezsystems/ezpublish-legacy | kernel/classes/ezcontentlanguage.php | eZContentLanguage.fetchList | static function fetchList( $forceReloading = false )
{
if( isset( $GLOBALS['eZContentLanguageList'] ) && $forceReloading === false )
return $GLOBALS['eZContentLanguageList'];
$cachePath = eZSys::cacheDirectory() . '/ezcontentlanguage_cache.php';
$clusterFileHandler = eZClusterFileHandler::instance( $cachePath );
if( $forceReloading || !$clusterFileHandler->fileExists( $cachePath ) )
{
$languages = eZPersistentObject::fetchObjectList( eZContentLanguage::definition() );
$clusterFileHandler->fileStoreContents( $cachePath, serialize( $languages ), 'content', 'php' );
}
else
{
$languages = unserialize( $clusterFileHandler->fetchContents() );
// If for some reason unserialize operation fails, we force the cache file to regenerate
// See http://issues.ez.no/18613
if ( $languages === false )
{
eZDebug::writeError(
"An error occurred while reading content language cache file $cachePath. File is being re-generated",
__METHOD__
);
return self::fetchList( true );
}
}
unset( $GLOBALS['eZContentLanguageList'] );
unset( $GLOBALS['eZContentLanguageMask'] );
$GLOBALS['eZContentLanguageList'] = array();
$mask = 1; // we want have 0-th bit set too!
foreach ( $languages as $language )
{
$GLOBALS['eZContentLanguageList'][$language->attribute( 'id' )] = $language;
$mask += $language->attribute( 'id' );
}
$GLOBALS['eZContentLanguageMask'] = $mask;
return $GLOBALS['eZContentLanguageList'];
} | php | static function fetchList( $forceReloading = false )
{
if( isset( $GLOBALS['eZContentLanguageList'] ) && $forceReloading === false )
return $GLOBALS['eZContentLanguageList'];
$cachePath = eZSys::cacheDirectory() . '/ezcontentlanguage_cache.php';
$clusterFileHandler = eZClusterFileHandler::instance( $cachePath );
if( $forceReloading || !$clusterFileHandler->fileExists( $cachePath ) )
{
$languages = eZPersistentObject::fetchObjectList( eZContentLanguage::definition() );
$clusterFileHandler->fileStoreContents( $cachePath, serialize( $languages ), 'content', 'php' );
}
else
{
$languages = unserialize( $clusterFileHandler->fetchContents() );
// If for some reason unserialize operation fails, we force the cache file to regenerate
// See http://issues.ez.no/18613
if ( $languages === false )
{
eZDebug::writeError(
"An error occurred while reading content language cache file $cachePath. File is being re-generated",
__METHOD__
);
return self::fetchList( true );
}
}
unset( $GLOBALS['eZContentLanguageList'] );
unset( $GLOBALS['eZContentLanguageMask'] );
$GLOBALS['eZContentLanguageList'] = array();
$mask = 1; // we want have 0-th bit set too!
foreach ( $languages as $language )
{
$GLOBALS['eZContentLanguageList'][$language->attribute( 'id' )] = $language;
$mask += $language->attribute( 'id' );
}
$GLOBALS['eZContentLanguageMask'] = $mask;
return $GLOBALS['eZContentLanguageList'];
} | [
"static",
"function",
"fetchList",
"(",
"$",
"forceReloading",
"=",
"false",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"GLOBALS",
"[",
"'eZContentLanguageList'",
"]",
")",
"&&",
"$",
"forceReloading",
"===",
"false",
")",
"return",
"$",
"GLOBALS",
"[",
"'eZC... | Fetches the list of the languages used on the site.
\param forceReloading Optional. If true, the list will be fetched from database even if it is cached in memory.
Default value is false.
\return Array of the eZContentLanguage objects of languages used on the site.
\static | [
"Fetches",
"the",
"list",
"of",
"the",
"languages",
"used",
"on",
"the",
"site",
"."
] | 2493420f527fbc829a8d5bdda402e05d64a20db7 | https://github.com/ezsystems/ezpublish-legacy/blob/2493420f527fbc829a8d5bdda402e05d64a20db7/kernel/classes/ezcontentlanguage.php#L163-L204 | train |
ezsystems/ezpublish-legacy | kernel/classes/ezcontentlanguage.php | eZContentLanguage.fetchLimitationList | static function fetchLimitationList( $forceReloading = false )
{
$languages = array();
foreach ( eZContentLanguage::fetchList( $forceReloading ) as $language )
{
$languages[] = array( 'name' => $language->attribute( 'name' ),
'id' => $language->attribute( 'locale' ) );
}
return $languages;
} | php | static function fetchLimitationList( $forceReloading = false )
{
$languages = array();
foreach ( eZContentLanguage::fetchList( $forceReloading ) as $language )
{
$languages[] = array( 'name' => $language->attribute( 'name' ),
'id' => $language->attribute( 'locale' ) );
}
return $languages;
} | [
"static",
"function",
"fetchLimitationList",
"(",
"$",
"forceReloading",
"=",
"false",
")",
"{",
"$",
"languages",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"eZContentLanguage",
"::",
"fetchList",
"(",
"$",
"forceReloading",
")",
"as",
"$",
"language",
")... | Fetches the array with names and IDs of the languages used on the site. This method is used by the permission system.
\param forceReloading Optional. If true, the list will be fetched from database even if it is cached in memory.
Default value is false.
\return Array with names and IDs of the languages used on the site.
\static | [
"Fetches",
"the",
"array",
"with",
"names",
"and",
"IDs",
"of",
"the",
"languages",
"used",
"on",
"the",
"site",
".",
"This",
"method",
"is",
"used",
"by",
"the",
"permission",
"system",
"."
] | 2493420f527fbc829a8d5bdda402e05d64a20db7 | https://github.com/ezsystems/ezpublish-legacy/blob/2493420f527fbc829a8d5bdda402e05d64a20db7/kernel/classes/ezcontentlanguage.php#L214-L223 | train |
ezsystems/ezpublish-legacy | kernel/classes/ezcontentlanguage.php | eZContentLanguage.fetchLocaleList | static function fetchLocaleList()
{
$languages = eZContentLanguage::fetchList();
$localeList = array();
foreach ( $languages as $language )
{
$localeList[] = $language->attribute( 'locale' );
}
return $localeList;
} | php | static function fetchLocaleList()
{
$languages = eZContentLanguage::fetchList();
$localeList = array();
foreach ( $languages as $language )
{
$localeList[] = $language->attribute( 'locale' );
}
return $localeList;
} | [
"static",
"function",
"fetchLocaleList",
"(",
")",
"{",
"$",
"languages",
"=",
"eZContentLanguage",
"::",
"fetchList",
"(",
")",
";",
"$",
"localeList",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"languages",
"as",
"$",
"language",
")",
"{",
"$",
... | Fetches the array of locale codes of the languages used on the site.
\return Array of locale codes of the languages used on the site.
\static | [
"Fetches",
"the",
"array",
"of",
"locale",
"codes",
"of",
"the",
"languages",
"used",
"on",
"the",
"site",
"."
] | 2493420f527fbc829a8d5bdda402e05d64a20db7 | https://github.com/ezsystems/ezpublish-legacy/blob/2493420f527fbc829a8d5bdda402e05d64a20db7/kernel/classes/ezcontentlanguage.php#L231-L242 | train |
ezsystems/ezpublish-legacy | kernel/classes/ezcontentlanguage.php | eZContentLanguage.fetch | static function fetch( $id )
{
$languages = eZContentLanguage::fetchList();
return isset( $languages[$id] )? $languages[$id]: false;
} | php | static function fetch( $id )
{
$languages = eZContentLanguage::fetchList();
return isset( $languages[$id] )? $languages[$id]: false;
} | [
"static",
"function",
"fetch",
"(",
"$",
"id",
")",
"{",
"$",
"languages",
"=",
"eZContentLanguage",
"::",
"fetchList",
"(",
")",
";",
"return",
"isset",
"(",
"$",
"languages",
"[",
"$",
"id",
"]",
")",
"?",
"$",
"languages",
"[",
"$",
"id",
"]",
"... | Fetches the language identified by ID.
\param id Identifier of the language to fetch.
\return eZContentLanguage object of language identified by ID $id.
\static | [
"Fetches",
"the",
"language",
"identified",
"by",
"ID",
"."
] | 2493420f527fbc829a8d5bdda402e05d64a20db7 | https://github.com/ezsystems/ezpublish-legacy/blob/2493420f527fbc829a8d5bdda402e05d64a20db7/kernel/classes/ezcontentlanguage.php#L251-L256 | train |
ezsystems/ezpublish-legacy | kernel/classes/ezcontentlanguage.php | eZContentLanguage.fetchByLocale | static function fetchByLocale( $locale, $createIfNotExist = false )
{
$languages = eZContentLanguage::fetchList();
foreach ( $languages as $language )
{
if ( $language->attribute( 'locale' ) == $locale )
{
return $language;
}
}
$language = false;
if ( $createIfNotExist )
{
$language = eZContentLanguage::addLanguage( $locale );
}
return $language;
} | php | static function fetchByLocale( $locale, $createIfNotExist = false )
{
$languages = eZContentLanguage::fetchList();
foreach ( $languages as $language )
{
if ( $language->attribute( 'locale' ) == $locale )
{
return $language;
}
}
$language = false;
if ( $createIfNotExist )
{
$language = eZContentLanguage::addLanguage( $locale );
}
return $language;
} | [
"static",
"function",
"fetchByLocale",
"(",
"$",
"locale",
",",
"$",
"createIfNotExist",
"=",
"false",
")",
"{",
"$",
"languages",
"=",
"eZContentLanguage",
"::",
"fetchList",
"(",
")",
";",
"foreach",
"(",
"$",
"languages",
"as",
"$",
"language",
")",
"{"... | Fetches the language identified by locale code.
\param locale Locale of the language to fetch, e. g. 'slk-SK'.
\return eZContentLanguage object identified by locale code $locale. | [
"Fetches",
"the",
"language",
"identified",
"by",
"locale",
"code",
"."
] | 2493420f527fbc829a8d5bdda402e05d64a20db7 | https://github.com/ezsystems/ezpublish-legacy/blob/2493420f527fbc829a8d5bdda402e05d64a20db7/kernel/classes/ezcontentlanguage.php#L264-L283 | train |
ezsystems/ezpublish-legacy | kernel/classes/ezcontentlanguage.php | eZContentLanguage.languagesByMask | static function languagesByMask( $mask )
{
$result = array();
$languages = eZContentLanguage::fetchList();
foreach ( $languages as $key => $language )
{
if ( (int) $key & (int) $mask )
{
$result[$language->attribute( 'locale' )] = $language;
}
}
return $result;
} | php | static function languagesByMask( $mask )
{
$result = array();
$languages = eZContentLanguage::fetchList();
foreach ( $languages as $key => $language )
{
if ( (int) $key & (int) $mask )
{
$result[$language->attribute( 'locale' )] = $language;
}
}
return $result;
} | [
"static",
"function",
"languagesByMask",
"(",
"$",
"mask",
")",
"{",
"$",
"result",
"=",
"array",
"(",
")",
";",
"$",
"languages",
"=",
"eZContentLanguage",
"::",
"fetchList",
"(",
")",
";",
"foreach",
"(",
"$",
"languages",
"as",
"$",
"key",
"=>",
"$"... | Returns array of languages which have set the corresponding bit in the mask.
\param mask Bitmap specifying which languages should be returned.
\return Array of eZContentLanguage objects of languages which have set the corresponding bit in $mask. | [
"Returns",
"array",
"of",
"languages",
"which",
"have",
"set",
"the",
"corresponding",
"bit",
"in",
"the",
"mask",
"."
] | 2493420f527fbc829a8d5bdda402e05d64a20db7 | https://github.com/ezsystems/ezpublish-legacy/blob/2493420f527fbc829a8d5bdda402e05d64a20db7/kernel/classes/ezcontentlanguage.php#L432-L446 | train |
ezsystems/ezpublish-legacy | kernel/classes/ezcontentlanguage.php | eZContentLanguage.prioritizedLanguagesByMask | static function prioritizedLanguagesByMask( $mask )
{
$result = array();
$languages = eZContentLanguage::prioritizedLanguages();
foreach ( $languages as $language )
{
if ( ( (int) $language->attribute( 'id' ) & (int) $mask ) > 0 )
{
$result[$language->attribute( 'locale' )] = $language;
}
}
return $result;
} | php | static function prioritizedLanguagesByMask( $mask )
{
$result = array();
$languages = eZContentLanguage::prioritizedLanguages();
foreach ( $languages as $language )
{
if ( ( (int) $language->attribute( 'id' ) & (int) $mask ) > 0 )
{
$result[$language->attribute( 'locale' )] = $language;
}
}
return $result;
} | [
"static",
"function",
"prioritizedLanguagesByMask",
"(",
"$",
"mask",
")",
"{",
"$",
"result",
"=",
"array",
"(",
")",
";",
"$",
"languages",
"=",
"eZContentLanguage",
"::",
"prioritizedLanguages",
"(",
")",
";",
"foreach",
"(",
"$",
"languages",
"as",
"$",
... | Returns array of prioritized languages which have set the corresponding bit in the mask.
\param mask Bitmap specifying which languages should be returned.
\return Array of eZContentLanguage objects of prioritized languages which have set the corresponding bit in $mask. | [
"Returns",
"array",
"of",
"prioritized",
"languages",
"which",
"have",
"set",
"the",
"corresponding",
"bit",
"in",
"the",
"mask",
"."
] | 2493420f527fbc829a8d5bdda402e05d64a20db7 | https://github.com/ezsystems/ezpublish-legacy/blob/2493420f527fbc829a8d5bdda402e05d64a20db7/kernel/classes/ezcontentlanguage.php#L454-L468 | train |
ezsystems/ezpublish-legacy | kernel/classes/ezcontentlanguage.php | eZContentLanguage.topPriorityLanguageByMask | static function topPriorityLanguageByMask( $mask )
{
$languages = eZContentLanguage::prioritizedLanguages();
foreach ( $languages as $language )
{
if ( ( (int) $language->attribute( 'id' ) & (int) $mask ) > 0 )
{
return $language;
}
}
return false;
} | php | static function topPriorityLanguageByMask( $mask )
{
$languages = eZContentLanguage::prioritizedLanguages();
foreach ( $languages as $language )
{
if ( ( (int) $language->attribute( 'id' ) & (int) $mask ) > 0 )
{
return $language;
}
}
return false;
} | [
"static",
"function",
"topPriorityLanguageByMask",
"(",
"$",
"mask",
")",
"{",
"$",
"languages",
"=",
"eZContentLanguage",
"::",
"prioritizedLanguages",
"(",
")",
";",
"foreach",
"(",
"$",
"languages",
"as",
"$",
"language",
")",
"{",
"if",
"(",
"(",
"(",
... | Returns the most prioritized language which has set the corresponding bit in the mask.
\param mask Bitmap specifying which languages should be checked.
\return eZContentLanguage object of the most prioritized language which have set the corresponding bit in $mask. | [
"Returns",
"the",
"most",
"prioritized",
"language",
"which",
"has",
"set",
"the",
"corresponding",
"bit",
"in",
"the",
"mask",
"."
] | 2493420f527fbc829a8d5bdda402e05d64a20db7 | https://github.com/ezsystems/ezpublish-legacy/blob/2493420f527fbc829a8d5bdda402e05d64a20db7/kernel/classes/ezcontentlanguage.php#L502-L513 | train |
ezsystems/ezpublish-legacy | kernel/classes/ezcontentlanguage.php | eZContentLanguage.maskByLocale | static function maskByLocale( $locales, $setZerothBit = false )
{
if ( !$locales )
{
return 0;
}
if ( !is_array( $locales ) )
{
$locales = array( $locales );
}
$mask = 0;
if ( $setZerothBit )
{
$mask = 1;
}
foreach( $locales as $locale )
{
$language = eZContentLanguage::fetchByLocale( $locale );
if ( $language )
{
$mask |= $language->attribute( 'id' );
}
}
return (int) $mask;
} | php | static function maskByLocale( $locales, $setZerothBit = false )
{
if ( !$locales )
{
return 0;
}
if ( !is_array( $locales ) )
{
$locales = array( $locales );
}
$mask = 0;
if ( $setZerothBit )
{
$mask = 1;
}
foreach( $locales as $locale )
{
$language = eZContentLanguage::fetchByLocale( $locale );
if ( $language )
{
$mask |= $language->attribute( 'id' );
}
}
return (int) $mask;
} | [
"static",
"function",
"maskByLocale",
"(",
"$",
"locales",
",",
"$",
"setZerothBit",
"=",
"false",
")",
"{",
"if",
"(",
"!",
"$",
"locales",
")",
"{",
"return",
"0",
";",
"}",
"if",
"(",
"!",
"is_array",
"(",
"$",
"locales",
")",
")",
"{",
"$",
"... | Returns bitmap mask for the specified languages.
\param locales Array of strings or a string specifying locale codes of the languages, e. g. 'slk-SK' or array( 'eng-GB', 'nor-NO' )
\param setZerothBit Optional. Specifies if the 0-th bit of mask should be set. False by default.
\return Bitmap mask having set the corresponding bits for the specified languages. | [
"Returns",
"bitmap",
"mask",
"for",
"the",
"specified",
"languages",
"."
] | 2493420f527fbc829a8d5bdda402e05d64a20db7 | https://github.com/ezsystems/ezpublish-legacy/blob/2493420f527fbc829a8d5bdda402e05d64a20db7/kernel/classes/ezcontentlanguage.php#L546-L574 | train |
ezsystems/ezpublish-legacy | kernel/classes/ezcontentlanguage.php | eZContentLanguage.idByLocale | static function idByLocale( $locale )
{
$language = eZContentLanguage::fetchByLocale( $locale );
if ( $language )
{
return (int)$language->attribute( 'id' );
}
else
{
return false;
}
} | php | static function idByLocale( $locale )
{
$language = eZContentLanguage::fetchByLocale( $locale );
if ( $language )
{
return (int)$language->attribute( 'id' );
}
else
{
return false;
}
} | [
"static",
"function",
"idByLocale",
"(",
"$",
"locale",
")",
"{",
"$",
"language",
"=",
"eZContentLanguage",
"::",
"fetchByLocale",
"(",
"$",
"locale",
")",
";",
"if",
"(",
"$",
"language",
")",
"{",
"return",
"(",
"int",
")",
"$",
"language",
"->",
"a... | \static
Returns id of the language specified.
\param locale String specifying locale code of the language, e. g. 'slk-SK'
\return ID of the language specified by locale or false if the language is not set on the site. | [
"\\",
"static",
"Returns",
"id",
"of",
"the",
"language",
"specified",
"."
] | 2493420f527fbc829a8d5bdda402e05d64a20db7 | https://github.com/ezsystems/ezpublish-legacy/blob/2493420f527fbc829a8d5bdda402e05d64a20db7/kernel/classes/ezcontentlanguage.php#L637-L648 | train |
ezsystems/ezpublish-legacy | kernel/classes/ezcontentlanguage.php | eZContentLanguage.objectCount | function objectCount()
{
$db = eZDB::instance();
$languageID = $this->ID;
if ( $db->databaseName() == 'oracle' )
{
$whereSQL = "bitand( language_mask, $languageID ) > 0";
}
else
{
$whereSQL = "language_mask & $languageID > 0";
}
$count = $db->arrayQuery( "SELECT COUNT(*) AS count FROM ezcontentobject WHERE $whereSQL" );
return $count[0]['count'];
} | php | function objectCount()
{
$db = eZDB::instance();
$languageID = $this->ID;
if ( $db->databaseName() == 'oracle' )
{
$whereSQL = "bitand( language_mask, $languageID ) > 0";
}
else
{
$whereSQL = "language_mask & $languageID > 0";
}
$count = $db->arrayQuery( "SELECT COUNT(*) AS count FROM ezcontentobject WHERE $whereSQL" );
return $count[0]['count'];
} | [
"function",
"objectCount",
"(",
")",
"{",
"$",
"db",
"=",
"eZDB",
"::",
"instance",
"(",
")",
";",
"$",
"languageID",
"=",
"$",
"this",
"->",
"ID",
";",
"if",
"(",
"$",
"db",
"->",
"databaseName",
"(",
")",
"==",
"'oracle'",
")",
"{",
"$",
"where... | \return The count of objects containing the translation in this language. | [
"\\",
"return",
"The",
"count",
"of",
"objects",
"containing",
"the",
"translation",
"in",
"this",
"language",
"."
] | 2493420f527fbc829a8d5bdda402e05d64a20db7 | https://github.com/ezsystems/ezpublish-legacy/blob/2493420f527fbc829a8d5bdda402e05d64a20db7/kernel/classes/ezcontentlanguage.php#L785-L801 | train |
ezsystems/ezpublish-legacy | kernel/classes/ezcontentlanguage.php | eZContentLanguage.jsArrayByMask | static function jsArrayByMask( $mask )
{
$localList = array();
$languages = eZContentLanguage::prioritizedLanguagesByMask( $mask );
foreach ( $languages as $key => $language )
{
$localList[] = array( 'locale' => $language->attribute( 'locale' ),
'name' => $language->attribute( 'name' ) );
}
if ( $localList )
{
return json_encode( $localList );
}
else
{
return false;
}
} | php | static function jsArrayByMask( $mask )
{
$localList = array();
$languages = eZContentLanguage::prioritizedLanguagesByMask( $mask );
foreach ( $languages as $key => $language )
{
$localList[] = array( 'locale' => $language->attribute( 'locale' ),
'name' => $language->attribute( 'name' ) );
}
if ( $localList )
{
return json_encode( $localList );
}
else
{
return false;
}
} | [
"static",
"function",
"jsArrayByMask",
"(",
"$",
"mask",
")",
"{",
"$",
"localList",
"=",
"array",
"(",
")",
";",
"$",
"languages",
"=",
"eZContentLanguage",
"::",
"prioritizedLanguagesByMask",
"(",
"$",
"mask",
")",
";",
"foreach",
"(",
"$",
"languages",
... | Returns the Javascript array with locale codes and names of the languages which have set the corresponding
bit in specified mask.
\param mask Bitmap mask specifying which languages should be considered.
\return JavaScript array described above. | [
"Returns",
"the",
"Javascript",
"array",
"with",
"locale",
"codes",
"and",
"names",
"of",
"the",
"languages",
"which",
"have",
"set",
"the",
"corresponding",
"bit",
"in",
"specified",
"mask",
"."
] | 2493420f527fbc829a8d5bdda402e05d64a20db7 | https://github.com/ezsystems/ezpublish-legacy/blob/2493420f527fbc829a8d5bdda402e05d64a20db7/kernel/classes/ezcontentlanguage.php#L878-L896 | train |
ezsystems/ezpublish-legacy | kernel/classes/ezcontentlanguage.php | eZContentLanguage.expireCache | static function expireCache( $expireCluster = true )
{
unset( $GLOBALS['eZContentLanguageList'],
$GLOBALS['eZContentLanguagePrioritizedLanguages'],
$GLOBALS['eZContentLanguageMask'],
$GLOBALS['eZContentLanguageCronjobMode'] );
// With the solution to #14227 we also need to clear the cached
// list of languages
if ( $expireCluster )
{
$cachePath = eZSys::cacheDirectory() . '/ezcontentlanguage_cache.php';
eZClusterFileHandler::instance()->fileDelete( $cachePath );
}
} | php | static function expireCache( $expireCluster = true )
{
unset( $GLOBALS['eZContentLanguageList'],
$GLOBALS['eZContentLanguagePrioritizedLanguages'],
$GLOBALS['eZContentLanguageMask'],
$GLOBALS['eZContentLanguageCronjobMode'] );
// With the solution to #14227 we also need to clear the cached
// list of languages
if ( $expireCluster )
{
$cachePath = eZSys::cacheDirectory() . '/ezcontentlanguage_cache.php';
eZClusterFileHandler::instance()->fileDelete( $cachePath );
}
} | [
"static",
"function",
"expireCache",
"(",
"$",
"expireCluster",
"=",
"true",
")",
"{",
"unset",
"(",
"$",
"GLOBALS",
"[",
"'eZContentLanguageList'",
"]",
",",
"$",
"GLOBALS",
"[",
"'eZContentLanguagePrioritizedLanguages'",
"]",
",",
"$",
"GLOBALS",
"[",
"'eZCont... | Removes all caches forcing it to read from database again for next method calls.
\static
@param bool $expireCluster whether expire cluster or not. | [
"Removes",
"all",
"caches",
"forcing",
"it",
"to",
"read",
"from",
"database",
"again",
"for",
"next",
"method",
"calls",
"."
] | 2493420f527fbc829a8d5bdda402e05d64a20db7 | https://github.com/ezsystems/ezpublish-legacy/blob/2493420f527fbc829a8d5bdda402e05d64a20db7/kernel/classes/ezcontentlanguage.php#L916-L930 | train |
ezsystems/ezpublish-legacy | kernel/classes/datatypes/ezimage/ezimagefile.php | eZImageFile.fetchImageAttributesByFilepath | static function fetchImageAttributesByFilepath( $filepath, $contentObjectAttributeID )
{
$db = eZDB::instance();
$contentObjectAttributeID = (int) $contentObjectAttributeID;
$cond = array( 'id' => $contentObjectAttributeID );
$fields = array( 'contentobject_id', 'contentclassattribute_id' );
$limit = array( 'offset' => 0, 'length' => 1 );
$rows = eZPersistentObject::fetchObjectList( eZContentObjectAttribute::definition(),
$fields,
$cond,
null,
$limit,
false );
if ( count( $rows ) != 1 )
return array();
$contentObjectID = (int)( $rows[0]['contentobject_id'] );
$contentClassAttributeID = (int)( $rows[0]['contentclassattribute_id'] );
// Transform ", &, < and > to entities since they are being transformed in entities by DOM
// See eZImageAliasHandler::initialize()
// Ref https://jira.ez.no/browse/EZP-20090
$filepath = $db->escapeString(
htmlspecialchars(
$filepath,
// Forcing default flags to be able to specify encoding. See http://php.net/htmlspecialchars
version_compare( PHP_VERSION, '5.4.0', '>=' ) ? ENT_COMPAT | ENT_HTML401 : ENT_COMPAT,
'UTF-8'
)
);
// Escape _ in like to avoid it to act as a wildcard !
$filepath = addcslashes( $filepath, "_" );
$query = "SELECT id, version, language_code
FROM ezcontentobject_attribute
WHERE contentobject_id = $contentObjectID AND
contentclassattribute_id = $contentClassAttributeID AND
data_text LIKE '%url=\"$filepath\"%'";
if ( $db->databaseName() == 'oracle' )
{
$query .= " ESCAPE '\'";
}
$rows = $db->arrayQuery( $query );
return $rows;
} | php | static function fetchImageAttributesByFilepath( $filepath, $contentObjectAttributeID )
{
$db = eZDB::instance();
$contentObjectAttributeID = (int) $contentObjectAttributeID;
$cond = array( 'id' => $contentObjectAttributeID );
$fields = array( 'contentobject_id', 'contentclassattribute_id' );
$limit = array( 'offset' => 0, 'length' => 1 );
$rows = eZPersistentObject::fetchObjectList( eZContentObjectAttribute::definition(),
$fields,
$cond,
null,
$limit,
false );
if ( count( $rows ) != 1 )
return array();
$contentObjectID = (int)( $rows[0]['contentobject_id'] );
$contentClassAttributeID = (int)( $rows[0]['contentclassattribute_id'] );
// Transform ", &, < and > to entities since they are being transformed in entities by DOM
// See eZImageAliasHandler::initialize()
// Ref https://jira.ez.no/browse/EZP-20090
$filepath = $db->escapeString(
htmlspecialchars(
$filepath,
// Forcing default flags to be able to specify encoding. See http://php.net/htmlspecialchars
version_compare( PHP_VERSION, '5.4.0', '>=' ) ? ENT_COMPAT | ENT_HTML401 : ENT_COMPAT,
'UTF-8'
)
);
// Escape _ in like to avoid it to act as a wildcard !
$filepath = addcslashes( $filepath, "_" );
$query = "SELECT id, version, language_code
FROM ezcontentobject_attribute
WHERE contentobject_id = $contentObjectID AND
contentclassattribute_id = $contentClassAttributeID AND
data_text LIKE '%url=\"$filepath\"%'";
if ( $db->databaseName() == 'oracle' )
{
$query .= " ESCAPE '\'";
}
$rows = $db->arrayQuery( $query );
return $rows;
} | [
"static",
"function",
"fetchImageAttributesByFilepath",
"(",
"$",
"filepath",
",",
"$",
"contentObjectAttributeID",
")",
"{",
"$",
"db",
"=",
"eZDB",
"::",
"instance",
"(",
")",
";",
"$",
"contentObjectAttributeID",
"=",
"(",
"int",
")",
"$",
"contentObjectAttri... | Looks up ezcontentobjectattribute entries matching an image filepath and
a contentobjectattribute ID
@param string $filePath file path to look up as URL in the XML string
@param int $contentObjectAttributeID
@return array An array with a series of ezcontentobject_attribute's id, version and language_code | [
"Looks",
"up",
"ezcontentobjectattribute",
"entries",
"matching",
"an",
"image",
"filepath",
"and",
"a",
"contentobjectattribute",
"ID"
] | 2493420f527fbc829a8d5bdda402e05d64a20db7 | https://github.com/ezsystems/ezpublish-legacy/blob/2493420f527fbc829a8d5bdda402e05d64a20db7/kernel/classes/datatypes/ezimage/ezimagefile.php#L80-L123 | train |
ezsystems/ezpublish-legacy | kernel/classes/ezcontentobjectversion.php | eZContentObjectVersion.hasConflicts | function hasConflicts( $editLanguage = false )
{
$object = $this->contentObject();
if ( !$editLanguage )
$editLanguage = $this->initialLanguageCode();
// Get versions (with published or archived status)
$versions = $object->versions( true, array( 'conditions' => array( 'status' => array( array( eZContentObjectVersion::STATUS_PUBLISHED, eZContentObjectVersion::STATUS_ARCHIVED ) ),
'language_code' => $editLanguage ) ) );
$conflictVersions = array();
foreach ( array_keys( $versions ) as $key )
{
$version =& $versions[$key];
if ( $version->attribute( 'modified' ) > $this->attribute( 'created' ) )
{
$conflictVersions[] = $version;
}
}
if ( !count( $conflictVersions ) )
{
return false;
}
return $conflictVersions;
} | php | function hasConflicts( $editLanguage = false )
{
$object = $this->contentObject();
if ( !$editLanguage )
$editLanguage = $this->initialLanguageCode();
// Get versions (with published or archived status)
$versions = $object->versions( true, array( 'conditions' => array( 'status' => array( array( eZContentObjectVersion::STATUS_PUBLISHED, eZContentObjectVersion::STATUS_ARCHIVED ) ),
'language_code' => $editLanguage ) ) );
$conflictVersions = array();
foreach ( array_keys( $versions ) as $key )
{
$version =& $versions[$key];
if ( $version->attribute( 'modified' ) > $this->attribute( 'created' ) )
{
$conflictVersions[] = $version;
}
}
if ( !count( $conflictVersions ) )
{
return false;
}
return $conflictVersions;
} | [
"function",
"hasConflicts",
"(",
"$",
"editLanguage",
"=",
"false",
")",
"{",
"$",
"object",
"=",
"$",
"this",
"->",
"contentObject",
"(",
")",
";",
"if",
"(",
"!",
"$",
"editLanguage",
")",
"$",
"editLanguage",
"=",
"$",
"this",
"->",
"initialLanguageCo... | \return array of version objects that caused conflict or false. | [
"\\",
"return",
"array",
"of",
"version",
"objects",
"that",
"caused",
"conflict",
"or",
"false",
"."
] | 2493420f527fbc829a8d5bdda402e05d64a20db7 | https://github.com/ezsystems/ezpublish-legacy/blob/2493420f527fbc829a8d5bdda402e05d64a20db7/kernel/classes/ezcontentobjectversion.php#L1805-L1830 | train |
ezsystems/ezpublish-legacy | kernel/rss/ezrssfunctioncollection.php | eZRSSFunctionCollection.exportByNode | static function exportByNode( $nodeID )
{
if ( !$nodeID )
return array( 'error' => array( 'error_type' => 'kernel',
'error_code' => eZError::KERNEL_NOT_FOUND ) );
$rssExport = eZPersistentObject::fetchObject( eZRSSExport::definition(),
null,
array( 'node_id' => $nodeID,
'status' => eZRSSExport::STATUS_VALID ),
true );
return array( 'result' => $rssExport );
} | php | static function exportByNode( $nodeID )
{
if ( !$nodeID )
return array( 'error' => array( 'error_type' => 'kernel',
'error_code' => eZError::KERNEL_NOT_FOUND ) );
$rssExport = eZPersistentObject::fetchObject( eZRSSExport::definition(),
null,
array( 'node_id' => $nodeID,
'status' => eZRSSExport::STATUS_VALID ),
true );
return array( 'result' => $rssExport );
} | [
"static",
"function",
"exportByNode",
"(",
"$",
"nodeID",
")",
"{",
"if",
"(",
"!",
"$",
"nodeID",
")",
"return",
"array",
"(",
"'error'",
"=>",
"array",
"(",
"'error_type'",
"=>",
"'kernel'",
",",
"'error_code'",
"=>",
"eZError",
"::",
"KERNEL_NOT_FOUND",
... | Return valid eZRSSExport object for a specific node if it exists.
@param int $nodeID
@return eZRSSExport|false Return value is inside a array with return value on result, as this is used as template fetch function. | [
"Return",
"valid",
"eZRSSExport",
"object",
"for",
"a",
"specific",
"node",
"if",
"it",
"exists",
"."
] | 2493420f527fbc829a8d5bdda402e05d64a20db7 | https://github.com/ezsystems/ezpublish-legacy/blob/2493420f527fbc829a8d5bdda402e05d64a20db7/kernel/rss/ezrssfunctioncollection.php#L37-L50 | train |
ezsystems/ezpublish-legacy | extension/ezoe/classes/ezoeserverfunctions.php | ezoeServerFunctions.getCacheTime | public static function getCacheTime( $functionName )
{
static $mtime = null;
if ( $mtime === null )
{
$mtime = filemtime( __FILE__ );
}
return $mtime;
} | php | public static function getCacheTime( $functionName )
{
static $mtime = null;
if ( $mtime === null )
{
$mtime = filemtime( __FILE__ );
}
return $mtime;
} | [
"public",
"static",
"function",
"getCacheTime",
"(",
"$",
"functionName",
")",
"{",
"static",
"$",
"mtime",
"=",
"null",
";",
"if",
"(",
"$",
"mtime",
"===",
"null",
")",
"{",
"$",
"mtime",
"=",
"filemtime",
"(",
"__FILE__",
")",
";",
"}",
"return",
... | getCacheTime
Expiry time for code generators registirated on this class.
Needs to be increased to current time when changes are done to returned translations.
@static
@param string $functionName | [
"getCacheTime",
"Expiry",
"time",
"for",
"code",
"generators",
"registirated",
"on",
"this",
"class",
".",
"Needs",
"to",
"be",
"increased",
"to",
"current",
"time",
"when",
"changes",
"are",
"done",
"to",
"returned",
"translations",
"."
] | 2493420f527fbc829a8d5bdda402e05d64a20db7 | https://github.com/ezsystems/ezpublish-legacy/blob/2493420f527fbc829a8d5bdda402e05d64a20db7/extension/ezoe/classes/ezoeserverfunctions.php#L554-L562 | train |
ezsystems/ezpublish-legacy | kernel/shop/classes/ezsimpleprice.php | eZSimplePrice.VATPercent | function VATPercent( $object = false, $country = false )
{
$VATType = $this->VATType();
if ( $object === false )
{
if ( $this->ContentObject === null )
return $VATType->attribute( 'percentage' );
$object = $this->ContentObject;
}
return $VATType->getPercentage( $object, $country );
} | php | function VATPercent( $object = false, $country = false )
{
$VATType = $this->VATType();
if ( $object === false )
{
if ( $this->ContentObject === null )
return $VATType->attribute( 'percentage' );
$object = $this->ContentObject;
}
return $VATType->getPercentage( $object, $country );
} | [
"function",
"VATPercent",
"(",
"$",
"object",
"=",
"false",
",",
"$",
"country",
"=",
"false",
")",
"{",
"$",
"VATType",
"=",
"$",
"this",
"->",
"VATType",
"(",
")",
";",
"if",
"(",
"$",
"object",
"===",
"false",
")",
"{",
"if",
"(",
"$",
"this",... | Can return dynamic percentage depending on product and country the user is from. | [
"Can",
"return",
"dynamic",
"percentage",
"depending",
"on",
"product",
"and",
"country",
"the",
"user",
"is",
"from",
"."
] | 2493420f527fbc829a8d5bdda402e05d64a20db7 | https://github.com/ezsystems/ezpublish-legacy/blob/2493420f527fbc829a8d5bdda402e05d64a20db7/kernel/shop/classes/ezsimpleprice.php#L216-L229 | train |
ezsystems/ezpublish-legacy | kernel/classes/ezcache.php | eZCache.clearAll | static function clearAll( $cacheList = false )
{
if ( !$cacheList )
$cacheList = eZCache::fetchList();
foreach ( $cacheList as $cacheItem )
{
eZCache::clearItem( $cacheItem );
}
return true;
} | php | static function clearAll( $cacheList = false )
{
if ( !$cacheList )
$cacheList = eZCache::fetchList();
foreach ( $cacheList as $cacheItem )
{
eZCache::clearItem( $cacheItem );
}
return true;
} | [
"static",
"function",
"clearAll",
"(",
"$",
"cacheList",
"=",
"false",
")",
"{",
"if",
"(",
"!",
"$",
"cacheList",
")",
"$",
"cacheList",
"=",
"eZCache",
"::",
"fetchList",
"(",
")",
";",
"foreach",
"(",
"$",
"cacheList",
"as",
"$",
"cacheItem",
")",
... | Clears all cache items.
@param bool $cacheList
@return bool True | [
"Clears",
"all",
"cache",
"items",
"."
] | 2493420f527fbc829a8d5bdda402e05d64a20db7 | https://github.com/ezsystems/ezpublish-legacy/blob/2493420f527fbc829a8d5bdda402e05d64a20db7/kernel/classes/ezcache.php#L383-L393 | train |
ezsystems/ezpublish-legacy | kernel/classes/ezcache.php | eZCache.clearImageAlias | static function clearImageAlias( $cacheItem )
{
$expiryHandler = eZExpiryHandler::instance();
$expiryHandler->setTimestamp( 'image-manager-alias', time() );
$expiryHandler->store();
ezpEvent::getInstance()->notify( 'image/invalidateAliases' );
} | php | static function clearImageAlias( $cacheItem )
{
$expiryHandler = eZExpiryHandler::instance();
$expiryHandler->setTimestamp( 'image-manager-alias', time() );
$expiryHandler->store();
ezpEvent::getInstance()->notify( 'image/invalidateAliases' );
} | [
"static",
"function",
"clearImageAlias",
"(",
"$",
"cacheItem",
")",
"{",
"$",
"expiryHandler",
"=",
"eZExpiryHandler",
"::",
"instance",
"(",
")",
";",
"$",
"expiryHandler",
"->",
"setTimestamp",
"(",
"'image-manager-alias'",
",",
"time",
"(",
")",
")",
";",
... | Sets the image alias timestamp to the current timestamp,
this causes all image aliases to be recreated on viewing. | [
"Sets",
"the",
"image",
"alias",
"timestamp",
"to",
"the",
"current",
"timestamp",
"this",
"causes",
"all",
"image",
"aliases",
"to",
"be",
"recreated",
"on",
"viewing",
"."
] | 2493420f527fbc829a8d5bdda402e05d64a20db7 | https://github.com/ezsystems/ezpublish-legacy/blob/2493420f527fbc829a8d5bdda402e05d64a20db7/kernel/classes/ezcache.php#L543-L549 | train |
ezsystems/ezpublish-legacy | kernel/classes/ezcache.php | eZCache.purgeImageAlias | static function purgeImageAlias( $cacheItem )
{
// 1. fetch ezcontentclass having an ezimage attribute
// 2. fetch objects of these classes
// 3. purge image alias for all version
$imageContentClassAttributes = eZContentClassAttribute::fetchList(
true,
array(
'data_type' => 'ezimage',
'version' => eZContentClass::VERSION_STATUS_DEFINED
)
);
$classIds = array();
$attributeIdentifiersByClass = array();
foreach ( $imageContentClassAttributes as $ccAttr )
{
$identifier = $ccAttr->attribute( 'identifier' );
$ccId = $ccAttr->attribute( 'contentclass_id' );
if ( !isset( $attributeIdentifiersByClass[$ccId] ) )
{
$attributeIdentifiersByClass[$ccId] = array();
}
$attributeIdentifiersByClass[$ccId][] = $identifier;
$classIds[] = $ccId;
}
$subTreeParams = array(
'ClassFilterType' => 'include',
'ClassFilterArray' => $classIds,
'MainNodeOnly' => true,
'IgnoreVisibility' => true,
'LoadDataMap' => false,
'Limit' => 100,
'Offset' => 0
);
$count = 0;
while ( true )
{
$nodes = eZContentObjectTreeNode::subTreeByNodeID( $subTreeParams, 1 );
if ( empty( $nodes ) )
{
break;
}
foreach ( $nodes as $node )
{
call_user_func( $cacheItem['reporter'], '', $count );
$object = $node->attribute( 'object' );
self::purgeImageAliasForObject(
$cacheItem, $object, $attributeIdentifiersByClass[$object->attribute( 'contentclass_id' )]
);
$count++;
}
eZContentObject::clearCache();
$subTreeParams['Offset'] += $subTreeParams['Limit'];
}
self::clearImageAlias( $cacheItem );
} | php | static function purgeImageAlias( $cacheItem )
{
// 1. fetch ezcontentclass having an ezimage attribute
// 2. fetch objects of these classes
// 3. purge image alias for all version
$imageContentClassAttributes = eZContentClassAttribute::fetchList(
true,
array(
'data_type' => 'ezimage',
'version' => eZContentClass::VERSION_STATUS_DEFINED
)
);
$classIds = array();
$attributeIdentifiersByClass = array();
foreach ( $imageContentClassAttributes as $ccAttr )
{
$identifier = $ccAttr->attribute( 'identifier' );
$ccId = $ccAttr->attribute( 'contentclass_id' );
if ( !isset( $attributeIdentifiersByClass[$ccId] ) )
{
$attributeIdentifiersByClass[$ccId] = array();
}
$attributeIdentifiersByClass[$ccId][] = $identifier;
$classIds[] = $ccId;
}
$subTreeParams = array(
'ClassFilterType' => 'include',
'ClassFilterArray' => $classIds,
'MainNodeOnly' => true,
'IgnoreVisibility' => true,
'LoadDataMap' => false,
'Limit' => 100,
'Offset' => 0
);
$count = 0;
while ( true )
{
$nodes = eZContentObjectTreeNode::subTreeByNodeID( $subTreeParams, 1 );
if ( empty( $nodes ) )
{
break;
}
foreach ( $nodes as $node )
{
call_user_func( $cacheItem['reporter'], '', $count );
$object = $node->attribute( 'object' );
self::purgeImageAliasForObject(
$cacheItem, $object, $attributeIdentifiersByClass[$object->attribute( 'contentclass_id' )]
);
$count++;
}
eZContentObject::clearCache();
$subTreeParams['Offset'] += $subTreeParams['Limit'];
}
self::clearImageAlias( $cacheItem );
} | [
"static",
"function",
"purgeImageAlias",
"(",
"$",
"cacheItem",
")",
"{",
"// 1. fetch ezcontentclass having an ezimage attribute",
"// 2. fetch objects of these classes",
"// 3. purge image alias for all version",
"$",
"imageContentClassAttributes",
"=",
"eZContentClassAttribute",
"::... | Purges the image aliases of all ezimage attribute. The original image is
kept.
@param array $cacheItem
@access public | [
"Purges",
"the",
"image",
"aliases",
"of",
"all",
"ezimage",
"attribute",
".",
"The",
"original",
"image",
"is",
"kept",
"."
] | 2493420f527fbc829a8d5bdda402e05d64a20db7 | https://github.com/ezsystems/ezpublish-legacy/blob/2493420f527fbc829a8d5bdda402e05d64a20db7/kernel/classes/ezcache.php#L558-L616 | train |
ezsystems/ezpublish-legacy | kernel/classes/ezcache.php | eZCache.purgeImageAliasForObject | private static function purgeImageAliasForObject( array $cacheItem, eZContentObject $object, array $imageIdentifiers )
{
$versions = $object->attribute( 'versions' );
foreach ( $versions as $version )
{
$dataMap = $version->attribute( 'data_map' );
foreach ( $imageIdentifiers as $identifier )
{
$attr = $dataMap[$identifier];
if ( !$attr instanceof eZContentObjectAttribute )
{
eZDebug::writeError( "Missing attribute $identifier in object " . $object->attribute( 'id' ) . ", version " . $version->attribute( 'version' ) . ". This indicates data corruption.", __METHOD__ );
}
elseif ( $attr->attribute( 'has_content' ) )
{
$attr->attribute( 'content' )->purgeAllAliases();
}
}
}
} | php | private static function purgeImageAliasForObject( array $cacheItem, eZContentObject $object, array $imageIdentifiers )
{
$versions = $object->attribute( 'versions' );
foreach ( $versions as $version )
{
$dataMap = $version->attribute( 'data_map' );
foreach ( $imageIdentifiers as $identifier )
{
$attr = $dataMap[$identifier];
if ( !$attr instanceof eZContentObjectAttribute )
{
eZDebug::writeError( "Missing attribute $identifier in object " . $object->attribute( 'id' ) . ", version " . $version->attribute( 'version' ) . ". This indicates data corruption.", __METHOD__ );
}
elseif ( $attr->attribute( 'has_content' ) )
{
$attr->attribute( 'content' )->purgeAllAliases();
}
}
}
} | [
"private",
"static",
"function",
"purgeImageAliasForObject",
"(",
"array",
"$",
"cacheItem",
",",
"eZContentObject",
"$",
"object",
",",
"array",
"$",
"imageIdentifiers",
")",
"{",
"$",
"versions",
"=",
"$",
"object",
"->",
"attribute",
"(",
"'versions'",
")",
... | The purge the image aliases in all versions of the content object.
@param array $cacheItem
@param eZContentObject $object
@param array $imageIdentifiers array of ezimage attribute identifiers | [
"The",
"purge",
"the",
"image",
"aliases",
"in",
"all",
"versions",
"of",
"the",
"content",
"object",
"."
] | 2493420f527fbc829a8d5bdda402e05d64a20db7 | https://github.com/ezsystems/ezpublish-legacy/blob/2493420f527fbc829a8d5bdda402e05d64a20db7/kernel/classes/ezcache.php#L625-L644 | train |
ezsystems/ezpublish-legacy | kernel/classes/ezcache.php | eZCache.clearTemplateBlockCache | static function clearTemplateBlockCache( $cacheItem )
{
$expiryHandler = eZExpiryHandler::instance();
$expiryHandler->setTimestamp( 'global-template-block-cache', time() );
$expiryHandler->store();
} | php | static function clearTemplateBlockCache( $cacheItem )
{
$expiryHandler = eZExpiryHandler::instance();
$expiryHandler->setTimestamp( 'global-template-block-cache', time() );
$expiryHandler->store();
} | [
"static",
"function",
"clearTemplateBlockCache",
"(",
"$",
"cacheItem",
")",
"{",
"$",
"expiryHandler",
"=",
"eZExpiryHandler",
"::",
"instance",
"(",
")",
";",
"$",
"expiryHandler",
"->",
"setTimestamp",
"(",
"'global-template-block-cache'",
",",
"time",
"(",
")"... | Removes all template block cache files and subtree entries. | [
"Removes",
"all",
"template",
"block",
"cache",
"files",
"and",
"subtree",
"entries",
"."
] | 2493420f527fbc829a8d5bdda402e05d64a20db7 | https://github.com/ezsystems/ezpublish-legacy/blob/2493420f527fbc829a8d5bdda402e05d64a20db7/kernel/classes/ezcache.php#L662-L667 | train |
ezsystems/ezpublish-legacy | kernel/classes/ezcache.php | eZCache.clearTemplateOverrideCache | static function clearTemplateOverrideCache( $cacheItem )
{
$cachePath = eZSys::cacheDirectory() . '/' . $cacheItem['path'];
eZDir::recursiveDelete( $cachePath );
eZTemplateDesignResource::clearInMemoryOverrideArray();
} | php | static function clearTemplateOverrideCache( $cacheItem )
{
$cachePath = eZSys::cacheDirectory() . '/' . $cacheItem['path'];
eZDir::recursiveDelete( $cachePath );
eZTemplateDesignResource::clearInMemoryOverrideArray();
} | [
"static",
"function",
"clearTemplateOverrideCache",
"(",
"$",
"cacheItem",
")",
"{",
"$",
"cachePath",
"=",
"eZSys",
"::",
"cacheDirectory",
"(",
")",
".",
"'/'",
".",
"$",
"cacheItem",
"[",
"'path'",
"]",
";",
"eZDir",
"::",
"recursiveDelete",
"(",
"$",
"... | Removes all template override cache files, subtree entries
and clears in memory override cache.
@since 4.2 | [
"Removes",
"all",
"template",
"override",
"cache",
"files",
"subtree",
"entries",
"and",
"clears",
"in",
"memory",
"override",
"cache",
"."
] | 2493420f527fbc829a8d5bdda402e05d64a20db7 | https://github.com/ezsystems/ezpublish-legacy/blob/2493420f527fbc829a8d5bdda402e05d64a20db7/kernel/classes/ezcache.php#L675-L680 | train |
ezsystems/ezpublish-legacy | kernel/classes/ezcache.php | eZCache.clearStateLimitations | static function clearStateLimitations( $cacheItem )
{
$cachePath = eZSys::cacheDirectory();
$fileHandler = eZClusterFileHandler::instance();
$fileHandler->fileDelete( $cachePath, 'statelimitations_' );
ezpEvent::getInstance()->notify( 'content/state/cache/all' );
} | php | static function clearStateLimitations( $cacheItem )
{
$cachePath = eZSys::cacheDirectory();
$fileHandler = eZClusterFileHandler::instance();
$fileHandler->fileDelete( $cachePath, 'statelimitations_' );
ezpEvent::getInstance()->notify( 'content/state/cache/all' );
} | [
"static",
"function",
"clearStateLimitations",
"(",
"$",
"cacheItem",
")",
"{",
"$",
"cachePath",
"=",
"eZSys",
"::",
"cacheDirectory",
"(",
")",
";",
"$",
"fileHandler",
"=",
"eZClusterFileHandler",
"::",
"instance",
"(",
")",
";",
"$",
"fileHandler",
"->",
... | Clears all state limitation cache files. | [
"Clears",
"all",
"state",
"limitation",
"cache",
"files",
"."
] | 2493420f527fbc829a8d5bdda402e05d64a20db7 | https://github.com/ezsystems/ezpublish-legacy/blob/2493420f527fbc829a8d5bdda402e05d64a20db7/kernel/classes/ezcache.php#L766-L773 | train |
ezsystems/ezpublish-legacy | kernel/classes/ezcache.php | eZCache.clearActiveExtensions | static function clearActiveExtensions( $cacheItem )
{
$handler = eZExpiryHandler::instance();
$handler->setTimestamp( $cacheItem['expiry-key'], time() );
$handler->store();
eZExtension::clearActiveExtensionsCache();
eZExtension::clearActiveExtensionsMemoryCache();
} | php | static function clearActiveExtensions( $cacheItem )
{
$handler = eZExpiryHandler::instance();
$handler->setTimestamp( $cacheItem['expiry-key'], time() );
$handler->store();
eZExtension::clearActiveExtensionsCache();
eZExtension::clearActiveExtensionsMemoryCache();
} | [
"static",
"function",
"clearActiveExtensions",
"(",
"$",
"cacheItem",
")",
"{",
"$",
"handler",
"=",
"eZExpiryHandler",
"::",
"instance",
"(",
")",
";",
"$",
"handler",
"->",
"setTimestamp",
"(",
"$",
"cacheItem",
"[",
"'expiry-key'",
"]",
",",
"time",
"(",
... | Clears active extensions list cache | [
"Clears",
"active",
"extensions",
"list",
"cache"
] | 2493420f527fbc829a8d5bdda402e05d64a20db7 | https://github.com/ezsystems/ezpublish-legacy/blob/2493420f527fbc829a8d5bdda402e05d64a20db7/kernel/classes/ezcache.php#L778-L786 | train |
ezsystems/ezpublish-legacy | kernel/classes/datatypes/ezmedia/ezmedia.php | eZMedia.fetchByContentObjectID | static function fetchByContentObjectID( $contentObjectID, $languageCode = null, $asObject = true )
{
$condition = array();
$condition['contentobject_id'] = $contentObjectID;
$condition['data_type_string'] = 'ezmedia';
if ( $languageCode != null )
{
$condition['language_code'] = $languageCode;
}
$custom = array( array( 'operation' => 'DISTINCT id',
'name' => 'id' ) );
$ids = eZPersistentObject::fetchObjectList( eZContentObjectAttribute::definition(),
array(),
$condition,
null,
null,
false,
false,
$custom );
$mediaFiles = array();
foreach ( $ids as $id )
{
$mediaFileObjectAttribute = eZMedia::fetch( $id['id'], null, $asObject );
$mediaFiles = array_merge( $mediaFiles, $mediaFileObjectAttribute );
}
return $mediaFiles;
} | php | static function fetchByContentObjectID( $contentObjectID, $languageCode = null, $asObject = true )
{
$condition = array();
$condition['contentobject_id'] = $contentObjectID;
$condition['data_type_string'] = 'ezmedia';
if ( $languageCode != null )
{
$condition['language_code'] = $languageCode;
}
$custom = array( array( 'operation' => 'DISTINCT id',
'name' => 'id' ) );
$ids = eZPersistentObject::fetchObjectList( eZContentObjectAttribute::definition(),
array(),
$condition,
null,
null,
false,
false,
$custom );
$mediaFiles = array();
foreach ( $ids as $id )
{
$mediaFileObjectAttribute = eZMedia::fetch( $id['id'], null, $asObject );
$mediaFiles = array_merge( $mediaFiles, $mediaFileObjectAttribute );
}
return $mediaFiles;
} | [
"static",
"function",
"fetchByContentObjectID",
"(",
"$",
"contentObjectID",
",",
"$",
"languageCode",
"=",
"null",
",",
"$",
"asObject",
"=",
"true",
")",
"{",
"$",
"condition",
"=",
"array",
"(",
")",
";",
"$",
"condition",
"[",
"'contentobject_id'",
"]",
... | Fetch media objects by content object id
@param int $contentObjectID contentobject id
@param string $languageCode language code
@param boolean $asObject if return object
@return array | [
"Fetch",
"media",
"objects",
"by",
"content",
"object",
"id"
] | 2493420f527fbc829a8d5bdda402e05d64a20db7 | https://github.com/ezsystems/ezpublish-legacy/blob/2493420f527fbc829a8d5bdda402e05d64a20db7/kernel/classes/datatypes/ezmedia/ezmedia.php#L191-L217 | train |
ezsystems/ezpublish-legacy | lib/ezi18n/classes/eztstranslator.php | eZTSTranslator.initialize | static function initialize( $context, $locale, $filename, $useCache = true )
{
$instance = false;
$file = $locale . '/' . $filename;
if ( !empty( $GLOBALS['eZTSTranslationTables'][$file] ) )
{
$instance = $GLOBALS['eZTSTranslationTables'][$file];
if ( $instance->hasInitializedContext( $context ) )
{
return $instance;
}
}
eZDebug::createAccumulatorGroup( 'tstranslator', 'TS translator' );
eZDebug::accumulatorStart( 'tstranslator_init', 'tstranslator', 'TS init' );
if ( !$instance )
{
$instance = new eZTSTranslator( $locale, $filename, $useCache );
$GLOBALS['eZTSTranslationTables'][$file] = $instance;
$manager = eZTranslatorManager::instance();
$manager->registerHandler( $instance );
}
$instance->load( $context );
eZDebug::accumulatorStop( 'tstranslator_init' );
return $instance;
} | php | static function initialize( $context, $locale, $filename, $useCache = true )
{
$instance = false;
$file = $locale . '/' . $filename;
if ( !empty( $GLOBALS['eZTSTranslationTables'][$file] ) )
{
$instance = $GLOBALS['eZTSTranslationTables'][$file];
if ( $instance->hasInitializedContext( $context ) )
{
return $instance;
}
}
eZDebug::createAccumulatorGroup( 'tstranslator', 'TS translator' );
eZDebug::accumulatorStart( 'tstranslator_init', 'tstranslator', 'TS init' );
if ( !$instance )
{
$instance = new eZTSTranslator( $locale, $filename, $useCache );
$GLOBALS['eZTSTranslationTables'][$file] = $instance;
$manager = eZTranslatorManager::instance();
$manager->registerHandler( $instance );
}
$instance->load( $context );
eZDebug::accumulatorStop( 'tstranslator_init' );
return $instance;
} | [
"static",
"function",
"initialize",
"(",
"$",
"context",
",",
"$",
"locale",
",",
"$",
"filename",
",",
"$",
"useCache",
"=",
"true",
")",
"{",
"$",
"instance",
"=",
"false",
";",
"$",
"file",
"=",
"$",
"locale",
".",
"'/'",
".",
"$",
"filename",
"... | Initialize the ts translator and context if this is not already done
@param string $context
@param string $locale
@param string $filename
@param bool $useCache
@return eZTSTranslator | [
"Initialize",
"the",
"ts",
"translator",
"and",
"context",
"if",
"this",
"is",
"not",
"already",
"done"
] | 2493420f527fbc829a8d5bdda402e05d64a20db7 | https://github.com/ezsystems/ezpublish-legacy/blob/2493420f527fbc829a8d5bdda402e05d64a20db7/lib/ezi18n/classes/eztstranslator.php#L53-L78 | train |
ezsystems/ezpublish-legacy | lib/ezi18n/classes/eztstranslator.php | eZTSTranslator.handleContextNode | function handleContextNode( $context )
{
$contextName = null;
$messages = array();
$context_children = $context->childNodes;
for( $i = 0; $i < $context_children->length; $i++ )
{
$context_child = $context_children->item( $i );
if ( $context_child->nodeType == XML_ELEMENT_NODE )
{
if ( $context_child->tagName == "name" )
{
$name_el = $context_child->firstChild;
if ( $name_el )
{
$contextName = $name_el->nodeValue;
}
}
break;
}
}
if ( !$contextName )
{
eZDebug::writeError( "No context name found, skipping context", __METHOD__ );
return false;
}
foreach( $context_children as $context_child )
{
if ( $context_child->nodeType == XML_ELEMENT_NODE )
{
$childName = $context_child->tagName;
if ( $childName == "message" )
{
$this->handleMessageNode( $contextName, $context_child );
}
else if ( $childName == "name" )
{
/* Skip name tags */
}
else
{
eZDebug::writeError( "Unknown element name: $childName", __METHOD__ );
}
}
}
if ( $contextName === null )
{
eZDebug::writeError( "No context name found, skipping context", __METHOD__ );
return false;
}
if ( !isset( $this->CachedMessages[$contextName] ) )
$this->CachedMessages[$contextName] = array();
return true;
} | php | function handleContextNode( $context )
{
$contextName = null;
$messages = array();
$context_children = $context->childNodes;
for( $i = 0; $i < $context_children->length; $i++ )
{
$context_child = $context_children->item( $i );
if ( $context_child->nodeType == XML_ELEMENT_NODE )
{
if ( $context_child->tagName == "name" )
{
$name_el = $context_child->firstChild;
if ( $name_el )
{
$contextName = $name_el->nodeValue;
}
}
break;
}
}
if ( !$contextName )
{
eZDebug::writeError( "No context name found, skipping context", __METHOD__ );
return false;
}
foreach( $context_children as $context_child )
{
if ( $context_child->nodeType == XML_ELEMENT_NODE )
{
$childName = $context_child->tagName;
if ( $childName == "message" )
{
$this->handleMessageNode( $contextName, $context_child );
}
else if ( $childName == "name" )
{
/* Skip name tags */
}
else
{
eZDebug::writeError( "Unknown element name: $childName", __METHOD__ );
}
}
}
if ( $contextName === null )
{
eZDebug::writeError( "No context name found, skipping context", __METHOD__ );
return false;
}
if ( !isset( $this->CachedMessages[$contextName] ) )
$this->CachedMessages[$contextName] = array();
return true;
} | [
"function",
"handleContextNode",
"(",
"$",
"context",
")",
"{",
"$",
"contextName",
"=",
"null",
";",
"$",
"messages",
"=",
"array",
"(",
")",
";",
"$",
"context_children",
"=",
"$",
"context",
"->",
"childNodes",
";",
"for",
"(",
"$",
"i",
"=",
"0",
... | Handles a DOM Context node and the messages it contains
@param DOMNode $context
@return bool | [
"Handles",
"a",
"DOM",
"Context",
"node",
"and",
"the",
"messages",
"it",
"contains"
] | 2493420f527fbc829a8d5bdda402e05d64a20db7 | https://github.com/ezsystems/ezpublish-legacy/blob/2493420f527fbc829a8d5bdda402e05d64a20db7/lib/ezi18n/classes/eztstranslator.php#L386-L441 | train |
ezsystems/ezpublish-legacy | lib/ezi18n/classes/eztstranslator.php | eZTSTranslator.handleMessageNode | function handleMessageNode( $contextName, $message )
{
$source = null;
$translation = null;
$comment = null;
$message_children = $message->childNodes;
for( $i = 0; $i < $message_children->length; $i++ )
{
$message_child = $message_children->item( $i );
if ( $message_child->nodeType == XML_ELEMENT_NODE )
{
$childName = $message_child->tagName;
if ( $childName == "source" )
{
if ( $message_child->childNodes->length > 0 )
{
$source = '';
foreach ( $message_child->childNodes as $textEl )
{
if ( $textEl instanceof DOMText )
{
$source .= $textEl->nodeValue;
}
else if ( $textEl instanceof DOMElement && $textEl->tagName == 'byte' )
{
$source .= chr( intval( '0' . $textEl->getAttribute( 'value' ) ) );
}
}
}
}
else if ( $childName == "translation" )
{
if ( $message_child->childNodes->length > 0 )
{
$translation = '';
foreach ( $message_child->childNodes as $textEl )
{
if ( $textEl instanceof DOMText )
{
$translation .= $textEl->nodeValue;
}
else if ( $textEl instanceof DOMElement && $textEl->tagName == 'byte' )
{
$translation .= chr( intval( '0' . $textEl->getAttribute( 'value' ) ) );
}
}
}
}
else if ( $childName == "comment" )
{
$comment_el = $message_child->firstChild;
$comment = $comment_el->nodeValue;
}
else if ( $childName == "translatorcomment" )
{
//Ignore it.
}
else if ( $childName == "location" )
{
//Handle location element. No functionality yet.
}
else
eZDebug::writeError( "Unknown element name: " . $childName, __METHOD__ );
}
}
if ( $source === null )
{
eZDebug::writeError( "No source name found, skipping message in context '{$contextName}'", __METHOD__ );
return false;
}
if ( $translation === null ) // No translation provided, then take the source as a reference
{
// eZDebug::writeError( "No translation, skipping message", __METHOD__ );
$translation = $source;
}
/* we need to convert ourselves if we're using libxml stuff here */
if ( $message instanceof DOMElement )
{
$codec = eZTextCodec::instance( "utf8" );
$source = $codec->convertString( $source );
$translation = $codec->convertString( $translation );
$comment = $codec->convertString( $comment );
}
$this->insert( $contextName, $source, $translation, $comment );
return true;
} | php | function handleMessageNode( $contextName, $message )
{
$source = null;
$translation = null;
$comment = null;
$message_children = $message->childNodes;
for( $i = 0; $i < $message_children->length; $i++ )
{
$message_child = $message_children->item( $i );
if ( $message_child->nodeType == XML_ELEMENT_NODE )
{
$childName = $message_child->tagName;
if ( $childName == "source" )
{
if ( $message_child->childNodes->length > 0 )
{
$source = '';
foreach ( $message_child->childNodes as $textEl )
{
if ( $textEl instanceof DOMText )
{
$source .= $textEl->nodeValue;
}
else if ( $textEl instanceof DOMElement && $textEl->tagName == 'byte' )
{
$source .= chr( intval( '0' . $textEl->getAttribute( 'value' ) ) );
}
}
}
}
else if ( $childName == "translation" )
{
if ( $message_child->childNodes->length > 0 )
{
$translation = '';
foreach ( $message_child->childNodes as $textEl )
{
if ( $textEl instanceof DOMText )
{
$translation .= $textEl->nodeValue;
}
else if ( $textEl instanceof DOMElement && $textEl->tagName == 'byte' )
{
$translation .= chr( intval( '0' . $textEl->getAttribute( 'value' ) ) );
}
}
}
}
else if ( $childName == "comment" )
{
$comment_el = $message_child->firstChild;
$comment = $comment_el->nodeValue;
}
else if ( $childName == "translatorcomment" )
{
//Ignore it.
}
else if ( $childName == "location" )
{
//Handle location element. No functionality yet.
}
else
eZDebug::writeError( "Unknown element name: " . $childName, __METHOD__ );
}
}
if ( $source === null )
{
eZDebug::writeError( "No source name found, skipping message in context '{$contextName}'", __METHOD__ );
return false;
}
if ( $translation === null ) // No translation provided, then take the source as a reference
{
// eZDebug::writeError( "No translation, skipping message", __METHOD__ );
$translation = $source;
}
/* we need to convert ourselves if we're using libxml stuff here */
if ( $message instanceof DOMElement )
{
$codec = eZTextCodec::instance( "utf8" );
$source = $codec->convertString( $source );
$translation = $codec->convertString( $translation );
$comment = $codec->convertString( $comment );
}
$this->insert( $contextName, $source, $translation, $comment );
return true;
} | [
"function",
"handleMessageNode",
"(",
"$",
"contextName",
",",
"$",
"message",
")",
"{",
"$",
"source",
"=",
"null",
";",
"$",
"translation",
"=",
"null",
";",
"$",
"comment",
"=",
"null",
";",
"$",
"message_children",
"=",
"$",
"message",
"->",
"childNo... | Handles a translation message DOM node
@param string $contextName
@param DOMNode $message | [
"Handles",
"a",
"translation",
"message",
"DOM",
"node"
] | 2493420f527fbc829a8d5bdda402e05d64a20db7 | https://github.com/ezsystems/ezpublish-legacy/blob/2493420f527fbc829a8d5bdda402e05d64a20db7/lib/ezi18n/classes/eztstranslator.php#L448-L534 | train |
ezsystems/ezpublish-legacy | lib/ezi18n/classes/eztstranslator.php | eZTSTranslator.findKey | function findKey( $key )
{
$msg = null;
if ( isset( $this->Messages[$key] ) )
{
$msg = $this->Messages[$key];
}
return $msg;
} | php | function findKey( $key )
{
$msg = null;
if ( isset( $this->Messages[$key] ) )
{
$msg = $this->Messages[$key];
}
return $msg;
} | [
"function",
"findKey",
"(",
"$",
"key",
")",
"{",
"$",
"msg",
"=",
"null",
";",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"Messages",
"[",
"$",
"key",
"]",
")",
")",
"{",
"$",
"msg",
"=",
"$",
"this",
"->",
"Messages",
"[",
"$",
"key",
"]",... | Returns the message that matches a translation md5 key
@param string $key
@return array|false The message, as an array, or false if not found | [
"Returns",
"the",
"message",
"that",
"matches",
"a",
"translation",
"md5",
"key"
] | 2493420f527fbc829a8d5bdda402e05d64a20db7 | https://github.com/ezsystems/ezpublish-legacy/blob/2493420f527fbc829a8d5bdda402e05d64a20db7/lib/ezi18n/classes/eztstranslator.php#L541-L549 | train |
ezsystems/ezpublish-legacy | lib/ezi18n/classes/eztstranslator.php | eZTSTranslator.keyTranslate | function keyTranslate( $key )
{
$msg = $this->findKey( $key );
if ( $msg !== null )
return $msg["translation"];
else
{
return null;
}
} | php | function keyTranslate( $key )
{
$msg = $this->findKey( $key );
if ( $msg !== null )
return $msg["translation"];
else
{
return null;
}
} | [
"function",
"keyTranslate",
"(",
"$",
"key",
")",
"{",
"$",
"msg",
"=",
"$",
"this",
"->",
"findKey",
"(",
"$",
"key",
")",
";",
"if",
"(",
"$",
"msg",
"!==",
"null",
")",
"return",
"$",
"msg",
"[",
"\"translation\"",
"]",
";",
"else",
"{",
"retu... | Returns the translation for a translation md5 key
@param string $key
@return string|false | [
"Returns",
"the",
"translation",
"for",
"a",
"translation",
"md5",
"key"
] | 2493420f527fbc829a8d5bdda402e05d64a20db7 | https://github.com/ezsystems/ezpublish-legacy/blob/2493420f527fbc829a8d5bdda402e05d64a20db7/lib/ezi18n/classes/eztstranslator.php#L578-L587 | train |
ezsystems/ezpublish-legacy | lib/ezi18n/classes/eztstranslator.php | eZTSTranslator.translate | function translate( $context, $source, $comment = null )
{
$msg = $this->findMessage( $context, $source, $comment );
if ( $msg !== null )
{
return $msg["translation"];
}
return null;
} | php | function translate( $context, $source, $comment = null )
{
$msg = $this->findMessage( $context, $source, $comment );
if ( $msg !== null )
{
return $msg["translation"];
}
return null;
} | [
"function",
"translate",
"(",
"$",
"context",
",",
"$",
"source",
",",
"$",
"comment",
"=",
"null",
")",
"{",
"$",
"msg",
"=",
"$",
"this",
"->",
"findMessage",
"(",
"$",
"context",
",",
"$",
"source",
",",
"$",
"comment",
")",
";",
"if",
"(",
"$... | Translates a context + source + comment
@param string $context
@param string $source
@param string $comment
@return string|false | [
"Translates",
"a",
"context",
"+",
"source",
"+",
"comment"
] | 2493420f527fbc829a8d5bdda402e05d64a20db7 | https://github.com/ezsystems/ezpublish-legacy/blob/2493420f527fbc829a8d5bdda402e05d64a20db7/lib/ezi18n/classes/eztstranslator.php#L596-L605 | train |
ezsystems/ezpublish-legacy | lib/ezi18n/classes/eztstranslator.php | eZTSTranslator.fetchList | static function fetchList( $localeList = array() )
{
$ini = eZINI::instance();
$dir = $ini->variable( 'RegionalSettings', 'TranslationRepository' );
$fileInfoList = array();
$translationList = array();
$locale = '';
if ( count( $localeList ) == 0 )
{
$localeList = eZDir::findSubdirs( $dir );
}
foreach( $localeList as $locale )
{
if ( $locale != 'untranslated' )
{
$translationFiles = eZDir::findSubitems( $dir . '/' . $locale, 'f' );
foreach( $translationFiles as $translationFile )
{
if ( eZFile::suffix( $translationFile ) == 'ts' )
{
$translationList[] = new eZTSTranslator( $locale, $translationFile );
}
}
}
}
return $translationList;
} | php | static function fetchList( $localeList = array() )
{
$ini = eZINI::instance();
$dir = $ini->variable( 'RegionalSettings', 'TranslationRepository' );
$fileInfoList = array();
$translationList = array();
$locale = '';
if ( count( $localeList ) == 0 )
{
$localeList = eZDir::findSubdirs( $dir );
}
foreach( $localeList as $locale )
{
if ( $locale != 'untranslated' )
{
$translationFiles = eZDir::findSubitems( $dir . '/' . $locale, 'f' );
foreach( $translationFiles as $translationFile )
{
if ( eZFile::suffix( $translationFile ) == 'ts' )
{
$translationList[] = new eZTSTranslator( $locale, $translationFile );
}
}
}
}
return $translationList;
} | [
"static",
"function",
"fetchList",
"(",
"$",
"localeList",
"=",
"array",
"(",
")",
")",
"{",
"$",
"ini",
"=",
"eZINI",
"::",
"instance",
"(",
")",
";",
"$",
"dir",
"=",
"$",
"ini",
"->",
"variable",
"(",
"'RegionalSettings'",
",",
"'TranslationRepository... | Fetches the list of available translations, as an eZTSTranslator for each translation.
@param array $localList
@return array( eZTSTranslator ) list of eZTranslator objects representing available translations | [
"Fetches",
"the",
"list",
"of",
"available",
"translations",
"as",
"an",
"eZTSTranslator",
"for",
"each",
"translation",
"."
] | 2493420f527fbc829a8d5bdda402e05d64a20db7 | https://github.com/ezsystems/ezpublish-legacy/blob/2493420f527fbc829a8d5bdda402e05d64a20db7/lib/ezi18n/classes/eztstranslator.php#L681-L713 | train |
ezsystems/ezpublish-legacy | lib/ezi18n/classes/eztstranslator.php | eZTSTranslator.expireCache | public static function expireCache( $timestamp = false, $locale = null )
{
if ( $timestamp === false )
$timestamp = time();
$handler = eZExpiryHandler::instance();
if ( $locale )
$handler->setTimestamp( self::EXPIRY_KEY . '-' . $locale, $timestamp );
else
$handler->setTimestamp( self::EXPIRY_KEY, $timestamp );
$handler->store();
self::resetGlobals();
} | php | public static function expireCache( $timestamp = false, $locale = null )
{
if ( $timestamp === false )
$timestamp = time();
$handler = eZExpiryHandler::instance();
if ( $locale )
$handler->setTimestamp( self::EXPIRY_KEY . '-' . $locale, $timestamp );
else
$handler->setTimestamp( self::EXPIRY_KEY, $timestamp );
$handler->store();
self::resetGlobals();
} | [
"public",
"static",
"function",
"expireCache",
"(",
"$",
"timestamp",
"=",
"false",
",",
"$",
"locale",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"timestamp",
"===",
"false",
")",
"$",
"timestamp",
"=",
"time",
"(",
")",
";",
"$",
"handler",
"=",
"eZExp... | Expires the translation cache
@param int $timestamp An optional timestamp cache should be exired from. Current timestamp used by default
@param string $locale Optional translation's locale to expire specifically. Expires global ts cache by default.
@return void | [
"Expires",
"the",
"translation",
"cache"
] | 2493420f527fbc829a8d5bdda402e05d64a20db7 | https://github.com/ezsystems/ezpublish-legacy/blob/2493420f527fbc829a8d5bdda402e05d64a20db7/lib/ezi18n/classes/eztstranslator.php#L733-L745 | train |
ezsystems/ezpublish-legacy | kernel/classes/eznodeassignment.php | eZNodeAssignment.fetchChildCountByVersionStatus | static function fetchChildCountByVersionStatus( $parentNodeIDList, $status = eZContentObjectVersion::STATUS_PENDING )
{
$db = eZDB::instance();
$parentIDStatement = $db->generateSQLINStatement( $parentNodeIDList );
$sql = "SELECT COUNT( DISTINCT eznode_assignment.id ) AS cnt
FROM ezcontentobject_version, eznode_assignment
WHERE ezcontentobject_version.contentobject_id = eznode_assignment.contentobject_id
AND ezcontentobject_version.version = eznode_assignment.contentobject_version
AND ezcontentobject_version.status = $status
AND eznode_assignment.parent_node $parentIDStatement ";
$countResult = $db->arrayQuery( $sql );
return (int)$countResult[0]['cnt'];
} | php | static function fetchChildCountByVersionStatus( $parentNodeIDList, $status = eZContentObjectVersion::STATUS_PENDING )
{
$db = eZDB::instance();
$parentIDStatement = $db->generateSQLINStatement( $parentNodeIDList );
$sql = "SELECT COUNT( DISTINCT eznode_assignment.id ) AS cnt
FROM ezcontentobject_version, eznode_assignment
WHERE ezcontentobject_version.contentobject_id = eznode_assignment.contentobject_id
AND ezcontentobject_version.version = eznode_assignment.contentobject_version
AND ezcontentobject_version.status = $status
AND eznode_assignment.parent_node $parentIDStatement ";
$countResult = $db->arrayQuery( $sql );
return (int)$countResult[0]['cnt'];
} | [
"static",
"function",
"fetchChildCountByVersionStatus",
"(",
"$",
"parentNodeIDList",
",",
"$",
"status",
"=",
"eZContentObjectVersion",
"::",
"STATUS_PENDING",
")",
"{",
"$",
"db",
"=",
"eZDB",
"::",
"instance",
"(",
")",
";",
"$",
"parentIDStatement",
"=",
"$"... | Fetch node assignment count by version status, giving parent node id list.
@param array $parentNodeIDList
@param int $status
@return int | [
"Fetch",
"node",
"assignment",
"count",
"by",
"version",
"status",
"giving",
"parent",
"node",
"id",
"list",
"."
] | 2493420f527fbc829a8d5bdda402e05d64a20db7 | https://github.com/ezsystems/ezpublish-legacy/blob/2493420f527fbc829a8d5bdda402e05d64a20db7/kernel/classes/eznodeassignment.php#L459-L471 | train |
ezsystems/ezpublish-legacy | kernel/classes/eznodeassignment.php | eZNodeAssignment.fetchChildListByVersionStatus | static function fetchChildListByVersionStatus( $parentNodeIDList, $status = eZContentObjectVersion::STATUS_PENDING, $asObject = true )
{
$db = eZDB::instance();
$parentIDStatement = $db->generateSQLINStatement( $parentNodeIDList );
$sql = "SELECT DISTINCT eznode_assignment.*
FROM ezcontentobject_version, eznode_assignment
WHERE ezcontentobject_version.contentobject_id = eznode_assignment.contentobject_id
AND ezcontentobject_version.version = eznode_assignment.contentobject_version
AND ezcontentobject_version.status = $status
AND eznode_assignment.parent_node $parentIDStatement
ORDER BY eznode_assignment.contentobject_id";
$nodeAssignmentArray = $db->arrayQuery( $sql );
if( $asObject )
{
$result = array();
foreach( $nodeAssignmentArray as $nodeAssignment )
{
$result[] = new eZNodeAssignment( $nodeAssignment );
}
return $result;
}
else
{
return $nodeAssignmentArray;
}
} | php | static function fetchChildListByVersionStatus( $parentNodeIDList, $status = eZContentObjectVersion::STATUS_PENDING, $asObject = true )
{
$db = eZDB::instance();
$parentIDStatement = $db->generateSQLINStatement( $parentNodeIDList );
$sql = "SELECT DISTINCT eznode_assignment.*
FROM ezcontentobject_version, eznode_assignment
WHERE ezcontentobject_version.contentobject_id = eznode_assignment.contentobject_id
AND ezcontentobject_version.version = eznode_assignment.contentobject_version
AND ezcontentobject_version.status = $status
AND eznode_assignment.parent_node $parentIDStatement
ORDER BY eznode_assignment.contentobject_id";
$nodeAssignmentArray = $db->arrayQuery( $sql );
if( $asObject )
{
$result = array();
foreach( $nodeAssignmentArray as $nodeAssignment )
{
$result[] = new eZNodeAssignment( $nodeAssignment );
}
return $result;
}
else
{
return $nodeAssignmentArray;
}
} | [
"static",
"function",
"fetchChildListByVersionStatus",
"(",
"$",
"parentNodeIDList",
",",
"$",
"status",
"=",
"eZContentObjectVersion",
"::",
"STATUS_PENDING",
",",
"$",
"asObject",
"=",
"true",
")",
"{",
"$",
"db",
"=",
"eZDB",
"::",
"instance",
"(",
")",
";"... | Fetch node assignment list by version status, giving parent node id list.
@param array $idList node id array
@param int $status status of the object version
@param boolean $count
@param boolean $asObject valid only when $count is false
@return array|int | [
"Fetch",
"node",
"assignment",
"list",
"by",
"version",
"status",
"giving",
"parent",
"node",
"id",
"list",
"."
] | 2493420f527fbc829a8d5bdda402e05d64a20db7 | https://github.com/ezsystems/ezpublish-legacy/blob/2493420f527fbc829a8d5bdda402e05d64a20db7/kernel/classes/eznodeassignment.php#L482-L508 | train |
ezsystems/ezpublish-legacy | kernel/private/api/content/field_set.php | ezpContentFieldSet.fromContentObject | public static function fromContentObject( eZContentObject $contentObject )
{
$set = new ezpContentFieldSet();
$languages = $contentObject->availableLanguages();
foreach( $languages as $language )
{
$set->childrenFieldSets[$language] =
ezpContentFieldSet::fromDataMap( $contentObject->fetchDataMap( false, $language ) );
}
// this sequence is REALLY ugly
reset( $languages );
$set->setActiveLanguage( current( $languages ) );
return $set;
} | php | public static function fromContentObject( eZContentObject $contentObject )
{
$set = new ezpContentFieldSet();
$languages = $contentObject->availableLanguages();
foreach( $languages as $language )
{
$set->childrenFieldSets[$language] =
ezpContentFieldSet::fromDataMap( $contentObject->fetchDataMap( false, $language ) );
}
// this sequence is REALLY ugly
reset( $languages );
$set->setActiveLanguage( current( $languages ) );
return $set;
} | [
"public",
"static",
"function",
"fromContentObject",
"(",
"eZContentObject",
"$",
"contentObject",
")",
"{",
"$",
"set",
"=",
"new",
"ezpContentFieldSet",
"(",
")",
";",
"$",
"languages",
"=",
"$",
"contentObject",
"->",
"availableLanguages",
"(",
")",
";",
"f... | Initializes a level one ezpContentFieldSet from an eZContentObject
@param eZContentObject $contentObject
@return ezpContentFieldSet | [
"Initializes",
"a",
"level",
"one",
"ezpContentFieldSet",
"from",
"an",
"eZContentObject"
] | 2493420f527fbc829a8d5bdda402e05d64a20db7 | https://github.com/ezsystems/ezpublish-legacy/blob/2493420f527fbc829a8d5bdda402e05d64a20db7/kernel/private/api/content/field_set.php#L33-L48 | train |
ezsystems/ezpublish-legacy | kernel/private/api/content/field_set.php | ezpContentFieldSet.fromDataMap | public static function fromDataMap( $dataMap )
{
$set = new ezpContentFieldSet();
foreach( $dataMap as $attribute )
{
$identifier = $attribute->attribute( 'contentclass_attribute_identifier' );
$set->fields[$identifier] = ezpContentField::fromContentObjectAttribute( $attribute );
}
$set->initIterator();
return $set;
} | php | public static function fromDataMap( $dataMap )
{
$set = new ezpContentFieldSet();
foreach( $dataMap as $attribute )
{
$identifier = $attribute->attribute( 'contentclass_attribute_identifier' );
$set->fields[$identifier] = ezpContentField::fromContentObjectAttribute( $attribute );
}
$set->initIterator();
return $set;
} | [
"public",
"static",
"function",
"fromDataMap",
"(",
"$",
"dataMap",
")",
"{",
"$",
"set",
"=",
"new",
"ezpContentFieldSet",
"(",
")",
";",
"foreach",
"(",
"$",
"dataMap",
"as",
"$",
"attribute",
")",
"{",
"$",
"identifier",
"=",
"$",
"attribute",
"->",
... | Initializes a level two ezpContentFieldSet from a content object data map
@param array $dataMap
@return ezpContentFieldSet | [
"Initializes",
"a",
"level",
"two",
"ezpContentFieldSet",
"from",
"a",
"content",
"object",
"data",
"map"
] | 2493420f527fbc829a8d5bdda402e05d64a20db7 | https://github.com/ezsystems/ezpublish-legacy/blob/2493420f527fbc829a8d5bdda402e05d64a20db7/kernel/private/api/content/field_set.php#L55-L65 | train |
ezsystems/ezpublish-legacy | kernel/private/api/content/field_set.php | ezpContentFieldSet.offsetGet | public function offsetGet( $offset )
{
// This needs to check if this language can be instanciated (e.g. is active on the installation)
if ( !isset( $this->childrenFieldSets[$offset] ) )
{
throw new Exception( "Language $offset could not be found on this ezpContent" );
}
return $this->childrenFieldSets[$offset];
} | php | public function offsetGet( $offset )
{
// This needs to check if this language can be instanciated (e.g. is active on the installation)
if ( !isset( $this->childrenFieldSets[$offset] ) )
{
throw new Exception( "Language $offset could not be found on this ezpContent" );
}
return $this->childrenFieldSets[$offset];
} | [
"public",
"function",
"offsetGet",
"(",
"$",
"offset",
")",
"{",
"// This needs to check if this language can be instanciated (e.g. is active on the installation)",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"childrenFieldSets",
"[",
"$",
"offset",
"]",
")",
")",
... | Array get handler.
Will return the requested language's ezpFieldSet
@return ezpContentFieldSet | [
"Array",
"get",
"handler",
".",
"Will",
"return",
"the",
"requested",
"language",
"s",
"ezpFieldSet"
] | 2493420f527fbc829a8d5bdda402e05d64a20db7 | https://github.com/ezsystems/ezpublish-legacy/blob/2493420f527fbc829a8d5bdda402e05d64a20db7/kernel/private/api/content/field_set.php#L95-L104 | train |
ezsystems/ezpublish-legacy | lib/ezsession/classes/ezpsessionhandler.php | ezpSessionHandler.setSaveHandler | public function setSaveHandler()
{
session_module_name( 'user' );
session_set_save_handler(
array( $this, 'open' ),
array( $this, 'close' ),
array( $this, 'read' ),
array( $this, 'write' ),
array( $this, 'destroy' ),
array( $this, 'gc' )
);
return true;
} | php | public function setSaveHandler()
{
session_module_name( 'user' );
session_set_save_handler(
array( $this, 'open' ),
array( $this, 'close' ),
array( $this, 'read' ),
array( $this, 'write' ),
array( $this, 'destroy' ),
array( $this, 'gc' )
);
return true;
} | [
"public",
"function",
"setSaveHandler",
"(",
")",
"{",
"session_module_name",
"(",
"'user'",
")",
";",
"session_set_save_handler",
"(",
"array",
"(",
"$",
"this",
",",
"'open'",
")",
",",
"array",
"(",
"$",
"this",
",",
"'close'",
")",
",",
"array",
"(",
... | Set it self as save handler
@return bool | [
"Set",
"it",
"self",
"as",
"save",
"handler"
] | 2493420f527fbc829a8d5bdda402e05d64a20db7 | https://github.com/ezsystems/ezpublish-legacy/blob/2493420f527fbc829a8d5bdda402e05d64a20db7/lib/ezsession/classes/ezpsessionhandler.php#L51-L63 | train |
ezsystems/ezpublish-legacy | lib/ezdb/classes/ezdbinterface.php | eZDBInterface.prepareSqlQuery | function prepareSqlQuery( &$fd, &$buffer )
{
$sqlQueryArray = array();
while( count( $sqlQueryArray ) == 0 && !feof( $fd ) )
{
$buffer .= fread( $fd, 4096 );
if ( $buffer )
{
// Fix SQL file by deleting all comments and newlines
// eZDebug::writeDebug( $buffer, "read data" );
$sqlQuery = preg_replace( array( "/^#.*\n" . "/m",
"#^/\*.*\*/\n" . "#m",
"/^--.*\n" . "/m",
"/\n|\r\n|\r/m" ),
array( "",
"",
"",
"\n" ),
$buffer );
// eZDebug::writeDebug( $sqlQuery, "read data" );
// Split the query into an array
$sqlQueryArray = preg_split( "/;\n/m", $sqlQuery );
if ( preg_match( '/;\n/m', $sqlQueryArray[ count( $sqlQueryArray ) -1 ] ) )
{
$buffer = '';
}
else
{
$buffer = $sqlQueryArray[ count( $sqlQueryArray ) -1 ];
array_splice( $sqlQueryArray, count( $sqlQueryArray ) -1 , 1 );
}
}
else
{
return $sqlQueryArray;
}
}
return $sqlQueryArray;
} | php | function prepareSqlQuery( &$fd, &$buffer )
{
$sqlQueryArray = array();
while( count( $sqlQueryArray ) == 0 && !feof( $fd ) )
{
$buffer .= fread( $fd, 4096 );
if ( $buffer )
{
// Fix SQL file by deleting all comments and newlines
// eZDebug::writeDebug( $buffer, "read data" );
$sqlQuery = preg_replace( array( "/^#.*\n" . "/m",
"#^/\*.*\*/\n" . "#m",
"/^--.*\n" . "/m",
"/\n|\r\n|\r/m" ),
array( "",
"",
"",
"\n" ),
$buffer );
// eZDebug::writeDebug( $sqlQuery, "read data" );
// Split the query into an array
$sqlQueryArray = preg_split( "/;\n/m", $sqlQuery );
if ( preg_match( '/;\n/m', $sqlQueryArray[ count( $sqlQueryArray ) -1 ] ) )
{
$buffer = '';
}
else
{
$buffer = $sqlQueryArray[ count( $sqlQueryArray ) -1 ];
array_splice( $sqlQueryArray, count( $sqlQueryArray ) -1 , 1 );
}
}
else
{
return $sqlQueryArray;
}
}
return $sqlQueryArray;
} | [
"function",
"prepareSqlQuery",
"(",
"&",
"$",
"fd",
",",
"&",
"$",
"buffer",
")",
"{",
"$",
"sqlQueryArray",
"=",
"array",
"(",
")",
";",
"while",
"(",
"count",
"(",
"$",
"sqlQueryArray",
")",
"==",
"0",
"&&",
"!",
"feof",
"(",
"$",
"fd",
")",
")... | Prepare the sql file so we can create the database.
@access private
@param resource $fd The file descriptor
@param string $buffer Reference to string buffer for SQL queries.
@return array | [
"Prepare",
"the",
"sql",
"file",
"so",
"we",
"can",
"create",
"the",
"database",
"."
] | 2493420f527fbc829a8d5bdda402e05d64a20db7 | https://github.com/ezsystems/ezpublish-legacy/blob/2493420f527fbc829a8d5bdda402e05d64a20db7/lib/ezdb/classes/ezdbinterface.php#L242-L284 | train |
ezsystems/ezpublish-legacy | lib/ezdb/classes/ezdbinterface.php | eZDBInterface.reportQuery | function reportQuery( $class, $sql, $numRows, $timeTaken, $asDebug = false )
{
$rowText = '';
if ( $numRows !== false ) $rowText = "$numRows rows, ";
$backgroundClass = ($this->TransactionCounter > 0 ? "debugtransaction transactionlevel-$this->TransactionCounter" : '');
if ( $asDebug )
eZDebug::writeDebug( "$sql", "$class::query($rowText" . number_format( $timeTaken, 3 ) . ' ms) query number per page:' . $this->NumQueries++, $backgroundClass );
else
eZDebug::writeNotice( "$sql", "$class::query($rowText" . number_format( $timeTaken, 3 ) . ' ms) query number per page:' . $this->NumQueries++, $backgroundClass );
} | php | function reportQuery( $class, $sql, $numRows, $timeTaken, $asDebug = false )
{
$rowText = '';
if ( $numRows !== false ) $rowText = "$numRows rows, ";
$backgroundClass = ($this->TransactionCounter > 0 ? "debugtransaction transactionlevel-$this->TransactionCounter" : '');
if ( $asDebug )
eZDebug::writeDebug( "$sql", "$class::query($rowText" . number_format( $timeTaken, 3 ) . ' ms) query number per page:' . $this->NumQueries++, $backgroundClass );
else
eZDebug::writeNotice( "$sql", "$class::query($rowText" . number_format( $timeTaken, 3 ) . ' ms) query number per page:' . $this->NumQueries++, $backgroundClass );
} | [
"function",
"reportQuery",
"(",
"$",
"class",
",",
"$",
"sql",
",",
"$",
"numRows",
",",
"$",
"timeTaken",
",",
"$",
"asDebug",
"=",
"false",
")",
"{",
"$",
"rowText",
"=",
"''",
";",
"if",
"(",
"$",
"numRows",
"!==",
"false",
")",
"$",
"rowText",
... | Writes a debug notice with query information.
@access private
@param string $class
@param string $sql
@param int|string $numRows
@param int|string $timeTaken
@param bool $asDebug | [
"Writes",
"a",
"debug",
"notice",
"with",
"query",
"information",
"."
] | 2493420f527fbc829a8d5bdda402e05d64a20db7 | https://github.com/ezsystems/ezpublish-legacy/blob/2493420f527fbc829a8d5bdda402e05d64a20db7/lib/ezdb/classes/ezdbinterface.php#L353-L363 | train |
ezsystems/ezpublish-legacy | lib/ezdb/classes/ezdbinterface.php | eZDBInterface.endTimer | function endTimer()
{
$this->EndTime = microtime( true );
// Calculate time taken in ms
$this->TimeTaken = $this->EndTime - $this->StartTime;
$this->TimeTaken *= 1000.0;
} | php | function endTimer()
{
$this->EndTime = microtime( true );
// Calculate time taken in ms
$this->TimeTaken = $this->EndTime - $this->StartTime;
$this->TimeTaken *= 1000.0;
} | [
"function",
"endTimer",
"(",
")",
"{",
"$",
"this",
"->",
"EndTime",
"=",
"microtime",
"(",
"true",
")",
";",
"// Calculate time taken in ms",
"$",
"this",
"->",
"TimeTaken",
"=",
"$",
"this",
"->",
"EndTime",
"-",
"$",
"this",
"->",
"StartTime",
";",
"$... | Stops the current timer and calculates the time taken.
@access private | [
"Stops",
"the",
"current",
"timer",
"and",
"calculates",
"the",
"time",
"taken",
"."
] | 2493420f527fbc829a8d5bdda402e05d64a20db7 | https://github.com/ezsystems/ezpublish-legacy/blob/2493420f527fbc829a8d5bdda402e05d64a20db7/lib/ezdb/classes/ezdbinterface.php#L390-L396 | train |
ezsystems/ezpublish-legacy | lib/ezdb/classes/ezdbinterface.php | eZDBInterface.begin | function begin()
{
$ini = eZINI::instance();
if ($ini->variable( "DatabaseSettings", "Transactions" ) == "enabled")
{
if ( $this->TransactionCounter > 0 )
{
if ( is_array( $this->TransactionStackTree ) )
{
// Make a new sub-level for debugging
$bt = debug_backtrace();
$subLevels =& $this->TransactionStackTree['sub_levels'];
for ( $i = 1; $i < $this->TransactionCounter; ++$i )
{
$subLevels =& $subLevels[count( $subLevels ) - 1]['sub_levels'];
}
// Next entry will be at the end
$subLevels[count( $subLevels )] = array( 'level' => $this->TransactionCounter,
'trace' => $bt,
'sub_levels' => array() );
}
++$this->TransactionCounter;
return false;
}
else
{
if ( is_array( $this->TransactionStackTree ) )
{
// Start new stack tree for debugging
$bt = debug_backtrace();
$this->TransactionStackTree = array( 'level' => $this->TransactionCounter,
'trace' => $bt,
'sub_levels' => array() );
}
}
$this->TransactionIsValid = true;
if ( $this->isConnected() )
{
$oldRecordError = $this->RecordError;
// Turn off error handling while we begin
$this->RecordError = false;
$this->beginQuery();
$this->RecordError = $oldRecordError;
// We update the transaction counter after the query, otherwise we
// mess up the debug background highlighting.
++$this->TransactionCounter;
}
}
return true;
} | php | function begin()
{
$ini = eZINI::instance();
if ($ini->variable( "DatabaseSettings", "Transactions" ) == "enabled")
{
if ( $this->TransactionCounter > 0 )
{
if ( is_array( $this->TransactionStackTree ) )
{
// Make a new sub-level for debugging
$bt = debug_backtrace();
$subLevels =& $this->TransactionStackTree['sub_levels'];
for ( $i = 1; $i < $this->TransactionCounter; ++$i )
{
$subLevels =& $subLevels[count( $subLevels ) - 1]['sub_levels'];
}
// Next entry will be at the end
$subLevels[count( $subLevels )] = array( 'level' => $this->TransactionCounter,
'trace' => $bt,
'sub_levels' => array() );
}
++$this->TransactionCounter;
return false;
}
else
{
if ( is_array( $this->TransactionStackTree ) )
{
// Start new stack tree for debugging
$bt = debug_backtrace();
$this->TransactionStackTree = array( 'level' => $this->TransactionCounter,
'trace' => $bt,
'sub_levels' => array() );
}
}
$this->TransactionIsValid = true;
if ( $this->isConnected() )
{
$oldRecordError = $this->RecordError;
// Turn off error handling while we begin
$this->RecordError = false;
$this->beginQuery();
$this->RecordError = $oldRecordError;
// We update the transaction counter after the query, otherwise we
// mess up the debug background highlighting.
++$this->TransactionCounter;
}
}
return true;
} | [
"function",
"begin",
"(",
")",
"{",
"$",
"ini",
"=",
"eZINI",
"::",
"instance",
"(",
")",
";",
"if",
"(",
"$",
"ini",
"->",
"variable",
"(",
"\"DatabaseSettings\"",
",",
"\"Transactions\"",
")",
"==",
"\"enabled\"",
")",
"{",
"if",
"(",
"$",
"this",
... | Begin a new transaction.
If we are already in transaction then we omit this new transaction and its matching commit or rollback.
@return bool | [
"Begin",
"a",
"new",
"transaction",
"."
] | 2493420f527fbc829a8d5bdda402e05d64a20db7 | https://github.com/ezsystems/ezpublish-legacy/blob/2493420f527fbc829a8d5bdda402e05d64a20db7/lib/ezdb/classes/ezdbinterface.php#L710-L761 | train |
ezsystems/ezpublish-legacy | lib/ezdb/classes/ezdbinterface.php | eZDBInterface.commit | function commit()
{
$ini = eZINI::instance();
if ($ini->variable( "DatabaseSettings", "Transactions" ) == "enabled")
{
if ( $this->TransactionCounter <= 0 )
{
eZDebug::writeError( 'No transaction in progress, cannot commit', __METHOD__ );
return false;
}
--$this->TransactionCounter;
if ( $this->TransactionCounter == 0 )
{
if ( is_array( $this->TransactionStackTree ) )
{
// Reset the stack debug tree since the top commit was done
$this->TransactionStackTree = array();
}
if ( $this->isConnected() )
{
// Check if we have encountered any problems, if so we have to rollback
if ( !$this->TransactionIsValid )
{
$oldRecordError = $this->RecordError;
// Turn off error handling while we rollback
$this->RecordError = false;
$this->rollbackQuery();
$this->RecordError = $oldRecordError;
return false;
}
else
{
$oldRecordError = $this->RecordError;
// Turn off error handling while we commit
$this->RecordError = false;
$this->commitQuery();
$this->RecordError = $oldRecordError;
}
}
}
else
{
if ( is_array( $this->TransactionStackTree ) )
{
// Close the last open nested transaction
$bt = debug_backtrace();
// Store commit trace
$subLevels =& $this->TransactionStackTree['sub_levels'];
for ( $i = 1; $i < $this->TransactionCounter; ++$i )
{
$subLevels =& $subLevels[count( $subLevels ) - 1]['sub_levels'];
}
// Find last entry and add the commit trace
$subLevels[count( $subLevels ) - 1]['commit_trace'] = $bt;
}
}
}
return true;
} | php | function commit()
{
$ini = eZINI::instance();
if ($ini->variable( "DatabaseSettings", "Transactions" ) == "enabled")
{
if ( $this->TransactionCounter <= 0 )
{
eZDebug::writeError( 'No transaction in progress, cannot commit', __METHOD__ );
return false;
}
--$this->TransactionCounter;
if ( $this->TransactionCounter == 0 )
{
if ( is_array( $this->TransactionStackTree ) )
{
// Reset the stack debug tree since the top commit was done
$this->TransactionStackTree = array();
}
if ( $this->isConnected() )
{
// Check if we have encountered any problems, if so we have to rollback
if ( !$this->TransactionIsValid )
{
$oldRecordError = $this->RecordError;
// Turn off error handling while we rollback
$this->RecordError = false;
$this->rollbackQuery();
$this->RecordError = $oldRecordError;
return false;
}
else
{
$oldRecordError = $this->RecordError;
// Turn off error handling while we commit
$this->RecordError = false;
$this->commitQuery();
$this->RecordError = $oldRecordError;
}
}
}
else
{
if ( is_array( $this->TransactionStackTree ) )
{
// Close the last open nested transaction
$bt = debug_backtrace();
// Store commit trace
$subLevels =& $this->TransactionStackTree['sub_levels'];
for ( $i = 1; $i < $this->TransactionCounter; ++$i )
{
$subLevels =& $subLevels[count( $subLevels ) - 1]['sub_levels'];
}
// Find last entry and add the commit trace
$subLevels[count( $subLevels ) - 1]['commit_trace'] = $bt;
}
}
}
return true;
} | [
"function",
"commit",
"(",
")",
"{",
"$",
"ini",
"=",
"eZINI",
"::",
"instance",
"(",
")",
";",
"if",
"(",
"$",
"ini",
"->",
"variable",
"(",
"\"DatabaseSettings\"",
",",
"\"Transactions\"",
")",
"==",
"\"enabled\"",
")",
"{",
"if",
"(",
"$",
"this",
... | Commits the current transaction. If this is not the outermost it will not commit
to the database immediately but instead decrease the transaction counter.
If the current transaction had any errors in it the transaction will be rollbacked
instead of commited. This ensures that the database is in a valid state.
Also the PHP execution will be stopped.
@return bool true if the transaction was successful, false otherwise. | [
"Commits",
"the",
"current",
"transaction",
".",
"If",
"this",
"is",
"not",
"the",
"outermost",
"it",
"will",
"not",
"commit",
"to",
"the",
"database",
"immediately",
"but",
"instead",
"decrease",
"the",
"transaction",
"counter",
"."
] | 2493420f527fbc829a8d5bdda402e05d64a20db7 | https://github.com/ezsystems/ezpublish-legacy/blob/2493420f527fbc829a8d5bdda402e05d64a20db7/lib/ezdb/classes/ezdbinterface.php#L785-L845 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.