Exemplo n.º 1
0
 /**
  * {@inheritdoc}
  */
 public function buildForm(array $form, FormStateInterface $form_state)
 {
     module_load_include('inc', 'pathauto');
     $config = $this->config('pathauto.settings');
     $form = array();
     $form['verbose'] = array('#type' => 'checkbox', '#title' => t('Verbose'), '#default_value' => $config->get('verbose'), '#description' => t('Display alias changes (except during bulk updates).'));
     $form['separator'] = array('#type' => 'textfield', '#title' => t('Separator'), '#size' => 1, '#maxlength' => 1, '#default_value' => $config->get('separator'), '#description' => t('Character used to separate words in titles. This will replace any spaces and punctuation characters. Using a space or + character can cause unexpected results.'));
     $form['case'] = array('#type' => 'radios', '#title' => t('Character case'), '#default_value' => $config->get('case'), '#options' => array(self::CASE_LEAVE_ASIS => t('Leave case the same as source token values.'), self::CASE_LOWER => t('Change to lower case')));
     $max_length = \Drupal::service('pathauto.alias_storage_helper')->getAliasSchemaMaxlength();
     $form['max_length'] = array('#type' => 'number', '#title' => t('Maximum alias length'), '#size' => 3, '#maxlength' => 3, '#default_value' => $config->get('max_length'), '#min' => 1, '#max' => $max_length, '#description' => t('Maximum length of aliases to generate. 100 is the recommended length. @max is the maximum possible length. See <a href="@pathauto-help">Pathauto help</a> for details.', array('@pathauto-help' => $this->getUrlGenerator()->generateFromPath('admin/help/pathauto'), '@max' => $max_length)));
     $form['max_component_length'] = array('#type' => 'number', '#title' => t('Maximum component length'), '#size' => 3, '#maxlength' => 3, '#default_value' => $config->get('max_component_length'), '#min' => 1, '#max' => $max_length, '#description' => t('Maximum text length of any component in the alias (e.g., [title]). 100 is the recommended length. @max is the maximum possible length. See <a href="@pathauto-help">Pathauto help</a> for details.', array('@pathauto-help' => $this->getUrlGenerator()->generateFromPath('admin/help/pathauto'), '@max' => $max_length)));
     $description = t('What should Pathauto do when updating an existing content item which already has an alias?');
     if (\Drupal::moduleHandler()->moduleExists('redirect')) {
         $description .= ' ' . t('The <a href="!url">Redirect module settings</a> affect whether a redirect is created when an alias is deleted.', array('!url' => \Drupal::url('redirect.settings')));
     } else {
         $description .= ' ' . t('Considering installing the <a href="!url">Redirect module</a> to get redirects when your aliases change.', array('!url' => 'http://drupal.org/project/redirect'));
     }
     $form['update_action'] = array('#type' => 'radios', '#title' => t('Update action'), '#default_value' => $config->get('update_action'), '#options' => array(PathautoManagerInterface::UPDATE_ACTION_NO_NEW => t('Do nothing. Leave the old alias intact.'), PathautoManagerInterface::UPDATE_ACTION_LEAVE => t('Create a new alias. Leave the existing alias functioning.'), PathautoManagerInterface::UPDATE_ACTION_DELETE => t('Create a new alias. Delete the old alias.')), '#description' => $description);
     $form['transliterate'] = array('#type' => 'checkbox', '#title' => t('Transliterate prior to creating alias'), '#default_value' => $config->get('transliterate'), '#description' => t('When a pattern includes certain characters (such as those with accents) should Pathauto attempt to transliterate them into the US-ASCII alphabet? Transliteration is handled by the Transliteration module.'));
     $form['reduce_ascii'] = array('#type' => 'checkbox', '#title' => t('Reduce strings to letters and numbers'), '#default_value' => $config->get('reduce_ascii'), '#description' => t('Filters the new alias to only letters and numbers found in the ASCII-96 set.'));
     $form['ignore_words'] = array('#type' => 'textarea', '#title' => t('Strings to Remove'), '#default_value' => $config->get('ignore_words'), '#description' => t('Words to strip out of the URL alias, separated by commas. Do not use this to remove punctuation.'), '#wysiwyg' => FALSE);
     $form['punctuation'] = array('#type' => 'fieldset', '#title' => t('Punctuation'), '#collapsible' => TRUE, '#collapsed' => TRUE, '#tree' => TRUE);
     $punctuation = \Drupal::service('pathauto.manager')->getPunctuationCharacters();
     foreach ($punctuation as $name => $details) {
         $details['default'] = PathautoManagerInterface::PUNCTUATION_REMOVE;
         if ($details['value'] == $config->get('separator')) {
             $details['default'] = PathautoManagerInterface::PUNCTUATION_REPLACE;
         }
         $form['punctuation']['punctuation' . $name] = array('#type' => 'select', '#title' => $details['name'] . ' (<code>' . SafeMarkup::checkPlain($details['value']) . '</code>)', '#default_value' => $details['default'], '#options' => array(PathautoManagerInterface::PUNCTUATION_REMOVE => t('Remove'), PathautoManagerInterface::PUNCTUATION_REPLACE => t('Replace by separator'), PathautoManagerInterface::PUNCTUATION_DO_NOTHING => t('No action (do not replace)')));
     }
     return parent::buildForm($form, $form_state);
 }
 /**
  * Get all the form contents for rendering
  * @return type renderable array
  */
 function getForm($form, &$form_state, $disabled, $myvalues)
 {
     $loaded = module_load_include('inc', 'raptor_contraindications', 'core/ContraIndEngine');
     if (!$loaded) {
         $msg = 'Failed to load the Contraindication Engine';
         throw new \Exception($msg);
         //This is fatal, so stop everything now.
     }
     $oCIE = new \raptor\ContraIndEngine(NULL);
     $form["data_entry_area1"] = array('#prefix' => "\n<section class='raptor-report'>\n", '#suffix' => "\n</section>\n");
     $form['data_entry_area1']['blurb']['p2'] = array('#type' => 'item', '#markup' => '<p>The flags and measures listed as "database" are configured in the database.  The items listed as "coded" are implemented by programmers in the RAPTOR codebase.  The "database" configured flags and measures can be customized for a deployed site, the "coded" items cannot.</p>');
     $form['data_entry_area1']['blurb']['p3'] = array('#type' => 'item', '#markup' => '<p>Both the flags and the measures listed here can be used in flag formulas, but only boolean items can be used in Rule formulas.  Boolean items are shown in this report as having value type "boolean".  A boolean flag can have one of three values "True","False", or "Null".  A "Null" value occurs when input criteria for a flag or measure is not available or is unknown at evaluation time.</p>');
     $form["data_entry_area1"]['table_container'] = array('#type' => 'item', '#prefix' => '<div class="raptor-dialog-table-container">', '#suffix' => '</div>', '#tree' => TRUE);
     $rows = "\n";
     $aAllInputs = $oCIE->getSREContext()->getDictionary()->getActiveRuleInputs();
     foreach ($aAllInputs as $aInputs) {
         $sLocked = isset($aInputs['locked']) && $aInputs['locked'] == 1 ? 'Yes' : 'No';
         $return_type = $aInputs['return'];
         if ($return_type > '') {
             $rtparts = explode(' ', $return_type);
             $rtclassmarkup = ' class="' . $rtparts[0] . '-measure" ';
         } else {
             $rtclassmarkup = '';
         }
         $rows .= "\n" . '<tr>' . '<td>' . $aInputs['source'] . '</td>' . '<td>' . $sLocked . '</td>' . '<td><span ' . $rtclassmarkup . '>' . $return_type . '</span></td>' . '<td>' . $aInputs['category_nm'] . '</td>' . '<td>' . $aInputs['name'] . '</td>' . '<td>' . $aInputs['purpose_tx'] . '</td>' . '<td>' . $aInputs['criteria_tx'] . '</td>' . '</tr>';
     }
     $form["data_entry_area1"]['table_container']['users'] = array('#type' => 'item', '#markup' => '<table id="my-raptor-dialog-table" class="raptor-dialog-table dataTable">' . '<thead><tr>' . '<th>Implementation Location</th>' . '<th>Read Only</th>' . '<th>Value Type</th>' . '<th>Category Date</th>' . '<th>Name</th>' . '<th>Purpose</th>' . '<th>Formula</th>' . '</tr>' . '</thead>' . '<tbody>' . $rows . '</tbody>' . '</table>');
     $form['data_entry_area1']['action_buttons'] = array('#type' => 'item', '#prefix' => '<div class="raptor-action-buttons">', '#suffix' => '</div>', '#tree' => TRUE);
     $form['data_entry_area1']['action_buttons']['refresh'] = array('#type' => 'submit', '#attributes' => array('class' => array('admin-action-button'), 'id' => 'refresh-report'), '#value' => t('Refresh Report'));
     $form['data_entry_area1']['action_buttons']['cancel'] = array('#type' => 'item', '#markup' => '<input class="admin-cancel-button" type="button" value="Exit" data-redirect="/drupal/worklist?dialog=viewReports">');
     return $form;
 }
