Integration of MVC

See all posts Reply

Integration of MVC new!
by Sai, 9 years, 11 months ago
Hello! TinyMVC use. I want to connect the class as a plugin. I can rename the file?
tinymvc_library_upload.php

And rename the class?
class TinyMVC_Library_Upload {}

Next load the plugin:
$this->load->library('upload');

Now it should be called as $this->upload($_FILES['file']); and $this->upload->uploaded;

But this does not work, a class. Even the error does not return. Can you recommend that be?Reply
Re: Integration of MVC new!
by colin, 9 years, 11 months ago
I don't use TinyMVC, sorry...Reply
Re: Integration of MVC new!
by Sai, 9 years, 11 months ago
You can specify how or whether the file after class initialization?
For example:

$handle = new upload();
$handle->file($_FILES['file']);

Is there a function that takes a file after initializing the class?Reply
Re: Integration of MVC new!
by colin, 9 years, 11 months ago
No, there isn't such function. Maybe you can simply create a wrapper class?Reply
Re: Integration of MVC new!
by Sai, 9 years, 11 months ago
A possible example?Reply
Re: Integration of MVC new!
by colin, 9 years, 11 months ago
I am afraid I cannot provide you with an example, I never used TinyMVC. But if you look at some existing TinyMVC plugins, it should give you an idea.

Basically, I think you should create a plugin class, where you instantiate the class.upload.php in a function that you would call 'upload' (and not in the constructor of your plugin).Reply
Re: Integration of MVC new!
by Sai, 9 years, 11 months ago
There used plugin Smarty templating engine. Here is his connection class:

// important so the TinyMVC and Smarty autoloaders work together!
define('SMARTY_SPL_AUTOLOAD', 1);

// require the Smarty class
require('libs/smarty/Smarty.class.php');
 
class TinyMVC_Library_Smarty Extends Smarty {
  function __construct() {
    parent::__construct();
    $this->setTemplateDir(array('tpl/site/','tpl/admin/'));
    $this->setCompileDir('tpl_c/');
    $this->setConfigDir('tinymvc/myapp/configs/');
	
    $this->configLoad('site.conf');
    $this->configLoad('admin.conf');
        
    $tmvc = tmvc::instance();
  }
}

So I connected the class to work with the mail. But I do not know how to connect your class. When it is initialized once specified file. If there was a feature where you can specify the file after initialization, it would simplify the work in this case.Reply
Re: Integration of MVC new!
by colin, 9 years, 11 months ago
I will look into it when I get some time. Feel free to submit a patch in the meantime.Reply
Re: Integration of MVC new!
by Sai, 9 years, 11 months ago
What is a patch?Reply
Re: Integration of MVC new!
by Sai, 9 years, 11 months ago
Generate the wrapper class.

require('libs/class.upload.php');
class TinyMVC_Library_Upload Extends upload {
  function __construct() {
    parent::__construct();
    $tmvc = tmvc::instance();
  }
}

now produces an error
Error: E_WARNING
Message: Missing argument 1 for upload::upload(), called in /home/otdc/domains/otdc.ru/public_html/paraavis/tinymvc/myfiles/plugins/tinymvc_library_upload.php on line 8 and defined
File: /home/otdc/domains/otdc.ru/public_html/paraavis/libs/class.upload.php
Line: 2573
Reply
Re: Integration of MVC new!
by Sai, 9 years, 11 months ago
Thanks Colin, I solved the problem. Generate the wrapper class:

require('libs/class.upload.php');
class TinyMVC_Library_Upload Extends upload {
    var $file;
    function __construct(){
        parent::__construct($this->file);
        $tmvc = tmvc::instance();
  }
}

Everything works. :)Reply
Re: Integration of MVC new!
by colin, 9 years, 11 months ago
Glad you got it working. And thank you for sharing the code.Reply