Changeset 216

Show
Ignore:
Timestamp:
06/12/03 22:45:08 (5 years ago)
Author:
mikelittle
Message:

New function to pull new options from db.
Added default parameter to dropdown_categories()
require -> require_once

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/b2-include/b2functions.php

    r203 r216  
    11<?php 
    2  
    3 /* new and improved ! now with more querystring stuff ! */ 
    4  
    5 if (!isset($querystring_start)) { 
    6     $querystring_start = '?'; 
    7     $querystring_equal = '='; 
    8     $querystring_separator = '&amp;'; 
    9 } 
    102 
    113if (!function_exists('_')) { 
     
    482474    global $tablesettings, $wpdb, $cache_settings, $use_cache, $querycount; 
    483475    if ((empty($cache_settings)) OR (!$use_cache)) { 
    484         $settings = $wpdb->get_row("SELECT * FROM $tablesettings"); 
    485         ++$querycount; 
     476        $settings = get_alloptions(); 
    486477        $cache_settings = $settings; 
    487478    } else { 
    488479        $settings = $cache_settings; 
    489480    } 
     481    if (!isset($settings->$setting)) { 
     482        error_log("get_settings: Didn't find setting $setting"); 
     483    } 
    490484    return $settings->$setting; 
    491485} 
    492486 
     487function get_alloptions() { 
     488    global $tableoptions, $wpdb; 
     489    $options = $wpdb->get_results("SELECT option_name, option_value FROM $tableoptions"); 
     490    ++$querycount; 
     491    if ($options) { 
     492        foreach ($options as $option) { 
     493            $all_options->{$option->option_name} = $option->option_value; 
     494        } 
     495    } 
     496    return $all_options; 
     497} 
     498     
    493499function get_postdata($postid) { 
    494500    global $tableusers, $tablesettings, $tablecategories, $tableposts, $tablecomments, $querycount, $wpdb; 
     
    577583} 
    578584 
    579 function dropdown_categories($blog_ID=1) { 
     585function dropdown_categories($blog_ID=1, $default=1) { 
    580586    global $postdata,$tablecategories,$mode,$querycount; 
    581587    $query="SELECT * FROM $tablecategories"; 
     
    584590    $width = ($mode=="sidebar") ? "100%" : "170px"; 
    585591    echo '<select name="post_category" style="width:'.$width.';" tabindex="2" id="category">'; 
     592    if ($postdata["Category"] != '') { 
     593        $default = $postdata["Category"]; 
     594    } 
    586595    while($post = mysql_fetch_object($result)) { 
    587596        echo "<option value=\"".$post->cat_ID."\""; 
    588         if ($post->cat_ID == $postdata["Category"]
     597        if ($post->cat_ID == $default
    589598            echo " selected"; 
    590599        echo ">".$post->cat_name."</option>"; 
     
    703712// ( or just any time between timer_start() and timer_stop() ) 
    704713 
    705    function timer_start() { 
    706        global $timestart; 
    707        $mtime = microtime(); 
    708        $mtime = explode(" ",$mtime); 
    709        $mtime = $mtime[1] + $mtime[0]; 
    710        $timestart = $mtime; 
    711        return true; 
    712    
    713  
    714    function timer_stop($display=0,$precision=3) { //if called like timer_stop(1), will echo $timetotal 
    715        global $timestart,$timeend; 
    716        $mtime = microtime(); 
    717        $mtime = explode(" ",$mtime); 
    718        $mtime = $mtime[1] + $mtime[0]; 
    719        $timeend = $mtime; 
    720        $timetotal = $timeend-$timestart; 
    721        if ($display) 
    722            echo number_format($timetotal,$precision); 
    723        return $timetotal; 
    724    
     714function timer_start() { 
     715    global $timestart; 
     716    $mtime = microtime(); 
     717    $mtime = explode(" ",$mtime); 
     718    $mtime = $mtime[1] + $mtime[0]; 
     719    $timestart = $mtime; 
     720    return true; 
     721
     722 
     723function timer_stop($display=0,$precision=3) { //if called like timer_stop(1), will echo $timetotal 
     724    global $timestart,$timeend; 
     725    $mtime = microtime(); 
     726    $mtime = explode(" ",$mtime); 
     727    $mtime = $mtime[1] + $mtime[0]; 
     728    $timeend = $mtime; 
     729    $timetotal = $timeend-$timestart; 
     730    if ($display) 
     731        echo number_format($timetotal,$precision); 
     732    return $timetotal; 
     733
    725734 
    726735