Exemplo n.º 3
0
 function createFedoraDataStreams($form_values, &$dom, &$rootElement)
 {
     module_load_include('php', 'Fedora_Repository', 'mimetype');
     global $base_url;
     $mimetype = new mimetype();
     $server = null;
     $file = $form_values['ingest-file-location'];
     $dformat = $mimetype->getType($file);
     $fileUrl = $base_url . '/' . drupal_urlencode($file);
     $beginIndex = strrpos($fileUrl, '/');
     $dtitle = substr($fileUrl, $beginIndex + 1);
     $dtitle = substr($dtitle, 0, strpos($dtitle, "."));
     $ds1 = $dom->createElement("foxml:datastream");
     $ds1->setAttribute("ID", "COLLECTION_POLICY");
     //set the ID
     $ds1->setAttribute("STATE", "A");
     $ds1->setAttribute("CONTROL_GROUP", "M");
     $ds1v = $dom->createElement("foxml:datastreamVersion");
     $ds1v->setAttribute("ID", "COLLECTION_POLICY.0");
     $ds1v->setAttribute("MIMETYPE", "{$dformat}");
     $ds1v->setAttribute("LABEL", "{$dtitle}");
     $ds1content = $dom->createElement('foxml:contentLocation');
     $ds1content->setAttribute("REF", "{$fileUrl}");
     $ds1content->setAttribute("TYPE", "URL");
     $ds1->appendChild($ds1v);
     $ds1v->appendChild($ds1content);
     $rootElement->appendChild($ds1);
 }
 /**
  * {@inheritdoc}
  */
 public function submitForm(array &$form, FormStateInterface $form_state)
 {
     module_load_include('inc', 'sociallogin');
     $data = get_authentication($form_state->getValue('api_key'), $form_state->getValue('api_secret'));
     if (isset($data['status']) && $data['status'] != 'status') {
         drupal_set_message($data['message'], $data['status']);
         return FALSE;
     }
     parent::SubmitForm($form, $form_state);
     $this->config('sociallogin.settings')->set('sso_site_name', $form_state->getValue('sso_site_name'))->set('api_key', $form_state->getValue('api_key'))->set('api_secret', $form_state->getValue('api_secret'))->set('username_option', $form_state->getValue('username_option'))->set('login_redirection', $form_state->getValue('login_redirection'))->set('register_redirection', $form_state->getValue('register_redirection'))->set('custom_login_url', $form_state->getValue('custom_login_url'))->set('custom_register_url', $form_state->getValue('custom_register_url'))->set('enable_linking', $form_state->getValue('enable_linking'))->set('linking_text', $form_state->getValue('linking_text'))->save();
     if (count(\Drupal::moduleHandler()->getImplementations('add_extra_sociallogin_config_settings')) > 0) {
         // Call all modules that implement the hook, and let them make changes to $variables.
         $config_data = \Drupal::moduleHandler()->invokeAll('add_extra_sociallogin_config_settings');
     }
     if (isset($config_data) && is_array($config_data)) {
         foreach ($config_data as $key => $value) {
             $this->config('sociallogin.settings')->set($value, $form_state->getValue($value))->save();
         }
     }
     drupal_set_message(t('Social Login settings have been saved.'), 'status');
     //Clear page cache
     foreach (Cache::getBins() as $service_id => $cache_backend) {
         if ($service_id == 'dynamic_page_cache') {
             $cache_backend->deleteAll();
         }
     }
 }
 /**
  * Payment method settings form.
  *
  * @param $order
  * The order transaction
  * @param $payment_method
  * The payment method used
  *
  * @return array
  *   Settings form array
  */
 public function getExtraInit($order, $payment_method)
 {
     $array = array();
     module_load_include('inc', 'commerce_payment', 'includes/commerce_payment.credit_card');
     $payment_token = $this->generatePaymentToken($order, $payment_method);
     if ($order) {
         $order_wrapper = entity_metadata_wrapper('commerce_order', $order);
         $billing_address = $order_wrapper->commerce_customer_billing->commerce_customer_address->value();
         $order_array = $order_wrapper->commerce_order_total->value();
         $default_currency = commerce_default_currency();
         $amount_cents = commerce_currency_convert($order_array['amount'], $order_array['currency_code'], $default_currency);
         $config = array();
         $config['publicKey'] = $payment_method['settings']['public_key'];
         $config['mode'] = $payment_method['settings']['mode'];
         $config['iconcolor'] = $payment_method['settings']['iconcolor'];
         $config['logourl'] = $payment_method['settings']['logourl'];
         $config['buttoncolor'] = $payment_method['settings']['buttoncolor'];
         $config['themecolor'] = $payment_method['settings']['themecolor'];
         $config['currencycode'] = $payment_method['settings']['currencycode'];
         $config['email'] = $order->mail;
         $config['name'] = "{$billing_address['first_name']} {$billing_address['last_name']}";
         $config['amount'] = $amount_cents;
         $config['currency'] = $default_currency;
         $config['localpayment'] = $payment_method['settings']['localpayment'] == 'false' ? 'card' : 'mixed';
         $config['paymentToken'] = $payment_token['token'];
         $array['script'] = $config;
         $array['paymentToken'] = $payment_token;
     }
     return $array;
 }
