예제 #1
0
function sed_pcf_if_field_section($atts, $thing = '')
{
    #	Tests to see if there is a named section of the named custom field.
    global $thisarticle;
    extract(lAtts(array('custom' => '', 'section' => ''), $atts));
    $cond = false;
    $vars = @$thisarticle[$custom];
    if (!empty($vars) and !empty($section)) {
        $vars = sed_lib_extract_packed_variable_section($section, $vars);
        $cond = is_array($vars);
    }
    return parse(EvalElse($thing, $cond));
}
예제 #2
0
function sed_copyright_date($atts)
{
    #	Outputs a blank string, a year or a year range according to
    # the $atts input. By default will output a year range where the
    # start year is the year of the first posted article in the TXP
    # article database table and the end year is either...
    # 1. The year from the lasmod date from the global variables
    # or
    # 2. The year that the last change to the article DB table was
    # committed
    #
    #	Of these, option 1 is faster but is not available to us if
    # the TXP installation has comments updating the lastmod date.
    global $thisarticle;
    global $prefs;
    global $is_article_list;
    global $sed_copyright_owner;
    $result = '';
    $sed_copyright_owner = '';
    extract(lAtts(array('debug' => '', 'custom' => '', 'start_year' => '', 'end_year' => '', 'date_type' => 'range', 'owner' => $prefs['sitename'], 'owner_href' => '', 'owner_title' => '', 'copy_text' => '©', 'order' => 'cdo', 'wraptag' => '', 'class' => 'copyright', 'custom' => ''), $atts));
    $start_extra = '';
    # Holds extra debug strings from date access routines.
    $end_extra = '';
    # Holds extra debug strings from date access routines.
    if (!empty($debug)) {
        echo "<br/>=== Copyright Date: Start Attributes ===<br/>\n";
        print_r($atts);
        echo "<br/>=== Copyright Date:  End  Attributes ===<br/>\n";
        print_r("First post query:[" . SED_FIRST_POST_QUERY . "], Last mod query:[" . SED_LAST_MOD_QUERY . "]");
        echo "<br/>=== Copyright Date:  End  Attributes ===<br/>\n";
    }
    #	Call the date access routines. These will access the cached date variables if needed and also give extra information
    # for debug in the $_extra strings.
    if (empty($custom) or true == $is_article_list) {
        $start = _get_start_year($start_year, $start_extra);
        $end = _get_end_year($end_year, $end_extra);
    } else {
        #	This section deals with article copyright processing. It looks in the named custom field for a section called 'copyright' and pulls
        # any needed details from it. Defaults to the posted date and article author but that can be overidden.
        #	copyright(attrib1='val1';attrib2='val2')
        #	Valid attributes are...
        #		owner 	(if not supplied defaults to the article author.)
        #		owner_href and owner_title.
        #		start	(if missing defaults to the year the article was posted)
        #		end		(if missing defaults to the start year)
        #
        $packed_string = @$thisarticle[$custom];
        $vars = sed_lib_extract_packed_variable_section('copyright', $packed_string);
        $title = gAtt($vars, 'owner_title');
        $href = gAtt($vars, 'owner_href');
        $sed_copyright_owner = gAtt($vars, 'owner', get_author_name($thisarticle['authorid']));
        if ($sed_copyright_owner and isset($href) and isset($title)) {
            $sed_copyright_owner = _sed_build_href($sed_copyright_owner, $href, $title);
        }
        $start = gAtt($vars, 'start', date('Y', $thisarticle['posted']));
        $end = gAtt($vars, 'start', $start);
        $start_extra = '(start from custom field)';
        $end_extra = '(end from custom field)';
    }
    #	Only ouput the extra debug info if needed.
    if (empty($debug)) {
        $start_extra = '';
        $end_extra = '';
    }
    #	If a range has been requested and the start year is the same as the end year then compress the format...
    if ($date_type == 'range' and $start === $end and $start_extra === $end_extra) {
        $date_type = 'end';
    }
    #	Do any other compressions as needed...
    if (empty($start) && empty($end)) {
        $date_type = 'none';
    }
    if (empty($start) && !empty($end)) {
        $date_type = 'end';
    }
    if (!empty($start) && empty($end)) {
        $date_type = 'start';
    }
    #	Format the resulting date string...
    switch ($date_type) {
        case 'range':
            $result = $start_extra . $start . '-' . $end_extra . $end;
            break;
        case 'start':
            $result = $start_extra . $start;
            break;
        case 'end':
            $result = $end_extra . $end;
            break;
        case 'none':
            $result = '';
    }
    return $result;
}