import v1.0.0-RC4 | 2009-05-20

This commit is contained in:
2019-07-17 22:08:50 +02:00
commit b484e522e8
2459 changed files with 1038434 additions and 0 deletions

View File

@ -0,0 +1,18 @@
<?php
/*
* @copyright Copyright (C) 2005-2009 Keyboard Monkeys Ltd. http://www.kb-m.com
* @license http://creativecommons.org/licenses/BSD/ BSD Licensese
* @author Keyboard Monkeys Ltd.
* @since Textroller 0.9
* @package TextRoller
* @packager Keyboard Monkeys
*/
class Monkeys_AccessDeniedException extends Zend_Exception
{
public function __construct()
{
parent::__construct('Access Denied');
}
}

View File

@ -0,0 +1,19 @@
<?php
/*
* @copyright Copyright (C) 2005-2009 Keyboard Monkeys Ltd. http://www.kb-m.com
* @license http://creativecommons.org/licenses/BSD/ BSD Licensese
* @author Keyboard Monkeys Ltd.
* @since Textroller 0.9
* @package TextRoller
* @packager Keyboard Monkeys
*/
class Monkeys_BadUrlException extends Zend_Exception
{
public function __construct($url)
{
parent::__construct("Bad URL: $url");
}
}

View File

@ -0,0 +1,104 @@
<?php
/*
* @copyright Copyright (C) 2005-2009 Keyboard Monkeys Ltd. http://www.kb-m.com
* @license http://creativecommons.org/licenses/BSD/ BSD License
* @author Keyboard Monkey Ltd
* @since CommunityID 0.9
* @package CommunityID
* @packager Keyboard Monkeys
*/
/**
* Same as Zend_Captcha_Image, but also readable by humans ;)
*/
class Monkeys_Captcha_Image extends Zend_Captcha_Image
{
/**#@+
* All uppercase, and removed letters/numbers than can be mistaken for one another
*/
static $V = array("A", "E", "I", "U", "Y");
static $VN = array("A", "E", "I", "U", "Y", "3","4","5","6","7","8","9");
static $C = array("B","C","D","F","G","H","J","K","M","N","P","Q","R","S","T","W","X");
static $CN = array("B","C","D","F","G","H","J","K","M","N","P","Q","R","S","T","W","X","3","4","5","6","7","8","9");
/**#@-*/
/**#@+
* Reduced these levels
*/
protected $_dotNoiseLevel = 25;
protected $_lineNoiseLevel = 1;
/**#@-*/
/**
* Gotta reproduce this function here 'cause PHP won't have late static binding till 5.3
*/
protected function _generateWord()
{
$word = '';
$wordLen = $this->getWordLen();
$vowels = $this->_useNumbers ? self::$VN : self::$V;
$consonants = $this->_useNumbers ? self::$CN : self::$C;
for ($i=0; $i < $wordLen; $i = $i + 2) {
// generate word with mix of vowels and consonants
$consonant = $consonants[array_rand($consonants)];
$vowel = $vowels[array_rand($vowels)];
$word .= $consonant . $vowel;
}
if (strlen($word) > $wordLen) {
$word = substr($word, 0, $wordLen);
}
return $word;
}
/**
* Set captcha word
*
* @param string $word
* @return Zend_Captcha_Word
*/
protected function _setWord($word)
{
$word = strtoupper($word);
$session = $this->getSession();
$session->word = $word;
$this->_word = $word;
return $this;
}
/**
* Validate the word
*
* Overriden to handle on in uppercase for better readability
*
* @see Zend_Validate_Interface::isValid()
* @param mixed $value
* @return boolean
*/
public function isValid($value, $context = null)
{
$name = $this->getName();
if (!isset($context[$name]['input'])) {
$this->_error(self::MISSING_VALUE);
return false;
}
$value = strtoupper($context[$name]['input']);
$this->_setValue($value);
if (!isset($context[$name]['id'])) {
$this->_error(self::MISSING_ID);
return false;
}
$this->_id = $context[$name]['id'];
if ($value !== $this->getWord()) {
$this->_error(self::BAD_CAPTCHA);
return false;
}
return true;
}
}

View File

@ -0,0 +1,163 @@
<?php
/*
* @copyright Copyright (C) 2005-2009 Keyboard Monkeys Ltd. http://www.kb-m.com
* @license http://creativecommons.org/licenses/BSD/ BSD License
* @author Keyboard Monkey Ltd
* @since CommunityID 0.9
* @package CommunityID
* @packager Keyboard Monkeys
*/
abstract class Monkeys_Controller_Action extends Zend_Controller_Action
{
/**
* not prepended with "_" because their view counterparts can't have "_" prepended
*/
protected $user;
protected $targetUser;
protected $_config;
protected $_numCols = 2;
protected $underMaintenance = false;
public function init()
{
if (!Zend_Registry::isRegistered('user')) {
// guest user
$users = new Users();
$user = $users->createRow();
Zend_Registry::set('user', $user);
}
$this->_config = Zend_Registry::get('config');
$this->user = Zend_Registry::get('user');
$this->view->user = $this->user;
$this->_validateTargetUser();
$this->_checkMaintenanceMode();
$this->view->controller = $this;
$this->view->addHelperPath('libs/Monkeys/View/Helper', 'Monkeys_View_Helper');
$this->_setScriptPaths();
$this->_setBase();
$this->view->numCols = $this->_numCols;
if ($this->getRequest()->isXmlHttpRequest()) {
$slowdown = $this->_config->environment->ajax_slowdown;
if ($slowdown > 0) {
sleep($slowdown);
}
$this->_helper->layout->disableLayout();
} else {
$this->view->version = Setup::VERSION;
$this->view->messages = $this->_helper->FlashMessenger->getMessages();
$this->view->loaderCombine = $this->_config->environment->YDN? 'true' : 'false';
$this->view->loaderBase = $this->_config->environment->YDN?
'http://yui.yahooapis.com/2.6.0/build/'
: $this->view->base . '/javascript/yui/';
}
}
private function _setScriptPaths()
{
if (($template = $this->_config->environment->template) == 'default') {
return;
}
$viewRenderer = Zend_Controller_Action_HelperBroker::getStaticHelper('viewRenderer');
$view = $viewRenderer->view;
$scriptPaths = $view->getScriptPaths();
$oldPath = $scriptPaths[0];
$newPath = substr($oldPath, 0, strrpos($oldPath, DIRECTORY_SEPARATOR, -2) + 1) . "scripts_$template" . DIRECTORY_SEPARATOR;
$view->addScriptPath($newPath);
}
private function _setBase()
{
if ($this->_config->subdomain->enabled) {
$protocol = $this->_getProtocol();
$this->view->base = "$protocol://"
. ($this->_config->subdomain->use_www? 'www.' : '')
. $this->_config->subdomain->hostname;
} else {
$this->view->base = $this->view->getBase();
}
}
private function _validateTargetUser()
{
if (Zend_Registry::isRegistered('targetUser')) {
// used by unit tests to inject the target user
$this->targetUser = Zend_Registry::get('targetUser');
} else {
$userId = $this->_getParam('userid');
if (is_null($userId)) {
$this->targetUser = $this->user;
} elseif ($this->_getParam('userid') == 0) {
$users = new Users();
$this->targetUser = $users->createRow();
} else {
if ($userId != $this->user->id && $this->user->role != User::ROLE_ADMIN) {
$this->_helper->FlashMessenger->addMessage('Error: Invalid user id');
$this->_redirect('profile/edit');
}
$users = new Users();
$this->targetUser = $users->getRowInstance($userId);
}
}
$this->view->targetUser = $this->targetUser;
}
protected function _checkMaintenanceMode()
{
if (!$this->_config->environment->installed) {
$this->underMaintenance = true;
$this->view->underMaintenance = false;
return;
}
$settings = new Settings();
$this->underMaintenance = $settings->isMaintenanceMode();
$this->view->underMaintenance = $this->underMaintenance;
}
protected function _redirectToNormalConnection()
{
if ($this->_config->SSL->enable_mixed_mode) {
$this->_redirect('http://' . $_SERVER['HTTP_HOST'] . $this->view->base);
} else {
$this->_redirect('');
}
}
protected function _redirectForMaintenance($backToNormalConnection = false)
{
if ($backToNormalConnection) {
$this->_redirectToNormalConnection('');
} else {
$this->_redirect('');
}
}
protected function _redirect($url, $options = array())
{
Zend_Registry::get('logger')->log("redirected to '$url'", Zend_Log::DEBUG);
return parent::_redirect($url, $options);
}
protected function _getProtocol()
{
if (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') {
return 'https';
} else {
return 'http';
}
}
}

