Commit ee92821271cd9fedcbf6d3f50e842f2f0107da13
1 parent
35468a8b
Implemented basic Collection class wrapper.
git-svn-id: https://kt-dms.svn.sourceforge.net/svnroot/kt-dms/trunk@9717 c91229c3-7414-0410-bfa2-8a42b809f60b
Showing
3 changed files
with
107 additions
and
0 deletions
ktapi/KTAPICollection.inc.php
0 → 100644
| 1 | +<?php | |
| 2 | + | |
| 3 | +/** | |
| 4 | + * Contains the basic Collection functionality for KTAPI. | |
| 5 | + * | |
| 6 | + * KnowledgeTree Community Edition | |
| 7 | + * Document Management Made Simple | |
| 8 | + * Copyright (C) 2008, 2009 KnowledgeTree Inc. | |
| 9 | + * Portions copyright The Jam Warehouse Software (Pty) Limited | |
| 10 | + * | |
| 11 | + * This program is free software; you can redistribute it and/or modify it under | |
| 12 | + * the terms of the GNU General Public License version 3 as published by the | |
| 13 | + * Free Software Foundation. | |
| 14 | + * | |
| 15 | + * This program is distributed in the hope that it will be useful, but WITHOUT | |
| 16 | + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS | |
| 17 | + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more | |
| 18 | + * details. | |
| 19 | + * | |
| 20 | + * You should have received a copy of the GNU General Public License | |
| 21 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. | |
| 22 | + * | |
| 23 | + * You can contact KnowledgeTree Inc., PO Box 7775 #87847, San Francisco, | |
| 24 | + * California 94120-7775, or email info@knowledgetree.com. | |
| 25 | + * | |
| 26 | + * The interactive user interfaces in modified source and object code versions | |
| 27 | + * of this program must display Appropriate Legal Notices, as required under | |
| 28 | + * Section 5 of the GNU General Public License version 3. | |
| 29 | + * | |
| 30 | + * In accordance with Section 7(b) of the GNU General Public License version 3, | |
| 31 | + * these Appropriate Legal Notices must retain the display of the "Powered by | |
| 32 | + * KnowledgeTree" logo and retain the original copyright notice. If the display of the | |
| 33 | + * logo is not reasonably feasible for technical reasons, the Appropriate Legal Notices | |
| 34 | + * must display the words "Powered by KnowledgeTree" and retain the original | |
| 35 | + * copyright notice. | |
| 36 | + * Contributor( s): ______________________________________ | |
| 37 | + * | |
| 38 | + */ | |
| 39 | + | |
| 40 | +class KTAPI_Collection { | |
| 41 | + | |
| 42 | + /** | |
| 43 | + * KTAPI_Collection constructor | |
| 44 | + * | |
| 45 | + */ | |
| 46 | + function __construct() { | |
| 47 | + | |
| 48 | + } | |
| 49 | + | |
| 50 | + | |
| 51 | + /** | |
| 52 | + * This will return the columns for the requested view, defaulting to browse view | |
| 53 | + * | |
| 54 | + */ | |
| 55 | + function get_columns($view = 'ktcore.views.browse') { | |
| 56 | + $oColumnRegistry =& KTColumnRegistry::getSingleton(); | |
| 57 | + $columns = $oColumnRegistry->getColumnsForView($view); | |
| 58 | + | |
| 59 | + // Flattening columns | |
| 60 | + | |
| 61 | + $res = array(); | |
| 62 | + $i = 0; | |
| 63 | + foreach($columns as $val) { | |
| 64 | + foreach($val as $objkey => $objval) { | |
| 65 | + $res[$i][$objkey] = $objval; | |
| 66 | + } | |
| 67 | + $i++; | |
| 68 | + } | |
| 69 | + return $res; | |
| 70 | + } | |
| 71 | + | |
| 72 | +} | |
| 73 | + | |
| 74 | + | |
| 75 | +?> | |
| 0 | 76 | \ No newline at end of file | ... | ... |
ktapi/ktapi.inc.php
| ... | ... | @@ -47,6 +47,8 @@ unset($_session_id); |
| 47 | 47 | require_once(realpath(dirname(__FILE__) . '/../config/dmsDefaults.php')); |
| 48 | 48 | require_once(KT_LIB_DIR . '/filelike/fsfilelike.inc.php'); |
| 49 | 49 | require_once(KT_LIB_DIR . '/foldermanagement/folderutil.inc.php'); |
| 50 | +require_once(KT_LIB_DIR . '/browse/DocumentCollection.inc.php'); | |
| 51 | +require_once(KT_LIB_DIR . "/browse/columnregistry.inc.php"); | |
| 50 | 52 | |
| 51 | 53 | define('KTAPI_DIR',KT_DIR . '/ktapi'); |
| 52 | 54 | |
| ... | ... | @@ -55,6 +57,7 @@ require_once(KTAPI_DIR .'/KTAPISession.inc.php'); |
| 55 | 57 | require_once(KTAPI_DIR .'/KTAPIFolder.inc.php'); |
| 56 | 58 | require_once(KTAPI_DIR .'/KTAPIDocument.inc.php'); |
| 57 | 59 | require_once(KTAPI_DIR .'/KTAPIAcl.inc.php'); |
| 60 | +require_once(KTAPI_DIR .'/KTAPICollection.inc.php'); | |
| 58 | 61 | |
| 59 | 62 | /** |
| 60 | 63 | * This class defines functions that MUST exist in the inheriting class |
| ... | ... | @@ -197,6 +200,18 @@ class KTAPI |
| 197 | 200 | } |
| 198 | 201 | return $user; |
| 199 | 202 | } |
| 203 | + | |
| 204 | + function get_columns_for_view($view = 'ktcore.views.browse') { | |
| 205 | + $ktapi_session = $this->get_session(); | |
| 206 | + if (is_null($ktapi_session) || PEAR::isError($ktapi_session)) | |
| 207 | + { | |
| 208 | + $error = new PEAR_Error(KTAPI_ERROR_SESSION_INVALID); | |
| 209 | + return $error; | |
| 210 | + } | |
| 211 | + | |
| 212 | + $collection = new KTAPI_Collection(); | |
| 213 | + return $collection->get_columns($view); | |
| 214 | + } | |
| 200 | 215 | |
| 201 | 216 | /** |
| 202 | 217 | * This returns a permission object or an error object. | ... | ... |
tests/api/testCollection.php
0 → 100644
| 1 | +<?php | |
| 2 | +require_once (dirname(__FILE__) . '/../test.php'); | |
| 3 | +require_once (KT_DIR . '/ktapi/ktapi.inc.php'); | |
| 4 | +class APICollectionTestCase extends KTUnitTestCase { | |
| 5 | + | |
| 6 | + function testCollection() { | |
| 7 | + $ktapi = new KTAPI(); | |
| 8 | + $session = $ktapi->start_session('admin', 'admin'); | |
| 9 | + $this->assertNotError($session); | |
| 10 | + | |
| 11 | + $columns = $ktapi->get_columns_for_view(); | |
| 12 | + | |
| 13 | + $this->assertIsA($columns, 'array'); | |
| 14 | + } | |
| 15 | + | |
| 16 | +} | |
| 17 | +?> | ... | ... |