本文整理汇总了PHP中Horde_Mime_Magic::analyzeData方法的典型用法代码示例。如果您正苦于以下问题:PHP Horde_Mime_Magic::analyzeData方法的具体用法?PHP Horde_Mime_Magic::analyzeData怎么用?PHP Horde_Mime_Magic::analyzeData使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Horde_Mime_Magic
的用法示例。
在下文中一共展示了Horde_Mime_Magic::analyzeData方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: createFile
/**
* Creates a new file in the directory
*
* @param string $name Name of the file
* @param resource|string $data Initial payload
* @return null|string
*/
public function createFile($name, $data = null)
{
list($app) = explode('/', $this->_path);
if (is_resource($data)) {
$content = new Horde_Stream_Existing(array('stream' => $data));
$type = Horde_Mime_Magic::analyzeData($content->getString(0, 100), $this->_mimedb);
} else {
$content = $data;
$type = Horde_Mime_Magic::analyzeData($content, $this->_mimedb);
}
if (!$type) {
$type = Horde_Mime_Magic::filenameToMime($name);
}
try {
$this->_registry->callByPackage($app, 'put', array($this->_path . '/' . $name, $content, $type));
} catch (Horde_Exception $e) {
throw new DAV\Exception($e->getMessage(), $e->getCode(), $e);
}
}
示例2: copy
}
} else {
$file_name = $tmpdir . '/mod_' . $file;
if (!file_exists($file_name)) {
copy($tmpdir . '/' . $file, $file_name);
}
}
if (!file_exists($file_name)) {
Horde::log(sprintf('Image not found [%s]', $file_name), 'ERR');
exit;
}
$file_data = file_get_contents($file_name);
break;
}
/* Load the image object. */
$type = Horde_Mime_Magic::analyzeData($file_data);
$image = $injector->getInstance('Horde_Core_Factory_Image')->create(array('data' => $file_data, 'type' => $type));
/* Check if no editing action required and send the image to browser. */
if (empty($action)) {
$image->display();
exit;
}
/* Image editing required. */
switch ($action) {
case 'rotate':
$image->rotate($vars->v);
break;
case 'flip':
$image->flip();
break;
case 'mirror':
示例3: fromASContact
/**
* Convert an ActiveSync contact message into a hash suitable for
* importing via self::add().
*
* @param Horde_ActiveSync_Message_Contact $message The contact message
* object.
*
* @return array A contact hash.
*/
public function fromASContact(Horde_ActiveSync_Message_Contact $message)
{
$hash = array();
foreach (self::$_asMap as $turbaField => $asField) {
if (!$message->isGhosted($asField)) {
try {
$hash[$turbaField] = $message->{$asField};
} catch (InvalidArgumentException $e) {
}
}
}
/* Requires special handling */
try {
if ($message->getProtocolVersion() >= Horde_ActiveSync::VERSION_TWELVE) {
if (!empty($message->airsyncbasebody)) {
$hash['notes'] = $message->airsyncbasebody->data;
}
} else {
$hash['notes'] = $message->body;
}
} catch (InvalidArgumentException $e) {
}
// picture ($message->picture *should* already be base64 encdoed)
if (!$message->isGhosted('picture')) {
$hash['photo'] = base64_decode($message->picture);
if (!empty($hash['photo'])) {
$hash['phototype'] = Horde_Mime_Magic::analyzeData($hash['photo']);
} else {
$hash['phototype'] = null;
}
}
/* Email addresses */
$hash['emails'] = array();
if (!$message->isGhosted('email1address')) {
$e = Horde_Icalendar_Vcard::getBareEmail($message->email1address);
$hash['emails'][] = $hash['email'] = $e ? $e : '';
}
if (!$message->isGhosted('email2address')) {
$e = Horde_Icalendar_Vcard::getBareEmail($message->email2address);
$hash['emails'][] = $hash['homeEmail'] = $e ? $e : '';
}
if (!$message->isGhosted('email3address')) {
$e = Horde_Icalendar_Vcard::getBareEmail($message->email3address);
$hash['emails'][] = $hash['workEmail'] = $e ? $e : '';
}
$hash['emails'] = implode(',', $hash['emails']);
/* Categories */
if (is_array($message->categories) && count($message->categories)) {
$hash['__tags'] = $message->categories;
}
/* Children */
if (is_array($message->children) && count($message->children)) {
// We use a comma as incoming delimiter as it's the most
// common even though it might be used withing a name string.
$hash['children'] = implode(', ', $message->children);
} elseif (!$message->isGhosted('children')) {
$hash['children'] = '';
}
/* Birthday and Anniversary */
if (!empty($message->birthday)) {
$bday = clone $message->birthday;
$bday->setTimezone(date_default_timezone_get());
$hash['birthday'] = $bday->format('Y-m-d');
} elseif (!$message->isGhosted('birthday')) {
$hash['birthday'] = '';
}
if (!empty($message->anniversary)) {
$anniversary = clone $message->anniversary;
$anniversary->setTimezone(date_default_timezone_get());
$hash['anniversary'] = $anniversary->format('Y-m-d');
} elseif (!$message->isGhosted('anniversary')) {
$hash['anniversary'] = '';
}
/* Countries */
include 'Horde/Nls/Countries.php';
if (!empty($message->homecountry)) {
if (!empty($this->map['homeCountryFree'])) {
$hash['homeCountryFree'] = $message->homecountry;
} else {
$country = array_search($message->homecountry, $countries);
if ($country === false) {
$country = $message->homecountry;
}
$hash['homeCountry'] = $country;
}
} elseif (!$message->isGhosted('homecountry')) {
$hash['homeCountry'] = '';
}
if (!empty($message->businesscountry)) {
if (!empty($this->map['workCountryFree'])) {
$hash['workCountryFree'] = $message->businesscountry;
//.........这里部分代码省略.........
示例4: download
/**
*/
public function download(Horde_Variables $vars)
{
global $wicked;
$page = $vars->get('page', 'Wiki/Home');
$page_id = ($id = $wicked->getPageId($page)) === false ? $page : $id;
$version = $vars->version;
if (empty($version)) {
try {
$attachments = $wicked->getAttachedFiles($page_id);
foreach ($attachments as $attachment) {
if ($attachment['attachment_name'] == $vars->file) {
$version = $attachment['attachment_version'];
}
}
} catch (Wicked_Exception $e) {
}
if (empty($version)) {
// If we redirect here, we cause an infinite loop with inline
// attachments.
header('HTTP/1.1 404 Not Found');
exit;
}
}
try {
$data = $wicked->getAttachmentContents($page_id, $vars->file, $version);
$wicked->logAttachmentDownload($page_id, $vars->file);
} catch (Wicked_Exception $e) {
// If we redirect here, we cause an infinite loop with inline
// attachments.
header('HTTP/1.1 404 Not Found');
echo $e->getMessage();
exit;
}
$type = Horde_Mime_Magic::analyzeData($data, isset($conf['mime']['magic_db']) ? $conf['mime']['magic_db'] : null);
if ($type === false) {
$type = Horde_Mime_Magic::filenameToMime($vars->file, false);
}
return array('data' => $data, 'file' => $vars->file, 'type' => $type);
}