GetAttachmentsByArticleNumber() public static method

Get all the attachments that belong to this article.
public static GetAttachmentsByArticleNumber ( integer $p_articleNumber, integer $p_languageId = null ) : array
$p_articleNumber integer
$p_languageId integer
return array
 /**
  * Get all the files and directories of a relative path.
  *
  * @param string $p_articleId
  *
  * @return array of file and path information.
  * <code>
  *   array('url'=>'full url',
  *         'storage'=>'full file path')
  * </code>
  */
 function getFiles($p_articleId, $p_languageId = null)
 {
     $files = array();
     if ($this->isValidBase() == false) {
         return $files;
     }
     $articleAttachments = ArticleAttachment::GetAttachmentsByArticleNumber($p_articleId, $p_languageId);
     foreach ($articleAttachments as $articleAttachment) {
         if (!$this->m_config['validate_files']) {
             $file['attachment'] = $articleAttachment;
             $file['url'] = $articleAttachment->getAttachmentUrl();
             $file['storage'] = $articleAttachment->getStorageLocation();
             $files[$articleAttachment->getAttachmentId()] = $file;
         }
     }
     ksort($files);
     return $files;
 }
 /**
  * Get all the files and directories of a relative path.
  *
  * @param string $p_articleId
  *
  * @return array of file and path information.
  * <code>
  *   array('url'=>'full url',
  *         'storage'=>'full file path')
  * </code>
  */
 function getFiles($p_articleId, $p_languageId = null, $p_filter = true)
 {
     $files = array();
     if ($this->isValidBase() == false) {
         return $files;
     }
     $mediaFormats = array();
     if ($p_filter == true) {
         $mediaFormats = explode(',', $this->m_config['media_formats']);
     }
     $articleAttachments = ArticleAttachment::GetAttachmentsByArticleNumber($p_articleId, $p_languageId);
     foreach ($articleAttachments as $articleAttachment) {
         if (!$this->m_config['validate_files']) {
             if (in_array($articleAttachment->getExtension(), $mediaFormats)) {
                 $file['attachment'] = $articleAttachment;
                 $file['url'] = $articleAttachment->getAttachmentUrl();
                 $file['storage'] = $articleAttachment->getStorageLocation();
                 $files[$articleAttachment->getAttachmentId()] = $file;
             }
         }
     }
     ksort($files);
     return $files;
 }
Beispiel #3
0
 protected function hasAttachments()
 {
     $attachments = ArticleAttachment::GetAttachmentsByArticleNumber($this->m_dbObject->getProperty('Number'));
     return (int)(sizeof($attachments) > 0);
 }
Beispiel #4
0
    $userSection = $blogService->getSection($g_user);
    if (empty($userSection) || $userSection->getSectionId() != $articleObj->getSection()->getSectionId()) {
        camp_html_display_error(getGS("You're not allowed to edit article."));
        exit;
    }
}
$articleData = $articleObj->getArticleData();
// Get article type fields.
$dbColumns = $articleData->getUserDefinedColumns(FALSE, TRUE);
$articleType = new ArticleType($articleObj->getType());
$articleImages = ArticleImage::GetImagesByArticleNumber($f_article_number);
$lockUserObj = new User($articleObj->getLockedByUser());
$articleCreator = new User($articleObj->getCreatorId());
$articleEvents = ArticlePublish::GetArticleEvents($f_article_number, $f_language_selected, TRUE);
$articleTopics = ArticleTopic::GetArticleTopics($f_article_number);
$articleFiles = ArticleAttachment::GetAttachmentsByArticleNumber($f_article_number, $f_language_selected);
$articleLanguages = $articleObj->getLanguages();
// Create displayable "last modified" time.
$lastModified = strtotime($articleObj->getLastModified());
$today = getdate();
$savedOn = getdate($lastModified);
$savedToday = true;
if ($today['year'] != $savedOn['year'] || $today['mon'] != $savedOn['mon'] || $today['mday'] != $savedOn['mday']) {
    $savedToday = FALSE;
}
$sectionObj = null;
$showComments = FALSE;
$showCommentControls = FALSE;
if ($f_publication_id > 0) {
    $publicationObj = new Publication($f_publication_id);
    if ($publicationObj->exists()) {
Beispiel #5
0
 protected function hasAttachments()
 {
     $cacheService = \Zend_Registry::get('container')->getService('newscoop.cache');
     $cacheKey = $cacheService->getCacheKey(array('hasAttachments', $this->m_dbObject->getProperty('Number')), 'attachments');
     if ($cacheService->contains($cacheKey)) {
         $attachments = $cacheService->fetch($cacheKey);
     } else {
         $attachments = ArticleAttachment::GetAttachmentsByArticleNumber($this->m_dbObject->getProperty('Number'));
         $cacheService->save($cacheKey, $attachments);
     }
     return (int) (sizeof($attachments) > 0);
 }