<?php


class WorkRootType implements INodeType
{

    public function getName()
    {
        return 'Раздел “Наши работы”';
    }

    public function isRootNode()
    {
        return true;
    }

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


    public function getActions()
    {
        return array(
            'editWorkRoot',
            'workBrand',
            'workModel',
            'work',
        );
    }

    public function actionLabels()
    {
        return array(
            'editWorkRoot' => 'Данные страницы',
            'workBrand' => 'Бренды',
            'workModel' => 'Модели',
            'work' => 'Работы',
        );
    }

    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 'editWorkRoot';
    }


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