ArticleType::getPreviewArticleData PHP Method

getPreviewArticleData() public method

If no article was found create an empty one.
public getPreviewArticleData ( ) : object
return object
    public function getPreviewArticleData()
    {
        global $g_ado_db;
        $sql = "SELECT " . $this->m_dbTableName . ".* FROM " . $this->m_dbTableName . ", Articles WHERE " . $this->m_dbTableName . ".NrArticle = Articles.Number AND " . $this->m_dbTableName . ".IdLanguage = Articles.IdLanguage LIMIT 1";
        $row = $g_ado_db->GetRow($sql);
        if (!$row) {
            $destArticleData = new ArticleData($this->m_name, Article::__generateArticleNumber(), 1);
        } else {
            $destArticleData = new ArticleData($this->m_name, $row['NrArticle'], $row['IdLanguage']);
        }
        return $destArticleData;
    }

Usage Example

Example #1
0
        // and also the number of translations associated with an article number
        global $g_ado_db;
        $sql = "SELECT * FROM X$f_src WHERE NrArticle=$f_cur_preview";
        $rows = $g_ado_db->GetAll($sql);
        if (!count($rows)) {
            $errMsgs[] = getGS('There is no article associated with the preview.');
            $ok = false;
        }
    }

    if ($ok) {
        $numberOfTranslations = count($rows);
        $firstLanguage = $rows[0]['IdLanguage'];
        $curPreview = new Article($firstLanguage, $f_cur_preview);
        $articleCreator = new User($curPreview->getCreatorId());
        $articleData = $dest->getPreviewArticleData();
        $dbColumns = $articleData->getUserDefinedColumns(1, true);
        $srcArticleData = $curPreview->getArticleData();
        $srcDbColumns = $srcArticleData->getUserDefinedColumns(1, true);
        $getString = '';
        foreach ($_GET as $k => $v) {
            if ( ($k != 'f_action') && ($k != 'f_preview_action') ) {
                $getString .= "&$k=$v";
            }
        }
        foreach ($_POST as $k => $v) {
            if ( ($k != 'f_action') && ($k != 'f_prev_action') ) {
                $getString .= "&$k=$v";
            }
        }
        $getString = substr($getString, 1);