Bin will be removed on June 1, 2014 in favor of http://gist.github.com. Please save all your pastes before then. So long, and thanks for all the fish!×
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
 
 
/*  this is in app_controller.php */
    function templateInclude($files)
    {  
       
        if (!is_array($files))
        {
            $files = array($files);
        }
 
        foreach ($files as $file)
        {
            //check what kind of file this is
            $type = explode('.',$file);
           
            if (count($type) <2)    //needs an extention
            {
                return false;
            }
            else
            {
                switch ($type[count($type)-1])  //check if it's a known type and assign the right global name
                {
                    case 'js': $this->js_files[$file]=$file;
                    break;
                    case 'css': $this->css_files[$file]=$file;
                    break;
                    default:
                    $this->set("INCLUDE_ERROR",$file);
                    return false;  //unknown type
                    break;
                }
            }
       
        }
    }
   
    private function lockIncludes()
    {
        if ($this->include_lock)
        {
            return false; //includes already locked
        }
       
        $this->set('CSS_FILES',$this->css_files);
        $this->set('JS_FILES',$this->js_files);
        $this->include_lock = true;
        return true;
    }
 
/* end app_controller.  remember to call lockIncludes()from beforeRender() */
 
/* in layout... probably should make this an element*/
foreach($CSS_FILES as $file)
{
    echo '@import "http://naskb/pulse/css/'.$file.'";';
}
 
if (isset($INCLUDE_ERRORS))
{
    echo '<!-- include error '.$INCLUDE_ERRORS." -->\n";
}
 
echo '</style>';
 
 
foreach($JS_FILES as $file)
{
    echo '<script type="text/javascript" src="http://naskb/pulse/js/'.$file.'"></script>';
}