Exemplo n.º 6
0
function add_Datastream($pid, $datastream, $dsLabel, $mimetype, $xml_url)
{
    module_load_include('php', 'Fedora_Repository', 'ObjectHelper');
    module_load_include('php', 'Fedora_Repository', 'ConnectionHelper');
    global $user;
    if (!fedora_repository_access(OBJECTHELPER::$ADD_FEDORA_STREAMS, $pid, $user)) {
        drupal_set_message('You do not have permission to add datastreams to this object!');
        return false;
    }
    global $base_url;
    module_load_include('php', 'Fedora_Repository', 'ConnectionHelper');
    $controlGroup = "M";
    $params = array('pid' => $pid, 'dsID' => $datastream, 'altIDs' => "", 'dsLabel' => $dsLabel, 'versionable' => "true", 'MIMEType' => $mimetype, 'formatURI' => "URL", 'dsLocation' => $xml_url, 'controlGroup' => "{$controlGroup}", 'dsState' => "A", 'checksumType' => "DISABLED", 'checksum' => "none", 'logMessage' => "datastream added");
    try {
        $soapHelper = new ConnectionHelper();
        $client = $soapHelper->getSoapClient(variable_get('fedora_soap_manage_url', 'http://localhost:8080/fedora/services/management?wsdl'));
        if ($client == null) {
            drupal_set_message(t('Error Getting Soap Client.'), 'error');
            return false;
        }
        $object = $client->__soapCall('addDatastream', array('parameters' => $params));
        return true;
    } catch (exception $e) {
        try {
            $params['force'] = 'true';
            $object = $client->__soapCall('ModifyDatastreamByReference', array($params));
            return true;
        } catch (exception $e1) {
            drupal_set_message(t($e1->getMessage()), 'error');
            return false;
        }
    }
}
Exemplo n.º 7
0
 /**
  * Modify the url and add headers appropriate to authenticate to Acquia Search.
  *
  * @return
  *  The nonce used in the request.
  */
 protected function prepareRequest(&$url, &$options, $use_data = TRUE)
 {
     module_load_include('inc', 'acquia_agent', 'acquia_agent_streams');
     $id = uniqid();
     if (!stristr($url, '?')) {
         $url .= "?";
     } else {
         $url .= "&";
     }
     $url .= 'request_id=' . $id;
     if ($use_data && isset($options['data'])) {
         list($cookie, $nonce) = acquia_search_auth_cookie($url, $options['data'], NULL, $this->env_id);
     } else {
         list($cookie, $nonce) = acquia_search_auth_cookie($url, NULL, NULL, $this->env_id);
     }
     if (empty($cookie)) {
         throw new Exception('Invalid authentication string - subscription keys expired or missing.');
     }
     $options['headers']['Cookie'] = $cookie;
     $options['headers'] += array('User-Agent' => 'acquia_search/' . variable_get('acquia_search_version', '6.x'));
     $options['context'] = acquia_agent_stream_context_create($url, 'acquia_search');
     if (!$options['context']) {
         throw new Exception(t("Could not create stream context"));
     }
     return $nonce;
 }
Exemplo n.º 8
0
 function canIngestHere($collection_pid)
 {
     global $user;
     module_load_include('php', 'Fedora_Repository', 'ObjectHelper');
     $objectHelper = new ObjectHelper();
     //get the childsecurity policy from the collection.
     $policyStream = $objectHelper->getStream($collection_pid, SECURITYCLASS::$SECURITYSTREAM, false);
     if ($policyStream == null) {
         //no child policy stream so collection is wide open to anyone to ingest, that has the permission ingest in Drupal.
         //maybe we should return false here?? would be more secure.
         return true;
     }
     $allowedUsersAndRoles = $this->getAllowedUsersAndRoles($policyStream);
     if (!$allowedUsersAndRoles) {
         //error processing stream so don't let them ingest here.
         return false;
     }
     $allowedUsers = $allowedUsersAndRoles["users"];
     $allowedRoles = $allowedUsersAndRoles["roles"];
     foreach ($user->roles as $role) {
         if (in_array($role, $allowedRoles)) {
             return true;
         }
     }
     if (in_array($user->name, $allowedUsers)) {
         return true;
     }
     return false;
 }
