|
eZ Publish
[4.2]
|
Handles simple creation of content objects by uploading files. More...
Public Member Functions | |
| attribute ($attributeName) | |
| attributes () | |
| eZContentUpload ($params=false) | |
| findHandler (&$result, $mimeInfo) | |
| handleLocalFile (&$result, $filePath, $location, $existingNode, $nameString= '') | |
| handleUpload (&$result, $httpFileIdentifier, $location, $existingNode, $nameString= '') | |
| hasAttribute ($attributeName) | |
| objectFileInfo ($contentObject) | |
| setResult ($result) | |
Static Public Member Functions | |
| static | cleanup ($actionName) |
| cleanupAll () | |
| nodeAliasID ($nodeName) | |
| static | result ($actionName, $cleanup=true) |
| static | upload ($parameters=array(), $module) |
Public Attributes | |
| $Parameters = false | |
| The upload parameters. | |
| const | STATUS_PERMISSION_DENIED = 1 |
Private Member Functions | |
| detectLocations ($classIdentifier, $class, $location, &$parentNodes, &$parentMainNode) | |
| fetchHTTPFile ($httpFileIdentifier, &$errors, &$file, &$mimeData) | |
| publishObject (&$result, &$errors, &$notices, $object, $publishVersion, $class, $parentNodes, $parentMainNode) | |
Static Private Member Functions | |
| checkAccess ($nodeID, $class) | |
| detectClassIdentifier ($mime) | |
| findHTTPFileAttribute ($dataMap, $fileAttribute) | |
| findRegularFileAttribute ($dataMap, $fileAttribute) | |
| findStringAttribute ($dataMap, $nameAttribute) | |
| processNamePattern ($variables, $namePattern) | |
Handles simple creation of content objects by uploading files.
This class makes it easy to use the start a new file upload and let it be created as a content object.
Using it is simply to call the upload function with some parameters.
eZContentUpload::upload( array( 'action_name' => 'MyActionName' ), $module );
It requires the module objects as the second parameter to redirect and the first define how the upload page should behave. Normally you just want to set action_name and define the behaviour of that action in settings/upload.ini.
Fetching the result afterwards is done by calling the result() method, it will return the resulting node ID or object ID depending on the configuration of the upload action.
eZContentUpload::result( 'MyActionName' );
It is also possible to use this class to upload a given file (HTTP or regular) as an object. The correct class and location can be determined automatically.
Simply create an instance and then call handleUpload() or handleLocalFile().
$upload = new eZContentUpload(); $upload->handleUpload( $result, 'UploadFile', 'auto', false ); $upload->handleLocalFile( $result, 'a_yellow_flower.jpg', 'auto' );
Definition at line 71 of file ezcontentupload.php.
| eZContentUpload::attribute | ( | $ | attributeName | ) |
null if no such attribute. Definition at line 114 of file ezcontentupload.php.
Referenced by detectLocations().
| eZContentUpload::attributes | ( | ) |
Definition at line 98 of file ezcontentupload.php.
| eZContentUpload::checkAccess | ( | $ | nodeID, |
| $ | class | ||
| ) | [static, private] |
Definition at line 1106 of file ezcontentupload.php.
Referenced by detectLocations().
| static eZContentUpload::cleanup | ( | $ | actionName | ) | [static] |
Cleans up the persistent data and result for action named $actionName
Definition at line 1271 of file ezcontentupload.php.
Referenced by result().
| eZContentUpload::cleanupAll | ( | ) | [static] |
Similar to cleanup() but removes persistent data from all actions.
Definition at line 1281 of file ezcontentupload.php.
| eZContentUpload::detectClassIdentifier | ( | $ | mime | ) | [static, private] |
Figures out the class which should be used for file with MIME-Type $mime and returns the class identifier.
| $mime | A string defining the MIME-Type, will be used to determine class identifier. |
Definition at line 944 of file ezcontentupload.php.
Referenced by handleLocalFile(), and handleUpload().
| eZContentUpload::detectLocations | ( | $ | classIdentifier, |
| $ | class, | ||
| $ | location, | ||
| &$ | parentNodes, | ||
| &$ | parentMainNode | ||
| ) | [private] |
Figures out the location(s) in which the class with the identifier $classIdentifier should be placed. The returned locations will either be a node ID or an identifier for a node (e.g. content).
true if a location was found or false if no location could be determined | $classIdentifier | Identifier of class, is used to determine location | |
| $location | The wanted location, either use 'auto' for automatic placement or number to determine to parent node ID. | |
| [out] | $parentNodes | Will contain an array with node IDs or identifiers if a location could be detected. |
| [out] | $parentMainNode | Will contain the ID of the main node if a location could be detected. |
Definition at line 981 of file ezcontentupload.php.
Referenced by handleLocalFile(), and handleUpload().
| eZContentUpload::eZContentUpload | ( | $ | params = false | ) |
Initializes the object with the session data if they are found. If $params is supplied it used instead.
Definition at line 80 of file ezcontentupload.php.
Referenced by result().
| eZContentUpload::fetchHTTPFile | ( | $ | httpFileIdentifier, |
| &$ | errors, | ||
| &$ | file, | ||
| &$ | mimeData | ||
| ) | [private] |
Fetches the HTTP-File into $file and fills in MIME-Type information into $mimeData.
false if something went wrong. Definition at line 816 of file ezcontentupload.php.
Referenced by handleUpload().
| eZContentUpload::findHandler | ( | &$ | result, |
| $ | mimeInfo | ||
| ) |
Finds the correct upload handler for the file specified in $mimeInfo. If no handler is found it will return the default attribute based handler eZContentUpload, this means that the file is passed to one suitable attribute and handled from there.
false if an error occured. Will return true if there is no handler configured for this type. Definition at line 1294 of file ezcontentupload.php.
Referenced by handleLocalFile(), and handleUpload().
| eZContentUpload::findHTTPFileAttribute | ( | $ | dataMap, |
| $ | fileAttribute | ||
| ) | [static, private] |
Checks if the attribute with the identifier $fileAttribute in $dataMap supports HTTP file uploading. If not it will go trough all attributes and find the first that has this support.
false if none were found. | $dataMap | Associative array with class attributes, the key is attribute identifier |
| $fileAttribute | The identifier of the attribute that is expected to have the file datatype. |
Definition at line 849 of file ezcontentupload.php.
Referenced by handleUpload().
| eZContentUpload::findRegularFileAttribute | ( | $ | dataMap, |
| $ | fileAttribute | ||
| ) | [static, private] |
Checks if the attribute with the identifier $fileAttribute in $dataMap supports file uploading. If not it will go trough all attributes and find the first that has this support.
false if none were found. | $dataMap | Associative array with class attributes, the key is attribute identifier |
| $fileAttribute | The identifier of the attribute that is expected to have the file datatype. |
Definition at line 882 of file ezcontentupload.php.
Referenced by handleLocalFile(), and objectFileInfo().
| eZContentUpload::findStringAttribute | ( | $ | dataMap, |
| $ | nameAttribute | ||
| ) | [static, private] |
Checks if the attribute with the identifier $nameAttribute in $dataMap supports string insertion. If not it will go trough all attributes and find the first that has this support.
false if none were found. | $dataMap | Associative array with class attributes, the key is attribute identifier |
| $nameAttribute | The identifier of the attribute that is expected to have the string datatype. |
Definition at line 915 of file ezcontentupload.php.
Referenced by handleLocalFile(), and handleUpload().
| eZContentUpload::handleLocalFile | ( | &$ | result, |
| $ | filePath, | ||
| $ | location, | ||
| $ | existingNode, | ||
| $ | nameString = '' |
||
| ) |
Fetches the local file, figures out its MIME-type and creates the proper content object out of it.
| $filePath | Path to file which should be stored. |
| $result | Result data, will be filled with information which the client can examine, contains:
|
| $location | The node ID which the new object will be placed or the string 'auto' for automatic placement of type. |
| $existingNode | Pass a contentobjecttreenode object to let the uploading be done to an existing object, if not it will create one from scratch. |
false if something failed or true if succesful. Definition at line 230 of file ezcontentupload.php.
| eZContentUpload::handleUpload | ( | &$ | result, |
| $ | httpFileIdentifier, | ||
| $ | location, | ||
| $ | existingNode, | ||
| $ | nameString = '' |
||
| ) |
Fetches the uploaded file, figures out its MIME-type and creates the proper content object out of it.
| $httpFileIdentifier | The HTTP identifier of the uploaded file, this must match the name of your input tag. |
| $result | Result data, will be filled with information which the client can examine, contains:
|
| $location | The node ID which the new object will be placed or the string 'auto' for automatic placement of type. |
| $existingNode | Pass a contentobjecttreenode object to let the uploading be done to an existing object, if not it will create one from scratch. |
false if something failed or true if succesful. Definition at line 455 of file ezcontentupload.php.
| eZContentUpload::hasAttribute | ( | $ | attributeName | ) |
Definition at line 106 of file ezcontentupload.php.
Referenced by detectLocations().
| eZContentUpload::nodeAliasID | ( | $ | nodeName | ) | [static] |
false if no ID could be found. Definition at line 1189 of file ezcontentupload.php.
Referenced by detectLocations(), and upload().
| eZContentUpload::objectFileInfo | ( | $ | contentObject | ) |
Finds the file attribute for object $contentObject and tries to extract file information using eZDataType::storedFileInformation().
false if it fails somehow. Definition at line 781 of file ezcontentupload.php.
| eZContentUpload::processNamePattern | ( | $ | variables, |
| $ | namePattern | ||
| ) | [static, private] |
Parses the name pattern $namePattern and replaces any variables found in $variables with the variable value.
| $variables | An associative array where the key is variable name and element the variable value. |
| $namePattern | A string containing of plain text or tags, each tag is enclosed in < and > and defines name of the variable to lookup. |
$vars = array( 'name' => 'A name', 'filename' => 'myfile.txt' ); $name = $this->parseNamePattern( $vars, '<name> - <filename>' ); print( $name ); // Will output 'A name - myfile.txt'
Definition at line 1138 of file ezcontentupload.php.
Referenced by handleLocalFile(), and handleUpload().
| eZContentUpload::publishObject | ( | &$ | result, |
| &$ | errors, | ||
| &$ | notices, | ||
| $ | object, | ||
| $ | publishVersion, | ||
| $ | class, | ||
| $ | parentNodes, | ||
| $ | parentMainNode | ||
| ) | [private] |
Publishes the object to the selected locations.
true if everything was OK, false if something failed. Definition at line 706 of file ezcontentupload.php.
Referenced by handleLocalFile(), and handleUpload().
| static eZContentUpload::result | ( | $ | actionName, |
| $ | cleanup = true |
||
| ) | [static] |
false if no result was found. It uses the action name $actionName to determine which result to look for. | $cleanup | If true it the persisten data is cleaned up by calling cleanup(). |
Definition at line 1247 of file ezcontentupload.php.
| eZContentUpload::setResult | ( | $ | result | ) |
Sets the result array to $result and stores the session variable.
Definition at line 1234 of file ezcontentupload.php.
Referenced by publishObject().
| static eZContentUpload::upload | ( | $ | parameters = array(), |
| $ | module | ||
| ) | [static] |
Sets some session data taken from $parameters and start the upload module by redirecting to it using $module. Most data will be automatically derived from the action_name value taken from settings/upload.ini, other values will override default values.
Definition at line 131 of file ezcontentupload.php.
| eZContentUpload::$Parameters = false |
The upload parameters.
Definition at line 1351 of file ezcontentupload.php.
Definition at line 74 of file ezcontentupload.php.
Referenced by handleLocalFile(), handleUpload(), nodeAliasID(), eZWebDAVContentServer\putContentData(), and eZWebDAVContentBackend\putContentData().