/** * @param DlePost $objDlePost The DB ORM object to process */ protected function process_object($objDlePost) { $objWpTermsArray = $objDlePost->LoadWpTermsArray(); if ($objWpTermsArray) { $this->intDleTermRelationshipsCount += count($objWpTermsArray); } else { return; } $objWpPosts = $objDlePost->LoadWpPosts(); if (!$objWpPosts) { return; } foreach ($objWpTermsArray as $objWpTerms) { $objWpTermTaxonomy = WpTermTaxonomy::LoadByTermIdTaxonomy($objWpTerms->TermId, "category"); if (!$objWpTermTaxonomy) { continue; } $objWpTermRelationships = WpTermRelationships::LoadByObjectIdTermTaxonomyId($objWpPosts->Id, $objWpTermTaxonomy->TermTaxonomyId); // check if already copied if (!$objWpTermRelationships) { $objWpTermRelationships = new WpTermRelationships(); $objWpTermRelationships->Initialize(); // set defaults $objWpTermRelationships->ObjectId = $objWpPosts->Id; $objWpTermRelationships->TermTaxonomyId = $objWpTermTaxonomy->TermTaxonomyId; $objWpTermRelationships->TermOrder = 0; $objWpTermRelationships->Save(); $this->intTermRelationshipsCount++; } } }
/** * @param DleTags $objDleTags The DB ORM object to process */ protected function process_object($objDleTags) { $objWpTerms = WpTerms::LoadBySlug($objDleTags->Tag); if (!$objWpTerms) { // It does not work. even with an appropriate setlocale call and with ISO-8859-1//TRANSLIT too // $strSlug = iconv(QApplication::$EncodingType, 'US-ASCII//TRANSLIT', $objDleTags->Tag); $strSlug = encodestring($objDleTags->Tag); $objWpTerms = WpTerms::LoadBySlug($strSlug); if (!$objWpTerms) { // This tag was not copied yet. $objWpTerms = new WpTerms(); $objWpTerms->Initialize(); // set defaults $objWpTerms->Name = $objDleTags->Tag; // DLE does not has url-compartible tag name version. it uses the urlencoded from cp1251 one. // We do a translit enstead. $objWpTerms->Slug = $strSlug; $objWpTerms->TermGroup = 0; $objWpTerms->Save(); $this->intTermCount++; } } // check if already copied $objWpTermTaxonomy = WpTermTaxonomy::LoadByTermIdTaxonomy($objWpTerms->TermId, "post_tag"); if (!$objWpTermTaxonomy) { $objWpTermTaxonomy = new WpTermTaxonomy(); $objWpTermTaxonomy->Initialize(); // set defaults $objWpTermTaxonomy->TermId = $objWpTerms->TermId; $objWpTermTaxonomy->Description = $objWpTerms->Name; $objWpTermTaxonomy->Parent = 0; $objWpTermTaxonomy->Taxonomy = "post_tag"; $objWpTermTaxonomy->Count = 0; $objWpTermTaxonomy->Save(); $this->intTermTaxonomyCount++; } $objWpPosts = $objDleTags->News->LoadWpPosts(); if (!$objWpPosts) { return; } $objWpTermRelationships = WpTermRelationships::LoadByObjectIdTermTaxonomyId($objWpPosts->Id, $objWpTermTaxonomy->TermTaxonomyId); // check if already copied if (!$objWpTermRelationships) { $objWpTermRelationships = new WpTermRelationships(); $objWpTermRelationships->Initialize(); // set defaults $objWpTermRelationships->ObjectId = $objWpPosts->Id; $objWpTermRelationships->TermTaxonomyId = $objWpTermTaxonomy->TermTaxonomyId; $objWpTermRelationships->TermOrder = 0; $objWpTermRelationships->Save(); $this->intTermRelationshipsCount++; } }