Exemplo n.º 9
0
 /**
  * {@inheritdoc}
  */
 public function setUp()
 {
     // Load two modules: the captcha module itself and the comment
     // module for testing anonymous comments.
     parent::setUp();
     module_load_include('inc', 'captcha');
     $this->drupalCreateContentType(array('type' => 'page'));
     // Create a normal user.
     $permissions = array('access comments', 'post comments', 'skip comment approval', 'access content', 'create page content', 'edit own page content');
     $this->normalUser = $this->drupalCreateUser($permissions);
     // Create an admin user.
     $permissions[] = 'administer CAPTCHA settings';
     $permissions[] = 'skip CAPTCHA';
     $permissions[] = 'administer permissions';
     $permissions[] = 'administer content types';
     $this->adminUser = $this->drupalCreateUser($permissions);
     // Open comment for page content type.
     $this->addDefaultCommentField('node', 'page');
     // Put comments on page nodes on a separate page.
     $comment_field = FieldConfig::loadByName('node', 'page', 'comment');
     $comment_field->setSetting('form_location', CommentItemInterface::FORM_SEPARATE_PAGE);
     $comment_field->save();
     /* @var \Drupal\captcha\Entity\CaptchaPoint $captcha_point */
     $captcha_point = \Drupal::entityManager()->getStorage('captcha_point')->load('user_login_form');
     $captcha_point->enable()->save();
     $this->config('captcha.settings')->set('default_challenge', 'captcha/test')->save();
 }
Exemplo n.º 10
0
 /**
  * {@inheritdoc}
  */
 public function settingsSummary()
 {
     $settings = $this->getSettings();
     $summary = array();
     $field_name = explode('.', $this->fieldDefinition->id());
     $field_name = end($field_name);
     $machine_name = isset($settings['format']) ? $settings['format'] : 'default';
     $name_format = entity_load('name_format', $machine_name);
     if ($name_format) {
         $summary[] = t('Format: %format (@machine_name)', array('%format' => $name_format->label(), '@machine_name' => $name_format->id()));
     } else {
         $summary[] = t('Format: <strong>Missing format.</strong><br/>This field will be displayed using the Default format.');
         $machine_name = 'default';
     }
     // Provide an example of the selected format.
     module_load_include('admin.inc', 'name');
     $used_components = $this->getFieldSetting('components');
     $excluded_components = array_diff_key($used_components, _name_translations());
     $examples = name_example_names($excluded_components, $field_name);
     if ($examples && ($example = array_shift($examples))) {
         $format = name_get_format_by_machine_name($machine_name);
         $formatted = SafeMarkup::checkPlain(NameFormatParser::parse($example, $format));
         if (empty($formatted)) {
             $formatted = '<em>&lt;&lt;empty&gt;&gt;</em>';
         }
         $summary[] = t('Example: !example', array('!example' => $formatted));
     }
     $summary[] = t('Markup: @yesno', array('@yesno' => empty($settings['markup']) ? t('no') : t('yes')));
     $output_options = _name_formatter_output_options();
     $output = empty($settings['output']) ? 'default' : $settings['output'];
     $summary[] = t('Output: @format', array('@format' => $output_options[$output]));
     return $summary;
 }
 /**
  * @todo Remove content_translation_edit_page().
  */
 public function edit(Request $request, $language)
 {
     $entity = $request->attributes->get($request->attributes->get('_entity_type_id'));
     module_load_include('pages.inc', 'content_translation');
     $language = language_load($language);
     return content_translation_edit_page($entity, $language);
 }
 /**
  * Override EntityReferenceHandler::settingsForm().
  */
 public function settingsForm($field, $instance)
 {
     $form = parent::settingsForm($field, $instance);
     $settings = !empty($instance['settings']['behaviors']['og_widget']) ? $instance['settings']['behaviors']['og_widget'] : array();
     $settings += array('default' => array('widget_type' => 'options_select', 'widget_settings' => array()), 'admin' => array('widget_type' => 'entityreference_autocomplete', 'widget_settings' => array()));
     $field_types = array('default' => array('title' => t('Default widget type'), 'description' => t('The widget type of the field as it will appear to the user.')), 'admin' => array('title' => t('Administrator widget type'), 'description' => t('The widget type of the field that will appear only to a user with "Administer group" permission.')));
     module_load_include('inc', 'field_ui', 'field_ui.admin');
     $widget_types = field_ui_widget_type_options('entityreference');
     unset($widget_types['og_complex']);
     $field_info_widget_types = field_info_widget_types();
     foreach ($field_types as $field_type => $value) {
         $settings_id = 'og-' . $field_type . '-settings';
         $form[$field_type]['widget_type'] = array('#type' => 'select', '#title' => $value['title'], '#required' => TRUE, '#options' => $widget_types, '#default_value' => $settings[$field_type]['widget_type'], '#description' => $value['description'], '#ajax' => array('callback' => 'og_' . $field_type . '_settings_form_ajax', 'wrapper' => $settings_id, 'method' => 'replace', 'event' => 'change'));
         $form[$field_type]['widget_settings'] = array('#type' => 'fieldset', '#title' => t('@title Settings', array('@title' => $value['title'])), '#tree' => TRUE, '#attributes' => array('id' => $settings_id));
         if ($settings[$field_type]['widget_type'] && !empty($field_info_widget_types[$settings[$field_type]['widget_type']])) {
             $widget_type = $field_info_widget_types[$settings[$field_type]['widget_type']];
             $current_settings = isset($settings[$field_type]['widget_settings']) ? $settings[$field_type]['widget_settings'] : array();
             $fake_instance = array('widget' => array('type' => $settings[$field_type]['widget_type'], 'module' => $widget_type['module'], 'settings' => $current_settings) + $instance['widget']) + $instance;
             $additions = module_invoke($widget_type['module'], 'field_widget_settings_form', $field, $fake_instance);
             if ($additions) {
                 $form[$field_type]['widget_settings'] += $additions;
             }
         }
     }
     // Field access settings.
     $form['access_override'] = array('#title' => t('Allow entity access to control field access'), '#description' => t('By default, the <em>administer group</em> permission is required to directly edit this field. Selecting this option will allow access to anybody with access to edit the entity.'), '#type' => 'checkbox', '#default_value' => isset($settings['access_override']) ? $settings['access_override'] : FALSE);
     return $form;
 }
