First commit
This commit is contained in:
commit
c6e2478c40
13918 changed files with 2303184 additions and 0 deletions
100
sites/all/modules/civicrm/Civi/Angular/Page/Main.php
Normal file
100
sites/all/modules/civicrm/Civi/Angular/Page/Main.php
Normal file
|
@ -0,0 +1,100 @@
|
|||
<?php
|
||||
namespace Civi\Angular\Page;
|
||||
|
||||
/**
|
||||
* This page is simply a container; any Angular modules defined by CiviCRM (or by CiviCRM extensions)
|
||||
* will be activated on this page.
|
||||
*
|
||||
* @link https://issues.civicrm.org/jira/browse/CRM-14479
|
||||
*/
|
||||
class Main extends \CRM_Core_Page {
|
||||
|
||||
/**
|
||||
* The weight to assign to any Angular JS module files.
|
||||
*/
|
||||
const DEFAULT_MODULE_WEIGHT = 200;
|
||||
|
||||
/**
|
||||
* The resource manager.
|
||||
*
|
||||
* Do not use publicly. Inject your own copy!
|
||||
*
|
||||
* @var \CRM_Core_Resources
|
||||
* @deprecated
|
||||
*/
|
||||
public $res;
|
||||
|
||||
/**
|
||||
* The Angular module manager.
|
||||
*
|
||||
* Do not use publicly. Inject your own copy!
|
||||
*
|
||||
* @var \Civi\Angular\Manager
|
||||
* @deprecated
|
||||
*/
|
||||
public $angular;
|
||||
|
||||
/**
|
||||
* The region of the page into which JavaScript will be loaded.
|
||||
*
|
||||
* @var String
|
||||
* @deprecated
|
||||
*/
|
||||
public $region;
|
||||
|
||||
/**
|
||||
* @param string $title
|
||||
* Title of the page.
|
||||
* @param int $mode
|
||||
* Mode of the page.
|
||||
* @param \CRM_Core_Resources|null $res
|
||||
* Resource manager.
|
||||
*/
|
||||
public function __construct($title = NULL, $mode = NULL, $res = NULL) {
|
||||
parent::__construct($title, $mode);
|
||||
$this->res = \CRM_Core_Resources::singleton();
|
||||
$this->angular = \Civi::service('angular');
|
||||
$this->region = \CRM_Utils_Request::retrieve('snippet', 'String') ? 'ajax-snippet' : 'html-header';
|
||||
}
|
||||
|
||||
/**
|
||||
* This function takes care of all the things common to all
|
||||
* pages. This typically involves assigning the appropriate
|
||||
* smarty variable :)
|
||||
*
|
||||
* @return string
|
||||
* The content generated by running this page
|
||||
*/
|
||||
public function run() {
|
||||
$this->registerResources();
|
||||
return parent::run();
|
||||
}
|
||||
|
||||
/**
|
||||
* Register resources required by Angular.
|
||||
*/
|
||||
public function registerResources() {
|
||||
$loader = new \Civi\Angular\AngularLoader();
|
||||
$loader->setPageName('civicrm/a');
|
||||
$loader->setModules(array('crmApp'));
|
||||
$loader->load();
|
||||
|
||||
// If trying to load an Angular page via AJAX, the route must be passed as a
|
||||
// URL parameter, since the server doesn't receive information about
|
||||
// URL fragments (i.e, what comes after the #).
|
||||
\CRM_Core_Resources::singleton()->addSetting(array(
|
||||
'crmApp' => array(
|
||||
'defaultRoute' => NULL,
|
||||
),
|
||||
'angularRoute' => \CRM_Utils_Request::retrieve('route', 'String'),
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function getTemplateFileName() {
|
||||
return 'Civi/Angular/Page/Main.tpl';
|
||||
}
|
||||
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue