/** * Возвращает список путей, куда может быть перемещен данный документ */ public static function whereToMove($documentName) { $validator = new \Extasy\Validators\ModelConfigValidator($documentName, array('sitemap', RegisteredDocument::ParentsConfigName)); $result = array(); if ($validator->isValid()) { $documents = $validator->getData(); if (!empty($documents)) { foreach ($documents as $key => $row) { $documents[$key] = sprintf('"%s"', \Faid\DB::escape($row)); } } else { $documents = array(-1); } $scripts = self::selectDocumentScriptParents($documentName); if (!empty($scripts)) { foreach ($scripts as $key => $row) { $scripts[$key] = sprintf('"%s"', \Faid\DB::escape($row['script'])); } } else { $scripts = array(-1); } $sql = <<<SQL \tSELECT * FROM `%s` WHERE `script` IN (%s) or `document_name` IN (%s) ORDER by `name` ASC; SQL; $sql = sprintf($sql, SITEMAP_TABLE, implode(',', $scripts), implode(',', $documents)); $result = DB::query($sql); } $documents = self::getRootDocuments(); foreach ($documents as $row) { if ($row['name'] == $documentName) { array_unshift($result, array('id' => 0, 'name' => 'Корень сайта', 'script' => 'root', 'full_url' => '')); } } return $result; }
/** * Собирает информацию по текущему элементу (набор кнопок + возможность сортировки) */ public function getInformation() { $aInfo = Sitemap_Sample::get($this->nParent); $szUrl = $this->standalone ? 'index.php' : 'page-list.php'; if (empty($aInfo)) { throw new Exception('Page not found'); } $this->orderCondition = '`order` asc'; if (!empty($aInfo['script'])) { $aChild = Sitemap_Sample::selectScriptChild($aInfo['script']); foreach ($aChild as $key => $row) { $aChild[$key] = $row['document_name']; } } else { $validator = new \Extasy\Validators\ModelConfigValidator($aInfo['document_name'], array('sitemap', RegisteredDocument::ChildrenConfigName)); if ($validator->isValid()) { $aChild = $validator->getData(); } else { $aChild = array(); } } // Формируем блок кнопок // Добавляем в блок кнопки добавления документа // Если более 3 доступных документов для добавления формируем селект if (sizeof($aChild) > 3) { $useSelect = 1; require_once CONTROL_PATH . 'select.php'; $select = new CSelect(); $select->name = 'document_name'; $select->id = 'document_name'; $items = array(array('id' => '-1', 'name' => 'Добавить...')); } else { } foreach ($aChild as $documentName) { $title = call_user_func(array($documentName, 'getLabel'), \Extasy\Model\Model::labelAddItem); $href = $szUrl . '?parent=' . $this->nParent . '&add=' . $documentName; if (empty($useSelect)) { $this->aButton[$title] = $href; } else { $items[] = array('id' => $href, 'name' => $title); } } if (!empty($useSelect)) { $select->values = $items; $select->current = '-1'; $this->aButton[] = array('code' => $select); } if (!empty($aInfo['document_name']) || !empty($aInfo['script_admin_url'])) { $this->aButton[_msg('Редактировать')] = \Extasy\CMS::getDashboardWWWRoot() . 'sitemap/edit.php?id=' . $aInfo['id']; } $this->aButton[_msg('Сортировать')] = \Extasy\CMS::getDashboardWWWRoot() . 'sitemap/order.php?id=' . $aInfo['id']; }