<?php


class NewsRootType implements INodeType
{

    public function getName()
    {
        return 'Новости';
    }

    public function isRootNode()
    {
        return true;
    }

    public function getNestedTypes()
    {
        return array(//            'textSection',
        );
    }


    public function getActions()
    {
        return array(
            'editNewsRoot',
            'newsCategory',
            'news',
            'publication',
            'show',
        );
    }

    public function actionLabels()
    {
        return array(
            'editNewsRoot' => 'Данные страницы',
            'newsCategory' => 'Рубрики',

            'news' => 'Новости',
            'publication' => 'Публикации',
            'show' => 'Видео',
        );
    }

    public function createAction($name, $controller, $id = null)
    {
        if ($id === null) $id = $name;
        require __DIR__ . '/actions/' . ucfirst($name) . 'Action.php';
        $actionClass = ucfirst($name) . 'Action';
        return new $actionClass($controller, $id);
    }

    /**
     * @return string
     */
    public function getDefaultAction()
    {
        return 'editNewsRoot';
    }


    public function deleteData($id)
    {
        $model = NewsRoot::model()->findByPk($id);
        if ($model != null) $model->delete();
    }
}
