CC-2166: Packaging Improvements. Moved the Zend app into airtime_mvc. It is now installed to /var/www/airtime. Storage is now set to /srv/airtime/stor. Utils are now installed to /usr/lib/airtime/utils/. Added install/airtime-dircheck.php as a simple test to see if everything is install/uninstalled correctly.

This commit is contained in:
Paul Baranowski 2011-04-14 18:55:04 -04:00
parent 514777e8d2
commit b11cbd8159
4546 changed files with 138 additions and 51 deletions

View file

@ -0,0 +1,39 @@
<?php
/**
* Zend Framework
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://framework.zend.com/license/new-bsd
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@zend.com so we can send you a copy immediately.
*
* @category Zend
* @package Zend_Service
* @subpackage Delicious
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: Exception.php 20096 2010-01-06 02:05:09Z bkarwin $
*/
/**
* @see Zend_Service_Exception
*/
require_once 'Zend/Service/Exception.php';
/**
* @category Zend
* @package Zend_Service
* @subpackage Delicious
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Service_Delicious_Exception extends Zend_Service_Exception
{}

View file

@ -0,0 +1,292 @@
<?php
/**
* Zend Framework
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://framework.zend.com/license/new-bsd
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@zend.com so we can send you a copy immediately.
*
* @category Zend
* @package Zend_Service
* @subpackage Delicious
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: Post.php 20096 2010-01-06 02:05:09Z bkarwin $
*/
/**
* @see Zend_Date
*/
require_once 'Zend/Date.php';
/**
* @see Zend_Service_Delicious_SimplePost
*/
require_once 'Zend/Service/Delicious/SimplePost.php';
/**
* Zend_Service_Delicious_Post represents a post of a user that can be edited
*
* @category Zend
* @package Zend_Service
* @subpackage Delicious
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Service_Delicious_Post extends Zend_Service_Delicious_SimplePost
{
/**
* Service that has downloaded the post
*
* @var Zend_Service_Delicious
*/
protected $_service;
/**
* @var int Number of people that have the same post
*/
protected $_others;
/**
* @var Zend_Date Post date
*/
protected $_date;
/**
* @var bool Post share
*/
protected $_shared = true;
/**
* @var string Post hash
*/
protected $_hash;
/**
* Constructs a new del.icio.us post
*
* @param Zend_Service_Delicious $service Service that has downloaded the post
* @param DOMElement|array $values Post content
* @throws Zend_Service_Delicious_Exception
* @return void
*/
public function __construct(Zend_Service_Delicious $service, $values)
{
$this->_service = $service;
if ($values instanceof DOMElement) {
$values = self::_parsePostNode($values);
}
if (!is_array($values) || !isset($values['url']) || !isset($values['title'])) {
/**
* @see Zend_Service_Delicious_Exception
*/
require_once 'Zend/Service/Delicious/Exception.php';
throw new Zend_Service_Delicious_Exception("Second argument must be array with at least 2 keys ('url' and"
. " 'title')");
}
if (isset($values['date']) && ! $values['date'] instanceof Zend_Date) {
/**
* @see Zend_Service_Delicious_Exception
*/
require_once 'Zend/Service/Delicious/Exception.php';
throw new Zend_Service_Delicious_Exception("Date has to be an instance of Zend_Date");
}
foreach (array('url', 'title', 'notes', 'others', 'tags', 'date', 'shared', 'hash') as $key) {
if (isset($values[$key])) {
$this->{"_$key"} = $values[$key];
}
}
}
/**
* Setter for title
*
* @param string $newTitle
* @return Zend_Service_Delicious_Post
*/
public function setTitle($newTitle)
{
$this->_title = (string) $newTitle;
return $this;
}
/**
* Setter for notes
*
* @param string $newNotes
* @return Zend_Service_Delicious_Post
*/
public function setNotes($newNotes)
{
$this->_notes = (string) $newNotes;
return $this;
}
/**
* Setter for tags
*
* @param array $tags
* @return Zend_Service_Delicious_Post
*/
public function setTags(array $tags)
{
$this->_tags = $tags;
return $this;
}
/**
* Add a tag
*
* @param string $tag
* @return Zend_Service_Delicious_Post
*/
public function addTag($tag)
{
$this->_tags[] = (string) $tag;
return $this;
}
/**
* Remove a tag
*
* @param string $tag
* @return Zend_Service_Delicious_Post
*/
public function removeTag($tag)
{
$this->_tags = array_diff($this->_tags, array((string) $tag));
return $this;
}
/**
* Getter for date
*
* @return Zend_Date
*/
public function getDate()
{
return $this->_date;
}
/**
* Getter for others
*
* This property is only populated when posts are retrieved
* with getPosts() method. The getAllPosts() and getRecentPosts()
* methods will not populate this property.
*
* @return int
*/
public function getOthers()
{
return $this->_others;
}
/**
* Getter for hash
*
* @return string
*/
public function getHash()
{
return $this->_hash;
}
/**
* Getter for shared
*
* @return bool
*/
public function getShared()
{
return $this->_shared;
}
/**
* Setter for shared
*
* @param bool $isShared
* @return Zend_Service_Delicious_Post
*/
public function setShared($isShared)
{
$this->_shared = (bool) $isShared;
return $this;
}
/**
* Deletes post
*
* @return Zend_Service_Delicious
*/
public function delete()
{
return $this->_service->deletePost($this->_url);
}
/**
* Saves post
*
* @return DOMDocument
*/
public function save()
{
$parms = array(
'url' => $this->_url,
'description'=> $this->_title,
'extended' => $this->_notes,
'shared' => ($this->_shared ? 'yes' : 'no'),
'tags' => implode(' ', (array) $this->_tags),
'replace' => 'yes'
);
/*
if ($this->_date instanceof Zend_Date) {
$parms['dt'] = $this->_date->get('Y-m-d\TH:i:s\Z');
}
*/
return $this->_service->makeRequest(Zend_Service_Delicious::PATH_POSTS_ADD, $parms);
}
/**
* Extracts content from the DOM element of a post
*
* @param DOMElement $node
* @return array
*/
protected static function _parsePostNode(DOMElement $node)
{
return array(
'url' => $node->getAttribute('href'),
'title' => $node->getAttribute('description'),
'notes' => $node->getAttribute('extended'),
'others' => (int) $node->getAttribute('others'),
'tags' => explode(' ', $node->getAttribute('tag')),
/**
* @todo replace strtotime() with Zend_Date equivalent
*/
'date' => new Zend_Date(strtotime($node->getAttribute('time'))),
'shared' => ($node->getAttribute('shared') == 'no' ? false : true),
'hash' => $node->getAttribute('hash')
);
}
}

