Testing how to develop an app
This commit is contained in:
		@ -28,4 +28,11 @@ class PageController extends Controller {
 | 
			
		||||
		return new TemplateResponse('mywiki', 'index');  // templates/index.php
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
     /**
 | 
			
		||||
      * @NoAdminRequired
 | 
			
		||||
      */
 | 
			
		||||
      public function test() {
 | 
			
		||||
		  return new DataResponse('JDG::Test');
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -23,9 +23,15 @@
 | 
			
		||||
     /**
 | 
			
		||||
      * @NoAdminRequired
 | 
			
		||||
      */
 | 
			
		||||
     public function index() {
 | 
			
		||||
        return new DataResponse($this->service->test($this->userId));
 | 
			
		||||
      public function test() {
 | 
			
		||||
        $x = $this->service->test($this->userId);
 | 
			
		||||
        return new DataResponse(print_r($x,true));
 | 
			
		||||
      }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
      * @NoAdminRequired
 | 
			
		||||
      */
 | 
			
		||||
     public function index() {
 | 
			
		||||
         return new DataResponse($this->service->findAll($this->userId));
 | 
			
		||||
     }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -1,32 +1,25 @@
 | 
			
		||||
<?php
 | 
			
		||||
namespace OCA\MyWiki\Helper;
 | 
			
		||||
 | 
			
		||||
use OCP\AppFramework\Files\Folder;
 | 
			
		||||
use OCP\Files\IRootFolder;
 | 
			
		||||
 | 
			
		||||
class WikiHelper {
 | 
			
		||||
    public static function isFolder(int $folderId) :bool {
 | 
			
		||||
        $mount = \OC\Files\Filesystem::getMountsForFileId($folderId);
 | 
			
		||||
        /*
 | 
			
		||||
        isReadable()    
 | 
			
		||||
        getById($folderId) 
 | 
			
		||||
        isCreatable()
 | 
			
		||||
        isUpdateable()
 | 
			
		||||
        lock()
 | 
			
		||||
 | 
			
		||||
$config = new \OC\Config('config/');
 | 
			
		||||
 $base_path = $config->getValue('datadirectory')
 | 
			
		||||
 | 
			
		||||
datadirectory is the key in the array defined in config.php that contains the base directory.
 | 
			
		||||
 | 
			
		||||
$basepath now contains a path like /var/www/html/nextcloud/data.        
 | 
			
		||||
        */
 | 
			
		||||
        // ToDo
 | 
			
		||||
        $nodes = \OC\Files\Node\Folder::getById($folderId);
 | 
			
		||||
 | 
			
		||||
        return true;
 | 
			
		||||
    public static function isFolder(IRootFolder $storage, int $folderId) :bool {
 | 
			
		||||
        $nodes = $storage->getById($folderId);
 | 
			
		||||
        if ( count($nodes)>0 ) {
 | 
			
		||||
            return $nodes[0]->getType() == \OCP\Files\Node::TYPE_FOLDER;
 | 
			
		||||
        }
 | 
			
		||||
        return false;
 | 
			
		||||
    }
 | 
			
		||||
    public static function isWiki(int $folderId) :bool {
 | 
			
		||||
        return \OC\Files\Filesystem::nodeExists('.wiki');
 | 
			
		||||
    public static function isWiki(IRootFolder $storage, int $folderId) :string {
 | 
			
		||||
        $nodes = $storage->getById($folderId);
 | 
			
		||||
        if ( count($nodes)>0 ) {
 | 
			
		||||
            $nodeStorage = $nodes[0]->getStorage();
 | 
			
		||||
            return $nodeStorage->file_get_contents('/wiki.yaml');
 | 
			
		||||
            // getPath()
 | 
			
		||||
            // getStorage()
 | 
			
		||||
        }
 | 
			
		||||
        return false;
 | 
			
		||||
    }
 | 
			
		||||
    public static function initWiki(int $folderId, string $title) :bool {
 | 
			
		||||
        // ToDo
 | 
			
		||||
 | 
			
		||||
@ -1,13 +1,13 @@
 | 
			
		||||
<?php
 | 
			
		||||
 | 
			
		||||
  namespace OCA\NotesTutorial\Migration;
 | 
			
		||||
  namespace OCA\MyWiki\Migration;
 | 
			
		||||
 | 
			
		||||
  use Closure;
 | 
			
		||||
  use OCP\DB\ISchemaWrapper;
 | 
			
		||||
  use OCP\Migration\SimpleMigrationStep;
 | 
			
		||||
  use OCP\Migration\IOutput;
 | 
			
		||||
 | 
			
		||||
  class Version1400Date20181013124731 extends SimpleMigrationStep {
 | 
			
		||||
  class Version000000Date20220302210900 extends SimpleMigrationStep {
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
    * @param IOutput $output
 | 
			
		||||
 | 
			
		||||
@ -10,20 +10,28 @@ use OCA\MyWiki\Db\Wiki;
 | 
			
		||||
use OCA\MyWiki\Db\WikiMapper;
 | 
			
		||||
use OCA\MyWiki\Helper\WikiHelper;
 | 
			
		||||
 | 
			
		||||
use \OCP\Files\Storage;
 | 
			
		||||
use \OCP\Files\IRootFolder;
 | 
			
		||||
 | 
			
		||||
use \OCP\IUserSession;
 | 
			
		||||
 | 
			
		||||
class WikiService {
 | 
			
		||||
 
 | 
			
		||||
    private $mapper;
 | 
			
		||||
    private $rootFolder;
 | 
			
		||||
    private $storage;
 | 
			
		||||
    private $userSession;
 | 
			
		||||
 | 
			
		||||
    public function __construct(WikiMapper $mapper,IRootFolder $rootFolder){
 | 
			
		||||
    public function __construct(WikiMapper $mapper, IRootFolder $storage) {
 | 
			
		||||
        // , IUserSession $userSession ) {
 | 
			
		||||
        $this->mapper = $mapper;
 | 
			
		||||
		$this->rootFolder = $rootFolder;
 | 
			
		||||
		// $this->userSession = $userSession;
 | 
			
		||||
		$this->storage = $storage;
 | 
			
		||||
 | 
			
		||||
        // , IUserSession $userSession
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function test(string $userId) {
 | 
			
		||||
        echo 'JDG :: Test for '.$userId;
 | 
			
		||||
        return WikiHelper::isWiki($this->storage, 208);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function findAll(string $userId) {
 | 
			
		||||
 | 
			
		||||
		Reference in New Issue
	
	Block a user