Exemplo n.º 13
0
 /**
  * Initialises this item using data from an XML node.
  * @param DOMElement $node The node to use for initialisation.
  * @param CqQuestionInterface $context The question or other object that the mapping
  * can query for things like the current answer, draggables and hotspots.
  */
 public function __construct(DOMElement $node, $context)
 {
     module_load_include('inc.php', 'closedquestion', 'lib/XmlLib');
     if ($node) {
         $attribs = $node->attributes;
         if ($attribs) {
             $item = $attribs->getNamedItem('identifier');
             if ($item === NULL) {
                 $item = $attribs->getNamedItem('id');
             }
             if ($item === NULL) {
                 $item = $attribs->getNamedItem('name');
             }
             if ($item !== NULL) {
                 $this->identifier = $item->nodeValue;
             }
             $item = $attribs->getNamedItem('src');
             if ($item !== NULL) {
                 $this->imgSrc = $item->nodeValue;
             }
             $item = $attribs->getNamedItem('class');
             if ($item !== NULL) {
                 $this->cssClass = $item->nodeValue;
             }
         }
         $this->text = cq_get_text_content($node, $context);
     }
 }
Exemplo n.º 14
0
/**
 * Registers forms with Bootstrap to be displayed as modals.
 *
 * This example registers the sitewide "Contact Us" form.
 *
 * @return array
 */
function hook_bootstrap_modal_forms()
{
    module_load_include('inc', 'contact', 'contact.pages');
    $items = array();
    $items['contact_modal_form'] = array('form' => drupal_get_form('contact_site_form'), 'title' => t('Contact Us'), 'action' => 'contact');
    return $items;
}
Exemplo n.º 15
0
 function getMetadata(&$form_values)
 {
     module_load_include('php', 'Fedora_Repository', 'mimetype');
     global $base_url;
     //$mimetype = new mimetype();
     if (!empty($_SESSION['fedora_ingest_files'])) {
         foreach ($_SESSION['fedora_ingest_files'] as $dsid => $createdFile) {
             $file = $form_values['ingest-file-location'];
             $fileUrl = $base_url . '/fedora/repository/' . $form_values['pid'] . '/FULL_SIZE';
             $file_size = filesize($createdFile);
             $file_md5 = md5_file($createdFile);
             $file_path = $fileUrl;
             $imagesize = getimagesize($createdFile);
             //list($file_width, $file_height, $file_format, $attr,$file_mime) = getimagesize($createdFile);
             $file_width = $imagesize['0'];
             $file_height = $imagesize['1'];
             $file_format = $imagesize['2'];
             $attr = $imagesize['3'];
             $file_mime = $imagesize['mime'];
             continue;
         }
     }
     $form_values['img_size'] = $file_size;
     $form_values['img_md5'] = $file_md5;
     $form_values['img_file'] = $file_path;
     $form_values['img_imagelength'] = $file_height;
     $form_values['img_imagewidth'] = $file_width;
     $form_values['img_format'] = str_replace(array('1', '2', '3', '4'), array('GIF', 'JPG', 'PNG', 'SWF'), $file_format);
     $form_values['img_mime'] = $file_mime;
     $form_values['img_samplingfrequencyunit'] = '1';
     $form_values['img_samplingfrequencyplane'] = '1';
 }
/**
 * Add menu position rules.
 */
function osha_add_menu_position_rules()
{
    if (module_exists('osha') && module_load_include('inc', 'osha', 'osha.utils')) {
        // Menu position rule for Press Release content type.
        $parent_menu = '------ Press room';
        $condition = array('content_type' => array('press_release' => 'press_release'));
        osha_add_menu_position_rule('Press room Menu Rule', $parent_menu, $condition);
        // Menu position rule for See all Press Releases Menu Rule.
        $condition = array('pages' => 'press-releases');
        osha_add_menu_position_rule('See all Press Releases Menu Rule', $parent_menu, $condition);
        // Menu position rule for Publication content type
        $condition = array('content_type' => array('publication' => 'publication'));
        osha_add_menu_position_rule('Publications Menu Rule', '------ Publications', $condition);
        // Menu position rule for Seminar content type
        $condition = array('content_type' => array('seminar' => 'seminar'));
        osha_add_menu_position_rule('Seminar Menu Rule', '------ Our seminars', $condition);
        // Menu position rule for Calls content type
        $condition = array('content_type' => array('calls' => 'calls'));
        osha_add_menu_position_rule('Calls Menu Rule', '------ Procurement', $condition);
        $condition = array('pages' => 'calls_archive');
        osha_add_menu_position_rule('Calls archive Menu Rule', '------ Procurement', $condition);
        // Menu position rule for Job vacancies content type
        $condition = array('content_type' => array('job_vacancies' => 'job_vacancies'));
        osha_add_menu_position_rule('Job vacancies Menu Rule', '------ Careers', $condition);
    }
}
 public function overviewForm($form, &$form_state)
 {
     // Add table and pager.
     $form = parent::overviewForm($form, $form_state);
     // Allow modules to insert their own action links to the 'table', like cleanup module.
     $top_actions = module_invoke_all('workflow_operations', 'top_actions', NULL);
     // Allow modules to insert their own workflow operations.
     foreach ($form['table']['#rows'] as &$row) {
         $url = $row[0]['data']['#url'];
         $workflow = $url['options']['entity'];
         foreach ($actions = module_invoke_all('workflow_operations', 'workflow', $workflow) as $action) {
             $action['attributes'] = isset($action['attributes']) ? $action['attributes'] : array();
             $row[] = l(strtolower($action['title']), $action['href'], $action['attributes']);
         }
     }
     // @todo: add these top actions next to the core 'Add workflow' action.
     $top_actions_args = array('links' => $top_actions, 'attributes' => array('class' => array('inline', 'action-links')));
     $form['action-links'] = array('#type' => 'markup', '#markup' => theme('links', $top_actions_args), '#weight' => -1);
     if (module_exists('workflownode')) {
         // Append the type_map form, changing the form by reference.
         // The 'type_map' form is only valid for Workflow Node API.
         module_load_include('inc', 'workflow_admin_ui', 'workflow_admin_ui.page.type_map');
         workflow_admin_ui_type_map_form($form);
     }
     // Add a submit button. The submit functions are added in the sub-forms.
     $form['submit'] = array('#type' => 'submit', '#value' => t('Save'), '#weight' => 100);
     return $form;
 }
