/** * _formatData * @description Will format the data input as Alfresco XML want's it * @author Henrik Hussfelt * @params $data - Data to format, $type - The type to format the data as, array $file - Filename if applicable and content name if applicable * @return $data - Formatted data * @since 1.0 */ private function _formatData($data, $type, $file = null) { // Set up return parameter $return = false; switch ($type) { case 'date': $return = FormatHelper::getAtomDateTime($data); break; case 'filename': $return = FormatHelper::filename($data, $file['name']); break; case 'string': $return = (string) $data; break; case 'int': $return = (int) intval($data); break; case 'content-string': // Replace content strings $1-5 with proper values // contentUrl=$1|mimetype=$2|size=$3|encoding=$4|locale=$5 // Set the full path $full_path = $this->_settings['files']['start_path'] . "/" . $file['name']; // Get mimetype with helper class $mimetype = FileHelper::findMimetype($full_path); // Get filesize $size = filesize($full_path); // Get encoding of file with helper class $encoding = FileHelper::findEncoding($full_path); // Set return string $return = str_replace(array('$1', '$2', '$3', '$4', '$5'), array($this->_folder_name . "/" . $file['content_name'], $mimetype, $size, $encoding, $this->getSetting('languages', 'locale')), $data); break; default: // Default action, return everything $return = $data; break; } // Return data or false return $return; }