View File

@ -0,0 +1,118 @@
<?
/*
* @copyright Copyright (C) 2005-2009 Keyboard Monkeys Ltd. http://www.kb-m.com
* @license http://creativecommons.org/licenses/BSD/ BSD License
* @author Keyboard Monkey Ltd
* @since CommunityID 0.9
* @package CommunityID
* @packager Keyboard Monkeys
*/
abstract class Monkeys_Controller_Error extends Monkeys_Controller_Action
{
protected $_numCols = 1;
public function errorAction()
{
$errors = $this->_getParam('error_handler');
if (!$this->_config->environment->production) {
echo "<br /><br />";
Zend_Debug::Dump($errors);
}
$exceptionClass = get_class($errors->exception);
Zend_Registry::get('logger')->log(
"Exception $exceptionClass\nMessage: ".$errors->exception->getMessage()."\nStack: \n" . print_r($errors->exception->getTraceAsString(), true),
Zend_Log::ERR
);
switch ($exceptionClass) {
case 'Monkeys_BadUrlException';
$this->getResponse()->setRawHeader('HTTP/1.1 404 Not Found');
$this->view->message = 'The URL you entered is incorrect. Please correct and try again.';
break;
case 'Monkeys_AccessDeniedException';
$this->getResponse()->setRawHeader('HTTP/1.1 401 Unauthorized');
$this->view->message = 'Access Denied - Maybe your session has expired? Try logging-in again.';
break;
default:
$this->view->message = get_class($errors->exception) . '<br />' . $errors->exception->getMessage();
if (!$this->_config->environment->production) {
$this->view->trace = $errors->exception->getTraceAsString();
} else if ($this->_config->email->adminemail) {
$mail = self::getMail($errors->exception, $this->user, $errors);
$mail->send();
$this->view->message .= '<br />The system administrator has been notified.';
}
break;
}
$this->getResponse()->clearBody();
}
/**
* @return Zend_Mail
* @throws Zend_Mail_Protocol_Exception
*/
public static function getMail(Exception $ex, User $user, $errors)
{
$exceptionClass = get_class($ex);
$stack = $ex->getTraceAsString();
$stackDetail = print_r($errors, true);
$currentUrl = Zend_OpenId::selfURL();
if ($user->role = ROLE_GUEST) {
$userLabel = 'Anonymous';
} else {
$userLabel = $user->getFullName() . '(' . $user->username . ')';
}
$body = <<<EOD
Dear Admin,
An error has occured in your Community-ID installation.
URL requested: $currentUrl
By User: $userLabel
Exception: $exceptionClass
Call stack:
$stack
Call stack detail:
$stackDetail
EOD;
// can't use $this-_config 'cause it's a static function
$configEmail = Zend_Registry::get('config')->email;
switch (strtolower($configEmail->transport)) {
case 'smtp':
Zend_Mail::setDefaultTransport(
new Zend_Mail_Transport_Smtp(
$configEmail->host,
$configEmail->toArray()
)
);
break;
case 'mock':
Zend_Mail::setDefaultTransport(new Zend_Mail_Transport_Mock());
break;
default:
Zend_Mail::setDefaultTransport(new Zend_Mail_Transport_Sendmail());
}
$mail = new Zend_Mail();
$mail->setBodyText($body);
$mail->setFrom('support@community-id.org');
$mail->addTo($configEmail->adminemail);
$mail->setSubject('Community-ID error report');
return $mail;
}
}

View File

@ -0,0 +1,72 @@
<?php
/*
* @copyright Copyright (C) 2005-2009 Keyboard Monkeys Ltd. http://www.kb-m.com
* @license http://creativecommons.org/licenses/BSD/ BSD License
* @author Keyboard Monkey Ltd
* @since CommunityID 0.9
* @package CommunityID
* @packager Keyboard Monkeys
*/
class Monkeys_Controller_Plugin_Auth extends Zend_Controller_Plugin_Abstract
{
private $_acl;
public function __construct($acl)
{
$this->_acl = $acl;
}
public function preDispatch($request)
{
if (!Zend_Registry::get('config')->environment->installed
&& $request->getModuleName() != 'install'
&& $request->getControllerName() != 'error')
{
$request->setModuleName('install');
$request->setControllerName('index');
$request->setActionName('index');
return;
}
if (Zend_Registry::isRegistered('user')) {
// used by unit tests to inject the logged-in user
$user= Zend_Registry::get('user');
} else {
$auth = Zend_Auth::getInstance();
$users = new Users();
if ($auth->hasIdentity()) {
$user = $auth->getStorage()->read();
$user->init();
// reactivate row as live data
$user->setTable($users);
} else {
// guest user
$user = $users->createRow();
}
Zend_Registry::set('user', $user);
}
$resource = $request->getModuleName() . '_' . $request->getControllerName();
if (!$this->_acl->has($resource)) {
//echo "role: " . $user->role . " - resource: $resource - privilege: " . $request->getActionName() . "<br>\n";
throw new Monkeys_BadUrlException($this->getRequest()->getRequestUri());
}
// if an admin is not allowed for this action, then the action doesn't exist
if (!$this->_acl->isAllowed(User::ROLE_ADMIN, $resource, $request->getActionName())) {
//echo "role: " . $user->role . " - resource: $resource - privilege: " . $request->getActionName() . "<br>\n";
throw new Monkeys_BadUrlException($this->getRequest()->getRequestUri());
}
if (!$this->_acl->isAllowed($user->role, $resource, $request->getActionName())) {
//echo "role: " . $user->role . " - resource: $resource - privilege: " . $request->getActionName() . "<br>\n";
throw new Monkeys_AccessDeniedException();
}
}
}

24
libs/Monkeys/Db/Profiler.php Executable file
View File

@ -0,0 +1,24 @@
<?php
/*
* @copyright Copyright (C) 2005-2009 Keyboard Monkeys Ltd. http://www.kb-m.com
* @license http://creativecommons.org/licenses/BSD/ BSD License
* @author Keyboard Monkey Ltd
* @since CommunityID 0.9
* @package CommunityID
* @packager Keyboard Monkeys
*/
class Monkeys_Db_Profiler extends Zend_Db_Profiler
{
public function Monkeys_Db_Profiler()
{
parent::__construct(true);
}
public function queryStart($queryText, $queryType = null)
{
Zend_Registry::get('logger')->log("DB QUERY: $queryText", Zend_Log::DEBUG);
return parent::queryStart($queryText, $queryType);
}
}

View File

@ -0,0 +1,18 @@
<?php
/*
* @copyright Copyright (C) 2005-2009 Keyboard Monkeys Ltd. http://www.kb-m.com
* @license http://creativecommons.org/licenses/BSD/ BSD License
* @author Keyboard Monkey Ltd
* @since CommunityID 0.9
* @package CommunityID
* @packager Keyboard Monkeys
*/
abstract class Monkeys_Db_Table_Gateway extends Zend_Db_Table_Abstract
{
public function getRowInstance($id)
{
return $this->fetchRow($this->select()->where('id = ?', $id));
}
}

View File