Exemplo n.º 18
0
/**
 * Act on user account cancellations.
 *
 * The user account is being canceled. Depending on the account cancellation
 * method, the module should either do nothing, unpublish content, anonymize
 * content, or delete content and data belonging to the canceled user account.
 *
 * Expensive operations should be added to the global batch with batch_set().
 *
 * @param $edit
 *   The array of form values submitted by the user.
 * @param $account
 *   The user object on which the operation is being performed.
 * @param $method
 *   The account cancellation method.
 *
 * @see user_cancel_methods()
 * @see hook_user_cancel_methods_alter()
 * @see user_cancel()
 */
function hook_user_cancel($edit, $account, $method)
{
    switch ($method) {
        case 'user_cancel_block_unpublish':
            // Unpublish nodes (current revisions).
            module_load_include('inc', 'node', 'node.admin');
            $nodes = db_select('node', 'n')->fields('n', array('nid'))->condition('uid', $account->uid)->execute()->fetchCol();
            node_mass_update($nodes, array('status' => 0));
            break;
        case 'user_cancel_reassign':
            // Anonymize nodes (current revisions).
            module_load_include('inc', 'node', 'node.admin');
            $nodes = db_select('node', 'n')->fields('n', array('nid'))->condition('uid', $account->uid)->execute()->fetchCol();
            node_mass_update($nodes, array('uid' => 0));
            // Anonymize old revisions.
            db_update('node_revision')->fields(array('uid' => 0))->condition('uid', $account->uid)->execute();
            // Clean history.
            db_delete('history')->condition('uid', $account->uid)->execute();
            break;
        case 'user_cancel_delete':
            // Delete nodes (current revisions).
            $nodes = db_select('node', 'n')->fields('n', array('nid'))->condition('uid', $account->uid)->execute()->fetchCol();
            foreach ($nodes as $nid) {
                node_delete($nid);
            }
            // Delete old revisions.
            db_delete('node_revision')->condition('uid', $account->uid)->execute();
            // Clean history.
            db_delete('history')->condition('uid', $account->uid)->execute();
            break;
    }
}
Exemplo n.º 19
0
 /**
  * {@inheritdoc}
  */
 public function nodeCreate($node)
 {
     $current_path = getcwd();
     chdir(DRUPAL_ROOT);
     // Set original if not set.
     if (!isset($node->original)) {
         $node->original = clone $node;
     }
     // Assign authorship if none exists and `author` is passed.
     if (!isset($node->uid) && !empty($node->author) && ($user = user_load(array('name' => $node->author)))) {
         $node->uid = $user->uid;
     }
     // Convert properties to expected structure.
     $this->expandEntityProperties($node);
     // Attempt to decipher any fields that may be specified.
     $this->expandEntityFields('node', $node);
     // Set defaults that haven't already been set.
     $defaults = clone $node;
     module_load_include('inc', 'node', 'node.pages');
     node_object_prepare($defaults);
     $node = (object) array_merge((array) $defaults, (array) $node);
     node_save($node);
     chdir($current_path);
     return $node;
 }
/**
 * Configure the apachesolr and search_api_solr modules with proper settings.
 */
function osha_configure_solr()
{
    $config_file = sprintf('%s/../conf/config.json', dirname(__FILE__));
    if (!is_readable($config_file)) {
        drupal_set_message("Cannot read configuration file!", 'warning');
        return;
    }
    $cfg = json_decode(file_get_contents($config_file), TRUE);
    if (empty($cfg)) {
        drupal_set_message('Configuration file was empty, nothing to do here', 'warning');
        return;
    }
    $cfg = array_merge(array('name' => 'Solr server', 'enabled' => 1, 'description' => 'Search server', 'scheme' => 'http', 'host' => 'localhost', 'port' => '8983', 'path' => '/solr', 'http_user' => '', 'http_password' => '', 'excerpt' => NULL, 'retrieve_data' => NULL, 'highlight_data' => NULL, 'skip_schema_check' => NULL, 'solr_version' => '', 'http_method' => 'AUTO'), $cfg['solr_server']);
    if (module_exists('search_api_solr') && module_load_include('inc', 'search_api', 'search_api.admin')) {
        drupal_set_message('Configuring search_api_solr ...');
        $form_state = array('values' => array('machine_name' => 'solr_server', 'class' => 'search_api_solr_service', 'name' => $cfg['name'], 'enabled' => $cfg['enabled'], 'description' => $cfg['description'], 'options' => array('form' => array('scheme' => $cfg['scheme'], 'host' => $cfg['host'], 'port' => $cfg['port'], 'path' => $cfg['path'], 'http' => array('http_user' => $cfg['http_user'], 'http_pass' => $cfg['http_pass']), 'advanced' => array('excerpt' => $cfg['excerpt'], 'retrieve_data' => $cfg['retrieve_data'], 'highlight_data' => $cfg['highlight_data'], 'skip_schema_check' => $cfg['skip_schema_check'], 'solr_version' => $cfg['solr_version'], 'http_method' => $cfg['http_method'])))));
        drupal_form_submit('search_api_admin_add_server', $form_state);
    }
    // Configure apachesolr: submit apachesolr_environment_edit_form
    if (module_exists('apachesolr') && module_load_include('inc', 'apachesolr', 'apachesolr.admin')) {
        drupal_set_message('Configuring apachesolr ...');
        $url = sprintf('%s://%s:%s%s', $cfg['scheme'], $cfg['host'], $cfg['port'], $cfg['path']);
        $env_id = apachesolr_default_environment();
        $environment = apachesolr_environment_load($env_id);
        $environment['url'] = $url;
        $environment['name'] = $cfg['name'];
        $environment['conf']['apachesolr_direct_commit'] = $cfg['apachesolr_direct_commit'];
        $environment['conf']['apachesolr_read_only'] = $cfg['apachesolr_read_only'];
        $environment['conf']['apachesolr_soft_commit'] = $cfg['apachesolr_soft_commit'];
        apachesolr_environment_save($environment);
        // @todo: See ticket #2527 - cannot make the form save new settings!
        // drupal_form_submit('apachesolr_environment_edit_form', $form_state,
        // $environment);
    }
}
Exemplo n.º 21
0
 public function setUp()
 {
     parent::setUp();
     module_load_include('inc', 'system', 'system.queue');
     $this->name = 'redis-queue-test-' . time();
     $this->queue = new Redis_Queue($this->name);
 }