View file

@ -0,0 +1,300 @@
<?php
/**
* Zend Framework
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://framework.zend.com/license/new-bsd
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@zend.com so we can send you a copy immediately.
*
* @category Zend
* @package Zend_Service
* @subpackage Delicious
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: PostList.php 20096 2010-01-06 02:05:09Z bkarwin $
*/
/**
* List of posts retrived from the del.icio.us web service
*
* @category Zend
* @package Zend_Service
* @subpackage Delicious
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Service_Delicious_PostList implements Countable, Iterator, ArrayAccess
{
/**
* @var array Array of Zend_Service_Delicious_Post
*/
protected $_posts = array();
/**
* @var Zend_Service_Delicious Service that has downloaded the post list
*/
protected $_service;
/**
* @var int Iterator key
*/
protected $_iteratorKey = 0;
/**
* @param Zend_Service_Delicious $service Service that has downloaded the post
* @param DOMNodeList|array $posts
* @return void
*/
public function __construct(Zend_Service_Delicious $service, $posts = null)
{
$this->_service = $service;
if ($posts instanceof DOMNodeList) {
$this->_constructFromNodeList($posts);
} else if (is_array($posts)) {
$this->_constructFromArray($posts);
}
}
/**
* Transforms DOMNodeList to array of posts
*
* @param DOMNodeList $nodeList
* @return void
*/
private function _constructFromNodeList(DOMNodeList $nodeList)
{
for ($i = 0; $i < $nodeList->length; $i++) {
$curentNode = $nodeList->item($i);
if($curentNode->nodeName == 'post') {
$this->_addPost(new Zend_Service_Delicious_Post($this->_service, $curentNode));
}
}
}
/**
* Transforms the Array to array of posts
*
* @param array $postList
* @return void
*/
private function _constructFromArray(array $postList)
{
foreach ($postList as $f_post) {
$this->_addPost(new Zend_Service_Delicious_SimplePost($f_post));
}
}
/**
* Add a post
*
* @param Zend_Service_Delicious_SimplePost $post
* @return Zend_Service_Delicious_PostList
*/
protected function _addPost(Zend_Service_Delicious_SimplePost $post)
{
$this->_posts[] = $post;
return $this;
}
/**
* Filter list by list of tags
*
* @param array $tags
* @return Zend_Service_Delicious_PostList
*/
public function withTags(array $tags)
{
$postList = new self($this->_service);
foreach ($this->_posts as $post) {
if (count(array_diff($tags, $post->getTags())) == 0) {
$postList->_addPost($post);
}
}
return $postList;
}
/**
* Filter list by tag
*
* @param string $tag
* @return Zend_Service_Delicious_PostList
*/
public function withTag($tag)
{
return $this->withTags(func_get_args());
}
/**
* Filter list by urls matching a regular expression
*
* @param string $regexp
* @return Zend_Service_Delicious_PostList
*/
public function withUrl($regexp)
{
$postList = new self($this->_service);
foreach ($this->_posts as $post) {
if (preg_match($regexp, $post->getUrl())) {
$postList->_addPost($post);
}
}
return $postList;
}
/**
* Return number of posts
*
* Implement Countable::count()
*
* @return int
*/
public function count()
{
return count($this->_posts);
}
/**
* Return the current element
*
* Implement Iterator::current()
*
* @return Zend_Service_Delicious_SimplePost
*/
public function current()
{
return $this->_posts[$this->_iteratorKey];
}
/**
* Return the key of the current element
*
* Implement Iterator::key()
*
* @return int
*/
public function key()
{
return $this->_iteratorKey;
}
/**
* Move forward to next element
*
* Implement Iterator::next()
*
* @return void
*/
public function next()
{
$this->_iteratorKey += 1;
}
/**
* Rewind the Iterator to the first element
*
* Implement Iterator::rewind()
*
* @return void
*/
public function rewind()
{
$this->_iteratorKey = 0;
}
/**
* Check if there is a current element after calls to rewind() or next()
*
* Implement Iterator::valid()
*
* @return bool
*/
public function valid()
{
$numItems = $this->count();
if ($numItems > 0 && $this->_iteratorKey < $numItems) {
return true;
} else {
return false;
}
}
/**
* Whether the offset exists
*
* Implement ArrayAccess::offsetExists()
*
* @param int $offset
* @return bool
*/
public function offsetExists($offset)
{
return ($offset < $this->count());
}
/**
* Return value at given offset
*
* Implement ArrayAccess::offsetGet()
*
* @param int $offset
* @throws OutOfBoundsException
* @return Zend_Service_Delicious_SimplePost
*/
public function offsetGet($offset)
{
if ($this->offsetExists($offset)) {
return $this->_posts[$offset];
} else {
throw new OutOfBoundsException('Illegal index');
}
}
/**
* Throws exception because all values are read-only
*
* Implement ArrayAccess::offsetSet()
*
* @param int $offset
* @param string $value
* @throws Zend_Service_Delicious_Exception
*/
public function offsetSet($offset, $value)
{
/**
* @see Zend_Service_Delicious_Exception
*/
require_once 'Zend/Service/Delicious/Exception.php';
throw new Zend_Service_Delicious_Exception('You are trying to set read-only property');
}
/**
* Throws exception because all values are read-only
*
* Implement ArrayAccess::offsetUnset()
*
* @param int $offset
* @throws Zend_Service_Delicious_Exception
*/
public function offsetUnset($offset)
{
/**
* @see Zend_Service_Delicious_Exception
*/
require_once 'Zend/Service/Delicious/Exception.php';
throw new Zend_Service_Delicious_Exception('You are trying to unset read-only property');
}
}

