subsite::get_theme_subsites (public)

 subsite::get_theme_subsites -theme theme [ -subsite_id subsite_id ] \
    [ -unmodified ]

Defined in packages/acs-subsite/tcl/subsite-procs.tcl

Returns a list of all packages implementing subsite that are currently using specified theme. Optionally, returns a list of just those that were not locally modified.

Switches:
-theme
(required)
theme key to lookup for.
-subsite_id
(optional)
narrow search to this subsite only. Useful to check whether a single subsite is using a theme with or without local modifications.
-unmodified
(boolean) (optional)
decides whether we include subsites which theme was locally modified.
Returns:
list of subsite_id

Partial Call Graph (max 5 caller/called nodes):
%3 test_subsite_api subsite_api (test acs-subsite) subsite::get_theme_subsites subsite::get_theme_subsites test_subsite_api->subsite::get_theme_subsites db_0or1row db_0or1row (public) subsite::get_theme_subsites->db_0or1row db_list db_list (public) subsite::get_theme_subsites->db_list parameter::get parameter::get (public) subsite::get_theme_subsites->parameter::get subsite::package_keys subsite::package_keys (public) subsite::get_theme_subsites->subsite::package_keys packages/acs-subsite/www/admin/themes/index.tcl packages/acs-subsite/ www/admin/themes/index.tcl packages/acs-subsite/www/admin/themes/index.tcl->subsite::get_theme_subsites subsite::refresh_theme_subsites subsite::refresh_theme_subsites (public) subsite::refresh_theme_subsites->subsite::get_theme_subsites

Testcases:
subsite_api
Source code:
    # Retrieve subsites using this theme
    set subsites [db_list get_theme_subsites [subst {
        select package_id from apm_parameter_values
        where parameter_id = (select parameter_id from apm_parameters
                              where package_key in ([ns_dbquotelist [subsite::package_keys]])
                              and parameter_name = 'ThemeKey')
        and attr_value = :theme
        and (:subsite_id is null or package_id = :subsite_id)
    }]]
    if {!$unmodified_p} {
        # User wants to get all of them. The end.
        return $subsites
    }

    # User wants also to filter by those using vanilla theme
    # parameters...

    # ...retrieve theme parameters
    if {![db_0or1row get_theme {
        select * from subsite_themes
        where key = :theme
    }]} {
        error "Theme '$theme' not found"
    }

    # ...map table columns with subsite parameters...
    set settings {
        template             DefaultMaster
        css                  ThemeCSS
        js                   ThemeJS
        form_template        DefaultFormStyle
        list_template        DefaultListStyle
        list_filter_template DefaultListFilterStyle
        dimensional_template DefaultDimensionalStyle
        resource_dir         ResourceDir
        streaming_head       StreamingHead
    }

    # ...foreach subsite...
    set theme_subsites [list]
    foreach subsite_id $subsites {
        set collect_p true
        # ...compare parameter value with vanilla theme value.
        foreach {var param} $settings {
            set default [string trim [set $var]]
            set value   [string trim [parameter::get -parameter $param -package_id $subsite_id]]
            #
            # Normalize whitespace to one single space.
            #
            regsub -all -- {\s+} $value { } value
            regsub -all -- {\s+} $default { } default
            set collect_p [expr {$default eq $value}]
            if {!$collect_p} {
                ns_log notice "theme '$theme' parameter $var differs on subsite '$subsite_id': default '$default' actual value '$value'"
                break
            }
        }
        if {$collect_p} {
            lappend theme_subsites $subsite_id
        }
    }
    return $theme_subsites
XQL Not present:
Generic
PostgreSQL XQL file:
packages/acs-subsite/tcl/subsite-procs-postgresql.xql

Oracle XQL file:
packages/acs-subsite/tcl/subsite-procs-oracle.xql

[ hide source ] | [ make this the default ]
Show another procedure: