Merge pull request #26 from ajshort/1ac23f8f676cb986dac679fbf43e4a7b61d0be68.

Remove Unused/Deprecated Classes
This commit is contained in:
Sam Minnée 2011-05-01 17:18:32 -07:00
commit 15b4c1e281
8 changed files with 0 additions and 623 deletions

View File

@ -1,64 +0,0 @@
<?php
/**
* The Notifications class allows you to create email notifications for various events.
* It lets your scripts generate a number of notifications, and delay sending of the emails until
* the end of execution, so that multiple notifications can collated together
* @package sapphire
*/
class Notifications extends Object {
protected static $events = array();
/**
* Raise an event that requires notification.
* @param eventType A string used to identify different event types. You can refer back to the events
* raised by this eventType.
* @param item An object related to the notification, such as a database record.
* @param notifyMemberID A person to notify via email about the event. Events won't be notified by
* email until you call {@link notifyByEmail()}
*/
static function event($eventType, $item, $notifyMemberID) {
Notifications::$events[$eventType][$notifyMemberID][] = $item;
}
/**
* Notify the appropriate parties about all instances of this event, by email.
* @param eventType A string, this should match the eventType passed to {@link event()}
* @param emailTemplateClass The class-name of the email template to use.
*/
static function notifyByEmail($eventType, $emailTemplateClass) {
$count = 0;
if(class_exists($emailTemplateClass)) {
foreach(Notifications::$events[$eventType] as $memberID => $items) {
if($memberID) {
$email = new $emailTemplateClass();
$email->populateTemplate(new ArrayData(array(
"Recipient" => DataObject::get_by_id("Member", $memberID),
"BrokenPages" => new DataObjectSet($items),
)));
$email->debug();
$email->send();
$count++;
}
}
}
return $count;
}
/**
* Get all the items that were passed with this event type.
* @param eventType A string, this should match the eventType passed to {@link event()}
*/
static function getItems($eventType) {
$allItems = array();
if(isset(Notifications::$events[$eventType])) {
foreach(Notifications::$events[$eventType] as $memberID => $items) {
$allItems = array_merge($allItems, (array)$items);
}
}
return $allItems;
}
}
?>

View File

@ -1,27 +0,0 @@
<?php
/**
* Class for handling archives.
* To implement a specific archive system, create a subclass of this abstract class, and amend the implementation of Archive::open().
* @package sapphire
* @subpackage filesystem
*/
abstract class Archive extends Object {
/**
* Return an Archive object for the given file.
*/
static function open($filename) {
if(substr($filename, strlen($filename) - strlen('.tar.gz')) == '.tar.gz' ||
substr($filename, strlen($filename) - strlen('.tar.bz2')) == '.tar.bz2' ||
substr($filename, strlen($filename) - strlen('.tar')) == '.tar') {
return new TarballArchive($filename);
}
}
function extractTo($destination, $entries = null) {
}
function listing($path) {
}
}
?>

View File

