Netbeans code completion for CodeIgniter - codeigniter

I am using Netbeans IDE for Php development. It gives me code completion for Kohana framework. Is there any way to have code completion for CodeIgniter in Netbeans?

Instructions:
Create a new directory inside nbproject (I used this since it’s omitted when pushing to prod) with your name of choice, I used CI_Autocomplete.
Create a new file with your name of choice, I used CI_Autocomplete_2.0.php, and place it inside the newly created folder, nbproject\CI_Autocomplete.
Paste the below code inside the new file, CI_Autocomplete_2.0.php.
<?php
/**
* #property CI_DB_active_record $db
* #property CI_DB_forge $dbforge
* #property CI_Benchmark $benchmark
* #property CI_Calendar $calendar
* #property CI_Cart $cart
* #property CI_Config $config
* #property CI_Controller $controller
* #property CI_Email $email
* #property CI_Encrypt $encrypt
* #property CI_Exceptions $exceptions
* #property CI_Form_validation $form_validation
* #property CI_Ftp $ftp
* #property CI_Hooks $hooks
* #property CI_Image_lib $image_lib
* #property CI_Input $input
* #property CI_Language $language
* #property CI_Loader $load
* #property CI_Log $log
* #property CI_Model $model
* #property CI_Output $output
* #property CI_Pagination $pagination
* #property CI_Parser $parser
* #property CI_Profiler $profiler
* #property CI_Router $router
* #property CI_Session $session
* #property CI_Sha1 $sha1
* #property CI_Table $table
* #property CI_Trackback $trackback
* #property CI_Typography $typography
* #property CI_Unit_test $unit_test
* #property CI_Upload $upload
* #property CI_URI $uri
* #property CI_User_agent $user_agent
* #property CI_Validation $validation
* #property CI_Xmlrpc $xmlrpc
* #property CI_Xmlrpcs $xmlrpcs
* #property CI_Zip $zip
*/
class CI_Controller {};
/**
* #property CI_DB_active_record $db
* #property CI_DB_forge $dbforge
* #property CI_Config $config
* #property CI_Loader $load
* #property CI_Session $session
*/
class CI_Model {};
?>
Now go to (this is for OSX so not sure if it’s the same for Windows) File > Project Properties (projectname) > PHP Include Path and include the new folder you created above, nbproject\CI_Autocomplete.
Restart your project and autocomplete will work.

Related

how to expose hidden arrow objects from indicator in chart objects lists

