/** * @param DleCategory $objDleCategory The DB ORM object to process */ protected function process_object($objDleCategory) { // wp: term_taxonomy_id, term_id, description, parent // dl: id, id, descr, parentid $wpTerms = $objDleCategory->LoadWpTerms(); if (!$wpTerms) { throw QCallerException(QApplication::Translate("Failed to find the WpTerm object for DleCategory.")); } $wpTermsParent = null; if ($objDleCategory->ParentidObject) { $wpTermsParent = $objDleCategory->ParentidObject->LoadWpTerms(); } $intWpTermsParentId = 0; if ($wpTermsParent) { $intWpTermsParentId = $wpTermsParent->TermId; } // check if already copied if (!WpTermTaxonomy::QueryCount(QQ::AndCondition(QQ::Equal(QQN::WpTermTaxonomy()->TermId, $wpTerms->TermId), QQ::Equal(QQN::WpTermTaxonomy()->Parent, $intWpTermsParentId)))) { $objWpTermTaxonomy = new WpTermTaxonomy(); $objWpTermTaxonomy->Initialize(); // set defaults $objWpTermTaxonomy->TermId = $wpTerms->TermId; $objWpTermTaxonomy->Description = $objDleCategory->Descr; $objWpTermTaxonomy->Parent = $intWpTermsParentId; $objWpTermTaxonomy->Taxonomy = "category"; $objWpTermTaxonomy->Count = 0; $objWpTermTaxonomy->Save(); $this->intTermTaxonomyCount++; } }
/** * @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++; } }
/** * @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++; } } }
/** * @return int The number of object in the DLE database to process. */ protected function get_process_objects_count() { return WpTermTaxonomy::CountAll(); }
public static function GetSoapObjectFromObject($objObject, $blnBindRelatedObjects) { if ($objObject->objTerm) { $objObject->objTerm = WpTerms::GetSoapObjectFromObject($objObject->objTerm, false); } else { if (!$blnBindRelatedObjects) { $objObject->intTermId = null; } } if ($objObject->objParentObject) { $objObject->objParentObject = WpTermTaxonomy::GetSoapObjectFromObject($objObject->objParentObject, false); } else { if (!$blnBindRelatedObjects) { $objObject->intParent = null; } } return $objObject; }
/** * Counts all associated WpTermTaxonomiesAsTerm * @return int */ public function CountWpTermTaxonomiesAsTerm() { if (is_null($this->intTermId)) { return 0; } return WpTermTaxonomy::CountByTermId($this->intTermId); }
public static function GetSoapObjectFromObject($objObject, $blnBindRelatedObjects) { if ($objObject->objTermTaxonomy) { $objObject->objTermTaxonomy = WpTermTaxonomy::GetSoapObjectFromObject($objObject->objTermTaxonomy, false); } else { if (!$blnBindRelatedObjects) { $objObject->intTermTaxonomyId = null; } } return $objObject; }