Beispiel #1
0
 /**
  * Return data on a resource view (this will be some form of HTML)
  *
  * @param   object  $resource  Current resource
  * @param   string  $option    Name of the component
  * @param   array   $areas     Active area(s)
  * @param   string  $rtrn      Data to be returned
  * @return  array
  */
 public function onResources($model, $option, $areas, $rtrn = 'all')
 {
     $arr = array('area' => $this->_name, 'html' => '', 'metadata' => '');
     // Check if our area is in the array of areas we want to return results for
     if (is_array($areas)) {
         if (!array_intersect($areas, $this->onResourcesAreas($model)) && !array_intersect($areas, array_keys($this->onResourcesAreas($model)))) {
             $rtrn = 'metadata';
         }
     }
     // Display only for tools
     if (!$model->isTool()) {
         return $arr;
     }
     if ($rtrn == 'all' || $rtrn == 'html') {
         $database = App::get('db');
         $tv = new \Components\Tools\Tables\Version($database);
         $rows = $tv->getVersions($model->resource->alias);
         // Get contribtool params
         $tconfig = Component::params('com_tools');
         // Instantiate a view
         $view = $this->view('default', 'browse')->set('tconfig', $tconfig)->set('option', $option)->set('resource', $model->resource)->set('rows', $rows);
         // Return the output
         $arr['html'] = $view->loadTemplate();
     }
     if ($rtrn == 'all' || $rtrn == 'metadata') {
         $arr['metadata'] = '';
     }
     return $arr;
 }