Ejemplo n.º 1
0
 public function setupSearchListingTask()
 {
     $typeID = Request::getInt('typeID', 0);
     $hubType = HubType::one($typeID)->row();
     $classpath = $hubType->get('class_path');
     $filepath = $hubType->get('file_path');
     $type = $hubType->get('type');
     require_once PATH_ROOT . DS . $filepath;
     if (strpos($classpath, 'Table') === FALSE) {
         $model = new $classpath();
     } else {
         $database = App::get('db');
         $model = new $classpath($database);
     }
     if (get_parent_class($model) == 'Hubzero\\Database\\Relational') {
         $row = $model->all()->limit(1)->rows();
     } elseif (get_parent_class($model) == 'JTable') {
         $query = $database->getQuery(true);
         $query->select('*');
         $query->limit(1);
         $query->from($model->getTableName());
         $database->setQuery($query);
         $row = $database->loadObjectList();
     }
     // Get the helper for now
     $helper = new Helper();
     // Push data to the the view
     $this->view->row = $row;
     $this->view->type = $type;
     $this->view->dynamicFields = array('cms_link', 'location-aware', 'member');
     $this->view->placeholders = array('title', 'description', 'fulltext', 'createdby', 'created_date', 'tags');
     $this->view->display();
 }
Ejemplo n.º 2
0
 public function saveHubTypeTask()
 {
     // Get Variables
     $name = Request::getVar('type', '');
     $class_path = Request::getVar('class_path', '');
     $file_path = Request::getVar('file_path', '');
     $row = Request::getVar('id', 0);
     $model = HubType::oneOrNew($row);
     $model->set('class_path', $class_path);
     $model->set('file_path', $file_path);
     $model->set('type', $name);
     if (!$model->save()) {
         // Fail
         App::redirect(Route::url('index.php?option=' . $this->_option . '&controller=' . $this->_controller . '&task=searchIndex', false), 'Failed to add HubType.', 'error');
     }
     // Success
     App::redirect(Route::url('/administrator/index.php?option=' . $this->_option . '&controller=' . $this->_controller . '&task=searchIndex', false), 'Successfully added ' . $name . ' to the search index.', 'success');
 }