当前位置: 首页>>代码示例>>PHP>>正文


PHP CRM_Core_Resources::singleton方法代码示例

本文整理汇总了PHP中CRM_Core_Resources::singleton方法的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Core_Resources::singleton方法的具体用法?PHP CRM_Core_Resources::singleton怎么用?PHP CRM_Core_Resources::singleton使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CRM_Core_Resources的用法示例。


在下文中一共展示了CRM_Core_Resources::singleton方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: alvcustom_civicrm_config

/**
 * Implements hook_civicrm_config().
 *
 * @link http://wiki.civicrm.org/confluence/display/CRMDOC/hook_civicrm_config
 */
function alvcustom_civicrm_config(&$config)
{
    _alvcustom_civix_civicrm_config($config);
    // Neither _pageRun, _postProcess nor _alterContent delivers this
    // JS to the confirm or transact pages, so _config() it is.
    CRM_Core_Resources::singleton()->addScriptFile('au.org.alv.alvcustom', 'js/alvcustom.js', TRUE);
}
开发者ID:xurizaemon,项目名称:au.org.alv.alvcustom,代码行数:12,代码来源:alvcustom.php

示例2: buildQuickForm

 /**
  * Function to actually build the form
  *
  * @return None
  * @access public
  */
 public function buildQuickForm()
 {
     $this->addFormRule(array('CRM_Mailchimp_Form_Setting', 'formRule'), $this);
     CRM_Core_Resources::singleton()->addStyleFile('uk.co.vedaconsulting.mailchimp', 'css/mailchimp.css');
     $webhook_url = CRM_Utils_System::url('civicrm/mailchimp/webhook', 'reset=1', TRUE, NULL, FALSE, TRUE);
     $this->assign('webhook_url', 'Webhook URL - ' . $webhook_url);
     // Add the API Key Element
     $this->addElement('text', 'api_key', ts('API Key'), array('size' => 48));
     // Add the User Security Key Element
     $this->addElement('text', 'security_key', ts('Security Key'), array('size' => 24));
     // Add Enable or Disable Debugging
     $enableOptions = array(1 => ts('Yes'), 0 => ts('No'));
     $this->addRadio('enable_debugging', ts('Enable Debugging'), $enableOptions, NULL);
     // Create the Submit Button.
     $buttons = array(array('type' => 'submit', 'name' => ts('Save & Test')));
     $groups = CRM_Mailchimp_Utils::getGroupsToSync(array(), null, $membership_only = TRUE);
     foreach ($groups as $group_id => $details) {
         $list = new Mailchimp_Lists(CRM_Mailchimp_Utils::mailchimp());
         $webhookoutput = $list->webhooks($details['list_id']);
         if ($webhookoutput[0]['sources']['api'] == 1) {
             CRM_Mailchimp_Utils::checkDebug('CRM_Mailchimp_Form_Setting - API is set in Webhook setting for listID', $details['list_id']);
             $listID = $details['list_id'];
             CRM_Core_Session::setStatus(ts('API is set in Webhook setting for listID %1', array(1 => $listID)), ts('Error'), 'error');
             break;
         }
     }
     // Add the Buttons.
     $this->addButtons($buttons);
 }
开发者ID:stevekessler,项目名称:uk.co.vedaconsulting.mailchimp,代码行数:35,代码来源:Setting.php

示例3: browse

 function browse()
 {
     CRM_Core_Resources::singleton()->addScriptFile('civicrm', 'js/crm.livePage.js');
     $statusTypes = array();
     $dao = new CRM_Event_DAO_ParticipantStatusType();
     $dao->orderBy('weight');
     $dao->find();
     $visibilities = CRM_Core_PseudoConstant::visibility();
     // these statuses are reserved, but disabled by default - so should be disablable after being enabled
     $disablable = array('On waitlist', 'Awaiting approval', 'Pending from waitlist', 'Pending from approval', 'Rejected');
     while ($dao->fetch()) {
         CRM_Core_DAO::storeValues($dao, $statusTypes[$dao->id]);
         $action = array_sum(array_keys($this->links()));
         if ($dao->is_reserved) {
             $action -= CRM_Core_Action::DELETE;
             if (!in_array($dao->name, $disablable)) {
                 $action -= CRM_Core_Action::DISABLE;
             }
         }
         $action -= $dao->is_active ? CRM_Core_Action::ENABLE : CRM_Core_Action::DISABLE;
         $statusTypes[$dao->id]['action'] = CRM_Core_Action::formLink(self::links(), $action, array('id' => $dao->id), ts('more'), FALSE, 'participantStatusType.manage.action', 'ParticipantStatusType', $dao->id);
         $statusTypes[$dao->id]['visibility'] = $visibilities[$dao->visibility_id];
     }
     $this->assign('rows', $statusTypes);
 }
