/** * Authenticates the password. * This is the 'authenticate' validator as declared in rules(). */ public function authenticate($attribute, $params) { if (!$this->hasErrors()) { $identity = new UserIdentity($this->username, $this->password); $identity->authenticate(); switch ($identity->errorCode) { case UserIdentity::ERROR_NONE: $duration = $this->rememberMe ? Yii::app()->controller->module->rememberMeTime : 0; Yii::app()->user->login($identity, $duration); break; case UserIdentity::ERROR_EMAIL_INVALID: $this->addError("username", t("Email is incorrect.")); break; case UserIdentity::ERROR_USERNAME_INVALID: $this->addError("username", t("Username is incorrect.")); break; case UserIdentity::ERROR_STATUS_NOTACTIV: $this->addError("status", t("You account is not activated.")); break; case UserIdentity::ERROR_STATUS_BAN: $this->addError("status", t("You account is blocked.")); break; case UserIdentity::ERROR_PASSWORD_INVALID: $this->addError("password", t("Password is incorrect.")); break; } } }
public function __construct() { parent::__construct(); $oCommentModel = new CommentModel(); $sComment = $this->httpRequest->post('comment'); $sCurrentTime = $this->dateTime->get()->dateTime('Y-m-d H:i:s'); $iTimeDelay = (int) DbConfig::getSetting('timeDelaySendComment'); $sTable = $this->httpRequest->get('table'); $iRecipientId = $this->httpRequest->get('recipient', 'int'); $iSenderId = (int) $this->session->get('member_id'); if (!$oCommentModel->idExists($iRecipientId, $sTable)) { \PFBC\Form::setError('form_comment', t('The comment recipient does not exists.')); } elseif (!$oCommentModel->checkWaitSend($iSenderId, $iTimeDelay, $sCurrentTime, $sTable)) { \PFBC\Form::setError('form_comment', Form::waitWriteMsg($iTimeDelay)); } elseif ($oCommentModel->isDuplicateContent($iSenderId, $sComment, $sTable)) { \PFBC\Form::setError('form_comment', Form::duplicateContentMsg()); } else { if (!$oCommentModel->add($sComment, $iRecipientId, $iSenderId, 1, $sCurrentTime, $sTable)) { \PFBC\Form::setError('form_comment', t('Oops! Error when adding comment.')); } else { /* Clean All Data of CommentModel Cache */ (new Framework\Cache\Cache())->start(CommentCoreModel::CACHE_GROUP, null, null)->clear(); HeaderUrl::redirect(Uri::get('comment', 'comment', 'read', $sTable . ',' . $iRecipientId), t('The comment has been sent successfully!')); } } unset($oCommentModel); }
public function prepare_remote_upgrade($remoteMPID = 0) { $tp = new TaskPermission(); if ($tp->canInstallPackages()) { $mri = MarketplaceRemoteItem::getByID($remoteMPID); if (!is_object($mri)) { $this->set('error', array(t('Invalid marketplace item ID.'))); return; } $local = Package::getbyHandle($mri->getHandle()); if (!is_object($local) || $local->isPackageInstalled() == false) { $this->set('error', array(Package::E_PACKAGE_NOT_FOUND)); return; } $r = $mri->downloadUpdate(); if ($r != false) { if (!is_array($r)) { $this->set('error', array($r)); } else { $errors = Package::mapError($r); $this->set('error', $errors); } } else { $this->redirect('/dashboard/extend/update', 'do_update', $mri->getHandle()); } } }
/** * Implemensts hook_breadcrumb(). * * tth@bellcom.dk check if there is a better way to do this... */ function cmstheme_breadcrumb($variables) { $breadcrumb = $variables['breadcrumb']; $nid = arg(1); if (is_numeric($nid)) { $node = node_load($nid); } if (!empty($breadcrumb)) { $output = '<div class="breadcrumb you-are-here">' . t('Du er her: ') . '</div>'; $title = drupal_get_title(); $breadcrumb[0] = l(t('Forside'), '<front>', array('attributes' => array('title' => 'Forside'))); $breadcrumb[] = '<a href="#" title="' . $title . '">' . $title . '</a>'; if ($title == 'Søg') { unset($breadcrumb); $breadcrumb[0] = l(t('Forside'), '<front>', array('attributes' => array('title' => 'Forside'))); $breadcrumb[] = '<a href="#" title="Søgning">Søgning</a>'; } if (isset($node) && is_object($node) && $node->type == 'meeting') { unset($breadcrumb); $breadcrumb[0] = l(t('Forside'), '<front>', array('attributes' => array('title' => 'Forside'))); $breadcrumb[] = l(t('Politik & planer'), 'politik-og-planer', array('attributes' => array('title' => 'Politik og planer'))); $breadcrumb[] = l(t('Søg i dagsordener og referater'), 'dagsorden-og-referat', array('attributes' => array('title' => 'Søg i dagsordner og referater'))); $breadcrumb[] = l(t($title), '#'); } $output .= '<div class="breadcrumb">' . implode('<div class="bread-crumb"> > </div> ', $breadcrumb) . '</div>'; return $output; } }
/** * Test the getViaUri() and getViaScheme() methods and target functions. */ function testUriFunctions() { $config = $this->config('system.file'); $instance = \Drupal::service('stream_wrapper_manager')->getViaUri($this->scheme . '://foo'); $this->assertEqual($this->classname, get_class($instance), 'Got correct class type for dummy URI.'); $instance = \Drupal::service('stream_wrapper_manager')->getViaUri('public://foo'); $this->assertEqual('Drupal\\Core\\StreamWrapper\\PublicStream', get_class($instance), 'Got correct class type for public URI.'); // Test file_uri_target(). $this->assertEqual(file_uri_target('public://foo/bar.txt'), 'foo/bar.txt', 'Got a valid stream target from public://foo/bar.txt.'); $this->assertEqual(file_uri_target('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg=='), 'image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg==', t('Got a valid stream target from a data URI.')); $this->assertFalse(file_uri_target('foo/bar.txt'), 'foo/bar.txt is not a valid stream.'); $this->assertFalse(file_uri_target('public://'), 'public:// has no target.'); $this->assertFalse(file_uri_target('data:'), 'data: has no target.'); // Test file_build_uri() and // Drupal\Core\StreamWrapper\LocalStream::getDirectoryPath(). $this->assertEqual(file_build_uri('foo/bar.txt'), 'public://foo/bar.txt', 'Expected scheme was added.'); $this->assertEqual(\Drupal::service('stream_wrapper_manager')->getViaScheme('public')->getDirectoryPath(), PublicStream::basePath(), 'Expected default directory path was returned.'); $this->assertEqual(\Drupal::service('stream_wrapper_manager')->getViaScheme('temporary')->getDirectoryPath(), $config->get('path.temporary'), 'Expected temporary directory path was returned.'); $config->set('default_scheme', 'private')->save(); $this->assertEqual(file_build_uri('foo/bar.txt'), 'private://foo/bar.txt', 'Got a valid URI from foo/bar.txt.'); // Test file_create_url() // TemporaryStream::getExternalUrl() uses Url::fromRoute(), which needs // route information to work. $this->container->get('router.builder')->rebuild(); $this->assertTrue(strpos(file_create_url('temporary://test.txt'), 'system/temporary?file=test.txt'), 'Temporary external URL correctly built.'); $this->assertTrue(strpos(file_create_url('public://test.txt'), Settings::get('file_public_path') . '/test.txt'), 'Public external URL correctly built.'); $this->assertTrue(strpos(file_create_url('private://test.txt'), 'system/files/test.txt'), 'Private external URL correctly built.'); }
/** * Test example forms provided by fapi_example. */ public function testInputDemoForm() { // Test for a link to the form_example in the Tools menu. $this->drupalGet(''); $this->assertResponse(200, 'The Home page is available.'); $this->assertLinkByHref('examples/fapi_example'); // Test for a link to the simple_form example on the form_example page. $this->drupalGet('examples/fapi_example'); $this->assertLinkByHref('examples/fapi_example/input_demo'); // Verify that anonymous can access the simpletest_examples page. $this->drupalGet('examples/fapi_example/input_demo'); $this->assertResponse(200, 'The Demo of Common Input Elements page is available.'); // Post the form. $edit = ['tests_taken[SAT]' => TRUE, 'color' => '#ff6bf1', 'expiration' => '2015-10-21', 'email' => '*****@*****.**', 'quantity' => '4', 'password' => 'letmein', 'password_confirm[pass1]' => 'letmein', 'password_confirm[pass2]' => 'letmein', 'size' => '76', 'active' => '1', 'search' => 'my search string', 'favorite' => 'blue', 'phone' => '555-555-5555', 'table[1]' => TRUE, 'table[3]' => TRUE, 'text' => 'This is a test of my form.', 'subject' => 'Form test', 'weight' => '3']; $this->drupalPostForm('/examples/fapi_example/input_demo', $edit, t('Submit')); $this->assertText('Value for What standardized tests did you take?: Array ( [SAT] => SAT )'); $this->assertText('Value for Color: #ff6bf1'); $this->assertText('Value for Content expiration: 2015-10-21'); $this->assertText('Value for Email: somebody@example.org'); $this->assertText('Value for Quantity: 4'); $this->assertText('Value for Password: letmein'); $this->assertText('Value for New Password: letmein'); $this->assertText('Value for Size: 76'); $this->assertText('Value for active: 1'); $this->assertText('Value for Search: my search string'); $this->assertText('Value for Favorite color: blue'); $this->assertText('Value for Phone: 555-555-5555'); $this->assertText('Value for Users: Array ( [1] => 1 [3] => 3 )'); $this->assertText('Value for Text: This is a test of my form.'); $this->assertText('Value for Subject: Form test'); $this->assertText('Value for Weight: 3'); }
/** * Test the behavior of a field module after being disabled and re-enabled. */ function testReEnabledField() { // Add a telephone field to the article content type. $field_storage = entity_create('field_storage_config', array('name' => 'field_telephone', 'entity_type' => 'node', 'type' => 'telephone')); $field_storage->save(); entity_create('field_instance_config', array('field_storage' => $field_storage, 'bundle' => 'article', 'label' => 'Telephone Number'))->save(); entity_get_form_display('node', 'article', 'default')->setComponent('field_telephone', array('type' => 'telephone_default', 'settings' => array('placeholder' => '123-456-7890')))->save(); entity_get_display('node', 'article', 'default')->setComponent('field_telephone', array('type' => 'telephone_link', 'weight' => 1))->save(); // Display the article node form and verify the telephone widget is present. $this->drupalGet('node/add/article'); $this->assertFieldByName("field_telephone[0][value]", '', 'Widget found.'); // Submit an article node with a telephone field so data exist for the // field. $edit = array('title[0][value]' => $this->randomName(), 'field_telephone[0][value]' => "123456789"); $this->drupalPostForm(NULL, $edit, t('Save')); $this->assertRaw('<a href="tel:123456789">'); // Test that the module can't be uninstalled from the UI while there is data // for it's fields. $admin_user = $this->drupalCreateUser(array('access administration pages', 'administer modules')); $this->drupalLogin($admin_user); $this->drupalGet('admin/modules'); $this->assertText('Fields type(s) in use'); $field_storage->delete(); $this->drupalGet('admin/modules'); $this->assertText('Fields pending deletion'); $this->cronRun(); $this->assertNoText('Fields type(s) in use'); $this->assertNoText('Fields pending deletion'); }
protected function doDisplay(array $context, array $blocks = array()) { $tags = array(); $filters = array("t" => 14); $functions = array(); try { $this->env->getExtension('sandbox')->checkSecurity(array(), array('t'), array()); } catch (Twig_Sandbox_SecurityError $e) { $e->setTemplateFile($this->getTemplateName()); if ($e instanceof Twig_Sandbox_SecurityNotAllowedTagError && isset($tags[$e->getTagName()])) { $e->setTemplateLine($tags[$e->getTagName()]); } elseif ($e instanceof Twig_Sandbox_SecurityNotAllowedFilterError && isset($filters[$e->getFilterName()])) { $e->setTemplateLine($filters[$e->getFilterName()]); } elseif ($e instanceof Twig_Sandbox_SecurityNotAllowedFunctionError && isset($functions[$e->getFunctionName()])) { $e->setTemplateLine($functions[$e->getFunctionName()]); } throw $e; } // line 13 echo "<a href=\""; echo $this->env->getExtension('sandbox')->ensureToStringAllowed($this->env->getExtension('drupal_core')->escapeFilter($this->env, isset($context["url"]) ? $context["url"] : null, "html", null, true)); echo "\""; echo $this->env->getExtension('sandbox')->ensureToStringAllowed($this->env->getExtension('drupal_core')->escapeFilter($this->env, $this->getAttribute(isset($context["attributes"]) ? $context["attributes"] : null, "addClass", array(0 => "feed-icon"), "method"), "html", null, true)); echo ">\n "; // line 14 echo $this->env->getExtension('sandbox')->ensureToStringAllowed($this->env->getExtension('drupal_core')->renderVar(t("Subscribe to @title", array("@title" => isset($context["title"]) ? $context["title"] : null)))); echo "\n</a>\n"; }
/** * Implements hook_form_node_form_alter(). * * When the node form is presented, add additional options * for Shareaholic Apps * * @param Array $form - Nested array of form elements * @param Array $form_state - keyed array containing form state * @param $form_id - String representing the name of the form itself */ function shareaholic_form_node_form_alter(&$form, &$form_state, $form_id) { $node = $form['#node']; $form['shareaholic_options'] = array('#type' => 'fieldset', '#access' => TRUE, '#title' => 'Shareaholic Options', '#collapsible' => TRUE, '#collapsed' => TRUE, '#group' => 'additional_settings', '#weight' => 100); // I have to namespace it this way because Drupal can't add // the shareholic_options name to it // when you process the form on submit!!! $form['shareaholic_options']['shareaholic_hide_share_buttons'] = array('#type' => 'checkbox', '#title' => 'Hide Share Buttons'); $form['shareaholic_options']['shareaholic_hide_recommendations'] = array('#type' => 'checkbox', '#title' => 'Hide Related Content'); $form['shareaholic_options']['shareaholic_exclude_from_recommendations'] = array('#type' => 'checkbox', '#title' => 'Exclude from Related Content'); $form['shareaholic_options']['shareaholic_exclude_og_tags'] = array('#type' => 'checkbox', '#title' => 'Do not include Open Graph tags'); if (!db_table_exists('shareaholic_content_settings')) { $form['shareaholic_options']['shareaholic_message'] = array('#type' => 'markup', '#markup' => '<p style="color:#FF0000;">' . t('Action required: you have some pending updates required by Shareaholic. Please go to update.php for more information.') . '</p>'); } if ($node->shareaholic_options['shareaholic_exclude_from_recommendations']) { $form['shareaholic_options']['shareaholic_exclude_from_recommendations']['#attributes'] = array('checked' => 'checked'); } if ($node->shareaholic_options['shareaholic_hide_recommendations']) { $form['shareaholic_options']['shareaholic_hide_recommendations']['#attributes'] = array('checked' => 'checked'); } if ($node->shareaholic_options['shareaholic_hide_share_buttons']) { $form['shareaholic_options']['shareaholic_hide_share_buttons']['#attributes'] = array('checked' => 'checked'); } if ($node->shareaholic_options['shareaholic_exclude_og_tags']) { $form['shareaholic_options']['shareaholic_exclude_og_tags']['#attributes'] = array('checked' => 'checked'); } }
/** * {@inheritdoc} */ public static function propertyDefinitions(FieldStorageDefinitionInterface $field_definition) { $properties['value'] = DataDefinition::create('string')->setLabel(t('Text'))->setRequired(TRUE); $properties['format'] = DataDefinition::create('filter_format')->setLabel(t('Text format')); $properties['processed'] = DataDefinition::create('string')->setLabel(t('Processed text'))->setDescription(t('The text with the text format applied.'))->setComputed(TRUE)->setClass('\\Drupal\\text\\TextProcessed')->setSetting('text source', 'value'); return $properties; }
/** * Tests that overrides do not affect forms or listing screens. */ public function testFormsWithOverrides() { $this->drupalLogin($this->drupalCreateUser(['administer site configuration'])); $original_label = 'Default'; $overridden_label = 'Overridden label'; $edited_label = 'Edited label'; $config_test_storage = $this->container->get('entity.manager')->getStorage('config_test'); // Set up an override. $settings['config']['config_test.dynamic.dotted.default']['label'] = (object) array('value' => $overridden_label, 'required' => TRUE); $this->writeSettings($settings); // Test that the overridden label is loaded with the entity. $this->assertEqual($config_test_storage->load('dotted.default')->label(), $overridden_label); // Test that the original label on the listing page is intact. $this->drupalGet('admin/structure/config_test'); $this->assertText($original_label); $this->assertNoText($overridden_label); // Test that the original label on the editing page is intact. $this->drupalGet('admin/structure/config_test/manage/dotted.default'); $elements = $this->xpath('//input[@name="label"]'); $this->assertIdentical((string) $elements[0]['value'], $original_label); $this->assertNoText($overridden_label); // Change to a new label and test that the listing now has the edited label. $edit = array('label' => $edited_label); $this->drupalPostForm(NULL, $edit, t('Save')); $this->drupalGet('admin/structure/config_test'); $this->assertNoText($overridden_label); $this->assertText($edited_label); // Test that the editing page now has the edited label. $this->drupalGet('admin/structure/config_test/manage/dotted.default'); $elements = $this->xpath('//input[@name="label"]'); $this->assertIdentical((string) $elements[0]['value'], $edited_label); // Test that the overridden label is still loaded with the entity. $this->assertEqual($config_test_storage->load('dotted.default')->label(), $overridden_label); }
function get() { require_once 'include/acl_selectors.php'; if (!local_channel()) { notice(t('Permission denied.') . EOL); return; } if (\App::$argc != 2) { return; } $contact_id = intval(\App::$argv[1]); $r = q("SELECT * FROM `contact` WHERE `id` = %d AND `uid` = %d LIMIT 1", intval($contact_id), intval(local_channel())); if (!count($r)) { notice(t('Contact not found.') . EOL); return; } $contact = $r[0]; $o = '<h3>' . t('Suggest Friends') . '</h3>'; $o .= '<div id="fsuggest-desc" >' . sprintf(t('Suggest a friend for %s'), $contact['name']) . '</div>'; $o .= '<form id="fsuggest-form" action="fsuggest/' . $contact_id . '" method="post" >'; // FIXME contact_selector deprecated, removed // $o .= contact_selector('suggest','suggest-select', false, // array('size' => 4, 'exclude' => $contact_id, 'networks' => 'DFRN_ONLY', 'single' => true)); $o .= '<div id="fsuggest-submit-wrapper"><input id="fsuggest-submit" type="submit" name="submit" value="' . t('Submit') . '" /></div>'; $o .= '</form>'; return $o; }
public function __construct() { parent::__construct(); $oUser = new UserCore(); $oUserModel = new UserCoreModel(); $oExistsModel = new ExistsCoreModel(); $oValidate = new Validate(); $aUserData = json_decode($this->file->getFile('http://api.randomuser.me/?results=' . $this->httpRequest->post('num')), true); foreach ($aUserData['results'] as $aUser) { $aUser = $aUser['user']; $sEmail = trim($aUser['email']); $sUsername = trim($aUser['username']); if ($oValidate->email($sEmail) && !$oExistsModel->email($sEmail) && $oValidate->username($sUsername)) { $aData['username'] = $sUsername; $aData['email'] = $sEmail; $aData['first_name'] = $aUser['name']['first']; $aData['last_name'] = $aUser['name']['last']; $aData['password'] = $aUser['password']; $aData['sex'] = $aUser['gender']; $aData['match_sex'] = array($oUser->getMatchSex($aData['sex'])); $aData['country'] = 'US'; $aData['city'] = $aUser['location']['city']; $aData['state'] = $aUser['location']['state']; $aData['zip_code'] = $aUser['location']['zip']; $aData['birth_date'] = $this->dateTime->get($aUser['dob'])->date('Y-m-d'); $aData['avatar'] = $aUser['picture']['large']; $aData['ip'] = Ip::get(); $aData['profile_id'] = $oUserModel->add(escape($aData, true)); $this->_addAvatar($aData, $oUser); } } unset($oUser, $oUserModel, $oExistsModel, $oValidate, $aUser, $aData, $aUserData); \PFBC\Form::setSuccess('form_add_fake_profiles', t('Users has been successfully added.')); }
/** * @return string An error message suitable for inclusion in the task log */ static function check_index() { list($remaining) = search::stats(); if ($remaining) { site_status::warning(t('Your search index needs to be updated. <a href="%url" class="g-dialog-link">Fix this now</a>', array("url" => html::mark_clean(url::site("admin/maintenance/start/search_task::update_index?csrf=__CSRF__")))), "search_index_out_of_date"); } }
/** * Test that required alt/title fields gets validated right. */ function testRequiredAttributes() { $field_name = strtolower($this->randomMachineName()); $field_settings = array('alt_field' => 1, 'alt_field_required' => 1, 'title_field' => 1, 'title_field_required' => 1, 'required' => 1); $instance = $this->createImageField($field_name, 'article', array(), $field_settings); $images = $this->drupalGetTestFiles('image'); // Let's just use the first image. $image = $images[0]; $this->uploadNodeImage($image, $field_name, 'article'); // Look for form-required for the alt text. $elements = $this->xpath('//label[@for="edit-' . $field_name . '-0-alt" and @class="js-form-required form-required"]/following-sibling::input[@id="edit-' . $field_name . '-0-alt"]'); $this->assertTrue(isset($elements[0]), 'Required marker is shown for the required alt text.'); $elements = $this->xpath('//label[@for="edit-' . $field_name . '-0-title" and @class="js-form-required form-required"]/following-sibling::input[@id="edit-' . $field_name . '-0-title"]'); $this->assertTrue(isset($elements[0]), 'Required marker is shown for the required title text.'); $this->assertText(t('Alternative text field is required.')); $this->assertText(t('Title field is required.')); $instance->setSetting('alt_field_required', 0); $instance->setSetting('title_field_required', 0); $instance->save(); $edit = array('title[0][value]' => $this->randomMachineName()); $this->drupalPostForm('node/add/article', $edit, t('Save and publish')); $this->assertNoText(t('Alternative text field is required.')); $this->assertNoText(t('Title field is required.')); $instance->setSetting('required', 0); $instance->setSetting('alt_field_required', 1); $instance->setSetting('title_field_required', 1); $instance->save(); $edit = array('title[0][value]' => $this->randomMachineName()); $this->drupalPostForm('node/add/article', $edit, t('Save and publish')); $this->assertNoText(t('Alternative text field is required.')); $this->assertNoText(t('Title field is required.')); }
public function getSummary() { $pageTitle = '<h2>' . mt('monitoring', 'Monitoring Backend', 'setup.page.title') . '</h2>'; $backendDescription = '<p>' . sprintf(mt('monitoring', 'Icinga Web 2 will retrieve information from your monitoring environment' . ' using a backend called "%s" and the specified resource below:'), $this->data['backendConfig']['name']) . '</p>'; if ($this->data['resourceConfig']['type'] === 'db') { $resourceTitle = '<h3>' . mt('monitoring', 'Database Resource') . '</h3>'; $resourceHtml = '' . '<table>' . '<tbody>' . '<tr>' . '<td><strong>' . t('Resource Name') . '</strong></td>' . '<td>' . $this->data['resourceConfig']['name'] . '</td>' . '</tr>' . '<tr>' . '<td><strong>' . t('Database Type') . '</strong></td>' . '<td>' . $this->data['resourceConfig']['db'] . '</td>' . '</tr>' . '<tr>' . '<td><strong>' . t('Host') . '</strong></td>' . '<td>' . $this->data['resourceConfig']['host'] . '</td>' . '</tr>' . '<tr>' . '<td><strong>' . t('Port') . '</strong></td>' . '<td>' . $this->data['resourceConfig']['port'] . '</td>' . '</tr>' . '<tr>' . '<td><strong>' . t('Database Name') . '</strong></td>' . '<td>' . $this->data['resourceConfig']['dbname'] . '</td>' . '</tr>' . '<tr>' . '<td><strong>' . t('Username') . '</strong></td>' . '<td>' . $this->data['resourceConfig']['username'] . '</td>' . '</tr>' . '<tr>' . '<td><strong>' . t('Password') . '</strong></td>' . '<td>' . str_repeat('*', strlen($this->data['resourceConfig']['password'])) . '</td>' . '</tr>'; if (isset($this->data['resourceConfig']['ssl_key']) && $this->data['resourceConfig']['ssl_key']) { $resourceHtml .= '' . '<tr>' . '<td><strong>' . t('SSL Key') . '</strong></td>' . '<td>' . $this->data['resourceConfig']['ssl_key'] . '</td>' . '</tr>'; } if (isset($this->data['resourceConfig']['ssl_cert']) && $this->data['resourceConfig']['ssl_cert']) { $resourceHtml .= '' . '<tr>' . '<td><strong>' . t('SSL Cert') . '</strong></td>' . '<td>' . $this->data['resourceConfig']['ssl_cert'] . '</td>' . '</tr>'; } if (isset($this->data['resourceConfig']['ssl_ca']) && $this->data['resourceConfig']['ssl_ca']) { $resourceHtml .= '' . '<tr>' . '<td><strong>' . t('CA') . '</strong></td>' . '<td>' . $this->data['resourceConfig']['ssl_ca'] . '</td>' . '</tr>'; } if (isset($this->data['resourceConfig']['ssl_capath']) && $this->data['resourceConfig']['ssl_capath']) { $resourceHtml .= '' . '<tr>' . '<td><strong>' . t('CA Path') . '</strong></td>' . '<td>' . $this->data['resourceConfig']['ssl_capath'] . '</td>' . '</tr>'; } if (isset($this->data['resourceConfig']['ssl_cipher']) && $this->data['resourceConfig']['ssl_cipher']) { $resourceHtml .= '' . '<tr>' . '<td><strong>' . t('Cipher') . '</strong></td>' . '<td>' . $this->data['resourceConfig']['ssl_cipher'] . '</td>' . '</tr>'; } $resourceHtml .= '' . '</tbody>' . '</table>'; } else { // $this->data['resourceConfig']['type'] === 'livestatus' $resourceTitle = '<h3>' . mt('monitoring', 'Livestatus Resource') . '</h3>'; $resourceHtml = '' . '<table>' . '<tbody>' . '<tr>' . '<td><strong>' . t('Resource Name') . '</strong></td>' . '<td>' . $this->data['resourceConfig']['name'] . '</td>' . '</tr>' . '<tr>' . '<td><strong>' . t('Socket') . '</strong></td>' . '<td>' . $this->data['resourceConfig']['socket'] . '</td>' . '</tr>' . '</tbody>' . '</table>'; } return $pageTitle . '<div class="topic">' . $backendDescription . $resourceTitle . $resourceHtml . '</div>'; }
/** * Theme a "you can't post comments" notice. * * @param $node * The comment node. * @ingroup themeable */ function city_magazine_comment_post_forbidden($node) { global $user; static $authenticated_post_comments; if (!$user->uid) { if (!isset($authenticated_post_comments)) { // We only output any link if we are certain, that users get permission // to post comments by logging in. We also locally cache this information. $authenticated_post_comments = array_key_exists(DRUPAL_AUTHENTICATED_RID, user_roles(TRUE, 'post comments') + user_roles(TRUE, 'post comments without approval')); } if ($authenticated_post_comments) { // We cannot use drupal_get_destination() because these links // sometimes appear on /node and taxonomy listing pages. if (variable_get('comment_form_location_' . $node->type, COMMENT_FORM_SEPARATE_PAGE) == COMMENT_FORM_SEPARATE_PAGE) { $destination = 'destination=' . rawurlencode("comment/reply/{$node->nid}#comment-form"); } else { $destination = 'destination=' . rawurlencode("node/{$node->nid}#comment-form"); } if (variable_get('user_register', 1)) { // Users can register themselves. // original //return t('<a href="@login"><span>Login</span></a> <span class="regulat-text">or</span> <a href="@register"><span>register</span></a> <span class="regulat-text">to post comments</span>', array('@login' => url('user/login', array('query' => $destination)), '@register' => url('user/register', array('query' => $destination)))); // no register return t('<a href="@login"><span>Login</span></a> <span class="regulat-text">to post comments</span>', array('@login' => url('user/login', array('query' => $destination)))); } else { // Only admins can add new users, no public registration. return t('<a href="@login"><span>Login</span></a> to post comments', array('@login' => url('user/login', array('query' => $destination)))); } } } }
/** * Implementation of hook_fivestar_target_info(). * * @param $field * The field structure for the operation. * @param $instance * The instance structures for the $field. * * @return array * An array of key => value pairs. Each key must be unique the identifier for this * target selection. The Value is an array of key => value pairs for a title and a * callback function. The title value is used for displaying in the #options array * of the target selection option. The callback function is used when trying to decided * which target the current vote should be cast against. * * @see fivestar_get_targets() * @see fivestar_fivestar_target_info() */ function hook_fivestar_target_info($field, $instance) { $entity_type = $instance['entity_type']; $bundle = $instance['bundle']; $options = array('example_node_author' => array('title' => t('Node Author'), 'callback' => '_example_target_node_author')); return $options; }
private function _get_admin_form() { $form = new Forge("admin/hide/save", "", "post", array("id" => "g-hide-admin-form")); $form->dropdown("access_permissions")->label(t("Who can see hidden items?"))->options(hide::get_groups_as_dropdown_options())->selected(module::get_var("hide", "access_permissions")); $form->submit("save")->value(t("Save")); return $form; }
/** * Adds a language. * * @param string $langcode * The language code of the language to add. */ protected function addLanguage($langcode) { $edit = array('predefined_langcode' => $langcode); $this->drupalPostForm('admin/config/regional/language/add', $edit, t('Add language')); $this->container->get('language_manager')->reset(); $this->assertTrue(\Drupal::languageManager()->getLanguage($langcode), SafeMarkup::format('Language %langcode added.', array('%langcode' => $langcode))); }
/** * {@inheritdoc} */ public function getConstraints() { $constraint_manager = \Drupal::typedDataManager()->getValidationConstraintManager(); $constraints = parent::getConstraints(); $constraints[] = $constraint_manager->create('ComplexData', array('value' => array('TestField' => array('value' => -1, 'message' => t('%name does not accept the value @value.', array('%name' => $this->getFieldDefinition()->getLabel(), '@value' => -1)))))); return $constraints; }
/** * Assert translations JS is added before drupal.js, because it depends on it. */ public function testLocaleTranslationJsDependencies() { // User to add and remove language. $admin_user = $this->drupalCreateUser(array('administer languages', 'access administration pages', 'translate interface')); // Add custom language. $this->drupalLogin($admin_user); // Code for the language. $langcode = 'es'; // The English name for the language. $name = $this->randomMachineName(16); // The domain prefix. $prefix = $langcode; $edit = array('predefined_langcode' => 'custom', 'langcode' => $langcode, 'label' => $name, 'direction' => LanguageInterface::DIRECTION_LTR); $this->drupalPostForm('admin/config/regional/language/add', $edit, t('Add custom language')); // Set path prefix. $edit = array("prefix[{$langcode}]" => $prefix); $this->drupalPostForm('admin/config/regional/language/detection/url', $edit, t('Save configuration')); // This forces locale.admin.js string sources to be imported, which contains // the next translation. $this->drupalGet($prefix . '/admin/config/regional/translate'); // Translate a string in locale.admin.js to our new language. $strings = \Drupal::service('locale.storage')->getStrings(array('source' => 'Show description', 'type' => 'javascript', 'name' => 'core/modules/locale/locale.admin.js')); $string = $strings[0]; $this->drupalPostForm(NULL, ['string' => 'Show description'], t('Filter')); $edit = ['strings[' . $string->lid . '][translations][0]' => $this->randomString(16)]; $this->drupalPostForm(NULL, $edit, t('Save translations')); // Calculate the filename of the JS including the translations. $js_translation_files = \Drupal::state()->get('locale.translation.javascript'); $js_filename = $prefix . '_' . $js_translation_files[$prefix] . '.js'; // Assert translations JS is included before drupal.js. $this->assertTrue(strpos($this->content, $js_filename) < strpos($this->content, 'core/misc/drupal.js'), 'Translations are included before Drupal.t.'); }
/** * Alter content in Administration menu bar before it is rendered. * * @param $content * A structured array suitable for drupal_render(), at the very least * containing the keys 'menu' and 'links'. Most implementations likely want * to alter or add to 'links'. * * $content['menu'] contains the HTML representation of the 'admin_menu' menu * tree. * @see admin_menu_menu_alter() * * $content['links'] contains additional top-level links in the Administration * menu, such as the icon menu or the logout link. You can add more items here * or play with the #weight attribute to customize them. * @see theme_admin_menu_links() * @see admin_menu_links_icon() * @see admin_menu_links_user() */ function hook_admin_menu_output_alter(&$content) { // Add new top-level item. $content['menu']['myitem'] = array('#title' => t('My item'), '#attributes' => array('class' => array('mymodule-myitem')), '#href' => 'mymodule/path', '#options' => array('query' => drupal_get_destination()), '#weight' => 50); // Add link to manually run cron. $content['menu']['myitem']['cron'] = array('#title' => t('Run cron'), '#access' => user_access('administer site configuration'), '#href' => 'admin/reports/status/run-cron'); }
/** * Implements EntityReferenceHandler::settingsForm(). */ public static function settingsForm($field, $instance) { $view_settings = empty($field['settings']['handler_settings']['view']) ? '' : $field['settings']['handler_settings']['view']; $displays = views_get_applicable_views('entityreference display'); // Filter views that list the entity type we want, and group the separate // displays by view. $entity_info = entity_get_info($field['settings']['target_type']); $options = array(); foreach ($displays as $data) { list($view, $display_id) = $data; if ($view->base_table == $entity_info['base table']) { $options[$view->name . ':' . $display_id] = $view->name . ' - ' . $view->display[$display_id]->display_title; } } // The value of the 'view_and_display' select below will need to be split // into 'view_name' and 'view_display' in the final submitted values, so // we massage the data at validate time on the wrapping element (not // ideal). $form['view']['#element_validate'] = array('entityreference_view_settings_validate'); if ($options) { $default = !empty($view_settings['view_name']) ? $view_settings['view_name'] . ':' . $view_settings['display_name'] : NULL; $form['view']['view_and_display'] = array('#type' => 'select', '#title' => t('View used to select the entities'), '#required' => TRUE, '#options' => $options, '#default_value' => $default, '#description' => '<p>' . t('Choose the view and display that select the entities that can be referenced.<br />Only views with a display of type "Entity Reference" are eligible.') . '</p>'); $default = !empty($view_settings['args']) ? implode(', ', $view_settings['args']) : ''; $form['view']['args'] = array('#type' => 'textfield', '#title' => t('View arguments'), '#default_value' => $default, '#required' => FALSE, '#description' => t('Provide a comma separated list of arguments to pass to the view.')); } else { $form['view']['no_view_help'] = array('#markup' => '<p>' . t('No eligible views were found. <a href="@create">Create a view</a> with an <em>Entity Reference</em> display, or add such a display to an <a href="@existing">existing view</a>.', array('@create' => url('admin/structure/views/add'), '@existing' => url('admin/structure/views'))) . '</p>'); } return $form; }
/** * Tests that the correct number of pager links are found for both keywords and phrases. */ function testExactQuery() { // Login with sufficient privileges. $this->drupalLogin($this->drupalCreateUser(array('create page content', 'search content'))); $settings = array('type' => 'page', 'title' => 'Simple Node'); // Create nodes with exact phrase. for ($i = 0; $i <= 17; $i++) { $settings['body'] = array(array('value' => 'love pizza')); $this->drupalCreateNode($settings); } // Create nodes containing keywords. for ($i = 0; $i <= 17; $i++) { $settings['body'] = array(array('value' => 'love cheesy pizza')); $this->drupalCreateNode($settings); } // Update the search index. $this->container->get('plugin.manager.search')->createInstance('node_search')->updateIndex(); search_update_totals(); // Refresh variables after the treatment. $this->refreshVariables(); // Test that the correct number of pager links are found for keyword search. $edit = array('keys' => 'love pizza'); $this->drupalPostForm('search/node', $edit, t('Search')); $this->assertLinkByHref('page=1', 0, '2nd page link is found for keyword search.'); $this->assertLinkByHref('page=2', 0, '3rd page link is found for keyword search.'); $this->assertLinkByHref('page=3', 0, '4th page link is found for keyword search.'); $this->assertNoLinkByHref('page=4', '5th page link is not found for keyword search.'); // Test that the correct number of pager links are found for exact phrase search. $edit = array('keys' => '"love pizza"'); $this->drupalPostForm('search/node', $edit, t('Search')); $this->assertLinkByHref('page=1', 0, '2nd page link is found for exact phrase search.'); $this->assertNoLinkByHref('page=2', '3rd page link is not found for exact phrase search.'); }
/** * Configure Skinr for this module. * * This hook should be placed in MODULENAME.skinr.inc and it will be auto-loaded. * This must either be in the same directory as the .module file or in a subdirectory * named 'includes'. * * The configuration info is keyed by the MODULENAME. In the case of $data['block'] * 'block' is the name of the module. * * There are two section to the configuration array: * - When you specify a "form", Skinr will insert its skins selector into the form * with the specified form_id. Example: $data[MODULENAME]['form'][FORM_ID] = ... * You can specify multiple forms that Skinr should add its skins selector to. A * good example where this would be needed is blocks where you have a different * form_id for adding a new block than when editing an existing block. * - When you specify "preprocess", Skinr will create a $vars['skinr'] variable * containing the appropriate skin classes for the specified preprocess hook. * Example: $data[MODULENAME]['preprocess'][PREPROCESS_HOOK] = ... * * Form options: * - "index_handler" is required. It specifies a function that returns an index where * Skinr can find the values in its data structure. * - "access_handler" specifies a function that returns TRUE if you wish to grant access * to skinr, or FALSE if not. * - "data_handler" specifies a function that returns the data used to populate the form. * This is useful in cases where a module caches data (like panels and views) and has * an option to cancel changes. * - "submit_handler" specifies a function that process the form data and saves it. * - "preprocess_hook" is required. Each skin states which preprocess hooks it will * work for. This parameter will limit the available skins by the specified * preprocess hook. * - "title" overrides the default title on the Skinr fieldset. * - "description" overrides the default description that provides additional * information to the user about this Skinr selector. * - "weight" overrides the order where Skinrs selector appears on the form. * - "collapsed" sets whether the fieldset appears collapsed or not. Defaults to TRUE. * - "selector_weight" overrides the weight of the selector field inside the fieldset. * This is useful, for instance, if you have multiple modules add selectors to the * same form. * - "selector_title" overrides the title of the selector field inside the fieldset. * * Preprocess options: * - "indexhandler" is required. It specifies a function that returns an index where * Skinr can find the values in its data structure. */ function hook_skinr_data() { $data['example']['form']['block_admin_configure'] = array('index_handler' => 'example_skinr_index_handler', 'preprocess_hook' => 'block', 'title' => t('Skinr settings'), 'description' => t('Here you can manage which Skinr styles, if any, you want to apply.'), 'weight' => 1, 'collapsed' => TRUE, 'selector_weight' => 0, 'selector_title' => t('Choose Skinr Style(s)')); $data['example']['form']['block_add_block_form'] = array('index_handler' => 'example_skinr_index_handler', 'title' => t('Skinr settings'), 'description' => t('Here you can manage which Skinr styles, if any, you want to apply to this block.'), 'weight' => -10, 'collapsed' => FALSE); $data['example']['preprocess']['block'] = array('index_handler' => 'block_skinr_preprocess_handler_block'); return $data; }
public function submit($arLayoutID) { if ($this->validateAction()) { $arLayout = AreaLayout::getByID($arLayoutID); if (!is_object($arLayout)) { throw new Exception(t('Invalid layout object.')); } if ($_POST['arLayoutPresetID'] == '-1') { UserPreset::add($arLayout, $_POST['arLayoutPresetName']); } else { $existingPreset = UserPreset::getByID($_POST['arLayoutPresetID']); if (is_object($existingPreset)) { $existingPreset->updateName($_POST['arLayoutPresetName']); $existingPreset->updateAreaLayoutObject($arLayout); } } $pr = new EditResponse(); if ($existingPreset) { $pr->setMessage(t('Area layout preset updated successfully.')); } else { $pr->setMessage(t('Area layout preset saved successfully.')); } $pr->outputJSON(); } }
/** * Implementation of THEMEHOOK_settings() function. * * @param $saved_settings * An array of saved settings for this theme. * @return * A form array. */ function cti_flex_settings($saved_settings) { // Get the default values from the .info file. $defaults = zen_theme_get_default_settings('cti_flex'); // Merge the saved variables and their default values. $settings = array_merge($defaults, $saved_settings); /* * Create the form using Forms API: http://api.drupal.org/api/6 */ $form = array(); $form['cti_flex_fixed'] = array('#type' => 'checkbox', '#title' => t('Use fixed width for theme'), '#default_value' => $settings['cti_flex_fixed'], '#description' => t('The theme will be centered and fixed at 960 pixels wide. If you do not select this, the layout will be fluid, full width.')); $form['cti_flex_design'] = array('#type' => 'radios', '#title' => t('Design'), '#default_value' => $settings['cti_flex_design'], '#options' => array('0' => t('Teal and Orange'), '1' => t('Blue and Green'), '2' => t('Red and Gray'), '4' => t('None (plain gray) - Select this option if using the color picker tool below')), '#description' => t('Select the specific site design you would like to use. Each design has its own style sheet in the "colors" directory of the theme.')); $form['cti_flex_font_family'] = array('#type' => 'radios', '#title' => t('Font Family'), '#default_value' => $settings['cti_flex_font_family'], '#options' => array('0' => t('None - set manually in stylesheet'), '1' => t('Arial, Helvetica, Bitstream Vera Sans, sans-serif'), '2' => t('Lucida Sans, Verdana, Arial, sans-serif'), '3' => t('Times, Times New Roman, Georgia, Bitstream Vera Serif, serif'), '4' => t('Georgia, Times New Roman, Bitstream Vera Serif, serif'), '5' => t('Verdana, Tahoma, Arial, Helvetica, Bitstream Vera Sans, sans-serif'), '6' => t('Tahoma, Verdana, Arial, Helvetica, Bitstream Vera Sans, sans-serif')), '#description' => t('Select the font family to be used on the site.')); $form['cti_flex_color1'] = array('#type' => (module_exists('colorpicker') ? 'colorpicker_' : '') . 'textfield', '#title' => t('Select color for body background (outside of main content area)'), '#default_value' => $settings['cti_flex_color1'], '#description' => t('Click on the eyedropper icon to use color picker. Or enter an HTML color code.'), '#prefix' => '<fieldset class="collapsible"><legend>Custom color settings</legend><br />These values will override any colors in your style sheets. Leave blank to use defaults.<br /><b>Important:</b> You must have the <a href="http://drupal.org/project/colorpicker" target="_blank">Color Picker</a> module installed to use the color picker widget.<div style="margin: 20px 0 0 20px;"><b>BACKGROUND COLORS</b>'); $form['cti_flex_color2'] = array('#type' => (module_exists('colorpicker') ? 'colorpicker_' : '') . 'textfield', '#title' => t('Select color for header and footer backgrounds'), '#default_value' => $settings['cti_flex_color2'], '#description' => t('Click on the eyedropper icon to use color picker. Or enter an HTML color code.')); $form['cti_flex_color3'] = array('#type' => (module_exists('colorpicker') ? 'colorpicker_' : '') . 'textfield', '#title' => t('Select color for main navigation bar and block header backgrounds'), '#default_value' => $settings['cti_flex_color3'], '#description' => t('Click on the eyedropper icon to use color picker. Or enter an HTML color code.')); $form['cti_flex_color4'] = array('#type' => (module_exists('colorpicker') ? 'colorpicker_' : '') . 'textfield', '#title' => t('Select color for block content background'), '#default_value' => $settings['cti_flex_color4'], '#description' => t('Click on the eyedropper icon to use color picker. Or enter an HTML color code.')); $form['cti_flex_color5'] = array('#type' => (module_exists('colorpicker') ? 'colorpicker_' : '') . 'textfield', '#title' => t('Select color for links'), '#default_value' => $settings['cti_flex_color5'], '#description' => t('Click on the eyedropper icon to use color picker. Or enter an HTML color code.'), '#prefix' => t('<b>TEXT COLORS</b>')); $form['cti_flex_color6'] = array('#type' => (module_exists('colorpicker') ? 'colorpicker_' : '') . 'textfield', '#title' => t('Select color for site name, site slogan and footer text'), '#default_value' => $settings['cti_flex_color6'], '#description' => t('Click on the eyedropper icon to use color picker. Or enter an HTML color code.')); $form['cti_flex_color7'] = array('#type' => (module_exists('colorpicker') ? 'colorpicker_' : '') . 'textfield', '#title' => t('Select color for primary menu links and block headers'), '#default_value' => $settings['cti_flex_color7'], '#description' => t('Click on the eyedropper icon to use color picker. Or enter an HTML color code.')); $form['cti_flex_color8'] = array('#type' => (module_exists('colorpicker') ? 'colorpicker_' : '') . 'textfield', '#title' => t('Select color for secondary menu links'), '#default_value' => $settings['cti_flex_color8'], '#description' => t('Click on the eyedropper icon to use color picker. Or enter an HTML color code.'), '#suffix' => '</div></fieldset>'); // Add the base theme's settings. $form += zen_settings($saved_settings, $defaults); // Remove some of the base theme's settings. unset($form['themedev']['zen_layout']); // We don't need to select the base stylesheet. // Return the form return $form; }
protected function showGeneralForm() { $model = new SettingGeneralForm(); settings()->deleteCache(); //Set Value for the Settings $model->site_name = Yii::app()->settings->get('general', 'site_name'); $model->site_title = Yii::app()->settings->get('general', 'site_title'); $model->site_description = Yii::app()->settings->get('general', 'site_description'); $model->slogan = Yii::app()->settings->get('general', 'slogan'); $model->homepage = Yii::app()->settings->get('general', 'homepage'); // if it is ajax validation request if (isset($_POST['ajax']) && $_POST['ajax'] === 'settings-form') { echo CActiveForm::validate($model); Yii::app()->end(); } // collect user input data if (isset($_POST['SettingGeneralForm'])) { $model->attributes = $_POST['SettingGeneralForm']; if ($model->validate()) { settings()->deleteCache(); foreach ($model->attributes as $key => $value) { Yii::app()->settings->set('general', $key, $value); } user()->setFlash('success', t('General Settings Updated Successfully!')); } } $this->render('cmswidgets.views.settings.settings_general_widget', array('model' => $model)); }
/** * 附件上传 * @return array 上传的附件的信息 */ public function save() { $data['attach_type'] = t($_REQUEST['attach_type']); $data['upload_type'] = $_REQUEST['upload_type'] ? t($_REQUEST['upload_type']) : 'file'; $thumb = intval($_REQUEST['thumb']); $width = intval($_REQUEST['width']); $height = intval($_REQUEST['height']); $cut = intval($_REQUEST['cut']); //Addons::hook('widget_upload_before_save', &$data); $option['attach_type'] = $data['attach_type']; $info = model('Attach')->upload($data, $option); //Addons::hook('widget_upload_after_save', &$info); if ($info['status']) { $data = $info['info'][0]; if ($thumb == 1) { $data['src'] = getImageUrl($data['save_path'] . $data['save_name'], $width, $height, $cut); } else { $data['src'] = $data['save_path'] . $data['save_name']; } $data['extension'] = strtolower($data['extension']); $return = array('status' => 1, 'data' => $data); } else { $return = array('status' => 0, 'data' => $info['info']); } echo json_encode($return); exit; }