Welcome Guest, Not a member yet? Register   Sign In
  Problem with library - problem with extending base class maybe?
Posted by: El Forum - 09-06-2007, 10:46 AM - No Replies

[eluser]LeePR[/eluser]
I'm having a little problem with a custom library. I have a StateCollection class that extends a Collection class. When I load the StateCollection library, the code in the constructor executes, but when I try to call one of the methods (inherited from Collection), I get an error:

Quote:Severity: Notice
Message: Undefined property: CI_Loader::$statecollection
Filename: views/stateList.php
Line Number: 3

Is the code in my Collection/StateCollection class at fault? Here's the code...

Collection (library):
Code:
<?php

    if (!defined('BASEPATH')) exit('No direct script access allowed');
    
    class Collection {
        public $arrCollection = array();
        public $CI;
        
        public function __construct() {
            // Empty constructor.
        }
        
        public function Collection() {
            $this->__construct();
        }
        
        public function hasNext() {
            // Later.
        }
        
        public function getNext() {
            // Later.
        }
        
        public function getCollection() {
            return $this->arrCollection;
        }
        
        public function add($object) {
            $arrCollection[] = $object;
        }
    }
?>
StateCollection (library):
Code:
<?php

    if (!defined('BASEPATH')) exit('No direct script access allowed');
    
    require_once('Collection.php');
    require_once('State.php');
    
    class StateCollection extends Collection {
    
        public function __construct() {
            parent::__construct();
            $this->CI =& get_instance();
            $this->populate();
        }
        
        public function Collection() {
            $this->__construct();
        }
        
        public function populate() {
            $this->CI->load->database();
            $sql = "SELECT lst_id, lst_code, lst_name " .
                "FROM rsfs_lookup_state";
            $query = $this->CI->db->query($sql);
            
            foreach ($query->result() as $row) {
                $collection[] = new State($row->lst_id);
            }
        }
    }
?>
stateList (view):
Code:
<?php
    $this->load->library('StateCollection');
    $states = $this->statecollection->getCollection(); // Undefined property: CI_Loader::$statecollection
?>
Can anyone offer some guidance?

Cheers,
LeePR


  GeoIP Lookup Plugin
Posted by: El Forum - 09-06-2007, 09:26 AM - No Replies

[eluser]ptrippett[/eluser]
Hi,

Here is a GeoIP plugin for CI. The import does hang until complete but i wanted to keep it as a plugin rather than making a Ajax frontend and making possible integration a nightmare.

Instructions are below and the code can be downloaded from http://code.google.com/p/ci-geoip/

Any questions or comments please post to this thread.

Code:
/*
     * GeoIP Plugin for CodeIgniter/Blueflame - Version 1
     * Writted By Paul Trippett (ptrippett_at_gmail.com)
     *
     * To use this plugin you must create a table in your database with
     * the following schema: -
     *
     * CREATE TABLE  `geoip` (
     *   `id` int(10) unsigned NOT NULL auto_increment,
     *   `ip_start` varchar(15) NOT NULL,
     *   `ip_end` varchar(15) NOT NULL,
     *   `ipnum_start` float NOT NULL,
     *   `ipnum_end` float NOT NULL,
     *   `country_code` char(2) NOT NULL,
     *   PRIMARY KEY  (`id`),
     *   KEY `geoip_lookup` USING BTREE (`ipnum_start`,`ipnum_end`)
     * ) ENGINE=InnoDB DEFAULT CHARSET=latin1;
     *
     *
     * Place this file in your application/plugins/ directory and download the
     * following files in to the {ci_root}/updates/geoip/ directory.
     *
     *      ftp://ftp.afrinic.net/pub/stats/afrinic/delegated-afrinic-latest
     *      ftp://ftp.apnic.net/pub/stats/apnic/delegated-apnic-latest
     *      ftp://ftp.arin.net/pub/stats/arin/delegated-arin-latest
     *      ftp://ftp.lacnic.net/pub/stats/lacnic/delegated-lacnic-latest
     *      ftp://ftp.ripe.net/ripe/stats/delegated-ripencc-latest
     *      ftp://ftp.apnic.net/pub/stats/iana/delegated-iana-latest
     *
     * You should then be able to use the following code in your controller: -
     *
     *      Import:
     *      $this->load->plugin('geoip');
     *      geoip_update();
     *
     *      Country Lookups:
     *      $this->load->plugin('geoip');
     *      geoip_lookup('xxx.xxx.xxx.xxx');
     *
     * geoip_update() needs only to be called _once_ after you update the files
     * from the RIR FTP sites.
     *
     * Should you wish to place the files in a different directory or use a
     * different table name you can put the following code in your
     * /application/config/config.php file: -
     *
     *      define('GEOIP_TABLENAME', 'geoip');
     *      define('GEOIP_FILESOURCE', 'updates/geoip/');
     *
     */