@ -0,0 +1,136 @@
<?
class Monkeys_Form_Decorator_Composite extends Zend_Form_Decorator_Abstract
{
public function buildLabel()
{
$element = $this->getElement();
$label = $element->getLabel();
if ($translator = $element->getTranslator()) {
$label = $translator->translate($label);
}
if ($element->isRequired()) {
$label .= '*';
}
return $label . ':';
/*return $element->getView()
->formLabel($element->getName(), $label);*/
}
public function buildInput($content = '')
{
$element = $this->getElement();
$helper = $element->helper;
$attribs = $element->getAttribs();
if ($this->getOption('bottom')) {
$attribs = array_merge($attribs, array('style' => 'top:0; width:auto'));
}
if ($element instanceof Monkeys_Form_Element_Captcha) {
return $content;
}
$input = $element->getView()->$helper(
$element->getName(),
$element->getValue(),
$attribs,
$element->options,
$this->getSeparator()
);
if ($element instanceof Monkeys_Form_Element_Radio) {
return "<div class=\"formRadio\">$input</div>";
}
return $input;
}
public function buildErrors()
{
$element = $this->getElement();
$messages = $element->getMessages();
if (empty($messages)) {
return '';
}
return $element->getView()->formErrors($messages);
/*return '<div class="errors">' .
$element->getView()->formErrors($messages) . '</div>';*/
}
public function buildDescription()
{
$element = $this->getElement();
$desc = $element->getDescription();
if (empty($desc)) {
return '';
}
if ($translator = $element->getTranslator()) {
$desc = $translator->translate($desc);
}
return $desc;
}
public function render($content)
{
$element = $this->getElement();
if (!$element instanceof Zend_Form_Element) {
return $content;
}
if (null === $element->getView()) {
return $content;
}
$placement = $this->getPlacement();
$label = $this->buildLabel();
$input = $this->buildInput($content);
$errors = $this->buildErrors();
$desc = $this->buildDescription();
if ($desc && $errors) {
$desc = "<div>$desc</div>";
} else if ($desc && !$errors) {
$desc = "<div class=\"description\">$desc</div>";
}
if ($this->getOption('yuiGridType')) {
$yuiGridType = $this->getOption('yuiGridType');
} else {
$yuiGridType = 'gf';
}
if ($this->getOption('wideLabel')) {
$output = "<div class=\"yui-$yuiGridType\" style=\"padding-bottom:10px\">\n"
." <div class=\"formLabel\" style=\"padding-bottom:10px\">$label</div>\n"
." <div class=\"yui-u first\">&nbsp;</div>\n"
." <div class=\"yui-u\">\n"
." $input\n"
." $desc\n"
. ($errors? " <div>$errors</div>\n" : "")
." </div>\n"
."</div>\n";
} else if ($this->getOption('continuous')) {
$output = "<div style=\"padding-bottom:10px\">\n"
." <span class=\"formLabel\">$label</span> $input"
." <div>\n"
." $desc\n"
. ($errors? " <div>$errors</div>\n" : "")
." </div>\n"
."</div>\n";
} else {
$output = "<div class=\"yui-$yuiGridType\">\n"
." <div class=\"yui-u first\">$label</div>\n"
." <div class=\"yui-u\">\n"
." $input\n"
." $desc\n"
. ($errors? " <div>$errors</div>\n" : "")
." </div>\n"
."</div>\n";
}
return $output;
}
}

View File

@ -0,0 +1,38 @@
<?php
/*
* @copyright Copyright (C) 2005-2009 Keyboard Monkeys Ltd. http://www.kb-m.com
* @license http://creativecommons.org/licenses/BSD/ BSD License
* @author Keyboard Monkey Ltd
* @since CommunityID 0.9
* @package CommunityID
* @packager Keyboard Monkeys
*/
/**
* I was obliged to do this because of a mayor flaw of Zend_Form_Element_Captcha
* not letting using custom captcha adapters
* (if the adapter is not defined in the construct, an exception is thrown, so I don't
* even have a chance to call addPrefixPath() on the element...)
*/
class Monkeys_Form_Element_Captcha extends Zend_Form_Element_Captcha
{
private $_decorator;
public function __construct($spec, $options = null)
{
$this->addPrefixPath('Monkeys_Captcha', 'Monkeys/Captcha/', 'captcha');
$options = array_merge($options, array('disableLoadDefaultDecorators' =>true));
parent::__construct($spec, $options);
$this->_decorator = new Monkeys_Form_Decorator_Composite();
$this->addDecorator($this->_decorator);
}
public function setDecoratorOptions(array $options)
{
$this->_decorator->setOptions($options);
return $this;
}
}

View File

@ -0,0 +1,23 @@
<?php
class Monkeys_Form_Element_Checkbox extends Zend_Form_Element_Checkbox
{
private $_decorator;
public function __construct($spec, $options = array())
{
$options = array_merge($options, array('disableLoadDefaultDecorators' =>true));
parent::__construct($spec, $options);
$this->_decorator = new Monkeys_Form_Decorator_Composite();
$this->addDecorator($this->_decorator);
}
public function setDecoratorOptions(array $options)
{
$this->_decorator->setOptions($options);
return $this;
}
}

View File

@ -0,0 +1,41 @@
<?php
/*
* @copyright Copyright (C) 2005-2009 Keyboard Monkeys Ltd. http://www.kb-m.com
* @license http://creativecommons.org/licenses/BSD/ BSD License
* @author Keyboard Monkey Ltd
* @since CommunityID 0.9
* @package CommunityID
* @packager Keyboard Monkeys
*/
class Monkeys_Form_Element_Country extends Zend_Form_Element_Select
{
private $_decorator;
public function __construct($spec, $options = array())
{
$options = array_merge($options, array('disableLoadDefaultDecorators' =>true));
parent::__construct($spec, $options);
$this->_decorator = new Monkeys_Form_Decorator_Composite();
$this->addDecorator($this->_decorator);
}
public function setDecoratorOptions(array $options)
{
$this->_decorator->setOptions($options);
return $this;
}
public function init()
{
parent::init();
translate('-- Select a Country --');
$this->addMultiOption(0, '-- Select a Country --');
$this->addMultiOptions(Zend_Locale::getCountryTranslationList(Zend_Registry::get('Zend_Locale')));
asort($this->options);
}
}

View File

@ -0,0 +1,164 @@
<?php
/*
* @copyright Copyright (C) 2005-2009 Keyboard Monkeys Ltd. http://www.kb-m.com
* @license http://creativecommons.org/licenses/BSD/ BSD Licensese
* @author Keyboard Monkeys Ltd.
* @since CommunityID0.9
* @package CommunityID
* @packager Keyboard Monkeys
*/
/**
* Based on
* http://zfsite.andreinikolov.com/2008/05/part-4-zend_form-captcha-password-confirmation-date-selector-field-zend_translate/
*/
class Monkeys_Form_Element_Date extends Zend_Form_Element_Xhtml
{
/**
* Use formSelect view helper by default
* @var string
*/
public $helper = 'formDateSelects';
/**
* This array will hold options:
* showEmpty - bool, if true will show and allow empty date
* startYear, endYear - start and end year to show
* reverseYears - if true - years will be print from most recent backwards
*
* Zend_Form_Decorator_ViewHelper will pass this array as argument to the
* view helper, responsible for rendering this element
*
* @var array
*/
public $options = array();
private $_decorator;
public function __construct($spec, $options = array())
{
$options = array_merge($options, array('disableLoadDefaultDecorators' =>true));
parent::__construct($spec, $options);
$this->_decorator = new Monkeys_Form_Decorator_Composite();
$this->addDecorator($this->_decorator);
}
public function setDecoratorOptions(array $options)
{
$this->_decorator->setOptions($options);
return $this;
}
public function init()
{
$this->options['showEmpty'] = true;
$this->options['startYear'] = 1900;
$this->options['endYear'] = (int) date("Y");
$this->options['reverseYears'] = false;
}
public function setShowEmptyValues($value)
{
$this->options['showEmpty'] = (bool) $value;
return $this;
}
public function setStartEndYear($start = null, $end = null)
{
if ($start)
{
$this->options['startYear'] = (int) $start;
}
if ($end)
{
$this->options['endYear'] = (int) $end;
}
return $this;
}
public function setReverseYears($value)
{
$this->options['reverseYears'] = (bool) $value;
return $this;
}
/**
* We want to get the date from our auxiliary fields here
*
* @param mixed $value
* @param mixed $context
* @return boolean
*/
public function isValid($value, $context = null)
{
$fieldName = $this->getName();
$auxiliaryFieldsNames = $this->getDayMonthYearFieldNames($fieldName);
if (isset($context[$auxiliaryFieldsNames['day']]) && isset($context[$auxiliaryFieldsNames['month']])
&& isset($context[$auxiliaryFieldsNames['year']]))
{
if ($context[$auxiliaryFieldsNames['year']] == '-'
|| $context[$auxiliaryFieldsNames['month']] == '-'
|| $context[$auxiliaryFieldsNames['day']] == '-')
{
$value = null;
}
else
{
$value = str_pad($context[$auxiliaryFieldsNames['year']], 4, '0', STR_PAD_LEFT) . '-'
. str_pad($context[$auxiliaryFieldsNames['month']], 2, '0', STR_PAD_LEFT) . '-'
. str_pad($context[$auxiliaryFieldsNames['day']], 2, '0', STR_PAD_LEFT);
}
$this->setValue($value);
}
return parent::isValid($value, $context);
}
/**
* Makes day, month and year names from given element name. Special case is array notation.
*
* Given a value such as foo[bar][baz], the generated names will be
* foo[bar][baz_day], foo[bar][baz_month] and foo[bar][baz_year]
* I know it is bad design to have this function here and in the View Helper,
* but I really can't think of other way
*
* @param string $value
* @return array
*/
protected function getDayMonthYearFieldNames($value)
{
if (empty($value) || !is_string($value)) {
return $value;
}
$ret = array(
'day' => $value . '_day',
'month' => $value . '_month',
'year' => $value . '_year'
);
if (strstr($value, '['))
{
$endPos = strlen($value) - 1;
if (']' != $value[$endPos]) {
return $ret;
}
$start = strrpos($value, '[') + 1;
$name = substr($value, $start, $endPos - $start);
$arrayName = substr($value, 0, $start-1);
$ret = array(
'day' => $arrayName . '[' . $name . '_day' . ']',
'month' => $arrayName . '[' . $name . '_month' . ']',
'year' => $arrayName . '[' . $name . '_year' . ']'
);
}
return $ret;
}
}