@ -1,87 +0,0 @@
<?php
/**
* Implementation of .tar, .tar.gz, and .tar.bz2 archive handler.
* @package sapphire
* @subpackage filesystem
*/
class TarballArchive extends Archive {
private $filename = '';
private $compressionModifiers = '';
function __construct($filename) {
$this->filename = $filename;
if(substr($filename, strlen($filename) - strlen('.gz')) == '.gz' ||
substr($filename, strlen($filename) - strlen('.tgz')) == '.tgz') {
$this->compressionModifiers = 'z';
} else if(substr($filename, strlen($filename) - strlen('.bz2')) == '.bz2') {
$compressionModifiers = 'j';
}
}
function listing() {
// Call tar on the command line to get the info we need
$base = BASE_PATH;
$command = "tar -tv{$this->compressionModifiers}f $base/$this->filename";
$consoleList = `$command`;
$listing = array();
// Seperate into an array of lines
$listItems = explode("\n", $consoleList);
foreach($listItems as $listItem) {
// The path is the last thing on the line
$fullpath = substr($listItem, strrpos($listItem, ' ') + 1);
$path = explode('/', $fullpath);
$item = array();
// The first part of the line is the permissions - the first character will be d if it is a directory
$item['type'] = (substr($listItem, 0, 1) == 'd') ? 'directory' : 'file';
if($item['type'] == 'directory') {
$item['listing'] = array();
// If it's a directory, the path will have a slash on the end, so get rid of it.
array_pop($path);
}
// The name of the file/directory is the last item on the path
$name = array_pop($path);
if($name == '') {
continue;
}
$item['path'] = implode('/', $path);
// Put the item in the right place
$dest = &$listing;
foreach($path as $folder) {
// If the directory doesn't exist, create it
if(!isset($dest[$folder])) {
$dest[$folder] = array();
$dest[$folder]['listing'] = array();
$dest[$folder]['type'] = 'directory';
}
$dest = &$dest[$folder]['listing'];
}
// If this is a directory and it's listing has already been created, copy the the listing
if($item['type'] == 'directory' && isset($dest[$name]['listing'])) {
$item['listing'] = $dest[$name]['listing'];
}
$dest[$name] = $item;
}
return $listing;
}
function extractTo($destination, $entries = null) {
if(!isset($entries)) {
$command = "tar -xv{$this->compressionModifiers}f ../$this->filename --directory $destination";
$output = `$command`;
}
}
}
?>

View File

@ -1,54 +0,0 @@
<?php
/**
* Autocompleting text field, using script.aculo.us
*
* @deprecated 2.4 Use third-party alternatives like http://code.google.com/p/ss-module-formfields/ or http://silverstripe.org/tag-field-module/
*
* @package forms
* @subpackage fields-formattedinput
*/
class AutocompleteTextField extends TextField {
protected $optionsURL;
function __construct($name, $title = null, $optionsURL, $value = "", $maxLength = null){
$this->optionsURL = $optionsURL;
parent::__construct($name, $title, $value, $maxLength);
}
function extraClass() {
return parent::extraClass() . " autocomplete";
}
function Field() {
// Requirements::javascript(SAPPHIRE_DIR . '/javascript/AutocompleteTextField.js');
$attributes = array(
'class' => "{$this->class} text" . ($this->extraClass() ? $this->extraClass() : ''),
'type' => 'text',
'id' => $this->id(),
'name' => $this->name,
'value' => $this->Value(),
'tabindex' => $this->getTabIndex(),
'size' => $this->maxLength ? min( $this->maxLength, 30 ) : 30
);
if($this->maxLength) $attributes['maxlength'] = $this->maxLength;
return $this->createTag('input', $attributes) . "<div id=\"" . $this->id() . "_Options\" class=\"autocompleteoptions\"></div>";
}
function FieldHolder() {
$holder = parent::FieldHolder();
$id = $this->id();
$holder .= <<<JS
<script type="text/javascript">
new Ajax.Autocompleter( '$id', '{$id}_Options', '{$this->optionsURL}', { afterUpdateElement : function(el) { if(el.onajaxupdate) { el.onajaxupdate(); } } } );
</script>
JS;
return $holder;
}
}
?>

View File

@ -1,86 +0,0 @@
<?php
/**
* @deprecated Use {@link TreeDropdownField} or {@link TreeMultiselectField}
* @package forms
* @subpackage fields-relational
*/
class TreeSelectorField extends FormField {
protected $sourceObject;
function __construct($name, $title, $sourceObject = "Group") {
$this->sourceObject = $sourceObject;
parent::__construct($name, $title);
}
function Field() {
Requirements::javascript(SAPPHIRE_DIR . "/thirdparty/prototype/prototype.js");
Requirements::javascript(SAPPHIRE_DIR . "/thirdparty/behaviour/behaviour.js");
Requirements::javascript(SAPPHIRE_DIR . "/javascript/prototype_improvements.js");
Requirements::add_i18n_javascript(SAPPHIRE_DIR . '/javascript/lang');
Requirements::javascript(SAPPHIRE_DIR . "/thirdparty/jquery/jquery.js");
Requirements::javascript(SAPPHIRE_DIR . "/javascript/TreeDropdownField.js");
$fieldName = $this->name;
if($this->form) {
$record = $this->form->getRecord();
if($record && $record->hasMethod($fieldName)) $items = $record->$fieldName();
}
if($items) {
foreach($items as $item) {
$titleArray[] =$item->Title;
$idArray[] = $item->ID;
}
if($titleArray) {
$itemList = implode(", ", $titleArray);
$value = implode(",", $idArray);
}
}
$id = $this->id();
return <<<HTML
<div class="TreeSelectorField">
<input type="hidden" name="$this->name" value="$value" />
<input type="button" class="edit" value="edit" />
<span class="items">$itemList</span>
</div>
HTML;
}
/**
* Save the results into the form
*/
function saveInto(DataObject $record) {
$fieldName = $this->name;
$saveDest = $record->$fieldName();
if($this->value) {
$items = preg_split("/ *, */", trim($this->value));
}
$saveDest->setByIDList($items);
}
/**
* Return the site tree
*/
function gettree() {
echo "<div class=\"actions\">
<input type=\"button\" name=\"save\" value=\""._t('TreeSelectorField.SAVE', 'save')."\" />
<input type=\"button\" name=\"cancel\" value=\""._t('TreeSelectorField.CANCEL', 'cancel')."\" />
</div>";
$obj = singleton($this->sourceObject);
$obj->markPartialTree(10);
$eval = '"<li id=\"selector-' . $this->name . '-$child->ID\" class=\"$child->class closed" . ($child->isExpanded() ? "" : " unexpanded") . "\"><a>" . $child->Title . "</a>"';
echo $obj->getChildrenAsUL("class=\"tree\"", $eval, null, true);
}
}
?>

View File