UPDATED:
Sorry my ex employer deleted the code Sad Better late than never but the code is now hosted at Google Code. The original link in this post has been updated.


  Need CSV/Excel support chinese characters input&ouput;
Posted by: El Forum - 09-06-2007, 09:24 AM - No Replies

[eluser]whidbey[/eluser]
has anybody made it?
share,pls,thx


  thumb quality sucks
Posted by: El Forum - 09-06-2007, 09:10 AM - No Replies

[eluser]iniweb[/eluser]
My config:

Code:
$config['image_library'] = 'GD';
$config['create_thumb'] = TRUE;
$config['maintain_ratio'] = FALSE;
$config['width'] = '100';
$config['height'] = '100';
$config['quality'] = '100%';
$config['thumb_marker'] = '_thumb';

Source pic: iniweb.ru/my_pc_2_original.jpg
Thumb pic: http://iniweb.ru/my_pc_2_original_thumb.jpg

How up quality?

P.S. English bad, sorry Smile


  Routes Questions
Posted by: El Forum - 09-06-2007, 08:40 AM - No Replies

[eluser]Unknown[/eluser]
I setup a route for our admin views:
$route['admin/([a-z]+)/([a-z]+)'] = "$1/admin_$2";

Basically this would route something like admin/blog/edit to blog/admin_edit in our blog controller.

However, is there a way that I can do this so that I don't have to pass the index function name in the url? So that admin/blog/ would auto go to blog/admin_index ?

- Andy


  Page views counter + caching?
Posted by: El Forum - 09-06-2007, 07:23 AM - No Replies

[eluser]#1313[/eluser]
I want to count how many times each of my pages are loaded and also want to use caching. I didn't dig deeply into CI caching mechanisms and i don't know exactly how they are working, so i need an advice. Where is the best place in the code for my counter incrementing routines? I want to avoid situations when a page is loaded from cache and counter isn't triggered.

And second question in this topic: what should i do if i want to additionally display the number of page views on the page (i.e. "This page was viewed 123 times")? I read in the guide that some info such as benchmarking does not cache — how can i mimic this behavior?

Thanks in advance.


  htmldoc is corrupty! why?
Posted by: El Forum - 09-06-2007, 07:06 AM - No Replies

[eluser]andregufc[/eluser]
i use htmldoc to generate my pdf files. i installed the package, but the pdf docs is corrupts. why?


  Automatic Requirements Gatherer
Posted by: El Forum - 09-06-2007, 07:05 AM - No Replies

[eluser]Unknown[/eluser]
Hi all,

Just discovered CodeIgniter and started to redo one of my sites using it, and I am already mighty impressed. I think within a month I will be nothing short of fanatical =)

While this post isn't actually about codeigniter, I noticed this community seems to be pretty active and friendly, so I was hoping I would share my ideas for a project I just started, and see if anyone has any feedback.

The project is for my undergraduate thesis in software engineering and I have decided to make an interview program.

The point of it would be to ask a client questions, and the output of which is both a formal requirements document (can subsequently be used to generate templates, quotes, estimate project length, etc.) and a transcript that includes their justifications and such - that the developer (ie. you) can read to get an understanding of their technical knowledge, expectations, etc.

Technically, I will deliver it using: HTML for the interface, AJAX for the communications, PHP for all the logic and XML for storing requirements, questions, etc.

I only started a few weeks ago, so it is obviously still in it's infant stages, but I am interested to hear what some other developers think of the idea. If it worked well, would you have your clients use it before your first meetings to discuss the scope of the project?

