Migration from Joomla 2.5 to Joomla 3.4.5 results in strange server error 500 - migration

I installed a brand new, clean Joomla 3.4.5 and then installed a component written by myself, which worked totally fine in Joomla 2.5. In Joomla 3 however, I get server error 500... in some cases...
I narrowed the error down to the following weird situation:
The component is called com_confighdv (I'm extending Joomla core's com_config). I added a view called JustaName, existing of two files:
admin/views/justaname/view.html.php:
<?php
class ConfigHdVViewJustaName extends JViewLegacy
{
}
?>
admin/views/justaname/tmpl/default.php:
Hello world!
This works fine when I go to index.php?option=com_confighdv&view=justaname.
Then I change the view's name from JustaName to Component:
The view's folder becomes: admin/views/component/
Class declaration becomes: class ConfigHdVViewComponent extends JViewLegacy {}
Now, when I go to index.php?option=com_confighdv&view=component I get a server error 500 :s
I really don't know what to do with this. Help is very much appreciated!

Solved! Switching to Joomla's maximum error reporting provided the explanation:
Fatal error: Class ConfigHdVModelComponent contains 1 abstract method and must therefore be declared abstract or implement the remaining methods (JModelForm::getForm) in /xxx/administrator/components/com_confighdv/models/component.php on line 18
So, the problem is not in the view, but in the model that belongs to the Component view!
I accidentally created this problem myself, by reducing the model declaration to what I thought was the absolute minimum:
class ConfigHdVModelComponent extends JModelAdmin
{
{
While this is not allowed, because you always have to define the getForm method, so:
class ConfigHdVModelComponent extends JModelAdmin
{
public function getForm($data = array(), $loadData = true)
{
}
{

Related

How to modify the base class of the class builded by "yiic migrate create XXX"?

All
I am using "yiic migrate" to setup my database,
But I got a problem,
for example,
$ ./yiic migrate create create_table_user
then, I got a class like this :
class m130918_015910_create_table_weddings extends CDbMigration
{
// something else
}
But I want it to be like this :
class m130918_015910_create_table_weddings extends migration_create_table
{
// something else
}
Is there any idea to do this ?
Oh, BTW, I searched the handbook, but nothing I got...
Per the page on the Yii guide about migrations, you can adjust the template file used with a templateFile flag on the command line:
http://www.yiiframework.com/doc/guide/1.1/en/database.migration#customizing-migration-command
Think that's what you need ...

On Yii framework, getting "Unable to resolve the request'

I'm trying to modify a previous developer's app and I believe I'm mimicking previous controllers but keep getting this error. After reading up, it appears my code is correct, but obviously not. Here is my code for the file .../public_html/protected/controllers/ProcessRawDataController.php
<?php
class ProcessRawData extends Controller {
public function actionIndex()
{
echo 'bla';
exit;
}
}
?>
When I go to this URL: mydomain.com/index.php?r=processRawData/index or mydomain.com/index.php?r=processRawData i get the error. I've tried changing to all lower case as well with the same result.
After posting this question, I just realized the error. The class declaration is missing the word "Controller". It should read
class ProcessRawDataController extends Controller {

Geb page url method from ConfigSlurper

I am trying to store the urls I need in a config file that gets pulled using ConfigSlurper. I think this may not work but not sure. Thoughts?
You are probably looking for functionality provided by baseUrl configuration. When using to MyPage the url which is used by the browser is determined by combining basUrl configuration and the url property of your page class.
If you wanted a slightly cleaner method of doing this, you could implement a base page such as the one below - inner class for brevity and to avoid calling protected methods directly - (we have apps on 26 different subdomains!):
package page.admin
import geb.Configuration
import geb.Page
class AdminPage extends Page {
class WrappedConfig extends Configuration {
WrappedConfig(ConfigObject rawConfig) {
super(rawConfig)
}
String getAdminBaseUrl() {
return readValue('adminUrl', '<invalid-url>')
}
}
String getPageUrl() {
WrappedConfig config = new WrappedConfig(browser.config.rawConfig)
return config.adminBaseUrl + this.class.url
}
}
Your config might look something like this:
baseUrl = 'http://base-app.example.net'
adminUrl = 'http://admin-app.example.com'
This way, you can still use normal geb syntax:
given:
to PageWhichExtendsAdminPage, 'your-path', key1: 'value1
to generate the url http://admin-app.example.com/your-path/?key1=value1
I run geb on different locales so I encountered the same issue. I usually load the different urls out of a config file with locale.getCountry() as parameter for the environment.
In the running class I replace the baseUrl with the loaded entry with the ConfigSlurper. The advantage is that I can handle multiple locales and localhost environments. Testing locally vs testing the staging environment.
I have one main spock file containing the whole regression testing and a inheriting spock class for every country. The inheriting spock files doesn't contain much except the country/language encoding in the class name.
The config file:
environment{
CA{
url="ca.somewhere.com"
validZipCode=...
...
}
...
}
The main class:
class MainRegression extends GebReportingSpec{
#Shared Locale locale
def setupSpec(){
...
locale = ParameterReader.getLocale(this.class.name)
...
}
def "testing the website"(){
when: "entering the main url"
go URLService.getBaseUrl(locale)
...
}
The inheriting class:
#Stepwise
class CaEnRegressionSpec{} // Canada with english language
A good way to handle the at-verification with different languages / locales:
http://ldaley.com/post/1013531080/painless-page-identification-with-geb-grails

Translation of Zend_Validation in ZF2

I have a strange Problem in Zend Framework 2. I've used the Zend Skeleton Application (https://github.com/zendframework/ZendSkeletonApplication) and added PhlyContact as Vendor Module (https://github.com/weierophinney/PhlyContact). I changed the Translation-Type to PhpArray so that i can use the Zend_Validate.php located in the resources-dir of the ZF2-Dist.
Everything translates EXCEPT the validation Messages :/ So i guess i am missing something:
I must pass the Translator to Zend_Validate (but how and where?)
The Translation should use a Text-Domain, but doesn't
When i remember right in ZF1 you had to set the Translator to default to pass it to Zend_Validate. Any Ideas on that !?
have a look at these methods
\Zend\Validator\AbstractValidator::setDefaultTranslator();
\Zend\Validator\AbstractValidator::setDefaultTranslatorTextDomain();
You can even do this with only one line (2nd parameter is text domain):
AbstractValidator::setDefaultTranslator($translator, 'default');
Example within Module.php:
use Zend\Validator\AbstractValidator;
class Module
{
public function onBootstrap(MvcEvent $e)
{
$translator = ....
AbstractValidator::setDefaultTranslator($translator, 'default');
}
}

Zend framework common code for all the controllers

I have a login button in the header of the website. This header's html is programmed into Zend framework views/layouts/home.phtml.
I have a hidden form in this layout that is triggered by jQuery thickbox inline content display integration. Reason, I dont want to make a ajax call to just fetch a small login form.
I create the form using Zend_Form and the problem is that I have to do it in all the controllers after checking if the user is logged in or not. I want to place this form generation in one single place, say in bootstrap and then have a logic in bootstrap to say that if user is logged in dont generate the form.
I don't know if bootstrap is the right place to do so or should I do it in some other place.
So, where should I instantiate the form so that its available everywhere if user is not logged in.
Create your own base controller which extends Zend_Controller_Action then have your controllers extend off of your base controller. I don't know what "jQuery thickbox inline content display integration" is...but you have several sections you can put it in depending when you need your code to run. init(), preDispatch(), postDispatch() etc... Just make sure when you extend off your base controller that you do sthing like:
parent::init()
parent::preDispatch()
parent::postDispatch()
etc... within each section so that the base code runs as well...
Be careful about Pradeep Sharma's solution (the answer he wrote himself and accepted below).
All the code code below is for ZF 1.12, and not ZF 2.0
In the bootstrap, Zend_Layout's MVC instance might not have been created yet. You should use Zend_Layout::startMvc() instead :
$view = Zend_Layout::startMvc()->getView() ;
And tbh I prefer executing this code in the preDispatch() function. New users of ZF might be interested in this :
application/plugins/HeaderForm.php :
class Application_Plugin_HeaderForm extends Zend_Controller_Plugin_Abstract
{
public function preDispatch(Zend_Controller_Request_Abstract $request)
{
$view = Zend_Layout::startMvc()->getView() ;
$view->headerForm = new Application_Form_HeaderForm() ;
}
}
Calling new Application_Form_HeaderForm() will autoload by default into application/forms/ folder. You can also create the form directly into the plugin with new Zend_Form(), and addElement() etc. but it won't be reusable.
Of course, you need to register this plugin in your bootstrap!
application/Bootstrap.php :
class Bootstrap extends Zend_Application_Bootstrap_Bootstrap
{
protected function _initPlugin()
{
$front = Zend_Controller_Front::getInstance() ;
$front->registerPlugin(new Application_Plugin_HeaderForm()) ;
}
}
Calling new Application_Plugin_HeaderForm() will autoload by default into application/plugins/ folder
I did it in a different way, extendingZend_Controller_Plugin_Abstract to implement a plugin and register it with front controller.
public function routeStartup(Zend_Controller_Request_Abstract $request) { }
generated the form inside the above mentioned method and by setting the form in $view object.
$view can be retrived using :
$view = Zend_Layout :: getMvcInstance()->getView();