Changeset 438

Show
Ignore:
Timestamp:
01/05/08 13:17:06 (12 months ago)
Author:
padams
Message:

- adding initial plugin, auth, and templates for Gallery2 installs.
- reorganized caller constructor
- fixed bug in cache where empty objects were being cached.

Location:
trunk
Files:
5 added
8 modified

Legend:

Unmodified
Added
Removed
  • trunk/conf/owa-config-dist.php

    r377 r438  
    1818 
    1919/** 
    20  * DB Configuration 
     20 * OWA Configuration 
    2121 *  
    2222 * @author      Peter Adams <peter@openwebanalytics.com> 
     
    2929 */ 
    3030  
    31 define('OWA_DB_TYPE', ''); // options: mysql 
    32 define('OWA_DB_NAME', ''); // name of the database 
    33 define('OWA_DB_HOST', ''); // host name of the server housing the database 
    34 define('OWA_DB_USER', ''); // database user 
    35 define('OWA_DB_PASSWORD', ''); // database user's password 
     31/** 
     32 * DATABASE CONFIGURATION 
     33 * 
     34 * Connection info for databases that will be used by OWA.  
     35 * 
     36 */ 
    3637 
    37 // define the URL of the public directory e.g. http://www.domain.com/root/dir/owa/public/  
    38 // Don't forget the slash at the end. 
    39 define('OWA_PUBLIC_URL', '');  
     38//define('OWA_DB_TYPE', ''); // options: mysql 
     39//define('OWA_DB_NAME', ''); // name of the database 
     40//define('OWA_DB_HOST', ''); // host name of the server housing the database 
     41//define('OWA_DB_USER', ''); // database user 
     42//define('OWA_DB_PASSWORD', ''); // database user's password 
    4043 
    41 // Log all php errors to OWA's error log file. Only do this to debug. 
    42 define('OWA_LOG_PHP_ERRORS', false); 
     44 
     45/**  
     46 * PUBLIC URL 
     47 * 
     48 * Define the URL of the public directory e.g. http://www.domain.com/root/dir/owa/public/  
     49 * Don't forget the slash at the end. 
     50 */ 
    4351  
     52// define('OWA_PUBLIC_URL', '');  
     53 
     54/**  
     55 * LOG PHP ERRORS 
     56 * 
     57 * Log all php errors to OWA's error log file. Only do this to debug. 
     58 */ 
     59 
     60//define('OWA_LOG_PHP_ERRORS', false); 
     61  
     62/**  
     63 * OBJECT CACHING 
     64 * 
     65 * Override setting to cache objects. Caching will increase performance.  
     66 */ 
     67 
     68//define('OWA_CACHE_OBJECTS', true); 
     69 
     70 
     71 
    4472?> 
  • trunk/modules/base/classes/entityManager.php

    r425 r438  
    233233                                 
    234234                        $properties = $this->db->select($this->_getProperties(), $constraint, get_class($this->entity)); 
    235                                  
    236                         $this->setProperties($properties); 
    237                          
    238                         if ($this->config['cache_objects'] == true): 
    239                                 $this->cache->set(get_class($this->entity), 'id'.$this->entity->id->value, $this->entity);       
    240                         endif;           
     235                         
     236                        if (!empty($properties)): 
     237                                         
     238                                $this->setProperties($properties); 
     239                                 
     240                                if ($this->config['cache_objects'] == true): 
     241                                        $this->cache->set(get_class($this->entity), 'id'.$this->entity->id->value, $this->entity);       
     242                                endif;           
     243                        endif; 
    241244                endif; 
    242245                 
  • trunk/modules/base/classes/error.php

    r433 r438  
    209209        } 
    210210         
    211         function crit() { 
     211        function crit($message) { 
    212212                 
    213213                return $this->log($message, PEAR_LOG_CRIT); 
     
    215215        } 
    216216         
    217         function alert() { 
     217        function alert($message) { 
    218218                 
    219219                return $this->log($message, PEAR_LOG_ALERT); 
     
    221221        } 
    222222         
    223         function emerg() { 
     223        function emerg($message) { 
    224224                 
    225225                return $this->log($message, PEAR_LOG_EMERG); 
  • trunk/modules/base/classes/settings.php

    r433 r438  
    343343                        'exits_table'                                   => 'exit', 
    344344                        'users_table'                                   => 'user', 
    345                         'db_type'                                               => OWA_DB_TYPE, 
     345                        'db_type'                                               => '', 
     346                        'db_name'                                               => '', 
     347                        'db_host'                                               => '', 
     348                        'db_user'                                               => '', 
     349                        'db_password'                                   => '', 
    346350                        'resolve_hosts'                                 => true, 
    347351                        'log_feedreaders'                               => true, 
  • trunk/modules/base/reportDashboard.php

    r398 r438  
    5050                // Load the core API 
    5151                $api = &owa_coreAPI::singleton($this->params); 
     52                 
     53                //if (empty($this->params['period'])): 
     54                //      $this->params['period'] = 'today'; 
     55                //endif; 
    5256                 
    5357                $data = array(); 
  • trunk/mw_plugin.php

    r425 r438  
    2121require_once "$IP/includes/SpecialPage.php"; 
    2222 
     23/* MEDIAWIKI GLOBALS */ 
    2324global $wgCachePages, $wgDBtype, $wgDBname, $wgDBserver, $wgDBuser, $wgDBpassword, $wgUser, $wgServer, $wgScriptPath, $wgScript; 
    2425 
    25 // OWA Configuration 
    26  
    27  
    28 // OWA DATABASE CONFIGURATION  
    29 // Will use Wordpress config unless there is a config file present. 
    30 // OWA uses this to setup it's own DB connection seperate from the one 
    31 // that Wordpress uses. 
    32  
    33 $config_file = OWA_CONF_DIR.'owa-config.php'; 
    34 if (file_exists($config_file)): 
    35         // do nothing as the caller class will define the DB config constants later. 
    36         ; 
    37 else: 
    38         // use the Wordpress configuration 
    39         define('OWA_DB_TYPE', $wgDBtype); 
    40         define('OWA_DB_NAME', $wgDBname); 
    41         define('OWA_DB_HOST', $wgDBserver); 
    42         define('OWA_DB_USER', $wgDBuser); 
    43         define('OWA_DB_PASSWORD', $wgDBpassword); 
    44 endif; 
     26/* OWA's MEDIAWIKI CONFIGURATION OVERRIDES */ 
    4527 
    4628// Public folder URI 
    4729define('OWA_PUBLIC_URL', $wgServer.$wgScriptPath.'/extensions/owa/public/'); 
    4830 
    49 // Build the OWA wordpress specific config overrides array 
     31// Build OWA's Mediawiki specific config overrides array 
    5032$owa_config = array(); 
     33 
     34// OWA DATABASE CONFIGURATION  
     35// Will use Mediawiki's config valuesunless there are values present in an OWA config file. 
     36// OWA uses this to setup it's own DB connection seperate from the one that Mediawiki uses. 
     37$owa_config['db_type'] = $wgDBtype; 
     38$owa_config['db_name'] = $wgDBname; 
     39$owa_config['db_host'] = $wgDBserver; 
     40$owa_config['db_user'] = $wgDBuser; 
     41$owa_config['db_password'] = $wgDBpassword; 
     42 
    5143$owa_config['report_wrapper'] = 'wrapper_mediawiki.tpl'; 
    5244$owa_config['images_url'] = OWA_PUBLIC_URL.'i/'; 
     
    6153$owa_config['is_embedded'] = 'true'; 
    6254 
    63 //$owa = new owa_php($owa_config); 
    64  
    6555// Turn MediaWiki Caching Off 
    6656global $wgCachePages, $wgCacheEpoch; 
     
    8070 
    8171//Load Special Page 
    82  
    8372$wgAutoloadClasses['SpecialOwa'] = __FILE__; 
    8473$wgSpecialPages['Owa'] = 'SpecialOwa'; 
     
    8776 
    8877 
    89 // OWA Factory 
    90  
     78/** 
     79 * OWA Singleton Method 
     80 * 
     81 * Makes a singleton instance of OWA using the config array 
     82 */ 
    9183function owa_factory() { 
    9284 
    9385        global $owa_config; 
     86         
    9487        static $owa; 
    9588         
     
    10497 
    10598/** 
    106  * Main Media Wiki Extension method 
    107  * 
     99 * Main Mediawiki Extension method 
     100 * 
     101 * sets up OWA to be triggered for various hooks/actions 
    108102 */ 
    109103function owa_main() { 
     104 
    110105        global $wgHooks; 
    111106 
    112          
    113          
    114         // Create Instance of OWA 
    115         //$owa = new owa_php; 
    116         //$owa = owa_factory(); 
    117107        // Hook for logging Article Page Views 
    118108        $wgHooks['ArticlePageDataAfter'][] = 'owa_logArticle'; 
     
    121111         
    122112        // Hooks for adding page tracking tags  
    123          
    124113        $wgHooks['ArticlePageDataAfter'][] = 'owa_footer'; 
    125114        $wgHooks['SpecialPageExecuteAfterPage'][] = 'owa_footer'; 
     
    133122 
    134123/** 
    135  * Logs Special Page Views 
    136  * 
     124 * Hook for OWA special actions 
     125 * 
     126 * This uses mediawiki's 'unknown action' hook to trigger OWA's special action handler. 
     127 * This is setup by adding 'action=owa' to the URLs for special actions. There is  
     128 * probably a better way to do this so that the OWA namespace is preserved. 
     129 * 
     130 * @TODO figure out how to register this method to be triggered only when 'action=owa' instead of  
     131 *               for all unknown mediawiki actions. 
    137132 * @param object $specialPage 
    138133 * @url http://www.mediawiki.org/wiki/Manual:MediaWiki_hooks/UnknownAction 
     
    154149} 
    155150 
     151/** 
     152 * OWA Priviledges 
     153 * 
     154 * Populates OWA requestion container with info about the current mediawiki user. 
     155 * This info is needed by OWA authentication system as well as to add dimensions 
     156 * requests that are logged. 
     157 */ 
    156158function owa_set_priviledges() { 
    157159 
     
    190192    $app_params['page_type'] = 'Special Page'; 
    191193 
    192     //print_r($wgOut); 
    193194        // Log the request 
    194195        $owa = owa_factory(); 
     
    249250 
    250251/** 
    251  * Adds first hit web bug to Article Pages if needed 
     252 * Adds helper page tags to Article Pages if they are needed 
    252253 * 
    253254 * @param object $article 
     
    266267 
    267268 
    268 /* Special Page Class 
    269  *  
     269/** 
     270 * OWA Special Page Class 
     271 * 
     272 * Enables OWA to be accessed through a Mediawiki special page.  
    270273 */ 
    271274class SpecialOwa extends SpecialPage { 
  • trunk/owa_caller.php

    r434 r438  
    9393                 */ 
    9494                 
    95                 /* DATABASE CONNECTIONS */ 
    96                  
    97                 //load DB constants if not set already by caller 
     95                /* APPLY CALLER CONFIGURATION OVERRIDES */ 
     96                 
     97                /** 
     98                 * This will apply configuration overirdes that are specified by the calling application. 
     99                 * This is usually used by plugins to setup integration specific configuration values. 
     100                 */ 
     101                $this->c->applyModuleOverrides('base', $config); 
     102                $this->e->debug('Caller configuration overrides applied.'); 
     103                 
     104                 
     105                /* APPLY CONFIGURATION FILE OVERRIDES */ 
     106                 
     107                $file = OWA_BASE_DIR.DIRECTORY_SEPARATOR.'conf'.DIRECTORY_SEPARATOR.'owa-config.php'; 
     108                 
     109                if (file_exists($file)): 
     110                        include ($file); 
     111                         
     112                        /* OBJECT CACHING */ 
     113                 
     114                        // Looks for object cache config constant 
     115                        if (defined('OWA_CACHE_OBJECTS')): 
     116                                $this->c->set('base', 'cache_objects', OWA_CACHE_OBJECTS); 
     117                        endif; 
     118                         
     119                 
     120                        /* ERROR LOGGING */ 
     121                 
     122                        // Looks for log level constant 
     123                        if (defined('OWA_ERROR_LOG_LEVEL')): 
     124                                $this->c->set('base', 'error_log_level', OWA_ERROR_LOG_LEVEL); 
     125                        endif; 
     126                 
     127                        /* PHP ERROR LOGGING */ 
     128                         
     129                        if (OWA_LOG_PHP_ERRORS === true): 
     130                                $this->e->logPhpErrors(); 
     131                        endif; 
     132                         
     133                else: 
     134                        $this->e->debug("I can't find your configuration file...assuming that you didn't create one."); 
     135                endif; 
     136                 
     137                                         
     138                /* APPLY DATABASE CONFIGURATION */ 
     139                 
     140                if (!defined('OWA_DB_TYPE')): 
     141                        define('OWA_DB_TYPE', $this->c->get('base', 'db_type')); 
     142                endif; 
     143                 
     144                if (!defined('OWA_DB_NAME')): 
     145                        define('OWA_DB_NAME', $this->c->get('base', 'db_name')); 
     146                endif; 
     147                 
    98148                if (!defined('OWA_DB_HOST')): 
    99                         $file = OWA_BASE_DIR.DIRECTORY_SEPARATOR.'conf'.DIRECTORY_SEPARATOR.'owa-config.php'; 
    100                         if (file_exists($file)): 
    101                                 include ($file); 
    102                         else: 
    103                                 $this->e->emerg("Uh-oh. Your DB config is undefined and I can't find your configuration file..."); 
    104                                 exit; 
    105                         endif; 
    106                 endif; 
    107                  
    108                  
    109                 /* OBJECT CACHING */ 
    110                  
    111                 // Looks for object cache config constant 
    112                 if (defined('OWA_OBJECT_CACHING')): 
    113                         $config['cache_objects'] = OWA_OBJECT_CACHING; 
    114                 endif; 
    115                  
    116                  
    117                 /* ERROR LOGGING */ 
    118                  
    119                 // Looks for log level constant 
    120                 if (defined('OWA_ERROR_LOG_LEVEL')): 
    121                         $config['error_log_level'] = OWA_ERROR_LOG_LEVEL; 
    122                 endif; 
    123                  
    124                 // log PHP warnings and errors 
    125                 if (OWA_LOG_PHP_ERRORS === true): 
    126                         $this->e->logPhpErrors(); 
    127                 endif; 
    128                  
    129                  
    130                 /** 
    131                  * User Settings Config Overrides 
    132                  * 
    133                  * These overrides come from user settings stored in the database 
    134                  */ 
    135                          
    136                 // sets config ID is not already set 
    137                 if (empty($config['configuration_id'])): 
    138                         $config['configuration_id'] = 1; 
     149                        define('OWA_DB_HOST', $this->c->get('base', 'db_host')); 
     150                endif; 
     151                 
     152                if (!defined('OWA_DB_USER')): 
     153                        define('OWA_DB_USER', $this->c->get('base', 'db_user')); 
     154                endif; 
     155                 
     156                if (!defined('OWA_DB_PASSWORD')): 
     157                        define('OWA_DB_PASSWORD', $this->c->get('base', 'db_password')); 
    139158                endif;   
     159                                         
     160                /* APPLY USER CONFIGURATION OVERRIDES FROM DATABASE */ 
    140161                 
    141162                // Applies config from db or cache 
    142163                // needed for installs when the configuration table does not exist. 
    143                 if ($config['do_not_fetch_config_from_db'] != true): 
    144                         $this->c->load($config['configuration_id']); 
    145                 endif; 
    146                          
    147                 /** 
    148                  * Run-time Config Overrides 
    149                  * 
    150                  */ 
    151                   
    152                 // Applies run time config overrides 
    153                 $this->c->applyModuleOverrides('base', $config); 
    154                 $this->e->debug('caller config overrides applied.'); 
     164                if ($this->c->get('base', 'do_not_fetch_config_from_db') != true): 
     165                        $this->c->load($this->c->get('base', 'configuration_id')); 
     166                endif; 
     167 
    155168                 
    156169                // re-fetch the array now that overrides have been applied. 
  • trunk/wp_plugin.php

    r410 r438  
    3434$current_plugins = get_option('active_plugins'); 
    3535 
     36// Public folder URI 
     37define('OWA_PUBLIC_URL', '../wp-content/plugins/owa/public/'); 
     38 
     39// Build the OWA wordpress specific config overrides array 
     40$owa_config = array(); 
     41 
    3642// OWA DATABASE CONFIGURATION  
    3743// Will use Wordpress config unless there is a config file present. 
    3844// OWA uses this to setup it's own DB connection seperate from the one 
    3945// that Wordpress uses. 
    40  
    41 $config_file = OWA_CONF_DIR.'owa-config.php'; 
    42 if (file_exists($config_file)): 
    43         // do nothing as the caller class will define the DB config constants later. 
    44         ; 
    45 else: 
    46         // use the Wordpress configuration 
    47         define('OWA_DB_TYPE', 'mysql'); 
    48         define('OWA_DB_NAME', DB_NAME); 
    49         define('OWA_DB_HOST', DB_HOST); 
    50         define('OWA_DB_USER', DB_USER); 
    51         define('OWA_DB_PASSWORD', DB_PASSWORD); 
    52 endif; 
    53  
    54 // Public folder URI 
    55 define('OWA_PUBLIC_URL', '../wp-content/plugins/owa/public/'); 
    56  
    57 // Build the OWA wordpress specific config overrides array 
    58 $owa_config = array(); 
     46$owa_config['db_type'] = 'mysql'; 
     47$owa_config['db_name'] = DB_NAME; 
     48$owa_config['db_host'] = DB_HOST; 
     49$owa_config['db_user'] = DB_USER; 
     50$owa_config['db_password'] = DB_PASSWORD; 
     51 
    5952$owa_config['report_wrapper'] = 'wrapper_wordpress.tpl'; 
    6053$owa_config['images_url'] = OWA_PUBLIC_URL.'i/';//'../wp-content/plugins/owa/public/i/';