getFileName() public method

public getFileName ( ) : string
return string
コード例 #1
0
ファイル: edit.php プロジェクト: sourcefabric/newscoop
if (strstr($attachmentObj->getMimeType(), "audio/") || strstr($attachmentObj->getMimeType(), "video/")) {
    echo new MediaPlayer($attachmentObj->getAttachmentUrl() . '?g_show_in_browser=1', $attachmentObj->getMimeType());
}
?>
</td>
</tr>
<?php 
if (strstr($attachmentObj->getMimeType(), "application/") || strstr($attachmentObj->getMimeType(), "image/")) {
    ?>
<TR>
    <TD ALIGN="RIGHT"><?php 
    echo $translator->trans('File Name', array(), 'article_files');
    ?>
:</TD>
    <TD><?php 
    echo htmlspecialchars($attachmentObj->getFileName());
    ?>
 &nbsp; <A
        HREF="<?php 
    p($attachmentObj->getAttachmentUrl());
    ?>
"><IMG
        TITLE="<?php 
    echo $translator->trans('Download', array(), 'article_files');
    ?>
" BORDER="0" ALIGN="absmiddle" SRC="<?php 
    p($Campsite["ADMIN_IMAGE_BASE_URL"]);
    ?>
/download.png" /></A></TD>
</TR>
<?php 
コード例 #2
0
ファイル: attachment.php プロジェクト: nidzix/Newscoop
$filename = urldecode(basename($attachment));
$extension = '';
if (($extensionStart = strrpos($attachment, '.')) !== false) {
    $extension = strtolower(substr($attachment, $extensionStart + 1));
    $attachment = substr($attachment, 0, $extensionStart);
}
$attachmentId = (int) ltrim($attachment, " 0\t\n\r");
$attachmentObj = new Attachment($attachmentId);
if (!$attachmentObj->exists()) {
    header('HTTP/1.0 404 Not Found');
    echo 'Error 404: File not found';
    exit;
}
header('Content-Type: ' . $attachmentObj->getMimeType());
if ($g_download == 1) {
    header('Content-Disposition: ' . $attachmentObj->getContentDisposition() . '; filename="' . $attachmentObj->getFileName()) . '"';
} else {
    if ($g_show_in_browser == 1) {
        header('Content-Disposition: inline; filename="' . $attachmentObj->getFileName()) . '"';
    } else {
        if (!$attachmentObj->getContentDisposition() && strstr($attachmentObj->getMimeType(), 'image/') && (strstr($_SERVER['HTTP_ACCEPT'], $attachmentObj->getMimeType()) || strstr($_SERVER['HTTP_ACCEPT'], '*/*'))) {
            header('Content-Disposition: inline; filename="' . $attachmentObj->getFileName()) . '"';
        } else {
            header('Content-Disposition: ' . $attachmentObj->getContentDisposition() . '; filename="' . $attachmentObj->getFileName()) . '"';
        }
    }
}
header('Content-Length: ' . $attachmentObj->getSizeInBytes());
$filePath = $attachmentObj->getStorageLocation();
if (file_exists($filePath)) {
    readfile($filePath);
コード例 #3
0
 /**
  * Action to make the table
  */
 public function tableAction()
 {
     $this->getHelper('contextSwitch')->addActionContext('table', 'json')->initContext();
     $view = $this->view;
     $table = $this->getHelper('datatable');
     /* @var $table Action_Helper_Datatable */
     $table->setDataSource($this->feedbackRepository);
     $table->setOption('oLanguage', array('sSearch' => ''));
     $table->setCols(array('index' => $view->toggleCheckbox(), 'user' => getGS('User'), 'message' => getGS('Date') . ' / ' . getGS('Message'), 'url' => getGS('Coming from')), array('index' => false));
     $index = 1;
     $acceptanceRepository = $this->_helper->entity->getRepository('Newscoop\\Entity\\Comment\\Acceptance');
     $table->setHandle(function ($feedback) use($view, &$index, $acceptanceRepository) {
         $user = $feedback->getUser();
         $url = $feedback->getUrl();
         $message = $feedback->getMessage();
         $publication = $feedback->getPublication();
         $section = $feedback->getSection();
         $article = $feedback->getArticle();
         if ($article) {
             $article_name = $article->getName();
             $article_url = $view->linkArticle($article);
         } else {
             $article_name = getGS('None');
             $article_url = $view->baseUrl('admin/feedback');
         }
         if ($section) {
             $section_name = $section->getName();
         } else {
             $section_name = getGS('None');
         }
         $attachment = array();
         $attachment['type'] = $feedback->getAttachmentType();
         $attachment['id'] = $feedback->getAttachmentId();
         if ($attachment['type'] == 'image') {
             $image = new Image($attachment['id']);
             $attachment['name'] = $image->getImageFileName();
             $attachment['status'] = $image->getStatus();
             $attachment['thumbnail'] = $image->getThumbnailUrl();
             $attachment['approve_url'] = $view->url(array('action' => 'approve', 'type' => 'image', 'format' => 'json', 'id' => $attachment['id']));
         }
         if ($attachment['type'] == 'document') {
             $document = new Attachment($attachment['id']);
             $attachment['name'] = $document->getFileName();
             $attachment['status'] = $document->getStatus();
             $attachment['approve_url'] = $view->url(array('action' => 'approve', 'type' => 'document', 'format' => 'json', 'id' => $attachment['id']));
         }
         $banned = $acceptanceRepository->checkBanned(array('name' => $user->getName(), 'email' => '', 'ip' => ''), $publication);
         if ($banned['name'] == true) {
             $banned = true;
         } else {
             $banned = false;
         }
         return array('index' => $index++, 'user' => array('username' => $user->getUsername(), 'name' => $user->getFirstName(), 'email' => $user->getEmail(), 'avatar' => (string) $view->getAvatar($user->getEmail(), array('img_size' => 50, 'default_img' => 'wavatar')), 'banurl' => $view->url(array('controller' => 'user', 'action' => 'toggle-ban', 'user' => $user->getId(), 'publication' => $publication->getId())), 'is_banned' => $banned), 'message' => array('id' => $feedback->getId(), 'created' => array('date' => $feedback->getTimeCreated()->format('Y.m.d'), 'time' => $feedback->getTimeCreated()->format('H:i:s')), 'message' => $feedback->getMessage(), 'subject' => $feedback->getSubject(), 'status' => $feedback->getStatus(), 'attachmentType' => $feedback->getAttachmentType(), 'action' => array('reply' => $view->url(array('action' => 'reply', 'format' => 'json'))), 'url' => $url, 'publication' => $publication->getName(), 'section' => $section_name, 'article' => array('name' => $article_name, 'url' => $article_url)), 'attachment' => $attachment);
     });
     $table->setOption('fnDrawCallback', 'datatableCallback.draw')->setOption('fnRowCallback', 'datatableCallback.row')->setOption('fnServerData', 'datatableCallback.addServerData')->setOption('fnInitComplete', 'datatableCallback.init')->setOption('sDom', '<"top">lf<"#actionExtender">rit<"bottom"ip>')->setStripClasses()->toggleAutomaticWidth(false)->setDataProp(array('index' => null, 'user' => null, 'message' => null, 'url' => null))->setClasses(array('index' => 'commentId', 'user' => 'commentUser', 'message' => 'commentTimeCreated', 'url' => 'commentThread'));
     try {
         $table->dispatch();
     } catch (Exception $e) {
         var_dump($e);
         exit;
     }
     //$this->editForm->setSimpleDecorate()->setAction($this->_helper->url('update'));
     //$this->view->editForm = $this->editForm;
 }
コード例 #4
0
ファイル: edit.php プロジェクト: nistormihai/Newscoop
<div class="indent">
<IMG SRC="<?php echo $attachmentObj->getAttachmentUrl(); ?>" BORDER="0" ALT="<?php echo htmlspecialchars($attachmentObj->getDescription($f_language_selected)); ?>">
</div>
<P>
<?php } ?>
<FORM NAME="dialog" METHOD="POST" ACTION="do_edit.php" >
<TABLE BORDER="0" CELLSPACING="0" CELLPADDING="6" class="table_input" width="400px">
<TR>
	<TD COLSPAN="2">
		<B><?php  p($title); ?></B>
		<HR NOSHADE SIZE="1" COLOR="BLACK">
	</TD>
</TR>
<TR>
	<TD ALIGN="RIGHT"><?php putGS('File Name'); ?>:</TD>
	<TD><?php echo htmlspecialchars($attachmentObj->getFileName()); ?> &nbsp; <A
		HREF="/attachment/<?php p(basename($attachmentObj->getStorageLocation())); ?>"><IMG
		TITLE="<?php putGS('Download'); ?>" BORDER="0" ALIGN="absmiddle" SRC="<?php p($Campsite["ADMIN_IMAGE_BASE_URL"]);?>/download.png" /></A></TD>
</TR>
<TR>
	<TD ALIGN="RIGHT"><?php  putGS('Description'); ?>:</TD>
	<TD>
	<INPUT TYPE="TEXT" NAME="f_description" VALUE="<?php echo htmlspecialchars($attachmentObj->getDescription($f_language_selected)); ?>" class="input_text" SIZE="32" <?php p($isReadOnly); ?>>
	</TD>
</TR>
<TR>
	<TD ALIGN="RIGHT"><?php putGS('File Size'); ?>:</TD>
	<TD><?php p(camp_format_bytes($attachmentObj->getSizeInBytes())); ?></TD>
</TR>
<TR>
	<TD ALIGN="left" colspan="2" style="padding-left: 15px;"><?php  putGS("Should this file only be available for this translation of the article, or for all translations?"); ?></TD>
コード例 #5
0
ファイル: do_del.php プロジェクト: nistormihai/Newscoop
if (!$g_user->hasPermission("DeleteFile")) {
	camp_html_display_error(getGS("You do not have the right to delete file attachments."), null, true);
	exit;
}

$articleObj = new Article($f_language_selected, $f_article_number);

if (!$articleObj->exists()) {
	camp_html_display_error(getGS("Article does not exist."), null, true);
	exit;
}

$attachmentObj = new Attachment($f_attachment_id);
if (!$attachmentObj->exists()) {
	camp_html_display_error(getGS('Attachment does not exist.'), null, true);
	exit;
}
$filePath = dirname($attachmentObj->getStorageLocation()) . '/' . $attachmentObj->getFileName();
ArticleAttachment::RemoveAttachmentFromArticle($f_attachment_id, $f_article_number);
$logtext = getGS('File #$1 "$2" unattached',
		 $attachmentObj->getAttachmentId(), $attachmentObj->getFileName());
Log::ArticleMessage($articleObj, $logtext, null, 39);

$attachmentFileName = $attachmentObj->getFileName();

// Go back to article.
camp_html_add_msg(getGS("File '$1' unattached.", $attachmentFileName), "ok");
camp_html_goto_page(camp_html_article_url($articleObj, $f_language_id, 'edit.php'));
?>
コード例 #6
0
ファイル: do_del.php プロジェクト: sourcefabric/newscoop
$f_article_number = Input::Get('f_article_number', 'int', 0);
$f_attachment_id = Input::Get('f_attachment_id', 'int', 0);
// Check input
if (!Input::IsValid()) {
    camp_html_display_error($translator->trans('Invalid input: $1', array('$1' => Input::GetErrorString())), null, true);
    exit;
}
if (!$g_user->hasPermission("DeleteFile")) {
    camp_html_display_error($translator->trans("You do not have the right to delete file attachments.", array(), 'article_files'), null, true);
    exit;
}
$articleObj = new Article($f_language_selected, $f_article_number);
if (!$articleObj->exists()) {
    camp_html_display_error($translator->trans("Article does not exist."), null, true);
    exit;
}
$attachmentObj = new Attachment($f_attachment_id);
if (!$attachmentObj->exists()) {
    camp_html_display_error($translator->trans('Attachment does not exist.', array(), 'article_files'), null, true);
    exit;
}
$filePath = dirname($attachmentObj->getStorageLocation()) . '/' . $attachmentObj->getFileName();
ArticleAttachment::RemoveAttachmentFromArticle($f_attachment_id, $f_article_number);
$logtext = $translator->trans('File #$1 "$2" unattached', array('$1' => $attachmentObj->getAttachmentId(), '$2' => $attachmentObj->getFileName()), 'article_files');
Log::ArticleMessage($articleObj, $logtext, null, 39);
$attachmentFileName = $attachmentObj->getFileName();
$cacheService = \Zend_Registry::get('container')->getService('newscoop.cache');
$cacheService->clearNamespace('attachments');
// Go back to article.
camp_html_add_msg($translator->trans("File \$1 unattached.", array('$1' => $attachmentFileName), 'article_files'), "ok");
camp_html_goto_page(camp_html_article_url($articleObj, $f_language_id, 'edit.php'));
コード例 #7
0
 /**
  * Action to make the table
  */
 public function tableAction()
 {
     $translator = \Zend_Registry::get('container')->getService('translator');
     $this->getHelper('contextSwitch')->addActionContext('table', 'json')->initContext();
     $view = $this->view;
     $table = $this->getHelper('datatable');
     /* @var $table Action_Helper_Datatable */
     $table->setDataSource($this->feedbackRepository);
     $table->setOption('oLanguage', array('oPaginate' => array('sFirst' => $translator->trans('First', array(), 'comments'), 'sLast' => $translator->trans('Last', array(), 'comments'), 'sNext' => $translator->trans('Next'), 'sPrevious' => $translator->trans('Previous')), 'sZeroRecords' => $translator->trans('No records found.', array(), 'comments'), 'sSearch' => $translator->trans('Search'), 'sInfo' => $translator->trans('Showing _START_ to _END_ of _TOTAL_ entries', array(), 'comments'), 'sEmpty' => $translator->trans('No entries to show', array(), 'comments'), 'sInfoFiltered' => $translator->trans(' - filtering from _MAX_ records', array(), 'comments'), 'sLengthMenu' => $translator->trans('Display _MENU_ records', array(), 'comments'), 'sInfoEmpty' => ''));
     $table->setCols(array('id' => $view->toggleCheckbox(), 'user' => $translator->trans('User', array(), 'comments'), 'message' => $translator->trans('Date') . ' / ' . $translator->trans('Message', array(), 'comments'), 'url' => $translator->trans('Coming from', array(), 'comments')), array('id' => false));
     $table->setInitialSorting(array('id' => 'desc'));
     $index = 1;
     $acceptanceRepository = $this->_helper->entity->getRepository('Newscoop\\Entity\\Comment\\Acceptance');
     $table->setHandle(function ($feedback) use($view, &$index, $acceptanceRepository) {
         $user = $feedback->getUser();
         $url = $feedback->getUrl();
         $message = $feedback->getMessage();
         $publication = $feedback->getPublication();
         $section = $feedback->getSection();
         $article = $feedback->getArticle();
         $translator = \Zend_Registry::get('container')->getService('translator');
         if ($article) {
             $article_name = $article->getName();
             $article_url = $view->linkArticle($article);
         } else {
             $article_name = $translator->trans('None', array(), 'comments');
             $article_url = $view->baseUrl('admin/feedback');
         }
         if ($section) {
             $section_name = $section->getName();
         } else {
             $section_name = $translator->trans('None', array(), 'comments');
         }
         $attachment = array();
         $attachment['type'] = $feedback->getAttachmentType();
         $attachment['id'] = $feedback->getAttachmentId();
         if ($attachment['type'] == 'image') {
             $image = new Image($attachment['id']);
             $attachment['name'] = $image->getImageFileName();
             $attachment['status'] = $image->getStatus();
             $attachment['thumbnail'] = $image->getThumbnailUrl();
             $attachment['approve_url'] = $view->url(array('action' => 'approve', 'type' => 'image', 'format' => 'json', 'id' => $attachment['id']));
         }
         if ($attachment['type'] == 'document') {
             $document = new Attachment($attachment['id']);
             $attachment['name'] = $document->getFileName();
             $attachment['status'] = $document->getStatus();
             $attachment['approve_url'] = $view->url(array('action' => 'approve', 'type' => 'document', 'format' => 'json', 'id' => $attachment['id']));
         }
         $banned = $acceptanceRepository->checkBanned(array('name' => $user->getName(), 'email' => '', 'ip' => ''), $publication);
         if ($banned['name'] == true) {
             $banned = true;
         } else {
             $banned = false;
         }
         $zendRouter = \Zend_Registry::get('container')->getService('zend_router');
         $userUrl = $zendRouter->assemble(array_merge(array('module' => 'default', 'controller' => 'user', 'action' => 'profile')), 'default', true);
         return array('id' => $index++, 'user' => array('username' => strip_tags($user->getUsername()), 'userUrl' => $userUrl . '/' . strip_tags($user->getUsername()), 'name' => $user->getFirstName(), 'email' => $user->getEmail(), 'avatar' => (string) $view->getAvatar($user->getEmail(), array('img_size' => 50, 'default_img' => 'wavatar')), 'banurl' => $view->url(array('controller' => 'user', 'action' => 'toggle-ban', 'user' => $user->getId(), 'publication' => $publication->getId())), 'is_banned' => $banned), 'message' => array('id' => $feedback->getId(), 'created' => array('date' => $feedback->getTimeCreated()->format('Y.m.d'), 'time' => $feedback->getTimeCreated()->format('H:i:s')), 'message' => $feedback->getMessage(), 'subject' => $feedback->getSubject(), 'status' => $feedback->getStatus(), 'attachmentType' => $feedback->getAttachmentType(), 'action' => array('reply' => $view->url(array('action' => 'reply', 'format' => 'json'))), 'url' => $url, 'publication' => $publication->getName(), 'section' => $section_name, 'article' => array('name' => $article_name, 'url' => $article_url)), 'attachment' => $attachment);
     });
     $table->setOption('fnDrawCallback', 'datatableCallback.draw')->setOption('fnRowCallback', 'datatableCallback.row')->setOption('fnServerData', 'datatableCallback.addServerData')->setOption('fnInitComplete', 'datatableCallback.init')->setOption('sDom', '<"top">lf<"#actionExtender">rit<"bottom"ip>')->setStripClasses()->toggleAutomaticWidth(false)->setDataProp(array('id' => null, 'user' => null, 'message' => null, 'url' => null))->setClasses(array('id' => 'commentId', 'user' => 'commentUser', 'message' => 'commentTimeCreated', 'url' => 'commentThread'));
     try {
         $table->dispatch();
     } catch (Exception $e) {
         throw new \Exception($e->getMessage());
     }
     //$this->editForm->setSimpleDecorate()->setAction($this->_helper->url('update'));
     //$this->view->editForm = $this->editForm;
 }
コード例 #8
0
ファイル: do_del.php プロジェクト: nidzix/Newscoop
    exit;
}
if (!$g_user->hasPermission('DeleteFile')) {
    camp_html_display_error(getGS('You do not have the right to delete files.'), null, true);
    exit;
}
$f_debate_nr = Input::Get('f_debate_nr', 'int', 0);
$f_debateanswer_nr = Input::Get('f_debateanswer_nr', 'int', 0);
$f_fk_language_id = Input::Get('f_fk_language_id', 'int', 0);
$f_attachment_id = Input::Get('f_attachment_id', 'int', 0);
$attachmentObj = new Attachment($f_attachment_id);
if (!$attachmentObj->exists()) {
    camp_html_display_error(getGS('Attachment does not exist.'), null, true);
    exit;
}
$filePath = dirname($attachmentObj->getStorageLocation()) . '/' . $attachmentObj->getFileName();
if (!is_writable(dirname($filePath))) {
    camp_html_add_msg(camp_get_error_message(CAMP_ERROR_DELETE_FILE, $filePath, basename($attachmentObj->getStorageLocation())));
    //camp_html_goto_page(camp_html_article_url($articleObj, $f_language_id, 'edit.php'));
    exit;
}
$DebateAnswerAttachment = new DebateAnswerAttachment($f_debate_nr, $f_debateanswer_nr, $f_attachment_id);
$DebateAnswerAttachment->delete();
// Go back to upload screen.
camp_html_add_msg(getGS("File '\$1' deleted.", $attachmentObj->getFileName()), "ok");
$attachmentObj->delete();
?>
<script>
location.href="popup.php?f_debate_nr=<?php 
p($f_debate_nr);
?>
コード例 #9
0
ファイル: do_edit.php プロジェクト: nistormihai/Newscoop
$issueObj = new Issue($f_publication_id, $f_language_id, $f_issue_number);
$sectionObj = new Section($f_publication_id, $f_issue_number, $f_language_id, $f_section_number);

