summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: dcc27b0)
raw | patch | inline | side by side (parent: dcc27b0)
author | cajus <cajus@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Mon, 17 Aug 2009 08:48:58 +0000 (08:48 +0000) | ||
committer | cajus <cajus@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Mon, 17 Aug 2009 08:48:58 +0000 (08:48 +0000) |
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@14073 594d385d-05f5-0310-b6e9-bd551577e9d8
gosa-core/include/class_filter.inc | patch | blob | history | |
gosa-core/include/class_listingSortIterator.inc | [new file with mode: 0644] | patch | blob |
index 3dca983e0da73e86e7cd05643ff0a02bb567bb50..108eb8ee04c7bfced1787595cf943f2b02d3fcd5 100644 (file)
<?php
+/*
+ * This code is part of GOsa (http://www.gosa-project.org)
+ * Copyright (C) 2003-2008 GONICUS GmbH
+ *
+ * ID: $$Id$$
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
class filter {
diff --git a/gosa-core/include/class_listingSortIterator.inc b/gosa-core/include/class_listingSortIterator.inc
--- /dev/null
@@ -0,0 +1,88 @@
+<?php
+/*
+ * This code is part of GOsa (http://www.gosa-project.org)
+ * Copyright (C) 2003-2008 GONICUS GmbH
+ *
+ * ID: $$Id: class_plugin.inc 13896 2009-07-07 07:06:37Z hickert $$
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+class listingSortIterator implements Iterator {
+ private $data;
+
+ public function __construct($data, $attribute, $type= "string") {
+ global $_sortAttribute;
+ global $_sortType;
+ $_sortAttribute= $attribute;
+ $_sortType= $type;
+
+ // Inline function to
+ function attrSort($ao, $bo) {
+ global $_sortAttribute;
+ global $_sortType;
+
+ // Extract values from ao and bo
+ $a= $b= "";
+ if (isset($ao[$_sortAttribute])) {
+ $a= $ao[$_sortAttribute];
+ if (is_array($a)) {
+ $a= $a[0];
+ }
+ }
+ if (isset($bo[$_sortAttribute])) {
+ $b= $bo[$_sortAttribute];
+ if (is_array($b)) {
+ $b= $b[0];
+ }
+ }
+
+ // Take a look at the several types
+ switch ($_sortType) {
+ case 'string':
+ return strnatcmp($a, $b);
+
+ default:
+ die(sprintf(_("Cannot sort entries: method '%s' is unknown!"), $_sortType));
+ }
+ }
+
+ // Sort for attribute
+ usort($data, "attrSort");
+ $this->data= $data;
+ }
+
+ function rewind() {
+ return reset($this->data);
+ }
+
+ function current() {
+ return current($this->data);
+ }
+
+ function key() {
+ return key($this->data);
+ }
+
+ function next() {
+ return next($this->data);
+ }
+
+ function valid() {
+ return key($this->data) !== null;
+ }
+}
+
+?>