Пример #1
0
 public function actionView()
 {
     $class = $this->_input->filterSingle('class', XenForo_Input::STRING);
     try {
         $model = XenForo_Model::create($class);
     } catch (Exception $e) {
     }
     if (empty($model) || !$model instanceof XenForo_Model) {
         return $this->responseNoPermission();
     }
     $reflectionClass = new ThemeHouse_Reflection_Class(get_class($model));
     $reflectionMethods = $reflectionClass->getMethods();
     $methods = array();
     foreach ($reflectionMethods as $reflectionMethod) {
         /* @var $reflectionMethod ReflectionMethod */
         $methodName = $reflectionMethod->getName();
         $declaringClass = $reflectionMethod->getDeclaringClass();
         $methods[$methodName]['declaringClass'] = $declaringClass->getName();
         $methods[$methodName]['isAbstract'] = $reflectionMethod->isAbstract();
         $methods[$methodName]['isConstructor'] = $reflectionMethod->isConstructor();
         $methods[$methodName]['isDeprecated'] = $reflectionMethod->isDeprecated();
         $methods[$methodName]['isDestructor'] = $reflectionMethod->isDestructor();
         $methods[$methodName]['isFinal'] = $reflectionMethod->isFinal();
         $methods[$methodName]['isInternal'] = $reflectionMethod->isInternal();
         $methods[$methodName]['isPrivate'] = $reflectionMethod->isPrivate();
         $methods[$methodName]['isProtected'] = $reflectionMethod->isProtected();
         $methods[$methodName]['isPublic'] = $reflectionMethod->isPublic();
         $methods[$methodName]['isStatic'] = $reflectionMethod->isStatic();
         $methods[$methodName]['isUserDefined'] = $reflectionMethod->isUserDefined();
     }
     $model = array('class' => $class);
     $viewParams = array('model' => $model, 'methods' => $methods);
     return $this->responseView('ThemeHouse_Models_ViewAdmin_Model_View', 'th_model_view_models', $viewParams);
 }
 public function actionView()
 {
     $class = $this->_input->filterSingle('class', XenForo_Input::STRING);
     try {
         $response = new Zend_Controller_Response_Http();
         $controllerPublic = new $class($this->getRequest(), $response, $this->getRouteMatch());
     } catch (Exception $e) {
     }
     if (empty($controllerPublic) || !$controllerPublic instanceof XenForo_ControllerPublic_Abstract) {
         return $this->responseNoPermission();
     }
     $reflectionClass = new ThemeHouse_Reflection_Class(get_class($controllerPublic));
     $reflectionMethods = $reflectionClass->getMethods();
     $methods = array();
     foreach ($reflectionMethods as $reflectionMethod) {
         /* @var $reflectionMethod ReflectionMethod */
         $methodName = $reflectionMethod->getName();
         $declaringClass = $reflectionMethod->getDeclaringClass();
         $methods[$methodName]['declaringClass'] = $declaringClass->getName();
         $methods[$methodName]['isAbstract'] = $reflectionMethod->isAbstract();
         $methods[$methodName]['isConstructor'] = $reflectionMethod->isConstructor();
         $methods[$methodName]['isDeprecated'] = $reflectionMethod->isDeprecated();
         $methods[$methodName]['isDestructor'] = $reflectionMethod->isDestructor();
         $methods[$methodName]['isFinal'] = $reflectionMethod->isFinal();
         $methods[$methodName]['isInternal'] = $reflectionMethod->isInternal();
         $methods[$methodName]['isPrivate'] = $reflectionMethod->isPrivate();
         $methods[$methodName]['isProtected'] = $reflectionMethod->isProtected();
         $methods[$methodName]['isPublic'] = $reflectionMethod->isPublic();
         $methods[$methodName]['isStatic'] = $reflectionMethod->isStatic();
         $methods[$methodName]['isUserDefined'] = $reflectionMethod->isUserDefined();
     }
     $controllerPublic = array('class' => $class);
     $viewParams = array('controllerPublic' => $controllerPublic, 'methods' => $methods);
     return $this->responseView('ThemeHouse_Controllers_ViewAdmin_ControllerPublic_View', 'th_controller_public_view_controllers', $viewParams);
 }
