Example #1
0
 /**
  * @return array
  */
 public function readActiveConfig()
 {
     if (!defined('CIVICRM_SETTINGS_PATH') || CIVICRM_SETTINGS_PATH !== $this->settingsFile) {
         return array();
     }
     $paths = is_callable(array('Civi', 'paths')) ? \Civi::paths() : NULL;
     $data = array('CMS_DB_DSN' => CIVICRM_UF_DSN, 'CMS_VERSION' => \CRM_Core_Config::singleton()->userSystem->getVersion(), 'CIVI_DB_DSN' => CIVICRM_DSN, 'CIVI_SITE_KEY' => CIVICRM_SITE_KEY, 'CIVI_VERSION' => \CRM_Utils_System::version(), 'CIVI_SETTINGS' => CIVICRM_SETTINGS_PATH, 'CIVI_TEMPLATEC' => \CRM_Core_Config::singleton()->templateCompileDir, 'CIVI_UF' => \CRM_Core_Config::singleton()->userFramework, 'IS_INSTALLED' => '1', 'SITE_TYPE' => 'cv-auto', 'CMS_URL' => $paths ? \Civi::paths()->getUrl('[cms.root]/', 'absolute') : \CRM_Utils_System::languageNegotiationURL(\CRM_Utils_System::baseCMSURL(), FALSE, TRUE), 'CMS_ROOT' => $paths ? \Civi::paths()->getPath('[cms.root]/.') : \CRM_Core_Config::singleton()->userSystem->cmsRootPath(), 'CIVI_CORE' => $paths ? \Civi::paths()->getPath('[civicrm.root]/.') : $GLOBALS['civicrm_root'], 'CIVI_URL' => $paths ? \Civi::paths()->getUrl('[civicrm.root]/', 'absolute') : '', 'CIVI_FILES' => $paths ? \Civi::paths()->getPath('[civicrm.root]/.') : dirname(\CRM_Core_Config::singleton()->templateCompileDir));
     return $data;
 }
Example #2
0
 public function __construct()
 {
     $this->register('civicrm.root', function () {
         return \CRM_Core_Config::singleton()->userSystem->getCiviSourceStorage();
     })->register('civicrm.files', function () {
         return \CRM_Core_Config::singleton()->userSystem->getDefaultFileStorage();
     })->register('cms', function () {
         return array('path' => \CRM_Core_Config::singleton()->userSystem->cmsRootPath(), 'url' => \CRM_Utils_System::baseCMSURL());
     })->register('cms.root', function () {
         return array('path' => \CRM_Core_Config::singleton()->userSystem->cmsRootPath(), 'url' => \CRM_Utils_System::languageNegotiationURL(\CRM_Utils_System::baseCMSURL(), FALSE, TRUE));
     });
 }