开发者ID:archcidburnziso,项目名称:civicrm-core,代码行数:25,代码来源:ParticipantStatus.php

示例4: preProcess

 /**
  * Function to set variables up before form is built
  *
  * @return void
  * @access public
  */
 function preProcess()
 {
     $this->_isTemplate = (bool) CRM_Utils_Request::retrieve('template', 'Integer', $this);
     $this->_id = CRM_Utils_Request::retrieve('id', 'Integer', $this);
     if ($this->_isTemplate) {
         CRM_Utils_System::setTitle(ts('New Vacancy Template'));
     }
     if ($this->_id) {
         if ($this->_isTemplate = CRM_Core_DAO::getFieldValue('CRM_HRRecruitment_DAO_HRVacancy', $this->_id, 'is_template')) {
             CRM_Utils_System::setTitle(ts('Edit Vacancy Template'));
         } else {
             CRM_Utils_System::setTitle(ts('Edit Vacancy'));
         }
     }
     $this->assign('isTemplate', $this->_isTemplate);
     $session = CRM_Core_Session::singleton();
     if ($this->_id) {
         $permission = CRM_HRRecruitment_BAO_HRVacancyPermission::checkVacancyPermission($this->_id, array("administer Vacancy", "administer CiviCRM"));
     } else {
         $permission = CRM_Core_Permission::checkAnyPerm(array("administer Vacancy", "administer CiviCRM"));
     }
     if (!$permission) {
         $session->pushUserContext(CRM_Utils_System::url('civicrm'));
         CRM_Core_Error::statusBounce(ts('You do not have the necessary permission to perform this action.'));
     }
     CRM_Core_Resources::singleton()->addScriptFile('org.civicrm.hrrecruitment', 'templates/CRM/HRRecruitment/Form/HRVacancy.js');
 }
开发者ID:JoeMurray,项目名称:civihr,代码行数:33,代码来源:HRVacancy.php

示例5: setDefaultValues

 /**
  * Set default values for the form
  *
  * @return void
  */
 public function setDefaultValues()
 {
     $defaults = array();
     $defaults['web_tracking_report_id'] = civicrm_api3('setting', 'getValue', array('group' => 'Web Tracking', 'name' => 'web_tracking_report_id'));
     CRM_Core_Resources::singleton()->addVars('WebTracking', array('web_tracking_report_id' => $defaults['web_tracking_report_id']));
     return $defaults;
 }
开发者ID:VishalAgarwal,项目名称:org.civicrm.webtracking,代码行数:12,代码来源:Report.php

示例6: run

 function run()
 {
     $rows = self::getAllRows();
     $this->assign('rows', $rows);
     CRM_Core_Resources::singleton()->addScriptFile('com.giantrabbit.civimailchimp', 'js/sync_log.js');
     parent::run();
 }
开发者ID:jaapjansma,项目名称:com.giantrabbit.civimailchimp,代码行数:7,代码来源:SyncLog.php

示例7: run

 /**
  * @return string
  */
 function run()
 {
     CRM_Utils_System::setTitle(ts('API explorer and generator'));
     CRM_Core_Resources::singleton()->addScriptFile('civicrm', 'templates/CRM/Admin/Page/APIExplorer.js')->addScriptUrl('//cdnjs.cloudflare.com/ajax/libs/prettify/r298/prettify.min.js', 99)->addStyleUrl('//cdnjs.cloudflare.com/ajax/libs/prettify/r298/prettify.min.css', 99);
     $this->assign('operators', CRM_Core_DAO::acceptedSQLOperators());
     return parent::run();
 }