View File

@ -0,0 +1,23 @@
<?php
class Monkeys_Form_Element_File extends Zend_Form_Element_File
{
private $_decorator;
public function __construct($spec, $options = array())
{
$options = array_merge($options, array('disableLoadDefaultDecorators' =>true));
parent::__construct($spec, $options);
$this->_decorator = new Monkeys_Form_Decorator_Composite();
$this->addDecorator($this->_decorator);
}
public function setDecoratorOptions(array $options)
{
$this->_decorator->setOptions($options);
return $this;
}
}

View File

@ -0,0 +1,41 @@
<?php
/*
* @copyright Copyright (C) 2005-2009 Keyboard Monkeys Ltd. http://www.kb-m.com
* @license http://creativecommons.org/licenses/BSD/ BSD License
* @author Keyboard Monkey Ltd
* @since CommunityID 0.9
* @package CommunityID
* @packager Keyboard Monkeys
*/
class Monkeys_Form_Element_Language extends Zend_Form_Element_Select
{
private $_decorator;
public function __construct($spec, $options = array())
{
$options = array_merge($options, array('disableLoadDefaultDecorators' =>true));
parent::__construct($spec, $options);
$this->_decorator = new Monkeys_Form_Decorator_Composite();
$this->addDecorator($this->_decorator);
}
public function setDecoratorOptions(array $options)
{
$this->_decorator->setOptions($options);
return $this;
}
public function init()
{
parent::init();
translate('-- Select a Language --');
$this->addMultiOption(0, '-- Select a Language --');
$this->addMultiOptions(Zend_Locale::getLanguageTranslationList(Zend_Registry::get('Zend_Locale')));
asort($this->options);
}
}

View File

@ -0,0 +1,13 @@
<?php
class Monkeys_Form_Element_Password extends Zend_Form_Element_Password
{
public function __construct($spec, $options = array())
{
$options = array_merge($options, array('disableLoadDefaultDecorators' =>true));
parent::__construct($spec, $options);
$this->addDecorator(new Monkeys_Form_Decorator_Composite());
}
}

View File

@ -0,0 +1,23 @@
<?php
class Monkeys_Form_Element_Radio extends Zend_Form_Element_Radio
{
private $_decorator;
public function __construct($spec, $options = array())
{
$options = array_merge($options, array('disableLoadDefaultDecorators' =>true));
parent::__construct($spec, $options);
$this->_decorator = new Monkeys_Form_Decorator_Composite();
$this->addDecorator($this->_decorator);
}
public function setDecoratorOptions(array $options)
{
$this->_decorator->setOptions($options);
return $this;
}
}

View File

@ -0,0 +1,22 @@
<?php
class Monkeys_Form_Element_Text extends Zend_Form_Element_Text
{
private $_decorator;
public function __construct($spec, $options = array())
{
$options = array_merge($options, array('disableLoadDefaultDecorators' =>true));
parent::__construct($spec, $options);
$this->_decorator = new Monkeys_Form_Decorator_Composite();
$this->addDecorator($this->_decorator);
}
public function setDecoratorOptions(array $options)
{
$this->_decorator->setOptions($options);
return $this;
}
}

View File

@ -0,0 +1,23 @@
<?php
class Monkeys_Form_Element_Textarea extends Zend_Form_Element_Textarea
{
private $_decorator;
public function __construct($spec, $options = array())
{
$options = array_merge($options, array('disableLoadDefaultDecorators' =>true));
parent::__construct($spec, $options);
$this->_decorator = new Monkeys_Form_Decorator_Composite();
$this->addDecorator($this->_decorator);
}
public function setDecoratorOptions(array $options)
{
$this->_decorator->setOptions($options);
return $this;
}
}

View File

@ -0,0 +1,54 @@
<?php
/*
* @copyright Copyright (C) 2005-2009 Keyboard Monkeys Ltd. http://www.kb-m.com
* @license http://creativecommons.org/licenses/BSD/ BSD License
* @author Keyboard Monkey Ltd
* @since CommunityID 0.9
* @package CommunityID
* @packager Keyboard Monkeys
*/
class Monkeys_Form_Element_Timezone extends Zend_Form_Element_Select
{
private $_decorator;
public function __construct($spec, $options = array())
{
$options = array_merge($options, array('disableLoadDefaultDecorators' =>true));
parent::__construct($spec, $options);
$this->_decorator = new Monkeys_Form_Decorator_Composite();
$this->addDecorator($this->_decorator);
}
public function setDecoratorOptions(array $options)
{
$this->_decorator->setOptions($options);
return $this;
}
public function init()
{
parent::init();
$fp = fopen(dirname(__FILE__) . '/zone.tab', 'r');
$timezones = array();
while ($row = fgets($fp)) {
if ($row[0] == '#') {
continue;
}
$elements = explode("\t", $row);
$timezones[trim($elements[2])] = trim(strtr($elements[2], '_', ' '));
}
ksort($timezones);
translate('-- Select a Timezone --');
$this->addMultiOption(0, '-- Select a Timezone --');
foreach ($timezones as $key => $value) {
$this->addMultiOption($key, $value);
}
}
}

View File