Example #3
0
 public static function getWidgetData($widgetId)
 {
     $query = "SELECT * FROM civicrm_wci_widget where id=" . $widgetId;
     $params = array();
     $dao = CRM_Core_DAO::executeQuery($query, $params, TRUE, 'CRM_Wci_DAO_Widget');
     $data = array();
     while ($dao->fetch()) {
         $data["title"] = $dao->title;
         $data["logo_image"] = $dao->logo_image;
         $data["image"] = $dao->image;
         empty($dao->button_title) ? $contrin_title = "Donate" : ($contrin_title = $dao->button_title);
         $data["button_title"] = $contrin_title;
         $data["button_link_to"] = $dao->button_link_to;
         $data["progress_bar_id"] = $dao->progress_bar_id;
         $data["description"] = $dao->description;
         $data["email_signup_group_id"] = $dao->email_signup_group_id;
         $data["size_variant"] = $dao->size_variant;
         $data["color_title"] = $dao->color_title;
         $data["color_title_bg"] = $dao->color_title_bg;
         $data["color_progress_bar"] = $dao->color_progress_bar;
         $data["color_progress_bar_bg"] = $dao->color_progress_bar_bg;
         $data["color_widget_bg"] = $dao->color_widget_bg;
         $data["color_description"] = $dao->color_description;
         $data["color_border"] = $dao->color_border;
         $data["color_button"] = $dao->color_button;
         $data["color_button_bg"] = $dao->color_button_bg;
         $data['style_rules'] = $dao->style_rules;
         $data["show_pb_perc"] = $dao->show_pb_perc;
         CRM_Wci_BAO_ProgressBar::getProgressbarData($dao->progress_bar_id, $data);
         $data["custom_template"] = $dao->custom_template;
         $data["widgetId"] = $widgetId;
         $data["override"] = $dao->override;
         $data["hide_title"] = $dao->hide_title;
         $data["hide_border"] = $dao->hide_border;
         $data["hide_pbcap"] = $dao->hide_pbcap;
         $data["color_bar"] = $dao->color_progress_bar;
         $defProf = civicrm_api3('setting', 'getValue', array('group' => 'Wci Preference', 'name' => 'default_wci_profile'));
         $data["emailSignupGroupFormURL"] = CRM_Utils_System::baseCMSURL() . '/civicrm/profile/create?reset=1&gid=' . $defProf;
         $data["color_btn_newsletter"] = $dao->color_btn_newsletter;
         $data["color_btn_newsletter_bg"] = $dao->color_btn_newsletter_bg;
         $data["newsletter_text"] = $dao->newsletter_text;
         $data["color_newsletter_text"] = $dao->color_newsletter_text;
     }
     return $data;
 }
 /**
  * Set the default values.
  * in an empty db, also called when setting component using GUI
  *
  * @param array $defaults
  *   Associated array of form elements.
  * @param bool $formMode
  *   this variable is set true for GUI
  *   mode (eg: Global setting >> Components)
  *
  */
 public static function setValues(&$defaults, $formMode = FALSE)
 {
     $config = CRM_Core_Config::singleton();
     $baseURL = $config->userFrameworkBaseURL;
     // CRM-6216: Drupal’s $baseURL might have a trailing LANGUAGE_NEGOTIATION_PATH,
     // which needs to be stripped before we start basing ResourceURL on it
     if ($config->userSystem->is_drupal) {
         global $language;
         if (isset($language->prefix) and $language->prefix) {
             if (substr($baseURL, -(strlen($language->prefix) + 1)) == $language->prefix . '/') {
                 $baseURL = substr($baseURL, 0, -(strlen($language->prefix) + 1));
             }
         }
     }
     $baseCMSURL = CRM_Utils_System::baseCMSURL();
     if ($config->templateCompileDir) {
         $path = CRM_Utils_File::baseFilePath($config->templateCompileDir);
     }
     if (!isset($defaults['enableSSL'])) {
         $defaults['enableSSL'] = 0;
     }
     //set defaults if not set in db
     if (!isset($defaults['userFrameworkResourceURL'])) {
         if ($config->userFramework == 'Joomla') {
             $defaults['userFrameworkResourceURL'] = $baseURL . "components/com_civicrm/civicrm/";
         } elseif ($config->userFramework == 'WordPress') {
             $defaults['userFrameworkResourceURL'] = $baseURL . "wp-content/plugins/civicrm/civicrm/";
         } else {
             // Drupal setting
             // check and see if we are installed in sites/all (for D5 and above)
             // we dont use checkURL since drupal generates an error page and throws
             // the system for a loop on lobo's macosx box
             // or in modules
             global $civicrm_root;
             $cmsPath = $config->userSystem->cmsRootPath();
             $defaults['userFrameworkResourceURL'] = $baseURL . str_replace("{$cmsPath}/", '', str_replace('\\', '/', $civicrm_root));
             if (strpos($civicrm_root, DIRECTORY_SEPARATOR . 'sites' . DIRECTORY_SEPARATOR . 'all' . DIRECTORY_SEPARATOR . 'modules') === FALSE) {
                 $startPos = strpos($civicrm_root, DIRECTORY_SEPARATOR . 'sites' . DIRECTORY_SEPARATOR);
                 $endPos = strpos($civicrm_root, DIRECTORY_SEPARATOR . 'modules' . DIRECTORY_SEPARATOR);
                 if ($startPos && $endPos) {
                     // if component is in sites/SITENAME/modules
                     $siteName = substr($civicrm_root, $startPos + 7, $endPos - $startPos - 7);
                     $civicrmDirName = trim(basename($civicrm_root));
                     $defaults['userFrameworkResourceURL'] = $baseURL . "sites/{$siteName}/modules/{$civicrmDirName}/";
                     if (!isset($defaults['imageUploadURL'])) {
                         $defaults['imageUploadURL'] = $baseURL . "sites/{$siteName}/files/civicrm/persist/contribute/";
                     }
                 }
             }
         }
     }
     if (!isset($defaults['imageUploadURL'])) {
         if ($config->userFramework == 'Joomla') {
             // gross hack
             // we need to remove the administrator/ from the end
             $tempURL = str_replace("/administrator/", "/", $baseURL);
             $defaults['imageUploadURL'] = $tempURL . "media/civicrm/persist/contribute/";
         } elseif ($config->userFramework == 'WordPress') {
             //for standalone no need of sites/defaults directory
             $defaults['imageUploadURL'] = $baseURL . "wp-content/plugins/files/civicrm/persist/contribute/";
         } else {
             $defaults['imageUploadURL'] = $baseURL . "sites/default/files/civicrm/persist/contribute/";
         }
     }
     if (!isset($defaults['imageUploadDir']) && is_dir($config->templateCompileDir)) {
         $imgDir = $path . "persist/contribute/";
         CRM_Utils_File::createDir($imgDir);
         $defaults['imageUploadDir'] = $imgDir;
     }
     if (!isset($defaults['uploadDir']) && is_dir($config->templateCompileDir)) {
         $uploadDir = $path . "upload/";
         CRM_Utils_File::createDir($uploadDir);
         CRM_Utils_File::restrictAccess($uploadDir);
         $defaults['uploadDir'] = $uploadDir;
     }
     if (!isset($defaults['customFileUploadDir']) && is_dir($config->templateCompileDir)) {
         $customDir = $path . "custom/";
         CRM_Utils_File::createDir($customDir);
         CRM_Utils_File::restrictAccess($customDir);
         $defaults['customFileUploadDir'] = $customDir;
     }
     // FIXME: hack to bypass the step for generating defaults for components,
     // while running upgrade, to avoid any serious non-recoverable error
     // which might hinder the upgrade process.
     $args = array();
     if (isset($_GET[$config->userFrameworkURLVar])) {
         $args = explode('/', $_GET[$config->userFrameworkURLVar]);
     }
     if (isset($defaults['enableComponents'])) {
         foreach ($defaults['enableComponents'] as $key => $name) {
             $comp = $config->componentRegistry->get($name);
             if ($comp) {
                 $co = $comp->getConfigObject();
                 $co->setDefaults($defaults);
             }
         }
     }
 }