public function move($id, $to) { try { $aDocument = Sitemap_Sample::get($id); if (empty($aDocument['document_name'])) { throw new Exception('Requested id isn`t document'); } Sitemap::updatePage($aDocument['document_name'], $aDocument['document_id'], $aDocument['name'], $aDocument['url_key'], $to); Sitemap::updateParentCount($aDocument['parent']); Sitemap::updateParentCount($to); // Если у переносимого документа есть дочерние элементы $child = Sitemap_Sample::selectChild($aDocument['id']); if (!empty($child)) { foreach ($child as $row) { Sitemap_RestoreUrl::restoreOne($row['id'], $aDocument); } } $this->addAlert('Документ перемещен'); } catch (Exception $e) { $this->addError('Ошибка при перемещении документа'); } $this->jumpBack(); }
/** * Тестируем обновление документа */ public function testUpdateDocument() { $nId = Sitemap::addPage('Test inserting', 'xx', TestDocument::ModelName, 1, 0); Sitemap::updatePage(TestDocument::ModelName, 1, 'Test updating', 'xxx', 0); $urlInfo = Sitemap_Sample::get($nId); $this->assertEquals($urlInfo['full_url'], '///xxx/'); $this->assertEquals($urlInfo['name'], 'Test updating'); }
public function update() { if ($this->withSitemap) { // Получаем сайтмап данные $this->needSitemapData(); $sitemapInfo = $this->returnSitemapParams(); Sitemap::updatePage(static::ModelName, $this->id->getValue(), $this->name->getValue(), $sitemapInfo['url_key'], $this->sitemapInfo['parent']); // Очищаем текущие сайтмап данные и обновлеяем их $this->sitemapInfo = null; $this->needSitemapData(); } // Обновляем return parent::update(); }