本文整理汇总了PHP中Civi::resources方法的典型用法代码示例。如果您正苦于以下问题:PHP Civi::resources方法的具体用法?PHP Civi::resources怎么用?PHP Civi::resources使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Civi
的用法示例。
在下文中一共展示了Civi::resources方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: preProcess
/**
* Heart of the viewing process. The runner gets all the meta data for
* the contact and calls the appropriate type of page to view.
*/
public function preProcess()
{
Civi::resources()->addStyleFile('civicrm', 'css/searchForm.css', 1, 'html-header');
$this->_unscheduled = $this->_archived = $archiveLinks = FALSE;
$this->_mailingId = CRM_Utils_Request::retrieve('mid', 'Positive', $this);
$this->_sms = CRM_Utils_Request::retrieve('sms', 'Positive', $this);
$this->assign('sms', $this->_sms);
// check that the user has permission to access mailing id
CRM_Mailing_BAO_Mailing::checkPermission($this->_mailingId);
$this->_action = CRM_Utils_Request::retrieve('action', 'String', $this);
$this->assign('action', $this->_action);
$showLinks = TRUE;
if (CRM_Mailing_Info::workflowEnabled()) {
if (CRM_Core_Permission::check('create mailings')) {
$archiveLinks = TRUE;
}
if (!CRM_Core_Permission::check('access CiviMail') && !CRM_Core_Permission::check('create mailings')) {
$showLinks = FALSE;
}
}
$this->assign('showLinks', $showLinks);
if (CRM_Core_Permission::check('access CiviMail')) {
$archiveLinks = TRUE;
}
if ($archiveLinks == TRUE) {
$this->assign('archiveLinks', $archiveLinks);
}
}
示例2: run
/**
* Run upgrade.
*
* @throws \Exception
*/
public function run()
{
// lets get around the time limit issue if possible for upgrades
if (!ini_get('safe_mode')) {
set_time_limit(0);
}
Civi::resources()->addStyleFile('civicrm', 'css/admin.css');
$upgrade = new CRM_Upgrade_Form();
list($currentVer, $latestVer) = $upgrade->getUpgradeVersions();
CRM_Utils_System::setTitle(ts('Upgrade CiviCRM to Version %1', array(1 => $latestVer)));
$template = CRM_Core_Smarty::singleton();
$template->assign('pageTitle', ts('Upgrade CiviCRM to Version %1', array(1 => $latestVer)));
$template->assign('cancelURL', CRM_Utils_System::url('civicrm/dashboard', 'reset=1'));
$action = CRM_Utils_Array::value('action', $_REQUEST, 'intro');
switch ($action) {
case 'intro':
$this->runIntro();
break;
case 'begin':
$this->runBegin();
break;
case 'finish':
$this->runFinish();
break;
default:
CRM_Core_Error::fatal(ts('Unrecognized upgrade action'));
}
}
示例3: preProcess
/**
* Obtains the group name from url and sets the title.
*/
public function preProcess()
{
Civi::resources()->addStyleFile('civicrm', 'css/admin.css');
CRM_Utils_System::setTitle(ts('CiviCRM Extensions'));
$destination = CRM_Utils_System::url('civicrm/admin/extensions', 'reset=1');
$destination = urlencode($destination);
$this->assign('destination', $destination);
}
示例4: run
/**
* Run page.
*
* @return string
*/
public function run()
{
Civi::resources()->addStyleFile('civicrm', 'css/admin.css');
CRM_Utils_System::setTitle(ts("Configuration Checklist"));
$this->assign('recentlyViewed', FALSE);
$destination = CRM_Utils_System::url('civicrm/admin/configtask', 'reset=1', FALSE, NULL, FALSE);
$destination = urlencode($destination);
$this->assign('destination', $destination);
return parent::run();
}
示例5: run
/**
* Run page.
*
* @return string
*/
public function run()
{
Civi::resources()->addStyleFile('civicrm', 'css/admin.css');
CRM_Utils_System::setTitle(ts("Configuration Checklist"));
$this->assign('recentlyViewed', FALSE);
$destination = CRM_Utils_System::url('civicrm/admin/configtask', 'reset=1', FALSE, NULL, FALSE);
$destination = urlencode($destination);
$this->assign('destination', $destination);
$this->assign('registerSite', htmlspecialchars('https://civicrm.org/register-your-site?src=iam&sid=' . CRM_Utils_System::getSiteID()));
return parent::run();
}
示例6: smarty_function_crmScript
/**
* Add a Javascript file to a specific part of the page
*
* @param array $params
* Array with keys:
* - ext: string, extension name. see CRM_Core_Resources::addScriptFile
* - file: string, relative file path. see CRM_Core_Resources::addScriptFile
* - url: string. see CRM_Core_Resources::addScriptURL
* - weight: int; default: CRM_Core_Resources::DEFAULT_WEIGHT (0)
* - region: string; default: CRM_Core_Resources::DEFAULT_REGION ('html-header')
* @param CRM_Core_Smarty $smarty
*
* @throws Exception
*/
function smarty_function_crmScript($params, &$smarty)
{
$params += array('weight' => CRM_Core_Resources::DEFAULT_WEIGHT, 'region' => CRM_Core_Resources::DEFAULT_REGION, 'ext' => 'civicrm');
if (array_key_exists('file', $params)) {
Civi::resources()->addScriptFile($params['ext'], $params['file'], $params['weight'], $params['region']);
} elseif (array_key_exists('url', $params)) {
Civi::resources()->addScriptUrl($params['url'], $params['weight'], $params['region']);
} else {
CRM_Core_Error::debug_var('crmScript_params', $params);
throw new Exception("crmScript requires url or ext+file");
}
}
示例7: preProcess
/**
* Basic setup.
*/
public function preProcess()
{
Civi::resources()->addStyleFile('civicrm', 'css/admin.css');
$this->_id = $this->get('id');
$this->_BAOName = $this->get('BAOName');
$this->_values = array();
if (isset($this->_id)) {
$params = array('id' => $this->_id);
// this is needed if the form is outside the CRM name space
$baoName = $this->_BAOName;
$baoName::retrieve($params, $this->_values);
}
}
示例8: run
/**
* Run page.
*
* @return string
*/
public function run()
{
Civi::resources()->addStyleFile('civicrm', 'css/admin.css');
$this->assign('registerSite', htmlspecialchars('https://civicrm.org/register-your-site?src=iam&sid=' . CRM_Utils_System::getSiteID()));
$groups = array('Customize Data and Screens' => ts('Customize Data and Screens'), 'Communications' => ts('Communications'), 'Localization' => ts('Localization'), 'Users and Permissions' => ts('Users and Permissions'), 'System Settings' => ts('System Settings'));
$config = CRM_Core_Config::singleton();
if (in_array('CiviContribute', $config->enableComponents)) {
$groups['CiviContribute'] = ts('CiviContribute');
}
if (in_array('CiviMember', $config->enableComponents)) {
$groups['CiviMember'] = ts('CiviMember');
}
if (in_array('CiviEvent', $config->enableComponents)) {
$groups['CiviEvent'] = ts('CiviEvent');
}
if (in_array('CiviMail', $config->enableComponents)) {
$groups['CiviMail'] = ts('CiviMail');
}
if (in_array('CiviCase', $config->enableComponents)) {
$groups['CiviCase'] = ts('CiviCase');
}
if (in_array('CiviReport', $config->enableComponents)) {
$groups['CiviReport'] = ts('CiviReport');
}
if (in_array('CiviCampaign', $config->enableComponents)) {
$groups['CiviCampaign'] = ts('CiviCampaign');
}
$values = CRM_Core_Menu::getAdminLinks();
$this->_showHide = new CRM_Core_ShowHideBlocks();
foreach ($groups as $group => $title) {
$groupId = str_replace(' ', '_', $group);
$this->_showHide->addShow("id_{$groupId}_show");
$this->_showHide->addHide("id_{$groupId}");
$v = CRM_Core_ShowHideBlocks::links($this, $groupId, '', '', FALSE);
if (isset($values[$group])) {
$adminPanel[$groupId] = $values[$group];
$adminPanel[$groupId]['show'] = $v['show'];
$adminPanel[$groupId]['hide'] = $v['hide'];
$adminPanel[$groupId]['title'] = $title;
} else {
$adminPanel[$groupId] = array();
$adminPanel[$groupId]['show'] = '';
$adminPanel[$groupId]['hide'] = '';
$adminPanel[$groupId]['title'] = $title;
}
}
$this->assign('adminPanel', $adminPanel);
$this->_showHide->addToTemplate();
return parent::run();
}
示例9: browse
/**
* Browse all contribution pages.
*
* @param mixed $action
* Unused parameter.
*/
public function browse($action = NULL)
{
Civi::resources()->addStyleFile('civicrm', 'css/searchForm.css', 1, 'html-header');
$this->_sortByCharacter = CRM_Utils_Request::retrieve('sortByCharacter', 'String', $this);
// @todo Unused local variable can be safely removed.
// But are there any side effects of CRM_Utils_Request::retrieve() that we
// need to preserve?
$createdId = CRM_Utils_Request::retrieve('cid', 'Positive', $this, FALSE, 0);
if ($this->_sortByCharacter == 'all' || !empty($_POST)) {
$this->_sortByCharacter = '';
$this->set('sortByCharacter', '');
}
$this->search();
$params = array();
$whereClause = $this->whereClause($params, FALSE);
$this->pagerAToZ($whereClause, $params);
$params = array();
$whereClause = $this->whereClause($params, TRUE);
$this->pager($whereClause, $params);
list($offset, $rowCount) = $this->_pager->getOffsetAndRowCount();
//check for delete CRM-4418
$allowToDelete = CRM_Core_Permission::check('delete in CiviContribute');
$query = "\n SELECT id\n FROM civicrm_contribution_page\n WHERE {$whereClause}\n ORDER BY is_active desc, title asc\n LIMIT {$offset}, {$rowCount}";
$contribPage = CRM_Core_DAO::executeQuery($query, $params, TRUE, 'CRM_Contribute_DAO_ContributionPage');
$contribPageIds = array();
while ($contribPage->fetch()) {
$contribPageIds[$contribPage->id] = $contribPage->id;
}
//get all section info.
$contriPageSectionInfo = CRM_Contribute_BAO_ContributionPage::getSectionInfo($contribPageIds);
$query = "\nSELECT *\nFROM civicrm_contribution_page\nWHERE {$whereClause}\nORDER BY is_active desc, title asc\n LIMIT {$offset}, {$rowCount}";
$dao = CRM_Core_DAO::executeQuery($query, $params, TRUE, 'CRM_Contribute_DAO_ContributionPage');
//get all campaigns.
$allCampaigns = CRM_Campaign_BAO_Campaign::getCampaigns(NULL, NULL, FALSE, FALSE, FALSE, TRUE);
//get configure actions links.
$configureActionLinks = self::configureActionLinks();
while ($dao->fetch()) {
$contribution[$dao->id] = array();
CRM_Core_DAO::storeValues($dao, $contribution[$dao->id]);
// form all action links
$action = array_sum(array_keys($this->actionLinks()));
//add configure actions links.
$action += array_sum(array_keys($configureActionLinks));
//add online contribution links.
$action += array_sum(array_keys(self::onlineContributionLinks()));
//add contribution search links.
$action += array_sum(array_keys(self::contributionLinks()));
if ($dao->is_active) {
$action -= (int) CRM_Core_Action::ENABLE;
} else {
$action -= (int) CRM_Core_Action::DISABLE;
}
//CRM-4418
if (!$allowToDelete) {
$action -= (int) CRM_Core_Action::DELETE;
}
//build the configure links.
$sectionsInfo = CRM_Utils_Array::value($dao->id, $contriPageSectionInfo, array());
$contribution[$dao->id]['configureActionLinks'] = CRM_Core_Action::formLink(self::formatConfigureLinks($sectionsInfo), $action, array('id' => $dao->id), ts('Configure'), TRUE, 'contributionpage.configure.actions', 'ContributionPage', $dao->id);
//build the contributions links.
$contribution[$dao->id]['contributionLinks'] = CRM_Core_Action::formLink(self::contributionLinks(), $action, array('id' => $dao->id), ts('Contributions'), TRUE, 'contributionpage.contributions.search', 'ContributionPage', $dao->id);
//build the online contribution links.
$contribution[$dao->id]['onlineContributionLinks'] = CRM_Core_Action::formLink(self::onlineContributionLinks(), $action, array('id' => $dao->id), ts('Links'), TRUE, 'contributionpage.online.links', 'ContributionPage', $dao->id);
//build the normal action links.
$contribution[$dao->id]['action'] = CRM_Core_Action::formLink(self::actionLinks(), $action, array('id' => $dao->id), ts('more'), TRUE, 'contributionpage.action.links', 'ContributionPage', $dao->id);
//show campaigns on selector.
$contribution[$dao->id]['campaign'] = CRM_Utils_Array::value($dao->campaign_id, $allCampaigns);
}
if (isset($contribution)) {
$this->assign('rows', $contribution);
}
}
示例10: browse
/**
* Browse all events.
*
* @return void
*/
public function browse()
{
Civi::resources()->addStyleFile('civicrm', 'css/searchForm.css', 1, 'html-header');
$this->_sortByCharacter = CRM_Utils_Request::retrieve('sortByCharacter', 'String', $this);
$createdId = CRM_Utils_Request::retrieve('cid', 'Positive', $this, FALSE, 0);
if (strtolower($this->_sortByCharacter) == 'all' || !empty($_POST)) {
$this->_sortByCharacter = '';
$this->set('sortByCharacter', '');
}
$this->_force = $this->_searchResult = NULL;
$this->search();
$params = array();
$this->_force = CRM_Utils_Request::retrieve('force', 'Boolean', $this, FALSE);
$this->_searchResult = CRM_Utils_Request::retrieve('searchResult', 'Boolean', $this);
$whereClause = $this->whereClause($params, FALSE, $this->_force);
$this->pagerAToZ($whereClause, $params);
$params = array();
$whereClause = $this->whereClause($params, TRUE, $this->_force);
// because is_template != 1 would be to simple
$whereClause .= ' AND (is_template = 0 OR is_template IS NULL)';
$this->pager($whereClause, $params);
list($offset, $rowCount) = $this->_pager->getOffsetAndRowCount();
// get all custom groups sorted by weight
$manageEvent = array();
$query = "\n SELECT *\n FROM civicrm_event\n WHERE {$whereClause}\nORDER BY start_date desc\n LIMIT {$offset}, {$rowCount}";
$dao = CRM_Core_DAO::executeQuery($query, $params, TRUE, 'CRM_Event_DAO_Event');
$permissions = CRM_Event_BAO_Event::checkPermission();
//get all campaigns.
$allCampaigns = CRM_Campaign_BAO_Campaign::getCampaigns(NULL, NULL, FALSE, FALSE, FALSE, TRUE);
// get the list of active event pcps
$eventPCPS = array();
$pcpDao = new CRM_PCP_DAO_PCPBlock();
$pcpDao->entity_table = 'civicrm_event';
$pcpDao->find();
while ($pcpDao->fetch()) {
$eventPCPS[$pcpDao->entity_id] = $pcpDao->entity_id;
}
// check if we're in shopping cart mode for events
$enableCart = CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::EVENT_PREFERENCES_NAME, 'enable_cart');
$this->assign('eventCartEnabled', $enableCart);
$mapping = CRM_Utils_Array::first(CRM_Core_BAO_ActionSchedule::getMappings(array('id' => CRM_Event_ActionMapping::EVENT_NAME_MAPPING_ID)));
$eventType = CRM_Core_OptionGroup::values('event_type');
while ($dao->fetch()) {
if (in_array($dao->id, $permissions[CRM_Core_Permission::VIEW])) {
$manageEvent[$dao->id] = array();
$repeat = CRM_Core_BAO_RecurringEntity::getPositionAndCount($dao->id, 'civicrm_event');
$manageEvent[$dao->id]['repeat'] = '';
if ($repeat) {
$manageEvent[$dao->id]['repeat'] = ts('Repeating (%1 of %2)', array(1 => $repeat[0], 2 => $repeat[1]));
}
CRM_Core_DAO::storeValues($dao, $manageEvent[$dao->id]);
// form all action links
$action = array_sum(array_keys($this->links()));
if ($dao->is_active) {
$action -= CRM_Core_Action::ENABLE;
} else {
$action -= CRM_Core_Action::DISABLE;
}
if (!in_array($dao->id, $permissions[CRM_Core_Permission::DELETE])) {
$action -= CRM_Core_Action::DELETE;
}
if (!in_array($dao->id, $permissions[CRM_Core_Permission::EDIT])) {
$action -= CRM_Core_Action::UPDATE;
}
$manageEvent[$dao->id]['action'] = CRM_Core_Action::formLink(self::links(), $action, array('id' => $dao->id), ts('more'), TRUE, 'event.manage.list', 'Event', $dao->id);
$params = array('entity_id' => $dao->id, 'entity_table' => 'civicrm_event', 'is_active' => 1);
$defaults['location'] = CRM_Core_BAO_Location::getValues($params, TRUE);
$manageEvent[$dao->id]['friend'] = CRM_Friend_BAO_Friend::getValues($params);
if (isset($defaults['location']['address'][1]['city'])) {
$manageEvent[$dao->id]['city'] = $defaults['location']['address'][1]['city'];
}
if (isset($defaults['location']['address'][1]['state_province_id'])) {
$manageEvent[$dao->id]['state_province'] = CRM_Core_PseudoConstant::stateProvince($defaults['location']['address'][1]['state_province_id']);
}
//show campaigns on selector.
$manageEvent[$dao->id]['campaign'] = CRM_Utils_Array::value($dao->campaign_id, $allCampaigns);
$manageEvent[$dao->id]['reminder'] = CRM_Core_BAO_ActionSchedule::isConfigured($dao->id, $mapping->getId());
$manageEvent[$dao->id]['is_pcp_enabled'] = CRM_Utils_Array::value($dao->id, $eventPCPS);
$manageEvent[$dao->id]['event_type'] = CRM_Utils_Array::value($manageEvent[$dao->id]['event_type_id'], $eventType);
$manageEvent[$dao->id]['is_repeating_event'] = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_RecurringEntity', $dao->id, 'parent_id', 'entity_id');
// allow hooks to set 'field' value which allows configuration pop-up to show a tab as enabled/disabled
CRM_Utils_Hook::tabset('civicrm/event/manage/rows', $manageEvent, array('event_id' => $dao->id));
}
}
$manageEvent['tab'] = self::tabs($enableCart);
$this->assign('rows', $manageEvent);
$statusTypes = CRM_Event_PseudoConstant::participantStatus(NULL, 'is_counted = 1');
$statusTypesPending = CRM_Event_PseudoConstant::participantStatus(NULL, 'is_counted = 0');
$findParticipants['statusCounted'] = implode(', ', array_values($statusTypes));
$findParticipants['statusNotCounted'] = implode(', ', array_values($statusTypesPending));
$this->assign('findParticipants', $findParticipants);
}