@ -1,182 +0,0 @@
<?php
/**
* XML Class handles parsing xml data within SilverStripe. For reading a RESTFul Service such as flickr or last.fm you should use RestfulService which provides a nicer interface to managing external RSS Feeds.
*
*
* <b>Building XML parsers with the XML class</b>
*
* To use the XML parser, you need to create a subclass. Then you define process_XXX functions to process different tags. The parser walks sequentially through the file and calls the process_XXX functions when it hits different tags.
*
* * **process_(tagname):** This will be called when the parser finds the start tag. It will be passed the attributes of the tag.
* * **process_(tagname)_end:** This will be called when the parser finds the closng tag. It will be passed the attributes and the content of the tag.
*
* * **process_tag :** This will be called if it is implemented and a method has not been created already for the tag being parsed. It is passed the tag name and attributes of the tag.
*
* * **process_tag_end:** This will be called if it is implemented and a method has not been created already for the tag being parsed. It is passed the tag name, the content of the tag and the attributes of the tag.
*
*
* The idea is that within this function, you build up $this->result with a useful representation of the XML data. It could be an array structure, an object, or something else.
*
* There are a couple of methods on the XML object that will help with
*
* * **$this->inContext('(tag)', '(tag).(class)'):** This will return true if the current tag has the specified tags as ancestors, in the order that you've specified.
*
* Finally, there are public methods that can be called on an instantiated XML subclass. This is how you will make use of your new parser.
*
* * **$parser->tidyXHTML($content):** This will run "tidy -asxhtml" on your content. This is useful if you're wanting to use the XML parser to parse HTML that may or may not be XML compliant.
* * **$parser->parse($content):** This will call the parser on the given XML content, and return the $this->result object that gets built.
*
* <b>Example</b>
*
* <code>
* class DeliciousHtmlParser extends XML {
* protected $currentItem = 0;
*
* function process_li($attributes) {
* if($attributes['class'] == "post") {
* $this->currentItem = sizeof($this->parsed);
* }
* }
*
* function process_a_end($content, $attributes) {
* if($this->inContext('li.post','h4.desc')) {
* $this->parsed[$this->currentItem][link] = $attributes[href];
* $this->parsed[$this->currentItem][title] = $content;
*
* } else if($this->inContext('li.post','div.meta') && $attributes['class'] == 'tag') {
* $this->parsed[$this->currentItem][tags][] = $content;
* }
* }
* }
*
* $html = file_get_contents("http://del.icio.us/$user/?setcount=100");
* $parser = new DeliciousHtmlParser();
* $tidyHtml = $parser->tidyXHTML($html);
* $result = $parser->parse($tidyHtml);
* </code>
*
* @package sapphire
* @subpackage misc
*/
class XML extends Object {
protected $parser;
protected $context, $attributeStore;
protected $parsed;
protected $collatedText;
function tidyXHTML($content) {
$cleanFile = TEMP_FOLDER . "/cleaner.tmp";
$fh = fopen($cleanFile,"wb");
fwrite($fh, $content);
fclose($fh);
if(file_exists($cleanFile)) {
$result = `tidy -asxhtml $cleanFile`;
unlink($cleanFile);
return $result;
}
}
function parse($content, $recursive = false) {
$this->parser = xml_parser_create('UTF-8');
// Andrew keeps giving me the wrong FSKING encoding! :-P
$content = ereg_replace('encoding="[^"]+"','encoding="utf-8"', $content);
xml_parser_set_option($this->parser, XML_OPTION_CASE_FOLDING, false);
//xml_parser_set_option($this->parser, XML_OPTION_TARGET_ENCODING, 'UTF-8');
xml_set_object($this->parser, $this);
xml_set_element_handler($this->parser, "tag_open", "tag_close");
xml_set_character_data_handler($this->parser, "cdata");
$this->parsed = null;
$this->context = array();
$this->attributeStore = array();
xml_parse($this->parser, $content);
// Handle a bad encoding type by forcing ISO-8859-15
if(xml_get_error_code($this->parser) == 32 && !$recursive) {
$content = ereg_replace('encoding="[^"]+"','encoding="utf-8"', $content);
return $this->parse($content, true);
}
if($err = xml_get_error_code($this->parser)) {
user_error("XML parser broke with error $err:" . xml_error_string($err), E_USER_ERROR);
}
return $this->parsed;
}
function inContext() {
$items = func_get_args();
$i=0;
foreach($items as $item) {
while($i < sizeof($this->context)) {
if($this->context[$i] == $item) break;
$i++;
}
if($this->context[$i] != $item) return false;
}
return true;
}
function stackActionFor($tag) {
for($i=sizeof($this->contextStack)-1;$i>=0;$i--) {
if($this->context[$i]['tag'] == $tag) return $this->contextStack[$i]['action'];
}
}
function tag_open($parser, $tag, $attributes) {
// Strip namespaces out of tags and attributes
$tag = ereg_replace('[^:]+:','',$tag);
if($attributes) foreach($attributes as $k => $v) $newAttributes[ereg_replace('[^:]+:','',$k)] = $v;
$attributes = isset($newAttributes) ? $newAttributes : $attributes;
if(isset($attributes['class'])) {
$this->context[] = "$tag.{$attributes['class']}";
} else {
$this->context[] = $tag;
}
$this->attributeStore[] = $attributes;
$this->collatedText = "";
$tagProcessorFunc = "process_$tag";
if($this->hasMethod($tagProcessorFunc)) {
$this->$tagProcessorFunc($attributes);
}elseif($this->hasMethod($tagProcessorFunc = "process_tag")){
$this->$tagProcessorFunc($tag, $attributes);
}
if($attributes) foreach($attributes as $k => $v) {
$attProcessorFunc = "processatt_$k";
if($this->hasMethod($attProcessorFunc)) {
$this->$attProcessorFunc($tag, $attributes);
}
}
}
function tag_close($parser, $tag) {
$tag = ereg_replace('[^:]+:','',$tag);
array_pop($this->context);
$attributes = array_pop($this->attributeStore);
if(method_exists($this, $funcName = "process_{$tag}_end")) {
$this->$funcName($this->collatedText, $attributes);
}elseif(method_exists($this,$funcName = "process_tag_end")){
// else run default method
$this->$funcName($tag,$this->collatedText, $attributes);
}
$this->collatedText = "";
}
function cdata($parser, $cdata) {
$this->collatedText .= $cdata;
}
}

