public function updateMultilingualSection(Section $section) { $db = Database::connection(); $db->Execute('update Stacks set stMultilingualSection = ? where cID = ?', array($section->getCollectionID(), $this->getCollectionID())); }
public function getSectionSiteInterfaceCompletionData(Section $section) { $app = Application::getFacadeApplication(); $db = $app->make('database')->connection(); $data = []; $data['messageCount'] = $db->fetchColumn('select count(mtID) from MultilingualTranslations where mtSectionID = ?', [$section->getCollectionID()]); $data['translatedCount'] = $db->fetchColumn('select count(mtID) from MultilingualTranslations where mtSectionID = ? and msgstr != ""', [$section->getCollectionID()]); $data['completionPercentage'] = 0; if ($data['messageCount'] > 0) { $data['completionPercentage'] = round($data['translatedCount'] / $data['messageCount'] * 100); } return $data; }
public function filterByLanguageSection(Section $ms) { $this->filter('stMultilingualSection', $ms->getCollectionID()); }
public function getSectionSiteInterfaceCompletionData(Section $section) { $db = \Database::get(); $data = array(); $data['messageCount'] = $db->GetOne('select count(mtID) from MultilingualTranslations where mtSectionID = ?', array($section->getCollectionID())); $data['translatedCount'] = $db->GetOne('select count(mtID) from MultilingualTranslations where mtSectionID = ? and msgstr != ""', array($section->getCollectionID())); $data['completionPercentage'] = 0; if ($data['messageCount'] > 0) { $data['completionPercentage'] = round($data['translatedCount'] / $data['messageCount'] * 100); } return $data; }
/** * @param Section $section * * @return self */ public function addLocalizedStack(Section $section) { $neutralStack = $this->getNeutralStack(); if ($neutralStack === null) { $neutralStack = $this; } $name = $neutralStack->getCollectionName(); $neutralStackPage = Page::getByID($neutralStack->getCollectionID()); $localizedStackPage = $neutralStackPage->duplicate($neutralStackPage); $localizedStackPage->update(['cName' => $name]); $siteTreeID = $neutralStack->getSiteTreeID(); // we have to do this because we need the area to exist before we try and add something to it. Area::getOrCreate($localizedStackPage, STACKS_AREA_NAME); $localizedStackCID = $localizedStackPage->getCollectionID(); $db = Database::connection(); $db->executeQuery(' insert into Stacks (stName, cID, stType, stMultilingualSection, siteTreeID) values (?, ?, ?, ?, ?)', [$name, $localizedStackCID, $this->getStackType(), $section->getCollectionID(), $siteTreeID]); $localizedStack = static::getByID($localizedStackCID); return $localizedStack; }