コード例 #1
0
ファイル: versions.php プロジェクト: kevinwojo/hubzero-cms
 /**
  * Return data on a resource view (this will be some form of HTML)
  *
  * @param   object   $publication  Current publication
  * @param   string   $option       Name of the component
  * @param   array    $areas        Active area(s)
  * @param   string   $rtrn         Data to be returned
  * @param   string   $version      Version name
  * @param   boolean  $extended     Whether or not to show panel
  * @param   boolean  $authorized
  * @return  array
  */
 public function onPublication($publication, $option, $areas, $rtrn = 'all', $version = 'default', $extended = true, $authorized = false)
 {
     $arr = array('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->onPublicationAreas($publication)) && !array_intersect($areas, array_keys($this->onPublicationAreas($publication)))) {
             $rtrn = 'metadata';
         }
     }
     if ($rtrn == 'all' || $rtrn == 'html') {
         // Get pub configs
         $config = Component::params($option);
         $database = App::get('db');
         $objV = new \Components\Publications\Tables\Version($database);
         $versions = $objV->getVersions($publication->id, $filters = array('public' => 1));
         // Are we allowing contributions
         $contributable = Plugin::isEnabled('projects', 'publications') ? 1 : 0;
         // Instantiate a view
         $view = $this->view('default', 'browse')->set('option', $option)->set('publication', $publication)->set('versions', $versions)->set('config', $config)->set('authorized', $authorized)->set('contributable', $contributable);
         // Return the output
         $arr['html'] = $view->setErrors($this->getErrors())->loadTemplate();
     }
     return $arr;
 }
コード例 #2
0
ファイル: versions.php プロジェクト: mined-gatech/hubzero-cms
 /**
  * Return data on a publication view (this will be some form of HTML)
  *
  * @param      object  	$publication 	Current publication
  * @param      string  	$option    		Name of the component
  * @param      array   	$areas     		Active area(s)
  * @param      string  	$rtrn      		Data to be returned
  * @param      string 	$version 		Version name
  * @param      boolean 	$extended 		Whether or not to show panel
  * @param      string 	$authorized
  * @return     array
  */
 public function onPublication($publication, $option, $areas, $rtrn = 'all', $version = 'default', $extended = true, $authorized = false)
 {
     $arr = array('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->onPublicationAreas($publication)) && !array_intersect($areas, array_keys($this->onPublicationAreas($publication)))) {
             $rtrn = 'metadata';
         }
     }
     $database = App::get('db');
     // Get pub configs
     $config = Component::params($option);
     if ($rtrn == 'all' || $rtrn == 'html') {
         $objV = new \Components\Publications\Tables\Version($database);
         $versions = $objV->getVersions($publication->id, $filters = array('public' => 1));
         // Instantiate a view
         $view = new \Hubzero\Plugin\View(array('folder' => 'publications', 'element' => 'versions', 'name' => 'browse'));
         // Are we allowing contributions
         $view->contributable = Plugin::isEnabled('projects', 'publications') ? 1 : 0;
         // Pass the view some info
         $view->option = $option;
         $view->publication = $publication;
         $view->versions = $versions;
         $view->config = $config;
         $view->authorized = $authorized;
         if ($this->getError()) {
             $view->setError($this->getError());
         }
         // Return the output
         $arr['html'] = $view->loadTemplate();
     }
     return $arr;
 }