From 356fe947ca4be8545cd92b456eeb6dd4bc9d5577 Mon Sep 17 00:00:00 2001 From: ajshort Date: Sat, 16 Apr 2011 00:25:15 +1000 Subject: [PATCH 1/6] API CHANGE: Removed the unused Notifications class. --- email/Notifications.php | 64 ----------------------------------------- 1 file changed, 64 deletions(-) delete mode 100755 email/Notifications.php diff --git a/email/Notifications.php b/email/Notifications.php deleted file mode 100755 index d8299f49a..000000000 --- a/email/Notifications.php +++ /dev/null @@ -1,64 +0,0 @@ - $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; - } - -} - -?> \ No newline at end of file From ae170ad991529f609b1c2e52d9d92a26a7420d3d Mon Sep 17 00:00:00 2001 From: ajshort Date: Sat, 16 Apr 2011 00:26:03 +1000 Subject: [PATCH 2/6] API CHANGE: Removed the unused XML class - use PHP's inbuilt XML support instead. --- integration/XML.php | 182 -------------------------------------------- 1 file changed, 182 deletions(-) delete mode 100755 integration/XML.php diff --git a/integration/XML.php b/integration/XML.php deleted file mode 100755 index 77dacc922..000000000 --- a/integration/XML.php +++ /dev/null @@ -1,182 +0,0 @@ -Building XML parsers with the XML class - * - * 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. - * - * Example - * - * - * 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); - * - * - * @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; - } -} \ No newline at end of file From 381e952aaf3bc4827894e8397915e86902d90867 Mon Sep 17 00:00:00 2001 From: ajshort Date: Sat, 16 Apr 2011 00:27:25 +1000 Subject: [PATCH 3/6] API CHANGE: Removed the unused Archive and TarballArchive classes. --- filesystem/Archive.php | 27 ----------- filesystem/TarballArchive.php | 87 ----------------------------------- 2 files changed, 114 deletions(-) delete mode 100644 filesystem/Archive.php delete mode 100644 filesystem/TarballArchive.php diff --git a/filesystem/Archive.php b/filesystem/Archive.php deleted file mode 100644 index cff3e66f2..000000000 --- a/filesystem/Archive.php +++ /dev/null @@ -1,27 +0,0 @@ - \ No newline at end of file diff --git a/filesystem/TarballArchive.php b/filesystem/TarballArchive.php deleted file mode 100644 index 49e9475cf..000000000 --- a/filesystem/TarballArchive.php +++ /dev/null @@ -1,87 +0,0 @@ -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`; - } - } - -} - -?> \ No newline at end of file From e8dd38eac34e406cfd3dcfd822230153b170a4de Mon Sep 17 00:00:00 2001 From: ajshort Date: Sun, 17 Apr 2011 20:44:37 +1000 Subject: [PATCH 4/6] API CHANGE: Removed DataObjectLog class, the same functionality should be implemented using extensions. --- model/DataObject.php | 10 ---- model/DataObjectLog.php | 113 ---------------------------------------- 2 files changed, 123 deletions(-) delete mode 100755 model/DataObjectLog.php diff --git a/model/DataObject.php b/model/DataObject.php index b6991cd00..788791776 100755 --- a/model/DataObject.php +++ b/model/DataObject.php @@ -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); } /** diff --git a/model/DataObjectLog.php b/model/DataObjectLog.php deleted file mode 100755 index 30b336304..000000000 --- a/model/DataObjectLog.php +++ /dev/null @@ -1,113 +0,0 @@ -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; - } -} - -?> \ No newline at end of file From a95e6ebae860185a0153b40c397b33050a54d7cb Mon Sep 17 00:00:00 2001 From: ajshort Date: Sun, 17 Apr 2011 20:45:29 +1000 Subject: [PATCH 5/6] API CHANGE: Removed long deprecated TreeSelectorField form field. --- forms/TreeSelectorField.php | 86 ------------------------------------- 1 file changed, 86 deletions(-) delete mode 100755 forms/TreeSelectorField.php diff --git a/forms/TreeSelectorField.php b/forms/TreeSelectorField.php deleted file mode 100755 index 814ecc663..000000000 --- a/forms/TreeSelectorField.php +++ /dev/null @@ -1,86 +0,0 @@ -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 << - - - $itemList - -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 "
- - -
"; - - - $obj = singleton($this->sourceObject); - $obj->markPartialTree(10); - - $eval = '"
  • name . '-$child->ID\" class=\"$child->class closed" . ($child->isExpanded() ? "" : " unexpanded") . "\">" . $child->Title . ""'; - echo $obj->getChildrenAsUL("class=\"tree\"", $eval, null, true); - - } - -} - -?> From 1ac23f8f676cb986dac679fbf43e4a7b61d0be68 Mon Sep 17 00:00:00 2001 From: ajshort Date: Sun, 17 Apr 2011 21:57:32 +1000 Subject: [PATCH 6/6] API CHANGE: Removed deprecated AutocompleteTextField form field. --- forms/AutocompleteTextField.php | 54 --------------------------------- 1 file changed, 54 deletions(-) delete mode 100644 forms/AutocompleteTextField.php diff --git a/forms/AutocompleteTextField.php b/forms/AutocompleteTextField.php deleted file mode 100644 index eadf6a516..000000000 --- a/forms/AutocompleteTextField.php +++ /dev/null @@ -1,54 +0,0 @@ -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) . "
    id() . "_Options\" class=\"autocompleteoptions\">
    "; - } - - function FieldHolder() { - $holder = parent::FieldHolder(); - - $id = $this->id(); - - $holder .= << - new Ajax.Autocompleter( '$id', '{$id}_Options', '{$this->optionsURL}', { afterUpdateElement : function(el) { if(el.onajaxupdate) { el.onajaxupdate(); } } } ); - -JS; - - return $holder; - } -} -?> \ No newline at end of file