plugins/staticpages/functions.inc
branchHEAD
changeset 7402 f7706912e8be
parent 7390 2b5aac1d58f8
child 7403 7a15ec67da80
     1.1 --- a/plugins/staticpages/functions.inc	Tue Oct 20 22:53:07 2009 +0100
     1.2 +++ b/plugins/staticpages/functions.inc	Thu Oct 15 13:05:28 2009 -0400
     1.3 @@ -572,11 +572,13 @@
     1.4  */
     1.5  function plugin_searchtypes_staticpages()
     1.6  {
     1.7 -    global $LANG_STATIC;
     1.8 +    global $LANG_STATIC, $_SP_CONF;
     1.9  
    1.10 -    $tmp['staticpages'] = $LANG_STATIC['staticpages'];
    1.11 -
    1.12 -    return $tmp;
    1.13 +    if ($_SP_CONF['includesearch'] == 1) {
    1.14 +        $tmp['staticpages'] = $LANG_STATIC['staticpages'];
    1.15 +        
    1.16 +        return $tmp;
    1.17 +    }
    1.18  }
    1.19  
    1.20  
    1.21 @@ -1253,6 +1255,97 @@
    1.22  }
    1.23  
    1.24  /**
    1.25 +* Return headlines for New Static Pages section in the What's New block, if enabled
    1.26 +*
    1.27 +* @return   mixed       array(headline, byline), or boolean false if disabled
    1.28 +*
    1.29 +*/
    1.30 +function plugin_whatsnewsupported_staticpages()
    1.31 +{
    1.32 +    global $_SP_CONF, $LANG_STATIC, $LANG_WHATSNEW;
    1.33 +
    1.34 +    if ($_SP_CONF['hidenewstaticpages'] == 0) {
    1.35 +        $retval = array($LANG_STATIC['pages'],
    1.36 +                        COM_formatTimeString($LANG_WHATSNEW['new_last'],
    1.37 +                                             $_SP_CONF['newstaticpagesinterval'])
    1.38 +                       );
    1.39 +    } else {
    1.40 +        $retval = false;
    1.41 +    }
    1.42 +
    1.43 +    return $retval;
    1.44 +}
    1.45 +
    1.46 +/**
    1.47 +* Return new Static Pages for the What's New block
    1.48 +*
    1.49 +* @return   string  HTML list of new staticpages
    1.50 +*
    1.51 +*/
    1.52 +function plugin_getwhatsnew_staticpages()
    1.53 +{
    1.54 +    global $_CONF, $_TABLES, $_SP_CONF, $LANG_STATIC;
    1.55 +
    1.56 +    $retval = '';
    1.57 +
    1.58 +    $extra_sql = "";
    1.59 +    if ($_SP_CONF['includecenterblocks'] == 0) {
    1.60 +        $extra_sql =' AND sp_centerblock = 0';
    1.61 +    }
    1.62 +    if ($_SP_CONF['includephp'] == 0) {
    1.63 +        $extra_sql .=' AND sp_php = 0';
    1.64 +    }
    1.65 +    
    1.66 +    $sql = "SELECT sp_id, sp_title 
    1.67 +        FROM {$_TABLES['staticpage']} 
    1.68 +        WHERE NOT ISNULL(sp_content) AND (sp_date >= (date_sub(NOW(), INTERVAL {$_SP_CONF['newstaticpagesinterval']} SECOND))) 
    1.69 +        {$extra_sql} 
    1.70 +        " . COM_getPermSQL( 'AND' ) . " 
    1.71 +        ORDER BY sp_date DESC LIMIT 15";
    1.72 +
    1.73 +    $result = DB_query( $sql );
    1.74 +
    1.75 +    $nrows = DB_numRows( $result );
    1.76 +
    1.77 +    if( $nrows > 0)
    1.78 +    {
    1.79 +        $newstaticpages = array();
    1.80 +
    1.81 +        for( $x = 0; $x < $nrows; $x++ )
    1.82 +        {
    1.83 +            $A = DB_fetchArray( $result );
    1.84 +
    1.85 +            $url = COM_buildUrl( $_CONF['site_url']
    1.86 +                . '/staticpages/index.php?page=' . $A['sp_id'] );                
    1.87 +
    1.88 +            $title = COM_undoSpecialChars( stripslashes( $A['sp_title'] ));
    1.89 +            $titletouse = COM_truncate( $title, $_SP_CONF['title_trim_length'],
    1.90 +                                        '...' );
    1.91 +            if( $title != $titletouse )
    1.92 +            {
    1.93 +                $attr = array('title' => htmlspecialchars($title));
    1.94 +            }
    1.95 +            else
    1.96 +            {
    1.97 +                $attr = array();
    1.98 +            }
    1.99 +            $astaticpage = str_replace( '$', '&#36;', $titletouse );
   1.100 +            $astaticpage = str_replace( ' ', '&nbsp;', $astaticpage );
   1.101 +
   1.102 +            $newstaticpages[] = COM_createLink($astaticpage, $url, $attr);
   1.103 +        }
   1.104 +
   1.105 +        $retval .= COM_makeList( $newstaticpages, 'list-new-comments' );
   1.106 +    }
   1.107 +    else
   1.108 +    {
   1.109 +        $retval .= $LANG_STATIC['no_new_pages'] . '<br' . XHTML . '>' . LB;
   1.110 +    }
   1.111 +
   1.112 +    return $retval;
   1.113 +}
   1.114 +
   1.115 +/**
   1.116  * Return information for a static page
   1.117  *
   1.118  * @param    string  $sp_id      static page ID or '*'