Welcome Guest, Not a member yet? Register   Sign In
  Include variables from a file.
Posted by: El Forum - 11-24-2008, 07:02 PM - Replies (6)

[eluser]Lazos[/eluser]
Right now I have the following array inside each of my controllers but now I decided that I want to include some more variables in the array which means that I have to edit each controller Sad.

Do you know a way that I can put this array in a file or something and include it inside each controller?

Code:
$this->headervars = array (
            'V_BREADCRUMBS'                => (isset($breadcrumbs)) ? $breadcrumbs : '',
            'V_CMS_TITLE'                => $this->siteprefs['adminsitename'],
            'V_PAGE_TITLE'                => $this->pagetitle,
            'V_MENU'                    => $topmenu,
            'L_WELCOME_USER'             => $this->lang->line('welcome'),        
            'L_ADMIN_PANEL_TITLE'        => $this->lang->line('admin_panel_title'),
            'V_ADMIN_PANEL_TITLE'         => $this->siteprefs['sitename'],
            'V_FIRST_LAST_NAME'         => $this->userdata['first_name']." ".$this->userdata['last_name']
            );


One of my Controllers:
Code:
class Tinymce extends Controller {
    var $userip;
    var $pagetitle;
    var $userdata;
    var $siteprefs;
    var $groupperms;
    var $headervars;
    var $footervars;
    var $userprefs;
    var $errormsg;
function __construct(){
        parent::Controller();
        $this->groupperms = array();
        // Header
        $this->user_ip = $this->input->ip_address();
        $this->userdata = $this->my_session->sess_read($this->user_ip, TINYMCE);
        $this->pagetitle = TINYMCE;
        $this->errormsg = '';
        if ($this->userdata['session_logged_in'] != 1) {
            redirect('/index.php/admin/login', 'location', 301);
        }
        $this->load->model('admin/header_model', 'header_model');
        $this->groupperms = $this->header_model->getAllGroupPerms($this->userdata['group_id']);
        $this->load->library('admin_theme');
        $this->load->library('admin_content');
        $this->load->library('tinymce_lib');
        $this->admin_content->initialize($this->userdata['user_id'], $this->userdata['group_id'], $this->groupperms);
        $this->siteprefs = $this->header_model->site_preferences();
        $this->tinymce_lib->setInitialValues($this->siteprefs);
        $this->admin_theme->_constructor($this->userdata['user_id'], $this->userdata['group_id']);
        $headers = $this->admin_theme->SendHeaders();
        $topmenu = $this->admin_theme->DoTopMenu();
        $this->headervars = array (
            'V_BREADCRUMBS'                => (isset($breadcrumbs)) ? $breadcrumbs : '',
            'V_CMS_TITLE'                => $this->siteprefs['adminsitename'],
            'V_PAGE_TITLE'                => $this->pagetitle,
            'V_MENU'                    => $topmenu,
            'L_WELCOME_USER'             => $this->lang->line('welcome'),        
            'L_ADMIN_PANEL_TITLE'        => $this->lang->line('admin_panel_title'),
            'V_ADMIN_PANEL_TITLE'         => $this->siteprefs['sitename'],
            'V_FIRST_LAST_NAME'         => $this->userdata['first_name']." ".$this->userdata['last_name']
            );
        $this->footervars = array (
            'V_CMS_NAME'                => $this->siteprefs['cmsname'],
            'V_CMS_VERSION'                => $this->siteprefs['cmsversion']
            );
    }
}


  Data Validation in Model
Posted by: El Forum - 11-24-2008, 05:45 PM - Replies (2)

[eluser]Teks[/eluser]
Apologies in advance for my newbie question - totally new to CodeIgniter.

In most Object-Oriented frameworks that use the MVC pattern, data validation is handled by the MODEL classes. That seems to be the logical division, as the model should be aware of what is, and isn't, permissible in its variables. A view, or a controller, would only be able to do very basic validation - ie., "is this an email address", "is this a number", etc. - but by the very definition on OO, it will be the model class that will be responsible for doing the ultimate check on the data, and making sure that it can be stored in the database. Even if we consider database operations alone - ie., referential integrity checks, etc. - there is a lot of validation that can only (and should only) be performed by the model. If the model *will* have to perform *some* data validation, then it does not seem to make much sense to put any data validation in a control class, and even less in a view class, as these then would have to be aware of the internal functioning and requirements of the model - and that breaks encapsulation, and makes it meaningless to have an OO framework in the first place.

