/** * Create title for content element and return it as string. If no title * exists return content element as object. * * @param integer $intId * @param boolean $booClGroup * @return DB_Mysql_Result|string */ public function createContentTitle($intId, $booClGroup) { $objContent = $this->_objDatabase->getContentObject($intId); $strHeadline = $this->_getHeadlineValue($objContent); $arrTitle = array(); switch ($objContent->type) { case 'headline': case 'gallery': case 'downloads': if ($strHeadline) { $arrTitle['title'] = $strHeadline; } break; case 'text': if ($strHeadline) { $arrTitle['title'] = $strHeadline; } elseif ($objContent->text) { $arrTitle['title'] = $objContent->text; } break; case 'html': if ($objContent->html) { $arrTitle['title'] = $objContent->html; } break; case 'list': $arrList = deserialize($objContent->listitems); if ($strHeadline) { $arrTitle['title'] = $strHeadline; } elseif ($arrList[0]) { $arrTitle['title'] = $arrList[0]; } break; case 'table': $arrTable = deserialize($objContent->tableitems); if ($strHeadline) { $arrTitle['title'] = $strHeadline; } elseif ($arrTable[0][0]) { $arrTitle['title'] = $arrTable[0][0]; } break; case 'accordion': if ($objContent->mooHeadline) { $arrTitle['title'] = $objContent->mooHeadline; } break; case 'code': if ($strHeadline) { $arrTitle['title'] = $strHeadline; } elseif ($objContent->code) { $arrTitle['title'] = $objContent->code; } break; case 'hyperlink': case 'download': if ($strHeadline) { $arrTitle['title'] = $strHeadline; } elseif ($objContent->linkTitle) { $arrTitle['title'] = $objContent->linkTitle; } break; case 'toplink': if ($objContent->linkTitle) { $arrTitle['title'] = $objContent->linkTitle; } break; case 'image': if ($strHeadline) { $arrTitle['title'] = $strHeadline; } elseif ($objContent->caption) { $arrTitle['title'] = $objContent->caption; } elseif ($objContent->alt) { $arrTitle['title'] = $objContent->alt; } break; default: // HOOK: call the hooks for clipboardContentTitle if (isset($GLOBALS['TL_HOOKS']['clipboardContentTitle']) && is_array($GLOBALS['TL_HOOKS']['clipboardContentTitle'])) { foreach ($GLOBALS['TL_HOOKS']['clipboardContentTitle'] as $arrCallback) { $this->import($arrCallback[0]); $strTmpTitle = $this->{$arrCallback}[0]->{$arrCallback}[1]($this, $strHeadline, $objContent, $booClGroup); if ($strTmpTitle !== false && !is_null($strTmpTitle)) { $arrTitle['title'] = $strTmpTitle; break; } } } break; } if (!$arrTitle['title']) { return $objContent; } $arrTitle['attribute'] = $GLOBALS['TL_LANG']['CTE'][$objContent->type][0]; return $arrTitle; }
/** * Create Content elements * * @param XMLReader $objXml * @param string $strTable * @param string $strPastePos * @param integer $intElemId * @param boolean $boolIsChild * @param boolean $isGrouped */ protected function createContent(&$objXml, $strTable, $strPastePos, $intElemId, $boolIsChild = FALSE, $isGrouped = FALSE) { $arrIds = array(); if ($boolIsChild == TRUE) { $intId = $intElemId; } else { if ($strPastePos == 'pasteAfter') { $objElem = $this->_objDatabase->getContentObject($intElemId); $intId = $objElem->pid; $intElemId = $objElem->id; } } while ($objXml->read()) { switch ($objXml->nodeType) { case XMLReader::ELEMENT: switch ($objXml->localName) { case 'row': $arrSet = $this->createArrSetForRow($objXml, $intId, $strTable, $strPastePos, $intElemId, $boolIsChild); if (array_key_exists('type', $arrSet)) { if ($this->_objHelper->existsContentType($arrSet)) { if (md5($GLOBALS['TL_CONFIG']['encryptionKey']) != $this->_strEncryptionKey) { if (!array_key_exists(substr($arrSet['type'], 1, -1), $GLOBALS['TL_CTE']['includes'])) { $objDb = $this->_objDatabase->insertInto($strTable, $arrSet); $intLastInsertId = $objDb->insertId; $this->loadDataContainer($strTable); $dataContainer = 'DC_' . $GLOBALS['TL_DCA'][$strTable]['config']['dataContainer']; $dc = new $dataContainer($strTable); if ($isGrouped) { $intElemId = $intLastInsertId; $strPastePos = 'pasteAfter'; $this->Input->setGet('act', 'copyAll'); } else { $this->Input->setGet('act', 'copy'); } if (is_array($GLOBALS['TL_DCA'][$strTable]['config']['oncopy_callback'])) { foreach ($GLOBALS['TL_DCA'][$strTable]['config']['oncopy_callback'] as $callback) { $this->import($callback[0]); $this->{$callback}[0]->{$callback}[1]($intLastInsertId, $dc); } } // HOOK: call the hooks for clipboardCopy if (isset($GLOBALS['TL_HOOKS']['clipboardCopy']) && is_array($GLOBALS['TL_HOOKS']['clipboardCopy'])) { foreach ($GLOBALS['TL_HOOKS']['clipboardCopy'] as $arrCallback) { $this->import($arrCallback[0]); $this->{$arrCallback}[0]->{$arrCallback}[1]($intLastInsertId, $dc, $isGrouped); } } $objResult = $this->Database->prepare('SELECT pid FROM tl_content WHERE id = ?')->execute($intLastInsertId); $arrIds[$intLastInsertId] = $objResult->pid; $this->Input->setGet('act', NULL); } else { $strMessage = $GLOBALS['TL_LANG']['MSC']['clContentPasteInfo'][0]; $this->_objHelper->writeCustomerInfoMessage($strMessage); } } else { $objDb = $this->_objDatabase->insertInto($strTable, $arrSet); $intLastInsertId = $objDb->insertId; $this->loadDataContainer($strTable); $dataContainer = 'DC_' . $GLOBALS['TL_DCA'][$strTable]['config']['dataContainer']; $dc = new $dataContainer($strTable); if ($isGrouped) { $intElemId = $intLastInsertId; $strPastePos = 'pasteAfter'; $this->Input->setGet('act', 'copyAll'); } else { $this->Input->setGet('act', 'copy'); } if (is_array($GLOBALS['TL_DCA'][$strTable]['config']['oncopy_callback'])) { foreach ($GLOBALS['TL_DCA'][$strTable]['config']['oncopy_callback'] as $callback) { $this->import($callback[0]); $this->{$callback}[0]->{$callback}[1]($intLastInsertId, $dc); } } // HOOK: call the hooks for clipboardCopy if (isset($GLOBALS['TL_HOOKS']['clipboardCopy']) && is_array($GLOBALS['TL_HOOKS']['clipboardCopy'])) { foreach ($GLOBALS['TL_HOOKS']['clipboardCopy'] as $arrCallback) { $this->import($arrCallback[0]); $this->{$arrCallback}[0]->{$arrCallback}[1]($intLastInsertId, $dc, $isGrouped); } } $objResult = $this->Database->prepare('SELECT pid FROM tl_content WHERE id = ?')->execute($intLastInsertId); $arrIds[$intLastInsertId] = $objResult->pid; $this->Input->setGet('act', NULL); } } else { $strMessage = $GLOBALS['TL_LANG']['MSC']['clContentPasteInfo'][1]; $this->_objHelper->writeCustomerInfoMessage($strMessage); } } } break; case XMLReader::END_ELEMENT: switch ($objXml->localName) { case 'content': if ($isGrouped && count($arrIds) > 0) { // HOOK: call the hooks for clipboardCopyAll if (isset($GLOBALS['TL_HOOKS']['clipboardCopyAll']) && is_array($GLOBALS['TL_HOOKS']['clipboardCopyAll'])) { foreach ($GLOBALS['TL_HOOKS']['clipboardCopyAll'] as $arrCallback) { $this->import($arrCallback[0]); $this->{$arrCallback}[0]->{$arrCallback}[1]($arrIds); } } } return; break; } break; } } }
/** * Get checksum as md5 hash from all page, article and content elements * that need to save in xml * * @param array $arrSet * @return string */ protected function _createChecksum($arrSet) { $arrChecksum = array(); switch ($arrSet['table']) { case 'tl_page': $arrPages = $this->_objDatabase->getPageObject($arrSet['elem_id'])->fetchAllAssoc(); if ($arrSet['childs']) { $arrTmp = array($arrPages[0]['id']); $arrChecksum['page'][] = $arrPages[0]; for ($i = 0; TRUE; $i++) { if (!isset($arrTmp[$i])) { break; } $arrSubPages = $this->_objDatabase->getSubpagesObject($arrTmp[$i])->fetchAllAssoc(); foreach ($arrSubPages as $arrSubPage) { $arrTmp[] = $arrSubPage['id']; $arrChecksum['page'][] = $arrSubPage; } } } else { foreach ($arrPages as $arrPage) { $arrChecksum['page'][] = $arrPage; } } case 'tl_article': if (is_array($arrChecksum['page'])) { foreach ($arrChecksum['page'] as $arrPage) { $arrArticles = $this->_objDatabase->getArticleObjectFromPid($arrPage['id'])->fetchAllAssoc(); foreach ($arrArticles as $arrArticle) { $arrChecksum['article'][] = $arrArticle; } } } else { $arrArticles = $this->_objDatabase->getArticleObject($arrSet['elem_id'])->fetchAllAssoc(); foreach ($arrArticles as $arrArticle) { $arrChecksum['article'][] = $arrArticle; } } case 'tl_content': if (is_array($arrChecksum['article'])) { foreach ($arrChecksum['article'] as $arrArticle) { $arrContents = $this->_objDatabase->getContentObjectFromPid($arrArticle['id'])->fetchAllAssoc(); foreach ($arrContents as $arrContent) { $arrChecksum['content'][] = $arrContent; } } } else { $arrContents = $this->_objDatabase->getContentObject($arrSet['elem_id'])->fetchAllAssoc(); foreach ($arrContents as $arrContent) { $arrChecksum['content'][] = $arrContent; } } break; case 'tl_module': $arrModules = $this->_objDatabase->getModuleObject($arrSet['elem_id'])->fetchAllAssoc(); foreach ($arrModules as $arrModule) { $arrChecksum['module'][] = $arrModule; } break; } return md5(serialize($arrChecksum)); }