Exemplo n.º 22
0
 /**
  * Create an overview of webform content.
  */
 public function contentOverview()
 {
     // @todo This needs to be removed and the view webform_webforms used instead.
     $query = db_select('webform', 'w');
     $query->join('node', 'n', 'w.nid = n.nid');
     $query->fields('n');
     $nodes = $query->execute()->fetchAllAssoc('nid');
     module_load_include('inc', 'webform', 'includes/webform.admin');
     $header = array(t('Title'), array('data' => t('View'), 'colspan' => '4'), array('data' => t('Operations'), 'colspan' => '3'));
     $rows = array();
     if (!empty($nodes)) {
         foreach ($nodes as $node) {
             $node = Node::load($node->nid);
             $rows[] = array(\Drupal::l($node->getTitle(), Url::fromRoute('entity.node.canonical', ['node' => $node->id()])), t('Submissions'), t('Analysis'), t('Table'), t('Download'), $node->access('update') ? \Drupal::l(t('Edit'), Url::fromRoute('entity.node.edit_form', ['node' => $node->id()])) : '', t('Components'), t('Clear'));
         }
     }
     if (empty($nodes)) {
         $webform_types = webform_node_types();
         if (empty($webform_types)) {
             $message = t('Webform is currently not enabled on any content types.') . ' ' . t('Visit the <a href="!url">Webform settings</a> page and enable Webform on at least one content type.', array('!url' => Url::fromRoute('webform.settings')->toString()));
         } else {
             $webform_type_list = webform_admin_type_list();
             $message = t('There are currently no webforms on your site. Create a !types piece of content.', array('!types' => $webform_type_list));
         }
         $rows[] = array(array('data' => $message, 'colspan' => 7));
     }
     $table = array('#type' => 'table', '#header' => $header, '#rows' => $rows);
     return $table;
 }
 /**
  * Test node creation by editor.
  *
  * 1. Editor creates Draft node
  * 2. Editor set status from Draft to Final Draft
  * 3. The node appears in the users's overview screen.
  */
 public function testModerateToBeApproved()
 {
     $this->loginAs('editor1');
     $node = $this->drupalCreateNode(array('language' => 'en', 'title' => $this->nodeTitle1, 'type' => 'news', 'workbench_access' => 1007));
     workbench_moderation_moderate($node, 'final_draft');
     $this->loginAs('review_manager1');
     // Set node status To Be Reviewed.
     $options = array('title_field[en][0][value]' => $this->nodeTitle1, 'workbench_moderation_state_new' => 'needs_review');
     $this->drupalPost("node/{$node->nid}/edit", $options, t('Save'));
     entity_get_controller('node')->resetCache(array($node->nid));
     $node = node_load($node->nid);
     $this->assertEquals('needs_review', $node->workbench_moderation['current']->state);
     // Set the reviewer to project_manager1
     $pm1 = user_load_by_name('project_manager1');
     $options = array('project_manager' => $pm1->uid);
     $this->drupalPost("node/{$node->nid}/review", $options, t('Change'));
     $this->drupalGet("node/{$node->nid}/review");
     $this->assertText('project_manager1');
     // Define the list of approvers.
     // Cannot use drupalPost here.
     $ap1 = user_load_by_name('approver1');
     $ap2 = user_load_by_name('approver2 ');
     $form_state = array('node' => $node, 'values' => array('rows' => array($ap1->uid => array('weight' => -10), $ap2->uid => array('weight' => -11))));
     module_load_include('inc', 'osha_workflow', 'osha_workflow.admin');
     drupal_form_submit('osha_workflow_node_approval_form', $form_state, $node);
     $this->drupalGet("node/{$node->nid}/approve");
     $this->assertText($ap1->name);
     $this->assertText($ap2->name);
     $this->loginAs('project_manager1');
     $options = array('workbench_moderation_state_new' => 'to_be_approved');
     $this->drupalPost("node/{$node->nid}/edit", $options, t('Save'));
     entity_get_controller('node')->resetCache(array($node->nid));
     $node = node_load($node->nid);
     $this->assertEquals('to_be_approved', $node->workbench_moderation['current']->state);
 }
Exemplo n.º 24
0
/**
 * Preprocess variables for page.tpl.php
 * default variales for page.tpl.php:
 * $logo, $front_page, $site_name, $site_slogan, $messages
 * $title_prefix, $title_suffix, $tabs, $action_links
 * $feed_icons, $breadcrumb
 */
