Yii Framework in Netbeans - Object Method Autocomplete Not Appearing - php

I have just noticed that the object method autocomplete does not bring up a list of methods to autocomplete with. I saw it when I was using the $PDO->bindParam() method. Normally, I can just start typing "bi" after the method arrow and the autocomplete will come straight up with the method. Now, these methods do not appear, however methods and attributes in my personally defined classes will appear. Also, it says "PHPDoc not found".
It's strange because it has worked fine previously. The only thing I can think of is that I had to delete the project out of Netbeans and then recover it back using "new project from existing sources".
Is there a broken link to a documentation file I need to re-connect? How would I go about fixing this? Also, apologies if this is an asinine question.

Code completion
To get context sensitive code completion, follow these steps:
Include Yii folder (assuming it is properly placed outside project directory)
Open "File > Project properties > PHP Include Path" and add the Yii framework root path
Ignore yiilite.php to avoid doubled/missing documentation
Open "Tools > Options > Miscellaneous > Files"
Add to the front of "Files Ignored by the IDE" the file "^(yiilite\.php|CVS|SCCS|...."
Restart NetBeans
Code completion in view files
Add the following PHPDoc statement at the head of the file to use code completion in view files. (you may add additional passed parameters as well)
/* #var $this PostController */
/* #var $model Post */
$this->getSomeProValue(); // possible with code completion
$model->author; // possible with code completion
Usage:
Typing suggestions: Ctrl-Space
Show Function parameters: Ctrl-P
Comment your own code with PHPDoc style. Here's a good example.

Related

Mass action doesn't work for Magento backend grid serializer

I've created a grid inside the tab using grid serializer using this tutorial. Then I've added a massaction to this grid using this tutorial.
Mass action block has appeared, but when I choose entities, choose massaction and click Submit, following error has been thrown to browser's console:
"ReferenceError: {gridId}_massactionJsObject is not defined"
Have anybody ever tried to add a mass action to the grid inside the tab? How to solve this error?
Instead of removing var in the abstract class just set the object to the window.
in app/design/adminhtml/default/default/template/widget/grid.phtml calls out to getAdditionalJavascript()
In your grid file add this function.
protected function getAdditionalJavascript() {
return 'window.{gridId}_massactionJsObject = {gridId}_massactionJsObject;';
}
I just attempted this today and ran into the same problem on Magento CE 1.8. After some digging, A co-worker and I discovered that the JavaScript in grid.phtml (lines 207-224) was running but not showing up in the DOM (still not sure why). When using the console, we noticed the varienGrid object is accessible because it is global due to being defined without a var.
With that being said, we found the mass action js in Abstract.php in the function getJavascript() (line 225) and removed the var from the variable definition. This solved the problem for us and hopefully will help you out. Also, you should not modify core. The file should be copied to local and modified there.
grid.phtml - app/design/adminhtml/default/default/template/widget/grid.phtml
Abstract.php - app/code/core/Mage/Adminhtml/Block/Widget/Grid/Massaction/Abstract.php

How to use Ajax with jQuery in Laravel 4?