开发者ID:prashantgajare,项目名称:civicrm-core,代码行数:10,代码来源:APIExplorer.php

示例8: buildForm

 function buildForm(&$form)
 {
     // Change the label on the "name" fields, and make mandatory
     // (they are mandatory for CC transactions, but not shown as such in the form by default
     // because of the 'pay later' option)
     $fields = array('billing_first_name' => ts('First Name'), 'billing_last_name' => ts('Last Name'), 'billing_individual_prefix' => ts('Title'));
     foreach ($fields as $field => $title) {
         if ($form->elementExists($field)) {
             $e =& $form->getElement($field);
             $e->setLabel($title);
             $form->addRule($field, ts('%1 is a required field.', array(1 => $title)), 'required');
         }
     }
     $fields = array('billing_street_address-5', 'billing_city-5', 'billing_country_id-5', 'billing_state_province_id-5', 'billing_postal_code-5');
     foreach ($fields as $field) {
         if ($form->elementExists($field)) {
             $e =& $form->getElement($field);
             $title = $e->getLabel();
             $form->addRule($field, ts('%1 is a required field.', array(1 => $title)), 'required');
         }
     }
     CRM_Core_Region::instance('page-body')->add(array('template' => 'CRM/Symbioticux/Contribute/Form/Contribution/Main.validate.tpl'));
     // Preview & demo sites should encourage to use a test CC number
     // otherwise users do not know what CC to use, and sometimes use their own.
     if (CRM_Utils_Array::value('action', $_REQUEST) == 'preview' || !empty($GLOBALS['symbioticux_demo']) || CRM_Utils_Array::value('name', $form->_paymentProcessors[1]) == 'Dummy') {
         CRM_Core_Region::instance('page-body')->add(array('template' => 'CRM/Symbioticux/Contribute/Form/Contribution/Main.billing-explain.tpl'));
         $js = "cj('#credit_card_number').click(function(event) {\n               if (! cj(this).val()) {\n                 cj(this).val('4111111111111111').trigger('change');\n                 cj('#cvv2').val('123').trigger('change');\n                 cj('#credit_card_exp_date_m').val('5').trigger('change');\n                 cj('#credit_card_exp_date_Y').val('2018').trigger('change');\n\n                 cj('.symbioticux-billing-explain-cc').prependTo('.credit_card_info-section').slideDown();\n               }\n             });";
         CRM_Core_Resources::singleton()->addScript($js);
     }
     CRM_Core_Region::instance('page-body')->add(array('template' => 'CRM/Symbioticux/Contribute/Form/Contribution/Main.hide-other-amount.tpl'));
     // Remove some CSS classes on the 'submit' button.
     $js = "cj('.crm-submit-buttons .crm-form-submit').addClass('btn btn-primary').removeClass('crm-form-submit').parent().removeClass('crm-button');";
     CRM_Core_Resources::singleton()->addScript($js);
 }
开发者ID:coopsymbiotic,项目名称:coop.symbiotic.symbioticux,代码行数:34,代码来源:Main.php

示例9: run

 public function run()
 {
     /**
      * @var \Civi\Angular\Manager $angular
      */
     //Use our manager instead of the one provided by core
     $angular = new Civi\Angular\VolunteerManager(\CRM_Core_Resources::singleton());
     $moduleNames = $this->parseModuleNames(\CRM_Utils_Request::retrieve('modules', 'String'), $angular);
     switch (\CRM_Utils_Request::retrieve('format', 'String')) {
         case 'json':
         case '':
             $this->send('application/javascript', json_encode($this->getMetadata($moduleNames, $angular)));
             break;
         case 'js':
             $digest = $this->digestJs($angular->getResources($moduleNames, 'js', 'path'));
             //Tell crmResource to use our ajax end-point
             $digest = str_replace("ajax/angular-modules", "ajax/volunteer-angular-modules", $digest);
             $this->send('application/javascript', $digest);
             break;
         case 'css':
             $this->send('text/css', \CRM_Utils_File::concat($angular->getResources($moduleNames, 'css', 'path'), "\n"));
             break;
         default:
             \CRM_Core_Error::fatal("Unrecognized format");
     }
     \CRM_Utils_System::civiExit();
 }
