Welcome, Guest
You have to register before you can post on our site.

Username/Email:
  

Password
  





Search Forums

(Advanced Search)

Forum Statistics
» Members: 11,561
» Latest member: scriptman
» Forum threads: 67,949
» Forum posts: 424,235

Full Statistics

Latest Threads
How to correctly update b...
Forum: General Help
1 hour ago
» Replies: 0   » Views: 8
Encryption Observation
Forum: General Help
1 hour ago
» Replies: 7   » Views: 263
500 Internal Server Error
Forum: Installation & Setup
2 hours ago
» Replies: 12   » Views: 6,374
question : SaaS style URL...
Forum: CodeIgniter 4 Support
3 hours ago
» Replies: 6   » Views: 169
dropdown list clears afte...
Forum: General Help
5 hours ago
» Replies: 1   » Views: 63
Create a Full Featured Re...
Forum: Model-View-Controller
5 hours ago
» Replies: 0   » Views: 4
Database Connection Probl...
Forum: Installation & Setup
Yesterday, 04:51 AM
» Replies: 2   » Views: 90
Undefined offset: 0
Forum: General Help
Yesterday, 04:07 AM
» Replies: 1   » Views: 81
CodeIgniter 3.1.9 release...
Forum: News & Discussion
Yesterday, 02:23 AM
» Replies: 22   » Views: 6,909
Aerospike Cache Driver Re...
Forum: CodeIgniter 4 Discussion
06-22-2018, 05:18 PM
» Replies: 0   » Views: 66

 
  Image manipulation bug
Posted by: El Forum - 08-14-2007, 10:38 AM - Forum: Archived Development & Programming - Replies (3)

[eluser]EugeneS[/eluser]
ok here is code i use:

Code:
$this->load->library('image_lib');

                // START Image resizing
                $config['source_image'] = $this->dir_to_upload.$this->file_name;
                $config['quality'] = '100%';
                $config['width'] = '80';
                $config['height'] = '80';
                $config['create_thumb'] = true;
                // END Image resizing
                $this->image_lib->initialize($config);

                $this->image_lib->resize();

                // START watermarking the image
                $config['source_image'] = $this->dir_to_upload.$this->file_name;
                $config['create_thumb'] = false;
                $config['wm_type'] = 'overlay';
                $config['wm_overlay_path'] = $this->dir_to_upload.'../watermark.gif';
                $config['wm_vrt_alignment'] = 'bottom';
                $config['wm_hor_alignment'] = 'right';
                // END watermarking the image

                $this->image_lib->initialize($config);

                $this->image_lib->watermark();


without $config['create_thumb'] = false; in the watermarking config it:
1) removes previously created thumb
2) it keep initial big image NOT watermarked
3) it creates fullsize image with the postfix _thumb and watermark it

it seems to me that Initialize method do not reset some internal variables inside the class after the previous operation.

PS: it doesnt matter if for watermarking i rename $config to $config_wm (i just expect this proposal from you guys Smile )


first my try was (and supposed to work correct but it doesnt)
Code:
$this->load->library('image_lib');

                // START Image resizing
                $config['source_image'] = $this->dir_to_upload.$this->file_name;
                $config['quality'] = '100%';
                $config['width'] = '80';
                $config['height'] = '80';
                $config['create_thumb'] = true;
                // END Image resizing

                // START watermarking the image
                $config['wm_type'] = 'overlay';
                $config['wm_overlay_path'] = $this->dir_to_upload.'../watermark.gif';
                $config['wm_vrt_alignment'] = 'bottom';
                $config['wm_hor_alignment'] = 'right';
                // END watermarking the image

                $this->image_lib->initialize($config);

                $this->image_lib->resize();

                $this->image_lib->watermark();


  Redirect in constructor: good practice?
Posted by: El Forum - 08-14-2007, 10:32 AM - Forum: Archived Development & Programming - Replies (10)

[eluser]codex[/eluser]
If a user is not logged I want to restrict access to specific parts of a website. Is this the way to do it? I mean put the redirect in the constructor.

Code:
function Home()
    {
        parent::Controller();
        
        if (!$this->session->userdata('uid')) {
            redirect('/test/');
        }    
    }


  DB cashing bug
Posted by: El Forum - 08-14-2007, 09:46 AM - Forum: Archived Development & Programming - Replies (2)

[eluser]EugeneS[/eluser]
it seems to me like a bug.

query cash files are created.

but when i change data in database and refresh the page this page shows me updated data instead of cashed results from the cash files.

so it seems to me even when cashing enabled and cash files were created CI any way ask database for data instead of cash files :\


  Display results of db query with only one result
Posted by: El Forum - 08-14-2007, 09:36 AM - Forum: Archived Development & Programming - Replies (9)