@ -0,0 +1,425 @@
# @(#)zone.tab 8.21
#
# TZ zone descriptions
#
# From Paul Eggert (1996-08-05):
#
# This file contains a table with the following columns:
# 1. ISO 3166 2-character country code. See the file `iso3166.tab'.
# 2. Latitude and longitude of the zone's principal location
# in ISO 6709 sign-degrees-minutes-seconds format,
# either +-DDMM+-DDDMM or +-DDMMSS+-DDDMMSS,
# first latitude (+ is north), then longitude (+ is east).
# 3. Zone name used in value of TZ environment variable.
# 4. Comments; present if and only if the country has multiple rows.
#
# Columns are separated by a single tab.
# The table is sorted first by country, then an order within the country that
# (1) makes some geographical sense, and
# (2) puts the most populous zones first, where that does not contradict (1).
#
# Lines beginning with `#' are comments.
#
#country-
#code coordinates TZ comments
AD +4230+00131 Europe/Andorra
AE +2518+05518 Asia/Dubai
AF +3431+06912 Asia/Kabul
AG +1703-06148 America/Antigua
AI +1812-06304 America/Anguilla
AL +4120+01950 Europe/Tirane
AM +4011+04430 Asia/Yerevan
AN +1211-06900 America/Curacao
AO -0848+01314 Africa/Luanda
AQ -7750+16636 Antarctica/McMurdo McMurdo Station, Ross Island
AQ -9000+00000 Antarctica/South_Pole Amundsen-Scott Station, South Pole
AQ -6734-06808 Antarctica/Rothera Rothera Station, Adelaide Island
AQ -6448-06406 Antarctica/Palmer Palmer Station, Anvers Island
AQ -6736+06253 Antarctica/Mawson Mawson Station, Holme Bay
AQ -6835+07758 Antarctica/Davis Davis Station, Vestfold Hills
AQ -6617+11031 Antarctica/Casey Casey Station, Bailey Peninsula
AQ -7824+10654 Antarctica/Vostok Vostok Station, S Magnetic Pole
AQ -6640+14001 Antarctica/DumontDUrville Dumont-d'Urville Station, Terre Adelie
AQ -690022+0393524 Antarctica/Syowa Syowa Station, E Ongul I
AR -3436-05827 America/Argentina/Buenos_Aires Buenos Aires (BA, CF)
AR -3124-06411 America/Argentina/Cordoba most locations (CB, CC, CN, ER, FM, MN, SE, SF)
AR -2447-06525 America/Argentina/Salta (SA, LP, NQ, RN)
AR -2411-06518 America/Argentina/Jujuy Jujuy (JY)
AR -2649-06513 America/Argentina/Tucuman Tucuman (TM)
AR -2828-06547 America/Argentina/Catamarca Catamarca (CT), Chubut (CH)
AR -2926-06651 America/Argentina/La_Rioja La Rioja (LR)
AR -3132-06831 America/Argentina/San_Juan San Juan (SJ)
AR -3253-06849 America/Argentina/Mendoza Mendoza (MZ)
AR -3319-06621 America/Argentina/San_Luis San Luis (SL)
AR -5138-06913 America/Argentina/Rio_Gallegos Santa Cruz (SC)
AR -5448-06818 America/Argentina/Ushuaia Tierra del Fuego (TF)
AS -1416-17042 Pacific/Pago_Pago
AT +4813+01620 Europe/Vienna
AU -3133+15905 Australia/Lord_Howe Lord Howe Island
AU -4253+14719 Australia/Hobart Tasmania - most locations
AU -3956+14352 Australia/Currie Tasmania - King Island
AU -3749+14458 Australia/Melbourne Victoria
AU -3352+15113 Australia/Sydney New South Wales - most locations
AU -3157+14127 Australia/Broken_Hill New South Wales - Yancowinna
AU -2728+15302 Australia/Brisbane Queensland - most locations
AU -2016+14900 Australia/Lindeman Queensland - Holiday Islands
AU -3455+13835 Australia/Adelaide South Australia
AU -1228+13050 Australia/Darwin Northern Territory
AU -3157+11551 Australia/Perth Western Australia - most locations
AU -3143+12852 Australia/Eucla Western Australia - Eucla area
AW +1230-06958 America/Aruba
AX +6006+01957 Europe/Mariehamn
AZ +4023+04951 Asia/Baku
BA +4352+01825 Europe/Sarajevo
BB +1306-05937 America/Barbados
BD +2343+09025 Asia/Dhaka
BE +5050+00420 Europe/Brussels
BF +1222-00131 Africa/Ouagadougou
BG +4241+02319 Europe/Sofia
BH +2623+05035 Asia/Bahrain
BI -0323+02922 Africa/Bujumbura
BJ +0629+00237 Africa/Porto-Novo
BL +1753-06251 America/St_Barthelemy
BM +3217-06446 Atlantic/Bermuda
BN +0456+11455 Asia/Brunei
BO -1630-06809 America/La_Paz
BR -0351-03225 America/Noronha Atlantic islands
BR -0127-04829 America/Belem Amapa, E Para
BR -0343-03830 America/Fortaleza NE Brazil (MA, PI, CE, RN, PB)
BR -0803-03454 America/Recife Pernambuco
BR -0712-04812 America/Araguaina Tocantins
BR -0940-03543 America/Maceio Alagoas, Sergipe
BR -1259-03831 America/Bahia Bahia
BR -2332-04637 America/Sao_Paulo S & SE Brazil (GO, DF, MG, ES, RJ, SP, PR, SC, RS)
BR -2027-05437 America/Campo_Grande Mato Grosso do Sul
BR -1535-05605 America/Cuiaba Mato Grosso
BR -0226-05452 America/Santarem W Para
BR -0846-06354 America/Porto_Velho Rondonia
BR +0249-06040 America/Boa_Vista Roraima
BR -0308-06001 America/Manaus E Amazonas
BR -0640-06952 America/Eirunepe W Amazonas
BR -0958-06748 America/Rio_Branco Acre
BS +2505-07721 America/Nassau
BT +2728+08939 Asia/Thimphu
BW -2545+02555 Africa/Gaborone
BY +5354+02734 Europe/Minsk
BZ +1730-08812 America/Belize
CA +4734-05243 America/St_Johns Newfoundland Time, including SE Labrador
CA +4439-06336 America/Halifax Atlantic Time - Nova Scotia (most places), PEI
CA +4612-05957 America/Glace_Bay Atlantic Time - Nova Scotia - places that did not observe DST 1966-1971
CA +4606-06447 America/Moncton Atlantic Time - New Brunswick
CA +5320-06025 America/Goose_Bay Atlantic Time - Labrador - most locations
CA +5125-05707 America/Blanc-Sablon Atlantic Standard Time - Quebec - Lower North Shore
CA +4531-07334 America/Montreal Eastern Time - Quebec - most locations
CA +4339-07923 America/Toronto Eastern Time - Ontario - most locations
CA +4901-08816 America/Nipigon Eastern Time - Ontario & Quebec - places that did not observe DST 1967-1973
CA +4823-08915 America/Thunder_Bay Eastern Time - Thunder Bay, Ontario
CA +6344-06828 America/Iqaluit Eastern Time - east Nunavut - most locations
CA +6608-06544 America/Pangnirtung Eastern Time - Pangnirtung, Nunavut
CA +744144-0944945 America/Resolute Eastern Time - Resolute, Nunavut
CA +484531-0913718 America/Atikokan Eastern Standard Time - Atikokan, Ontario and Southampton I, Nunavut
CA +624900-0920459 America/Rankin_Inlet Central Time - central Nunavut
CA +4953-09709 America/Winnipeg Central Time - Manitoba & west Ontario
CA +4843-09434 America/Rainy_River Central Time - Rainy River & Fort Frances, Ontario
CA +5024-10439 America/Regina Central Standard Time - Saskatchewan - most locations
CA +5017-10750 America/Swift_Current Central Standard Time - Saskatchewan - midwest
CA +5333-11328 America/Edmonton Mountain Time - Alberta, east British Columbia & west Saskatchewan
CA +690650-1050310 America/Cambridge_Bay Mountain Time - west Nunavut
CA +6227-11421 America/Yellowknife Mountain Time - central Northwest Territories
CA +682059-1334300 America/Inuvik Mountain Time - west Northwest Territories
CA +5946-12014 America/Dawson_Creek Mountain Standard Time - Dawson Creek & Fort Saint John, British Columbia
CA +4916-12307 America/Vancouver Pacific Time - west British Columbia
CA +6043-13503 America/Whitehorse Pacific Time - south Yukon
CA +6404-13925 America/Dawson Pacific Time - north Yukon
CC -1210+09655 Indian/Cocos
CD -0418+01518 Africa/Kinshasa west Dem. Rep. of Congo
CD -1140+02728 Africa/Lubumbashi east Dem. Rep. of Congo
CF +0422+01835 Africa/Bangui
CG -0416+01517 Africa/Brazzaville
CH +4723+00832 Europe/Zurich
CI +0519-00402 Africa/Abidjan
CK -2114-15946 Pacific/Rarotonga
CL -3327-07040 America/Santiago most locations
CL -2709-10926 Pacific/Easter Easter Island & Sala y Gomez
CM +0403+00942 Africa/Douala
CN +3114+12128 Asia/Shanghai east China - Beijing, Guangdong, Shanghai, etc.
CN +4545+12641 Asia/Harbin Heilongjiang (except Mohe), Jilin
CN +2934+10635 Asia/Chongqing central China - Sichuan, Yunnan, Guangxi, Shaanxi, Guizhou, etc.
CN +4348+08735 Asia/Urumqi most of Tibet & Xinjiang
CN +3929+07559 Asia/Kashgar west Tibet & Xinjiang
CO +0436-07405 America/Bogota
CR +0956-08405 America/Costa_Rica
CU +2308-08222 America/Havana
CV +1455-02331 Atlantic/Cape_Verde
CX -1025+10543 Indian/Christmas
CY +3510+03322 Asia/Nicosia
CZ +5005+01426 Europe/Prague
DE +5230+01322 Europe/Berlin
DJ +1136+04309 Africa/Djibouti
DK +5540+01235 Europe/Copenhagen
DM +1518-06124 America/Dominica
DO +1828-06954 America/Santo_Domingo
DZ +3647+00303 Africa/Algiers
EC -0210-07950 America/Guayaquil mainland
EC -0054-08936 Pacific/Galapagos Galapagos Islands
EE +5925+02445 Europe/Tallinn
EG +3003+03115 Africa/Cairo
EH +2709-01312 Africa/El_Aaiun
ER +1520+03853 Africa/Asmara
ES +4024-00341 Europe/Madrid mainland
ES +3553-00519 Africa/Ceuta Ceuta & Melilla
ES +2806-01524 Atlantic/Canary Canary Islands
ET +0902+03842 Africa/Addis_Ababa
FI +6010+02458 Europe/Helsinki
FJ -1808+17825 Pacific/Fiji
FK -5142-05751 Atlantic/Stanley
FM +0725+15147 Pacific/Truk Truk (Chuuk) and Yap
FM +0658+15813 Pacific/Ponape Ponape (Pohnpei)
FM +0519+16259 Pacific/Kosrae Kosrae
FO +6201-00646 Atlantic/Faroe
FR +4852+00220 Europe/Paris
GA +0023+00927 Africa/Libreville
GB +513030-0000731 Europe/London
GD +1203-06145 America/Grenada
GE +4143+04449 Asia/Tbilisi
GF +0456-05220 America/Cayenne
GG +4927-00232 Europe/Guernsey
GH +0533-00013 Africa/Accra
GI +3608-00521 Europe/Gibraltar
GL +6411-05144 America/Godthab most locations
GL +7646-01840 America/Danmarkshavn east coast, north of Scoresbysund
GL +7029-02158 America/Scoresbysund Scoresbysund / Ittoqqortoormiit
GL +7634-06847 America/Thule Thule / Pituffik
GM +1328-01639 Africa/Banjul
GN +0931-01343 Africa/Conakry
GP +1614-06132 America/Guadeloupe
GQ +0345+00847 Africa/Malabo
GR +3758+02343 Europe/Athens
GS -5416-03632 Atlantic/South_Georgia
GT +1438-09031 America/Guatemala
GU +1328+14445 Pacific/Guam
GW +1151-01535 Africa/Bissau
GY +0648-05810 America/Guyana
HK +2217+11409 Asia/Hong_Kong
HN +1406-08713 America/Tegucigalpa
HR +4548+01558 Europe/Zagreb
HT +1832-07220 America/Port-au-Prince
HU +4730+01905 Europe/Budapest
ID -0610+10648 Asia/Jakarta Java & Sumatra
ID -0002+10920 Asia/Pontianak west & central Borneo
ID -0507+11924 Asia/Makassar east & south Borneo, Celebes, Bali, Nusa Tengarra, west Timor
ID -0232+14042 Asia/Jayapura Irian Jaya & the Moluccas
IE +5320-00615 Europe/Dublin
IL +3146+03514 Asia/Jerusalem
IM +5409-00428 Europe/Isle_of_Man
IN +2232+08822 Asia/Kolkata
IO -0720+07225 Indian/Chagos
IQ +3321+04425 Asia/Baghdad
IR +3540+05126 Asia/Tehran
IS +6409-02151 Atlantic/Reykjavik
IT +4154+01229 Europe/Rome
JE +4912-00207 Europe/Jersey
JM +1800-07648 America/Jamaica
JO +3157+03556 Asia/Amman
JP +353916+1394441 Asia/Tokyo
KE -0117+03649 Africa/Nairobi
KG +4254+07436 Asia/Bishkek
KH +1133+10455 Asia/Phnom_Penh
KI +0125+17300 Pacific/Tarawa Gilbert Islands
KI -0308-17105 Pacific/Enderbury Phoenix Islands
KI +0152-15720 Pacific/Kiritimati Line Islands
KM -1141+04316 Indian/Comoro
KN +1718-06243 America/St_Kitts
KP +3901+12545 Asia/Pyongyang
KR +3733+12658 Asia/Seoul
KW +2920+04759 Asia/Kuwait
KY +1918-08123 America/Cayman
KZ +4315+07657 Asia/Almaty most locations
KZ +4448+06528 Asia/Qyzylorda Qyzylorda (Kyzylorda, Kzyl-Orda)
KZ +5017+05710 Asia/Aqtobe Aqtobe (Aktobe)
KZ +4431+05016 Asia/Aqtau Atyrau (Atirau, Gur'yev), Mangghystau (Mankistau)
KZ +5113+05121 Asia/Oral West Kazakhstan
LA +1758+10236 Asia/Vientiane
LB +3353+03530 Asia/Beirut
LC +1401-06100 America/St_Lucia
LI +4709+00931 Europe/Vaduz
LK +0656+07951 Asia/Colombo
LR +0618-01047 Africa/Monrovia
LS -2928+02730 Africa/Maseru
LT +5441+02519 Europe/Vilnius
LU +4936+00609 Europe/Luxembourg
LV +5657+02406 Europe/Riga
LY +3254+01311 Africa/Tripoli
MA +3339-00735 Africa/Casablanca
MC +4342+00723 Europe/Monaco
MD +4700+02850 Europe/Chisinau
ME +4226+01916 Europe/Podgorica
MF +1804-06305 America/Marigot
MG -1855+04731 Indian/Antananarivo
MH +0709+17112 Pacific/Majuro most locations
MH +0905+16720 Pacific/Kwajalein Kwajalein
MK +4159+02126 Europe/Skopje
ML +1239-00800 Africa/Bamako
MM +1647+09610 Asia/Rangoon
MN +4755+10653 Asia/Ulaanbaatar most locations
MN +4801+09139 Asia/Hovd Bayan-Olgiy, Govi-Altai, Hovd, Uvs, Zavkhan
MN +4804+11430 Asia/Choibalsan Dornod, Sukhbaatar
MO +2214+11335 Asia/Macau
MP +1512+14545 Pacific/Saipan
MQ +1436-06105 America/Martinique
MR +1806-01557 Africa/Nouakchott
MS +1643-06213 America/Montserrat
MT +3554+01431 Europe/Malta
MU -2010+05730 Indian/Mauritius
MV +0410+07330 Indian/Maldives
MW -1547+03500 Africa/Blantyre
MX +1924-09909 America/Mexico_City Central Time - most locations
MX +2105-08646 America/Cancun Central Time - Quintana Roo
MX +2058-08937 America/Merida Central Time - Campeche, Yucatan
MX +2540-10019 America/Monterrey Central Time - Coahuila, Durango, Nuevo Leon, Tamaulipas
MX +2313-10625 America/Mazatlan Mountain Time - S Baja, Nayarit, Sinaloa
MX +2838-10605 America/Chihuahua Mountain Time - Chihuahua
MX +2904-11058 America/Hermosillo Mountain Standard Time - Sonora
MX +3232-11701 America/Tijuana Pacific Time
MY +0310+10142 Asia/Kuala_Lumpur peninsular Malaysia
MY +0133+11020 Asia/Kuching Sabah & Sarawak
MZ -2558+03235 Africa/Maputo
NA -2234+01706 Africa/Windhoek
NC -2216+16530 Pacific/Noumea
NE +1331+00207 Africa/Niamey
NF -2903+16758 Pacific/Norfolk
NG +0627+00324 Africa/Lagos
NI +1209-08617 America/Managua
NL +5222+00454 Europe/Amsterdam
NO +5955+01045 Europe/Oslo
NP +2743+08519 Asia/Katmandu
NR -0031+16655 Pacific/Nauru
NU -1901-16955 Pacific/Niue
NZ -3652+17446 Pacific/Auckland most locations
NZ -4357-17633 Pacific/Chatham Chatham Islands
OM +2336+05835 Asia/Muscat
PA +0858-07932 America/Panama
PE -1203-07703 America/Lima
PF -1732-14934 Pacific/Tahiti Society Islands
PF -0900-13930 Pacific/Marquesas Marquesas Islands
PF -2308-13457 Pacific/Gambier Gambier Islands
PG -0930+14710 Pacific/Port_Moresby
PH +1435+12100 Asia/Manila
PK +2452+06703 Asia/Karachi
PL +5215+02100 Europe/Warsaw
PM +4703-05620 America/Miquelon
PN -2504-13005 Pacific/Pitcairn
PR +182806-0660622 America/Puerto_Rico
PS +3130+03428 Asia/Gaza
PT +3843-00908 Europe/Lisbon mainland
PT +3238-01654 Atlantic/Madeira Madeira Islands
PT +3744-02540 Atlantic/Azores Azores
PW +0720+13429 Pacific/Palau
PY -2516-05740 America/Asuncion
QA +2517+05132 Asia/Qatar
RE -2052+05528 Indian/Reunion
RO +4426+02606 Europe/Bucharest
RS +4450+02030 Europe/Belgrade
RU +5443+02030 Europe/Kaliningrad Moscow-01 - Kaliningrad
RU +5545+03735 Europe/Moscow Moscow+00 - west Russia
RU +4844+04425 Europe/Volgograd Moscow+00 - Caspian Sea
RU +5312+05009 Europe/Samara Moscow+01 - Samara, Udmurtia
RU +5651+06036 Asia/Yekaterinburg Moscow+02 - Urals
RU +5500+07324 Asia/Omsk Moscow+03 - west Siberia
RU +5502+08255 Asia/Novosibirsk Moscow+03 - Novosibirsk
RU +5601+09250 Asia/Krasnoyarsk Moscow+04 - Yenisei River
RU +5216+10420 Asia/Irkutsk Moscow+05 - Lake Baikal
RU +6200+12940 Asia/Yakutsk Moscow+06 - Lena River
RU +4310+13156 Asia/Vladivostok Moscow+07 - Amur River
RU +4658+14242 Asia/Sakhalin Moscow+07 - Sakhalin Island
RU +5934+15048 Asia/Magadan Moscow+08 - Magadan
RU +5301+15839 Asia/Kamchatka Moscow+09 - Kamchatka
RU +6445+17729 Asia/Anadyr Moscow+10 - Bering Sea
RW -0157+03004 Africa/Kigali
SA +2438+04643 Asia/Riyadh
SB -0932+16012 Pacific/Guadalcanal
SC -0440+05528 Indian/Mahe
SD +1536+03232 Africa/Khartoum
SE +5920+01803 Europe/Stockholm
SG +0117+10351 Asia/Singapore
SH -1555-00542 Atlantic/St_Helena
SI +4603+01431 Europe/Ljubljana
SJ +7800+01600 Arctic/Longyearbyen
SK +4809+01707 Europe/Bratislava
SL +0830-01315 Africa/Freetown
SM +4355+01228 Europe/San_Marino
SN +1440-01726 Africa/Dakar
SO +0204+04522 Africa/Mogadishu
SR +0550-05510 America/Paramaribo
ST +0020+00644 Africa/Sao_Tome
SV +1342-08912 America/El_Salvador
SY +3330+03618 Asia/Damascus
SZ -2618+03106 Africa/Mbabane
TC +2128-07108 America/Grand_Turk
TD +1207+01503 Africa/Ndjamena
TF -492110+0701303 Indian/Kerguelen
TG +0608+00113 Africa/Lome
TH +1345+10031 Asia/Bangkok
TJ +3835+06848 Asia/Dushanbe
TK -0922-17114 Pacific/Fakaofo
TL -0833+12535 Asia/Dili
TM +3757+05823 Asia/Ashgabat
TN +3648+01011 Africa/Tunis
TO -2110+17510 Pacific/Tongatapu
TR +4101+02858 Europe/Istanbul
TT +1039-06131 America/Port_of_Spain
TV -0831+17913 Pacific/Funafuti
TW +2503+12130 Asia/Taipei
TZ -0648+03917 Africa/Dar_es_Salaam
UA +5026+03031 Europe/Kiev most locations
UA +4837+02218 Europe/Uzhgorod Ruthenia
UA +4750+03510 Europe/Zaporozhye Zaporozh'ye, E Lugansk / Zaporizhia, E Luhansk
UA +4457+03406 Europe/Simferopol central Crimea
UG +0019+03225 Africa/Kampala
UM +1645-16931 Pacific/Johnston Johnston Atoll
UM +2813-17722 Pacific/Midway Midway Islands
UM +1917+16637 Pacific/Wake Wake Island
US +404251-0740023 America/New_York Eastern Time
US +421953-0830245 America/Detroit Eastern Time - Michigan - most locations
US +381515-0854534 America/Kentucky/Louisville Eastern Time - Kentucky - Louisville area
US +364947-0845057 America/Kentucky/Monticello Eastern Time - Kentucky - Wayne County
US +394606-0860929 America/Indiana/Indianapolis Eastern Time - Indiana - most locations
US +384038-0873143 America/Indiana/Vincennes Eastern Time - Indiana - Daviess, Dubois, Knox & Martin Counties
US +410305-0863611 America/Indiana/Winamac Eastern Time - Indiana - Pulaski County
US +382232-0862041 America/Indiana/Marengo Eastern Time - Indiana - Crawford County
US +382931-0871643 America/Indiana/Petersburg Eastern Time - Indiana - Pike County
US +384452-0850402 America/Indiana/Vevay Eastern Time - Indiana - Switzerland County
US +415100-0873900 America/Chicago Central Time
US +375711-0864541 America/Indiana/Tell_City Central Time - Indiana - Perry County
US +411745-0863730 America/Indiana/Knox Central Time - Indiana - Starke County
US +450628-0873651 America/Menominee Central Time - Michigan - Dickinson, Gogebic, Iron & Menominee Counties
US +470659-1011757 America/North_Dakota/Center Central Time - North Dakota - Oliver County
US +465042-1012439 America/North_Dakota/New_Salem Central Time - North Dakota - Morton County (except Mandan area)
US +394421-1045903 America/Denver Mountain Time
US +433649-1161209 America/Boise Mountain Time - south Idaho & east Oregon
US +364708-1084111 America/Shiprock Mountain Time - Navajo
US +332654-1120424 America/Phoenix Mountain Standard Time - Arizona
US +340308-1181434 America/Los_Angeles Pacific Time
US +611305-1495401 America/Anchorage Alaska Time
US +581807-1342511 America/Juneau Alaska Time - Alaska panhandle
US +593249-1394338 America/Yakutat Alaska Time - Alaska panhandle neck
US +643004-1652423 America/Nome Alaska Time - west Alaska
US +515248-1763929 America/Adak Aleutian Islands
US +211825-1575130 Pacific/Honolulu Hawaii
UY -3453-05611 America/Montevideo
UZ +3940+06648 Asia/Samarkand west Uzbekistan
UZ +4120+06918 Asia/Tashkent east Uzbekistan
VA +4154+01227 Europe/Vatican
VC +1309-06114 America/St_Vincent
VE +1030-06656 America/Caracas
VG +1827-06437 America/Tortola
VI +1821-06456 America/St_Thomas
VN +1045+10640 Asia/Ho_Chi_Minh
VU -1740+16825 Pacific/Efate
WF -1318-17610 Pacific/Wallis
WS -1350-17144 Pacific/Apia
YE +1245+04512 Asia/Aden
YT -1247+04514 Indian/Mayotte
ZA -2615+02800 Africa/Johannesburg
ZM -1525+02817 Africa/Lusaka
ZW -1750+03103 Africa/Harare

View File

@ -0,0 +1,129 @@
<?php
/*
* @copyright Copyright (C) 2005-2009 Keyboard Monkeys Ltd. http://www.kb-m.com
* @license http://creativecommons.org/licenses/BSD/ BSD License
* @author Keyboard Monkey Ltd
* @since CommunityID 0.9
* @package CommunityID
* @packager Keyboard Monkeys
*/
class Monkeys_OpenId_Provider_Storage_Database extends Zend_OpenId_Provider_Storage
{
public function addAssociation($handle, $macFunc, $secret, $expires)
{
$associations = new Associations();
$association = $associations->createRow();
$association->handle = $handle;
$association->macfunc = $macFunc;
$association->secret = $secret;
$association->expires = $expires;
$association->save();
return true;
}
public function getAssociation($handle, &$macFunc, &$secret, &$expires)
{
$associations = new Associations();
$association = $associations->getAssociationGivenHandle($handle);
if (!$association) {
return false;
}
if ($association->expires < time()) {
return false;
}
$macFunc = $association->macfunc;
$secret = $association->secret;
$expires = $association->expires;
return true;
}
/**
* Always returns false, since we'll be adding user through the GUI interface only
*/
public function addUser($id, $password)
{
return false;
}
public function hasUser($id)
{
$users = new Users();
$user = $users->getUserWithOpenId($id);
return $user? true : false;
}
public function checkUser($id, $password)
{
$auth = Zend_Auth::getInstance();
$db = Zend_Db::factory(Zend_Registry::get('config')->database);
$authAdapter = new Zend_Auth_Adapter_DbTable($db, 'users', 'openid', 'password');
$authAdapter->setIdentity($id);
$authAdapter->setCredential($password);
$result = $auth->authenticate($authAdapter);
if ($result->isValid()) {
// we don't wanna login into community-id
Zend_Auth::getInstance()->clearIdentity();
return true;
}
return false;
}
/**
* Returns array of all trusted/untrusted sites for given user identified
* by $id
*
* @param string $id user identity URL
* @return array
*/
public function getTrustedSites($id)
{
$users = new Users();
$user = $users->getUserWithOpenId($id);
$sites = new Sites();
$trustedSites = array();
foreach ($sites->getTrusted($user) as $site) {
$trustedSites[$site->site] = unserialize($site->trusted);
}
return $trustedSites;
}
/**
* Stores information about trusted/untrusted site for given user
*
* @param string $id user identity URL
* @param string $site site URL
* @param mixed $trusted trust data from extension or just a boolean value. If null, delete site. I know, bad desing. Blame it on ZF.
* @return bool
*/
public function addSite($id, $site, $trusted)
{
$users = new Users();
$user = $users->getUserWithOpenId($id);
$sites = new Sites();
$sites->deleteForUserSite($user, $site);
if (!is_null($trusted)) {
$siteObj = $sites->createRow();
$siteObj->user_id = $user->id;
$siteObj->site = $site;
$siteObj->creation_date = date('Y-m-d');
$siteObj->trusted = serialize($trusted);
$siteObj->save();
}
return true;
}
}

View File

@ -0,0 +1,38 @@
<?php
/*
* @copyright Copyright (C) 2005-2009 Keyboard Monkeys Ltd. http://www.kb-m.com
* @license http://creativecommons.org/licenses/BSD/ BSD License
* @author Keyboard Monkey Ltd
* @since CommunityID 0.9
* @package CommunityID
* @packager Keyboard Monkeys
*/
class Monkeys_Validate_PasswordConfirmation extends Zend_Validate_Abstract
{
const NOT_MATCH = 'notMatch';
protected $_messageTemplates = array(
self::NOT_MATCH => 'Password confirmation does not match'
);
public function isValid($value, $context = null)
{
$value = (string) $value;
$this->_setValue($value);
if (is_array($context)) {
if (isset($context['password2'])
&& ($value == $context['password2']))
{
return true;
}
} elseif (is_string($context) && ($value == $context)) {
return true;
}
$this->_error(self::NOT_MATCH);
return false;
}
}

View File

@ -0,0 +1,281 @@
<?php
/*
* @copyright Copyright (C) 2005-2009 Keyboard Monkeys Ltd. http://www.kb-m.com
* @license http://creativecommons.org/licenses/BSD/ BSD Licensese
* @author Keyboard Monkeys Ltd.
* @since Textroller 0.9
* @package TextRoller
* @packager Keyboard Monkeys
*/
/**
* Based on
* http://zfsite.andreinikolov.com/2008/05/part-4-zend_form-captcha-password-confirmation-date-selector-field-zend_translate/
*/
class Monkeys_View_Helper_FormDateSelects extends Zend_View_Helper_FormElement
{
private $_months = array(
1 => 'January',
2 => 'February',
3 => 'March',
4 => 'April',
5 => 'May',
6 => 'June',
7 => 'July',
8 => 'August',
9 => 'Septembre',
10 => 'October',
11 => 'November',
12 => 'December'
);
/**
* Translation object
*
* @var Zend_Translate_Adapter
*/
protected $_translator;
public function formDateSelects($name, $value = null, $attribs = null,
$options = null, $listsep = "<br />\n")
{
$info = $this->_getInfo($name, $value, $attribs, $options, $listsep);
extract($info); // name, id, value, attribs, options, listsep, disable
// now start building the XHTML.
$disabled = '';
if (true === $disable) {
$disabled = ' disabled="disabled"';
}
$elementNamesArray = $this->getDayMonthYearFieldNames($name);
$valueDay = $valueMonth = $valueYear = null;
if ($value !== null)
{
$valueExploded = explode('-', $value);
if (!isset($valueExploded[2]))
$value = null;
else
{
$valueDay = (int) $valueExploded[2];
$valueMonth = (int) $valueExploded[1];
$valueYear = (int) $valueExploded[0];
}
}
// Build the surrounding day element first.
$xhtml = '<select '
. ' name="' . $this->view->escape($elementNamesArray['day']) . '"'
. ' id="' . $this->view->escape($id . '_day') . '"'
. $disabled
. $this->_htmlAttribs($attribs)
. ">\n ";
// build the list of options
$list = array();
if ($options['showEmpty'])
{
$list[] = '<option value="-"> </option>';
}
for ($i = 1; $i <= 31; $i++)
{
$list[] = '<option'
. ' value="' . $i . '"'
. ($valueDay === $i ? ' selected="selected"' : '')
. '>' . $i . '';
}
// add the options to the xhtml and close the select
$xhtml .= implode("\n ", $list) . "\n</select>";
// Build the month next
$xhtml .= ' <select '
. ' name="' . $this->view->escape($elementNamesArray['month']) . '"'
. ' id="' . $this->view->escape($id . '_month') . '"'
. $disabled
. $this->_htmlAttribs($attribs)
. ">\n ";
// build the list of options
$list = array();
if ($options['showEmpty'])
{
$list[] = '<option value="-"> </option>';
}
for ($i = 1; $i <= 12; $i++)
{
$list[] = '<option'
. ' value="' . $i . '"'
. ($valueMonth === $i ? ' selected="selected"' : '')
. '>' . $this->_translateValue($this->_months[$i]) . '';
}
// add the options to the xhtml and close the select
$xhtml .= implode("\n ", $list) . "\n</select>";
// Build the years next
$xhtml .= ' <select '
. ' name="' . $this->view->escape($elementNamesArray['year']) . '"'
. ' id="' . $this->view->escape($id . '_year') . '"'
. $disabled
. $this->_htmlAttribs($attribs)
. ">\n ";
// build the list of options
$list = array();
if ($options['showEmpty'])
{
$list[] = '<option value="-"> </option>';
}
if ($options['reverseYears'])
{
for ($i = $options['endYear']; $i >= $options['startYear']; $i--)
{
$list[] = '<option '
. ' value="' . $i . '"'
. ($valueYear === $i ? ' selected="selected"' : '')
. '>' . $i . '</option>';
}
}
else
{
for ($i = $options['startYear']; $i >= $options['endYear']; $i++)
{
$list[] = '<option '
. ' value="' . $i . '"'
. ($valueYear === $i ? ' selected="selected"' : '')
. '>' . $i . '</option>';
}
}
// add the options to the xhtml and close the select
$xhtml .= implode("\n ", $list) . "\n</select>";
return $xhtml;
}
/**
* Makes day, month and year names from given element name. Special case is array notation.
*
* Given a value such as foo[bar][baz], the generated names will be
* foo[bar][baz_day], foo[bar][baz_month] and foo[bar][baz_year]
*
* @param string $value
* @return array
*/
protected function getDayMonthYearFieldNames($value)
{
if (empty($value) || !is_string($value)) {
return $value;
}
$ret = array(
'day' => $value . '_day',
'month' => $value . '_month',
'year' => $value . '_year'
);
if (strstr($value, '['))
{
$endPos = strlen($value) - 1;
if (']' != $value[$endPos]) {
return $ret;
}
$start = strrpos($value, '[') + 1;
$name = substr($value, $start, $endPos - $start);
$arrayName = substr($value, 0, $start-1);
$ret = array(
'day' => $arrayName . '[' . $name . '_day' . ']',
'month' => $arrayName . '[' . $name . '_month' . ']',
'year' => $arrayName . '[' . $name . '_year' . ']'
);
}
return $ret;
}
/**
* Borrowed from multi option value's _translateValue()
*
* @param string $value
* @return string
*/
protected function _translateValue($value)
{
if (is_array($value)) {
foreach ($value as $key => $val) {
$value[$key] = $this->_translateValue($val);
}
return $value;
} else {
if (null !== ($translator = $this->getTranslator())) {
if ($translator->isTranslated($value)) {
return $translator->translate($value);
}
}
return $value;
}
}
/*
* Retrieve translation object (borrowed from Zend_View_Helper_HeadTitle)
*
* If none is currently registered, attempts to pull it from the registry
* using the key 'Zend_Translate'.
*
* @return Zend_Translate_Adapter|null
*/
public function getTranslator()
{
if (null === $this->_translator) {
require_once 'Zend/Registry.php';
if (Zend_Registry::isRegistered('Zend_Translate')) {
$this->setTranslator(Zend_Registry::get('Zend_Translate'));
}
}
return $this->_translator;
}
/**
* Sets a translation Adapter for translation (borrowed from Zend_View_Helper_HeadTitle)
*
* @param Zend_Translate|Zend_Translate_Adapter $translate
* @return Zend_View_Helper_HeadTitle
*/
public function setTranslator($translate)
{
if ($translate instanceof Zend_Translate_Adapter) {
$this->_translator = $translate;
} elseif ($translate instanceof Zend_Translate) {
$this->_translator = $translate->getAdapter();
} else {
require_once 'Zend/View/Exception.php';
throw new Zend_View_Exception("You must set an instance of Zend_Translate or Zend_Translate_Adapter");
}
return $this;
}
private function _translationsHolder()
{
translate('January');
translate('February');
translate('March');
translate('April');
translate('May');
translate('June');
translate('July');
translate('August');
translate('Septembre');
translate('October');
translate('November');
translate('December');
}
}

View File

@ -0,0 +1,26 @@
<?php
/*
* @copyright Copyright (C) 2005-2009 Keyboard Monkeys Ltd. http://www.kb-m.com
* @license http://creativecommons.org/licenses/BSD/ BSD License
* @author Keyboard Monkey Ltd
* @since CommunityID 0.9
* @package CommunityID
* @packager Keyboard Monkeys
*/
class Monkeys_View_Helper_GetBase
{
public function getBase()
{
$ctrl = Zend_Controller_Front::getInstance();
$baseUrl = $ctrl->getBaseUrl();
$url = rtrim($baseUrl, '/');
if (substr($baseUrl, strlen($baseUrl) - 9) == 'index.php') {
$url = substr($baseUrl, 0, strlen($baseUrl) - 10);
}
return $url;
}
}

Binary file not shown.

14371
libs/Monkeys/tests/names.txt Executable file

File diff suppressed because it is too large Load Diff

234935
libs/Monkeys/tests/words.txt Executable file

File diff suppressed because it is too large Load Diff