public function cmsNavItemToXML(ModelObject $CMSNavItem) { $xml = new SimpleXMLExtended('<item/>'); $xml->addAttribute('id', $CMSNavItem->CMSNavItemID); $xml->addAttribute('pluginid', $CMSNavItem->PluginID); $xml->addAttribute('uri', $CMSNavItem->URI); foreach (array('slug', 'label', 'sort_order', 'permissions') as $key) { $camel = StringUtils::camelize($key); if (!empty($CMSNavItem->{$camel})) { $xml->addAttribute($key, $CMSNavItem->{$camel}); } } $xml->addAttribute('enabled', $CMSNavItem->isEnabled() ? 'true' : 'false'); if (!empty($CMSNavItem->DoAddLinksFor)) { $xml->addAttribute('create_add_menu', $CMSNavItem->DoAddLinksFor); } // if($CMSNavItem->hasModifiedDate()) // $xml->addChild('modified_date', $this->DateFactory->toStorageDate($CMSNavItem->ModifiedDate)->toMySQLDate()); // if($CMSNavItem->hasCreationDate()) // $xml->addChild('creation_date', $this->DateFactory->toStorageDate($CMSNavItem->CreationDate)->toMySQLDate()); $sort_array = array(); $children = $CMSNavItem->getChildren(); if (!empty($children)) { foreach ($children as $child) { $sort_array[] = $child->SortOrder; $sort_array2[] = $child->Slug; } array_multisort($sort_array, SORT_ASC, $sort_array2, SORT_ASC, $children); foreach ($children as $child) { $xml->addXMLElement($this->cmsNavItemToXML($child)); } } return $xml; }
public function getPrimaryKey(NodeRef $nodeRef) { return 'Table' . StringUtils::camelize($nodeRef->getElement()->Slug . 'ID'); }
/** * Loads up all of the node refs (up to max nodes) into a temporary table. * * @param string $element * @param int $maxNodes * * @return int - the total number of records found */ private function loadNodeRefsWithMissingThumbs($element, $maxNodes = 10000) { $this->createTempTable($element); $tempTableName = $this->getTempTableName($element); $cElement = StringUtils::camelize($element); $thumbSizes = $this->MediaService->getUniqueThumbnailSizes($element); $totalSizes = count($thumbSizes); $tableName = str_replace('-', '_', 'n-' . $element); $sql = array(); foreach ($thumbSizes as $thumbSize) { $sql[] = <<<EOL ( SELECT IF(COUNT(1),1,0) FROM {$tableName}_outtags b WHERE b.Table{$cElement}ID = a.Table{$cElement}ID AND b.Role = 'thumbnails' AND b.Value = '{$thumbSize}' ) EOL; } $sql = implode('+', $sql); $sql = <<<EOL INSERT IGNORE INTO {$tempTableName} (slug) SELECT SQL_CALC_FOUND_ROWS Slug FROM ( SELECT a.Slug, a.Table{$cElement}ID FROM {$tableName} a WHERE a.Status <> 'deleted' AND {$totalSizes} > ({$sql}) ) as T1 ORDER BY Table{$cElement}ID DESC LIMIT {$maxNodes} EOL; $this->Logger->info($sql); $db = $this->getDBConnection(); $db->write($sql, DatabaseInterface::AFFECTED_ROWS); return intVal($db->readField('SELECT FOUND_ROWS()')); }