[eluser]mb2007[/eluser]
Hello,

often I just request for one special database entry, so I use LIMIT 1. But the result with the CI function is a object so I use a foreach loop to display it. Is there a better way to access the array?

Code:
$this->db->select('some_row');
$this->db->where('some_other_row',$some_other_row_value);
$this->db->limit(1);
$query = $this->db->get('table');

foreach($query->result() as $row):
    echo $row->some_row;
endforeach;


  how to get database 'active_group' value in a controller?
Posted by: El Forum - 08-14-2007, 08:50 AM - Forum: Archived Development & Programming - Replies (1)

[eluser]litzinger[/eluser]
How do I get the value of the 'active_group' variable in the database.php file in a controller? I need to turn off certain functionality of my site if I'm in the development environment.


  Blueprint Class library release
Posted by: El Forum - 08-14-2007, 08:31 AM - Forum: Archived General Discussion - No Replies

[eluser]Jamongkad[/eluser]
Hi all I figured I've leeched enough from this community, so as a token of thanks to the wonderful and patient denizens of CI forums I would like to submit my very first library!

Recently I pounced upon the Blueprint CSS framework. And I must say it's quite good! so I decided to make a library for Code Igniter. I personally use this as a means of rapid development. I know it's far from finished but I will try my best to stick close and churn out updates.

I based the code off of some research from the Jquery.php class library thank you to cvfoss for giving me a template to work from...

Ok here we go before anything please make a css folder in your application directory. So that you got a placed to drop the Blueprint folder in. If there are any corrections please let me know!

Blueprint.php <-----This goes to the library.

Code:
&lt;?php  if (!defined('BASEPATH')) exit('No direct script access allowed');

class Blueprint {

    var $externalBlueprint='';

    var $externalStyle=array();
    
    //php4 constructor points to php5 constructor
    function Blueprint()
    {
         $this->__constructor();
    }
    //php5 constructor
    function __constructor()
    {}
    
    //set the url of Blueprint //
    function injectBlueprint($url)
    {
         $this->externalBlueprint = $url;
    }
    //add external style like &lt;style type="text/css" media="screen"&gt;@import url('style.css');&lt;/style&gt;, loads into an array to be looped in the final blueprint process
    function injectExternalStyle($url)
    {
        $this->externalStyle[]='&lt;style type="text/css" media="screen"" &gt;'.'@import url("'.$url.'");'.'&lt;/style&gt;';
        return true;
    }
    
    ///outputs the entire Blueprint stuff, including the externally loaded scripts.
    function igniteBlueprint()
    {
     $result= '&lt;link rel="stylesheet" type="text/css" media="screen, projection" href="'.$this-&gt;externalBlueprint.'">';
        
        foreach($this->externalStyle as $externalStyles){
            $result.=$externalStyles;
        }
        
        return $result;
    }
    
}

?&gt;

controller
Code:
&lt;?php

class Home extends Controller {

    function Home()
    {
     parent::Controller();    
     $this->load->library('blueprint');
    }
    
    function index()
    {
     //testing out the excellent Blueprint library!
      
     //this loads the screen.css indicate where the css/blueprint directory is placed in.    
     $this->blueprint->injectBlueprint('css/blueprint/screen.css');

     //this loads the print.css indicate where the css/blueprint directory is placed in.
     $this->blueprint->injectExternalStyle('css/blueprint/print.css');
    
     //this fires up the library to be thrown into the view
     $data['css'] = $this->blueprint->igniteBlueprint();
    
     $this->load->view('my_view.php',$data);
    }
}
?&gt;

view
my_view.php
Code:
&lt;html&gt;
&lt;head&gt;
&lt;title&gt;My View&lt;/title&gt;

//Echo the $css variable.
&lt;?php if(isset($css)) echo $css; ?&gt;

&lt;/head&gt;
&lt;body&gt;
  <p>I love Code Igniter!</p>
  <p>Jamongkad</p>


&lt;/body&gt;
&lt;/html&gt;


  Auth library breaking MVC?
Posted by: El Forum - 08-14-2007, 07:51 AM - Forum: Archived General Discussion - No Replies

[eluser]gon[/eluser]
Hi everyone,

I've developed a small Auth library.

I want the login form to appear in lots of pages, and that the messages (incorrect login, etc.) appear near the form, and in the same page where the user was.

So I've placed the Auth code in a library.
I load it in my controller constructors, and the library checks sessions, and, if POST fields are sent, proceed to login, logout, or whatever.

In the controller actions I use the Auth object for getting the login state, and the login forms (which will include validation info if it has been set by the Auth object).


When the login is correct, the Auth object performs a redirection on the same page.

