+ * @version $Revision: 1.9 $
+ */
+
+// }}}
+class System_Command {
+ // {{{ properties
+
+ /**
+ * Array of settings used when creating the shell command
+ *
+ * @var array
+ * @access private
+ */
+ var $options = array();
+
+ /**
+ * Array of available shells to use to execute the command
+ *
+ * @var array
+ * @access private
+ */
+ var $shells = array();
+
+ /**
+ * Array of available control operators used between commands
+ *
+ * @var array
+ * @access private
+ */
+ var $controlOperators = array();
+
+ /**
+ * The system command to be executed
+ *
+ * @var string
+ * @access private
+ */
+ var $systemCommand = null;
+
+ /**
+ * Previously added part to the command string
+ *
+ * @var string
+ * @access private
+ */
+ var $previousElement = null;
+
+ /**
+ * Directory for writing stderr output
+ *
+ * @var string
+ * @access private
+ */
+ var $tmpDir = null;
+
+ /**
+ * To allow the pear error object to accumulate when building
+ * the command, we use the command status to keep track when
+ * a pear error is raised
+ *
+ * @var int
+ * @access private
+ */
+ var $commandStatus = 0;
+
+ /**
+ * Hold initialization PEAR_Error
+ *
+ * @var object
+ * @access private
+ **/
+ var $_initError = null;
+
+ // }}}
+ // {{{ constructor
+
+ /**
+ * Class constructor
+ *
+ * Defines all necessary constants and sets defaults
+ *
+ * @access public
+ */
+ function System_Command($in_shell = null)
+ {
+ // Defining constants
+ $this->options = array(
+ 'SEQUENCE' => true,
+ 'SHUTDOWN' => false,
+ 'SHELL' => $this->which($in_shell),
+ 'OUTPUT' => true,
+ 'NOHUP' => false,
+ 'BACKGROUND' => false,
+ 'STDERR' => false
+ );
+
+ // prepare the available control operators
+ $this->controlOperators = array(
+ 'PIPE' => '|',
+ 'AND' => '&&',
+ 'OR' => '||',
+ 'GROUP' => ';',
+ 'LFIFO' => '<',
+ 'RFIFO' => '>',
+ );
+
+ // List of allowed/available shells
+ $this->shells = array(
+ 'sh',
+ 'bash',
+ 'zsh',
+ 'tcsh',
+ 'csh',
+ 'ash',
+ 'sash',
+ 'esh',
+ 'ksh'
+ );
+
+ // Find the first available shell
+ if (empty($this->options['SHELL'])) {
+ foreach ($this->shells as $shell) {
+ if ($this->options['SHELL'] = $this->which($shell)) {
+ break;
+ }
+ }
+
+ // see if we still have no shell
+ if (empty($this->options['SHELL'])) {
+ $this->_initError =& PEAR::raiseError(null, SYSTEM_COMMAND_NO_SHELL, null, E_USER_WARNING, null, 'System_Command_Error', true);
+ return;
+ }
+ }
+
+ // Caputre a temporary directory for capturing stderr from commands
+ $this->tmpDir = System::tmpdir();
+ if (!System::mkDir("-p {$this->tmpDir}")) {
+ $this->_initError =& PEAR::raiseError(null, SYSTEM_COMMAND_TMPDIR_ERROR, null, E_USER_WARNING, null, 'System_Command_Error', true);
+ return;
+ }
+ }
+
+ // }}}
+ // {{{ setOption()
+
+ /**
+ * Sets the value for an option. Each option should be set to true
+ * or false; except the 'SHELL' option which should be a string
+ * naming a shell. The options are:
+ *
+ * 'SEQUENCE' Allow a sequence command or not (right now this is always on);
+ *
+ * 'SHUTDOWN' Execute commands via a shutdown function;
+ *
+ * 'SHELL' Path to shell;
+ *
+ * 'OUTPUT' Output stdout from process;
+ *
+ * 'NOHUP' Use nohup to detach process;
+ *
+ * 'BACKGROUND' Run as a background process with &;
+ *
+ * 'STDERR' Output on stderr will raise an error, even if
+ * the command's exit value is zero. The output from
+ * stderr can be retrieved using the getDebugInfo()
+ * method of the Pear_ERROR object returned by
+ * execute().;
+ *
+ * @param string $in_option is a case-sensitive string,
+ * corresponding to the option
+ * that should be changed
+ * @param mixed $in_setting is the new value for the option
+ * @access public
+ * @return bool true if succes, else false
+ */
+ function setOption($in_option, $in_setting)
+ {
+ if ($this->_initError) {
+ return $this->_initError;
+ }
+
+ $option = strtoupper($in_option);
+
+ if (!isset($this->options[$option])) {
+ PEAR::raiseError(null, SYSTEM_COMMAND_ERROR, null, E_USER_NOTICE, null, 'System_Command_Error', true);
+ return false;
+ }
+
+ switch ($option) {
+ case 'OUTPUT':
+ case 'SHUTDOWN':
+ case 'SEQUENCE':
+ case 'BACKGROUND':
+ case 'STDERR':
+ $this->options[$option] = !empty($in_setting);
+ return true;
+ break;
+
+ case 'SHELL':
+ if (($shell = $this->which($in_setting)) !== false) {
+ $this->options[$option] = $shell;
+ return true;
+ }
+ else {
+ PEAR::raiseError(null, SYSTEM_COMMAND_NO_SHELL, null, E_USER_NOTICE, $in_setting, 'System_Command_Error', true);
+ return false;
+ }
+ break;
+
+ case 'NOHUP':
+ if (empty($in_setting)) {
+ $this->options[$option] = false;
+ }
+ else if ($location = $this->which('nohup')) {
+ $this->options[$option] = $location;
+ }
+ else {
+ PEAR::raiseError(null, SYSTEM_COMMAND_NOHUP_MISSING, null, E_USER_NOTICE, null, 'System_Command_Error', true);
+ return false;
+ }
+ break;
+ }
+ }
+
+ // }}}
+ // {{{ pushCommand()
+
+ /**
+ * Used to push a command onto the running command to be executed
+ *
+ * @param string $in_command binary to be run
+ * @param string $in_argument either an option or argument value, to be handled appropriately
+ * @param string $in_argument
+ * @param ...
+ *
+ * @access public
+ * @return boolean true on success {or System_Command_Error Exception}
+ */
+ function pushCommand($in_command)
+ {
+ if ($this->_initError) {
+ return $this->_initError;
+ }
+
+ if (!is_null($this->previousElement) && !in_array($this->previousElement, $this->controlOperators)) {
+ $this->commandStatus = -1;
+ $error = PEAR::raiseError(null, SYSTEM_COMMAND_COMMAND_PLACEMENT, null, E_USER_WARNING, null, 'System_Command_Error', true);
+ }
+
+ // check for error here
+ $command = escapeshellcmd($this->which($in_command));
+ if ($command === false) {
+ $error = PEAR::raiseError(null, SYSTEM_COMMAND_INVALID_COMMAND, null, E_USER_WARNING, null, 'System_Command_Error', true);
+ }
+
+ $argv = func_get_args();
+ array_shift($argv);
+ foreach($argv as $arg) {
+ if (strpos($arg, '-') === 0) {
+ $command .= ' ' . $arg;
+ }
+ elseif ($arg != '') {
+ $command .= ' ' . escapeshellarg($arg);
+ }
+ }
+
+ $this->previousElement = $command;
+ $this->systemCommand .= $command;
+
+ return isset($error) ? $error : true;
+ }
+
+ // }}}
+ // {{{ pushOperator()
+
+ /**
+ * Used to push an operator onto the running command to be executed
+ *
+ * @param string $in_operator Either string reprentation of operator or system character
+ *
+ * @access public
+ * @return boolean true on success {or System_Command_Error Exception}
+ */
+ function pushOperator($in_operator)
+ {
+ if ($this->_initError) {
+ return $this->_initError;
+ }
+
+ $operator = isset($this->controlOperators[$in_operator]) ? $this->controlOperators[$in_operator] : $in_operator;
+
+ if (is_null($this->previousElement) || in_array($this->previousElement, $this->controlOperators)) {
+ $this->commandStatus = -1;
+ $error = PEAR::raiseError(null, SYSTEM_COMMAND_OPERATOR_PLACEMENT, null, E_USER_WARNING, null, 'System_Command_Error', true);
+ }
+ elseif (!in_array($operator, $this->controlOperators)) {
+ $this->commandStatus = -1;
+ $error = PEAR::raiseError(null, SYSTEM_COMMAND_INVALID_OPERATOR, null, E_USER_WARNING, $operator, 'System_Command_Error', true);
+ }
+
+ $this->previousElement = $operator;
+ $this->systemCommand .= ' ' . $operator . ' ';
+ return isset($error) ? $error : true;
+ }
+
+ // }}}
+ // {{{ execute()
+
+ /**
+ * Executes the code according to given options
+ *
+ * @return bool true if success {or System_Command_Exception}
+ *
+ * @access public
+ */
+ function execute()
+ {
+ if ($this->_initError) {
+ return $this->_initError;
+ }
+
+ // if the command is empty or if the last element was a control operator, we can't continue
+ if (is_null($this->previousElement) || $this->commandStatus == -1 || in_array($this->previousElement, $this->controlOperators)) {
+ return PEAR::raiseError(null, SYSTEM_COMMAND_INVALID_COMMAND, null, E_USER_WARNING, $this->systemCommand, 'System_Command_Error', true);
+ }
+
+ // Warning about impossible mix of options
+ if (!empty($this->options['OUTPUT'])) {
+ if (!empty($this->options['SHUTDOWN']) || !empty($this->options['NOHUP'])) {
+ return PEAR::raiseError(null, SYSTEM_COMMAND_NO_OUTPUT, null, E_USER_WARNING, null, 'System_Command_Error', true);
+ }
+ }
+
+ // if this is not going to stdout, then redirect to /dev/null
+ if (empty($this->options['OUTPUT'])) {
+ $this->systemCommand .= ' >/dev/null';
+ }
+
+ $suffix = '';
+ // run a command immune to hangups, with output to a non-tty
+ if (!empty($this->options['NOHUP'])) {
+ $this->systemCommand = $this->options['NOHUP'] . $this->systemCommand;
+ }
+ // run a background process (only if not nohup)
+ elseif (!empty($this->options['BACKGROUND'])) {
+ $suffix = ' &';
+ }
+
+ // Register to be run on shutdown
+ if (!empty($this->options['SHUTDOWN'])) {
+ $line = "system(\"{$this->systemCommand}$suffix\");";
+ $function = create_function('', $line);
+ register_shutdown_function($function);
+ return true;
+ }
+ else {
+ // send stderr to a file so that we can reap the error message
+ $tmpFile = tempnam($this->tmpDir, 'System_Command-');
+ $this->systemCommand .= ' 2>' . $tmpFile . $suffix;
+ $shellPipe = $this->which('echo') . ' ' . escapeshellarg($this->systemCommand) . ' | ' . $this->options['SHELL'];
+ exec($shellPipe, $result, $returnVal);
+
+ if ($returnVal !== 0) {
+ // command returned nonzero; that's always an error
+ $return = PEAR::raiseError(null, SYSTEM_COMMAND_NONZERO_EXIT, null, E_USER_WARNING, null, 'System_Command_Error', true);
+ }
+ else if (!$this->options['STDERR']) {
+ // caller does not care about stderr; return success
+ $return = implode("\n", $result);
+ }
+ else {
+ // our caller cares about stderr; check stderr output
+ clearstatcache();
+ if (filesize($tmpFile) > 0) {
+ // the command actually wrote to stderr
+ $stderr_output = file_get_contents($tmpFile);
+ $return = PEAR::raiseError(null, SYSTEM_COMMAND_STDERR, null, E_USER_WARNING, $stderr_output, 'System_Command_Error', true);
+ } else {
+ // total success; return stdout gathered by exec()
+ $return = implode("\n", $result);
+ }
+ }
+
+ unlink($tmpFile);
+ return $return;
+ }
+ }
+
+ // }}}
+ // {{{ which()
+
+ /**
+ * Functionality similiar to unix 'which'. Searches the path
+ * for the specified program.
+ *
+ * @param $cmd name of the executable to search for
+ *
+ * @access private
+ * @return string returns the full path if found, false if not
+ */
+ function which($in_cmd)
+ {
+ // only pass non-empty strings to System::which()
+ if (!is_string($in_cmd) || '' === $in_cmd) {
+ return(false);
+ }
+
+ // explicitly pass false as fallback value
+ return System::which($in_cmd, false);
+ }
+
+ // }}}
+ // {{{ reset()
+
+ /**
+ * Prepare for a new command to be built
+ *
+ * @access public
+ * @return void
+ */
+ function reset()
+ {
+ $this->previousElement = null;
+ $this->systemCommand = null;
+ $this->commandStatus = 0;
+ }
+
+ // }}}
+ // {{{ errorMessage()
+
+ /**
+ * Return a textual error message for a System_Command error code
+ *
+ * @param integer error code
+ *
+ * @return string error message, or false if the error code was
+ * not recognized
+ */
+ function errorMessage($in_value)
+ {
+ static $errorMessages;
+ if (!isset($errorMessages)) {
+ $errorMessages = array(
+ SYSTEM_COMMAND_OK => 'no error',
+ SYSTEM_COMMAND_ERROR => 'unknown error',
+ SYSTEM_COMMAND_NO_SHELL => 'no shell found',
+ SYSTEM_COMMAND_INVALID_SHELL => 'invalid shell',
+ SYSTEM_COMMAND_TMPDIR_ERROR => 'could not create temporary directory',
+ SYSTEM_COMMAND_INVALID_OPERATOR => 'control operator invalid',
+ SYSTEM_COMMAND_INVALID_COMMAND => 'invalid system command',
+ SYSTEM_COMMAND_OPERATOR_PLACEMENT => 'invalid placement of control operator',
+ SYSTEM_COMMAND_COMMAND_PLACEMENT => 'invalid placement of command',
+ SYSTEM_COMMAND_NOHUP_MISSING => 'nohup not found on system',
+ SYSTEM_COMMAND_NO_OUTPUT => 'output not allowed',
+ SYSTEM_COMMAND_STDERR => 'command wrote to stderr',
+ SYSTEM_COMMAND_NONZERO_EXIT => 'non-zero exit value from command',
+ );
+ }
+
+ if (System_Command::isError($in_value)) {
+ $in_value = $in_value->getCode();
+ }
+
+ return isset($errorMessages[$in_value]) ? $errorMessages[$in_value] : $errorMessages[SYSTEM_COMMAND_ERROR];
+ }
+
+ // }}}
+ // {{{ isError()
+
+ /**
+ * Tell whether a result code from a System_Command method is an error
+ *
+ * @param int result code
+ *
+ * @return bool whether $in_value is an error
+ *
+ * @access public
+ */
+ function isError($in_value)
+ {
+ return (is_object($in_value) &&
+ (strtolower(get_class($in_value)) == 'system_command_error' ||
+ is_subclass_of($in_value, 'system_command_error')));
+ }
+
+ // }}}
+}
+
+// {{{ class System_Command_Error
+
+/**
+ * System_Command_Error constructor.
+ *
+ * @param mixed System_Command error code, or string with error message.
+ * @param integer what "error mode" to operate in
+ * @param integer what error level to use for $mode & PEAR_ERROR_TRIGGER
+ * @param mixed additional debug info, such as the last query
+ *
+ * @access public
+ *
+ * @see PEAR_Error
+ */
+
+// }}}
+class System_Command_Error extends PEAR_Error
+{
+ // {{{ properties
+
+ /**
+ * Message in front of the error message
+ * @var string $error_message_prefix
+ */
+ var $error_message_prefix = 'System_Command Error: ';
+
+ // }}}
+ // {{{ constructor
+
+ function System_Command_Error($code = SYSTEM_COMMAND_ERROR, $mode = PEAR_ERROR_RETURN,
+ $level = E_USER_NOTICE, $debuginfo = null)
+ {
+ if (is_int($code)) {
+ $this->PEAR_Error(System_Command::errorMessage($code), $code, $mode, $level, $debuginfo);
+ } else {
+ $this->PEAR_Error("Invalid error code: $code", SYSTEM_COMMAND_ERROR, $mode, $level, $debuginfo);
+ }
+ }
+
+ // }}}
+}
+?>
diff --git a/index.php b/index.php
index 4eff99dff5..cb26e21961 100644
--- a/index.php
+++ b/index.php
@@ -1,7 +1,7 @@
getDebugInfo();
}
common_log(LOG_ERR, $logmsg);
- $msg = sprintf(_('The database for %s isn\'t responding correctly, '.
- 'so the site won\'t work properly. '.
- 'The site admins probably know about the problem, '.
- 'but you can contact them at %s to make sure. '.
- 'Otherwise, wait a few minutes and try again.'),
- common_config('site', 'name'),
- common_config('site', 'email'));
+ if ($error instanceof DB_DataObject_Error) {
+ $msg = sprintf(_('The database for %s isn\'t responding correctly, '.
+ 'so the site won\'t work properly. '.
+ 'The site admins probably know about the problem, '.
+ 'but you can contact them at %s to make sure. '.
+ 'Otherwise, wait a few minutes and try again.'),
+ common_config('site', 'name'),
+ common_config('site', 'email'));
+ } else {
+ $msg = _('An important error occured, probably related to email setup. '.
+ 'Check logfiles for more info..');
+ }
$dac = new DBErrorAction($msg, 500);
$dac->showPage();
@@ -70,7 +75,7 @@ function main()
global $user, $action, $config;
Snapshot::check();
-
+
if (!_have_config()) {
$msg = sprintf(_("No configuration file found. Try running ".
"the installation program first."));
diff --git a/install.php b/install.php
index 133f2b30f6..b94a929360 100644
--- a/install.php
+++ b/install.php
@@ -1,7 +1,7 @@
Config file "config.php" already exists.
@@ -116,11 +115,6 @@ function showForm()
disable
Enable fancy (pretty) URLs. Auto-detection failed, it depends on Javascript.
-
-
-
- Site path, following the "/" after the domain name in the URL. Empty is fine. Field should be filled automatically.
-
@@ -167,7 +161,6 @@ function handlePost()
$username = $_POST['username'];
$password = $_POST['password'];
$sitename = $_POST['sitename'];
- $path = $_POST['path'];
$fancy = !empty($_POST['fancy']);
?>
@@ -176,7 +169,7 @@ function handlePost()
");
return $res;
diff --git a/js/farbtastic/farbtastic.js b/js/farbtastic/farbtastic.js
index 24a377803c..d8b5ad9cdf 100644
--- a/js/farbtastic/farbtastic.js
+++ b/js/farbtastic/farbtastic.js
@@ -1,5 +1,21 @@
-// $Id: farbtastic.js,v 1.2 2007/01/08 22:53:01 unconed Exp $
-// Farbtastic 1.2
+/**
+ * Farbtastic Color Picker 1.2
+ * © 2008 Steven Wittens
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
jQuery.fn.farbtastic = function (callback) {
$.farbtastic(this, callback);
diff --git a/js/farbtastic/farbtastic.go.js b/js/userdesign.go.js
similarity index 66%
rename from js/farbtastic/farbtastic.go.js
rename to js/userdesign.go.js
index 0149eca7d9..b54b492cce 100644
--- a/js/farbtastic/farbtastic.go.js
+++ b/js/userdesign.go.js
@@ -10,19 +10,19 @@ $(document).ready(function() {
function UpdateColors(S) {
C = $(S).val();
switch (parseInt(S.id.slice(-1))) {
- case 0: default:
- $('body').css({'background-color':C});
- break;
- case 1:
- $('#content').css({'background-color':C});
+ case 1: default:
+ $('html, body').css({'background-color':C});
break;
case 2:
- $('#aside_primary').css({'background-color':C});
+ $('#content, #site_nav_local_views .current a').css({'background-color':C});
break;
case 3:
- $('body').css({'color':C});
+ $('#aside_primary').css({'background-color':C});
break;
case 4:
+ $('html body').css({'color':C});
+ break;
+ case 5:
$('a').css({'color':C});
break;
}
@@ -49,7 +49,7 @@ $(document).ready(function() {
}
}
- function Init() {
+ function InitFarbtastic() {
$('#settings_design_color').append('');
$('#color-picker').hide();
@@ -59,7 +59,9 @@ $(document).ready(function() {
swatches
.each(SynchColors)
.blur(function() {
- $(this).val($(this).val().toUpperCase());
+ tv = $(this).val();
+ $(this).val(tv.toUpperCase());
+ (tv.length == 4) ? ((tv[0] == '#') ? $(this).val('#'+tv[1]+tv[1]+tv[2]+tv[2]+tv[3]+tv[3]) : '') : '';
})
.focus(function() {
$('#color-picker').show();
@@ -73,13 +75,25 @@ $(document).ready(function() {
}
var f, swatches;
- Init();
+ InitFarbtastic();
$('#form_settings_design').bind('reset', function(){
setTimeout(function(){
swatches.each(function(){UpdateColors(this);});
$('#color-picker').remove();
swatches.unbind();
- Init();
+ InitFarbtastic();
},10);
});
-});
+
+ $('#design_background-image_off').focus(function() {
+ $('body').css({'background-image':'none'});
+ });
+ $('#design_background-image_on').focus(function() {
+ var bis = $('#design_background-image_onoff img')[0].src;
+ $('body').css({'background-image':'url('+bis+')'});
+ });
+
+ $('#design_background-image_repeat').click(function() {
+ ($(this)[0].checked) ? $('body').css({'background-repeat':'repeat'}) : $('body').css({'background-repeat':'no-repeat'});
+ });
+});
\ No newline at end of file
diff --git a/js/util.js b/js/util.js
index fd2500d447..65a77960a0 100644
--- a/js/util.js
+++ b/js/util.js
@@ -217,6 +217,7 @@ $(document).ready(function(){
$('#'+li.id).css({display:'none'});
$('#'+li.id).fadeIn(2500);
NoticeReply();
+ NoticeAttachments();
}
}
$("#notice_data-text").val("");
@@ -230,23 +231,12 @@ $(document).ready(function(){
};
$("#form_notice").ajaxForm(PostNotice);
$("#form_notice").each(addAjaxHidden);
- NoticeHover();
NoticeReply();
NoticeAttachments();
});
-
-function NoticeHover() {
- function mouseHandler(e) {
- $(e.target).closest('li.hentry')[(e.type === 'mouseover') ? 'addClass' : 'removeClass']('hover');
- };
- $('#content .notices').mouseover(mouseHandler);
- $('#content .notices').mouseout(mouseHandler);
-}
-
-
function NoticeReply() {
- if ($('#notice_data-text').length > 0) {
+ if ($('#notice_data-text').length > 0 && $('#content .notice_reply').length > 0) {
$('#content .notice').each(function() {
var notice = $(this)[0];
$($('.notice_reply', notice)[0]).click(function() {
diff --git a/lib/Shorturl_api.php b/lib/Shorturl_api.php
index 924aa93a89..29f4eb3a66 100644
--- a/lib/Shorturl_api.php
+++ b/lib/Shorturl_api.php
@@ -1,7 +1,7 @@
array(_('OpenID'),
_('Add or remove OpenIDs')),
- 'designsettings' =>
+ 'userdesignsettings' =>
array(_('Design'),
_('Design your profile')),
'othersettings' =>
diff --git a/lib/arraywrapper.php b/lib/arraywrapper.php
index ef0eeffa5e..a8a12b3bb3 100644
--- a/lib/arraywrapper.php
+++ b/lib/arraywrapper.php
@@ -1,7 +1,7 @@
attachment->id);
if (!empty($thumbnail)) {
- $this->out->element('img', array('alt' => 'nothing to say', 'src' => $thumbnail->url, 'width' => $thumbnail->width, 'height' => $thumbnail->height));
+ $this->out->element('img', array('alt' => '', 'src' => $thumbnail->url, 'width' => $thumbnail->width, 'height' => $thumbnail->height));
}
}
@@ -244,6 +243,50 @@ class AttachmentListItem extends Widget
class Attachment extends AttachmentListItem
{
+ function showLink() {
+ $this->out->elementStart('div', array('id' => 'attachment_view',
+ 'class' => 'hentry'));
+ $this->out->elementStart('div', 'entry-title');
+ $this->out->elementStart('a', $this->linkAttr());
+ $this->out->element('span', null, $this->linkTitle());
+ $this->showRepresentation();
+ $this->out->elementEnd('a');
+ $this->out->elementEnd('div');
+
+ if (!empty($this->oembed->author_name) || !empty($this->oembed->provider)) {
+ $this->out->elementStart('div', array('id' => 'oembed_info',
+ 'class' => 'entry-content'));
+ if (!empty($this->oembed->author_name)) {
+ $this->out->elementStart('dl', 'vcard author');
+ $this->out->element('dt', null, _('Author'));
+ $this->out->elementStart('dd', 'fn');
+ if (empty($this->oembed->author_url)) {
+ $this->out->text($this->oembed->author_name);
+ } else {
+ $this->out->element('a', array('href' => $this->oembed->author_url,
+ 'class' => 'url'), $this->oembed->author_name);
+ }
+ $this->out->elementEnd('dd');
+ $this->out->elementEnd('dl');
+ }
+ if (!empty($this->oembed->provider)) {
+ $this->out->elementStart('dl', 'vcard');
+ $this->out->element('dt', null, _('Provider'));
+ $this->out->elementStart('dd', 'fn');
+ if (empty($this->oembed->provider_url)) {
+ $this->out->text($this->oembed->provider);
+ } else {
+ $this->out->element('a', array('href' => $this->oembed->provider_url,
+ 'class' => 'url'), $this->oembed->provider);
+ }
+ $this->out->elementEnd('dd');
+ $this->out->elementEnd('dl');
+ }
+ $this->out->elementEnd('div');
+ }
+ $this->out->elementEnd('div');
+ }
+
function show() {
$this->showNoticeAttachment();
}
diff --git a/lib/channel.php b/lib/channel.php
index f1e2055466..38c1d4d67f 100644
--- a/lib/channel.php
+++ b/lib/channel.php
@@ -1,7 +1,7 @@
0) {
+ $p = substr($past_root, 0, $last_slash);
+ } else {
+ $p = '';
+ }
+ return $p;
+}
-$_server = array_key_exists('SERVER_NAME', $_SERVER) ?
- strtolower($_SERVER['SERVER_NAME']) :
- null;
-$_path = array_key_exists('SCRIPT_NAME', $_SERVER) ?
- substr($_SERVER['SCRIPT_NAME'], 1, strrpos($_SERVER['SCRIPT_NAME'], '/') - 1) :
- null;
+// try to figure out where we are. $server and $path
+// can be set by including module, else we guess based
+// on HTTP info.
+
+if (isset($server)) {
+ $_server = $server;
+} else {
+ $_server = array_key_exists('SERVER_NAME', $_SERVER) ?
+ strtolower($_SERVER['SERVER_NAME']) :
+ null;
+}
+
+if (isset($path)) {
+ $_path = $path;
+} else {
+ $_path = array_key_exists('SCRIPT_NAME', $_SERVER) ?
+ _sn_to_path($_SERVER['SCRIPT_NAME']) :
+ null;
+}
// default configuration, overwritten in config.php
@@ -71,6 +94,14 @@ $config =
array('name' => 'Just another Laconica microblog',
'server' => $_server,
'theme' => 'default',
+ 'design' =>
+ array('backgroundcolor' => '#F0F2F5',
+ 'contentcolor' => '#FFFFFF',
+ 'sidebarcolor' => '#CEE1E9',
+ 'textcolor' => '#000000',
+ 'linkcolor' => '#002E6E',
+ 'backgroundimage' => null,
+ 'disposition' => 1),
'path' => $_path,
'logfile' => null,
'logo' => null,
@@ -108,13 +139,21 @@ $config =
'profile' =>
array('banned' => array()),
'avatar' =>
- array('server' => null),
+ array('server' => null,
+ 'dir' => INSTALLDIR . '/avatar/',
+ 'path' => $_path . '/avatar/'),
+ 'background' =>
+ array('server' => null,
+ 'dir' => INSTALLDIR . '/background/',
+ 'path' => $_path . '/background/'),
'public' =>
array('localonly' => true,
'blacklist' => array(),
'autosource' => array()),
'theme' =>
- array('server' => null),
+ array('server' => null,
+ 'dir' => null,
+ 'path'=> null),
'throttle' =>
array('enabled' => false, // whether to throttle edits; false by default
'count' => 20, // number of allowed messages in timespan
@@ -150,6 +189,7 @@ $config =
'memcached' =>
array('enabled' => false,
'server' => 'localhost',
+ 'base' => null,
'port' => 11211),
'ping' =>
array('notify' => array()),
@@ -163,41 +203,51 @@ $config =
'frequency' => 10000,
'reporturl' => 'http://laconi.ca/stats/report'),
'attachments' =>
- array('supported' => array('image/png',
- 'image/jpeg',
- 'image/gif',
- 'image/svg+xml',
- 'audio/mpeg',
- 'audio/x-speex',
- 'application/ogg',
- 'application/pdf',
- 'application/vnd.oasis.opendocument.text',
- 'application/vnd.oasis.opendocument.text-template',
- 'application/vnd.oasis.opendocument.graphics',
- 'application/vnd.oasis.opendocument.graphics-template',
- 'application/vnd.oasis.opendocument.presentation',
- 'application/vnd.oasis.opendocument.presentation-template',
- 'application/vnd.oasis.opendocument.spreadsheet',
- 'application/vnd.oasis.opendocument.spreadsheet-template',
- 'application/vnd.oasis.opendocument.chart',
- 'application/vnd.oasis.opendocument.chart-template',
- 'application/vnd.oasis.opendocument.image',
- 'application/vnd.oasis.opendocument.image-template',
- 'application/vnd.oasis.opendocument.formula',
- 'application/vnd.oasis.opendocument.formula-template',
- 'application/vnd.oasis.opendocument.text-master',
- 'application/vnd.oasis.opendocument.text-web',
- 'application/x-zip',
- 'application/zip',
- 'text/plain',
- 'video/mpeg',
- 'video/mp4',
- 'video/quicktime',
- 'video/mpeg'),
+ array('server' => null,
+ 'dir' => INSTALLDIR . '/file/',
+ 'path' => $_path . '/file/',
+ 'supported' => array('image/png',
+ 'image/jpeg',
+ 'image/gif',
+ 'image/svg+xml',
+ 'audio/mpeg',
+ 'audio/x-speex',
+ 'application/ogg',
+ 'application/pdf',
+ 'application/vnd.oasis.opendocument.text',
+ 'application/vnd.oasis.opendocument.text-template',
+ 'application/vnd.oasis.opendocument.graphics',
+ 'application/vnd.oasis.opendocument.graphics-template',
+ 'application/vnd.oasis.opendocument.presentation',
+ 'application/vnd.oasis.opendocument.presentation-template',
+ 'application/vnd.oasis.opendocument.spreadsheet',
+ 'application/vnd.oasis.opendocument.spreadsheet-template',
+ 'application/vnd.oasis.opendocument.chart',
+ 'application/vnd.oasis.opendocument.chart-template',
+ 'application/vnd.oasis.opendocument.image',
+ 'application/vnd.oasis.opendocument.image-template',
+ 'application/vnd.oasis.opendocument.formula',
+ 'application/vnd.oasis.opendocument.formula-template',
+ 'application/vnd.oasis.opendocument.text-master',
+ 'application/vnd.oasis.opendocument.text-web',
+ 'application/x-zip',
+ 'application/zip',
+ 'text/plain',
+ 'video/mpeg',
+ 'video/mp4',
+ 'video/quicktime',
+ 'video/mpeg'),
'file_quota' => 5000000,
'user_quota' => 50000000,
'monthly_quota' => 15000000,
+ 'uploads' => true,
+ 'filecommand' => '/usr/bin/file',
),
+ 'group' =>
+ array('maxaliases' => 3),
+ 'oohembed' => array('endpoint' => 'http://oohembed.com/oohembed/'),
+ 'search' =>
+ array('type' => 'fulltext'),
);
$config['db'] = &PEAR::getStaticProperty('DB_DataObject','options');
@@ -223,15 +273,19 @@ if (function_exists('date_default_timezone_set')) {
// server-wide, then vhost-wide, then for a path,
// finally for a dir (usually only need one of the last two).
-$_config_files = array('/etc/laconica/laconica.php',
- '/etc/laconica/'.$_server.'.php');
+if (isset($conffile)) {
+ $_config_files = array($conffile);
+} else {
+ $_config_files = array('/etc/laconica/laconica.php',
+ '/etc/laconica/'.$_server.'.php');
-if (strlen($_path) > 0) {
- $_config_files[] = '/etc/laconica/'.$_server.'_'.$_path.'.php';
+ if (strlen($_path) > 0) {
+ $_config_files[] = '/etc/laconica/'.$_server.'_'.$_path.'.php';
+ }
+
+ $_config_files[] = INSTALLDIR.'/config.php';
}
-$_config_files[] = INSTALLDIR.'/config.php';
-
$_have_a_config = false;
foreach ($_config_files as $_config_file) {
diff --git a/lib/personal.php b/lib/currentuserdesignaction.php
similarity index 56%
rename from lib/personal.php
rename to lib/currentuserdesignaction.php
index f92732375b..7c2520cf67 100644
--- a/lib/personal.php
+++ b/lib/currentuserdesignaction.php
@@ -2,7 +2,7 @@
/**
* Laconica, the distributed open-source microblogging tool
*
- * User profile page
+ * Base class for actions that use the current user's design
*
* PHP version 5
*
@@ -19,11 +19,10 @@
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see .
*
- * @category Personal
+ * @category Action
* @package Laconica
* @author Evan Prodromou
- * @author Sarven Capadisli
- * @copyright 2008-2009 Control Yourself, Inc.
+ * @copyright 2009 Control Yourself, Inc.
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
* @link http://laconi.ca/
*/
@@ -33,28 +32,57 @@ if (!defined('LACONICA')) {
}
/**
- * Base class for user profile page
+ * Base class for actions that use the current user's design
*
- * @category Personal
+ * Some pages (settings in particular) use the current user's chosen
+ * design. This superclass returns that design.
+ *
+ * @category Action
* @package Laconica
* @author Evan Prodromou
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
* @link http://laconi.ca/
+ *
*/
-class PersonalAction extends Action
+class CurrentUserDesignAction extends Action
{
- var $user = null;
+ /**
+ * Show the user's design stylesheet
+ *
+ * @return nothing
+ */
+ function showStylesheets()
+ {
+ parent::showStylesheets();
- function isReadOnly($args)
+ $design = $this->getDesign();
+
+ if (!empty($design)) {
+ $design->showCSS($this);
+ }
+ }
+
+ /**
+ * A design for this action
+ *
+ * if the user attribute has been set, returns that user's
+ * design.
+ *
+ * @return Design a design object to use
+ */
+
+ function getDesign()
{
- return true;
+ $cur = common_current_user();
+
+ if (empty($cur)) {
+ return null;
+ }
+
+ return $cur->getDesign();
}
- function handle($args)
- {
- parent::handle($args);
- }
}
diff --git a/lib/daemon.php b/lib/daemon.php
index 9c1ae50a02..a0df00bdcc 100644
--- a/lib/daemon.php
+++ b/lib/daemon.php
@@ -1,7 +1,7 @@
.
+ *
+ * @category Settings
+ * @package Laconica
+ * @author Sarven Capadisli
+ * @author Zach Copley
+ * @copyright 2008-2009 Control Yourself, Inc.
+ * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
+ * @link http://laconi.ca/
+ */
+
+if (!defined('LACONICA')) {
+ exit(1);
+}
+
+require_once INSTALLDIR . '/lib/accountsettingsaction.php';
+require_once INSTALLDIR . '/lib/webcolor.php';
+
+class DesignSettingsAction extends AccountSettingsAction
+{
+
+ var $submitaction = null;
+
+ /**
+ * Title of the page
+ *
+ * @return string Title of the page
+ */
+
+ function title()
+ {
+ return _('Profile design');
+ }
+
+ /**
+ * Instructions for use
+ *
+ * @return instructions for use
+ */
+
+ function getInstructions()
+ {
+ return _('Customize the way your profile looks ' .
+ 'with a background image and a colour palette of your choice.');
+ }
+
+ function showDesignForm($design)
+ {
+
+ $this->elementStart('form', array('method' => 'post',
+ 'enctype' => 'multipart/form-data',
+ 'id' => 'form_settings_design',
+ 'class' => 'form_settings',
+ 'action' => $this->submitaction));
+ $this->elementStart('fieldset');
+ $this->hidden('token', common_session_token());
+
+ $this->elementStart('fieldset', array('id' =>
+ 'settings_design_background-image'));
+ $this->element('legend', null, _('Change background image'));
+ $this->elementStart('ul', 'form_data');
+ $this->elementStart('li');
+ $this->element('label', array('for' => 'design_background-image_file'),
+ _('Upload file'));
+ $this->element('input', array('name' => 'design_background-image_file',
+ 'type' => 'file',
+ 'id' => 'design_background-image_file'));
+ $this->element('p', 'form_guide', _('You can upload your personal ' .
+ 'background image. The maximum file size is 2Mb.'));
+ $this->element('input', array('name' => 'MAX_FILE_SIZE',
+ 'type' => 'hidden',
+ 'id' => 'MAX_FILE_SIZE',
+ 'value' => ImageFile::maxFileSizeInt()));
+ $this->elementEnd('li');
+
+ if (!empty($design->backgroundimage)) {
+
+ $this->elementStart('li', array('id' => 'design_background-image_onoff'));
+
+ $this->element('img', array('src' =>
+ Design::url($design->backgroundimage)));
+
+ $attrs = array('name' => 'design_background-image_onoff',
+ 'type' => 'radio',
+ 'id' => 'design_background-image_on',
+ 'class' => 'radio',
+ 'value' => 'on');
+
+ if ($design->disposition & BACKGROUND_ON) {
+ $attrs['checked'] = 'checked';
+ }
+
+ $this->element('input', $attrs);
+
+ $this->element('label', array('for' => 'design_background-image_on',
+ 'class' => 'radio'),
+ _('On'));
+
+ $attrs = array('name' => 'design_background-image_onoff',
+ 'type' => 'radio',
+ 'id' => 'design_background-image_off',
+ 'class' => 'radio',
+ 'value' => 'off');
+
+ if ($design->disposition & BACKGROUND_OFF) {
+ $attrs['checked'] = 'checked';
+ }
+
+ $this->element('input', $attrs);
+
+ $this->element('label', array('for' => 'design_background-image_off',
+ 'class' => 'radio'),
+ _('Off'));
+ $this->element('p', 'form_guide', _('Turn background image on or off.'));
+ $this->elementEnd('li');
+ }
+
+ $this->elementStart('li');
+ $this->checkbox('design_background-image_repeat',
+ _('Tile background image'),
+ ($design->disposition & BACKGROUND_TILE) ? true : false );
+ $this->elementEnd('li');
+
+ $this->elementEnd('ul');
+ $this->elementEnd('fieldset');
+
+ $this->elementStart('fieldset', array('id' => 'settings_design_color'));
+ $this->element('legend', null, _('Change colours'));
+ $this->elementStart('ul', 'form_data');
+
+ try {
+
+ $bgcolor = new WebColor($design->backgroundcolor);
+
+ $this->elementStart('li');
+ $this->element('label', array('for' => 'swatch-1'), _('Background'));
+ $this->element('input', array('name' => 'design_background',
+ 'type' => 'text',
+ 'id' => 'swatch-1',
+ 'class' => 'swatch',
+ 'maxlength' => '7',
+ 'size' => '7',
+ 'value' => '#' . $bgcolor->hexValue()));
+ $this->elementEnd('li');
+
+ $ccolor = new WebColor($design->contentcolor);
+
+ $this->elementStart('li');
+ $this->element('label', array('for' => 'swatch-2'), _('Content'));
+ $this->element('input', array('name' => 'design_content',
+ 'type' => 'text',
+ 'id' => 'swatch-2',
+ 'class' => 'swatch',
+ 'maxlength' => '7',
+ 'size' => '7',
+ 'value' => '#' . $ccolor->hexValue()));
+ $this->elementEnd('li');
+
+ $sbcolor = new WebColor($design->sidebarcolor);
+
+ $this->elementStart('li');
+ $this->element('label', array('for' => 'swatch-3'), _('Sidebar'));
+ $this->element('input', array('name' => 'design_sidebar',
+ 'type' => 'text',
+ 'id' => 'swatch-3',
+ 'class' => 'swatch',
+ 'maxlength' => '7',
+ 'size' => '7',
+ 'value' => '#' . $sbcolor->hexValue()));
+ $this->elementEnd('li');
+
+ $tcolor = new WebColor($design->textcolor);
+
+ $this->elementStart('li');
+ $this->element('label', array('for' => 'swatch-4'), _('Text'));
+ $this->element('input', array('name' => 'design_text',
+ 'type' => 'text',
+ 'id' => 'swatch-4',
+ 'class' => 'swatch',
+ 'maxlength' => '7',
+ 'size' => '7',
+ 'value' => '#' . $tcolor->hexValue()));
+ $this->elementEnd('li');
+
+ $lcolor = new WebColor($design->linkcolor);
+
+ $this->elementStart('li');
+ $this->element('label', array('for' => 'swatch-5'), _('Links'));
+ $this->element('input', array('name' => 'design_links',
+ 'type' => 'text',
+ 'id' => 'swatch-5',
+ 'class' => 'swatch',
+ 'maxlength' => '7',
+ 'size' => '7',
+ 'value' => '#' . $lcolor->hexValue()));
+
+ $this->elementEnd('li');
+
+ } catch (WebColorException $e) {
+ common_log(LOG_ERR, 'Bad color values in design ID: ' .
+ $design->id);
+ }
+
+ $this->elementEnd('ul');
+ $this->elementEnd('fieldset');
+
+ $this->element('input', array('id' => 'settings_design_reset',
+ 'type' => 'reset',
+ 'value' => 'Reset',
+ 'class' => 'submit form_action-primary',
+ 'title' => _('Reset back to default')));
+
+ $this->submit('save', _('Save'), 'submit form_action-secondary',
+ 'save', _('Save design'));
+
+ $this->elementEnd('fieldset');
+ $this->elementEnd('form');
+ }
+
+ /**
+ * Handle a post
+ *
+ * Validate input and save changes. Reload the form with a success
+ * or error message.
+ *
+ * @return void
+ */
+
+ function handlePost()
+ {
+ // XXX: Robin's workaround for a bug in PHP where $_POST
+ // and $_FILE are empty in the case that the uploaded
+ // file is bigger than PHP is configured to handle.
+
+ if ($_SERVER['REQUEST_METHOD'] == 'POST') {
+ if (empty($_POST) && $_SERVER['CONTENT_LENGTH']) {
+
+ $msg = _('The server was unable to handle that much POST ' .
+ 'data (%s bytes) due to its current configuration.');
+
+ $this->showForm(sprintf($msg, $_SERVER['CONTENT_LENGTH']));
+ }
+ }
+
+ // CSRF protection
+ $token = $this->trimmed('token');
+ if (!$token || $token != common_session_token()) {
+ $this->showForm(_('There was a problem with your session token. '.
+ 'Try again, please.'));
+ return;
+ }
+
+ if ($this->arg('save')) {
+ $this->saveDesign();
+ } else if ($this->arg('reset')) {
+ $this->resetDesign();
+ } else {
+ $this->showForm(_('Unexpected form submission.'));
+ }
+ }
+
+ /**
+ * Add the Farbtastic stylesheet
+ *
+ * @return void
+ */
+
+ function showStylesheets()
+ {
+ parent::showStylesheets();
+ $farbtasticStyle =
+ common_path('theme/base/css/farbtastic.css?version='.LACONICA_VERSION);
+
+ $this->element('link', array('rel' => 'stylesheet',
+ 'type' => 'text/css',
+ 'href' => $farbtasticStyle,
+ 'media' => 'screen, projection, tv'));
+ }
+
+ /**
+ * Add the Farbtastic scripts
+ *
+ * @return void
+ */
+
+ function showScripts()
+ {
+ parent::showScripts();
+
+ $farbtasticPack = common_path('js/farbtastic/farbtastic.js');
+ $userDesignGo = common_path('js/userdesign.go.js');
+
+ $this->element('script', array('type' => 'text/javascript',
+ 'src' => $farbtasticPack));
+ $this->element('script', array('type' => 'text/javascript',
+ 'src' => $userDesignGo));
+ }
+
+ /**
+ * Get a default user design
+ *
+ * @return Design design
+ */
+
+ function defaultDesign()
+ {
+ $defaults = common_config('site', 'design');
+
+ $design = new Design();
+
+ try {
+
+ $color = new WebColor();
+
+ $color->parseColor($defaults['backgroundcolor']);
+ $design->backgroundcolor = $color->intValue();
+
+ $color->parseColor($defaults['contentcolor']);
+ $design->contentcolor = $color->intValue();
+
+ $color->parseColor($defaults['sidebarcolor']);
+ $design->sidebarcolor = $color->intValue();
+
+ $color->parseColor($defaults['textcolor']);
+ $design->textcolor = $color->intValue();
+
+ $color->parseColor($defaults['linkcolor']);
+ $design->linkcolor = $color->intValue();
+
+ $design->backgroundimage = $defaults['backgroundimage'];
+
+ $design->disposition = $defaults['disposition'];
+
+ } catch (WebColorException $e) {
+ common_log(LOG_ERR, _('Bad default color settings: ' .
+ $e->getMessage()));
+ }
+
+ return $design;
+ }
+
+ function saveBackgroundImage($design) {
+
+ // Now that we have a Design ID we can add a file to the design.
+ // XXX: This is an additional DB hit, but figured having the image
+ // associated with the Design rather than the User was worth
+ // it. -- Zach
+
+ if ($_FILES['design_background-image_file']['error'] ==
+ UPLOAD_ERR_OK) {
+
+ $filepath = null;
+
+ try {
+ $imagefile =
+ ImageFile::fromUpload('design_background-image_file');
+ } catch (Exception $e) {
+ $this->showForm($e->getMessage());
+ return;
+ }
+
+ $filename = Design::filename($design->id,
+ image_type_to_extension($imagefile->type),
+ common_timestamp());
+
+ $filepath = Design::path($filename);
+
+ move_uploaded_file($imagefile->filepath, $filepath);
+
+ $original = clone($design);
+ $design->backgroundimage = $filename;
+ $design->setDisposition(true, false, false);
+ $result = $design->update($original);
+
+ if ($result === false) {
+ common_log_db_error($design, 'UPDATE', __FILE__);
+ $this->showForm(_('Couldn\'t update your design.'));
+ return;
+ }
+ }
+ }
+
+}
diff --git a/lib/error.php b/lib/error.php
index 282682133a..bbf9987cff 100644
--- a/lib/error.php
+++ b/lib/error.php
@@ -13,7 +13,7 @@
* @link http://laconi.ca/
*
* Laconica - a distributed open-source microblogging tool
- * Copyright (C) 2008, Controlez-Vous, Inc.
+ * Copyright (C) 2008, 2009, Control Yourself, Inc.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
diff --git a/lib/facebookutil.php b/lib/facebookutil.php
index 242d2e06f2..4d0df797be 100644
--- a/lib/facebookutil.php
+++ b/lib/facebookutil.php
@@ -1,7 +1,7 @@
.
+ *
+ * @category Action
+ * @package Laconica
+ * @author Zach Copley
+ * @copyright 2009 Control Yourself, Inc.
+ * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
+ * @link http://laconi.ca/
+ */
+
+if (!defined('LACONICA')) {
+ exit(1);
+}
+
+/**
+ * Base class for actions that use a group's design
+ *
+ * Pages related to groups can be themed with a design.
+ * This superclass returns that design.
+ *
+ * @category Action
+ * @package Laconica
+ * @author Zach Copley
+ * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
+ * @link http://laconi.ca/
+ *
+ */
+class GroupDesignAction extends Action {
+
+ /** The group in question */
+ var $group = null;
+
+ /**
+ * Show the groups's design stylesheet
+ *
+ * @return nothing
+ */
+ function showStylesheets()
+ {
+ parent::showStylesheets();
+
+ $design = $this->getDesign();
+
+ if (!empty($design)) {
+ $design->showCSS($this);
+ }
+ }
+
+ /**
+ * A design for this action
+ *
+ * if the group attribute has been set, returns that group's
+ * design.
+ *
+ * @return Design a design object to use
+ */
+
+ function getDesign()
+ {
+
+ if (empty($this->group)) {
+ return null;
+ }
+
+ return $this->group->getDesign();
+ }
+
+}
diff --git a/lib/groupeditform.php b/lib/groupeditform.php
index ca674f3c8e..7e8d6eea3a 100644
--- a/lib/groupeditform.php
+++ b/lib/groupeditform.php
@@ -111,7 +111,6 @@ class GroupEditForm extends Form
}
}
-
/**
* Name of the form
*
@@ -157,6 +156,16 @@ class GroupEditForm extends Form
($this->out->arg('location')) ? $this->out->arg('location') : $this->group->location,
_('Location for the group, if any, like "City, State (or Region), Country"'));
$this->out->elementEnd('li');
+ if (common_config('group', 'maxaliases') > 0) {
+ $aliases = (empty($this->group)) ? array() : $this->group->getAliases();
+ $this->out->elementStart('li');
+ $this->out->input('aliases', _('Aliases'),
+ ($this->out->arg('aliases')) ? $this->out->arg('aliases') :
+ (!empty($aliases)) ? implode(' ', $aliases) : '',
+ sprintf(_('Extra nicknames for the group, comma- or space- separated, max %d'),
+ common_config('group', 'maxaliases')));;
+ $this->out->elementEnd('li');
+ }
$this->out->elementEnd('ul');
}
diff --git a/lib/grouplist.php b/lib/grouplist.php
index 1b85474998..1ded5160bd 100644
--- a/lib/grouplist.php
+++ b/lib/grouplist.php
@@ -166,7 +166,7 @@ class GroupList extends Widget
if ($user->isMember($this->group)) {
$lf = new LeaveForm($this->out, $this->group);
$lf->show();
- } else {
+ } else if (!Group_block::isBlocked($this->group, $user->getProfile())) {
$jf = new JoinForm($this->out, $this->group);
$jf->show();
}
diff --git a/lib/groupnav.php b/lib/groupnav.php
index 90bdc10149..9e530c447c 100644
--- a/lib/groupnav.php
+++ b/lib/groupnav.php
@@ -95,6 +95,12 @@ class GroupNav extends Widget
$cur = common_current_user();
if ($cur && $cur->isAdmin($this->group)) {
+ $this->out->menuItem(common_local_url('blockedfromgroup', array('nickname' =>
+ $nickname)),
+ _('Blocked'),
+ sprintf(_('%s blocked users'), $nickname),
+ $action_name == 'blockedfromgroup',
+ 'nav_group_blocked');
$this->out->menuItem(common_local_url('editgroup', array('nickname' =>
$nickname)),
_('Admin'),
@@ -107,6 +113,12 @@ class GroupNav extends Widget
sprintf(_('Add or edit %s logo'), $nickname),
$action_name == 'grouplogo',
'nav_group_logo');
+ $this->out->menuItem(common_local_url('groupdesignsettings', array('nickname' =>
+ $nickname)),
+ _('Design'),
+ sprintf(_('Add or edit %s design'), $nickname),
+ $action_name == 'groupdesignsettings',
+ 'nav_group_design');
}
$this->out->elementEnd('ul');
}
diff --git a/lib/grouptagcloudsection.php b/lib/grouptagcloudsection.php
index 5d68af28bf..9b7a10f6b9 100644
--- a/lib/grouptagcloudsection.php
+++ b/lib/grouptagcloudsection.php
@@ -32,7 +32,7 @@ if (!defined('LACONICA')) {
}
/**
- * Personal tag cloud section
+ * Group tag cloud section
*
* @category Widget
* @package Laconica
@@ -64,12 +64,27 @@ class GroupTagCloudSection extends TagCloudSection
$weightexpr='sum(exp(-(now() - notice_tag.created) / %s))';
}
+ $names = $this->group->getAliases();
+
+ $names = array_merge(array($this->group->nickname), $names);
+
+ // XXX This is dumb.
+
+ $quoted = array();
+
+ foreach ($names as $name) {
+ $quoted[] = "\"$name\"";
+ }
+
+ $namestring = implode(',', $quoted);
+
$qry = 'SELECT notice_tag.tag, '.
$weightexpr . ' as weight ' .
'FROM notice_tag JOIN notice ' .
'ON notice_tag.notice_id = notice.id ' .
'JOIN group_inbox on group_inbox.notice_id = notice.id ' .
'WHERE group_inbox.group_id = %d ' .
+ 'AND notice_tag.tag not in (%s) '.
'GROUP BY notice_tag.tag ' .
'ORDER BY weight DESC ';
@@ -85,9 +100,9 @@ class GroupTagCloudSection extends TagCloudSection
$tag = Memcached_DataObject::cachedQuery('Notice_tag',
sprintf($qry,
common_config('tag', 'dropoff'),
- $this->group->id),
+ $this->group->id,
+ $namestring),
3600);
return $tag;
}
-
}
diff --git a/lib/mailbox.php b/lib/mailbox.php
index 01bbf5721a..f1f6e98c19 100644
--- a/lib/mailbox.php
+++ b/lib/mailbox.php
@@ -31,8 +31,6 @@ if (!defined('LACONICA')) {
exit(1);
}
-require_once INSTALLDIR.'/lib/personal.php';
-
define('MESSAGES_PER_PAGE', 20);
/**
@@ -47,11 +45,11 @@ define('MESSAGES_PER_PAGE', 20);
* @see OutboxAction
*/
-class MailboxAction extends PersonalAction
+class MailboxAction extends CurrentUserDesignAction
{
var $page = null;
- function prepare($args)
+ function prepare($args)
{
parent::prepare($args);
@@ -265,12 +263,12 @@ class MailboxAction extends PersonalAction
* Returns either the name (and link) of the API client that posted the notice,
* or one of other other channels.
*
- * @param string $source the source of the message
+ * @param string $source the source of the message
*
* @return void
*/
- function showSource($source)
+ function showSource($source)
{
$source_name = _($source);
switch ($source) {
@@ -297,4 +295,17 @@ class MailboxAction extends PersonalAction
return;
}
+ /**
+ * Mailbox actions are read only
+ *
+ * @param array $args other arguments
+ *
+ * @return boolean
+ */
+
+ function isReadOnly($args)
+ {
+ return true;
+ }
+
}
diff --git a/lib/noticeform.php b/lib/noticeform.php
index 3212f382ad..4e2a2edd61 100644
--- a/lib/noticeform.php
+++ b/lib/noticeform.php
@@ -90,7 +90,9 @@ class NoticeForm extends Form
$this->user = common_current_user();
}
- $this->enctype = 'multipart/form-data';
+ if (common_config('attachments', 'uploads')) {
+ $this->enctype = 'multipart/form-data';
+ }
}
/**
@@ -148,12 +150,14 @@ class NoticeForm extends Form
$this->out->element('dd', array('id' => 'notice_text-count'),
'140');
$this->out->elementEnd('dl');
- $this->out->hidden('MAX_FILE_SIZE', common_config('attachments', 'file_quota'));
- $this->out->element('label', array('for' => 'notice_data-attach'), _('Attach'));
- $this->out->element('input', array('id' => 'notice_data-attach',
- 'type' => 'file',
- 'name' => 'attach',
- 'title' => _('Attach a file')));
+ if (common_config('attachments', 'uploads')) {
+ $this->out->element('label', array('for' => 'notice_data-attach'),_('Attach'));
+ $this->out->element('input', array('id' => 'notice_data-attach',
+ 'type' => 'file',
+ 'name' => 'attach',
+ 'title' => _('Attach a file')));
+ $this->out->hidden('MAX_FILE_SIZE', common_config('attachments', 'file_quota'));
+ }
if ($this->action) {
$this->out->hidden('notice_return-to', $this->action, 'returnto');
}
diff --git a/lib/noticelist.php b/lib/noticelist.php
index fadc238a4d..6f05c63d66 100644
--- a/lib/noticelist.php
+++ b/lib/noticelist.php
@@ -50,7 +50,6 @@ require_once INSTALLDIR.'/lib/attachmentlist.php';
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
* @link http://laconi.ca/
* @see Notice
- * @see StreamAction
* @see NoticeListItem
* @see ProfileNoticeList
*/
@@ -180,7 +179,6 @@ class NoticeListItem extends Widget
{
$this->showStart();
$this->showNotice();
- $this->showNoticeAttachments();
$this->showNoticeInfo();
$this->showNoticeOptions();
$this->showEnd();
@@ -194,36 +192,10 @@ class NoticeListItem extends Widget
$this->out->elementEnd('div');
}
- function showNoticeAttachments() {
- if ($this->isUsedInList()) {
- return;
- }
- $al = new AttachmentList($this->notice, $this->out);
- $al->show();
- }
-
- function isUsedInList() {
- return 'shownotice' !== $this->out->args['action'];
- }
-
-/*
- function attachmentCount($discriminant = true) {
- $file_oembed = new File_oembed;
- $query = "select count(*) as c from file_oembed join file_to_post on file_oembed.file_id = file_to_post.file_id where post_id=" . $this->notice->id;
- $file_oembed->query($query);
- $file_oembed->fetch();
- return intval($file_oembed->c);
- }
-*/
-
- function showWithAttachment() {
- }
-
function showNoticeInfo()
{
$this->out->elementStart('div', 'entry-content');
$this->showNoticeLink();
-// $this->showWithAttachment();
$this->showNoticeSource();
$this->showContext();
$this->out->elementEnd('div');
@@ -364,10 +336,6 @@ class NoticeListItem extends Widget
// versions (>> 0.4.x)
$this->out->raw(common_render_content($this->notice->content, $this->notice));
}
- $uploaded = $this->notice->getUploadedAttachment();
- if ($uploaded) {
- $this->out->element('a', array('href' => $uploaded[0], 'class' => 'attachment', 'id' => 'attachment-' . $uploaded[1]), $uploaded[0]);
- }
$this->out->elementEnd('p');
}
diff --git a/lib/oauthstore.php b/lib/oauthstore.php
index 183164e170..f224c6c221 100644
--- a/lib/oauthstore.php
+++ b/lib/oauthstore.php
@@ -1,7 +1,7 @@
.
+ *
+ * @category Action
+ * @package Laconica
+ * @author Evan Prodromou
+ * @copyright 2009 Control Yourself, Inc.
+ * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
+ * @link http://laconi.ca/
+ */
+
+if (!defined('LACONICA')) {
+ exit(1);
+}
+
+/**
+ * Base class for actions that use the page owner's design
+ *
+ * Some pages have a clear "owner" -- like the profile page, subscriptions
+ * pages, etc. This superclass uses that owner's chosen design for the page
+ * design.
+ *
+ * @category Action
+ * @package Laconica
+ * @author Evan Prodromou
+ * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
+ * @link http://laconi.ca/
+ *
+ */
+
+class OwnerDesignAction extends Action {
+
+ /** The user for this page. */
+
+ var $user = null;
+
+ /**
+ * Show the owner's design stylesheet
+ *
+ * @return nothing
+ */
+ function showStylesheets()
+ {
+ parent::showStylesheets();
+
+ $design = $this->getDesign();
+
+ if (!empty($design)) {
+ $design->showCSS($this);
+ }
+ }
+
+ /**
+ * A design for this action
+ *
+ * if the user attribute has been set, returns that user's
+ * design.
+ *
+ * @return Design a design object to use
+ */
+
+ function getDesign()
+ {
+ if (empty($this->user)) {
+ return null;
+ }
+
+ return $this->user->getDesign();
+ }
+}
diff --git a/lib/peoplesearchresults.php b/lib/peoplesearchresults.php
index d3f8408525..9f6696b5f6 100644
--- a/lib/peoplesearchresults.php
+++ b/lib/peoplesearchresults.php
@@ -12,7 +12,7 @@
* @link http://laconi.ca/
*
* Laconica - a distributed open-source microblogging tool
- * Copyright (C) 2008, Controlez-Vous, Inc.
+ * Copyright (C) 2008, 2009, Control Yourself, Inc.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
@@ -56,20 +56,25 @@ class PeopleSearchResults extends ProfileList
function __construct($profile, $terms, $action)
{
- parent::__construct($profile, $terms, $action);
+ parent::__construct($profile, $action);
+
$this->terms = array_map('preg_quote',
array_map('htmlspecialchars', $terms));
+
$this->pattern = '/('.implode('|',$terms).')/i';
}
+ function newProfileItem($profile)
+ {
+ return new PeopleSearchResultItem($profile, $this->action);
+ }
+}
+
+class PeopleSearchResultItem extends ProfileListItem
+{
function highlight($text)
{
return preg_replace($this->pattern, '\\1', htmlspecialchars($text));
}
-
- function isReadOnly($args)
- {
- return true;
- }
}
diff --git a/lib/profileaction.php b/lib/profileaction.php
index a3437ff4dd..2519922b2b 100644
--- a/lib/profileaction.php
+++ b/lib/profileaction.php
@@ -47,9 +47,8 @@ require_once INSTALLDIR.'/lib/groupminilist.php';
* @link http://laconi.ca/
*/
-class ProfileAction extends Action
+class ProfileAction extends OwnerDesignAction
{
- var $user = null;
var $page = null;
var $profile = null;
var $tag = null;
@@ -110,7 +109,7 @@ class ProfileAction extends Action
$this->element('h2', null, _('Subscriptions'));
if ($profile) {
- $pml = new ProfileMiniList($profile, $this->user, $this);
+ $pml = new ProfileMiniList($profile, $this);
$cnt = $pml->show();
if ($cnt == 0) {
$this->element('p', null, _('(None)'));
@@ -139,7 +138,7 @@ class ProfileAction extends Action
$this->element('h2', null, _('Subscribers'));
if ($profile) {
- $pml = new ProfileMiniList($profile, $this->user, $this);
+ $pml = new ProfileMiniList($profile, $this);
$cnt = $pml->show();
if ($cnt == 0) {
$this->element('p', null, _('(None)'));
diff --git a/lib/profilelist.php b/lib/profilelist.php
index a4cc235552..a604230f85 100644
--- a/lib/profilelist.php
+++ b/lib/profilelist.php
@@ -49,25 +49,37 @@ class ProfileList extends Widget
{
/** Current profile, profile query. */
var $profile = null;
- /** Owner of this list */
- var $owner = null;
/** Action object using us. */
var $action = null;
- function __construct($profile, $owner=null, $action=null)
+ function __construct($profile, $action=null)
{
parent::__construct($action);
$this->profile = $profile;
- $this->owner = $owner;
$this->action = $action;
}
function show()
{
+ $this->startList();
+ $cnt = $this->showProfiles();
+ $this->endList();
+ return $cnt;
+ }
+ function startList()
+ {
$this->out->elementStart('ul', 'profiles');
+ }
+ function endList()
+ {
+ $this->out->elementEnd('ul');
+ }
+
+ function showProfiles()
+ {
$cnt = 0;
while ($this->profile->fetch()) {
@@ -75,24 +87,66 @@ class ProfileList extends Widget
if($cnt > PROFILES_PER_PAGE) {
break;
}
- $this->showProfile();
+ $pli = $this->newListItem($this->profile);
+ $pli->show();
}
- $this->out->elementEnd('ul');
-
return $cnt;
}
- function showProfile()
+ function newListItem($profile)
+ {
+ return new ProfileListItem($this->profile, $this->action);
+ }
+}
+
+class ProfileListItem extends Widget
+{
+ /** Current profile. */
+ var $profile = null;
+ /** Action object using us. */
+ var $action = null;
+
+ function __construct($profile, $action)
+ {
+ parent::__construct($action);
+
+ $this->profile = $profile;
+ $this->action = $action;
+ }
+
+ function show()
+ {
+ $this->startItem();
+ $this->showProfile();
+ $this->showActions();
+ $this->endItem();
+ }
+
+ function startItem()
{
$this->out->elementStart('li', array('class' => 'profile',
'id' => 'profile-' . $this->profile->id));
+ }
- $user = common_current_user();
- $is_own = !is_null($user) && isset($this->owner) && ($user->id === $this->owner->id);
+ function showProfile()
+ {
+ $this->startProfile();
+ $this->showAvatar();
+ $this->showFullName();
+ $this->showLocation();
+ $this->showHomepage();
+ $this->showBio();
+ $this->endProfile();
+ }
+ function startProfile()
+ {
$this->out->elementStart('div', 'entity_profile vcard');
+ }
+ function showAvatar()
+ {
$avatar = $this->profile->getAvatar(AVATAR_STREAM_SIZE);
$this->out->elementStart('a', array('href' => $this->profile->profileurl,
'class' => 'url'));
@@ -108,7 +162,10 @@ class ProfileList extends Widget
$this->out->raw($this->highlight($this->profile->nickname));
$this->out->elementEnd('span');
$this->out->elementEnd('a');
+ }
+ function showFullName()
+ {
if (!empty($this->profile->fullname)) {
$this->out->elementStart('dl', 'entity_fn');
$this->out->element('dt', null, 'Full name');
@@ -119,6 +176,10 @@ class ProfileList extends Widget
$this->out->elementEnd('dd');
$this->out->elementEnd('dl');
}
+ }
+
+ function showLocation()
+ {
if (!empty($this->profile->location)) {
$this->out->elementStart('dl', 'entity_location');
$this->out->element('dt', null, _('Location'));
@@ -127,6 +188,10 @@ class ProfileList extends Widget
$this->out->elementEnd('dd');
$this->out->elementEnd('dl');
}
+ }
+
+ function showHomepage()
+ {
if (!empty($this->profile->homepage)) {
$this->out->elementStart('dl', 'entity_url');
$this->out->element('dt', null, _('URL'));
@@ -138,6 +203,10 @@ class ProfileList extends Widget
$this->out->elementEnd('dd');
$this->out->elementEnd('dl');
}
+ }
+
+ function showBio()
+ {
if (!empty($this->profile->bio)) {
$this->out->elementStart('dl', 'entity_note');
$this->out->element('dt', null, _('Note'));
@@ -146,57 +215,33 @@ class ProfileList extends Widget
$this->out->elementEnd('dd');
$this->out->elementEnd('dl');
}
+ }
- # If we're on a list with an owner (subscriptions or subscribers)...
-
- if ($this->owner) {
- # Get tags
- $tags = Profile_tag::getTags($this->owner->id, $this->profile->id);
-
- $this->out->elementStart('dl', 'entity_tags');
- $this->out->elementStart('dt');
- if ($is_own) {
- $this->out->element('a', array('href' => common_local_url('tagother',
- array('id' => $this->profile->id))),
- _('Tags'));
- } else {
- $this->out->text(_('Tags'));
- }
- $this->out->elementEnd('dt');
- $this->out->elementStart('dd');
- if ($tags) {
- $this->out->elementStart('ul', 'tags xoxo');
- foreach ($tags as $tag) {
- $this->out->elementStart('li');
- $this->out->element('span', 'mark_hash', '#');
- $this->out->element('a', array('rel' => 'tag',
- 'href' => common_local_url($this->action->trimmed('action'),
- array('nickname' => $this->owner->nickname,
- 'tag' => $tag))),
- $tag);
- $this->out->elementEnd('li');
- }
- $this->out->elementEnd('ul');
- } else {
- $this->out->text(_('(none)'));
- }
- $this->out->elementEnd('dd');
- $this->out->elementEnd('dl');
- }
-
- if ($is_own) {
- $this->showOwnerControls($this->profile);
- }
-
+ function endProfile()
+ {
$this->out->elementEnd('div');
+ }
+ function showActions()
+ {
+ $this->startActions();
+ $this->showSubscribeButton();
+ $this->endActions();
+ }
+
+ function startActions()
+ {
$this->out->elementStart('div', 'entity_actions');
-
$this->out->elementStart('ul');
+ }
+ function showSubscribeButton()
+ {
// Is this a logged-in user, looking at someone else's
// profile?
+ $user = common_current_user();
+
if (!empty($user) && $this->profile->id != $user->id) {
$this->out->elementStart('li', 'entity_subscribe');
if ($user->isSubscribed($this->profile)) {
@@ -207,33 +252,22 @@ class ProfileList extends Widget
$sf->show();
}
$this->out->elementEnd('li');
- $this->out->elementStart('li', 'entity_block');
- if ($user->id == $this->owner->id) {
- $this->showBlockForm();
- }
- $this->out->elementEnd('li');
}
-
- $this->out->elementEnd('ul');
-
- $this->out->elementEnd('div');
-
- $this->out->elementEnd('li');
}
- /* Override this in subclasses. */
-
- function showOwnerControls($profile)
+ function endActions()
{
- return;
+ $this->out->elementEnd('ul');
+ $this->out->elementEnd('div');
+ }
+
+ function endItem()
+ {
+ $this->out->elementEnd('li');
}
function highlight($text)
{
return htmlspecialchars($text);
}
-
- function showBlockForm()
- {
- }
}
diff --git a/lib/profileminilist.php b/lib/profileminilist.php
index 57496d0e97..09bef6f7c6 100644
--- a/lib/profileminilist.php
+++ b/lib/profileminilist.php
@@ -47,26 +47,20 @@ define('PROFILES_PER_MINILIST', 27);
class ProfileMiniList extends ProfileList
{
- function show()
+ function startList()
{
$this->out->elementStart('ul', 'entities users xoxo');
-
- $cnt = 0;
-
- while ($this->profile->fetch()) {
- $cnt++;
- if($cnt > PROFILES_PER_MINILIST) {
- break;
- }
- $this->showProfile();
- }
-
- $this->out->elementEnd('ul');
-
- return $cnt;
}
- function showProfile()
+ function newListItem($profile)
+ {
+ return new ProfileMiniListItem($profile, $this->action);
+ }
+}
+
+class ProfileMiniListItem extends ProfileListItem
+{
+ function show()
{
$this->out->elementStart('li', 'vcard');
$this->out->elementStart('a', array('title' => $this->profile->getBestName(),
diff --git a/lib/queuehandler.php b/lib/queuehandler.php
index f76f16e073..d5e0150d9c 100644
--- a/lib/queuehandler.php
+++ b/lib/queuehandler.php
@@ -1,7 +1,7 @@
connect('main/'.$a, array('action' => $a));
@@ -131,7 +132,7 @@ class Router
// settings
foreach (array('profile', 'avatar', 'password', 'openid', 'im',
- 'email', 'sms', 'twitter', 'design', 'other') as $s) {
+ 'email', 'sms', 'twitter', 'userdesign', 'other') as $s) {
$m->connect('settings/'.$s, array('action' => $s.'settings'));
}
@@ -164,10 +165,10 @@ class Router
array('action' => 'newnotice'),
array('replyto' => '[A-Za-z0-9_-]+'));
- $m->connect('notice/:notice/file',
- array('action' => 'file'),
+ $m->connect('notice/:notice/file',
+ array('action' => 'file'),
array('notice' => '[0-9]+'));
-
+
$m->connect('notice/:notice',
array('action' => 'shownotice'),
array('notice' => '[0-9]+'));
@@ -222,12 +223,20 @@ class Router
array('nickname' => '[a-zA-Z0-9]+'));
}
- foreach (array('members', 'logo', 'rss') as $n) {
+ foreach (array('members', 'logo', 'rss', 'designsettings') as $n) {
$m->connect('group/:nickname/'.$n,
array('action' => 'group'.$n),
array('nickname' => '[a-zA-Z0-9]+'));
}
+ $m->connect('group/:nickname/blocked',
+ array('action' => 'blockedfromgroup'),
+ array('nickname' => '[a-zA-Z0-9]+'));
+
+ $m->connect('group/:nickname/makeadmin',
+ array('action' => 'makeadmin'),
+ array('nickname' => '[a-zA-Z0-9]+'));
+
$m->connect('group/:id/id',
array('action' => 'groupbyid'),
array('id' => '[0-9]+'));
@@ -342,7 +351,8 @@ class Router
$m->connect('api/favorites/:method/:argument',
array('action' => 'api',
- 'apiaction' => 'favorites'));
+ 'apiaction' => 'favorites',
+ array('method' => '(create|destroy)')));
$m->connect('api/favorites/:argument',
array('action' => 'api',
diff --git a/lib/rssaction.php b/lib/rssaction.php
index eafdbf131d..6f6c9a8cb0 100644
--- a/lib/rssaction.php
+++ b/lib/rssaction.php
@@ -212,6 +212,10 @@ class Rss10Action extends Action
$this->element('sioc:has_creator', array('rdf:resource' => $creator_uri.'#acct'));
$this->element('laconica:postIcon', array('rdf:resource' => $profile->avatarUrl()));
$this->element('cc:licence', array('rdf:resource' => common_config('license', 'url')));
+ if ($notice->reply_to) {
+ $replyurl = common_local_url('shownotice', array('notice' => $notice->reply_to));
+ $this->element('sioc:reply_to', array('rdf:resource' => $replyurl));
+ }
$this->elementEnd('item');
$this->creators[$creator_uri] = $profile;
}
diff --git a/lib/search_engines.php b/lib/search_engines.php
index 7b9dbb6182..772f41883b 100644
--- a/lib/search_engines.php
+++ b/lib/search_engines.php
@@ -1,7 +1,7 @@
table) {
- $this->target->whereAdd('MATCH(content) ' .
- 'AGAINST (\''.addslashes($q).'\' IN BOOLEAN MODE)');
+
+ // Don't show imported notices
+ $this->target->whereAdd('notice.is_local != ' . NOTICE_GATEWAY);
+
if (strtolower($q) != $q) {
+ $this->target->whereAdd("( MATCH(content) AGAINST ('" . addslashes($q) .
+ "' IN BOOLEAN MODE)) OR ( MATCH(content) " .
+ "AGAINST ('" . addslashes(strtolower($q)) .
+ "' IN BOOLEAN MODE))");
+ } else {
$this->target->whereAdd('MATCH(content) ' .
- 'AGAINST (\''.addslashes(strtolower($q)).'\' IN BOOLEAN MODE)', 'OR');
+ 'AGAINST (\''.addslashes($q).'\' IN BOOLEAN MODE)');
}
+
return true;
} else {
throw new ServerException('Unknown table: ' . $this->table);
@@ -131,6 +139,28 @@ class MySQLSearch extends SearchEngine
}
}
+class MySQLLikeSearch extends SearchEngine
+{
+ function query($q)
+ {
+ if ('identica_people' === $this->table) {
+ $qry = sprintf('(nickname LIKE "%%%1$s%%" OR '.
+ ' fullname LIKE "%%%1$s%%" OR '.
+ ' location LIKE "%%%1$s%%" OR '.
+ ' bio LIKE "%%%1$s%%" OR '.
+ ' homepage LIKE "%%%1$s%%")', addslashes($q));
+ } else if ('identica_notices' === $this->table) {
+ $qry = sprintf('content LIKE "%%%1$s%%"', addslashes($q));
+ } else {
+ throw new ServerException('Unknown table: ' . $this->table);
+ }
+
+ $this->target->whereAdd($qry);
+
+ return true;
+ }
+}
+
class PGSearch extends SearchEngine
{
function query($q)
@@ -138,6 +168,9 @@ class PGSearch extends SearchEngine
if ('identica_people' === $this->table) {
return $this->target->whereAdd('textsearch @@ plainto_tsquery(\''.addslashes($q).'\')');
} else if ('identica_notices' === $this->table) {
+
+ // XXX: We need to filter out gateway notices (notice.is_local = -2) --Zach
+
return $this->target->whereAdd('to_tsvector(\'english\', content) @@ plainto_tsquery(\''.addslashes($q).'\')');
} else {
throw new ServerException('Unknown table: ' . $this->table);
diff --git a/lib/searchaction.php b/lib/searchaction.php
index e74450e11f..34fe9373f4 100644
--- a/lib/searchaction.php
+++ b/lib/searchaction.php
@@ -12,7 +12,7 @@
* @link http://laconi.ca/
*
* Laconica - a distributed open-source microblogging tool
- * Copyright (C) 2008, Controlez-Vous, Inc.
+ * Copyright (C) 2008, 2009, Control Yourself, Inc.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
@@ -148,10 +148,10 @@ You can also try your search on other engines:
* [Tweet scan](http://www.tweetscan.com/indexi.php?s=%s)
* [Google](http://www.google.com/search?q=site%%3A%%%%site.server%%%%+%s)
* [Yahoo](http://search.yahoo.com/search?p=site%%3A%%%%site.server%%%%+%s)
-
+* [Collecta](http://collecta.com/#q=%s)
E_O_T
-), $qe, $qe, $qe, $qe);
+), $qe, $qe, $qe, $qe, $qe);
$this->elementStart('dl', array('id' => 'help_search', 'class' => 'help'));
$this->element('dt', null, _('Search help'));
$this->elementStart('dd', 'instructions');
diff --git a/lib/servererroraction.php b/lib/servererroraction.php
index 595dcf1470..db73521668 100644
--- a/lib/servererroraction.php
+++ b/lib/servererroraction.php
@@ -13,7 +13,7 @@
* @link http://laconi.ca/
*
* Laconica - a distributed open-source microblogging tool
- * Copyright (C) 2008, Controlez-Vous, Inc.
+ * Copyright (C) 2008, 2009, Control Yourself, Inc.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
diff --git a/lib/settingsaction.php b/lib/settingsaction.php
index db20c58043..17d3a2f64d 100644
--- a/lib/settingsaction.php
+++ b/lib/settingsaction.php
@@ -43,7 +43,7 @@ if (!defined('LACONICA')) {
* @see Widget
*/
-class SettingsAction extends Action
+class SettingsAction extends CurrentUserDesignAction
{
/**
* A message for the user.
diff --git a/lib/stream.php b/lib/stream.php
deleted file mode 100644
index 0cb9e0bf4f..0000000000
--- a/lib/stream.php
+++ /dev/null
@@ -1,32 +0,0 @@
-.
- */
-
-if (!defined('LACONICA')) { exit(1); }
-
-require_once(INSTALLDIR.'/lib/personal.php');
-require_once(INSTALLDIR.'/lib/noticelist.php');
-
-class StreamAction extends PersonalAction
-{
- function show_notice_list($notice)
- {
- $nl = new NoticeList($notice);
- return $nl->show();
- }
-}
diff --git a/lib/subs.php b/lib/subs.php
index 0e7b9ded52..3bd67b39c7 100644
--- a/lib/subs.php
+++ b/lib/subs.php
@@ -1,7 +1,7 @@
.
+ *
+ * @category Public
+ * @package Laconica
+ * @author Evan Prodromou
+ * @copyright 2008-2009 Control Yourself, Inc.
+ * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
+ * @link http://laconi.ca/
+ */
+
+if (!defined('LACONICA')) {
+ exit(1);
+}
+
+require_once INSTALLDIR.'/lib/profilelist.php';
+
+/**
+ * Widget to show a list of subscriptions
+ *
+ * @category Public
+ * @package Laconica
+ * @author Zach Copley
+ * @author Evan Prodromou
+ * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
+ * @link http://laconi.ca/
+ */
+
+class SubscriptionList extends ProfileList
+{
+ /** Owner of this list */
+ var $owner = null;
+
+ function __construct($profile, $owner=null, $action=null)
+ {
+ parent::__construct($profile, $action);
+
+ $this->owner = $owner;
+ }
+
+ function newListItem($profile)
+ {
+ return new SubscriptionListItem($profile, $this->owner, $this->action);
+ }
+}
+
+class SubscriptionListItem extends ProfileListItem
+{
+ /** Owner of this list */
+ var $owner = null;
+
+ function __construct($profile, $owner, $action)
+ {
+ parent::__construct($profile, $action);
+
+ $this->owner = $owner;
+ }
+
+ function showProfile()
+ {
+ $this->startProfile();
+ $this->showAvatar();
+ $this->showFullName();
+ $this->showLocation();
+ $this->showHomepage();
+ $this->showBio();
+ // Relevant portion!
+ $this->showTags();
+ $this->endProfile();
+ }
+
+ function isOwn()
+ {
+ $user = common_current_user();
+ return (!empty($user) && ($this->owner->id == $user->id));
+ }
+
+ function showTags()
+ {
+ $tags = Profile_tag::getTags($this->owner->id, $this->profile->id);
+
+ $this->out->elementStart('dl', 'entity_tags');
+ $this->out->elementStart('dt');
+ if ($this->isOwn()) {
+ $this->out->element('a', array('href' => common_local_url('tagother',
+ array('id' => $this->profile->id))),
+ _('Tags'));
+ } else {
+ $this->out->text(_('Tags'));
+ }
+ $this->out->elementEnd('dt');
+ $this->out->elementStart('dd');
+ if ($tags) {
+ $this->out->elementStart('ul', 'tags xoxo');
+ foreach ($tags as $tag) {
+ $this->out->elementStart('li');
+ $this->out->element('span', 'mark_hash', '#');
+ $this->out->element('a', array('rel' => 'tag',
+ 'href' => common_local_url($this->action->trimmed('action'),
+ array('nickname' => $this->owner->nickname,
+ 'tag' => $tag))),
+ $tag);
+ $this->out->elementEnd('li');
+ }
+ $this->out->elementEnd('ul');
+ } else {
+ $this->out->text(_('(none)'));
+ }
+ $this->out->elementEnd('dd');
+ $this->out->elementEnd('dl');
+ }
+}
diff --git a/lib/theme.php b/lib/theme.php
index 0d88248227..2fe6ab69b7 100644
--- a/lib/theme.php
+++ b/lib/theme.php
@@ -43,10 +43,14 @@ if (!defined('LACONICA')) {
function theme_file($relative, $theme=null)
{
- if (!$theme) {
+ if (empty($theme)) {
$theme = common_config('site', 'theme');
}
- return INSTALLDIR.'/theme/'.$theme.'/'.$relative;
+ $dir = common_config('theme', 'dir');
+ if (empty($dir)) {
+ $dir = INSTALLDIR.'/theme';
+ }
+ return $dir.'/'.$theme.'/'.$relative;
}
/**
@@ -60,13 +64,31 @@ function theme_file($relative, $theme=null)
function theme_path($relative, $theme=null)
{
- if (!$theme) {
+ if (empty($theme)) {
$theme = common_config('site', 'theme');
}
- $server = common_config('theme', 'server');
- if ($server) {
- return 'http://'.$server.'/'.$theme.'/'.$relative;
- } else {
- return common_path('theme/'.$theme.'/'.$relative);
+
+ $path = common_config('theme', 'path');
+
+ if (empty($path)) {
+ $path = common_config('site', 'path') . '/theme/';
}
+
+ if ($path[strlen($path)-1] != '/') {
+ $path .= '/';
+ }
+
+ if ($path[0] != '/') {
+ $path = '/'.$path;
+ }
+
+ $server = common_config('theme', 'server');
+
+ if (empty($server)) {
+ $server = common_config('site', 'server');
+ }
+
+ // XXX: protocol
+
+ return 'http://'.$server.$path.$theme.'/'.$relative;
}
diff --git a/lib/twitter.php b/lib/twitter.php
index c1d0dc254d..3ec082686a 100644
--- a/lib/twitter.php
+++ b/lib/twitter.php
@@ -1,7 +1,7 @@
init_twitter_atom();
break;
default:
- $this->client_error(_('Not a supported data format.'));
+ $this->clientError(_('Not a supported data format.'));
break;
}
@@ -573,13 +573,13 @@ class TwitterapiAction extends Action
$this->end_twitter_rss();
break;
default:
- $this->client_error(_('Not a supported data format.'));
+ $this->clientError(_('Not a supported data format.'));
break;
}
return;
}
- function client_error($msg, $code = 400, $content_type = 'json')
+ function clientError($msg, $code = 400, $content_type = 'json')
{
static $status = array(400 => 'Bad Request',
@@ -666,7 +666,7 @@ class TwitterapiAction extends Action
$this->show_json_objects($profile_array);
break;
default:
- $this->client_error(_('Not a supported data format.'));
+ $this->clientError(_('Not a supported data format.'));
return;
}
return;
diff --git a/lib/util.php b/lib/util.php
index b3a94a5a01..1af4625167 100644
--- a/lib/util.php
+++ b/lib/util.php
@@ -1,7 +1,7 @@
isMember($group)) {
$attrs = array('href' => $group->permalink(),
'class' => 'url');
@@ -1322,7 +1322,13 @@ function common_session_token()
function common_cache_key($extra)
{
- return 'laconica:' . common_keyize(common_config('site', 'name')) . ':' . $extra;
+ $base_key = common_config('memcached', 'base');
+
+ if (empty($base_key)) {
+ $base_key = common_keyize(common_config('site', 'name'));
+ }
+
+ return 'laconica:' . $base_key . ':' . $extra;
}
function common_keyize($str)
@@ -1371,3 +1377,68 @@ function common_database_tablename($tablename)
//table prefixes could be added here later
return $tablename;
}
+
+function common_shorten_url($long_url)
+{
+ $user = common_current_user();
+ if (empty($user)) {
+ // common current user does not find a user when called from the XMPP daemon
+ // therefore we'll set one here fix, so that XMPP given URLs may be shortened
+ $svc = 'ur1.ca';
+ } else {
+ $svc = $user->urlshorteningservice;
+ }
+
+ $curlh = curl_init();
+ curl_setopt($curlh, CURLOPT_CONNECTTIMEOUT, 20); // # seconds to wait
+ curl_setopt($curlh, CURLOPT_USERAGENT, 'Laconica');
+ curl_setopt($curlh, CURLOPT_RETURNTRANSFER, true);
+
+ switch($svc) {
+ case 'ur1.ca':
+ require_once INSTALLDIR.'/lib/Shorturl_api.php';
+ $short_url_service = new LilUrl;
+ $short_url = $short_url_service->shorten($long_url);
+ break;
+
+ case '2tu.us':
+ $short_url_service = new TightUrl;
+ require_once INSTALLDIR.'/lib/Shorturl_api.php';
+ $short_url = $short_url_service->shorten($long_url);
+ break;
+
+ case 'ptiturl.com':
+ require_once INSTALLDIR.'/lib/Shorturl_api.php';
+ $short_url_service = new PtitUrl;
+ $short_url = $short_url_service->shorten($long_url);
+ break;
+
+ case 'bit.ly':
+ curl_setopt($curlh, CURLOPT_URL, 'http://bit.ly/api?method=shorten&long_url='.urlencode($long_url));
+ $short_url = current(json_decode(curl_exec($curlh))->results)->hashUrl;
+ break;
+
+ case 'is.gd':
+ curl_setopt($curlh, CURLOPT_URL, 'http://is.gd/api.php?longurl='.urlencode($long_url));
+ $short_url = curl_exec($curlh);
+ break;
+ case 'snipr.com':
+ curl_setopt($curlh, CURLOPT_URL, 'http://snipr.com/site/snip?r=simple&link='.urlencode($long_url));
+ $short_url = curl_exec($curlh);
+ break;
+ case 'metamark.net':
+ curl_setopt($curlh, CURLOPT_URL, 'http://metamark.net/api/rest/simple?long_url='.urlencode($long_url));
+ $short_url = curl_exec($curlh);
+ break;
+ case 'tinyurl.com':
+ curl_setopt($curlh, CURLOPT_URL, 'http://tinyurl.com/api-create.php?url='.urlencode($long_url));
+ $short_url = curl_exec($curlh);
+ break;
+ default:
+ $short_url = false;
+ }
+
+ curl_close($curlh);
+
+ return $short_url;
+}
\ No newline at end of file
diff --git a/lib/webcolor.php b/lib/webcolor.php
new file mode 100644
index 0000000000..f3ca6e94a8
--- /dev/null
+++ b/lib/webcolor.php
@@ -0,0 +1,192 @@
+.
+ *
+ * @category Personal
+ * @package Laconica
+ * @author Zach Copley
+ * @copyright 2009 Control Yourself, Inc.
+ * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
+ * @link http://laconi.ca/
+ */
+
+if (!defined('LACONICA')) {
+ exit(1);
+}
+
+class WebColor {
+
+ // XXX: Maybe make getters and setters for r,g,b values and tuples,
+ // e.g.: to support this kinda CSS representation: rgb(255,0,0)
+ // http://www.w3.org/TR/CSS21/syndata.html#color-units
+
+ var $red = 0;
+ var $green = 0;
+ var $blue = 0;
+
+ /**
+ * Constructor
+ *
+ * @return nothing
+ */
+
+ function __construct($color = null)
+ {
+ if (isset($color)) {
+ $this->parseColor($color);
+ }
+ }
+
+ /**
+ * Parses input to and tries to determine whether the color
+ * is being specified via an integer or hex tuple and sets
+ * the RGB instance variables accordingly.
+ *
+ * XXX: Maybe support (r,g,b) style, and array?
+ *
+ * @param mixed $color
+ *
+ * @return nothing
+ */
+
+ function parseColor($color) {
+
+ if (is_numeric($color)) {
+ $this->setIntColor($color);
+ } else {
+
+ // XXX named colors
+
+ // XXX: probably should do even more validation
+
+ if (preg_match('/(#([0-9A-Fa-f]{3,6})\b)/u', $color) > 0) {
+ $this->setHexColor($color);
+ } else {
+ $errmsg = _('%s is not a valid color!');
+ throw new WebColorException(sprintf($errmsg, $color));
+ }
+ }
+ }
+
+ /**
+ * @param string $name
+ *
+ * @return nothing
+ */
+
+ function setNamedColor($name)
+ {
+ // XXX Implement this
+ }
+
+
+ /**
+ * Sets the RGB color values from a a hex tuple
+ *
+ * @param string $hexcolor
+ *
+ * @return nothing
+ */
+
+ function setHexColor($hexcolor) {
+
+ if ($hexcolor[0] == '#') {
+ $hexcolor = substr($hexcolor, 1);
+ }
+
+ if (strlen($hexcolor) == 6) {
+ list($r, $g, $b) = array($hexcolor[0].$hexcolor[1],
+ $hexcolor[2].$hexcolor[3],
+ $hexcolor[4].$hexcolor[5]);
+ } elseif (strlen($hexcolor) == 3) {
+ list($r, $g, $b) = array($hexcolor[0].$hexcolor[0],
+ $hexcolor[1].$hexcolor[1],
+ $hexcolor[2].$hexcolor[2]);
+ } else {
+ $errmsg = _('%s is not a valid color! Use 3 or 6 hex chars.');
+ throw new WebColorException(sprintf($errmsg, $hexcolor));
+ }
+
+ $this->red = hexdec($r);
+ $this->green = hexdec($g);
+ $this->blue = hexdec($b);
+
+ }
+
+ /**
+ * Sets the RGB color values from a 24-bit integer
+ *
+ * @param int $intcolor
+ *
+ * @return nothing
+ */
+
+ function setIntColor($intcolor)
+ {
+ // We could do 32 bit and have an alpha channel because
+ // Sarven wants one real bad, but nah.
+
+ $this->red = $intcolor >> 16;
+ $this->green = $intcolor >> 8 & 0xFF;
+ $this->blue = $intcolor & 0xFF;
+
+ }
+
+ /**
+ * Returns a hex tuple of the RGB color useful for output in HTML
+ *
+ * @return string
+ */
+
+ function hexValue() {
+
+ $hexcolor = (strlen(dechex($this->red)) < 2 ? '0' : '' ) .
+ dechex($this->red);
+ $hexcolor .= (strlen(dechex($this->green)) < 2 ? '0' : '') .
+ dechex($this->green);
+ $hexcolor .= (strlen(dechex($this->blue)) < 2 ? '0' : '') .
+ dechex($this->blue);
+
+ return strtoupper($hexcolor);
+
+ }
+
+ /**
+ * Returns a 24-bit packed integer representation of the RGB color
+ * for convenient storage in the DB
+ *
+ * XXX: probably could just use hexdec() instead
+ *
+ * @return int
+ */
+
+ function intValue()
+ {
+ $intcolor = 256 * 256 * $this->red + 256 * $this->green + $this->blue;
+ return $intcolor;
+ }
+
+}
+
+class WebColorException extends Exception
+{
+}
+
+?>
\ No newline at end of file
diff --git a/lib/xmppqueuehandler.php b/lib/xmppqueuehandler.php
index 91015fd450..a078cd9f7e 100644
--- a/lib/xmppqueuehandler.php
+++ b/lib/xmppqueuehandler.php
@@ -1,7 +1,7 @@
.
+ */
+
+// -*- mode: php -*-
+
+# Abort if called from a web server
+
+if (isset($_SERVER) && array_key_exists('REQUEST_METHOD', $_SERVER)) {
+ print "This script must be run from the command line\n";
+ exit();
+}
+
+define('LACONICA', true);
+
+// Set various flags so we don't time out on long-running processes
+
+ini_set("max_execution_time", "0");
+ini_set("max_input_time", "0");
+set_time_limit(0);
+mb_internal_encoding('UTF-8');
+
+// Add extlib to our path so we can get Console_Getopt
+
+$_extra_path = array(INSTALLDIR.'/extlib/');
+
+set_include_path(implode(PATH_SEPARATOR, $_extra_path) . PATH_SEPARATOR . get_include_path());
+
+require_once 'Console/Getopt.php';
+
+// Note: $shortoptions and $longoptions should be pre-defined!
+
+$_default_shortoptions = 'qvhc:s:p:';
+
+$_default_longoptions = array('quiet', 'verbose', 'help', 'conf=', 'server=', 'path=');
+
+if (isset($shortoptions)) {
+ $shortoptions .= $_default_shortoptions;
+} else {
+ $shortoptions = $_default_shortoptions;
+}
+
+if (isset($longoptions)) {
+ $longoptions = array_merge($longoptions, $_default_longoptions);
+} else {
+ $longoptions = $_default_longoptions;
+}
+
+$parser = new Console_Getopt();
+
+list($options, $args) = $parser->getopt($argv, $shortoptions, $longoptions);
+
+function show_help()
+{
+ global $helptext;
+
+ $_default_help_text = << Use as config file
+ -s --server= Use as server name
+ -p --path= Use as path name
+ -h --help Show this message and quit.
+
+END_OF_DEFAULT;
+ if (isset($helptext)) {
+ print $helptext;
+ }
+ print $_default_help_text;
+ exit(0);
+}
+
+foreach ($options as $option) {
+
+ switch ($option[0]) {
+ case '--server':
+ case 's':
+ $server = $option[1];
+ break;
+
+ case '--path':
+ case 'p':
+ $path = $option[1];
+ break;
+
+ case '--conf':
+ case 'c':
+ $conffile = $option[1];
+ break;
+
+ case '--help':
+ case 'h':
+ show_help();
+ }
+}
+
+require_once INSTALLDIR . '/lib/common.php';
+
+set_error_handler('common_error_handler');
+
+function have_option($str)
+{
+ global $options;
+ foreach ($options as $option) {
+ if ($option[0] == $str) {
+ return true;
+ }
+ }
+ return false;
+}
+
+function get_option_value($str)
+{
+ global $options;
+ foreach ($options as $option) {
+ if ($option[0] == $str) {
+ return $option[1];
+ }
+ }
+ return null;
+}
\ No newline at end of file
diff --git a/scripts/decache.php b/scripts/decache.php
index b18eaa2cd3..90e1ec63c0 100644
--- a/scripts/decache.php
+++ b/scripts/decache.php
@@ -18,35 +18,26 @@
* along with this program. If not, see .
*/
-# Abort if called from a web server
-if (isset($_SERVER) && array_key_exists('REQUEST_METHOD', $_SERVER)) {
- print "This script must be run from the command line\n";
- exit(1);
-}
-
-ini_set("max_execution_time", "0");
-ini_set("max_input_time", "0");
-set_time_limit(0);
-mb_internal_encoding('UTF-8');
-
define('INSTALLDIR', realpath(dirname(__FILE__) . '/..'));
-define('LACONICA', true);
-require_once(INSTALLDIR . '/lib/common.php');
+$helptext = << []
+Clears the cache for the object in table with id
+If is specified, use that instead of 'id'
+ENDOFHELP;
-if ($argc < 3 || $argc > 4) {
- print "USAGE: decache.php []\n";
- print "Clears the cache for the object in table with id .\n\n";
- print "If is specified, use that instead of 'id'\n";
- exit(1);
+require_once INSTALLDIR.'/scripts/commandline.inc';
+
+if (count($args) < 2 || count($args) > 3) {
+ show_help();
}
-$table = $argv[1];
-$id = $argv[2];
-if ($argc > 3) {
- $column = $argv[3];
+$table = $args[0];
+$id = $args[1];
+if (count($args) > 2) {
+ $column = $args[2];
} else {
- $colum = 'id';
+ $column = 'id';
}
$object = Memcached_DataObject::staticGet($table, $column, $id);
diff --git a/scripts/enjitqueuehandler.php b/scripts/enjitqueuehandler.php
index 40f60da5d8..05e1d9366b 100755
--- a/scripts/enjitqueuehandler.php
+++ b/scripts/enjitqueuehandler.php
@@ -2,7 +2,7 @@
.
*/
-# Abort if called from a web server
-if (isset($_SERVER) && array_key_exists('REQUEST_METHOD', $_SERVER)) {
- print "This script must be run from the command line\n";
- exit();
-}
-
define('INSTALLDIR', realpath(dirname(__FILE__) . '/..'));
-define('LACONICA', true);
-require_once(INSTALLDIR . '/lib/common.php');
-require_once(INSTALLDIR . '/lib/mail.php');
-require_once(INSTALLDIR . '/lib/queuehandler.php');
+$shortoptions = 'i::';
+$longoptions = array('id::');
+
+$helptext = << 1) ? $argv[1] : null;
+if (have_option('-i')) {
+ $id = get_option_value('-i');
+} else if (have_option('--id')) {
+ $id = get_option_value('--id');
+} else if (count($args) > 0) {
+ $id = $args[0];
+} else {
+ $id = null;
+}
$handler = new EnjitQueueHandler($id);
diff --git a/scripts/facebookqueuehandler.php b/scripts/facebookqueuehandler.php
index c6859cb219..05a35577fe 100755
--- a/scripts/facebookqueuehandler.php
+++ b/scripts/facebookqueuehandler.php
@@ -2,7 +2,7 @@
.
*/
-# Abort if called from a web server
-if (isset($_SERVER) && array_key_exists('REQUEST_METHOD', $_SERVER)) {
- print "This script must be run from the command line\n";
- exit();
-}
-
define('INSTALLDIR', realpath(dirname(__FILE__) . '/..'));
-define('LACONICA', true);
-require_once(INSTALLDIR . '/lib/common.php');
-require_once(INSTALLDIR . '/lib/facebookutil.php');
-require_once(INSTALLDIR . '/lib/queuehandler.php');
+$shortoptions = 'i::';
+$longoptions = array('id::');
-set_error_handler('common_error_handler');
+$helptext = <<log(LOG_INFO, "INITIALIZE");
@@ -51,20 +52,22 @@ class FacebookQueueHandler extends QueueHandler
{
return facebookBroadcastNotice($notice);
}
-
+
function finish()
{
}
}
-ini_set("max_execution_time", "0");
-ini_set("max_input_time", "0");
-set_time_limit(0);
-
-mb_internal_encoding('UTF-8');
-
-$id = ($argc > 1) ? $argv[1] : null;
+if (have_option('i')) {
+ $id = get_option_value('i');
+} else if (have_option('--id')) {
+ $id = get_option_value('--id');
+} else if (count($args) > 0) {
+ $id = $args[0];
+} else {
+ $id = null;
+}
$handler = new FacebookQueueHandler($id);
diff --git a/scripts/fixup_conversations.php b/scripts/fixup_conversations.php
new file mode 100755
index 0000000000..2cfa422e65
--- /dev/null
+++ b/scripts/fixup_conversations.php
@@ -0,0 +1,67 @@
+#!/usr/bin/env php
+.
+ */
+
+define('INSTALLDIR', realpath(dirname(__FILE__) . '/..'));
+
+require_once INSTALLDIR.'/scripts/commandline.inc';
+
+common_log(LOG_INFO, 'Fixing up conversations.');
+
+$notice = new Notice();
+$notice->whereAdd('conversation is null');
+$notice->orderBy('id');
+
+$cnt = $notice->find();
+
+print "Found $cnt notices.\n";
+
+while ($notice->fetch()) {
+
+ print "$notice->id =>";
+
+ $orig = clone($notice);
+
+ if (empty($notice->reply_to)) {
+ $notice->conversation = $notice->id;
+ } else {
+ $reply = Notice::staticGet('id', $notice->reply_to);
+
+ if (empty($reply)) {
+ common_log(LOG_WARNING, "Replied-to notice $notice->reply_to not found.");
+ $notice->conversation = $notice->id;
+ } else if (empty($reply->conversation)) {
+ common_log(LOG_WARNING, "Replied-to notice $reply->id has no conversation ID.");
+ $notice->conversation = $notice->id;
+ } else {
+ $notice->conversation = $reply->conversation;
+ }
+ }
+
+ print "$notice->conversation";
+
+ $result = $notice->update($orig);
+
+ if (!$result) {
+ common_log_db_error($notice, 'UPDATE', __FILE__);
+ continue;
+ }
+
+ print ".\n";
+}
diff --git a/scripts/fixup_hashtags.php b/scripts/fixup_hashtags.php
index 6f65c78a1f..bd38e31055 100755
--- a/scripts/fixup_hashtags.php
+++ b/scripts/fixup_hashtags.php
@@ -2,7 +2,7 @@
+
+Fixup records in a database that stored the data incorrectly (pre-0.7.4 for Laconica).
+
+ENDOFHELP;
+
+require_once INSTALLDIR.'/scripts/commandline.inc';
+require_once 'DB.php';
class UTF8FixerUpper
{
@@ -356,9 +353,9 @@ class UTF8FixerUpper
}
}
-$max_date = ($argc > 1) ? $argv[1] : null;
-$max_id = ($argc > 2) ? $argv[2] : null;
-$min_id = ($argc > 3) ? $argv[3] : null;
+$max_date = (count($args) > 0) ? $args[0] : null;
+$max_id = (count($args) > 1) ? $args[1] : null;
+$min_id = (count($args) > 2) ? $args[2] : null;
$fixer = new UTF8FixerUpper(array('max_date' => $max_date,
'max_notice' => $max_id,
diff --git a/scripts/getpiddir.php b/scripts/getpiddir.php
index 4f57042493..9927cc6d95 100755
--- a/scripts/getpiddir.php
+++ b/scripts/getpiddir.php
@@ -2,7 +2,7 @@
.
*/
-# Abort if called from a web server
-if (isset($_SERVER) && array_key_exists('REQUEST_METHOD', $_SERVER)) {
- print "This script must be run from the command line\n";
- exit();
-}
-
define('INSTALLDIR', realpath(dirname(__FILE__) . '/..'));
-define('LACONICA', true);
-require_once(INSTALLDIR . '/lib/common.php');
+$helptext = <<
-$id_file = ($argc > 1) ? $argv[1] : 'ids.txt';
+Update users to use inbox table. Listed in an ID file, default 'ids.txt'.
+
+ENDOFHELP;
+
+require_once INSTALLDIR.'/scripts/commandline.inc';
+
+$id_file = (count($args) > 1) ? $args[0] : 'ids.txt';
common_log(LOG_INFO, 'Updating user inboxes.');
$ids = file($id_file);
foreach ($ids as $id) {
-
+
$user = User::staticGet('id', $id);
if (!$user) {
common_log(LOG_WARNING, 'No such user: ' . $id);
continue;
}
-
+
if ($user->inboxed) {
common_log(LOG_WARNING, 'Already inboxed: ' . $id);
continue;
}
-
+
common_log(LOG_INFO, 'Updating inbox for user ' . $user->id);
-
+
$user->query('BEGIN');
-
+
$old_inbox = new Notice_inbox();
$old_inbox->user_id = $user->id;
-
+
$result = $old_inbox->delete();
-
+
if (is_null($result) || $result === false) {
common_log_db_error($old_inbox, 'DELETE', __FILE__);
continue;
}
$old_inbox->free();
-
+
$inbox = new Notice_inbox();
-
+
$result = $inbox->query('INSERT INTO notice_inbox (user_id, notice_id, created) ' .
'SELECT ' . $user->id . ', notice.id, notice.created ' .
'FROM subscription JOIN notice ON subscription.subscribed = notice.profile_id ' .
@@ -80,30 +76,30 @@ foreach ($ids as $id) {
'AND notice.created >= subscription.created ' .
'AND NOT EXISTS (SELECT user_id, notice_id ' .
'FROM notice_inbox ' .
- 'WHERE user_id = ' . $user->id . ' ' .
+ 'WHERE user_id = ' . $user->id . ' ' .
'AND notice_id = notice.id) ' .
'ORDER BY notice.created DESC ' .
'LIMIT 0, 1000');
-
+
if (is_null($result) || $result === false) {
common_log_db_error($inbox, 'INSERT', __FILE__);
continue;
}
-
+
$orig = clone($user);
$user->inboxed = 1;
$result = $user->update($orig);
-
+
if (!$result) {
common_log_db_error($user, 'UPDATE', __FILE__);
continue;
}
-
+
$user->query('COMMIT');
-
+
$inbox->free();
unset($inbox);
-
+
if ($cache) {
$cache->delete(common_cache_key('user:notices_with_friends:' . $user->id));
$cache->delete(common_cache_key('user:notices_with_friends:' . $user->id . ';last'));
diff --git a/scripts/jabberqueuehandler.php b/scripts/jabberqueuehandler.php
index 8b6e974c0a..a449932364 100755
--- a/scripts/jabberqueuehandler.php
+++ b/scripts/jabberqueuehandler.php
@@ -2,7 +2,7 @@
.
*/
-# Abort if called from a web server
-if (isset($_SERVER) && array_key_exists('REQUEST_METHOD', $_SERVER)) {
- print "This script must be run from the command line\n";
- exit();
-}
-
define('INSTALLDIR', realpath(dirname(__FILE__) . '/..'));
-define('LACONICA', true);
-require_once(INSTALLDIR . '/lib/common.php');
-require_once(INSTALLDIR . '/lib/jabber.php');
-require_once(INSTALLDIR . '/lib/xmppqueuehandler.php');
+$shortoptions = 'r::';
+$longoptions = array('resource::');
-set_error_handler('common_error_handler');
+$helptext = << 1) ? $argv[1] : (common_config('xmpp','resource') . '-queuehandler');
+if (have_option('r')) {
+ $resource = get_option_value('r');
+} else if (have_option('--resource')) {
+ $resource = get_option_value('--resource');
+} else if (count($args) > 0) {
+ $resource = $args[0];
+} else {
+ $resource = null;
+}
$handler = new JabberQueueHandler($resource);
diff --git a/scripts/maildaemon.php b/scripts/maildaemon.php
index b9facec1a5..cfb11a36fc 100755
--- a/scripts/maildaemon.php
+++ b/scripts/maildaemon.php
@@ -2,7 +2,7 @@
.
*/
-# Abort if called from a web server
-if (isset($_SERVER) && array_key_exists('REQUEST_METHOD', $_SERVER)) {
- print "This script must be run from the command line\n";
- exit();
-}
-
define('INSTALLDIR', realpath(dirname(__FILE__) . '/..'));
-define('LACONICA', true);
-require_once(INSTALLDIR . '/lib/common.php');
+$helptext = <<cleanup_msg($msg);
- $this->add_notice($user, $msg);
+ $err = $this->add_notice($user, $msg);
+ if (is_string($err)) {
+ $this->error($from, $err);
+ return false;
+ } else {
+ return true;
+ }
}
function error($from, $msg)
@@ -130,17 +135,15 @@ class MailerDaemon
function add_notice($user, $msg)
{
- // should test
- // $msg_shortened = common_shorten_links($msg);
- // if (mb_strlen($msg_shortened) > 140) ERROR and STOP
$notice = Notice::saveNew($user->id, $msg, 'mail');
if (is_string($notice)) {
$this->log(LOG_ERR, $notice);
- return;
+ return $notice;
}
common_broadcast_notice($notice);
$this->log(LOG_INFO,
'Added notice ' . $notice->id . ' from user ' . $user->nickname);
+ return true;
}
function parse_message($fname)
diff --git a/scripts/ombqueuehandler.php b/scripts/ombqueuehandler.php
index cdcea51dc7..1587192b6f 100755
--- a/scripts/ombqueuehandler.php
+++ b/scripts/ombqueuehandler.php
@@ -2,7 +2,7 @@
.
*/
-# Abort if called from a web server
-if (isset($_SERVER) && array_key_exists('REQUEST_METHOD', $_SERVER)) {
- print "This script must be run from the command line\n";
- exit();
-}
-
define('INSTALLDIR', realpath(dirname(__FILE__) . '/..'));
-define('LACONICA', true);
-require_once(INSTALLDIR . '/lib/common.php');
-require_once(INSTALLDIR . '/lib/omb.php');
-require_once(INSTALLDIR . '/lib/queuehandler.php');
+$shortoptions = 'i::';
+$longoptions = array('id::');
+
+$helptext = <<log(LOG_INFO, "INITIALIZE");
@@ -56,7 +60,7 @@ class OmbQueueHandler extends QueueHandler
return omb_broadcast_remote_subscribers($notice);
}
}
-
+
function finish()
{
}
@@ -68,12 +72,15 @@ class OmbQueueHandler extends QueueHandler
}
}
-ini_set("max_execution_time", "0");
-ini_set("max_input_time", "0");
-set_time_limit(0);
-mb_internal_encoding('UTF-8');
-
-$id = ($argc > 1) ? $argv[1] : null;
+if (have_option('i')) {
+ $id = get_option_value('i');
+} else if (have_option('--id')) {
+ $id = get_option_value('--id');
+} else if (count($args) > 0) {
+ $id = $args[0];
+} else {
+ $id = null;
+}
$handler = new OmbQueueHandler($id);
diff --git a/scripts/pingqueuehandler.php b/scripts/pingqueuehandler.php
index ada6ecdba2..23678ea4b5 100644
--- a/scripts/pingqueuehandler.php
+++ b/scripts/pingqueuehandler.php
@@ -2,7 +2,7 @@
.
*/
-# Abort if called from a web server
-if (isset($_SERVER) && array_key_exists('REQUEST_METHOD', $_SERVER)) {
- print "This script must be run from the command line\n";
- exit();
-}
-
define('INSTALLDIR', realpath(dirname(__FILE__) . '/..'));
-define('LACONICA', true);
-require_once(INSTALLDIR . '/lib/common.php');
-require_once(INSTALLDIR . '/lib/ping.php');
-require_once(INSTALLDIR . '/lib/queuehandler.php');
+$shortoptions = 'i::';
+$longoptions = array('id::');
-set_error_handler('common_error_handler');
+$helptext = << 1) ? $argv[1] : NULL;
+if (have_option('i')) {
+ $id = get_option_value('i');
+} else if (have_option('--id')) {
+ $id = get_option_value('--id');
+} else if (count($args) > 0) {
+ $id = $args[0];
+} else {
+ $id = null;
+}
$handler = new PingQueueHandler($id);
diff --git a/scripts/publicqueuehandler.php b/scripts/publicqueuehandler.php
index b0fa22d438..58ecc1745e 100755
--- a/scripts/publicqueuehandler.php
+++ b/scripts/publicqueuehandler.php
@@ -2,7 +2,7 @@
.
*/
-# Abort if called from a web server
-if (isset($_SERVER) && array_key_exists('REQUEST_METHOD', $_SERVER)) {
- print "This script must be run from the command line\n";
- exit();
-}
-
define('INSTALLDIR', realpath(dirname(__FILE__) . '/..'));
-define('LACONICA', true);
-require_once(INSTALLDIR . '/lib/common.php');
-require_once(INSTALLDIR . '/lib/jabber.php');
-require_once(INSTALLDIR . '/lib/xmppqueuehandler.php');
+$shortoptions = 'r::';
+$longoptions = array('resource::');
-set_error_handler('common_error_handler');
+$helptext = << 1) ? $argv[1] : (common_config('xmpp','resource') . '-public');
+if (have_option('r')) {
+ $resource = get_option_value('r');
+} else if (have_option('--resource')) {
+ $resource = get_option_value('--resource');
+} else if (count($args) > 0) {
+ $resource = $args[0];
+} else {
+ $resource = null;
+}
$handler = new PublicQueueHandler($resource);
diff --git a/scripts/reportsnapshot.php b/scripts/reportsnapshot.php
index e332d856c0..c644b557f0 100644
--- a/scripts/reportsnapshot.php
+++ b/scripts/reportsnapshot.php
@@ -18,20 +18,13 @@
* along with this program. If not, see .
*/
-# Abort if called from a web server
-if (isset($_SERVER) && array_key_exists('REQUEST_METHOD', $_SERVER)) {
- print "This script must be run from the command line\n";
- exit(1);
-}
-
-ini_set("max_execution_time", "0");
-ini_set("max_input_time", "0");
-set_time_limit(0);
-mb_internal_encoding('UTF-8');
-
define('INSTALLDIR', realpath(dirname(__FILE__) . '/..'));
-define('LACONICA', true);
-require_once(INSTALLDIR . '/lib/common.php');
+$helptext = <<.
*/
-# Abort if called from a web server
-if (isset($_SERVER) && array_key_exists('REQUEST_METHOD', $_SERVER)) {
- print "This script must be run from the command line\n";
- exit(1);
-}
-
-ini_set("max_execution_time", "0");
-ini_set("max_input_time", "0");
-set_time_limit(0);
-mb_internal_encoding('UTF-8');
-
define('INSTALLDIR', realpath(dirname(__FILE__) . '/..'));
-define('LACONICA', true);
-require_once(INSTALLDIR . '/lib/common.php');
+$helptext = <<
-if ($argc != 3) {
- print "USAGE: setpassword.php \n";
- print "Sets the password of user with name to \n";
- exit(1);
+Sets the password of user with name to
+
+END_OF_PASSWORD_HELP;
+
+require_once INSTALLDIR.'/scripts/commandline.inc';
+
+if (count($args) < 2) {
+ show_help();
}
-$nickname = $argv[1];
-$password = $argv[2];
+$nickname = $args[0];
+$password = $args[1];
if (mb_strlen($password) < 6) {
print "Password must be 6 characters or more.\n";
diff --git a/scripts/setup.cfg.sample b/scripts/setup.cfg.sample
new file mode 100644
index 0000000000..dd3c2705fc
--- /dev/null
+++ b/scripts/setup.cfg.sample
@@ -0,0 +1,13 @@
+# CONFIGURATION FILE for setup_status_network.sh
+
+# Base database name; full name will include nickname
+
+export DBHOST=masterdb.example.net
+export DBBASE=_example_net
+export USERBASE=_example_net
+export ADMIN=root
+export ADMINPASS=yourpassword
+export SITEDB=example_net_site
+export AVATARBASE=/var/www/avatar.example.net
+export PWDGEN="pwgen 20"
+
diff --git a/scripts/setup_status_network.sh b/scripts/setup_status_network.sh
new file mode 100755
index 0000000000..29ee010ed9
--- /dev/null
+++ b/scripts/setup_status_network.sh
@@ -0,0 +1,30 @@
+#!/bin/bash
+
+source ./setup.cfg
+
+export nickname=$1
+export sitename=$2
+
+export password=`$PWDGEN`
+export database=$nickname$DBBASE
+export username=$nickname$USERBASE
+
+# Create the db
+
+mysqladmin -h $DBHOST -u $ADMIN --password=$ADMINPASS create $database
+
+for f in laconica.sql innodb.sql sms_carrier.sql foreign_services.sql notice_source.sql; do
+ mysql -h $DBHOST -u $ADMIN --password=$ADMINPASS $database < ../db/$f;
+done
+
+mysql -h $DBHOST -u $ADMIN --password=$ADMINPASS $SITEDB << ENDOFCOMMANDS
+
+GRANT INSERT,SELECT,UPDATE,DELETE ON $database.* TO '$username'@'localhost' IDENTIFIED BY '$password';
+GRANT INSERT,SELECT,UPDATE,DELETE ON $database.* TO '$username'@'%' IDENTIFIED BY '$password';
+INSERT INTO status_network (nickname, dbhost, dbuser, dbpass, dbname, sitename, created)
+VALUES ('$nickname', '$DBHOST', '$username', '$password', '$database', '$sitename', now());
+
+ENDOFCOMMANDS
+
+mkdir $AVATARBASE/$nickname
+chmod a+w $AVATARBASE/$nickname
diff --git a/scripts/sitemap.php b/scripts/sitemap.php
index 39eb859bba..88ca2ba7aa 100755
--- a/scripts/sitemap.php
+++ b/scripts/sitemap.php
@@ -1,10 +1,37 @@
+#!/usr/bin/env php
.
+ */
define('INSTALLDIR', realpath(dirname(__FILE__) . '/..'));
-define('LACONICA', true);
-require_once(INSTALLDIR . '/lib/common.php');
-require_once(INSTALLDIR . '/lib/util.php');
+$shortoptions = 'f:d:u:';
+
+$helptext = << Use as output file
+ -d Use for new sitemaps
+ -u Use as root for URLs
+
+END_OF_SITEMAP_HELP;
+
+require_once INSTALLDIR . '/scripts/commandline.inc';
$output_paths = parse_args();
@@ -13,11 +40,11 @@ notices_map();
user_map();
index_map();
-# ------------------------------------------------------------------------------
-# Main functions: get data out and turn them into sitemaps
-# ------------------------------------------------------------------------------
+// ------------------------------------------------------------------------------
+// Main functions: get data out and turn them into sitemaps
+// ------------------------------------------------------------------------------
-# Generate index sitemap of all other sitemaps.
+// Generate index sitemap of all other sitemaps.
function index_map()
{
global $output_paths;
@@ -26,7 +53,7 @@ function index_map()
foreach (glob("$output_dir*.xml") as $file_name) {
- # Just the file name please.
+ // Just the file name please.
$file_name = preg_replace("|$output_dir|", '', $file_name);
$index_urls .= sitemap(
@@ -40,7 +67,7 @@ function index_map()
write_file($output_paths['index_file'], sitemapindex($index_urls));
}
-# Generate sitemap of standard site elements.
+// Generate sitemap of standard site elements.
function standard_map()
{
global $output_paths;
@@ -61,7 +88,7 @@ function standard_map()
)
);
- $docs = array('about', 'faq', 'contact', 'im', 'openid', 'openmublog',
+ $docs = array('about', 'faq', 'contact', 'im', 'openid', 'openmublog',
'privacy', 'source', 'badge');
foreach($docs as $title) {
@@ -79,7 +106,7 @@ function standard_map()
write_file($urlset_path, urlset($standard_map_urls));
}
-# Generate sitemaps of all notices.
+// Generate sitemaps of all notices.
function notices_map()
{
global $output_paths;
@@ -93,14 +120,14 @@ function notices_map()
while ($notices->fetch()) {
- # Maximum 50,000 URLs per sitemap file.
+ // Maximum 50,000 URLs per sitemap file.
if ($notice_count == 50000) {
$notice_count = 0;
$map_count++;
}
- # remote notices have an URL
-
+ // remote notices have an URL
+
if (!$notices->url && $notices->uri) {
$notice = array(
'url' => ($notices->uri) ? $notices->uri : common_local_url('shownotice', array('notice' => $notices->id)),
@@ -114,11 +141,11 @@ function notices_map()
}
}
- # Make full sitemaps from the lists and save them.
+ // Make full sitemaps from the lists and save them.
array_to_map($notice_list, 'notice');
}
-# Generate sitemaps of all users.
+// Generate sitemaps of all users.
function user_map()
{
global $output_paths;
@@ -132,7 +159,7 @@ function user_map()
while ($users->fetch()) {
- # Maximum 50,000 URLs per sitemap file.
+ // Maximum 50,000 URLs per sitemap file.
if ($user_count == 50000) {
$user_count = 0;
$map_count++;
@@ -140,7 +167,7 @@ function user_map()
$user_args = array('nickname' => $users->nickname);
- # Define parameters for generating elements.
+ // Define parameters for generating elements.
$user = array(
'url' => common_local_url('showstream', $user_args),
'changefreq' => 'daily',
@@ -183,8 +210,8 @@ function user_map()
'priority' => '0.5',
);
- # Construct a element for each user facet and add it
- # to our existing list of those.
+ // Construct a element for each user facet and add it
+ // to our existing list of those.
$user_list[$map_count] .= url($user);
$user_rss_list[$map_count] .= url($user_rss);
$all_list[$map_count] .= url($all);
@@ -196,9 +223,9 @@ function user_map()
$user_count++;
}
- # Make full sitemaps from the lists and save them.
- # Possible factoring: put all the lists into a master array, thus allowing
- # calling with single argument (i.e., array_to_map('user')).
+ // Make full sitemaps from the lists and save them.
+ // Possible factoring: put all the lists into a master array, thus allowing
+ // calling with single argument (i.e., array_to_map('user')).
array_to_map($user_list, 'user');
array_to_map($user_rss_list, 'user_rss');
array_to_map($all_list, 'all');
@@ -208,14 +235,14 @@ function user_map()
array_to_map($foaf_list, 'foaf');
}
-# ------------------------------------------------------------------------------
-# XML generation functions
-# ------------------------------------------------------------------------------
+// ------------------------------------------------------------------------------
+// XML generation functions
+// ------------------------------------------------------------------------------
-# Generate a element.
+// Generate a element.
function url($url_args)
{
- $url = preg_replace('/&/', '&', $url_args['url']); # escape ampersands for XML
+ $url = preg_replace('/&/', '&', $url_args['url']); // escape ampersands for XML
$lastmod = $url_args['lastmod'];
$changefreq = $url_args['changefreq'];
$priority = $url_args['priority'];
@@ -246,7 +273,7 @@ function url($url_args)
function sitemap($sitemap_args)
{
- $url = preg_replace('/&/', '&', $sitemap_args['url']); # escape ampersands for XML
+ $url = preg_replace('/&/', '&', $sitemap_args['url']); // escape ampersands for XML
$lastmod = $sitemap_args['lastmod'];
if (is_null($url)) {
@@ -265,7 +292,7 @@ function sitemap($sitemap_args)
return $sitemap_out;
}
-# Generate a element.
+// Generate a element.
function urlset($urlset_text)
{
$urlset = '' . "\n" .
@@ -276,7 +303,7 @@ function urlset($urlset_text)
return $urlset;
}
-# Generate a element.
+// Generate a element.
function sitemapindex($sitemapindex_text)
{
$sitemapindex = '' . "\n" .
@@ -287,49 +314,31 @@ function sitemapindex($sitemapindex_text)
return $sitemapindex;
}
-# Generate a sitemap from an array containing elements and write it to a file.
+// Generate a sitemap from an array containing elements and write it to a file.
function array_to_map($url_list, $filename_prefix)
{
global $output_paths;
if ($url_list) {
- # $map_urls is a long string containing concatenated elements.
+ // $map_urls is a long string containing concatenated elements.
while (list($map_idx, $map_urls) = each($url_list)) {
$urlset_path = $output_paths['output_dir'] . "$filename_prefix-$map_idx.xml";
-
+
write_file($urlset_path, urlset($map_urls));
}
}
}
-# ------------------------------------------------------------------------------
-# Internal functions
-# ------------------------------------------------------------------------------
+// ------------------------------------------------------------------------------
+// Internal functions
+// ------------------------------------------------------------------------------
-# Parse command line arguments.
+// Parse command line arguments.
function parse_args()
{
- $args = getopt('f:d:u:');
-
- if (is_null($args[f]) && is_null($args[d]) && is_null($args[u])) {
- error('Mandatory arguments: -f -d