I have an indicator that draws arrows on the chart as seen in the image below:
I tried searching for the arrow objects in Object List but there were no objects there. I also checked Object List>List All menu. I guess the way that the indicator is written has hid them from the chart. How can I expose these objects from the indicator to the chart?
Here are some relevant bits of my indicator:
//--- indicator settings
#property indicator_chart_window
#property indicator_buffers 6
#property indicator_plots 6
#property indicator_type1 DRAW_ARROW
#property indicator_width1 5
#property indicator_color1 0xFFAA00
#property indicator_label1 "Buy"
#property indicator_type2 DRAW_ARROW
#property indicator_width2 5
#property indicator_color2 0x0000FF
#property indicator_label2 "Sell"
#property indicator_type3 DRAW_ARROW
#property indicator_width3 5
#property indicator_color3 0xFFAA00
#property indicator_label3 "Buy"
#property indicator_type4 DRAW_ARROW
#property indicator_width4 5
#property indicator_color4 0x0000FF
#property indicator_label4 "Sell"
#property indicator_type5 DRAW_ARROW
#property indicator_width5 5
#property indicator_color5 0x00FFFB
#property indicator_label5 "CLOSE BUY"
#property indicator_type6 DRAW_ARROW
#property indicator_width6 5
#property indicator_color6 0x00FFFB
#property indicator_label6 "CLOSE SELL"
//--- indicator buffers
double Buffer1[];
double Buffer2[];
double Buffer3[];
double Buffer4[];
double Buffer5[];
double Buffer6[];
datetime time_alert; //used when sending alert
input bool Audible_Alerts = true;
double myPoint; //initialized in OnInit
int MA_handle;
double MA[];
int MA_handle2;
double MA2[];
int MACD_handle;
double MACD_Signal[];
int MA_handle3;
double MA3[];
double Close[];
int MA_handle4;
double MA4[];
int MA_handle5;
double MA5[];
int MA_handle6;
double MA6[];
double Open[];
.
.
.
int OnInit()
{
SetIndexBuffer(0, Buffer1);
PlotIndexSetDouble(0, PLOT_EMPTY_VALUE, EMPTY_VALUE);
PlotIndexSetInteger(0, PLOT_ARROW, 241);
SetIndexBuffer(1, Buffer2);
PlotIndexSetDouble(1, PLOT_EMPTY_VALUE, EMPTY_VALUE);
PlotIndexSetInteger(1, PLOT_ARROW, 242);
SetIndexBuffer(2, Buffer3);
PlotIndexSetDouble(2, PLOT_EMPTY_VALUE, EMPTY_VALUE);
PlotIndexSetInteger(2, PLOT_ARROW, 241);
SetIndexBuffer(3, Buffer4);
PlotIndexSetDouble(3, PLOT_EMPTY_VALUE, EMPTY_VALUE);
PlotIndexSetInteger(3, PLOT_ARROW, 242);
SetIndexBuffer(4, Buffer5);
PlotIndexSetDouble(4, PLOT_EMPTY_VALUE, EMPTY_VALUE);
PlotIndexSetInteger(4, PLOT_ARROW, 251);
SetIndexBuffer(5, Buffer6);
PlotIndexSetDouble(5, PLOT_EMPTY_VALUE, EMPTY_VALUE);
PlotIndexSetInteger(5, PLOT_ARROW, 251);
//initialize myPoint
myPoint = Point();
if(Digits() == 5 || Digits() == 3)
{
myPoint *= 10;
}
MA_handle = iMA(NULL, PERIOD_CURRENT, 1, 0, MODE_SMA, PRICE_CLOSE);
if(MA_handle < 0)
{
Print("The creation of iMA has failed: MA_handle=", INVALID_HANDLE);
Print("Runtime error = ", GetLastError());
return(INIT_FAILED);
}
.
.
.
Arrows can be drawn as objects (in such a case you can find such objects when checking for the objects, select All because they can be hidden), or as indicator buffers. In your case, it looks like arrows are buffers because your indicator initializes buffers. In order to get data, you need to use iCustom function.

CodeIgniter 3.1 and NetBeans 8.0.1 autocompleter

This is my first project with CodeIgniter. I have a problem with autocomplete with Netbeans 8.0.1. I found the answers for this question, but they not working for me.
I Try these solutions but not working for me
How to integrate codeIgniter with netbeans fully
NetBeans 8.0 PHP CodeIgniter Framework support
Netbeans code completion for CodeIgniter
When I try to add folder to PATH there are following ERROR:
Shared: Path D:\MyProjects\project\autocomplete is already part of project.
CI_Autocomplete.php
<?php
/**
* #property CI_DB_active_record $db
* #property CI_DB_forge $dbforge
* #property CI_Benchmark $benchmark
* #property CI_Calendar $calendar
* #property CI_Cart $cart
* #property CI_Config $config
* #property CI_Controller $controller
* #property CI_Email $email
* #property CI_Encrypt $encrypt
* #property CI_Exceptions $exceptions
* #property CI_Form_validation $form_validation
* #property CI_Ftp $ftp
* #property CI_Hooks $hooks
* #property CI_Image_lib $image_lib
* #property CI_Input $input
* #property CI_Language $language
* #property CI_Loader $load
* #property CI_Log $log
* #property CI_Model $model
* #property CI_Output $output
* #property CI_Pagination $pagination
* #property CI_Parser $parser
* #property CI_Profiler $profiler
* #property CI_Router $router
* #property CI_Session $session
* #property CI_Sha1 $sha1
* #property CI_Table $table
* #property CI_Trackback $trackback
* #property CI_Typography $typography
* #property CI_Unit_test $unit_test
* #property CI_Upload $upload
* #property CI_URI $uri
* #property CI_User_agent $user_agent
* #property CI_Validation $validation
* #property CI_Xmlrpc $xmlrpc
* #property CI_Xmlrpcs $xmlrpcs
* #property CI_Zip $zip
*/
class CI_Controller {};
/**
* #property CI_DB_active_record $db
* #property CI_DB_forge $dbforge
* #property CI_Config $config
* #property CI_Loader $load
* #property CI_Session $session
*/
class CI_Model {};
?>
Follow these steps
Create Autocomplete in outside of the application folder.
Inside that create CI_autocomplete.php file
Inside CI_autocomplete.php add below code (Can download here)
<?php
/**
* #property CI_DB_active_record $db
* #property CI_DB_forge $dbforge
* #property CI_Benchmark $benchmark
* #property CI_Calendar $calendar
* #property CI_Cart $cart
* #property CI_Config $config
* #property CI_Controller $controller
* #property CI_Email $email
* #property CI_Encrypt $encrypt
* #property CI_Exceptions $exceptions
* #property CI_Form_validation $form_validation
* #property CI_Ftp $ftp
* #property CI_Hooks $hooks
* #property CI_Image_lib $image_lib
* #property CI_Input $input
* #property CI_Language $language
* #property CI_Loader $load
* #property CI_Log $log
* #property CI_Model $model
* #property CI_Output $output
* #property CI_Pagination $pagination
* #property CI_Parser $parser
* #property CI_Profiler $profiler
* #property CI_Router $router
* #property CI_Session $session
* #property CI_Sha1 $sha1
* #property CI_Table $table
* #property CI_Trackback $trackback
* #property CI_Typography $typography
* #property CI_Unit_test $unit_test
* #property CI_Upload $upload
* #property CI_URI $uri
* #property CI_User_agent $user_agent
* #property CI_Validation $validation
* #property CI_Xmlrpc $xmlrpc
* #property CI_Xmlrpcs $xmlrpcs
* #property CI_Zip $zip
*/
class CI_Controller {};
/**
* #property CI_DB_active_record $db
* #property CI_DB_forge $dbforge
* #property CI_Config $config
* #property CI_Loader $load
* #property CI_Session $session
*/
class CI_Model {};
?>
Goto
Tools
plugins
Installed
Uninstall - PHP CakePHP Framework (Option on Uninstall restart IDE later)
Deactivate - PHP CI Framework Repositary (Option on Uninstall restart IDE later)
All fine. As simple go to your controller type $this->load-> you can see the suggestions Like below image
please note CI_DB_active_record change in codeigniter 3.
put
#property CI_DB_query_builder $db
instead of
#property CI_DB_active_record $db

JSONModel + copmlex object

I have some problem with this library and my objects,I have 3 kind of object:
page, widget, gallery
page:
int
string
dictionary of widget
widget:
int
string
dictionary gallery
gallery
int
string
array page
I create all protocol so I create something like:
page:
import widget
int
string
dict<Widget>
widget
import gallery
int
string
Gallery
dict<Gallery>
Gallery
import page
int
string
array<Page>
after I create delegate and all this I get "unknow type" error and cannot find protocol...where is the error?
You need to define protocol and import the header file
//Page.h
#protocol Page
#end
#class Widget;
#interface Page : JSONModel
#property (nonatomic, assign) NSInteger pageID;
#property (nonatomic, strong) NSString *name;
#property (nonatomic, strong) Widget *widget;
//Widget.h
#class Gallery;
#interface Widget : JSONModel
#property (nonatomic, assign) NSInteger widgetID;
#property (nonatomic, strong) NSString *name;
#property (nonatomic, strong) Gallery *gallery;
//Gallery.h
#import "Page.h"
#interface Gallery : JSONModel
#property (nonatomic, assign) NSInteger galleryID;
#property (nonatomic, strong) NSString *name;
#property (nonatomic, strong) NSArray<Page>* pages;

Magical Record exception while save One-To-Many Entity

in my new App I have Core Data and Magical Record and this is how is structured the db:
This is the class corresponding to the entity NEWS:
#class SMCategories;
#interface SMNews : NSManagedObject
#property (nonatomic, retain) NSNumber * wpId;
#property (nonatomic, retain) NSString * title;
#property (nonatomic, retain) NSString * content;
#property (nonatomic, retain) NSString * url;
#property (nonatomic, retain) NSString * thumbnailUrl;
#property (nonatomic, retain) NSString * thumbnailFile;
#property (nonatomic, retain) NSDate * date;
#property (nonatomic, retain) SMCategories *category;
This is the class corresponding to the entity CATEGORIES:
#interface SMCategories : NSManagedObject
#property (nonatomic, retain) NSNumber * wpId;
#property (nonatomic, retain) NSString * name;
#property (nonatomic, retain) NSDate * lastUpdate;
#property (nonatomic, retain) NSSet *news;
#end
#interface SMCategories (CoreDataGeneratedAccessors)
- (void)addNewsObject:(NSManagedObject *)value;
- (void)removeNewsObject:(NSManagedObject *)value;
- (void)addNews:(NSSet *)values;
- (void)removeNews:(NSSet *)values;
This is the function I use to save, inside a cycle, all the datas that should be saved in the entity CATEGORIES:
- (void)saveUpdateCategories:(NSString *)result {
NSDictionary *tmpCategories = [result objectFromJSONString];
NSArray *categoriesList = [tmpCategories objectForKey:#"categories"];
NSDictionary *singleCategory;
NSPredicate * filter = [[NSPredicate alloc] init];
for(int i = 0; i < [categoriesList count];i++) {
singleCategory = [categoriesList objectAtIndex:i];
filter = [NSPredicate predicateWithFormat:#"wpId == %#",[singleCategory objectForKey:#"id"]];
SMCategories *checkCategory = [SMCategories MR_findFirstWithPredicate:filter];
[MagicalRecord saveWithBlock:^(NSManagedObjectContext *localContext) {
SMCategories *categoryToAdd;
if (checkCategory == nil) {
categoryToAdd = [SMCategories MR_createEntityInContext: localContext];
} else {
categoryToAdd = checkCategory;
}
categoryToAdd.name = [singleCategory objectForKey:#"name"];
categoryToAdd.wpId = [currentUtils stringToNumber:[singleCategory objectForKey:#"id"]];
categoryToAdd.lastUpdate = [currentUtils stringToDate:#"01/01/2000 00:00:01" formatted:#"dd/MM/yyyy HH:mm:ss"];
categoryToAdd.news = nil;
} completion:^(BOOL success, NSError *error) {
if (i == [categoriesList count] - 1) {
[progressWheel stopAnimating];
NSMutableDictionary *tmpOptions = [[NSMutableDictionary alloc] init];
tmpOptions = [currentUtils getDictionaryPlistFile:#"options.plist" path:[currentUtils getMainLocalPath]];
[tmpOptions setObject:[NSDate date] forKey:#"lastCategoriesUpdates"];
[currentUtils saveDictionaryPlistFile:tmpOptions fileName:#"options.plist" path:[currentUtils getMainLocalPath]];
[menuButton setEnabled:YES];
if (categoryToLoadPassed == nil)
categoryToLoadPassed = [SMCategories MR_findFirstByAttribute:#"name" withValue:DEFAULT_CATEGORY];
[self downloadNewsOfCategory:categoryToLoadPassed];
}
}];
}
}
This part of code works as well.
This is the funcion I use to save, inside another cycle, all the datas that should be inserted into the entity NEWS.
-(void) saveNewsOfCategory:(SMCategories *)category resultToSave: (NSString *) result {
NSDictionary *tmpNews = [result objectFromJSONString];
NSArray *newsList = [tmpNews objectForKey:#"posts"];
NSDictionary *singleNew;
NSPredicate * filter = [[NSPredicate alloc] init];
for(int i = 0; i < [newsList count];i++) {
singleNew = [newsList objectAtIndex:i];
filter = [NSPredicate predicateWithFormat:#"wpId == %#",[singleNew objectForKey:#"id"]];
SMNews *checkNew = [SMNews MR_findFirstWithPredicate:filter];
[MagicalRecord saveWithBlock:^(NSManagedObjectContext *localContext) {
SMNews *newToAdd;
if (checkNew == nil) {
newToAdd = [SMNews MR_createEntityInContext: localContext];
} else {
newToAdd = checkNew;
}
newToAdd.category = category;
newToAdd.title = [singleNew objectForKey:#"title"];
newToAdd.content = [singleNew objectForKey:#"content"];
newToAdd.wpId = [currentUtils stringToNumber:[singleNew objectForKey:#"id"]];
newToAdd.date = [currentUtils stringToDate:[singleNew objectForKey:#"date"] formatted:#"yyyy-MM-dd HH:mm:ss"];
newToAdd.url = [NSString stringWithFormat:#"%#?p=%#",WEBSITE,[singleNew objectForKey:#"id"]];
newToAdd.thumbnailFile = nil;
newToAdd.thumbnailUrl = [singleNew objectForKey:#"image"];
} completion:^(BOOL success, NSError *error) {
if (i == [newsList count] - 1) {
[MagicalRecord saveWithBlock:^(NSManagedObjectContext *localContext) {
category.lastUpdate = [NSDate date];
} completion:^(BOOL success, NSError *error) {
[progressWheel stopAnimating];
[currentTable reloadData];
}];
}
}];
}
}
Here it's thrown an exception EXT_BAD_ACCESS next to the line
newToAdd.category = category;
category is passed as one of the parameters of the corresponding function.
As you would have understood I have 2 entitis CATEGORIES and NEWS with a One-To-Many relationship.
First off I download all the categories and I store them into CATEGORIES entity when the user wants to download all the news of a specific category I download them and store with the second function into news entity passign into the second function the category of those specific news as parameters of my function.
If delete the line incriminated all the news are correctly store inside the database but they are not related to any cateogries.
What am I doing wrong?
The following line that threw an exception because I save the entity in a new Thread.
newToAdd.category = category;
So used a singleton class to get the category and set in that specific localcontex this way
SMCategories *currentCategory = [[DataManager getInstance] getCurrentCategory];
newsToAdd.category = [currentCategory MR_inContext:localContext];
Now everything works correctly.

many-to-one relation core data

I am obviously new in Core Data, I have read quite a lot about the topic from Apple and from countless other sources. However, none seems to treat the many-to-one relation in a way for a newbie like me to understand. I seems to be fine with one-to-one relation, but I have some difficulties on understanding many-to-one relation.
My problem is as follow:
I am working on a small project to practice Core Data. In my project, there are two entities:Person and Note and they are related as follow:
(Sorry, couldn't add the picture)
A Person can have several notes, but Note can only have one owner, Person. Person entity is related with a one-to-many relation (double arrows pointing to the entity: Note), while the entity Note is related with a many-to-one (single arrow pointing to Person)
This is what I have so far:
Note.h
#class Person;
#interface Note : NSManagedObject
#property (nonatomic, retain) NSDate * noteCreateDate;
#property (nonatomic, retain) NSString * noteUser;
#property (nonatomic, retain) Person *person;
Person.h
#class Note, Organise;
#interface Person : NSManagedObject
#property (nonatomic, retain) NSString * personAddress;
#property (nonatomic, retain) NSData * personAvatar;
#property (nonatomic, retain) NSString * personBDay;
#property (nonatomic, retain) NSDate * personFutureDate;
#property (nonatomic, retain) NSString * personGender;
#property (nonatomic, retain) NSString * personName;
#property (nonatomic, retain) NSString * personRelation;
#property (nonatomic, retain) NSSet *notes;
#property (nonatomic, retain) NSSet *organises;
#end
#interface Person (CoreDataGeneratedAccessors)
- (void)addNotesObject:(Note *)value;
- (void)removeNotesObject:(Note *)value;
- (void)addNotes:(NSSet *)values;
- (void)removeNotes:(NSSet *)values
In my view controller I am trying to save the notes as follow:
NSManagedObjectContext *context = [self managedObjectContext];
Note *newNote;
newNote = (Note *) [NSEntityDescription insertNewObjectForEntityForName:#"Note" inManagedObjectContext:context];
// Saving the notes
newNote.noteUser = noteTextView.text;
newNote.noteCreateDate = added;
[newNote setPerson:newNote.person];
///////////////Saving to the DataBase /////////
NSError *error = nil;
if ([self.managedObjectContext hasChanges]) {
if (![self.managedObjectContext save:&error]) { //save failed
NSLog(#"Save Failed: %#", [error localizedDescription]);
}
else {
NSLog(#"Save Succeeded");
}
}
It is saving the data in the database fine, but the problem is: There is no relationship between Person and Notes in the database. The column for person in the database is empty (not showing to whom the note belong to).
I have tried several things to try to link the person with the note, NONE of them seems to work. So, it seems that I am stucked and I would very much appreciate some help.
This is the latest tutorial I used for help:
http://brandontreb.com/core-data-quicktip-inverse-relationships
https://itunes.apple.com/fr/itunes-u/advanced-iphone-development/id407243028?l=en&mt=10
Thank you.
Your code does not create any relationship between the Note and a Person. This:
[newNote setPerson:newNote.person];
is the same as newNote.person = newNote.person; and does not change anything.
You must create a Person object (or fetch an existing Person) and then set
newNote.person = thePerson;
to establish the relationship.

Resources