Indeed, so far, every OO framework I've used instructs programmers to place data validation functions within the model classes.

It seems to me, however, from the information in the User Guide, and from several postings in this forum, that CodeIgniter assumes that data validation for my models should be performed by my CONTROLLER classes - using the Form Validation class. Am I wrong?

Is there an easy way to implement the data validation functions - already available in the Form Validation class - in my models?


  Caching an ACL Object
Posted by: El Forum - 11-24-2008, 04:57 PM - Replies (3)

[eluser]zackwragg[/eluser]
Hi all,

After having implemented Zend_ACL in my codeigniter application, I am looking to serialize the ACL object and cache it to cut down on the various overheads that can create as it gets bigger.

My question is, is there any benefit in using the Zend_Cache libraries to do this, over just using the PHP serialize function and using CodeIgniter's file helper to store it in a file. I can then use the CI file helpers to pull it out of the file and unserialize it.

Thanks for the help.


  Using .htaccess for dynamic subdomains
Posted by: El Forum - 11-24-2008, 03:48 PM - Replies (15)

[eluser]psdtocode[/eluser]
Hello,

I'm curious how I would setup my server to use dynamic subdomains. I have full access to http.conf, and the entire server. I want to acheive the effect of WordPress MU, if you know how that works.

The site I'm creating allows people to create blog-like sites under my parent domain, so it would be http://sample.mydomain.com/. The domain would then route to a URL such as:

Code:
http://mydomain.com/site_manager/index.php/site/view/sample

I've gotten it to be http://mydomain.com/site/view/sample (couldn't get rid of the site/view/ part) for basic testing, however I am wanting to reroute the URL's to how they would be on the live site.

Examples:
Code:
http://sample.mydomain.com/
shows what is on:
Code:
http://mydomain.com/site_manager/index.php/site/view/sample


Code:
http://sample.mydomain.com/post/123
shows what is on:
Code:
http://mydomain.com/site_manager/index.php/site/view/sample/post/123

Horrible URL structure in my opinion, but I don't know how else I could structure it.

Thanks,
Andrew


  Problems with read_file and seeing two requests
Posted by: El Forum - 11-24-2008, 03:09 PM - Replies (3)

[eluser]louis w[/eluser]
I am trying to use readfile (or CI read_file) to load an image from the server and output it to the browser. What is really strange is that if I watch my logs I see two requests happening right after each other every time it runs.

This is what I am running:

// Shows the image, but two requests show up in system logs
header('Content-type: '.$file['mime']);
readfile($load_path);

// Outputs binary data to browser
$this->output->set_header('Content-type: '.$file['mime']);
readfile($load_path);

// Doesn't work
$this->output->set_header('Content-type: '.$file['mime']);
return read_file($load_path);

Any idea what might be going on?


  regular expression help - proprtly pase full url from string
Posted by: El Forum - 11-24-2008, 02:45 PM - Replies (2)

[eluser]new_igniter[/eluser]
Hello,
Can someone share a regex that properly handles grabbing a http link from a string of text?
What I have below works, but not in all circumstances, i.e. link has ),>,:, etc on the end. So I would love to know people's experiences with this and how they solved it.

Thanks!

Code:
$regex = '/(http:\/\/[^&"\'\s]+)/i';
        if (preg_match_all($regex, $text, $matches, PREG_SET_ORDER))
        {
           $link = $matches[0][0];
        }

for CI search: regex grab url from text, grab url from string,


  constant will not echo in a function
Posted by: El Forum - 11-24-2008, 02:27 PM - Replies (7)

[eluser]paulcj2[/eluser]
Using CodeIgniter, I am building constants within a function for a navigation image. For some reason what works in one function does not work in another.

I have defined two constants: one for a logo image to display in a banner and one for a navigation image to display just below the banner.

Code:
function fetch_site_constants() {

            $sql_cnst = "SELECT
                        *
                    FROM
                        website
                    WHERE
                        site_id=?
                        ";

            $rs_cnst = $this->db->query($sql_cnst, array(SITE_ID));

            foreach ($rs_cnst->result() as $row) {
            define('SITE_LOGO_ID', $row->site_logo_id);
            define('NAV_IMG_ID', $row->nav_img_id);
                   }
               }//end function