function water_preprocess_page(&$vars)
{
    if (isset($vars['node'])) {
        // If the node type is "blog_madness" the template suggestion will be "page--blog-madness.tpl.php".
        $vars['theme_hook_suggestions'][] = 'page__' . $vars['node']->type;
        if ($vars['node']->type == 'deprecated_organization') {
            //var_dump($vars['node']);
            //$vars['organization_geolocation'] = array($vars['node']->field_latitude['und']['0']['value'], $vars['node']->field_longitude['und']['0']['value']);
            /*
             * LOAD GMAPS MODULE
             */
            //add html element 'organization-gmap-canvas' in template file that will hold Google map
            //Load gmap3_tools.inc file
            module_load_include('inc', 'gmap3_tools');
            //all gmap3_tools_add_map() function from API file with appropriate map configuratio array
            gmap3_tools_add_map(array('mapId' => 'organization-gmap-canvas', 'mapOptions' => array('centerX' => -34.397, 'centerY' => 150.644, 'zoom' => 12), 'markers' => array(gmap3_tools_create_marker(-1, -1, 'Home', 'Home')), 'geocodeAddress' => $vars['node']->field_city['und']['0']['taxonomy_term']->name, 'gmap3ToolsOptions' => array('defaultMarkersPosition' => GMAP3_TOOLS_DEFAULT_MARKERS_POSITION_CENTER)));
        }
        //create a variable to hold rich title field added to specific content types
        $view = node_view($vars['node']);
        $vars['rich_title'] = render($view['field_rich_title']);
    }
    //var_dump($vars);
    //var_export($vars);
    //var_dump(debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS));
    //    $vars['contact_form'] = drupal_render(drupal_get_form('contact_site_form'));
}
 protected function setUp()
 {
     parent::setUp();
     module_load_include('compare.inc', 'locale');
     $admin_user = $this->drupalCreateUser(array('administer modules', 'administer languages', 'access administration pages', 'translate interface'));
     $this->drupalLogin($admin_user);
     $this->drupalPostForm('admin/config/regional/language/add', array('predefined_langcode' => 'hu'), t('Add language'));
 }
 public function test_osha_workflow_workbench_project_managers_form()
 {
     $_GET['q'] = 'admin/config/workbench/access/managers';
     module_load_include('inc', 'osha_workflow', 'osha_workflow.admin');
     $form = drupal_get_form('osha_workflow_workbench_project_managers_form');
     $this->assertNotNull($form);
     $this->assertArrayHasKey('main-menu', $form['rows']);
 }
Exemplo n.º 27
0
/**
 * Alters the list of available EPUB libraries.
 *
 * During the configuration of the EPUB library to be used, the module needs
 * to discover and display the available libraries. This function should use
 * the internal _print_scan_libs() function which will scan both the module
 * and the libraries directory in search of the unique file pattern that can
 * be used to identify the library location.
 *
 * @param array $epub_tools
 *   An associative array using as key the format 'module|path', and as value
 *   a string describing the discovered library, where:
 *   - module: the machine name of the module that handles this library.
 *   - path: the path where the library is installed, relative to DRUPAL_ROOT.
 *     If the recommended path is used, it begins with sites/all/libraries.
 *   As a recommendation, the value should contain in parantheses the path
 *   where the library was found, to allow the user to distinguish between
 *   multiple install paths of the same library version.
 *
 * @ingroup print_hooks
 */
function hook_print_epub_available_libs_alter(&$epub_tools)
{
    module_load_include('inc', 'print', 'includes/print');
    $tools = _print_scan_libs('foo', '!^foo.php$!');
    foreach ($tools as $tool) {
        $epub_tools['print_epub_foo|' . $tool] = 'foo (' . dirname($tool) . ')';
    }
}
/**
 * Provides possibility to flush pages for external cache storages.
 *
 * @param $urls
 *   List of internal paths and/or absolute URLs that should be flushed.
 *
 *   Example of array (when base url include option is enabled):
 *   array(
 *     'node/1' => 'http://example.com/node/1',
 *     'news' => 'http://example.com/news',
 *   );
 *
 *   Example of array (when base url include option is disabled):
 *   array(
 *     'node/1' => 'node/1',
 *     'news' => 'news',
 *   );
 *
 * @param $wildcards
 *   Array with wildcards implementations for each internal path.
 *   Indicates whether should be executed wildcard cache flush.
 *
 *   Example:
 *   array(
 *     'node/1' => FALSE,
 *     'news' => TRUE,
 *   );
 *
 * @param $object_type
 *  Name of object type ('node', 'comment', 'user', etc).
 *
 * @param $object
 *   Object (node, comment, user, etc) for which expiration is executes.
 *
 * @see expire.api.inc
 */
function hook_expire_cache($urls, $wildcards, $object_type, $object)
{
    module_load_include('inc', 'purge');
    foreach ($urls as $url) {
        $full_path = url($url, array('absolute' => TRUE));
        purge_urls($full_path, $wildcards);
    }
}
Exemplo n.º 29
0
 /**
  * Implements DrupalEntityControllerInterface::__construct().
  *
  * @param $entity_type
  */
 public function __construct($entity_type)
 {
     $this->productCache = array();
     if (!class_exists('Apigee\\ManagementAPI\\APIProduct')) {
         module_load_include('module', 'libraries');
         module_load_include('module', 'devconnect');
         devconnect_init();
     }
 }
Exemplo n.º 30
0
/**
 * Returns available translation servers and server definitions.
 *
 * @return keyed array of available servers.
 *   Example: array('localize.drupal.org' => array(
 *       'name' => 'localize.drupal.org',
 *       'server_url' => 'http://ftp.drupal.org/files/translations/l10n_server.xml',
 *       'update_url' => 'http://ftp.drupal.org/files/translations/%core/%project/%project-%release.%language.po',
 *     ),
 *   );
 */
function hook_l10n_servers()
{
    // This hook is used to specify the default localization server(s).
    // Additionally server data can be specified on a per project basis in the
    // .info file or using the hook_l10n_update_projects_alter().
    module_load_include('inc', 'l10n_update');
    $server = l10n_update_default_server();
    return array($server['name'] => $server);
}