Exemple #1
0
function sed_pcf_get_value($atts)
{
    #	Returns the value of the named variable in the named section of the named custom field (if any) else returns the default value (NULL).
    global $thisarticle;
    extract(lAtts(array('custom' => '', 'section' => '', 'variable' => '', 'default' => NULL), $atts));
    $result = $default;
    $vars = @$thisarticle[$custom];
    if (!empty($vars) and !empty($section) and !empty($variable)) {
        if ('none' === $section) {
            $vars = sed_lib_extract_name_value_pairs($vars);
        } else {
            $vars = sed_lib_extract_packed_variable_section($section, $vars);
        }
        if (is_array($vars)) {
            $result = @$vars[$variable];
        }
    }
    return $result;
}
function sed_lib_extract_packed_variable_section($section_name, $packed_string, $prefix = '', $attach_name = false, $section_char = '|', $variable_delim_char = ';')
{
    $result = array();
    if (empty($packed_string) or empty($section_name)) {
        return false;
    }
    //
    //	Break the packed string on the section boundaries...
    //
    $sections = explode($section_char, $packed_string);
    $count = count($sections);
    if (0 == $count) {
        return false;
    }
    //
    //	Find the section with the matching prefix. If it is not present
    // then return false.
    //
    $found = false;
    $section = '';
    $len = strlen($section_name);
    for ($i = 0; $i < $count; $i++) {
        $s = $sections[$i];
        if ($s[$len] === '(') {
            if (substr($s, 0, $len) == $section_name) {
                $section = $s;
                $i = $count;
            }
        }
    }
    if ('' === $section) {
        return false;
    }
    //
    //	Split this section on the variable delimiter...
    //
    $section_len = strlen($section);
    $content = substr($section, $len + 1, $section_len - $len - 2);
    $result = sed_lib_extract_name_value_pairs($content, $prefix, $section_name, $attach_name, $variable_delim_char);
    return $result;
}
function _sed_sf_build_static_section_list($section, $row)
{
    global $_sed_sf_static_sections;
    $data = _sed_sf_get_data($section);
    $data_array = sed_lib_extract_name_value_pairs($data);
    $ss = $data_array['ss'];
    if ($ss[0] == '1') {
        $_sed_sf_static_sections[] = $section;
    }
}