[Fusionforge-commits] r14246 - trunk/src/common/widget

Olivier Berger olberger at fusionforge.org
Fri Aug 26 12:54:41 CEST 2011


Author: olberger
Date: 2011-08-26 12:54:41 +0200 (Fri, 26 Aug 2011)
New Revision: 14246

Modified:
   trunk/src/common/widget/Widget.class.php
   trunk/src/common/widget/WidgetLayoutManager.class.php
Log:
Comments and docs

Modified: trunk/src/common/widget/Widget.class.php
===================================================================
--- trunk/src/common/widget/Widget.class.php	2011-08-26 10:54:34 UTC (rev 14245)
+++ trunk/src/common/widget/Widget.class.php	2011-08-26 10:54:41 UTC (rev 14246)
@@ -59,8 +59,10 @@
 require_once('common/widget/Widget_MyMonitoredDocuments.class.php');
 
 /**
- * Widget
- */
+* "Codendi" Layout Widget
+*
+*/
+        
 /* abstract */ class Widget {
 
 	var $content_id;
@@ -83,6 +85,10 @@
 	function getTitle() {
 		return '';
 	}
+	/**
+	 * TODO : Enter description here ...
+	 * @return string
+	 */
 	function getContent() {
 		return '';
 	}
@@ -160,6 +166,11 @@
 	}
 	function destroy($id) {
 	}
+	/**
+	 * getInstance - Returns an instance of a widget given its name
+	 * @param string $widget_name
+	 * @return Widget instance
+	 */
 	static  function & getInstance($widget_name) {
 		$o = null;
 		switch($widget_name) {
@@ -265,6 +276,7 @@
 			default:
 				//$em = EventManager::instance();
 				//$em->processEvent('widget_instance', array('widget' => $widget_name, 'instance' => &$o));
+				// calls the plugin's hook to get an instance of the widget
 				plugin_hook('widget_instance', array('widget' => $widget_name, 'instance' => &$o));
 				break;
 		}
@@ -273,6 +285,11 @@
 		}
 		return $o;
 	}
+	/**
+	 * getCodendiWidgets - Static
+	 * @param unknown_type $owner_type
+	 * @return multitype:
+	 */
 	static function getCodendiWidgets($owner_type) {
 		switch ($owner_type) {
 			case WidgetLayoutManager::OWNER_TYPE_USER:
@@ -283,6 +300,7 @@
 						);
 				break;
 			case WidgetLayoutManager::OWNER_TYPE_GROUP:
+				// project home widgets
 				$widgets = array('projectdescription', 'projectmembers', 'projectinfo',
 						'projectlatestfilereleases', 'projectlatestdocuments', 'projectlatestnews', 'projectpublicareas', //'projectwikipage' //not yet
 						'projectlatestsvncommits', 'projectlatestcvscommits', 'projecttwitterfollow',
@@ -297,6 +315,7 @@
 				break;
 		}
 
+		// add widgets of the plugins, declared through hooks
 		$plugins_widgets = array();
 		//$em =& EventManager::instance();
 		//$em->processEvent('widgets', array('codendi_widgets' => &$plugins_widgets, 'owner_type' => $owner_type));

Modified: trunk/src/common/widget/WidgetLayoutManager.class.php
===================================================================
--- trunk/src/common/widget/WidgetLayoutManager.class.php	2011-08-26 10:54:34 UTC (rev 14245)
+++ trunk/src/common/widget/WidgetLayoutManager.class.php	2011-08-26 10:54:41 UTC (rev 14246)
@@ -30,6 +30,10 @@
  */
 class WidgetLayoutManager {
 	const OWNER_TYPE_USER  = 'u';
+	/**
+	 * Layout for project home
+	 * @var string
+	 */
 	const OWNER_TYPE_GROUP = 'g';
 	const OWNER_TYPE_HOME  = 'h';
 
@@ -213,13 +217,14 @@
 	}
 
 	/**
-	 * displayAvailableWidgets - Display all widget that the user can add to the layout
+	 * displayAvailableWidgets - Display all widgets that the user can add to the layout
 	 *
 	 * @param	int	owner_id
 	 * @param	char	owner_type
 	 * @param	int	layout_id
 	 */
 	function displayAvailableWidgets($owner_id, $owner_type, $layout_id) {
+		// select already used widgets
 		$used_widgets = array();
 		$sql = "SELECT *
 			FROM layouts_contents
@@ -310,6 +315,7 @@
 			echo '</table>';
 			echo '<input type="submit" id="save" value="'. _("Submit") .'" />';
 		} else {
+			// display the widget selection form
 			$after = '';
 			echo '<table cellpadding="0" cellspacing="0">
 				<tbody>
@@ -453,7 +459,7 @@
 	}
 
 	/**
-	 * _displayWidgetsSelectionForm
+	 * _displayWidgetsSelectionForm - displays a widget selection form
 	 *
 	 * @param  title
 	 * @param  widgets
@@ -467,6 +473,7 @@
 			$categs = $this->getCategories($widgets);
 			$widget_rows = array();
 			if (count($categs)) {
+				// display the categories selector in left panel
 				foreach($categs as $c => $ws) {
 					$widget_rows[$c] = '<a class="widget-categ-switcher" href="#widget-categ-'. $c .'"><span>'.  str_replace('-',' ', $hp->purify($c, CODENDI_PURIFIER_CONVERT_HTML))  .'</span></a>';
 				}
@@ -504,6 +511,7 @@
 				foreach($categs as $c => $ws) {
 					$i = 0;
 					$widget_rows = array();
+					// display widgets of the category
 					foreach($ws as $widget_name => $widget) {
 						$row = '';
 						$row .= '<div class="widget-preview '. $widget->getPreviewCssClass() .'">';
@@ -530,6 +538,13 @@
 		}
 		return $additionnal_html;
 	}
+	
+	/**
+	 * getCategories - sort the widgets in their different categories
+	 * 
+	 * @param array $widgets
+	 * @return array (category => widgets)
+	 */
 	function getCategories($widgets) {
 		$categ = array();
 		foreach($widgets as $widget_name) {




More information about the Fusionforge-commits mailing list