phpgrid using codeigniter - php

I'm working on a web application using codeigniter and i want to use php grid
in displaying information but i dont know how to do it with codeigniter! Is there anyone has worked with php grid using codeignitier? Help please!! I'm would have opted for flexigrid
but it doesn't offer so much functionality such as exporting to various document format(excel, word, e.t.c).
Thanx in advance!

I'm not familiar with php grid, but usually you can just throw a class file in application/libraries and then load it like this:
$this->load->library('phpgrid');
// and use it like this
$this->phpgrid->phpgrid_method();

You can use the following code to load php datagrid or any 3rd party PHP libraries.
$this->load->library('phpgrid');

Another approach in CodeIgniter is to directly include third party libraries without calling load library.
require_once(APPPATH. 'libraries/phpGrid_Lite/conf.php');
$data['phpgrid'] = new C_DataGrid("SELECT * FROM Orders", "orderNumber", "Orders"); //$this->ci_phpgrid->example_method(3);
APPPATH is explained in this SO discussion.

Related

Change Laravel 8 Notification Salutation without publishing the template files

I would like to edit the 'regards, {application name}' part in the toMail Notifications without publishing the blade template files. Imo its an overkill to do so
Part in Question is here
I know Laravel provides several functions to change the contents of the Mail but this part seems to always stay the same unless edited via the template files.
Thank you in advance!
So after some digging through the files I found the solution and it's pretty easy:
return (new MailMessage)
->from('info#test.com', 'Testorganisation')
->subject('Your mailsubject')
->greeting("Hello $notifiable->name,")
->salutation("You are welcome"); // Change this for a different salutation
This results in this output
It's handled via the subject-Function inside the SimpleMessage.php file located in /vendor/laravel/framework/src/Illuminate/Notifications/Messages/
Hope this helps someone, since I didn't find a solution other than publishing the blade templates.
I don't know when the function was added, but works in Laravel 8+

Can't get MaxMind Reader to work

According to their PHP Packagist repository page
https://packagist.org/packages/maxmind-db/reader
the following code is all I need to get the reader to work. PHP doesn't seem to like the use MaxMind\Db\Reader;line. Any clue on how to fix this so it uses the reader.
require_once 'vendor/autoload.php';
use MaxMind\Db\Reader;
$reader = new Reader('GeoIP2-City.mmdb');
print_r($reader->get($_SERVER['REMOTE_ADDR']));
$reader->close()
Okay the solution I figured out is that anything that uses the keyword [use] need to be first in the PHP document; e.g. API.

Codeigniter: highlighting strings text in codeigniter

I tried to implement this(http://web.archive.org/web/20080506155528/http://software.zuavra.net/inline-diff/) with my codeigntier framework but i could not able to implement it.
Anyone if you have implemented this with codeigniter framework then please help me.
Why i could not able to implement:
I run those files seperately(Not with framework) & it worked for me. but while keeping the same files( i.e inline_example.php content) in my COdeigniter controllers then it showed me too many errors like(shown in image) . Then i though this is out of my capacity to implement with codeignter. so i thought to ask here help
i have implemented this library in codeigniter.
To resolve that error you have to replace &new variable to new in all library files of inline diff.
for example :
inline_function.php
$diff = &new Text_Diff($hlines1, $hlines2);
$diff = new Text_Diff($hlines1, $hlines2);
and also change path in unified.php and diff.php
require_once(APPPATH.'libraries/Text/Diff/Renderer.php');

include typoscript with php

Is it possible to include a typoscript file via php?
Normally I would include typoscript with this:
<INCLUDE_TYPOSCRIPT: source="FILE:fileadmin/templates/typoscript/setup/1.ts">
But I want to do this just with php and not typoscript. Is that possible?
My Purpose: I want to dynamically load typoscript in my page
This can be achieved by invoking accordant functions at an early stage, e.g. in calling or delegating it in ext_localconf.php. For example, the bookstrap package is loading TypoScript in PHP like this:
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addPageTSConfig(
'<INCLUDE_TYPOSCRIPT: source="FILE:EXT:' . $_EXTKEY
. '/Configuration/PageTS/Mod/Wizards/newContentElement.txt">'
);
Please consider, that TypoScript is cached before the actual front-end rendering starts. This means, that you should not modify TypoScript if you're plugin class or controller logic has been called already.
May be you need to return a value from the php function and use typoscript conditions for choosing the typoscript file.
You might try the following (if I get you right):
$typoscriptFile .= file_get_contents($someFile);
$parser = t3lib_div::makeInstance('t3lib_TSparser');
$parser->parse($typoscriptFile);
$tsArray = $parser->setup;
I really don't know how well that will play with anything related to global typoscript though.
If you wanted a complete correct parse, you might be able to pull something like this off if you populated a fresh t3lib_TStemplate instance from $GLOBALS['TSFE']->tmpl and than ran the code above. Might work, never tried.

How to connect these 3 programming languages?

How to pass information in this flow:
Flash(AS3) -> PHP, using XML -> Database(mysql)
Can anyone write a simple code for that?
Thanks.
http://www.kirupa.com/developer/actionscript/flashphpxml_integration.htm
This will tell you most of what you need to know to get started.
If you're not already tied to using XML, you might want to look into using AMF. There's a number of OSS implementations of AMF for PHP, from the obviously named amfphp to an implementation in the Zend Framework. Hopefully somebody with experience here will come along and provide a better answer.
What about WebService SOAP/WSDL?
So you can provide web service on php and send information from Flex/AS3/Flash by calling some webservice method and then store it into mysql db.
Flex has class WebService, so on client side to call server method is as easy as:
var webService:WebService = new WebService();
webService.wsdl = "http://yoursite.com/webservice.wsdl";
webService.loadWSDL();
webService.this_is_method_from_php_server(your_object_serialized_as_xml);
On PHP side I'm sure there are dozen libraries to provide SOAP/WSDL.
I would recommend using amfPHP to get information from a MySQL database passed to Flash through php. It is simpler, faster and easier to use than using php to output the database result in xml. Basically what you do with amfPHP is that you can call php functions directly from flash using the LocalConnection class.
I'll simplify some code to illustrate how it works:
//PHP code
//Here's you main php class which all the sql commands will be called
class Main{
public function saveUser($username, $password){
//I'll send in the username and password to insert it into the users column
$this->db->query("INSERT INTO users VALUES ($username, $password)");
//I'm using the MDB2 library for sql queries,
//you write less code when doing queries.
}
}
//Actionscript 3 code
//To pass parameters to my php function I have to make an array.
var amfParameters:Array = [];
amfParameters['username'] = "richard";
amfParameters['password'] = "123123";
//Then create a localconnection which will connect to amfphp.
var localConnection:LocalConnection = new LocalConnection();
localConnection.connect(gatewayURL); //gatewayURL is the url to the gateway amfphp file
localConnection.call("testproject.Main.saveUser", loaderResponder, amfParameters);
//testproject.Main.saveUser is the path for our Main.php file and saveUser is the function
//loaderResponder is a Responder class which handles the callback from amfphp.
So basically you will call the php function in flash, and you can also return data to flash aswell.
This is just to illustrate a little bit of how amfphp works. It's not meant to be a complete code sample. Just to give a brief idea.
Think about it and if you think it looks interesting go and download amfphp and try it out! You won't be dissappointed.

Categories