Changeset 12332

Show
Ignore:
Timestamp:
09/17/07 17:13:47 (1 year ago)
Author:
bergie
Message:

Helper for displaying user-uploaded CSS files of a style. Makes it very easy to customize CSS using the Style Editor for shared templates

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/midcom/midcom.core/midcom/helper/_styleloader.php

    r12175 r12332  
    771771        return true; 
    772772    } 
    773  
     773     
     774    /** 
     775     * Include all text/css attachments of current style to MidCOM headers 
     776     */ 
     777    function add_database_head_elements() 
     778    { 
     779        static $called = false; 
     780        if ($called) 
     781        { 
     782            return; 
     783        } 
     784        $style = new midcom_db_style($_MIDGARD['style']); 
     785        $mc = midcom_baseclasses_database_attachment::new_collector('parentguid', $style->guid); 
     786        $mc->add_constraint('mimetype', '=', 'text/css'); 
     787        $mc->add_value_property('name'); 
     788        $mc->execute(); 
     789        $attachments = $mc->list_keys(); 
     790         
     791        foreach ($attachments as $guid => $values) 
     792        { 
     793            // TODO: Support media types 
     794            $filename = $mc->get_subkey($guid, 'name'); 
     795            $_MIDCOM->add_link_head 
     796            ( 
     797                array 
     798                ( 
     799                    'rel' => 'stylesheet', 
     800                    'type' => 'text/css', 
     801                    'href' => "{$_MIDGARD['self']}midcom-serveattachment-{$guid}/{$filename}", 
     802                ) 
     803            ); 
     804        } 
     805 
     806        $called = true; 
     807    } 
    774808} 
    775809