]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - lib/common.php
common_local_url() second parameter optional
[quix0rs-gnu-social.git] / lib / common.php
index b4c2f9b6e7e24ad60bdc1911700353a63fa6244a..8e0ea56b6b8a8716759f1b3c4e5c7fc41c3c392b 100644 (file)
  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  */
 
-if (!defined('LACONICA')) { exit(1) }
+/* XXX: break up into separate modules (HTTP, HTML, user, files) */
+
+
+if (!defined('LACONICA')) { exit(1); }
 
 define('AVATAR_PROFILE_SIZE', 96);
 define('AVATAR_STREAM_SIZE', 48);
@@ -26,26 +29,33 @@ define('MAX_AVATAR_SIZE', 256 * 1024);
 
 # global configuration object
 
+require_once('PEAR.php');
+require_once('DB/DataObject.php');
+
 // default configuration, overwritten in config.php
 
 $config =
   array('site' =>
-               array('name' => 'Just another µB'),
+               array('name' => 'Just another Laconica microblog',
+                         'server' => 'localhost',
+                         'path' => '/'),
                'avatar' =>
                array('directory' => INSTALLDIR . 'files',
-                         'path' => '/files'),
-               'dsn' =>
-               array('phptype' => 'mysql',
-                         'username' => 'stoica',
-                         'password' => 'apasswd',
-                         'hostspec' => 'localhost',
-                         'database' => 'thedb')
-               'dboptions' =>
-               array('debug' => 2,
-                         'portability' => DB_PORTABILITY_ALL));
+                         'path' => '/files')
+);
+
+$config['db'] = &PEAR::getStaticProperty('DB_DataObject','options');
+
+$config['db'] = 
+  array('database' => 'YOU HAVE TO SET THIS IN config.php',
+           'schema_location' => $INSTALLDIR . '/classes',
+               'class_location' => $INSTALLDIR . '/classes',
+               'require_prefix' => 'classes/',
+               'class_prefix' => '',
+        'db_driver' => 'MDB2',
+               'quote_identifiers' => false);
 
 require_once(INSTALLDIR . '/config.php');
-require_once('DB.php');
 
 # Show a server error
 
@@ -254,6 +264,44 @@ function common_avatar_url($filename) {
        return $config['avatar']['path'] . '/' . $filename;
 }
 
+function common_local_url($action, $args=NULL) {
+       global $config;
+       /* XXX: pretty URLs */
+       $extra = '';
+       if ($args) {
+               foreach ($args as $key => $value) {
+                       $extra .= "&${key}=${value}";
+               }
+       }
+       return "http://".$config['site']['server'].'/'.$config['site']['path']."/index.php?action=${action}${extra}";
+}
+
+function commmon_date_string($dt) {
+       // XXX: do some sexy date formatting
+       return date(DATE_RFC822);
+}
+
+function common_redirect($url, $code=307) {
+       static $status = array(301 => "Moved Permanently",
+                                                  302 => "Found",
+                                                  303 => "See Other",
+                                                  307 => "Temporary Redirect");
+       header("Status: ${code} $status[$code]");
+       header("Location: $url");
+       common_element('a', array('href' => $url), $url);
+}
+
+function common_broadcast_notices($id) {
+       // XXX: broadcast notices to remote subscribers
+       // XXX: broadcast notices to SMS
+       // XXX: broadcast notices to Jabber
+       // XXX: broadcast notices to other IM
+       // XXX: use a queue system like http://code.google.com/p/microapps/wiki/NQDQ
+       return true;
+}
+
 // XXX: set up gettext
 
-function _t($str) { $str }
+function _t($str) { 
+       return $str;
+}