开发者ID:adam-edison,项目名称:org.civicrm.volunteer,代码行数:27,代码来源:Modules.php

示例10: browse

 /**
  * Browse all CiviCRM Profile group fields.
  *
  * @return void
  * @access public
  * @static
  */
 function browse()
 {
     CRM_Core_Resources::singleton()->addScriptFile('civicrm', 'js/crm.livePage.js');
     $ufField = array();
     $ufFieldBAO = new CRM_Core_BAO_UFField();
     // fkey is gid
     $ufFieldBAO->uf_group_id = $this->_gid;
     $ufFieldBAO->orderBy('weight', 'field_name');
     $ufFieldBAO->find();
     $otherModules = CRM_Core_BAO_UFGroup::getUFJoinRecord($this->_gid);
     $this->assign('otherModules', $otherModules);
     $isGroupReserved = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_UFGroup', $this->_gid, 'is_reserved');
     $this->assign('isGroupReserved', $isGroupReserved);
     $profileType = CRM_Core_BAO_UFField::getProfileType($this->_gid);
     if ($profileType == 'Contribution' || $profileType == 'Membership' || $profileType == 'Activity' || $profileType == 'Participant') {
         $this->assign('skipCreate', TRUE);
     }
     $locationType = array();
     $locationType = CRM_Core_PseudoConstant::get('CRM_Core_DAO_Address', 'location_type_id');
     $fields = CRM_Contact_BAO_Contact::exportableFields('All', FALSE, TRUE);
     $fields = array_merge(CRM_Contribute_BAO_Contribution::getContributionFields(), $fields);
     $select = array();
     foreach ($fields as $name => $field) {
         if ($name) {
             $select[$name] = $field['title'];
         }
     }
     $select['group'] = ts('Group(s)');
     $select['tag'] = ts('Tag(s)');
     $visibility = CRM_Core_SelectValues::ufVisibility();
     while ($ufFieldBAO->fetch()) {
         $ufField[$ufFieldBAO->id] = array();
         $phoneType = $locType = '';
         CRM_Core_DAO::storeValues($ufFieldBAO, $ufField[$ufFieldBAO->id]);
         $ufField[$ufFieldBAO->id]['visibility_display'] = $visibility[$ufFieldBAO->visibility];
         $ufField[$ufFieldBAO->id]['label'] = $ufFieldBAO->label;
         $action = array_sum(array_keys($this->actionLinks()));
         if ($ufFieldBAO->is_active) {
             $action -= CRM_Core_Action::ENABLE;
         } else {
             $action -= CRM_Core_Action::DISABLE;
         }
         if ($ufFieldBAO->is_reserved) {
             $action -= CRM_Core_Action::UPDATE;
             $action -= CRM_Core_Action::DISABLE;
             $action -= CRM_Core_Action::DELETE;
         }
         $ufField[$ufFieldBAO->id]['order'] = $ufField[$ufFieldBAO->id]['weight'];
         $ufField[$ufFieldBAO->id]['action'] = CRM_Core_Action::formLink(self::actionLinks(), $action, array('id' => $ufFieldBAO->id, 'gid' => $this->_gid), ts('more'), FALSE, 'ufField.row.actions', 'UFField', $ufFieldBAO->id);
     }
     $returnURL = CRM_Utils_System::url('civicrm/admin/uf/group/field', "reset=1&action=browse&gid={$this->_gid}");
     $filter = "uf_group_id = {$this->_gid}";
     CRM_Utils_Weight::addOrder($ufField, 'CRM_Core_DAO_UFField', 'id', $returnURL, $filter);
     $this->assign('ufField', $ufField);
     // retrieve showBestResult from session
     $session = CRM_Core_Session::singleton();
     $showBestResult = $session->get('showBestResult');
     $this->assign('showBestResult', $showBestResult);
     $session->set('showBestResult', 0);
 }
