[5140] trunk/htdocs/system: K2 and Charcoal now correctly add the menu blocks on activation when no blocks exist .

2 views
Skip to first unread message

s...@habariproject.org

unread,
Jun 13, 2011, 1:38:12 PM6/13/11
to habar...@googlegroups.com
Revision
5140
Author
lildude
Date
2011-06-13 17:37:53 +0000 (Mon, 13 Jun 2011)

Log Message

K2 and Charcoal now correctly add the menu blocks on activation when no blocks exist.  This also now happens for K2 when it is activated on initial installation. This fixes #1439

Modified Paths

Diff

Modified: trunk/htdocs/system/classes/block.php (5139 => 5140)


--- trunk/htdocs/system/classes/block.php	2011-06-13 16:22:05 UTC (rev 5139)
+++ trunk/htdocs/system/classes/block.php	2011-06-13 17:37:53 UTC (rev 5140)
@@ -321,25 +321,25 @@
 	 */
 	public function add_to_area( $area, $order = null, $scope = null )
 	{
-		if(is_null($scope)) {
-			$scope = '';
+		if( is_null( $scope ) ) {
+			$scope = 0;
 		}
-		if(is_null($order) || ! is_int($order)) {
-			$order = DB::get_value('SELECT max(display_order) + 1 FROM {blocks_areas} WHERE area = :area AND scope_id = :scope', array('area'=>$area, 'scope'=>$scope));
-			if(is_null($order)) {
+		if( is_null( $order ) || ! is_int( $order ) ) {
+			$order = DB::get_value( 'SELECT max(display_order) + 1 FROM {blocks_areas} WHERE area = :area AND scope_id = :scope', array( 'area' => $area, 'scope' => $scope ) );
+			if( is_null( $order ) ) {
 				$order = 1;
 			}
 		}
 		else {
-			DB::query('UPDATE {blocks_areas} SET display_order = display_order + 1 WHERE area = :area AND scope_id = :scope AND display_order >= :order', array('area'=>$area, 'scope'=>$scope, 'order'=>$order));
+			DB::query( 'UPDATE {blocks_areas} SET display_order = display_order + 1 WHERE area = :area AND scope_id = :scope AND display_order >= :order', array( 'area' => $area, 'scope' => $scope, 'order' => $order ) );
 		}
 		
 		// If the block isn't saved in the database, insert it.
-		if(!$this->id) {
+		if( !$this->id ) {
 			$this->insert();
 		}
 			
-		$result = DB::query( 'INSERT INTO {blocks_areas} (block_id, area, scope_id, display_order) VALUES (:block_id, :area, :scope_id, :display_order)', array( 'block_id'=>$this->id, 'area'=>$area, 'scope_id'=>$scope, 'display_order'=>$order ) );
+		$result = DB::query( 'INSERT INTO {blocks_areas} (block_id, area, scope_id, display_order) VALUES (:block_id, :area, :scope_id, :display_order)', array( 'block_id' => $this->id, 'area' => $area, 'scope_id' => $scope, 'display_order' => $order ) );
 	}
 }
 

Modified: trunk/htdocs/system/handlers/installhandler.php (5139 => 5140)


--- trunk/htdocs/system/handlers/installhandler.php	2011-06-13 16:22:05 UTC (rev 5139)
+++ trunk/htdocs/system/handlers/installhandler.php	2011-06-13 17:37:53 UTC (rev 5140)
@@ -730,6 +730,7 @@
 		Options::set( 'atom_entries', '5' );
 		Options::set( 'theme_name', 'k2' );
 		Options::set( 'theme_dir', 'k2' );
+		Themes::activate_theme( 'k2', 'k2' );
 		Options::set( 'comments_require_id', 1 );
 		Options::set( 'locale', $this->handler_vars['locale'] );
 		Options::set( 'timezone', 'UTC' );

Modified: trunk/htdocs/system/themes/charcoal/theme.php (5139 => 5140)


--- trunk/htdocs/system/themes/charcoal/theme.php	2011-06-13 16:22:05 UTC (rev 5139)
+++ trunk/htdocs/system/themes/charcoal/theme.php	2011-06-13 17:37:53 UTC (rev 5140)
@@ -23,7 +23,7 @@
 		if ( empty( $opts ) ) {
 			Options::set_group( __CLASS__, $this->defaults );
 		}
-		$blocks = $this->get_blocks( 'nav', '', $this );
+		$blocks = $this->get_blocks( 'nav', 0, $this );
 		if( count( $blocks ) == 0 ) {
 			$block = new Block( array(
 				'title' => _t( 'Charcoal Menu' ),

Modified: trunk/htdocs/system/themes/k2/theme.php (5139 => 5140)


--- trunk/htdocs/system/themes/k2/theme.php	2011-06-13 16:22:05 UTC (rev 5139)
+++ trunk/htdocs/system/themes/k2/theme.php	2011-06-13 17:37:53 UTC (rev 5140)
@@ -17,7 +17,7 @@
 	 */
 	public function action_theme_activated()
 	{
-		$blocks = $this->get_blocks( 'nav', '', $this );
+		$blocks = $this->get_blocks( 'nav', 0, $this );
 		if ( count( $blocks ) == 0 ) {
 			$block = new Block( array(
 				'title' => _t( 'K2 Menu' ),
Reply all
Reply to author
Forward
0 new messages