Пример #3
0
 public static function createMethod(XenForo_Controller $controller, $method, $body = '', $signature = '')
 {
     $class = self::getClass($controller);
     $reflectionClass = new ThemeHouse_Reflection_Class($class);
     if ($reflectionClass->hasMethod($method)) {
         $reflectionMethod = $reflectionClass->getMethod($method);
         // TODO update signature
         // $reflectionMethod->setSignature($signature);
         $reflectionMethod->setMethodBody($body);
     } else {
         $reflectionClass->addMethod($method, $body, $signature);
     }
     return $method;
 }
Пример #4
0
 protected function _getMethodDeleteResponse($class, $prefix)
 {
     $reflectionClass = new ThemeHouse_Reflection_Class(get_class($class));
     $method = $this->_input->filterSingle('method', XenForo_Input::STRING);
     if (!$reflectionClass->hasMethod($method)) {
         return $this->responseNoPermission();
     }
     if ($this->isConfirmedPost()) {
         $reflectionClass->deleteMethod($method);
         return $this->responseRedirect(XenForo_ControllerResponse_Redirect::SUCCESS, XenForo_Link::buildAdminLink($prefix, array('class' => get_class($class))));
     } else {
         $viewParams = array('class' => array('class' => get_class($class)), 'method' => $method, 'prefix' => $prefix);
         return $this->responseView('ThemeHouse_Reflection_ViewAdmin_Method_Delete', 'th_method_delete_reflection', $viewParams);
     }
 }
Пример #5
0
 public static function createFromReflectionClass(ThemeHouse_Reflection_Class $reflectionClass)
 {
     $phpFile = self::create('ThemeHouse_PhpFile', $reflectionClass->getName());
     foreach ($reflectionClass->getConstants() as $constantName => $constantValue) {
         $constant = $phpFile->getConstant($constantName);
         $constant->setValue($constantValue);
     }
     foreach ($reflectionClass->getDefaultProperties() as $propertyName => $propertyValue) {
         $variable = $phpFile->getVariable($propertyName);
         $variable->setValue($propertyValue);
     }
     foreach ($reflectionClass->getMethods(-1, 'ThemeHouse_Reflection_Method') as $method) {
         /* @var $method ThemeHouse_Reflection_Method */
         $function = $phpFile->getFunction($method->getName());
         $function->setBody($method->getBody());
         $function->setPhpDoc($method->getDocblock()->getContents());
         $function->setSignature(explode(',', $method->getSignature()));
         if ($method->isPublic()) {
             $function->setPublic(true);
         } elseif ($method->isProtected()) {
             $function->setProtected(true);
         }
     }
     return $phpFile;
 }
Пример #6
0
 public function actionSaveField()
 {
     $input = $this->_input->filter(array('class' => XenForo_Input::STRING, 'table' => XenForo_Input::STRING, 'name' => XenForo_Input::STRING, 'data_type' => XenForo_Input::STRING, 'default' => XenForo_Input::STRING, 'auto_increment' => XenForo_Input::BOOLEAN));
     $dataWriter = XenForo_DataWriter::create($input['class']);
     if (empty($dataWriter) || !$dataWriter instanceof XenForo_DataWriter) {
         return $this->responseNoPermission();
     }
     $reflectionClass = new ThemeHouse_Reflection_Class($input['class']);
     if ($reflectionClass->hasMethod('_getFields')) {
         /* @var $reflectionMethod ThemeHouse_DataWriters_Reflection_Method_DataWriter_GetFields */
         $reflectionMethod = $reflectionClass->getMethod('_getFields', 'ThemeHouse_DataWriters_Reflection_Method_DataWriter_GetFields');
         $reflectionMethod->addField($input['table'], $input['name'], $input['data_type'], $input['default'], $input['auto_increment']);
     } else {
         // TODO add _getFields method
     }
     $addOnId = ThemeHouse_DataWriters_Helper_DataWriter::getAddOnIdFromDataWriterClass($input['class']);
     $installControllerClass = $addOnId . '_Install_Controller';
     /* @var $reflectionClass ThemeHouse_DataWriters_Reflection_Class_InstallController */
     $reflectionClass = new ThemeHouse_DataWriters_Reflection_Class_InstallController($installControllerClass);
     if ($reflectionClass->hasOveridden('_getTables')) {
         /* @var $reflectionMethod ThemeHouse_DataWriters_Reflection_Method_InstallController_GetTables */
         $reflectionMethod = $reflectionClass->getMethod('_getTables', 'ThemeHouse_DataWriters_Reflection_Method_InstallController_GetTables');
         $reflectionMethod->addColumn($input['table'], $input['name'], $input['data_type'], $input['default'], $input['auto_increment']);
     } else {
         $reflectionClass->addGetTablesMethod($input['table'], $input['name'], $input['data_type'], $input['default'], $input['auto_increment']);
     }
     // TODO add column to database?
     $dataWriter = array('class' => $input['class']);
     return $this->responseRedirect(XenForo_ControllerResponse_Redirect::RESOURCE_CREATED, XenForo_Link::buildAdminLink('data-writers/edit-method', $dataWriter, array('method' => '_getFields')));
 }