I am brand new to Laravel 4 and seeing if I can convert my website over to it (previously written without a framework). I can't get AJAX (via jQuery) to interact properly with my controller.
So firstly, the controller I am working in is called IndexController.php and has a function called types which is shown below:
class IndexController extends BaseController {
// Other controller functions
public function types($brand) {
$types = DB::select('select * from aircraft_types where brand_id = ?', array($brand));
echo json_encode($types);
}
}
The function returns the data from the database (in JSON format). I have then created a route to this controller and function as follows:
Route::get('types/{id}', array('uses'=>'IndexController#types'));
I have doubled checked that the route and function are working by going to //localhost/lavarel/public/types/1 and indeed it returns the correct JSON data.
The jquery function in question is below:
function updateTypes($brand) {
$("#type").append('<option value="test">Test...</option>'); // This executes correctly
$.getJSON('/types/'+$brand, function(data) {
$("#type").append('<option value="test 2">Test 2...</option>'); // This does not
// Some other JSON related code
});
To test where the function works, I have inserted two lines which edit the item I am using. The function is being called correctly as the first 'Test' option is being appended. However, it never seems to activate the callback function as the second line of test code is not executed.
I suspect the issue is the URL I am providing to JavaScript '/types/'+$brand. I have seen in some tutorials a BASE var used before the URL I provide, but I don't see why my code above wouldn't work. Any pointers?
Can anyone explain to me where I am going wrong?
Your base path to your laravel project is localhost/laravel/public/ but your AJAX-request goes to just localhost. There're some methods for fixing this.
Method 1:
This is the most preffered method. (in my opinion)
Instead of using nginx, apache for starting a web server, you can use PHP's built in web server.
Open a terminal window (or cmd in Windows), cd into the main directory for your project (the one with vendor, app and public directories) and type the command php artisan serve. This will create a PHP-server on localhost:8000 and your base path will be /.
There's a lot of options, for example php artisan help serve" if you want to see them all.
After you've done so your code should work.
Method 2
If you want to use nginx or apache you should add a virtualhost for your project.
That can be done though the configs.
Apache: http://httpd.apache.org/docs/current/vhosts/examples.html
Nginx: http://wiki.nginx.org/ServerBlockExample
After that you should add a new entry to the hosts file.
Method 3
As you said you could add a BASE variable before the '/types/'+$brand.
Your request goes to localhost/types/$brand.
It should go to localhost/laravel/public/types/$brand.
Just replace '/types/'$brand with '/laravel/public/types'+$brand
Use HTML 'base' meta tag
<!doctype html>
<html lang="en">
<head>
...
<base href="{{ URL::to('/') }}"/>
...
Declaring this tag, you ensure that every relative URL will be based on project's real, absolute URL (http://localhost/my-laravel-project/public/), not on Localhost's URL (http://localhost)

ReDJ plugin fom Joomla 2.5 to Joomla 3 migrating (nothing displays in admin panel)

I had ReDJ plugin v 1.6 working on 2.5 Joomla site. But I'm moving on Joomla 3 and this module don't work now - exception errors appears. In change-logs I found this:
Changed class names for ALL models, controllers and views. So I simply add Legacy suffix to all classes that handles exceptions. And also change JRequest (it is deprecated in v3) on $input=JFactory::getApplication()->input;.
So for now, seems like all is working fine. Except.. component admin panel - i can see component menu, but there is no any content on page.
Here is screenshot: http://tinyurl.com/btfzxux
Main controller controller.php code:
http://pastebin.com/vQjYvYkK
Main component file redj.php code:
http://pastebin.com/gF6icdE3
I found that dont work line parent::display(); in controller.php file. And there is no error in logs and display.
And this line calls JControllerAdmin->display() which is:
/**
* Display is not supported by this controller.
*......................
*......................
*/
public function display($cachable = false, $urlparams = array())
{
return $this;
}
So nothing displayed. I tried to rename extends definition as JControllerLegasy (because it supports display() method), but still nothing in component output.
How can i output component content in admin panel in Joomla 3?
Any help appreciated.
S.G.
UPDATE 1:
I publish my code on GitHub. I'm tying to optimize this plugin for Joomla 3. Any help welcome!
https://github.com/staniaslavg/ReDJ
P.S. Now redirection list displays and adding a new one works fine. But.. there is no items in item list.
UPDATE 2:
Finally, everything works fine (tested jnly by me, but seems like everything is OK..)
P.S. If nothing displays in tabs - check for DataBase columns. I added a few more. Check whis by var_dump errors variable (like $this->get('Errors')) in files views/.../view.html.php
Code on GitHub: https://github.com/staniaslavg/ReDJ
I've posted some updates in the github repo, to show that it's possible to get it working. (for the redirects view sequence). Unforunately some code used in Joomla! 2.5 by the component was already deprecated and was removed in 3.0. Also the GUI looks bad in 3.0, it needs more work.
As much as I would like to help you to get it running, the time involved it huge. I would strongly suggest using Joomla! 2.5 which is still for a good period supported.
Also the developer announces that a Joomla! 3.0 version is underway.
Going over all the code and fixing it makes little sense for me, but here are some examples:
JDatabase::getEscaped() has been removed. Use JDatabase::escape() instead.
$db->getEscaped($orderCol.' '.$orderDirn)
=> $db->escape($orderCol.' '.$orderDirn)
JToolBar no longer supports the 'X' functions (eg, addNewX, editListX) that hide the main menu before doing the function.
and others.

Developing/using a custom Resource Plugin in Zend Framework

We have used Zend_Log, which is configured in application.ini differently for different circumstances. We initialize it/get it in the bootstrap and store it in the registry:
$r = $this->getPluginResource('log');
$logger = $r->getLog();
But we've subclassed Zend_Log (say, Our_Log) to add customized features, and want to get it the same way. So then we have to make a new Resource Plugin. That seems quite easy - just copy Application/Resource/Log.php, rename the file to Ourlog.php, rename the class to class Zend_Application_Resource_Ourlog. For now, let's not worry about "Our_Log", the class -- just use the new Resource Plugin to get a Zend_Log, to reduce the variables.
So then, our new code in the bootstrap is:
$r = $this->getPluginResource('ourlog');
$logger = $r->getLog();
but of course this doesn't work, error applying method to non-object "r". According to the documentation,
"As long as you register the prefix path for this resource plugin, you
can then use it in your application."
but how do you register a prefix path? That would have been helpful. But that shouldn't matter, I used the same prefix path as the default, and I know the file is being read because I "require" it.
Anyway, any guidance on what simple step I'm missing would be greatly appreciated.
Thanks for the pointers -- so close, so close (I think). I thought I was getting it...
Okay, so I renamed the class Xyz_Resource_Xyzlog, I put it in library/Xyz/Resource/Xyzlog.php
Then, because I don't love ini files, in the bootstrap I put:
$loader=$this->getPluginLoader();
$loader->addPrefixPath('Xyz_Resource','Xyz/Resource/');
$r = $this->getPluginResource('xyzlog');
if (!is_object($r)) die ('Not an object!!');
Sudden Death. So, okay, do the ini:
pluginPaths.Xyz_Resource='Xyz/Resource/'
The same. No help. I believed that the basepaths of the plugin paths would include the PHP "include" paths. Am I mistaken in that? Any other ideas? I'll happily write up what finally works for me to help some other poor soul in this circumstance. Something to do with Name Spaces, maybe?
Plugin classes are resolved using the plugin loader, which works slightly differently to the autoloader; so just requiring the class in doesn't help you here. Instead, add this to your application.ini:
pluginPaths.Application_Resource = "Application/Resource"
you should then be able to use the class as normal. Since your path above will be checked before the default Zend one, you can also name your class 'Log' and still extend the Logger resource to override the standard functionality.

CodeIgniter: Can't Get My New Controller/View To Show

I am learning how to use codeIgniter as my php framework. I am reading through the documentation and watching the intro video and just generally following along with the first tutorial, but it's not working for me.
I have created a controller called "test.php" and a view called "test_view". The controller for this class is exactly like "welcome.php" and the view file just has some static html. However, when I go to index.php/test I get a 404 error.
I have also tried manipulating the original welcome files so that instead of calling a view it just echos "testing", yet I still see the original welcome message! I've tried clearing my browsing cash and refreshing, but to no avail.
Any suggestions? Thanks.
Edit: Here's the code for controllers/test.php
<?php
class Test extends Controller {
//Just trying to get it to echo test
public function index()
{
echo "test";
//$this->load->view('test_view');
}
}
?>
Try looking at this page in the documentation - this might solve your problem.
This basically means you should try typing index.php?/test/ instead (notice the question-mark).
First of all, check the above link. Might be useful.
If not, then...
Try changing the default controller in the config file ('routes.php') to something else (probably, to 'test'), then try loading index.php. Just to test whether the whole system works (or not).
Check whether mod_rewrite is loaded (in your server .conf-file, if you're using Apache).
Try using the latest build of the framework. AFAIK, the name of the controller class for now is "CI_Controller".
Finally, try removing the word 'public' before the declaration of the function. AFAIR, CI enable you to make private functions in controllers just by using prefix (which is set in the config file) at the beginning of the name of the function (thus making all the other functions public).
But most certainly the problem is with the mod_rewrite. If not, try debugging with die('Page found'); instead of echo - this will allow you to track possible redirects on the page.

Categories