Showing posts with label CodeIgniter. Show all posts
Showing posts with label CodeIgniter. Show all posts

Monday, April 21, 2014

PYROCMS Module View Call from Helper

 Pyrocms:
We used pyrocms , in this each module contain plugin.php.
This file used for display the module views.
This plugin.php used $this->module_view function.

But we need to load  the other modules view files only option in plugin.php.
Not other option.


so i wrote this code for simply call the module view from any location.



Code : [put this code to helper file or create new helper file  in (system/cms/helpers/)]
require_once APPPATH.'libraries/Plugins.php';

class Display_mview extends Plugin
{

 public    function disp_module($module, $view, $vars = array(), $parse_output = true) {
       
        $ci =& get_instance();
        $mview = $this->module_view($module,$view, $vars , $parse_output);
        return $mview ;
    }

}


 function module_view($module, $view, $vars = array(), $parse_output = true)
{
    $dview = new Display_mview();
    $module_view = $dview->disp_module($module,$view, $vars , $parse_output);   
    return $module_view;
}





Ex : [call any view or any controller or any where]

 call from anywhere and any module.

<?php echo module_view('module_name','view name',array('data'=>'value')); ?>


Friday, March 14, 2014

Hide the page links in the pagination in Codeigniter

Config options are set as :

 $this->load->library('pagination');
    $config['base_url']    = "/blog/index/$tid/";
    $config['total_rows']  = $num_items;
    $config['per_page']    = $max_items;
    $config['first_link']  = FALSE;
    $config['last_link']   = FALSE;
    $config['uri_segment'] = 4;
    $config['use_page_numbers'] = TRUE;
    $config['display_pages'] = TRUE;
    $config['num_links']     = 1; # this doesn't work
    $config['prev_link']     = 'Previous';
    $config['next_link']     = 'Next';
    $config['cur_tag_open']  = '';
    $config['cur_tag_close'] = '';
    $config['full_tag_open'] = '
'; $config['full_tag_close']= '
'; $this->pagination->initialize($config); $this->outputData['pagination'] = $this->pagination->create_links();

   


OUTPUT :  Prev 1 2 4 3 Next

And if I turn off display_pages I get:

OUTPUT :  Prev Next

Simply way to modify pagination like this in Codeigniter.

Monday, May 13, 2013

Uploading a csv into Codeigniter

You may get an error " the file type you are attempting to upload is not allowed " when upload csv file in codeigniter

Kindly change the array value of csv in your application/config/mimes.php

Put the follwing code

'csv'   =>  array('application/vnd.ms-excel', 'text/anytext', 'text/plain', 'text/x-comma-separated-values', 'text/comma-separated-values', 'application/octet-stream', 'application/vnd.ms-excel', 'application/x-csv', 'text/x-csv', 'text/csv', 'application/csv', 'application/excel', 'application/vnd.msexcel'),

Enjoy it ....

Saturday, May 04, 2013

Frameworks for PHP

Dwoo
Dwoo is a PHP 5 template engine positioned as an alternative to Smarty. It is (nearly) fully compatible with its templates and plug-ins, but it is being written from scratch and is aimed to go one step further with a cleaner code base.

CodeIgniter
CodeIgniter is a powerful, high-performance, open-source PHP framework that helps you author PHP applications rapidly. CodeIgniter is known for having a light footprint, thereby reducing your server’s work. 

YII Framework
Here is a high-performance component-based PHP framework that is supposed to be more efficient than CodeIgniter, CakePHP, ZF and Symfony. An optimal solution for developing large-scale Web applications. Yii supports MVC, DAO/ActiveRecord, I18N/L10N, caching, jQuery-based AJAX support, authentication and role-based access control, scaffolding, input validation, widgets, events, theming and Web services.

NetBeans
A dedicated PHP coding environment and complete integration with web standards. The NetBeans PHP editor is dynamically integrated with NetBeans HTML, JavaScript and CSS editing features such as syntax highlighting and the JavaScript debugger. NetBeans IDE 6.5 fully supports iterative development, so testing PHP projects follows the classic patterns familiar to web developers.

Solar
Solar is a PHP 5 development framework for Web applications derived from the Savant templating engine. Solar uses the MVC architectural pattern and has a host of classes and functions for securing your Web app against SQL injection, cross-website scripting (XSS) and other common exploits. 

PEAR – PHP Extension and Application Repository
PEAR is a popular framework and distribution system for reusable PHP components. The purpose of the framework is to provide a structured library of open-source code for PHP users, a system for code distribution and package maintenance and a standard style for PHP code.

Propel
Propel is an Object-Relational Mapping (ORM) framework for PHP 5. It allows you to access your database using a set of objects, providing a simple API for storing and retrieving data.

Zend Framework
The Zend Framework by Zend Technologies (the creators of PHP’s scripting engine) is a popular PHP Web application framework that embraces the principles of PHP OOP; it’s very extensible and has built-in utilities for working with free Web service APIs, such as those of Google, Flickr and Amazon.

Qcodo
Qcodo is an excellent open-source PHP Web application framework. It’s subdivided into two parts: (1) Code Generator, and (2) Qforms. Code Generator handles the creation of object code and PHP and HTML front-end code from your data model. Qforms is an intuitive system for handling and creating complex PHP-driven HTML Web forms. Check out demos of applications that use Qcodo and presentational material that covers Qcodo

SAJAX
SAJAX is a JavaScript and AJAX application framework that works well with PHP (as well as several other server-side scripting languages). See SAJAX at work by going to Wall live demonstration.

Smarty
Smarty is a popular PHP templating system to help you separate PHP logic and front-end code (HTML, CSS, JavaScript). It will keep your projects modular and easier to maintain.