View file

@ -0,0 +1,123 @@
<?php
/**
* Zend Framework
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://framework.zend.com/license/new-bsd
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@zend.com so we can send you a copy immediately.
*
* @category Zend
* @package Zend_Service
* @subpackage Delicious
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: SimplePost.php 20096 2010-01-06 02:05:09Z bkarwin $
*/
/**
* Represents a publicly available post
*
* @category Zend
* @package Zend_Service
* @subpackage Delicious
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Service_Delicious_SimplePost
{
/**
* @var string Post url
*/
protected $_url;
/**
* @var string Post title
*/
protected $_title;
/**
* @var string Post notes
*/
protected $_notes;
/**
* @var array Post tags
*/
protected $_tags = array();
/**
* Constructor
*
* @param array $post Post data
* @return void
* @throws Zend_Service_Delicious_Exception
*/
public function __construct(array $post)
{
if (!isset($post['u']) || !isset($post['d'])) {
/**
* @see Zend_Service_Delicious_Exception
*/
require_once 'Zend/Service/Delicious/Exception.php';
throw new Zend_Service_Delicious_Exception('Title and URL not set.');
}
$this->_url = $post['u'];
$this->_title = $post['d'];
if (isset($post['t'])) {
$this->_tags = $post['t'];
}
if (isset($post['n'])) {
$this->_notes = $post['n'];
}
}
/**
* Getter for URL
*
* @return string
*/
public function getUrl()
{
return $this->_url;
}
/**
* Getter for title
*
* @return string
*/
public function getTitle()
{
return $this->_title;
}
/**
* Getter for notes
*
* @return string
*/
public function getNotes()
{
return $this->_notes;
}
/**
* Getter for tags
*
* @return array
*/
public function getTags()
{
return $this->_tags;
}
}