开发者ID:archcidburnziso,项目名称:civicrm-core,代码行数:67,代码来源:Field.php

示例11: bootstrapvisualize_civicrm_pageRun

function bootstrapvisualize_civicrm_pageRun(&$page)
{
    $pageName = $page->getVar('_name');
    if ($pageName == 'CRM_Civisualize_Page_Main') {
        CRM_Core_Resources::singleton()->addStyleFile('eu.tttp.bootstrapvisualize', 'css/bootstrap.min.css');
    }
}
开发者ID:TechToThePeople,项目名称:bootstrapvisualize,代码行数:7,代码来源:bootstrapvisualize.php

示例12: buildQuickForm

 /**
  * Function to actually build the form
  *
  * @return None
  * @access public
  */
 public function buildQuickForm()
 {
     $this->addFormRule(array('CRM_Mailchimp_Form_Setting', 'formRule'), $this);
     CRM_Core_Resources::singleton()->addStyleFile('uk.co.vedaconsulting.mailchimp', 'css/mailchimp.css');
     $webhook_url = CRM_Utils_System::url('civicrm/mailchimp/webhook', 'reset=1', TRUE, NULL, FALSE, TRUE);
     $this->assign('webhook_url', 'Webhook URL - ' . $webhook_url);
     // Add the API Key Element
     $this->addElement('text', 'api_key', ts('API Key'), array('size' => 48));
     // Add the User Security Key Element
     $this->addElement('text', 'security_key', ts('Security Key'), array('size' => 24));
     // Add Enable or Disable Debugging
     $enableOptions = array(1 => ts('Yes'), 0 => ts('No'));
     $this->addRadio('enable_debugging', ts('Enable Debugging'), $enableOptions, NULL);
     // Create the Submit Button.
     $buttons = array(array('type' => 'submit', 'name' => ts('Save & Test')));
     // Add the Buttons.
     $this->addButtons($buttons);
     try {
         // Initially we won't be able to do this as we don't have an API key.
         $api = CRM_Mailchimp_Utils::getMailchimpApi();
         // Check for warnings and output them as status messages.
         $warnings = CRM_Mailchimp_Utils::checkGroupsConfig();
         foreach ($warnings as $message) {
             CRM_Core_Session::setStatus($message);
         }
     } catch (Exception $e) {
         CRM_Core_Session::setStatus('Could not use the Mailchimp API - ' . $e->getMessage() . ' You will see this message If you have not yet configured your Mailchimp acccount.');
     }
 }
开发者ID:sunilpawar,项目名称:uk.co.vedaconsulting.mailchimp,代码行数:35,代码来源:Setting.php

