public function testConvert() { $original = "Abcdefg Âéìøü 这是一个测试。"; $str = Zotero_Attachments::encodeRelativeDescriptorString($original); // assert $str = Zotero_Attachments::decodeRelativeDescriptorString($str); $this->assertEquals($original, $str); }
private function getAttachmentFilename() { if (!$this->isAttachment()) { throw new Exception("attachmentFilename can only be retrieved for attachment items"); } if (!$this->isImportedAttachment()) { throw new Exception("attachmentFilename cannot be retrieved for linked attachments"); } if ($this->attachmentData['filename'] !== null) { return $this->attachmentData['filename']; } if (!$this->id) { return ''; } $path = $this->attachmentPath; if (!$path) { return ''; } // Strip "storage:" $filename = substr($path, 8); $filename = Zotero_Attachments::decodeRelativeDescriptorString($filename); $this->attachmentData['filename'] = $filename; return $filename; }