/** * Implements template_preprocess_maintenance_page(). */ function solkit_octal_preprocess_maintenance_page(&$variables) { global $install_state; if ($install_state) { // Find the number of tasks to run. $tasks = install_tasks_to_display($install_state); $total = sizeof($tasks); // Find the position of the active task. $keys = array_keys($tasks); $active_task = $install_state['active_task']; $current = array_search($active_task, $keys) + 1; // Show steps. $variables['steps'] = t('Step @current of @total', array('@current' => $current, '@total' => $total)); $variables['title'] = $tasks[$active_task]; } $profile = isset($_GET['profile']) ? $_GET['profile'] : ''; if ($profile) { $path = drupal_get_path('profile', $profile); $info_file = $path . '/' . $profile . '.info'; $info = drupal_parse_info_file($info_file); $variables['site_name'] = $info['name']; $version['version'] = $info['version']; // Use copyright from distro info file. if (isset($info['copyright'])) { $variables['copyright'] = $info['copyright']; } else { $variables['copyright'] = st('@name @version', array('@name' => $info['name'], '@version' => $info['version'])); } // Quick fix to add the required radix-progress.js. // We assume that Radix is at profiles/*/themes/radix. // TODO: handle this better. drupal_add_js($path . '/themes/radix/assets/javascripts/radix-progress.js'); } }
/** * Preprocess functions =============================================== */ function tao_preprocess_html(&$vars) { $vars['classes_array'][] = 'tao'; // Add IE from theme file. $tao_path = drupal_get_path('theme', 'tao'); $info = drupal_parse_info_file($tao_path . '/tao.info'); $ie = $info['stylesheets']['ie']; foreach ($ie as $key => $value) { drupal_add_css($tao_path . '/' . $value, array('browsers' => array('IE' => $key, '!IE' => FALSE))); } }
/** * Implements \SiteAudit\Check\Abstract\calculateScore(). */ public function calculateScore() { if (!module_exists('views')) { $this->abort = TRUE; return SiteAuditCheckAbstract::AUDIT_CHECK_SCORE_INFO; } $info = drupal_parse_info_file(drupal_get_path('module', 'views') . '/views.info'); if (version_compare($info['version'], '7.x-3.0') >= 0) { return SiteAuditCheckAbstract::AUDIT_CHECK_SCORE_PASS; } return SiteAuditCheckAbstract::AUDIT_CHECK_SCORE_WARN; }
/** * Retrieve data. */ public function curl($url) { $path = drupal_get_path('module', 'likebtn') . '/likebtn.info'; $info = drupal_parse_info_file($path); $drupal_version = VERSION; $likebtn_version = $info["core"]; $php_version = phpversion(); $useragent = "Drupal {$drupal_version}; likebtn module {$likebtn_version}; PHP {$php_version}"; try { $ch = curl_init(); curl_setopt($ch, CURLOPT_USERAGENT, $useragent); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_TIMEOUT, 60); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); $result = curl_exec($ch); curl_close($ch); } catch (Exception $e) { } return $result; }
/** * Parse an .info file and add relevant strings to the list. * * @param $file_path * Complete file path to load contents with. * @param $file_name * Stripped file name to use in outpout. * @param $strings * Current strings array * @param $api_version * Drupal API version to work with. */ function _potx_find_info_file_strings($file_path, $file_name, $save_callback, $api_version = POTX_API_6) { $info = array(); if (file_exists($file_path)) { $info = $api_version > POTX_API_5 ? drupal_parse_info_file($file_path) : parse_ini_file($file_path); } // We need the name, description and package values. Others, // like core and PHP compatibility, timestamps or versions // are not to be translated. foreach (array('name', 'description', 'package') as $key) { if (isset($info[$key])) { // No context support for .info file strings. $save_callback($info[$key], POTX_CONTEXT_NONE, $file_name); } } // Add regions names from themes. if (isset($info['regions']) && is_array($info['regions'])) { foreach ($info['regions'] as $region => $region_name) { // No context support for .info file strings. $save_callback($region_name, POTX_CONTEXT_NONE, $file_name); } } }
} $value = stripslashes(substr($value1, 1, -1)) . stripslashes(substr($value2, 1, -1)) . $value3; // Parse array syntax $keys = preg_split('/\\]?\\[/', rtrim($key, ']')); $last = array_pop($keys); $parent =& $info; // Create nested arrays foreach ($keys as $key) { if ($key == '') { $key = count($parent); } if (!isset($parent[$key]) || !is_array($parent[$key])) { $parent[$key] = array(); } $parent =& $parent[$key]; } // Handle PHP constants. if (isset($constants[$value])) { $value = $constants[$value]; } // Insert actual value if ($last == '') { $last = count($parent); } $parent[$last] = $value; } } return $info; } $info = drupal_parse_info_file($argv[1]); echo $info['version'];
/** * Handler when cart/icepay_result is callback * * @return string */ public function runPageCartResult() { $logger = \Icepay_Api_Logger::getInstance(); $logger->enableLogging()->setLoggingLevel(\Icepay_Api_Logger::LEVEL_ERRORS_AND_TRANSACTION)->logToFunction("logWrapper", "log"); $config = \Drupal::config("uc_icepay.settings"); /* postback */ if ($_SERVER['REQUEST_METHOD'] == 'POST') { $icepay = \Icepay_Project_Helper::getInstance()->postback(); $icepay->setMerchantID($config->get("merchant_id"))->setSecretCode($config->get("secret_code"))->doIPCheck(true); if ($config->get("ipcheck") && $config->get("ipcheck_list") != '') { $ipRanges = explode(",", $config->get("ipcheck_list")); foreach ($ipRanges as $ipRange) { $ip = explode("-", $ipRange); $icepay->setIPRange($ip[0], $ip[1]); } } if ($icepay->validate()) { $data = $icepay->GetPostback(); $orderID = $data->reference; $order = uc_order_load($orderID); if (!$order) { return t("Order not exists"); } $firstPostback = Database::getConnection()->select('uc_payment_icepay', 'i')->fields('i', array('transaction_id'))->condition('transaction_id', $data->transactionID, '=')->execute()->fetchAssoc(); $paymentDetails = IcepayApi::getPaymentDetailsByOrderId($orderID); if ($icepay->canUpdateStatus($paymentDetails->icepay_status)) { $order->icepay_status = $data->status; $order->transaction_id = $data->transactionID; IcepayApi::enterPayment($order); // updating order status, this one is deprecated //uc_order_update_status($orderID, IcepayApi::getUbercartStatusCode($data->status)); // updating order status, using direct save into order $order->setStatusId(IcepayApi::getUbercartStatusCode($data->status))->save(); } // adding new comment order uc_order_comment_save($orderID, 1, t($data->statusCode), 'order', IcepayApi::getUbercartStatusCode($data->status), true); // need to save into order payment if postback from Icepay is confirming payment received // @see Drupal/uc_payment/Form/OrderPaymentsForm::submitForm() if (strtoupper($data->status) == "OK" || strtoupper($data->status) == "REFUND") { $orderTotal = $order->getTotal(); // when refund, means order total is requested back if (strtoupper($data->status) == "REFUND") { $orderTotal *= -1; } uc_payment_enter($orderID, $paymentDetails->payment_method, $orderTotal, \Drupal::currentUser()->id(), '', $data->statusCode, REQUEST_TIME); } // best to record this into watch log // https://drupalize.me/blog/201510/how-log-messages-drupal-8 \Drupal::logger('uc_icepay')->info('Icepay Postback :: ' . $data->statusCode); // need to send notification due to order status update if (isset($firstPostback['transaction_id'])) { // this rules invoke to send order status update by email is deprecated //rules_invoke_event('uc_order_status_email_update', $order); } } else { if ($icepay->isVersionCheck()) { $dump = array("module" => sprintf(t("Version %s using PHP API 2 version %s"), ICEPAY_VERSION, Icepay_Project_Helper::getInstance()->getReleaseVersion()), "notice" => "Checksum validation passed!"); if ($icepay->validateVersion()) { $name = "uc_cart"; $path = drupal_get_path('module', $name) . '/' . $name . '.info'; $data = drupal_parse_info_file($path); $dump["additional"] = array("Drupal" => VERSION, "Ubercart" => $data["version"]); } else { $dump["notice"] = "Checksum failed! Merchant ID and Secret code probably incorrect."; } var_dump($dump); exit; } } return t("Postback script functions properly"); } else { $icepay = \Icepay_Project_Helper::getInstance()->result(); $icepay->setMerchantID($config->get("merchant_id"))->setSecretCode($config->get("secret_code")); if (!$icepay->validate()) { $data = $icepay->getResultData(); //$output = $data->statusCode; //return $output; drupal_set_message($data->statusCode, 'error'); $response = new RedirectResponse(\Drupal::url('uc_cart.checkout')); $response->send(); } else { $data = $icepay->getResultData(); if ($data->status == 'ERR') { //$output = $data->statusCode; //return $output; drupal_set_message($data->statusCode, 'error'); return new RedirectResponse(\Drupal::url('uc_cart.checkout')); } $order = uc_order_load($data->reference); if (!$order) { return t("Order with id :orderId not exist", array(":orderId" => $data->reference)); } $session = \Drupal::service('session'); if (!$session->get('cart_order')) { drupal_set_message(t("Cart is currently empty."), 'error'); return new RedirectResponse(\Drupal::url('uc_cart.checkout')); } //$order->icepay_status = \ICEPAY_STATUSCODE::SUCCESS; $order->icepay_status = $data->status; $order->transaction_id = $data->transactionID; IcepayApi::enterPayment($order); // update order status $order->setStatusId(IcepayApi::getUbercartStatusCode($data->status))->save(); $_SESSION['uc_checkout'][$session->get('cart_order')]['do_complete'] = TRUE; // $response = new RedirectResponse(Url::fromRoute('uc_cart.checkout_complete')->toString()); // $response->send(); return new RedirectResponse(\Drupal::url('uc_cart.checkout_complete')); } } }
/** * Extract metadata from the Module .info file. * * @param Module $module * * @return Module */ public function runInfoScan(Module $module) { // Extract basic info and register the module. if ($info_file = $this->findInfoFile($module->getLocation())) { $info = drupal_parse_info_file($info_file); // Faulty info files cause warnings for me. if (empty($info['name'])) { // Exception handling. $info['name'] = "Bad Info"; $info['description'] = $info_file; $module->addStatus('info:failed'); } $info += array('name' => "Bad info"); $module->setLabel($info['name']); if (isset($info['description'])) { $module->setDescription($info['description']); } if (isset($info['version'])) { $module->setVersion($info['version']); } $module->addStatus('info:processed'); } else { $module->addStatus('info:failed'); } return $module; }
<?php /* * Script to run after deployments. * Checks the dosomething.info file to determine if new modules need to be enabled. * * to run: drush --script-path=../bin/ php-script enable_modules.php * */ // Parse the data in the info file. $info = drupal_parse_info_file('../lib/profiles/dosomething/dosomething.info'); $modules = $info['dependencies']; // Enable modules enable_modules_if_needed($modules); /** * Enable modules if disabled. * * @param array $modules * An array of modules */ function enable_modules_if_needed($modules) { foreach ($modules as $module) { // Check if modules are disabled. $result = db_select('system', 's')->fields('s', array('status'))->condition('name', $module, '=')->condition('status', 0, '=')->execute(); if ($result->fetchAssoc()) { // Create an array of modules to enable. $to_enable[] = $module; } } if ($to_enable) {
function package_release_contrib($type, $nid, $project_short_name, $version, $tag, $release_dir) { global $tmp_dir, $repositories, $dest_root, $dest_rel; global $cvs, $tar, $gzip, $rm, $ln; global $drush, $drush_make_dir; global $license, $trans_install; // Files to ignore when checking timestamps: $exclude = array('.', '..', 'LICENSE.txt'); $parts = split('/', $release_dir); // modules, themes, theme-engines, profiles, or translations $contrib_type = $parts[1]; // specific directory (same as uri) $project_short_name = $parts[2]; $project_build_root = "{$tmp_dir}/{$project_short_name}"; $cvs_export_dir = "{$repositories[DRUPAL_CONTRIB_REPOSITORY_ID]['modules']}/{$contrib_type}/{$project_short_name}"; $release_file_id = $project_short_name . '-' . $version; $release_node_view_link = l(t('view'), 'node/' . $nid); $file_path_tgz = $dest_rel . '/' . $release_file_id . '.tar.gz'; $full_dest_tgz = $dest_root . '/' . $file_path_tgz; // Remember if the tar.gz version of this release file already exists. $tgz_exists = is_file($full_dest_tgz); // Clean up any old build directory if it exists. // Don't use drupal_exec or return if this fails, we expect it to be empty. exec("{$rm} -rf {$project_build_root}"); // Make a fresh build directory and move inside it. if (!mkdir($project_build_root) || !drupal_chdir($project_build_root)) { return 'error'; } // Checkout this release from CVS, and see if we need to rebuild it if (!drupal_exec("{$cvs} -q export -r {$tag} -d {$project_short_name} {$cvs_export_dir}")) { return 'error'; } if (!is_dir("{$project_build_root}/{$project_short_name}")) { wd_err("ERROR: %dir does not exist after cvs export -r %tag -d %dir %cvs_export_dir", array('%dir' => $project_short_name, '%rev' => $tag, '%cvs_export_dir' => $cvs_export_dir), $release_node_view_link); return 'error'; } $info_files = array(); $youngest = file_find_youngest($project_short_name, 0, $exclude, $info_files); if ($type == 'branch' && $tgz_exists && filemtime($full_dest_tgz) + 300 > $youngest) { // The existing tarball for this release is newer than the youngest // file in the directory, we're done. return 'no-op'; } // Update any .info files with packaging metadata. foreach ($info_files as $file) { if (!fix_info_file_version($file, $project_short_name, $version)) { wd_err("ERROR: Failed to update version in %file, aborting packaging", array('%file' => $file), $release_node_view_link); return 'error'; } } // Link not copy, since we want to preserve the date... if (!drupal_exec("{$ln} -sf {$license} {$project_short_name}/LICENSE.txt")) { return 'error'; } // Do we want a subdirectory in the tarball or not? $tarball_needs_subdir = TRUE; if ($contrib_type == 'translations' && $project_short_name != 'drupal-pot') { // Translation projects are packaged differently based on core version. if (intval($version) > 5) { if (!($to_tar = package_release_contrib_d6_translation($project_short_name, $version, $release_node_view_link))) { // Return on error. return 'error'; } $tarball_needs_subdir = FALSE; } elseif (!($to_tar = package_release_contrib_pre_d6_translation($project_short_name, $version, $release_node_view_link))) { // Return on error. return 'error'; } } else { // Not a translation: just grab the whole directory. $to_tar = $project_short_name; } if (!$tarball_needs_subdir) { if (!drupal_chdir($project_short_name)) { return 'error'; } } // 'h' is for dereference, we want to include the files, not the links if (!drupal_exec("{$tar} -ch --file=- {$to_tar} | {$gzip} -9 --no-name > {$full_dest_tgz}")) { return 'error'; } $files[] = $file_path_tgz; // Start with no package contents, since this is only valid for profiles. $package_contents = array(); // This is a profile, so invoke the drush_make routines to package core // and/or any other contrib releases specified in the profile's .make file. if ($contrib_type == 'profiles') { // Move inside the profile directory. if (!drupal_chdir("{$project_build_root}/{$project_short_name}")) { return 'error'; } // In order for extended packaging to take place, the profile must have a // file named drupal-org.make in the main directory of their profile. $drupalorg_makefile = 'drupal-org.make'; if (file_exists($drupalorg_makefile)) { // Search the .make file for the required 'core' attribute. $info = drupal_parse_info_file($drupalorg_makefile); // Only proceed if a core release was found. if (!isset($info['core'])) { wd_err("ERROR: %profile does not have the required 'core' attribute.", array('%profile' => $release_file_id), $release_node_view_link); return 'error'; } else { // Basic sanity check for the format of the attribute. The CVS checkout // attempt of core will handle the rest of the validation (ie, it will // fail if a non-existant tag is specified. if (!preg_match("/^(\\d+)\\.(\\d+)(-[a-z0-9]+)?\$/", $info['core'], $matches)) { wd_err("ERROR: %profile specified an invalid 'core' attribute -- both API version and release are required.", array('%profile' => $release_file_id), $release_node_view_link); return 'error'; } else { // Compare the Drupal API version in the profile's version string with // the API version of core specificed in the .make file -- these should // match. $profile_api_version = $matches[1]; $parts = explode('.', $version); $release_api_version = $parts[0]; if ($profile_api_version != $release_api_version) { wd_err("ERROR: %profile specified an invalid 'core' attribute -- the API version must match the API version of the release.", array('%profile' => $release_file_id), $release_node_view_link); return 'error'; } } // NO-CORE DISTRIBUTION. $no_core_id = "{$release_file_id}-no-core"; // Build the drupal file path and the full file path. $no_core_file_path = "{$dest_rel}/{$no_core_id}.tar.gz"; $no_core_full_dest = "{$dest_root}/{$no_core_file_path}"; // Run drush_make to build the profile's contents. // --drupal-org: Invoke drupal.org specific validation/processing. // --drupal-org-build-root: Let the script know where to place it's // build-related files. // --drupal-org-log-errors-to-file: Store build errors for later output. // --drupal-org-log-package-items-to-file: Store package items for // later recording in the database. if (!drupal_exec("{$drush} --include={$drush_make_dir} make --drupal-org --drupal-org-build-root={$project_build_root} --drupal-org-log-errors-to-file --drupal-org-log-package-items-to-file {$drupalorg_makefile} .")) { // The build failed, get any output error messages and include them // in the packaging error report. $build_errors_file = "{$project_build_root}/build_errors.txt"; if (file_exists($build_errors_file)) { $lines = file($build_errors_file, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES); foreach ($lines as $line) { wd_err("ERROR: {$line}"); } } wd_err("ERROR: Build for %profile failed.", array('%profile' => $no_core_id), $release_node_view_link); return 'error'; } // Change into the profile build directory. if (!drupal_chdir($project_build_root)) { return 'error'; } // Package the no-core distribution. // 'h' is for dereference, we want to include the files, not the links if (!drupal_exec("{$tar} -ch --file=- {$project_short_name} | {$gzip} -9 --no-name > {$no_core_full_dest}")) { return 'error'; } $files[] = $no_core_file_path; // CORE DISTRIBUTION. // Write a small .make file used to build core. $core_version = $info['core']; $core_build_dir = "drupal-{$core_version}"; $core_makefile = "{$core_build_dir}.make"; file_put_contents($core_makefile, core_make_file($core_version)); // Run drush_make to build core. if (!drupal_exec("{$drush} --include={$drush_make_dir} make {$core_makefile} {$core_build_dir}")) { // The build failed, bail out. wd_err("ERROR: Build for %core failed.", array('%core' => $core_build_dir), $release_node_view_link); return 'error'; } // Move the profile into place inside core. if (!rename($project_short_name, "{$core_build_dir}/profiles/{$project_short_name}")) { return 'error'; } $core_id = "{$release_file_id}-core"; // Build the drupal file path and the full file path. $core_file_path = "{$dest_rel}/{$core_id}.tar.gz"; $core_full_dest = "{$dest_root}/{$core_file_path}"; // Package the core distribution. // 'h' is for dereference, we want to include the files, not the links if (!drupal_exec("{$tar} -ch --file=- {$core_build_dir} | {$gzip} -9 --no-name > {$core_full_dest}")) { return 'error'; } $files[] = $core_file_path; // Development releases may have changed package contents -- clear out // their package item summary so a fresh item summary will be inserted. if ($type == 'branch' && module_exists('project_package')) { db_query("DELETE FROM {project_package_local_release_item} WHERE package_nid = %d", $nid); } // Core was built without the drupal.org drush extension, so the // package item for core isn't in the package contents file. Retrieve // it manually. $core_tag = 'DRUPAL-' . str_replace('.', '-', $core_version); if (!($core_release_nid = db_result(db_query("SELECT nid FROM {project_release_nodes} WHERE tag = '%s'", $core_tag)))) { return 'error'; } $package_contents[] = $core_release_nid; // Retrieve the package contents for the release. $package_contents_file = "{$project_build_root}/package_contents.txt"; if (file_exists($package_contents_file)) { $lines = file($package_contents_file, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES); foreach ($lines as $line) { if (is_numeric($line)) { $package_contents[] = $line; } } } else { wd_err("ERROR: %file does not exist for %profile release.", array('%file' => $package_contents_file, '%profile' => $release_file_id), $release_node_view_link); return 'error'; } } } else { wd_msg("No makefile for %profile profile -- skipping extended packaging.", array('%profile' => $release_file_id), $release_node_view_link); } } // As soon as the tarball exists, update the DB package_release_update_node($nid, $files, $package_contents); if ($tgz_exists) { wd_msg("%id has changed, re-packaged.", array('%id' => $release_file_id), $view_link); } else { wd_msg("Packaged %id.", array('%id' => $release_file_id), $view_link); } // Don't consider failure to remove this directory a build failure. drupal_exec("{$rm} -rf {$project_build_root}"); return 'success'; }