if (!$articleObj->exists()) {
	camp_html_display_error(getGS("Article does not exist."), null, true);
	exit;
}

// This file can only be accessed if the user has the right to change articles
// or the user created this article and it hasnt been published yet.
if (!$articleObj->userCanModify($g_user)) {
	camp_html_display_error(getGS('You do not have the right to change the article.'), null, true);
	exit;
}

$attachmentObj = new Attachment($f_attachment_id);
$attachmentObj->setDescription($f_language_selected, $f_description);
if ($f_language_specific == "yes") {
	$attachmentObj->setLanguageId($f_language_selected);
} else {
	$attachmentObj->setLanguageId(null);
}
if ($f_content_disposition == "attachment" || empty($f_content_disposition)) {
	$attachmentObj->setContentDisposition($f_content_disposition);
}

// Go back to article.
camp_html_add_msg(getGS("File '$1' updated.", $attachmentObj->getFileName()), "ok");
camp_html_goto_page(camp_html_article_url($articleObj, $f_language_id, 'edit.php'));

?>
コード例 #10
0
ファイル: edit-attachment.php プロジェクト: nidzix/Newscoop
} else {
    $label_text = getGS('View attachment');
}
include_once $GLOBALS['g_campsiteDir'] . "/{$ADMIN_DIR}/html_head.php";
include_once $GLOBALS['g_campsiteDir'] . "/{$ADMIN_DIR}/javascript_common.php";
echo '<div class="toolbar clearfix"><span class="article-title">' . $label_text . '</span></div>';
?>