Using the constant SITE_LOGO_ID, I fetch the logo/banner/branding image
information
Code:
function fetch_logo_image() {
            $sql_logo = "SELECT
                    image_filename,
                    image_caption
                FROM
                    image_library
                WHERE
                    image_id=?";

        echo "SITE_LOGO_ID 2= " . SITE_LOGO_ID . "<br>";
            $rs_logo = $this->db->query($sql_logo, array(SITE_LOGO_ID));
                    
                foreach ($rs_logo->result() as $row) {
            define('LOGO_FILENAME', $row->image_filename);
            define('LOGO_CAPTION', $row->image_caption);
            }
            
            echo "<p>LOGO_FILENAME:" .LOGO_FILENAME. "<br />";
            echo "LOGO_CAPTION:" .LOGO_CAPTION. "</p>";
    
    }//end function
Yet using exactly the same kind of routine, I can't get the constant NAV_IMG_ID to fetch the navigation image information
Code:
function fetch_nav_image() {
            $sql_nav_img = "SELECT
                    image_filename,
                    image_caption
                FROM
                    image_library
                WHERE
                    image_id=?";

        echo "NAV_IMG_ID 2= " . NAV_IMG_ID . "<br>";
            $rs_nav_img = $this->db->query($sql_nav_img, array(NAV_IMG_ID));
                    
                foreach ($rs_nav_img->result() as $row) {
            define('NAV_IMG_FILENAME', $row->image_filename);
            define('NAV_IMG_CAPTION', $row->image_caption);
            }
            
            echo "<p>NAV_IMG_FILENAME:" .NAV_IMG_FILENAME. "<br />";
            echo "NAV_IMG_CAPTION:" .NAV_IMG_CAPTION. "</p>";
    
    }//end function
I can't even echo the query within function fetch_nav_image(). What’s really strange is that I have no such problems with SITE_LOGO_ID., as you can see from the test echo statements and the way the site logo works in the header banner. What am I missing?
http://clickbasicsdemo.com/index.php


  Unique URL Part
Posted by: El Forum - 11-24-2008, 02:06 PM - Replies (2)

[eluser]freshface[/eluser]
For an application I need a unqiue key to view something.
But it also need to be 'safe', maybe sha encrypted?

ex: ww.url.ltd/uniquekey

But what is the best way to create such an unique key?


  Resizing Images
Posted by: El Forum - 11-24-2008, 01:59 PM - No Replies

[eluser]louis w[/eluser]
Is it possible to resize AND crop with the same request?

I am passing in these configuration values:

[width] => 200
[height] => 200
[x_axis] => -150
[y_axis] => 0


I am calculating the x axis myself given the size of the image, and the size I would like to output. The intention is that it would resize the image to fit the size I specify and crop off the ends that hang off. That way I can resize to an exact dimension an not have empty space.

Does not seem to work thou.


  [SOLVED] AJAX + force_download
Posted by: El Forum - 11-24-2008, 01:21 PM - Replies (4)

[eluser]PV-Patrick[/eluser]
I am trying to get the force_download function to work with AJAX, or even just with direct headers and I am unable to get it to work. The force_download works fine without using AJAX request.

Does anyone have any advice on how to go about using AJAX for a forced download? I have seen a couple topics but am unable to get anything working, thanks!


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

Username
  

Password
  





Latest Threads
Get date from datetime fi...
by Bosborne
1 hour ago
Protect certain pages in ...
by frocco
5 hours ago
Gateway time out CI 4.4.1
by adleon73
5 hours ago
v4.3.5 security fix relea...
by yenprima28
7 hours ago
Reading a session variabl...
by Bosborne
8 hours ago
CI NEEDS A PROPER DOCUMEN...
by Bosborne
8 hours ago
Optimize.php make a probl...
by ALTITUDE_DEV
9 hours ago
Trying to remove index.ph...
by kabeza
Today, 04:13 AM
CodeIgniter 3 to 4 migrat...
by kenjis
Today, 02:15 AM
Background image does not...
by ozornick
Today, 12:49 AM

Forum Statistics
» Members: 86,874
» Latest member: mapkeepshake
» Forum threads: 77,627
» Forum posts: 376,235

Full Statistics

Search Forums

(Advanced Search)


Theme © iAndrew 2016 - Forum software by © MyBB