<?php


class SportRootType implements INodeType
{

    public function getName()
    {
        return 'Автоспорт';
    }

    public function isRootNode()
    {
        return true;
    }

    public function getNestedTypes()
    {
        return array(
            'sportSection',
            'albumsSection',
            'calendarSection',
        );
    }


    public function getActions()
    {
        return array(
            'editSportRoot',
        );
    }

    public function actionLabels(){
        return array(
            'editSportRoot'=>'Данные страницы',
        );
    }

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


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