diff --git a/lib/browse/columnregistry.inc.php b/lib/browse/columnregistry.inc.php index 347c07c..e60d6f7 100644 --- a/lib/browse/columnregistry.inc.php +++ b/lib/browse/columnregistry.inc.php @@ -57,13 +57,13 @@ class KTColumnRegistry { } function getColumn($sNamespace) { - $aInfo = KTUtil::arrayGet($this->columns, $sNamespace, null); + $aInfo = $this->getColumnInfo($sNamespace); if (empty($aInfo)) { return PEAR::raiseError(sprintf(_kt("No such column: %s"), $sNamespace)); } require_once($aInfo['file']); - + return new $aInfo['class']; } diff --git a/plugins/ktcore/KTColumns.inc.php b/plugins/ktcore/KTColumns.inc.php index f4fca2e..77be114 100644 --- a/plugins/ktcore/KTColumns.inc.php +++ b/plugins/ktcore/KTColumns.inc.php @@ -10,8 +10,12 @@ class AdvancedTitleColumn extends AdvancedColumn { var $sortable = true; var $aOptions = array(); var $aIconPaths = array(); + var $link_folders = true; + var $link_documents = true; - function setOptions($aOptions) { + function setOptions($aOptions) { + $this->link_folders = KTUtil::arrayGet($aOptions, 'link_folders', $this->link_folders, false); + $this->link_documents = KTUtil::arrayGet($aOptions, 'link_documents', $this->link_documents, false); parent::setOptions($aOptions); } @@ -40,16 +44,19 @@ class AdvancedTitleColumn extends AdvancedColumn { function renderFolderLink($aDataRow) { - $outStr = ''; - $outStr .= htmlentities($aDataRow["folder"]->getName(), ENT_NOQUOTES, 'UTF-8'); - $outStr .= ' '; + $outStr = htmlentities($aDataRow["folder"]->getName(), ENT_NOQUOTES, 'UTF-8'); + if($this->link_folders) { + $outStr = '' . $outStr . ''; + } return $outStr; } function renderDocumentLink($aDataRow) { - $outStr = 'getFilename().'">'; - $outStr .= htmlentities($aDataRow["document"]->getName(), ENT_NOQUOTES, 'UTF-8'); - $outStr .= ''; + $outStr = htmlentities($aDataRow["document"]->getName(), ENT_NOQUOTES, 'UTF-8'); + if($this->link_documents) { + $outStr = 'getFilename().'">' . + $outStr . ''; + } return $outStr; } diff --git a/plugins/ktcore/KTWidgets.php b/plugins/ktcore/KTWidgets.php index c587829..814ccb6 100644 --- a/plugins/ktcore/KTWidgets.php +++ b/plugins/ktcore/KTWidgets.php @@ -455,6 +455,8 @@ class KTCoreCollectionWidget extends KTWidget { $this->iFolderId = KTUtil::arrayGet($aOptions, 'folder_id'); if(empty($this->iFolderId)) return PEAR::raiseError(_kt('No initial folder specified specified.')); + $this->aBCUrlParams = KTUtil::arrayGet($aOptions, 'bcurl_params', array()); + $this->aCols = array(); foreach($this->oCollection->columns as $oCol) { $this->aCols[] = $oCol->namespace; @@ -483,8 +485,8 @@ class KTCoreCollectionWidget extends KTWidget { $oCR =& KTColumnRegistry::getSingleton(); //print '
';
 	foreach($this->aCols as $ns) { 
-	    //	    print $ns . "\n";
-	    //	    var_dump($oCR->getColumn($ns)); 
+	    // print $ns . "\n";
+	    // var_dump($oCR->getColumn($ns)); 
 	    $oCR->getColumn($ns);
 	}
 	//var_dump($this->oCollection->columns);
@@ -496,7 +498,7 @@ class KTCoreCollectionWidget extends KTWidget {
 
 class KTCoreCollectionPage extends KTStandardDispatcher {
 
-    function _generate_breadcrumbs(&$oFolder, $sCode) {
+    function _generate_breadcrumbs(&$oFolder, $sCode, $aURLParams) {
         $aBreadcrumbs = array();
         $folder_path_names = $oFolder->getPathArray();
         $folder_path_ids = explode(',', $oFolder->getParentFolderIds());
@@ -506,11 +508,13 @@ class KTCoreCollectionPage extends KTStandardDispatcher {
             array_shift($folder_path_names);
         }
 
+        
+
         foreach (range(0, count($folder_path_ids) - 1) as $index) {
             $id = $folder_path_ids[$index];
-            $url = KTUtil::addQueryString($_SERVER['PHP_SELF'], 
-                                          array('fFolderId' => $id,
-                                                'code' => $sCode));
+        
+            $aParams = kt_array_merge($aURLParams, array('fFolderId'=>$id, 'code'=>$sCode));
+            $url = KTUtil::addQueryString($_SERVER['PHP_SELF'], $aParams);
             $aBreadcrumbs[] = array("url" => $url, "name" => $folder_path_names[$index]);
         }
         
@@ -540,16 +544,17 @@ class KTCoreCollectionPage extends KTStandardDispatcher {
 	$oCollection->setOptions($aOptions);
 
         // add the collection code to the title column QS params
-        $aColOpts = $oCollection->getColumnOptions('ktcore.columns.title');
-
-        $aColOpts['qs_params'] = kt_array_merge(KTUtil::arrayGet($aColOpts, 'qs_params', array()), 
-                                                array('code' => $sCode));
 
-	$oCollection->setColumnOptions('ktcore.columns.title', $aColOpts);
+	foreach($oWidget->aCols as $ns) { 
+            $aColOpts = $oCollection->getColumnOptions($ns);
+            $aColOpts['qs_params'] = kt_array_merge(KTUtil::arrayGet($aColOpts, 'qs_params', array()), 
+                                                    array('code' => $sCode));
+	    $oCollection->setColumnOptions($ns, $aColOpts);
+	}
 
 
         // make the breadcrumbs
-        $aBreadcrumbs = $this->_generate_breadcrumbs($oFolder, $sCode);
+        $aBreadcrumbs = $this->_generate_breadcrumbs($oFolder, $sCode, $oWidget->aBCUrlParams);
 
 	print KTTemplating::renderTemplate('ktcore/forms/widgets/collection', 
 					   array('collection'=>$oCollection,
diff --git a/plugins/ktcore/admin/archivedDocuments.php b/plugins/ktcore/admin/archivedDocuments.php
index 35ce522..0fc3580 100755
--- a/plugins/ktcore/admin/archivedDocuments.php
+++ b/plugins/ktcore/admin/archivedDocuments.php
@@ -68,52 +68,50 @@ class ArchivedDocumentsDispatcher extends KTAdminDispatcher {
         
         // Setup the collection for move display.
         
-        $collection = new DocumentCollection();
+        $aBaseParams = array();
+
+        $collection = new AdvancedCollection();
+
+        $oCR =& KTColumnRegistry::getSingleton();
+
+        // selection col
+        $col = $oCR->getColumn('ktcore.columns.selection');
+        $col->setOptions(array('show_folders' => false, 'rangename' => '_d[]'));
+        $collection->addColumn($col);
         
-        $collection->addColumn(new SelectionColumn("Select","selected_docs[]", false, true));
-        $collection->addColumn(new KTArchiveTitle("Archive Documents","title"));        
+        // title col
+        $col = $oCR->getColumn('ktcore.columns.title');
+        $col->setOptions(array('link_documents' => false));
         
+        $collection->addColumn($col);
+
         $qObj = new ArchivedBrowseQuery($oFolder->getId());
         $collection->setQueryObject($qObj);
 
-        $batchPage = (int) KTUtil::arrayGet($_REQUEST, "page", 0);
-        $batchSize = 20;
-
-        $resultURL = KTUtil::addQueryString($_SERVER['PHP_SELF'], sprintf("fFolderId=%d&action=browse", $sMoveCode, $oFolder->getId()));
-        $collection->setBatching($resultURL, $batchPage, $batchSize);
+        $aOptions = $collection->getEnvironOptions();
+        $aOptions['result_url'] = KTUtil::addQueryString($_SERVER['PHP_SELF'], 
+                                                         array(kt_array_merge($aBaseParams, array('fFolderId' => $oFolder->getId()))));
 
-        // ordering. (direction and column)
-        $displayOrder = KTUtil::arrayGet($_REQUEST, 'sort_order', "asc");
-        if ($displayOrder !== "asc") { $displayOrder = "desc"; }
-        $displayControl = KTUtil::arrayGet($_REQUEST, 'sort_on', "title");
+        $collection->setOptions($aOptions);
 
-        $collection->setSorting($displayControl, $displayOrder);
+	$oWF =& KTWidgetFactory::getSingleton();
+	$oWidget = $oWF->get('ktcore.widgets.collection', 
+			     array('label' => _kt('Browse'),
+				   'description' => _kt('Select something'),
+				   'required' => true,
+				   'name' => 'browse',
+                                   'folder_id' => $oFolder->getId(),
+                                   'bcurl_params' => $aBaseParams,
+				   'collection' => $collection));
 
-        $collection->getResults();    
-        
-        $aBreadcrumbs = array();
-        $folder_path_names = $oFolder->getPathArray();
-        $folder_path_ids = explode(',', $oFolder->getParentFolderIds());
-        $folder_path_ids[] = $oFolder->getId();
-        if ($folder_path_ids[0] == 0) {
-            array_shift($folder_path_ids);
-            array_shift($folder_path_names);
-        }
 
-        foreach (range(0, count($folder_path_ids) - 1) as $index) {
-            $id = $folder_path_ids[$index];
-            $url = KTUtil::addQueryString($_SERVER['PHP_SELF'], sprintf("fFolderId=%d", $sMoveCode, $id));
-            $aBreadcrumbs[] = array("url" => $url, "name" => $folder_path_names[$index]);
-        }
-        
         $oTemplating =& KTTemplating::getSingleton();
         $oTemplate = $oTemplating->loadTemplate("ktcore/document/admin/archivebrowse");
         $aTemplateData = array(
               "context" => $this,
               'folder' => $oFolder,
               'breadcrumbs' => $aBreadcrumbs,
-              'collection' => $collection,
-              'collection_breadcrumbs' => $aBreadcrumbs,
+              'collection' => $oWidget,
         );
         
         return $oTemplate->render($aTemplateData);                  
@@ -129,7 +127,7 @@ class ArchivedDocumentsDispatcher extends KTAdminDispatcher {
     function do_confirm_restore() {
         $this->aBreadcrumbs[] = array('url' => $_SERVER['PHP_SELF'], 'name' => _kt('Archived Documents'));
         
-        $selected_docs = KTUtil::arrayGet($_REQUEST, 'selected_docs', array()); 
+        $selected_docs = KTUtil::arrayGet($_REQUEST, '_d', array()); 
         
         $this->oPage->setTitle(sprintf(_kt('Confirm Restore of %d documents'), count($selected_docs)));
         
diff --git a/plugins/ktstandard/KTDocumentLinks.php b/plugins/ktstandard/KTDocumentLinks.php
index 41e6dfa..2eb6a52 100644
--- a/plugins/ktstandard/KTDocumentLinks.php
+++ b/plugins/ktstandard/KTDocumentLinks.php
@@ -33,33 +33,8 @@ require_once(KT_LIB_DIR . "/browse/BrowseColumns.inc.php");
 require_once(KT_LIB_DIR . "/browse/PartialQuery.inc.php");
 require_once(KT_LIB_DIR . "/browse/browseutil.inc.php");
 
+require_once(KT_LIB_DIR . "/browse/columnregistry.inc.php");
 
-class KTDocumentLinkTitle extends TitleColumn {
-
-    function renderDocumentLink($aDataRow) {
-        $parentDocumentId = KTUtil::arrayGet($_REQUEST, 'fDocumentId');
-        
-        if ($aDataRow["document"]->getId() != $parentDocumentId) {
-            $outStr = 'getFilename().'">';
-            $outStr .= $aDataRow["document"]->getName();
-            $outStr .= '';
-        } else { 
-            $outStr = $aDataRow["document"]->getName() . ' (' . _kt('you cannot link to the source document') . ')';
-        }
-        return $outStr;
-    }
-    
-    function buildDocumentLink($aDataRow) {
-        $parentDocumentId = KTUtil::arrayGet($_REQUEST, 'fDocumentId');
-        return KTUtil::addQueryStringSelf(sprintf('action=type_select&fDocumentId=%d&fTargetDocumentId=%d', $parentDocumentId, $aDataRow["document"]->getId()));
-    }
-
-    function buildFolderLink($aDataRow) {
-        $parentDocumentId = KTUtil::arrayGet($_REQUEST, 'fDocumentId');
-        
-        return KTUtil::addQueryStringSelf(sprintf('action=new&fDocumentId=%d&fFolderId=%d', $parentDocumentId, $aDataRow["folder"]->getId()));
-    }
-}
 
 class KTDocumentLinks extends KTPlugin {
     var $sNamespace = "ktstandard.documentlinks.plugin";
@@ -72,6 +47,8 @@ class KTDocumentLinks extends KTPlugin {
 
     function setup() {
         $this->registerAction('documentaction', 'KTDocumentLinkAction', 'ktcore.actions.document.link');
+        $this->registerColumn(_kt('Link Title'), 'ktdocumentlinks.columns.title', 'KTDocumentLinkTitle', 
+                              dirname(__FILE__) . '/KTDocumentLinksColumns.php');
     }
 }
 
@@ -139,49 +116,47 @@ class KTDocumentLinkAction extends KTDocumentAction {
         
         // Setup the collection for move display.
         
-        $collection = new DocumentCollection();
-        $collection->addColumn(new KTDocumentLinkTitle("Target Documents","title"));        
+        $collection = new AdvancedCollection();
+        $aBaseParams = array('fDocumentId'=>$oParentDocument->getId());
+
+
+        $oCR =& KTColumnRegistry::getSingleton();
+
+        $col = $oCR->getColumn('ktcore.columns.singleselection');
+        $col->setOptions(array('qs_params'=>kt_array_merge($aBaseParams, array('fFolderId'=>$oFolder->getId()))));
+        $collection->addColumn($col);        
+        
+        $col = $oCR->getColumn('ktdocumentlinks.columns.title');
+        $col->setOptions(array('qs_params'=>kt_array_merge($aBaseParams, array('fFolderId'=>$oFolder->getId()))));
+        $collection->addColumn($col);
         
         $qObj = new BrowseQuery($iFolderId);
         $collection->setQueryObject($qObj);
 
-        $batchPage = (int) KTUtil::arrayGet($_REQUEST, "page", 0);
-        $batchSize = 20;
+        $aOptions = $collection->getEnvironOptions();
+        $aOptions['result_url'] = KTUtil::addQueryString($_SERVER['PHP_SELF'], 
+                                                         array(kt_array_merge($aBaseParams, array('fFolderId' => $oFolder->getId()))));
 
-        $resultURL = KTUtil::addQueryStringSelf(sprintf("action=new&fDocumentId=%d&fFolderId=%d", $oParentDocument->getId(), $oFolder->getId()));
-        $collection->setBatching($resultURL, $batchPage, $batchSize);
+        $collection->setOptions($aOptions);
 
-        // ordering. (direction and column)
-        $displayOrder = KTUtil::arrayGet($_REQUEST, 'sort_order', "asc");
-        if ($displayOrder !== "asc") { $displayOrder = "desc"; }
-        $displayControl = KTUtil::arrayGet($_REQUEST, 'sort_on', "title");
+	$oWF =& KTWidgetFactory::getSingleton();
+	$oWidget = $oWF->get('ktcore.widgets.collection', 
+			     array('label' => _kt('Browse'),
+				   'description' => _kt('Select something'),
+				   'required' => true,
+				   'name' => 'browse',
+                                   'folder_id' => $oFolder->getId(),
+                                   'bcurl_params' => $aBaseParams,
+				   'collection' => $collection));
 
-        $collection->setSorting($displayControl, $displayOrder);
 
-        $collection->getResults();    
-        
-        $aBreadcrumbs = array();
-        $folder_path_names = $oFolder->getPathArray();
-        $folder_path_ids = explode(',', $oFolder->getParentFolderIds());
-
-        if ($folder_path_ids[0] == 0) {
-            array_shift($folder_path_ids);
-            array_shift($folder_path_names);
-        }
-        $folder_path_ids[] = $oFolder->getId();
-
-        foreach (range(0, count($folder_path_ids) - 1) as $index) {
-            $id = $folder_path_ids[$index];
-            $url = KTUtil::addQueryStringSelf(sprintf("action=new&fDocumentId=%d&fFolderId=%d", $oParentDocument->getId(), $id));
-            $aBreadcrumbs[] = array("url" => $url, "name" => $folder_path_names[$index]);
-        }
         
         $aTemplateData = array(
               'context' => $this,
               'folder' => $oFolder,
+              'parent' => $oParentDocument,
               'breadcrumbs' => $aBreadcrumbs,
-              'collection' => $collection,
-              'collection_breadcrumbs' => $aBreadcrumbs,
+              'collection' => $oWidget,
               'link_types' => LinkType::getList("id > 0"),
         );
         
@@ -199,7 +174,14 @@ class KTDocumentLinkAction extends KTDocumentAction {
             exit(0);
         }
 
-        $oTargetDocument = Document::get(KTUtil::arrayGet($_REQUEST, 'fTargetDocumentId'));
+        /*
+        print '
';
+        var_dump($_REQUEST);
+        exit(0);
+        */
+
+
+        $oTargetDocument = Document::get(KTUtil::arrayGet($_REQUEST, '_d'));
         if (PEAR::isError($oTargetDocument)) { 
             $this->errorRedirectToMain(_kt('Invalid target document selected.'));
             exit(0);
diff --git a/plugins/ktstandard/KTDocumentLinksColumns.php b/plugins/ktstandard/KTDocumentLinksColumns.php
new file mode 100644
index 0000000..bc42d2e
--- /dev/null
+++ b/plugins/ktstandard/KTDocumentLinksColumns.php
@@ -0,0 +1,59 @@
+getColumn('ktcore.columns.title');
+
+class KTDocumentLinkTitle extends AdvancedTitleColumn {
+    var $namespace = 'ktdocumentlinks.columns.title';
+
+    function renderDocumentLink($aDataRow) {        
+        $aOptions = $this->getOptions();
+        $fParentDocId = KTUtil::arrayGet(KTUtil::arrayGet($aOptions, 'qs_params', array()),
+                                         'fDocumentId', False);
+
+        if ((int)$aDataRow["document"]->getId() === (int)$fParentDocId) {
+            return $aDataRow["document"]->getName() . 
+                ' (' . _kt('you cannot link to the source document') . ')';
+        } else {
+            return parent::renderDocumentLink($aDataRow);
+        }
+    }
+}
+
+?>
\ No newline at end of file
diff --git a/resources/js/collectionframe.js b/resources/js/collectionframe.js
index 7fad175..9752b1d 100644
--- a/resources/js/collectionframe.js
+++ b/resources/js/collectionframe.js
@@ -24,9 +24,13 @@ function setupFrame(frame) {
     var moveInputs = function(e) {
         for(var e in {'input':1, 'select':1, 'textarea':1}) {
             var elms = frame.contentDocument.getElementsByTagName(e);
+            forEach(elms, function(e) {
+                        e.style.display = 'none';
+                    });
             appendChildNodes(form, elms);
         }
     }
+
     resizeFrame(frame);
     connect(frame, 'onload', function(e) { resizeFrame(e.src()); });
     connect(form, 'onsubmit', moveInputs);
diff --git a/templates/ktcore/forms/widgets/collection.smarty b/templates/ktcore/forms/widgets/collection.smarty
index be1e14d..3cd831e 100644
--- a/templates/ktcore/forms/widgets/collection.smarty
+++ b/templates/ktcore/forms/widgets/collection.smarty
@@ -13,6 +13,7 @@
 
 
 
+
 
 
 
diff --git a/templates/ktstandard/action/link.smarty b/templates/ktstandard/action/link.smarty
index 807881f..76b484d 100644
--- a/templates/ktstandard/action/link.smarty
+++ b/templates/ktstandard/action/link.smarty
@@ -4,33 +4,19 @@
 {if $link_types}
 

{i18n}Select a target document to link to.{/i18n}

-

{i18n}Use the folder collection and path below to browse to the document you wish to link to.{/i18n}

- -{foreach from=$collection_breadcrumbs item=breadcrumb name=bc} - -{$breadcrumb.name} - -{if !$smarty.foreach.bc.last} -» -{/if} - -{/foreach} - {$collection->render()} - {else}

{i18n}No link types are defined. Please ask the administrator to add them.{/i18n}