diff --git a/ktapi/KTAPICollection.inc.php b/ktapi/KTAPICollection.inc.php new file mode 100644 index 0000000..03de34e --- /dev/null +++ b/ktapi/KTAPICollection.inc.php @@ -0,0 +1,75 @@ +. + * + * You can contact KnowledgeTree Inc., PO Box 7775 #87847, San Francisco, + * California 94120-7775, or email info@knowledgetree.com. + * + * The interactive user interfaces in modified source and object code versions + * of this program must display Appropriate Legal Notices, as required under + * Section 5 of the GNU General Public License version 3. + * + * In accordance with Section 7(b) of the GNU General Public License version 3, + * these Appropriate Legal Notices must retain the display of the "Powered by + * KnowledgeTree" logo and retain the original copyright notice. If the display of the + * logo is not reasonably feasible for technical reasons, the Appropriate Legal Notices + * must display the words "Powered by KnowledgeTree" and retain the original + * copyright notice. + * Contributor( s): ______________________________________ + * + */ + +class KTAPI_Collection { + + /** + * KTAPI_Collection constructor + * + */ + function __construct() { + + } + + + /** + * This will return the columns for the requested view, defaulting to browse view + * + */ + function get_columns($view = 'ktcore.views.browse') { + $oColumnRegistry =& KTColumnRegistry::getSingleton(); + $columns = $oColumnRegistry->getColumnsForView($view); + + // Flattening columns + + $res = array(); + $i = 0; + foreach($columns as $val) { + foreach($val as $objkey => $objval) { + $res[$i][$objkey] = $objval; + } + $i++; + } + return $res; + } + +} + + +?> \ No newline at end of file diff --git a/ktapi/ktapi.inc.php b/ktapi/ktapi.inc.php index c17a41d..eddf4a5 100644 --- a/ktapi/ktapi.inc.php +++ b/ktapi/ktapi.inc.php @@ -47,6 +47,8 @@ unset($_session_id); require_once(realpath(dirname(__FILE__) . '/../config/dmsDefaults.php')); require_once(KT_LIB_DIR . '/filelike/fsfilelike.inc.php'); require_once(KT_LIB_DIR . '/foldermanagement/folderutil.inc.php'); +require_once(KT_LIB_DIR . '/browse/DocumentCollection.inc.php'); +require_once(KT_LIB_DIR . "/browse/columnregistry.inc.php"); define('KTAPI_DIR',KT_DIR . '/ktapi'); @@ -55,6 +57,7 @@ require_once(KTAPI_DIR .'/KTAPISession.inc.php'); require_once(KTAPI_DIR .'/KTAPIFolder.inc.php'); require_once(KTAPI_DIR .'/KTAPIDocument.inc.php'); require_once(KTAPI_DIR .'/KTAPIAcl.inc.php'); +require_once(KTAPI_DIR .'/KTAPICollection.inc.php'); /** * This class defines functions that MUST exist in the inheriting class @@ -197,6 +200,18 @@ class KTAPI } return $user; } + + function get_columns_for_view($view = 'ktcore.views.browse') { + $ktapi_session = $this->get_session(); + if (is_null($ktapi_session) || PEAR::isError($ktapi_session)) + { + $error = new PEAR_Error(KTAPI_ERROR_SESSION_INVALID); + return $error; + } + + $collection = new KTAPI_Collection(); + return $collection->get_columns($view); + } /** * This returns a permission object or an error object. diff --git a/tests/api/testCollection.php b/tests/api/testCollection.php new file mode 100644 index 0000000..6029055 --- /dev/null +++ b/tests/api/testCollection.php @@ -0,0 +1,17 @@ +start_session('admin', 'admin'); + $this->assertNotError($session); + + $columns = $ktapi->get_columns_for_view(); + + $this->assertIsA($columns, 'array'); + } + +} +?>