Skip to content

Commit

Permalink
Merge branch 'onphp-master' into pinba
Browse files Browse the repository at this point in the history
Conflicts:
	doc/ChangeLog
  • Loading branch information
dovg committed Sep 30, 2011
2 parents 381fd7f + 9df89c5 commit 8fb5b87
Show file tree
Hide file tree
Showing 20 changed files with 1,099 additions and 180 deletions.
4 changes: 2 additions & 2 deletions core/Form/Filter.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ public static function textImport()
{
return
FilterChain::create()->
add(Filter::trim())->
add(Filter::stripTags());
add(Filter::stripTags())->
add(Filter::trim());
}

/**
Expand Down
3 changes: 3 additions & 0 deletions core/Form/Primitives/PrimitiveString.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ public function import($scope)
if (!BasePrimitive::import($scope))
return null;

if (!is_scalar($scope[$this->name]) || is_bool($scope[$this->name]))
return false;

$this->value = (string) $scope[$this->name];

$this->selfFilter();
Expand Down
38 changes: 31 additions & 7 deletions doc/ChangeLog
Original file line number Diff line number Diff line change
@@ -1,11 +1,35 @@
2011-07-20 Evgeny V. Kokovikhin
2011-09-29 Alexander A. Zaytsev

* core/Cache/Memcached.class.php, core/Cache/PeclMemcached.class.php,
core/DB/PgSQL.class.php, global.inc.php.tpl,
main/Monitoring/PinbaClient.class.php, main/Monitoring/PinbedMemcached.class.php,
main/Monitoring/PinbedPeclMemcached.class.php,
main/Monitoring/PinbedPgSQL.class.php: wrapper for pinba added.
see http://pinba.org/wiki/Main_Page for details
* main/Flow/EmptyGifView.class.php: view with hardcoded empty gif 1x1 image.

2011-09-14 Alexander A. Zaytsev

* core/Form/Primitives/PrimitiveString.class.php: import only scalar values,
except bool.

* core/Form/Filter.class.php: fix filter order in Filter::textImport().

2011-09-01 Sergey S. Sergeev

* main/Utils/AMQP/AMQPQueueConsumer.class.php,
main/Utils/AMQP/AMQPConsumer.class.php,
main/Utils/AMQP/AMQPDefaultConsumer.class.php,
main/Utils/AMQP/AMQPChannelInterface.class.php,
main/Utils/AMQP/Pecl/AMQPPeclChannel.class.php:
consumer logic implemented, phpDoc updated.

* main/Utils/AMQP/AMQPIncomingMessage.class.php: typo fixed.

2011-08-26 Sergey S. Sergeev

* main/Utils/AMQP/AMQPChannelInterface.class.php,
main/Utils/AMQP/AMQPBaseChannel.class.php, main/Utils/AMQP/AMQP.class.php,
main/Utils/AMQP/Pecl/AMQPPeclChannel.class.php,
main/Utils/AMQP/Pecl/AMQPPecl.class.php, main/Utils/AMQP/Exceptions:
extract AMQPChannelInterface, all channel classes implements
AMQPChannelInterface; methods returns an instance of AMQPChannelInterface;
throws AMQPServerException, AMQPServerConnectionException if RabbitMQ
is down OR connection is not available.

2011-08-18 Evgeny V. Kokovikhin

Expand Down
2 changes: 2 additions & 0 deletions global.inc.php.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,8 @@
.ONPHP_MAIN_PATH.'Utils'.DIRECTORY_SEPARATOR.'AMQP'.PATH_SEPARATOR
.ONPHP_MAIN_PATH.'Utils'.DIRECTORY_SEPARATOR.'AMQP'
.DIRECTORY_SEPARATOR.'Pecl'.PATH_SEPARATOR
.ONPHP_MAIN_PATH.'Utils'.DIRECTORY_SEPARATOR.'AMQP'
.DIRECTORY_SEPARATOR.'Exceptions'.PATH_SEPARATOR

.ONPHP_MAIN_PATH.'Messages' .PATH_SEPARATOR
.ONPHP_MAIN_PATH.'Messages'.DIRECTORY_SEPARATOR.'Interface'.PATH_SEPARATOR
Expand Down
43 changes: 43 additions & 0 deletions main/Flow/EmptyGifView.class.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<?php
/***************************************************************************
* Copyright (C) 2011 by Alexander A. Zaytsev *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU Lesser General Public License as *
* published by the Free Software Foundation; either version 3 of the *
* License, or (at your option) any later version. *
* *
***************************************************************************/

