OnArticleDelete() public static method

After article removal (with all its languages), the map is preserved with just the last language.
public static OnArticleDelete ( integer $p_articleNumber ) : void
$p_articleNumber integer
return void
Esempio n. 1
0
    /**
     * Delete article from database.  This will
     * only delete one specific translation of the article.
     *
     * @return boolean
     */
    public function delete()
    {
        // It is an optimization to put these here because in most cases
        // you dont need these files.
        require_once($GLOBALS['g_campsiteDir'].'/classes/ArticleImage.php');
        require_once($GLOBALS['g_campsiteDir'].'/classes/ArticleTopic.php');
        require_once($GLOBALS['g_campsiteDir'].'/classes/ArticleIndex.php');
        require_once($GLOBALS['g_campsiteDir'].'/classes/ArticleAttachment.php');
        require_once($GLOBALS['g_campsiteDir'].'/classes/ArticleComment.php');
        require_once($GLOBALS['g_campsiteDir'].'/classes/ArticlePublish.php');

        // Delete scheduled publishing
        ArticlePublish::OnArticleDelete($this->m_data['Number'], $this->m_data['IdLanguage']);

        // Delete Article Comments
        ArticleComment::OnArticleDelete($this->m_data['Number'], $this->m_data['IdLanguage']);

        // is this the last translation?
        if (count($this->getLanguages()) <= 1) {
            // Delete image pointers
            ArticleImage::OnArticleDelete($this->m_data['Number']);

            // Delete topics pointers
            ArticleTopic::OnArticleDelete($this->m_data['Number']);

            // Delete file pointers
            ArticleAttachment::OnArticleDelete($this->m_data['Number']);

            // Delete indexes
            ArticleIndex::OnArticleDelete($this->getPublicationId(), $this->getIssueNumber(),
                $this->getSectionNumber(), $this->getLanguageId(), $this->getArticleNumber());
        }

        // geo-map processing
        // is this the last translation?
        if (count($this->getLanguages()) <= 1) {
            // unlink the article-map pointers
            Geo_Map::OnArticleDelete($this->m_data['Number']);
        }
        else {
            // removing non-last translation of the map poi contents
            Geo_Map::OnLanguageDelete($this->m_data['Number'], $this->m_data['IdLanguage']);
        }

        // Delete row from article type table.
        $articleData = new ArticleData($this->m_data['Type'],
            $this->m_data['Number'],
            $this->m_data['IdLanguage']);
        $articleData->delete();

        $tmpObj = clone $this; // for log
        $tmpData = $this->m_data;
        $tmpData['languageName'] = $this->getLanguageName();
        // Delete row from Articles table.
        $deleted = parent::delete();

        if ($deleted) {
            if (function_exists("camp_load_translation_strings")) {
                camp_load_translation_strings("api");
            }
            Log::ArticleMessage($tmpObj, getGS('Article deleted.'), null, 32);
        }
        $this->m_cacheUpdate = true;
        return $deleted;
    } // fn delete
Esempio n. 2
0
 /**
  * Delete article from database.  This will
  * only delete one specific translation of the article.
  *
  * @return boolean
  */
 public function delete()
 {
     // It is an optimization to put these here because in most cases
     // you dont need these files.
     require_once $GLOBALS['g_campsiteDir'] . '/classes/ArticleImage.php';
     require_once $GLOBALS['g_campsiteDir'] . '/classes/ArticleTopic.php';
     require_once $GLOBALS['g_campsiteDir'] . '/classes/ArticleIndex.php';
     require_once $GLOBALS['g_campsiteDir'] . '/classes/ArticleAttachment.php';
     require_once $GLOBALS['g_campsiteDir'] . '/classes/ArticlePublish.php';
     // Delete scheduled publishing
     ArticlePublish::OnArticleDelete($this->m_data['Number'], $this->m_data['IdLanguage']);
     $translator = \Zend_Registry::get('container')->getService('translator');
     // Delete Article Comments
     // @todo change this with DOCTRINE2 CASCADE DELETE
     $em = Zend_Registry::get('container')->getService('em');
     $repository = $em->getRepository('Newscoop\\Entity\\Comment');
     $repository->deleteArticle($this->m_data['Number'], $this->m_data['IdLanguage']);
     $repository = $em->getRepository('Newscoop\\Entity\\ArticleDatetime');
     $repository->deleteByArticle($this->m_data['Number']);
     $em->flush();
     // is this the last translation?
     if (count($this->getLanguages()) <= 1) {
         // Delete image pointers
         ArticleImage::OnArticleDelete($this->m_data['Number']);
         // Delete topics pointers
         ArticleTopic::OnArticleDelete($this->m_data['Number']);
         // Delete file pointers
         ArticleAttachment::OnArticleDelete($this->m_data['Number']);
         // Delete related articles
         ContextBox::OnArticleDelete($this->m_data['Number']);
         ContextBoxArticle::OnArticleDelete($this->m_data['Number']);
         // Delete the article from playlists
         $em = Zend_Registry::get('container')->getService('em');
         $repository = $em->getRepository('Newscoop\\Entity\\PlaylistArticle');
         $repository->deleteArticle($this->m_data['Number']);
         $em->flush();
         // Delete indexes
         ArticleIndex::OnArticleDelete($this->getPublicationId(), $this->getIssueNumber(), $this->getSectionNumber(), $this->getLanguageId(), $this->getArticleNumber());
     }
     // geo-map processing
     // is this the last translation?
     if (count($this->getLanguages()) <= 1) {
         // unlink the article-map pointers
         Geo_Map::OnArticleDelete($this->m_data['Number']);
     } else {
         // removing non-last translation of the map poi contents
         Geo_Map::OnLanguageDelete($this->m_data['Number'], $this->m_data['IdLanguage']);
     }
     // Delete row from article type table.
     $articleData = new ArticleData($this->m_data['Type'], $this->m_data['Number'], $this->m_data['IdLanguage']);
     $articleData->delete();
     $tmpObj = clone $this;
     // for log
     $tmpData = $this->m_data;
     $tmpData['languageName'] = $this->getLanguageName();
     // Delete row from Articles table.
     $deleted = parent::delete();
     if ($deleted) {
         $cacheService = \Zend_Registry::get('container')->getService('newscoop.cache');
         $cacheService->clearNamespace('article');
         Log::ArticleMessage($tmpObj, $translator->trans('Article deleted.', array(), 'api'), null, 32);
     }
     $this->m_cacheUpdate = true;
     return $deleted;
 }