function gevent_service() { global $calendar; $info = libraries_load('google-api-php-client'); if (!$info['loaded']) { drupal_set_message(t('Can`t authenticate with google as library is missing check Status report or Readme for requirements, download from') . l('https://github.com/google/google-api-php-client/archive/master.zip', 'https://github.com/google/google-api-php-client/archive/master.zip'), 'error'); return FALSE; } $client_email = variable_get('gapps_service_client_email'); $file = file_load(variable_get('gapps_service_private_key')); $private_key = file_get_contents(drupal_realpath($file->uri)); $user_to_impersonate = variable_get('gevent_admin'); $scopes = array('https://www.googleapis.com/auth/calendar'); $credentials = new Google_Auth_AssertionCredentials($client_email, $scopes, $private_key, 'notasecret', 'http://oauth.net/grant_type/jwt/1.0/bearer', $user_to_impersonate); $client = new Google_Client(); $client->setApplicationName('Drupal gevent module'); $client->setAssertionCredentials($credentials); while ($client->getAuth()->isAccessTokenExpired()) { $client->getAuth()->refreshTokenWithAssertion(); } $calendar = new Google_Service_Calendar($client); $_SESSION['gevent_access_token'] = $client->getAccessToken(); if ($_SESSION['gevent_access_token']) { return $calendar; } else { return NULL; } }
function gapps_service($domain) { global $directory; $info = libraries_load('google-api-php-client'); if (!$info['loaded']) { drupal_set_message(t('Can`t authenticate with google as library is missing check Status report or Readme for requirements, download from') . l('https://github.com/google/google-api-php-client/archive/master.zip', 'https://github.com/google/google-api-php-client/archive/master.zip'), 'error'); return FALSE; } $client_email = variable_get('gapps_service_client_email'); $file = file_load(variable_get('gapps_service_private_key')); $private_key = file_get_contents(drupal_realpath($file->uri)); if ($domain == 'teacher') { $user_to_impersonate = variable_get('gapps_teacher_admin'); } else { $user_to_impersonate = variable_get('gapps_student_admin'); } $scopes = array('https://www.googleapis.com/auth/admin.directory.orgunit', 'https://www.googleapis.com/auth/admin.directory.group', 'https://www.googleapis.com/auth/admin.directory.group.member', 'https://www.googleapis.com/auth/admin.directory.user', 'https://www.googleapis.com/auth/admin.directory.user.alias'); $credentials = new Google_Auth_AssertionCredentials($client_email, $scopes, $private_key); $credentials->sub = $user_to_impersonate; $client = new Google_Client(); $client->setApplicationName('Drupal gapps module'); $client->setAssertionCredentials($credentials); while ($client->getAuth()->isAccessTokenExpired()) { $client->getAuth()->refreshTokenWithAssertion($credentials); } $directory = new Google_Service_Directory($client); $_SESSION['gapps_' . $domain . '_access_token'] = $client->getAccessToken(); if ($_SESSION['gapps_' . $domain . '_access_token']) { return $directory; } else { return NULL; } }
/** * Preprocess variables for html.tpl.php * * @see system_elements() * @see html.tpl.php */ function apigee_base_preprocess_html(&$variables) { // Try to load the library, if the apigee_base_ui module is in use. if (module_exists('apigee_base_ui')) { libraries_load('apigee_base', 'minified'); } }
/** * {@inheritdoc} */ public function process($text, $langcode) { // Load GeSHi library (if not already). $geshi_library = libraries_load('geshi'); if (!$geshi_library['loaded']) { drupal_set_message($geshi_library['error message'], 'error'); return $text; } // Get the available tags. list($generic_code_tags, $language_tags, $tag_to_lang) = $this->getTags(); if (in_array(GeshiFilter::BRACKETS_PHPBLOCK, array_filter($this->tagStyles()))) { $language_tags[] = 'questionmarkphp'; $tag_to_lang['questionmarkphp'] = 'php'; } $tags = array_merge($generic_code_tags, $language_tags); // Escape special (regular expression) characters in tags (for tags like // 'c++' and 'c#'). $tags = preg_replace('#(\\+|\\#)#', '\\\\$1', $tags); $tags_string = implode('|', $tags); // Pattern for matching the prepared "<code>...</code>" stuff. $pattern = '#\\[geshifilter-(' . $tags_string . ')([^\\]]*)\\](.*?)(\\[/geshifilter-\\1\\])#s'; $text = preg_replace_callback($pattern, array($this, 'replaceCallback'), $text); // Create the object with result. $result = new FilterProcessResult($text); // Add the css file when necessary. if ($this->config->get('css_mode') == GeshiFilter::CSS_CLASSES_AUTOMATIC) { $result->setAttachments(array('library' => array('geshifilter/geshifilter'))); } // Add cache tags, so we can re-create the node when some geshifilter // settings change. $cache_tags = array('geshifilter'); $result->addCacheTags($cache_tags); return $result; }
/** * Geshifilter wrapper for GeSHi processing. * * @param string $source_code * Source code to process. * @param string $lang * Language from sourcecode. * @param int $linenumbers_start * The line number to start from. * @param string $message * The message that will be displayed in the highlighted section. * @param string $title * The title to use. * @param \GeSHi $geshi * (optional) The GeSHi object that will be used for generating the HTML. * * @return string * The sourcecode after process by Geshi. */ public static function geshiProcessCustomGeshi($source_code, $lang, $linenumbers_start = 1, $message = '', $title, $geshi = NULL) { $source_code = trim($source_code, "\n\r"); if (!is_object($geshi)) { // Load GeSHi library (if not already). $geshi_library = libraries_load('geshi'); if (!$geshi_library['loaded']) { drupal_set_message($geshi_library['error message'], 'error'); return $source_code; } // Create GeSHi object. $geshi = self::geshiFactory($source_code, $lang); } self::overrideGeshiDefaults($geshi, $lang); // Some more GeSHi settings and parsing. // Block source code mode. $geshi->enable_line_numbers(GESHI_FANCY_LINE_NUMBERS, 2); $geshi->start_line_numbers_at($linenumbers_start); $message = '<div class="message"><p>' . Html::Escape($message) . '</p></div>'; $source_code = ''; if (isset($title)) { $source_code .= '<div class="geshifilter-title">' . Html::Escape($title) . '</div>'; } $source_code .= '<div class="geshifilter">' . $message . $geshi->parse_code() . '</div>'; return $source_code; }
/** * Preprocess variables for html.tpl.php * * @see system_elements() * @see html.tpl.php */ function twitter_bootstrap_preprocess_html(&$variables) { // Try to load the library if (module_exists('twitter_bootstrap_ui')) { $library = libraries_load('twitter_bootstrap', 'minified'); } }
function __construct() { if (function_exists('libraries_load')) { libraries_load('KalturaClient'); } else { $status_report = l("Status report", 'admin/reports/status'); drupal_set_message(t("Kaltura module now requires Libraries module to be installed and enabled. Please follow instructions listed on the {$status_report} page."), 'error'); } }
/** * @return CMISService */ function _cmisro_service() { static $service; if (!$service) { libraries_load('chemistry'); $service = new CMISService(variable_get('cmisro_url'), variable_get('cmisro_username'), variable_get('cmisro_password'), variable_get('cmisro_repositoryId')); $service->succinct = true; } return $service; }
/** * {@inheritdoc} */ public function buildForm(array $form, FormStateInterface $form_state, $view = NULL) { $config = $this->config('geshifilter.settings'); // Check if GeSHi library is available. $geshi_library = libraries_load('geshi'); if (!$geshi_library['loaded']) { drupal_set_message($geshi_library['error message'], 'error'); return array(); } $add_checkbox = TRUE; $add_tag_option = !$config->get('use_format_specific_options'); $form['language_settings'] = $this->perLanguageSettings($view, $add_checkbox, $add_tag_option); return parent::buildForm($form, $form_state); }
/** * Geshifilter wrapper for GeSHi processing. * * @param string $source_code * Source code to process. * @param string $lang * Language from sourcecode. * @param int $line_numbering * The line numbering mode, one of LINE_NUMBERS_* from GeshiFilter class. * @param int $linenumbers_start * The line number to start from. * @param bool $inline_mode * When to write all styles inline or from a css. * @param string $title * The title to use in code. * * @return string * The sourcecode after process by Geshi. */ public static function geshiProcess($source_code, $lang, $line_numbering = 0, $linenumbers_start = 1, $inline_mode = FALSE, $title = NULL) { $config = \Drupal::config('geshifilter.settings'); // Load GeSHi library (if not already). $geshi_library = libraries_load('geshi'); if (!$geshi_library['loaded']) { drupal_set_message($geshi_library['error message'], 'error'); return $source_code; } $source_code = trim($source_code, "\n\r"); // Create GeSHi object. $geshi = self::geshiFactory($source_code, $lang); // CSS mode. $ccs_mode = $config->get('css_mode'); if ($ccs_mode == GeshiFilter::CSS_CLASSES_AUTOMATIC || $ccs_mode == GeshiFilter::CSS_CLASSES_ONLY) { $geshi->enable_classes(TRUE); } self::overrideGeshiDefaults($geshi, $lang); // Some more GeSHi settings and parsing. if ($inline_mode) { // Inline source code mode. $geshi->set_header_type(GESHI_HEADER_NONE); // To make highlighting work we have to manually set a class on the code // element we will wrap the code in. // To counter a change between GeSHi version 1.0.7.22 and 1.0.8 (svn // commit 1610), we use both the language and overall_class for the class, // to mimic the 1.0.8 behavior, which is backward compatible. $code_class = "{$geshi->language} {$geshi->overall_class}"; $source_code = '<span class="geshifilter"' . (isset($title) ? ' title="' . SafeMarkup::checkPlain($title) . '"' : '') . '><code class="' . $code_class . '">' . $geshi->parse_code() . '</code></span>'; } else { // Block source code mode. $geshi->set_header_type((int) $config->get('code_container', GESHI_HEADER_PRE)); if ($line_numbering == 1) { $geshi->enable_line_numbers(GESHI_NORMAL_LINE_NUMBERS); $geshi->start_line_numbers_at($linenumbers_start); } elseif ($line_numbering >= 2) { $geshi->enable_line_numbers(GESHI_FANCY_LINE_NUMBERS, $line_numbering); $geshi->start_line_numbers_at($linenumbers_start); } if (isset($title)) { $source_code = '<div class="geshifilter-title">' . SafeMarkup::checkPlain($title) . '</div>'; } else { $source_code = ''; } $source_code .= '<div class="geshifilter">' . $geshi->parse_code() . '</div>'; } return $source_code; }
/** * Triggered when the REST server request a list of supported response formats. * * @param array $formatters * An associative array of formatter info arrays keyed by type extension. The * formatter info specifies an array of 'mime types' that corresponds to the * output format; a 'view' class that is a subclass of RESTServerView; and * 'view arguments' that should be passed to the view when it is created; * a 'model' can also be specified which the controller then must declare * support for to be able to serve data in that format. * @return void */ function hook_rest_server_response_formatters_alter(&$formatters) { /* * Sample modifications of the formatters array. Both yaml and * rss are formats that already are supported, so the changes are * nonsensical but illustrates the proper use of this hook. */ // Add a Yaml response format conditionally. if (($library = libraries_load('spyc')) && !empty($library['loaded'])) { $formatters['yaml'] = array('mime types' => array('text/plain', 'application/x-yaml', 'text/yaml'), 'view' => 'RESTServerViewBuiltIn', 'view arguments' => array('format' => 'yaml')); } // Add a Rss response format. $formatters['rss'] = array('model' => 'ResourceFeedModel', 'mime types' => array('text/xml'), 'view' => 'RssFormatView'); // Remove the jsonp response format. unset($formatters['jsonp']); }
/** * Loads the Litle SDK library and initializes a Request object. * * If the SDK can't be loaded, watchdog the error and throw an exception. * * @throws RuntimeException * If the Litle SDK can't be loaded. */ public function __construct() { $library = libraries_load('litle'); if (!empty($library['loaded'])) { // Initialize an internal Request object. $this->newRequest(); return; } // Couldn't load the library. Try to get some info and watchdog it. $replacements = array('@error' => '', '@error_message' => ''); if (isset($library['error'])) { $replacements['@error'] = $library['error']; } if (isset($library['error message'])) { $replacements['@error_message'] = $library['error message']; } watchdog('Commerce Litle', 'Litle library not found! @error @error_message', $replacements, WATCHDOG_ALERT); throw new RuntimeException('Cannot load the Litle SDK'); }
public function viewElements(FieldItemListInterface $items, $langcode) { $library = libraries_load('pdf.js'); $elements = array(); if ($library['loaded']) { foreach ($items as $delta => $item) { $filename = $item->entity->getFilename(); if ($item->isDisplayed() && $item->entity && strpos($filename, 'pdf')) { $file_url = file_create_url($item->entity->getFileUri()); $library_path = libraries_get_path('pdf.js'); $iframe_src = file_create_url($library_path . '/web/viewer.html') . '?file=' . rawurlencode($file_url); $force_pdfjs = $this->getSetting('keep_pdfjs'); $html = array( '#type' => 'html_tag', '#tag' => 'iframe', '#value' => $file_url, '#attributes' => array( 'class' => array('pdf'), 'webkitallowfullscreen' => '', 'mozallowfullscreen' => '', 'allowfullscreen' => '', 'frameborder' => 'no', 'width' => $this->getSetting('width'), 'height' => $this->getSetting('height'), 'src' => $iframe_src, 'data-src' => $file_url, ), ); $elements[$delta] = array('#markup' => \Drupal::service('renderer')->render($html)); } } if ($force_pdfjs != TRUE) { $elements['#attached']['library'][] = 'pdf/default'; } } else { drupal_set_message($library['error message'], 'error'); $elements[] = array( '#markup' => t('Please download and install ') . \Drupal::l( $library['name'], Url::fromUri($library['download url'])) . '!' ); } return $elements; }
/** * Helper function for generating the CSS rules. * * @return string * String with the CSS rules. */ public static function generateLanguagesCssRules() { $output = ''; $geshi_library = libraries_load('geshi'); if ($geshi_library['loaded']) { $languages = GeshiFilter::getAvailableLanguages(); foreach ($languages as $langcode => $language_full_name) { // Create GeSHi object. $geshi = GeshiFilterProcess::geshiFactory('', $langcode); GeshiFilterProcess::overrideGeshiDefaults($geshi, $langcode); // Add CSS rules for current language. $output .= $geshi->get_stylesheet(FALSE) . "\n"; // Release GeSHi object. unset($geshi); } } else { drupal_set_message(t('Error while generating CSS rules: could not load GeSHi library.'), 'error'); } return $output; }
/** * Loads a specified library (variant) for testing. * * JavaScript and CSS files can be checked directly by SimpleTest, so we only * need to manually check for PHP files. We provide information about the loaded * JavaScript and CSS files for easier debugging. See example/README.txt for * more information. */ private function buildPage($library, $variant = NULL) { libraries_load($library, $variant); // JavaScript and CSS files can be checked directly by SimpleTest, so we only // need to manually check for PHP files. $output = ''; // For easer debugging of JS loading, a text is shown that the JavaScript will // replace. $output .= '<h2>JavaScript</h2>'; $output .= '<div class="libraries-test-javascript">'; $output .= 'If this text shows up, no JavaScript test file was loaded.'; $output .= '</div>'; // For easier debugging of CSS loading, the loaded CSS files will color the // following text. $output .= '<h2>CSS</h2>'; $output .= '<div class="libraries-test-css">'; $output .= 'If one of the CSS test files has been loaded, this text will be colored:'; $output .= '<ul>'; // Do not reference the actual CSS files (i.e. including '.css'), because that // breaks testing. $output .= '<li>example_1: red</li>'; $output .= '<li>example_2: green</li>'; $output .= '<li>example_3: orange</li>'; $output .= '<li>example_4: blue</li>'; $output .= '<li>libraries_test: purple</li>'; $output .= '</ul>'; $output .= '</div>'; $output .= '<h2>PHP</h2>'; $output .= '<div class="libraries-test-php">'; $output .= 'The following is a list of all loaded test PHP files:'; $output .= '<ul>'; $files = get_included_files(); foreach ($files as $file) { if ((strpos($file, 'libraries/test') || strpos($file, 'libraries_test')) && !strpos($file, 'libraries_test.module') && !strpos($file, 'lib/Drupal/libraries_test')) { $output .= '<li>' . str_replace(DRUPAL_ROOT . '/', '', $file) . '</li>'; } } $output .= '</ul>'; $output .= '</div>'; return ['#markup' => $output]; }
/** * Lazy loads the google calendar service * * @return Google_Service_Calendar */ function cob_calendar_service() { static $client = null; static $service = null; if (!$service) { if (!$client) { libraries_load('google-api-php-client'); $json = json_decode(file_get_contents(DRUPAL_ROOT . '/' . conf_path() . '/credentials.json')); $credentials = new \Google_Auth_AssertionCredentials($json->client_email, ['https://www.googleapis.com/auth/calendar.readonly'], $json->private_key); $credentials->sub = variable_get('cob_google_email'); $client = new \Google_Client(); $client->setClassConfig('Google_Cache_File', 'directory', DRUPAL_ROOT . '/' . conf_path() . '/files/Google_Client'); $client->setAssertionCredentials($credentials); if ($client->getAuth()->isAccessTokenExpired()) { $client->getAuth()->refreshTokenWithAssertion(); } } $service = new \Google_Service_Calendar($client); } return $service; }
public function execute(\Payment $payment) { libraries_load('stripe-php'); $context =& $payment->contextObj; $api_key = $payment->method->controller_data['private_key']; switch ($context->value('donation_interval')) { case 'm': $interval = 'month'; break; case 'y': $interval = 'year'; break; default: $interval = NULL; break; } try { \Stripe::setApiKey($api_key); \Stripe::setApiVersion('2014-01-31'); $customer = $this->createCustomer($payment->method_data['stripe_payment_token'], $this->getName($context), $context->value('email')); $stripe = NULL; $plan_id = NULL; if (!$interval) { $stripe = $this->createCharge($customer, $payment); } else { $plan_id = $this->createPlan($customer, $payment, $interval); $stripe = $this->createSubscription($customer, $plan_id); } $payment->setStatus(new \PaymentStatusItem(PAYMENT_STATUS_SUCCESS)); $payment->save(); $params = array('pid' => $payment->pid, 'stripe_id' => $stripe->id, 'type' => $stripe->object, 'plan_id' => $plan_id); \Drupal::database()->insert('stripe_payment')->fields($params)->execute(); } catch (\Stripe_Error $e) { $payment->setStatus(new \PaymentStatusItem(PAYMENT_STATUS_FAILED)); $payment->save(); $message = '@method payment method encountered an error while contacting ' . 'the stripe server. The status code "@status" and the error ' . 'message "@message". (pid: @pid, pmid: @pmid)'; $variables = array('@status' => $e->getHttpStatus(), '@message' => $e->getMessage(), '@pid' => $payment->pid, '@pmid' => $payment->method->pmid, '@method' => $payment->method->title_specific); \Drupal::logger('stripe_payment')->error($message, []); } }
/** * Implements partial__{name}_preprocess(). */ function shelter_preprocess_cluster_docs_featured_documents(&$variables) { libraries_load('jcarousel'); drupal_add_js(drupal_get_path('theme', 'shelter') . '/assets/javascripts/featured-docs.js'); }
/** * Loads a library. * * @param $name * The name of the library to load. * @param $variant * The name of the variant to load. Note that only one variant of a library can be loaded within a single request. * The variant that has been passed first is used; different variant names in subsequent calls are ignored. * * @return * An associative array of the library information as returned from libraries_info(). The top-level properties contain * the effective definition of the library (variant) that has been loaded. Additionally: * - installed: Whether the library is installed, as determined by libraries_detect_library(). * - loaded: Either the amount of library files that have been loaded, or FALSE if the library could not be loaded. * See MYPLUGIN_libraries::libraries_info() for more information. */ function libraries_load($name, $variant = null) { static $loaded; if (!isset($loaded[$name])) { $library = libraries_detect($name); // TODO: cache. /* $cache = e107::getCache(); $cacheID = 'libraries_' . $name; $library = $cache->retrieve($cacheID, false, true, true); if($library) { $library = unserialize($library); } else { $library = libraries_detect($name); $data = serialize($library); $cache->set($cacheID, $data, true); } */ // Exit early if the library was not found. if ($library === false) { $loaded[$name] = $library; return $loaded[$name]; } // If a variant was specified, override the top-level properties with the variant properties. if (isset($variant)) { // Ensure that the $variant key exists, and if it does not, set its 'installed' property to FALSE by // default. This will prevent the loading of the library files below. $library['variants'] += array($variant => array('installed' => false)); $library = array_merge($library, $library['variants'][$variant]); } // Regardless of whether a specific variant was requested or not, there can only be one variant of a library // within a single request. unset($library['variants']); // TODO: // Invoke callbacks in the 'pre-dependencies-load' group. libraries_invoke('pre-dependencies-load', $library); // If the library (variant) is installed, load it. $library['loaded'] = false; if ($library['installed']) { // Load library dependencies. if (isset($library['dependencies'])) { foreach ($library['dependencies'] as $dependency) { libraries_load($dependency); } } // TODO: // Invoke callbacks in the 'pre-load' group. libraries_invoke('pre-load', $library); // Load all the files associated with the library. $library['loaded'] = libraries_load_files($library); // TODO: // Invoke callbacks in the 'post-load' group. libraries_invoke('post-load', $library); } $loaded[$name] = $library; } return $loaded[$name]; }
<?php } ?> </header> <?php } ?> <div id='calendar'></div> <?php // Hide comments, tags, and links now so that we can render them later. hide($content['comments']); hide($content['links']); hide($content['field_tags']); //print render($content); //Custom logic begins here libraries_load('fullcalendar'); $holidays = $content['field_holiday']['#object']->field_holiday['und']; $holidays_json = array(); foreach ($holidays as $key => $data) { $holiday_json = array(); $holiday_json['field_holiday_name'] = $data['field_holiday_name']['und'][0]['value']; $holiday_json['field_location'] = !empty($data['field_location']['und']) ? $data['field_location']['und'][0]['value'] : '0'; $holiday_json['field_publishing_date'] = $data['field_publishing_date']['und'][0]['value']; array_push($holidays_json, $holiday_json); } drupal_add_js(array('holiday_node' => array('holidays_json' => $holidays_json)), 'setting'); drupal_add_js(path_to_theme() . '/js/holidaycalendar.js', 'file'); ?> <div class="newScroll" > HIHIEIEIEI </div>
/** * Load and render a help topic. * * @param string $module * Name of the module. * @param string $topic * Name of the topic. * @todo port the drupal_alter functionality. * * @return string * Returns formatted topic. */ public function viewTopic($module, $topic, $is_modal = false) { $file_info = $this->advanced_help->getTopicFileInfo($module, $topic); if ($file_info) { $info = $this->advanced_help->getTopic($module, $topic); $file = "{$file_info['path']}/{$file_info['file']}"; $build = [ '#type' => 'markup', ]; if (!empty($info['css'])) { $build['#attached']['library'][] = $info['module'] . '/' . $info['css']; } $build['#markup'] = file_get_contents($file); if (isset($info['readme file']) && $info['readme file']) { $ext = pathinfo($file, PATHINFO_EXTENSION); if ('md' == $ext && $this->advanced_help->isMarkdownFilterEnabled()) { libraries_load('php-markdown', 'markdown-extra'); $build['#markup'] = '<div class="advanced-help-topic">' . Xss::filterAdmin(\Michelf\MarkdownExtra::defaultTransform($build['#markup'])) . '</div>'; } else { $readme = ''; if ('md' == $ext) { $readme .= '<p>' . $this->t('If you install the !module module, the text below will be filtered by the module, producing rich text.', [ '!module' => $this->l($this->t('Markdown filter'), Url::fromUri('https://www.drupal.org/project/markdown'), ['attributes' => ['title' => $this->t('Link to project.')]]) ]) . '</p>'; } $readme .= '<div class="advanced-help-topic"><pre class="readme">' . SafeMarkup::checkPlain($build['#markup']) . '</pre></div>'; $build['#markup'] = $readme; } return $build['#markup']; } // Change 'topic:' to the URL for another help topic. preg_match('/&topic:([^"]+)&/', $build['#markup'], $matches); if (isset($matches[1]) && preg_match('/[\w\-]\/[\w\-]+/', $matches[1])) { list($umodule, $utopic) = explode('/', $matches[1]); $path = new Url('advanced_help.help', ['module' => $umodule, 'topic' => $utopic]); $build['#markup'] = preg_replace('/&topic:([^"]+)&/', $path->toString(), $build['#markup']); } global $base_path; // Change 'path:' to the URL to the base help directory. $build['#markup'] = str_replace('&path&', $base_path . $info['path'] . '/', $build['#markup']); // Change 'trans_path:' to the URL to the actual help directory. $build['#markup'] = str_replace('&trans_path&', $base_path . $file_info['path'] . '/', $build['#markup']); // Change 'base_url:' to the URL to the site. $build['#markup'] = preg_replace('/&base_url&([^"]+)"/', $base_path . '$1' . '"', $build['#markup']); // Run the line break filter if requested. if (!empty($info['line break'])) { // Remove the header since it adds an extra <br /> to the filter. $build['#markup'] = preg_replace('/^<!--[^\n]*-->\n/', '', $build['#markup']); $build['#markup'] = _filter_autop($build['#markup']); } if (!empty($info['navigation']) && !$is_modal) { $topics = $this->advanced_help->getTopics(); $topics = $this->getTopicHierarchy($topics); if (!empty($topics[$module][$topic]['children'])) { $items = $this->getTree($topics, $topics[$module][$topic]['children']); $links = [ '#theme' => 'item_list', '#items' => $items ]; $build['#markup'] .= \Drupal::service('renderer')->render($links, FALSE); } list($parent_module, $parent_topic) = $topics[$module][$topic]['_parent']; if ($parent_topic) { $parent = $topics[$module][$topic]['_parent']; $up = new Url('advanced_help.help', ['module' => $parent[0], 'topic' => $parent[1]]); } else { $up = new Url('advanced_help.module_index', ['module' => $module]); } $siblings = $topics[$parent_module][$parent_topic]['children']; uasort($siblings, [$this, 'helpUasort']); $prev = $next = NULL; $found = FALSE; foreach ($siblings as $sibling) { list($sibling_module, $sibling_topic) = $sibling; if ($found) { $next = $sibling; break; } if ($sibling_module == $module && $sibling_topic == $topic) { $found = TRUE; continue; } $prev = $sibling; } if ($prev || $up || $next) { $navigation = '<div class="help-navigation clear-block">'; if ($prev) { $navigation .= $this->l('«« ' . $topics[$prev[0]][$prev[1]]['title'], new Url('advanced_help.help', ['module' => $prev[0], 'topic' => $prev[1]], ['attributes' => ['class' => 'help-left']])); } if ($up) { $navigation .= $this->l($this->t('Up'), $up->setOption('attributes', ['class' => ($prev) ? 'help-up' : 'help-up-noleft'])); } if ($next) { $navigation .= $this->l($topics[$next[0]][$next[1]]['title'] . ' »»', new Url('advanced_help.help', ['module' => $next[0], 'topic' => $next[1]], ['attributes' => ['class' => 'help-right']])); } $navigation .= '</div>'; $build['#markup'] .= $navigation; } } $build['#markup'] = '<div class="advanced-help-topic">' . $build['#markup'] . '</div>'; // drupal_alter('advanced_help_topic', $output, $popup); return $build; } }
/** * List of available languages. * * @return array * An array mapping language code to array with the language path and * full language name. */ public static function getAvailableLanguages() { // Try to get it from cache (database actually). $cache = \Drupal::cache(); $available_languages = $cache->get('geshifilter_available_languages_cache'); if (!$available_languages) { // Not in cache: build the array of available_languages. $geshi_library = libraries_load('geshi'); $available_languages = array(); if ($geshi_library['loaded']) { $dirs = array($geshi_library['library path'] . '/geshi', drupal_get_path('module', 'geshifilter') . '/geshi-extra'); foreach ($dirs as $dir) { foreach (file_scan_directory($dir, '/.[pP][hH][pP]$/i') as $filename => $fileinfo) { // Short name. $name = $fileinfo->name; // Get full name. $geshi = new \GeSHi('', $name); $geshi->set_language_path($dir); $fullname = $geshi->get_language_name(); unset($geshi); // Store. $available_languages[$name] = array('language_path' => $dir, 'fullname' => $fullname); } } ksort($available_languages); // Save array to database. $cache->set('geshifilter_available_languages_cache', $available_languages); } } else { $available_languages = $available_languages->data; } return $available_languages; }
<?php if (!defined('e107_INIT')) { exit; } if (USER_AREA and strpos(e_REQUEST_URI, 'collection')) { if (function_exists('libraries_load') && ($library = libraries_load('prettyPhoto')) && !empty($library['loaded'])) { } else { /* if libraries plugin is not used */ e107::js('gallery', 'jslib/prettyPhoto/js/jquery.prettyPhoto.js', 'jquery'); e107::css('gallery', 'jslib/prettyPhoto/css/prettyPhoto.css', 'jquery'); } $settings = array('hook' => 'data-gal', 'theme' => 'pp_default', 'overlay_gallery' => false, 'deeplinking' => false); e107::js('settings', array('collection' => $settings)); // Now load behavior. e107::js('footer', '{e_PLUGIN}collection/prettyphoto.init.js'); } ?>
<?php /** * @file * Load libraries and JS/CSS files. * If you want to use libraries plugin just upload quick-select folder to e107_web folder * Libraries plugin: https://github.com/lonalore/libraries */ if (!defined('e107_INIT')) { exit; } if (USER_AREA) { /* can be delete if theme use admin modal code or use plugin prefs */ if (function_exists('libraries_load') && ($library = libraries_load('frmediaman-modal')) && !empty($library['loaded'])) { e107::js('links_page', 'frmediaman/frmediaman-modal.js'); } /* script to get admin modal works, this code is from admin.jquery.js file */ if (function_exists('libraries_load') && ($library = libraries_load('frmediaman')) && !empty($library['loaded'])) { e107::js('links_page', 'frmediaman/frmediaman.js'); } }
function ichado1_preprocess_page(&$vars) { $a = 'a'; $cur_path = current_path(); $cur_path_alias = drupal_get_path_alias($cur_path); $add_breadcrumb = drupal_get_title(); if ($cur_path == 'front') { drupal_add_js(drupal_get_path('theme', 'ichado1') . '/js/vktarget.js'); } if ($cur_path == 'cart' || preg_match('/^checkout\\/[\\d]+$/', $cur_path) || preg_match('/^checkout\\/[\\d]+\\/complete$/', $cur_path) || preg_match('/^checkout\\/[\\d]+\\/review$/', $cur_path) || preg_match('/^news$/', $cur_path) || preg_match('/^o-nas$/', $cur_path_alias) || preg_match('/^kontakty$/', $cur_path_alias) || preg_match('/^kak-zakazat-0$/', $cur_path_alias) || preg_match('/^oplata$/', $cur_path_alias) || preg_match('/^dostavka$/', $cur_path_alias) || preg_match('/^garantii-vozvrata$/', $cur_path_alias) || $cur_path == 'user/register' || $cur_path == 'user/login') { $vars['title'] = ''; } if ($cur_path == 'cart' || preg_match('/^checkout\\/[\\d]+$/', $cur_path) || preg_match('/^checkout\\/[\\d]+\\/review$/', $cur_path) || variable_get('auto_scroll', FALSE) || $cur_path == 'catalog' && preg_match('/cart/', $_SERVER['HTTP_REFERER'])) { drupal_add_js(drupal_get_path('theme', 'ichado1') . '/js/auto-scroll.js', 'file'); variable_set('auto_scroll', FALSE); } if (preg_match('/catalog/', $cur_path) || preg_match('/catalog/', $cur_path_alias)) { libraries_load('jcarousel'); } $vars['catalog_menu_drop'] = ''; $context_get = context_get('context'); if ($context_get && in_array('for_drop_down_menu', array_keys($context_get))) { $block = module_invoke('superfish', 'block_view', 1); $catalog_menu_drop = render($block['content']); $vars['catalog_menu_drop'] = $catalog_menu_drop; } /* drupal_add_js('//cdn.callbackhunter.com/cbh.js?hunter_code=7ab9ebf48fe3227cd14cdb9ba43f2cd5', array( 'type' => 'external', 'scope' => 'footer', 'every_page' => TRUE, )); */ }
/** * Implements preprocess_views_view__VIEW(). */ function preprocess_views_view__artwork(&$vars) { $display_id = $vars['display_id']; switch ($display_id) { // Call flexslider scripts. case 'page_3': libraries_load('photoswipe'); break; } }
/** * Tests the applying of callbacks. */ function testCallbacks() { $expected = array('name' => 'Example callback', 'library path' => drupal_get_path('module', 'libraries') . '/tests/example', 'version' => '1', 'versions' => array('1' => array('variants' => array('example_variant' => array('info callback' => 'not applied', 'pre-detect callback' => 'not applied', 'post-detect callback' => 'not applied', 'pre-load callback' => 'not applied', 'post-load callback' => 'not applied')), 'info callback' => 'not applied', 'pre-detect callback' => 'not applied', 'post-detect callback' => 'not applied', 'pre-load callback' => 'not applied', 'post-load callback' => 'not applied')), 'variants' => array('example_variant' => array('info callback' => 'not applied', 'pre-detect callback' => 'not applied', 'post-detect callback' => 'not applied', 'pre-load callback' => 'not applied', 'post-load callback' => 'not applied')), 'callbacks' => array('info' => array('_libraries_test_info_callback'), 'pre-detect' => array('_libraries_test_pre_detect_callback'), 'post-detect' => array('_libraries_test_post_detect_callback'), 'pre-load' => array('_libraries_test_pre_load_callback'), 'post-load' => array('_libraries_test_post_load_callback')), 'info callback' => 'not applied', 'pre-detect callback' => 'not applied', 'post-detect callback' => 'not applied', 'pre-load callback' => 'not applied', 'post-load callback' => 'not applied', 'module' => 'libraries_test'); libraries_info_defaults($expected, 'example_callback'); // Test a callback in the 'info' group. $expected['info callback'] = 'applied (top-level)'; $expected['versions']['1']['info callback'] = 'applied (version 1)'; $expected['versions']['1']['variants']['example_variant']['info callback'] = 'applied (version 1, variant example_variant)'; $expected['variants']['example_variant']['info callback'] = 'applied (variant example_variant)'; $library = libraries_info('example_callback'); $this->verbose('Expected:<pre>' . var_export($expected, TRUE) . '</pre>'); $this->verbose('Actual:<pre>' . var_export($library, TRUE) . '</pre>'); $this->assertEqual($library, $expected, 'Prepare callback was applied correctly.'); // Test a callback in the 'pre-detect' and 'post-detect' phases. // Successfully detected libraries should only contain version information // for the detected version and thus, be marked as installed. unset($expected['versions']); $expected['installed'] = TRUE; // Additionally, version-specific properties of the detected version are // supposed to override the corresponding top-level properties. $expected['info callback'] = 'applied (version 1)'; $expected['variants']['example_variant']['installed'] = TRUE; $expected['variants']['example_variant']['info callback'] = 'applied (version 1, variant example_variant)'; // Version-overloading takes place after the 'pre-detect' callbacks have // been applied. $expected['pre-detect callback'] = 'applied (version 1)'; $expected['post-detect callback'] = 'applied (top-level)'; $expected['variants']['example_variant']['pre-detect callback'] = 'applied (version 1, variant example_variant)'; $expected['variants']['example_variant']['post-detect callback'] = 'applied (variant example_variant)'; $library = libraries_detect('example_callback'); $this->verbose('Expected:<pre>' . var_export($expected, TRUE) . '</pre>'); $this->verbose('Actual:<pre>' . var_export($library, TRUE) . '</pre>'); $this->assertEqual($library, $expected, 'Detect callback was applied correctly.'); // Test a callback in the 'pre-load' and 'post-load' phases. // Successfully loaded libraries should only contain information about the // already loaded variant. unset($expected['variants']); $expected['loaded'] = 0; $expected['pre-load callback'] = 'applied (top-level)'; $expected['post-load callback'] = 'applied (top-level)'; $library = libraries_load('example_callback'); $this->verbose('Expected:<pre>' . var_export($expected, TRUE) . '</pre>'); $this->verbose('Actual:<pre>' . var_export($library, TRUE) . '</pre>'); $this->assertEqual($library, $expected, 'Pre-load and post-load callbacks were applied correctly.'); // This is not recommended usually and is only used for testing purposes. drupal_static_reset('libraries_load'); // Successfully loaded library variants are supposed to contain the specific // variant information only. $expected['info callback'] = 'applied (version 1, variant example_variant)'; $expected['pre-detect callback'] = 'applied (version 1, variant example_variant)'; $expected['post-detect callback'] = 'applied (variant example_variant)'; $library = libraries_load('example_callback', 'example_variant'); $this->verbose('Expected:<pre>' . var_export($expected, TRUE) . '</pre>'); $this->verbose('Actual:<pre>' . var_export($library, TRUE) . '</pre>'); $this->assertEqual($library, $expected, 'Pre-detect and post-detect callbacks were applied correctly to a variant.'); }