/**
* @ingroup Flow
**/
final class EmptyGifView implements View
{
/**
* @return EmptyGifView
**/
public static function create()
{
return new self;
}

/**
* @return EmptyGifView
**/
public function render(/* Model */ $model = null)
{
header('Content-Type: image/gif');
header('Content-Length: 43');
header('Accept-Ranges: none');

// NOTE: this is hardcoded empty gif 1x1 image
print
"GIF89\x61\x01\x00\x01\x00\x80\x00\x00\xff\xff\xff\x00"
."\x00\x00\x21\xf9\x04\x01\x00\x00\x00\x00\x2c\x00\x00\x00"
."\x00\x01\x00\x01\x00\x00\x02\x02\x44\x01\x00\x3b";

return $this;
}
}
?>
22 changes: 15 additions & 7 deletions main/Utils/AMQP/AMQP.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,27 +22,32 @@ abstract class AMQP
protected $link = null;

/**
* @var array of AMQPBaseChannel instances
* @var array of AMQPChannelInterface instances
**/
protected $channels = array();

/**
* @return boolean
* @return AMQP
**/
abstract public function connect();

/**
* @return bolean
* @return AMQP
**/
abstract public function disconnect();

/**
* @return AMQP
**/
abstract public function reconnect();

/**
* @return boolean
**/
abstract public function isConnected();

/**
* @return AMQPBaseChannel
* @return AMQPChannelInterface
*/
abstract protected function spawnChannel($id, AMQP $transport);

Expand All @@ -66,6 +71,9 @@ public static function spawn($class, AMQPCredentials $credentials)
return new $class($credentials);
}

/**
* @return AMQP
**/
public function getLink()
{
return $this->link;
Expand All @@ -74,7 +82,7 @@ public function getLink()
/**
* @param integer $id
* @throws WrongArgumentException
* @return AMQPBaseChannel
* @return AMQPChannelInterface
**/
public function createChannel($id)
{
Expand All @@ -97,7 +105,7 @@ public function createChannel($id)

/**
* @throws MissingElementException
* @return AMQPBaseChannel
* @return AMQPChannelInterface
**/
public function getChannel($id)
{
Expand All @@ -120,7 +128,7 @@ public function getChannelList()
/**
* @param integer $id
* @throws MissingElementException
* @return AMQPBaseChannel
* @return AMQPChannelInterface
**/
public function dropChannel($id)
{
Expand Down
87 changes: 22 additions & 65 deletions main/Utils/AMQP/AMQPBaseChannel.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
/**
* Base class modelling an AMQ channel
**/
abstract class AMQPBaseChannel
abstract class AMQPBaseChannel implements AMQPChannelInterface
{
protected $id = null;

Expand All @@ -21,76 +21,18 @@ abstract class AMQPBaseChannel
**/
protected $transport = null;

abstract public function isOpen();
abstract public function open();
abstract public function close();

/**
* @return boolean
**/
abstract public function exchangeDeclare(
$name, AMQPExchangeConfig $conf
);

/**
* @return boolean
**/
abstract public function exchangeDelete(
$name, $ifUnused = false, $ifEmpty = false
);

/**
* @see http://www.rabbitmq.com/blog/2010/10/19/exchange-to-exchange-bindings/
**/
abstract public function exchangeToExchangeBind(
$destination, $source, $routingKey
);

abstract public function exchangeToExchangeUnbind(
$destination, $source, $routingKey
);

/**
* @return integer - the message count in queue
**/
abstract public function queueDeclare($name, AMQPQueueConfig $conf);

/**
* @return boolean
**/
abstract public function queueBind($name, $exchange, $routingKey);

/**
* @return boolean
**/
abstract public function queueUnbind($name, $exchange, $routingKey);

/**
* @return boolean
**/
abstract public function queuePurge($name);

/**
* @return boolean
**/
abstract public function queueDelete($name);

abstract public function basicPublish(
$exchange, $routingKey, AMQPOutgoingMessage $msg
);

abstract public function basicQos($prefetchSize, $prefetchCount);
abstract public function basicGet($queue, $noAck = true);
abstract public function basicAck($deliveryTag, $multiple = false);
abstract public function basicConsume($queue, /*Consumer*/ $callback);
abstract public function basicCancel($consumerTag);

public function __construct($id, AMQP $transport)
{
$this->id = $id;
$this->transport = $transport;
}

public function __destruct()
{
if ($this->isOpen())
$this->close();
}

public function getTransport()
{
return $this->transport;
Expand All @@ -100,5 +42,20 @@ public function getId()
{
return $this->id;
}

/**
* @throws AMQPServerConnectionException
* @return AMQPBaseChannel
**/
protected function checkConnection()
{
if (!$this->transport->getLink()->isConnected()) {
throw new AMQPServerConnectionException(
"No connection available"
);
}

return $this;
}
}
?>
Loading

0 comments on commit 8fb5b87

Please sign in to comment.