<?php


class QuestionRootType implements INodeType
{

    public function getName()
    {
        return 'Вопросы';
    }

    public function isRootNode()
    {
        return true;
    }

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


    public function getActions()
    {
        return array(
            'editQuestion','questionCategory','question'
        );
    }

    public function actionLabels(){
        return array(
            'editQuestion'=>'Данные страницы',
            'questionCategory'=>'Категории вопросов',
            'question'=>'Вопросы',
        );
    }

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


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