You can find a lot more detailed research and general fluff (along with a very basic prototype that has a whopping 4 questions in it's knowledgebase) at the following site for anyone who is interested:

http://www.designconcepts.com.au/thesis/

Thanks in advance to anyone who has feedback. I have spoken with some academics and some management types about it, but very few actual programmers.

Cheers,

Simon


  Using query strings normally
Posted by: El Forum - 09-06-2007, 06:46 AM - No Replies

[eluser]Paul Scott[/eluser]
I found myself wanting to be able to specify a variable through GET as-well as through CI's ability to parse the / into parameters of the called function. I was wanting to do this because I was passing a site-wide parameter (it was checked for no matter what page you were on) and I didn't want to have to add the parameter to every function - especially not when some functions had optional parameters.

I found, to my dismay, that trying to go to a url like /admin/main/index?msg=Something returned a 404. A little inspection found that CI was trying to find the controller and function specified by 'msg'.

To fix this, I opened ./system/libraries/Router.php and in the function `_get_uri_string` there is a section that checks if there is only 1 GET variable and uses the name of it to find the controller.

Code:
// If the URL has a question mark then it's simplest to just
// build the URI string from the zero index of the $_GET array.
// This avoids having to deal with $_SERVER variables, which
// can be unreliable in some environments
if (is_array($_GET) AND count($_GET) == 1)
{
    // Note: Due to a bug in current() that affects some versions
    // of PHP we can not pass function call directly into it
    $keys = array_keys($_GET);
    return current($keys);
}
This is the code block that did it within the `_get_uri_string` function. To counter-act this, I simply changed the if-statement to read
Code:
if (FALSE AND is_array($_GET) AND count($_GET) == 1)
Then I needed to stop the GET variable from being destroyed by CI and stop CI trying to take the controller and function from the `c` and `m` $_GET variables by default:
Code:
$config['enable_query_strings'] = TRUE;
$config['controller_trigger'] = '';
$config['function_trigger'] = '';

Now I can use URIs like /admin/clients/view/613?msg=updated with my header-template checking for $_GET['msg'] and out-puting it on any page that it's found on.

I thought I would post this because somebody else might have this problem and was wondering why this is the default behaviour? Also, is there a reason why this might have been a bad idea?

Thanks


  Upload class problem
Posted by: El Forum - 09-06-2007, 01:40 AM - No Replies

[eluser]emperius[/eluser]
I need to upload few files at the same time.

I made an arrray of input elements

Code:
<table width="700" border="0" cellpadding="5">
    &lt;?
        for($i=0;$i<5;$i++)
        {
            echo "<tr>";
                echo "<td width=\"200\">Фото ".($i+1)."</td>";
                echo "<td width=\"500\">&lt;input type=\"file\" size=\"50%\" name=\"f[$i]\"&gt;</td>";
            echo "</tr>";
        }
    ?&gt;
    <tr>
      <td>&lt;input type="submit"&gt;</td>
      <td>&nbsp;</td>
    </tr>    
  </table>

and in the controller I check if field is not empty and try to upload file.

Code:
if(!empty($_FILES['f']))
{
    $farr = $_FILES['f'];
    for($i=0;$i<count($farr['name']);$i++)
    {
        if($farr['name'][$i] != "")
        {
            $field = "f[$i]";
                
            $config['upload_path'] = realpath('public/object');
            $config['allowed_types'] = 'jpg';
            $this->load->library('upload', $config);
                    
            $this->upload->do_upload($field);
            $resarr = $this->upload->data();
            
            $file = $resarr['file_name'];
                    
            $this->upload->display_errors('<p>', '</p>');
            $this->upload->data();
              }
    }
}

the permission for folder is set 777

and i don't get errors and data about successfull file upload Sad

What I'm doing wrong?


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

Username
  

Password
  





Latest Threads
Any user guid or video o...
by msnisha
3 hours ago
MVC vs MVCS vs CodeIgnite...
by massimiliano1.mancini
7 hours ago
Why PHP is still worth le...
by php_rocs
Today, 05:13 AM
Is hiring a digital marke...
by Markhenry123
Today, 02:45 AM
my controller fails to fi...
by PaulC
Today, 01:40 AM
My Library cannot see ses...
by InsiteFX
Yesterday, 08:48 PM
update the framework to t...
by captain-sensible
Yesterday, 12:14 PM
CodeIgniter Shield 1.0.0 ...
by Ayatorvi
Yesterday, 06:06 AM
Update to 4.6.1
by serialkiller
05-07-2025, 11:58 AM
Can't create new database...
by paulbalandan
05-07-2025, 08:49 AM

Forum Statistics
» Members: 144,977
» Latest member: gnexterior
» Forum threads: 78,382
» Forum posts: 379,420

Full Statistics

Search Forums

(Advanced Search)


Theme © iAndrew 2016 - Forum software by © MyBB