本文整理匯總了PHP中dmString::startsWith方法的典型用法代碼示例。如果您正苦於以下問題:PHP dmString::startsWith方法的具體用法?PHP dmString::startsWith怎麽用?PHP dmString::startsWith使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類dmString
的用法示例。
在下文中一共展示了dmString::startsWith方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: executeGetDmMediaMetadata
public function executeGetDmMediaMetadata(dmWebRequest $request)
{
if (!($mediaId = $request->getParameter('media_id'))) {
return $this->forward404();
}
if (dmString::startsWith($mediaId, 'page:')) {
if (!$this->isAuthorized('page')) {
return $this->forwardSecure();
}
$page = dmDb::table('DmPage')->findOneBy('id', str_replace('page:', '', $mediaId));
return $this->renderJson(array('src' => $this->getHelper()->link($page)->getHref(), 'type' => 'page', 'id' => trim(str_replace('page:', '', $mediaId)), 'title' => $page->get('title')));
} elseif (dmString::startsWith($mediaId, 'media:')) {
if (!$this->isAuthorized('media')) {
return $this->forwardSecure();
}
$id = trim(str_replace('media:', '', $mediaId));
$media = dmDb::table('DmMedia')->findOneBy('id', $id);
$size = explode('x', $media->get('dimensions'));
return $this->renderJson(array('id' => $media->get('id'), 'src' => '/' . $media->getWebPath(), 'legend' => $media->get('legend'), 'mime' => $media->get('mime'), 'size' => $media->get('size'), 'width' => isset($size[0]) ? $size[0] : '', 'height' => isset($size[1]) ? $size[1] : '', 'type' => 'media'));
} else {
return $this->forward404();
}
}
示例2: updateFilePath
protected function updateFilePath($file, Swift_Message $message, $templateName)
{
$id = str_replace('dmFile-', '', $file->id);
if (!$id) {
$id = $file->getAttribute('data-dm-file-id');
}
if (is_numeric($id)) {
$mediaRecord = dmDb::table('dmMedia')->findOneByIdWithFolder($id);
if ($mediaRecord) {
$embed = false;
$embedExtensions = array_map('trim', explode(',', dmConfig::get('mail_template_embed_file_types', 'doc,docx,xls,xlsx,ppt,pptx,pdf,mdb')));
foreach ($embedExtensions as $ext) {
if (dmString::endsWith($file->href, '.' . $ext, false)) {
$embed = true;
break;
}
}
if (dmConfig::get('mail_template_embed_local_files_as_attachments', true) && $embed) {
try {
$file->href = $message->embed(Swift_EmbeddedFile::fromPath(dmOs::join(sfConfig::get('sf_web_dir'), $mediaRecord->getWebPath())));
} catch (Exception $e) {
$this->logError($templateName, 'local', 'file', $file->href);
$file->href = '';
}
} else {
if (file_exists(dmOs::join(sfConfig::get('sf_web_dir'), $link = $mediaRecord->getWebPath()))) {
$file->href = $this->basePath . '/' . $mediaRecord->getWebPath();
} else {
$this->logError($templateName, 'local', 'file', $file->href);
$file->href = '';
}
}
return $file;
}
}
if (dmString::startsWith($file->href, sfConfig::get('sf_root_dir')) || dmString::startsWith($file->href, $this->basePath)) {
return $this->updateLocalFilePath($file, $message, $templateName);
} else {
return $this->updateRemoteFilePath($file, $message, $templateName);
}
}