CakePHP
CakePHP is one of the leading PHP frameworks for creating robust, fully-featured Web applications. CakePHP has an extensive and well-organized online manual. If you want to learn via video tutorials, check out the CakePHP screencasts.

PHPSpec
PHPSpec is a simple and intuitive PHP framework. It follows the Behavior-Driven Development principle and therefore allows you to write behavior-oriented code, oftentimes in plain English. 


Thursday, August 16, 2012

CodeIgniter - frontend language files editor

I was looking for frontend language files editor suitable for my needs. Unfortunately I failed to find a solution that suits me ( maybe type-o in keywords ;o) ). Therefore I decided to create my own piece of code.

Hence I present my little contribution to CodeIgniter.

Now you can find this project on github! :o)
Frontend Language Files Editor on github

Basic idea
  • Using Language Class my files for language are stored in /my_application_folder/language/.
  • I want edit all pairs key=>value for languages without opening my file. Add new keys which will be enable for another languages.
  • I want to create new languages, new files and copy structure of file to another language.
  • I want to delete languages or files.
  • I want to delete one key from all files and from database.
  • I want to remove keys from database for file if file does not exist in other languages.
  • I want to create backup file just in case.
 
So basically keys will be stored in database. If I add new key, save file in which I add it, and then go to edit this file in other language that new key will show up in form. But remember, new key physically will not be in another languages files until you save them.

Requirements

Codeigniter 2.x, jQuery

Installation

Grab it from github and extract to corresponding folders.

Be aware that there is application/core/My_Lang.php file, so if you use i18n for multilanguage most likely you have MY_Lang in that folder already. So be sure that you want to overwrite it.

How it works
You call it by entering address: http://yourdomainhere/language/

The list of languages are created by folder structure in /my_application_folder/language/.

The list of files are created by content in language directory. Only .php files are considered and backup files are excluded.

When you choose some file for the first time (keys are not in database) you will be asked if you want to add them.

If there are some differences between keys in file and keys in database we have two options.

1. Some keys exists in file and not in database - you will be asked if you want to add them. Until than, that keys will not be available in form. Warning! If you save your file before adding those keys, the translation and key will be erased from the file.
2. Some keys exists in database and not in the file - you will see (NEW!) next to key name. You will see that most likely when new key was added to the file in other language.

In case anything goes wrong (I hope not) I added copy function which creates backup file so you can restore last file after crash. Better be save than sorry ;o)

If you delete key from file it is also deleted from other languages and database.

All translations are escaped by addslashes php function. So if you're using $this->lang->line('key') and there was some escaping, remember to use stripslashes before you echo $this... You could also use core/My_Lang.php file which already has it. Then you don't have to worry about that.

If you have CSRF protection on - remember that it has expire time - so don't edit your files too long ;o)

I assume that if you want a line break in your translation, you need to add
tag.

This frontend already use language class. All buttons, information etc are already put into language_lang.php file so you can translate it into your language.

If you have some questions/suggestions/problems feel free to ask.


Saturday, August 11, 2012

Top 10 good PHP framework

A good PHP framework can help you develop a PHP application quickly, with more simplicity and with a vision "best-practices-oriented".

Take a look at this list with 10 great PHP frameworks and suggest that you prefer or a new link to a framework not included into this list.

1. CodeIgniter
CodeIgniter is a powerful PHP framework with a very small footprint, built for PHP coders who need a simple and elegant toolkit to create full-featured web applications.
Read more...

2. CakePHP
CakePHP is a rapid development framework for PHP that provides an extensible architecture for developing, maintaining, and deploying applications.
Read more...

3. Symfony
Symfony is a full-stack framework, a library of cohesive classes written in PHP5. It provides an architecture, components and tools for developers to build complex web applications faster. Choosing symfony allows you to release your applications earlier, host and scale them without problem, and maintain them over time with no surprise.
Read more...

4. Prado
PRADOTM is a component-based and event-driven programming framework for developing Web applications in PHP 5. PRADO stands for PHP Rapid Application Development Object-oriented.
Read more...

5. Qcodo
It is a completely object-oriented framework that takes the best of PHP and provides a truly rapid application development platform. Initial prototypes roll out in minutes instead of hours. Iterations come around in hours instead of days (or even weeks). As projects iterate into more cohesive solutions, the framework allows developers to take prototypes to the next level by providing the capability of bringing the application maturity.
Read more...

6. Zend Framework
Zend Framework is focused on building more secure, reliable, and modern Web 2.0 applications & web services, and consuming widely available APIs from leading vendors like Google, Amazon, Yahoo!, Flickr, as well as API providers and catalogers like StrikeIron and ProgrammableWeb.
Read more...

7. Akelos
The Akelos PHP Framework is a web application development platform based on the MVC (Model View Controller) design pattern. Based on good practices, it allows you to:
Write views using Ajax easily, Control requests and responses through a controller, Manage internationalized applications, Communicate models and the database using simple conventions.
Read more...

8. Maintainable
The Maintainable PHP Framework was originally built only for our own projects, then released to open source at the request of our customers. Like any framework, it's certainly not appropriate for every application. It's designed primarily for use with small- to mid- sized applications.
Read more...

9. evoCore
evoCore is the framework at the heart of the b2evolution blogging application. It is freely available for anyone to use. It is dual licensed so you can choose to use it either under the GNU GPL or the Mozilla MPL license. (b2evo for example is using it under the GPL).
Read more...

10. Stratos
The Stratos Framework is an open-source, object-oriented web application framework that facilitates the rapid development of well-organized, secure, and maintainable PHP web applications. Stratos frees you from working on tedious, routine tasks, and allows you to focus on specific software requirements.
Read more...