<?php 
camp_html_display_msgs();
?>

<div class="wrapper"><div class="main-content-wrapper">

<h2><?php 
echo $object->getFileName();
?>
</h2>
<p class="dates"><?php 
putGS('Created');
?>
: <?php 
echo $object->getTimeCreated();
?>
, <?php 
putGS('Last modified');
?>
: <?php 
echo $object->getLastModified();
?>
</p>
コード例 #11
0
}
else {
    $crumbs[] = array(getGS('View attachment'), "");
}
$breadcrumbs = camp_html_breadcrumbs($crumbs);

include_once($GLOBALS['g_campsiteDir']."/$ADMIN_DIR/javascript_common.php");

echo $breadcrumbs;
?>

<?php camp_html_display_msgs(); ?>

<div class="wrapper"><div class="main-content-wrapper">

<h2><?php echo $object->getFileName(); ?></h2>
<p class="dates"><?php putGS('Created'); ?>: <?php echo $object->getTimeCreated(); ?>, <?php putGS('Last modified'); ?>: <?php echo $object->getLastModified(); ?></p>

<?php echo new MediaPlayer($object->getAttachmentUrl() . '?g_show_in_browser=1', $object->getMimeType()); ?>

<dl class="attachment">
    <dt><?php putGS('Type'); ?>:</dt>
    <dd><?php echo $object->getMimeType(); ?></dd>

    <dt><?php putGS('Size'); ?>:</dt>
    <dd><?php echo MediaList::FormatFileSize($object->getSizeInBytes()); ?></dd>

    <?php if ($object->getCharset()) { ?>
    <dt><?php putGS('Charset'); ?>:</dt>
    <dd><?php echo $object->getCharset(); ?></dd>
    <?php } ?>