The object must take actions depending on which params are set in the POST array.


This works OK, and I was thinking on implementing it as a Hook.

I am working against the rules, or best practices of CI?

TIA.


  Pre-populated inputs and validation
Posted by: El Forum - 08-14-2007, 07:32 AM - Forum: Archived Development & Programming - Replies (10)

[eluser]codex[/eluser]
Hi,

I'm not sure how to implement this, so I could use a bit of advice. I have an 'edit profile' form which is prepopulated with the user's data. Some fields can't be left empty so his needs to be validated. For instance, a user can edit his name, but he can't completely erase it.

To validate I have to populate the input value like so (it's based on an own helper function, last option is 'value'):

Code:
&lt;?php echo input_text("user_name", 20, "input_text", $this->validation->user_name)?&gt;

But this way I can't populate the initial value with '$query[0]->user_name'. What can I do?

I thought of this:

Code:
&lt;?php
if (!$this->input->post('user_name')) {
$name = $query[0]->user_first_name }
else { $name = $this->validation->user_name
}
echo input_text("user_first_name", 20, "input_text", $name)?&gt;

But then I get an 'undefined variable' error. And something tells me I'm not thinking correctly ;-)


  Working with forms: best practice
Posted by: El Forum - 08-14-2007, 06:55 AM - Forum: Archived Development & Programming - Replies (4)

[eluser]Carlton[/eluser]
Hey,

I have managed to create a very basic search form using the form helper very easily, it's nice and quick thanks to the docs and pretty flexible to do most things I need so far.

I have something that is bugging me and not totally sure if I am using forms in the intended way, I mean it works but not sure if it the done way of doing things. I think the documentation is great explain how to display a form but I couldn't find any recommendedations on HOW to use them...i.e. post and process results. I will gladly contribute if the method I have outlined below is correct because it sure is basic Smile

I have put together a quick example, to summarize, my controller index simply displays a form...which when submitted calls the search function. Am I right in using a function to process my data and check the request before redirecting to another controller function with the query in the URL to process the request?

So when I submit my form I might get redirected to...

Code:
http://localhost/index.php/search/nike

Which might display a set of search results, based on my parameter (nike), from a DB in a table perhaps...this seems clean to me, and the URLs seem to make sense from an SEO point of view...do any other users have any feedback on this approach?

Code:
&lt;?php

class Test extends Controller {

    function Test ()
    {
        parent::Controller();
    }

    function index ()
    {
        // Load the form helper
        $this->load->helper('form');
        
        // Open a form using the helper
        $data['content'] = form_open('test/search1');
            
            // No helper for a form label????????
        $data['content'] .= '<label for="customer">Enter text</label>';
        $data['content'] .= form_input(array('id'=>'customer', 'name'=>'customer'), 'search text');
        $data['content'] .= form_submit('submit', 'search');
        //$this->load->view('common/master_view', $data);
        // For simplicity just output the form here, would normally pass to view
        echo $data['content'];
    }

    function search1 ()
    {
        // Use the 'name' attribute from our form display what the search text
        echo $_REQUEST['customer'];
        
        // Perform some sort of checks on search string
        if (isset($_REQUEST['customer'])) {
            // Redirect to a controller to do the search
            redirect('search/' . $_REQUEST['customer']);
        } else {
            redirect('someerror_view');
        }
    }

}

?&gt;


  Observe "Events"
Posted by: El Forum - 08-14-2007, 06:10 AM - Forum: Archived General Discussion - Replies (9)

[eluser]IkeE65[/eluser]
Hi everybody,

I'm currently looking for a php-based framework to use for a relatively complex application.
The frontend will be based on ExtJS and a lot of people over at the forums at extjs.com prefer codeignitor, so here I am ;-)

One important question:
Is it possible to get something like observing events to work? I found some topics here in the forums, with talking about observer patterns, active records, event listeners, joomla framework-beta-stuff and so on, but I didn't really get behind it.

What I want to do:
I want to build a some kind of modular CRM (Customer Relationsship Management). So I have customers and some lets call them "modules", like the customerlist itself, a calendar, a todo list or for example an email client. If the client who hopefully is using the crm some day, there will be a bunch of modules extending this functionality.
So, when adding a new module, for example some kind of document management, i don't want to have to change anything inside the customer management module, where i add/edit/delete customers. But for example if i delete a customer, the customers documents have to be deleted too.
In short, when "firing" the "onCustomerDelete"-Event from the customer management module, some corresponding callback action has to be called inside any module which wants something to be done or better has registered this action, when a customer is deleted.

Is this possible with codeigniter and some coding? Or are there some basic traps, which deny such things?

Greets in advance

Ike

(Sorry for maybe bad english ;-))



  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2018 MyBB Group.