View File

@ -974,7 +974,6 @@ class DataObject extends ViewableData implements DataObjectInterface, i18nEntity
* - All relevant tables will be updated.
* - $this->onBeforeWrite() gets called beforehand.
* - Extensions such as Versioned will ammend the database-write to ensure that a version is saved.
* - Calls to {@link DataObjectLog} can be used to see everything that's been changed.
*
* @uses DataExtension->augmentWrite()
*
@ -1116,13 +1115,6 @@ class DataObject extends ViewableData implements DataObjectInterface, i18nEntity
}
DB::manipulate($manipulation);
if(isset($isNewRecord) && $isNewRecord) {
DataObjectLog::addedObject($this);
} else {
DataObjectLog::changedObject($this);
}
$this->onAfterWrite();
$this->changed = null;
@ -1212,8 +1204,6 @@ class DataObject extends ViewableData implements DataObjectInterface, i18nEntity
$this->OldID = $this->ID;
$this->ID = 0;
DataObjectLog::deletedObject($this);
}
/**

View File

@ -1,113 +0,0 @@
<?php
/**
* A DataObjectLog is a log of changes that have been made to the database in this session.
* It was designed to help with updates to the CMS tree, and could be used wherever an Ajax call
* needs to update a complex on-screen representation of your data.
* @package sapphire
* @subpackage model
*/
class DataObjectLog extends Object {
/**
* This must be set to true for the DataObjectLog to work
*/
static $enabled = false;
/**
* The DataObjects that have been added to the database in this session.
* @var array
*/
static $added = array();
/**
* The DataObjects that have been deleted from the database in this session.
* @var array
*/
static $deleted = array();
/**
* The DataObjects that have been changed in the database in this session.
*/
static $changed = array();
/**
* Add this DataObject as added in the log.
* @param DataObject $object
*/
static function addedObject($object) {
if(self::$enabled) {
self::$added[$object->class][] = $object;
}
}
/**
* Add this DataObject as deleted in the log.
* @param DataObject $object
*/
static function deletedObject($object) {
if(self::$enabled) {
self::$deleted[$object->class][] = $object;
}
}
/**
* Add this DataObject as changed in the log.
* @param DataObject $object
*/
static function changedObject($object) {
if(self::$enabled) {
self::$changed[$object->class][] = $object;
}
}
/**
* Get all DataObjects that have been added this session that are of
* the class or a subclass of the class provided.
* @param string $className The class name.
* @return array
*/
static function getAdded($className) {
return self::getByClass($className, self::$added);
}
/**
* Get all DataObjects that have been deleted this session that are of
* the class or a subclass of the class provided.
* @param string $className The class name.
* @return array
*/
static function getDeleted($className) {
return self::getByClass($className, self::$deleted);
}
/**
* Get all DataObjects that have been changed this session that are of
* the class or a subclass of the class provided.
* @param string $className The class name.
* @return array
*/
static function getChanged($className) {
return self::getByClass($className, self::$changed);
}
/**
* Get all DataObjects in the given set that are of the class or a
* subclass of the class provided.
* @param string $className The class name.
* @param array $set The set to search in.
* @return array
*/
static function getByClass($className, $set) {
$allClasses = ClassInfo::subclassesFor($className);
foreach($allClasses as $subClass) {
if(isset($set[$subClass])) {
foreach($set[$subClass] as $page) {
$result[$page->ID] = $page;
}
}
}
return isset($result) ? $result : null;
}
}
?>