示例13: addResources

 /**
  * Load needed JS, CSS and settings for the backend Volunteer Management UI
  */
 public static function addResources($entity_id, $entity_table)
 {
     static $loaded = FALSE;
     if ($loaded) {
         return;
     }
     $loaded = TRUE;
     $config = CRM_Core_Config::singleton();
     $ccr = CRM_Core_Resources::singleton();
     // Vendor libraries
     $ccr->addScriptFile('civicrm', 'packages/backbone/json2.js', 100, 'html-header', FALSE);
     $ccr->addScriptFile('civicrm', 'packages/backbone/backbone-min.js', 120, 'html-header');
     $ccr->addScriptFile('civicrm', 'packages/backbone/backbone.marionette.min.js', 125, 'html-header', FALSE);
     // Our stylesheet
     $ccr->addStyleFile('org.civicrm.volunteer', 'css/volunteer_app.css');
     // Add all scripts for our js app
     $weight = 0;
     $baseDir = CRM_Extension_System::singleton()->getMapper()->keyToBasePath('org.civicrm.volunteer') . '/';
     // This glob pattern will recurse the js directory up to 4 levels deep
     foreach (glob($baseDir . 'js/{*,*/*,*/*/*,*/*/*/*}.js', GLOB_BRACE) as $file) {
         $fileName = substr($file, strlen($baseDir));
         $ccr->addScriptFile('org.civicrm.volunteer', $fileName, $weight++);
     }
     // Add our template
     CRM_Core_Smarty::singleton()->assign('isModulePermissionSupported', CRM_Core_Config::singleton()->userPermissionClass->isModulePermissionSupported());
     CRM_Core_Region::instance('page-header')->add(array('template' => 'CRM/Volunteer/Form/Manage.tpl'));
     // Fetch event so we can set the default start time for needs
     // FIXME: Not the greatest for supporting non-events
     $entity = civicrm_api3(str_replace('civicrm_', '', $entity_table), 'getsingle', array('id' => $entity_id));
     // Static variables
     $ccr->addSetting(array('pseudoConstant' => array('volunteer_need_visibility' => array_flip(CRM_Volunteer_BAO_Need::buildOptions('visibility_id', 'validate')), 'volunteer_role' => CRM_Volunteer_BAO_Need::buildOptions('role_id', 'get'), 'volunteer_status' => CRM_Activity_BAO_Activity::buildOptions('status_id', 'validate')), 'volunteer' => array('default_date' => CRM_Utils_Array::value('start_date', $entity)), 'config' => array('timeInputFormat' => $config->timeInputFormat)));
     // Check for problems
     _volunteer_civicrm_check_resource_url();
 }
开发者ID:relldoesphp,项目名称:civivolunteer,代码行数:37,代码来源:Manage.php

示例14: statelegemail_civicrm_buildForm

/**
 * Implements hook_civicrm_buildForm().
 */
function statelegemail_civicrm_buildForm($formName, &$form)
{
    switch ($formName) {
        case 'CRM_Campaign_Form_Petition':
            CRM_Core_Resources::singleton()->addScriptFile('com.aghstrategies.statelegemail', 'js/addressField.js');
    }
}
开发者ID:aghstrategies,项目名称:com.aghstrategies.statelegemail,代码行数:10,代码来源:statelegemail.php

示例15: _securefiles_addWidgetToForm

/**
 * Check to see if we have any enabled fields on this
 * form, and if so, set the required class, add them
 * to the list, notify the backend service, and add
 * the required JS and CSS to the page.
 *
 * @param CRM_Core_Form $form
 */
function _securefiles_addWidgetToForm(&$form)
{
    $includeWidget = false;
    $enabled_fields = _securefiles_get_secure_enabled_fields();
    $secureFields = array();
    foreach ($form->_elements as $index => &$field) {
        if ($field->_type == "file") {
            $fieldId = str_replace("custom_", "", $field->_attributes['name']);
            $fieldId = preg_replace('/_.*/', "", $fieldId);
            if (in_array($fieldId, $enabled_fields)) {
                $secureFields[$index] = $fieldId;
                $css_classes = CRM_Utils_Array::value('class', $field->_attributes);
                $field->_attributes['class'] = trim($css_classes . ' securefiles_upload');
                $includeWidget = true;
            }
        }
    }
    if ($includeWidget) {
        $ccr = CRM_Core_Resources::singleton();
        $ccr->addScriptFile('com.ginkgostreet.securefiles', 'js/securefiles_widget.js');
        $ccr->addStyleFile('com.ginkgostreet.securefiles', 'css/securefiles_widget.css');
        $clientSideVars = array();
        $clientSideVars['currentContactId'] = CRM_Core_Session::singleton()->getLoggedInContactID();
        //Give the Backend Service a chance to add additional resources to the form.
        $backendService = CRM_Securefiles_Backend::getBackendService();
        if ($backendService) {
            $backendService->runForm($form, $clientSideVars, $secureFields);
        }
        $ccr->addScript("CRM.\$(function (\$) { CRM.SecureFilesWidget = " . json_encode($clientSideVars) . "; });", 1, 'page-body');
    }
}
开发者ID:ginkgostreet,项目名称:com.ginkgostreet.securefiles,代码行数:39,代码来源:securefiles.widget.php


注:本文中的CRM_Core_Resources::singleton方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。