/** * Add custom PHPTemplate variable into the page template */ function ninesixtyrobots_preprocess_page(&$vars) { // Check if the theme is using Twitter. $use_twitter = theme_get_setting('use_twitter'); // If the theme uses Twitter pull it in and display it in the slogan. if ($use_twitter) { if ($cache = cache_get('ninesixtyrobots_tweets')) { $data = $cache->data; } else { $query = theme_get_setting('twitter_search_term'); $query = drupal_encode_path($query); $response = drupal_http_request('http://search.twitter.com/search.json?q=' . $query); if ($response->code == 200) { $data = json_decode($response->data); // Set a 5 minute cache on retrieving tweets. // Note if this isn't updating on your site *run cron*. cache_set('ninesixtyrobots_tweets', $data, 'cache', 300); } } $tweet = $data->results[array_rand($data->results)]; // Create the actual variable finally. $vars['site_slogan'] = check_plain(html_entity_decode($tweet->text)); } }
<?php print render($content); ?> <?php if ($page) { ?> <?php $share_title = drupal_encode_path($title); $share_url = drupal_encode_path(url(current_path(), array('absolute' => true))); $share_media = NULL; if (isset($content['field_image'])) { if (isset($content['field_image']['#items'])) { $share_media_path = $content['field_image']['#items'][0]['uri']; $share_media = drupal_encode_path(file_create_url($share_media_path)); } } ?> <div class="field field-name-field-share field-type-text field-label-above"> <div class="field-items"> <div class="field-item even"> <p> <a href="https://www.facebook.com/sharer/sharer.php?u=<?php print $share_url; ?> " target="_blank"><i class="fa fa-facebook"></i></a> <a href="https://plus.google.com/share?url=<?php print $share_url; ?> " target="_blank"><i class="fa fa-google-plus"></i></a>
/** * Returns the local writable target of the resource within the stream. * * Overrides getExternalUrl(). * * Return the HTML URI of a public file. */ function getExternalUrl() { $path = str_replace('\\', '/', $this->getTarget()); return $GLOBALS['base_url'] . '/' . $this->getDirectoryPath() . '/' . drupal_encode_path($path); }
function setUp2() { $this->user1 = user_load(1); // Update uid 1's name and password so we know it. $password = user_password(); require_once DRUPAL_ROOT . '/' . variable_get('password_inc', 'includes/password.inc'); $account = array('name' => 'user1', 'pass' => user_hash_password(trim($password))); // We cannot use user_save() here or the password would be hashed again. db_update('users')->fields($account)->condition('uid', 1)->execute(); // Reload and log in uid 1. $this->user1 = user_load(1, TRUE); $this->user1->pass_raw = $password; // Rebuild content access permissions $this->drupalLogin($this->user1); $this->drupalPost('admin/reports/status/rebuild', array(), t('Rebuild permissions')); if (module_exists('devel_node_access')) { // Enable Devel Node Access. $this->drupalGet('admin/config/development/devel'); $this->assertResponse(200); $this->drupalPost('admin/config/development/devel', array('devel_node_access_debug_mode' => '1'), t('Save configuration')); $this->assertResponse(200, 'Devel Node Access configuration saved.'); // Enable the second DNA block, too. $this->drupalPost('admin/structure/block/list', array('blocks[devel_node_access_dna_user][region]' => 'footer'), t('Save blocks')); } if (module_exists('devel')) { $this->drupalPost('admin/config/development/devel', array('devel_error_handlers[]' => array(1, 2, 4)), t('Save configuration')); $this->assertResponse(200, 'Devel configuration saved.'); $this->drupalPost('admin/people/permissions/list', array('1[access devel information]' => 'access devel information', '2[access devel information]' => 'access devel information'), t('Save permissions')); $this->assertResponse(200, 'Devel permissions saved.'); } /* The base class creates the following users: $this->user1 = user 1 $this->admin_user = array('administer blocks', 'administer forums', 'administer menu', 'administer taxonomy', 'create forum content')); // 'access administration pages') $this->edit_any_topics_user = array('create forum content', 'edit any forum content', 'delete any forum content', 'access administration pages') $this->edit_own_topics_user = array('create forum content', 'edit own forum content', 'delete own forum content') $this->web_user = array() Remove these users and roles and create the ones we need. */ user_role_delete((int) reset($this->admin_user->roles)); user_role_delete((int) reset($this->edit_any_topics_user->roles)); user_role_delete((int) reset($this->edit_own_topics_user->roles)); user_delete($this->admin_user->uid); user_delete($this->edit_any_topics_user->uid); user_delete($this->edit_own_topics_user->uid); user_delete($this->web_user->uid); unset($this->web_user); // Get rids and uids up to 10/9. for ($i = 0; $i < 3; ++$i) { $dummy_rid = (int) $this->drupalCreateRole(array(), 'dummy'); $dummy_user = $this->drupalCreateNamedUser('Dummy', array($dummy_rid)); user_role_delete($dummy_rid); user_delete($dummy_user->uid); } // Create our roles. $this->admin_rid = 3; $this->webmaster_rid = (int) $this->drupalCreateRole(array('administer blocks', 'administer forums', 'administer nodes', 'administer comments', 'administer menu', 'administer taxonomy', 'create forum content', 'access content overview', 'access administration pages', 'view revisions', 'revert revisions', 'delete revisions'), '11 webmaster'); $this->forum_admin_rid = (int) $this->drupalCreateRole(array('administer forums', 'create forum content', 'edit any forum content', 'delete any forum content'), '12 forum admin'); $this->edndel_any_content_rid = (int) $this->drupalCreateRole(array('create forum content', 'edit any forum content', 'delete any forum content', 'view own unpublished content'), '13 edndel any content'); $this->edndel_own_content_rid = (int) $this->drupalCreateRole(array('create forum content', 'edit own forum content', 'delete own forum content'), '14 edndel own content'); $this->edit_any_content_rid = (int) $this->drupalCreateRole(array('create forum content', 'edit any forum content', 'view own unpublished content'), '15 edit any content'); $this->edit_own_content_rid = (int) $this->drupalCreateRole(array('create forum content', 'edit own forum content', 'edit own comments'), '16 edit own content'); $this->delete_any_content_rid = (int) $this->drupalCreateRole(array('create forum content', 'delete any forum content', 'view own unpublished content'), '17 delete any content'); $this->delete_own_content_rid = (int) $this->drupalCreateRole(array('create forum content', 'delete own forum content', 'edit own comments'), '18 delete own content'); // EOC should not make any difference! $this->create_content_rid = (int) $this->drupalCreateRole(array('create forum content'), '19 create content'); $this->anon_rid = DRUPAL_ANONYMOUS_RID; $this->auth_rid = DRUPAL_AUTHENTICATED_RID; // Create our users. $this->admin_user = $this->drupalCreateNamedUser('10_Administrator', array($this->admin_rid)); $this->webmaster_user = $this->drupalCreateNamedUser('11_Webmaster', array($this->webmaster_rid)); $this->forum_admin_user = $this->drupalCreateNamedUser('12_Forum_admin', array($this->forum_admin_rid)); $this->edndel_any_content_user = $this->drupalCreateNamedUser('13_EdNDel_any_content', array($this->edndel_any_content_rid)); $this->edndel_own_content_user = $this->drupalCreateNamedUser('14_EdNDel_own_content', array($this->edndel_own_content_rid)); $this->edit_any_content_user = $this->drupalCreateNamedUser('15_Edit_any_content', array($this->edit_any_content_rid)); $this->edit_own_content_user = $this->drupalCreateNamedUser('16_Edit_own_content', array($this->edit_own_content_rid)); $this->delete_any_content_user = $this->drupalCreateNamedUser('17_Delete_any_content', array($this->delete_any_content_rid)); $this->delete_own_content_user = $this->drupalCreateNamedUser('18_Delete_own_content', array($this->delete_own_content_rid)); $this->create_content_user = $this->drupalCreateNamedUser('19_Create_content', array($this->create_content_rid)); $this->auth_user = $this->drupalCreateNamedUser('20_Auth_only', array()); $this->moderator = $this->drupalCreateNamedUser('21_Moderator', array($this->create_content_rid)); $anon = drupal_anonymous_user(); $anon->name = check_plain(format_username($anon)); $this->accounts = array($this->user1, $this->admin_user, $this->webmaster_user, $this->forum_admin_user, $this->edndel_any_content_user, $this->edndel_own_content_user, $this->edit_any_content_user, $this->edit_own_content_user, $this->delete_any_content_user, $this->delete_own_content_user, $this->create_content_user, $this->auth_user, $this->moderator); $this->rids = array($this->anon_rid, $this->auth_rid, $this->admin_rid, $this->webmaster_rid, $this->forum_admin_rid, $this->edndel_any_content_rid, $this->edndel_own_content_rid, $this->edit_any_content_rid, $this->edit_own_content_rid, $this->delete_any_content_rid, $this->delete_own_content_rid, $this->create_content_rid); // Show settings for reference. $this->drupalGet('admin/people/permissions/list'); $this->assertResponse(200, '^^^ Permissions'); $this->drupalGet('admin/people', array('query' => array('sort' => 'asc', 'order' => drupal_encode_path(t('Username'))))); $this->assertResponse(200, '^^^ Users'); }
/** * @param $path * @return mixed */ public static function drupal_encode_path($path) { return drupal_encode_path($path); }