public function setupDefaults($navs)
 {
     // Create a new layout called 'Default'
     $defaultLayout = CpNav_LayoutRecord::model()->findById('1');
     if ($defaultLayout) {
         $layoutsRecord = $defaultLayout;
     } else {
         $layoutsRecord = new CpNav_LayoutRecord();
     }
     //$layoutsRecord->id = '1';
     $layoutsRecord->name = 'Default';
     $layoutsRecord->isDefault = '1';
     $layoutsRecord->save();
     // With this new layout in mind, populate the nav table with items from the default cp nav
     $i = 0;
     foreach ($navs as $key => $value) {
         $navRecord = new CpNav_NavRecord();
         $navRecord->layoutId = '1';
         $navRecord->handle = $key;
         $navRecord->currLabel = $value['label'];
         $navRecord->prevLabel = $value['label'];
         $navRecord->enabled = '1';
         $navRecord->order = $i;
         $navRecord->url = array_key_exists('url', $value) ? $value['url'] : $key;
         $navRecord->prevUrl = $navRecord->url;
         $navRecord->manualNav = '0';
         $navRecord->newWindow = '0';
         $navRecord->save();
         $i++;
     }
 }
 public function createNav($value)
 {
     $navRecord = new CpNav_NavRecord();
     $navRecord->layoutId = $value['layoutId'];
     $navRecord->handle = $value['handle'];
     $navRecord->currLabel = $value['label'];
     $navRecord->prevLabel = $value['label'];
     $navRecord->enabled = '1';
     $navRecord->url = $value['url'];
     $navRecord->prevUrl = $value['url'];
     $navRecord->order = array_key_exists('order', $value) ? $value['order'] : '99';
     $navRecord->manualNav = array_key_exists('manual', $value) ? true : false;
     $navRecord->newWindow = array_key_exists('newWindow', $value) ? $value['newWindow'] : false;
     if ($navRecord->save()) {
         $nav = CpNav_NavModel::populateModel($navRecord);
         return array('success' => true, 'nav' => $nav);
     } else {
         return array('success' => false, 'error' => $navRecord->getErrors());
     }
 }