Пример #7
0
 public function actionSave()
 {
     $options = $this->_input->filter(array('datawriter' => XenForo_Input::STRING, 'fields' => XenForo_Input::ARRAY_SIMPLE, 'actions' => XenForo_Input::ARRAY_SIMPLE, 'addon_id' => XenForo_Input::STRING, 'class' => XenForo_Input::STRING, 'method' => XenForo_Input::STRING, 'route_prefix' => XenForo_Input::STRING, 'title_field' => XenForo_Input::STRING, 'subtitle_field' => XenForo_Input::STRING));
     try {
         $dataWriter = XenForo_DataWriter::create($options['datawriter']);
     } catch (Exception $e) {
     }
     if (empty($dataWriter) || !$dataWriter instanceof XenForo_DataWriter) {
         return $this->responseNoPermission();
     }
     $options['primary_key_id'] = ThemeHouse_Controllers_Helper_DataWriter::getPrimaryKey($dataWriter);
     $name = substr(strrchr($options['class'], '_'), 1);
     $dataWriterReflectionClass = new ThemeHouse_Reflection_Class(get_class($dataWriter));
     $getModelMethod = '_get' . $name . 'Model';
     /* @var $reflectionMethod ThemeHouse_Reflection_Method */
     $dataWriterReflectionMethod = $dataWriterReflectionClass->getMethod($getModelMethod, 'ThemeHouse_Reflection_Method');
     $options['model'] = $dataWriterReflectionMethod->getReturnTag();
     $camelCaseRoutePrefix = ThemeHouse_Controllers_Helper_RoutePrefix::hyphenCaseToCamelCase($options['route_prefix']);
     $routePrefixClass = $options['addon_id'] . '_Route_PrefixAdmin_' . $camelCaseRoutePrefix;
     /* @var $routePrefixModel XenForo_Model_RoutePrefix */
     $routePrefixModel = $this->getModelFromCache('XenForo_Model_RoutePrefix');
     $routePrefix = $routePrefixModel->getPrefixByOriginal($options['route_prefix'], 'admin');
     if (!$routePrefix) {
         /* @var $routePrefixDw XenForo_DataWriter_RoutePrefix */
         $routePrefixDw = XenForo_DataWriter::create('XenForo_DataWriter_RoutePrefix');
         $routePrefixDw->bulkSet(array('route_type' => 'admin', 'original_prefix' => $options['route_prefix'], 'route_class' => $routePrefixClass, 'build_link' => 'data_only', 'addon_id' => $options['addon_id']));
         $routePrefixDw->setOption(ThemeHouse_Controllers_Extend_XenForo_DataWriter_RoutePrefix::OPTION_PRIMARY_KEY_ID, $options['primary_key_id']);
         $routePrefixDw->save();
     }
     $phpFile = new ThemeHouse_Controllers_PhpFile_ControllerAdmin($options['class'], $options);
     $phpFile->export();
     return $this->responseRedirect(XenForo_ControllerResponse_Redirect::RESOURCE_CREATED, XenForo_Link::buildAdminLink('admin-controllers'));
 }