/**
  * 
  * @param \fpcm\model\articles\article $article
  * @return \fpcm\model\articles\article
  */
 public function run($article = null)
 {
     $termList = new \fpcm\modules\nkorg\tweetextender\model\termlist();
     $terms = $termList->getTerms();
     if (!count($terms)) {
         return $article;
     }
     $moduleArticle = clone $article;
     /* @var $term \fpcm\modules\nkorg\tweetextender\model\term */
     foreach ($terms as $term) {
         $newTitle = preg_replace(array('/(' . $term->getSearchterm() . ')/is'), $term->getReplaceterm(), $moduleArticle->getTitle());
         $moduleArticle->setTitle($newTitle);
     }
     return $moduleArticle;
 }
Exemple #2
0
 public function run($params = null)
 {
     $view = new \fpcm\model\view\module(\fpcm\model\abstracts\module::getModuleKeyByFolder(__DIR__), 'acp', 'main');
     $termlist = new \fpcm\modules\nkorg\tweetextender\model\termlist();
     if (!is_null(\fpcm\classes\http::get('added'))) {
         $view->addNoticeMessage('NKORG_TWEETENTENDER_SAVED_OK');
     }
     if (!is_null(\fpcm\classes\http::get('btnDeleteTerms')) && !is_null(\fpcm\classes\http::get('ids'))) {
         $ids = \fpcm\classes\http::get('ids');
         if ($termlist->deleteTerms($ids)) {
             $view->addNoticeMessage('NKORG_TWEETENTENDER_DELETE_OK');
         } else {
             $view->addErrorMessage('NKORG_TWEETENTENDER_DELETE_FAILED');
         }
     }
     $terms = $termlist->getTerms();
     $view->assign('terms', $terms);
     $view->render();
 }