Exemplo n.º 1
0
function openfit_base_preprocess_comment(&$variables)
{
    $openfit_node_types = array('activity' => TRUE);
    if (!isset($variables['node']) || !isset($openfit_node_types[$variables['node']->type])) {
        return;
    }
    $comment = $variables['comment'];
    // Remove the standard comment links: reply, edit, delete
    unset($variables['content']['links']['comment']['#links']);
    // Add a delete menu if the user posted the comment or is admin
    global $user;
    if (user_access('administer comments') || $user->uid == $comment->uid) {
        $url = drupal_get_path_alias('node/' . $variables['node']->nid) . '/comments';
        $variables['content']['links']['comment']['#links'] = array('comment-delete' => array('title' => ' ', 'href' => 'comment/' . $comment->cid . '/delete', 'query' => array('destination' => $url), 'html' => TRUE));
    }
    // Display "XX ago" for posts less than 1 day, otherwise use locale to format datetime
    $ago = time() - $comment->created;
    if ($ago < 86400) {
        $variables['created'] = t('!interval ago', array('!interval' => format_interval(time() - $comment->created)));
    } else {
        $locale = OpenFitUserSetting::getCurrentUserLocale();
        $fmt = new IntlDateFormatter($locale, IntlDateFormatter::SHORT, IntlDateFormatter::SHORT);
        $created = new DateTime('now');
        $created->setTimestamp($comment->created);
        $variables['created'] = $fmt->format($created);
    }
    $variables['submitted'] = $variables['author'] . '&nbsp;' . '<time datetime="' . $variables['datetime'] . '" pubdate="pubdate">' . $variables['created'] . '</time>';
}
Exemplo n.º 2
0
 /**
  * Implements \SiteAudit\Check\Abstract\getResultInfo().
  */
 public function getResultInfo()
 {
     if ($this->registry['cron_last']) {
         return dt('Cron last ran at @date (@ago ago)', array('@date' => date('r', $this->registry['cron_last']), '@ago' => format_interval(time() - $this->registry['cron_last'])));
     }
     return dt('Cron has never run.');
 }
Exemplo n.º 3
0
/**
 * Create Cleaner settings form.
 *
 * @return array
 *   Form of the cleaner settings page.
 */
function hook_cleaner_settings()
{
    // Add CSS to the admin settings page.
    drupal_add_css(drupal_get_path('module', 'cleaner') . '/cleaner.css');
    $form = array();
    $yes_no = array(t('No'), t('Yes'));
    $inline = array('class' => array('container-inline'));
    $interval = array(0 => t('Every time')) + Cleaner::$intervals;
    $form['cleaner_cron'] = array('#type' => 'radios', '#title' => t('Run interval'), '#options' => $interval, '#default_value' => variable_get('cleaner_cron', 3600), '#description' => t('This is how often the options below will occur. The actions will occur on the next Cron run after this interval expires. "Every time" means on every Cron run.'), '#attributes' => $inline);
    $form['cleaner_clear_cache'] = array('#type' => 'radios', '#options' => $yes_no, '#title' => t('Clean up cache'), '#default_value' => variable_get('cleaner_clear_cache', 0), '#description' => Cleaner::cleanerGetCacheTablesTable(), '#attributes' => $inline);
    $form['cleaner_empty_watchdog'] = array('#type' => 'radios', '#options' => $yes_no, '#title' => t('Clean up Watchdog'), '#default_value' => variable_get('cleaner_empty_watchdog', 0), '#description' => t('There is a standard setting for controlling Watchdog contents. This is more useful for test sites.'), '#attributes' => $inline);
    $cookie = session_get_cookie_params();
    $select = db_select('sessions', 's')->fields('s', array('timestamp'))->condition('timestamp', REQUEST_TIME - $cookie['lifetime'], '<');
    $count = $select->execute()->rowCount();
    $form['cleaner_clean_sessions'] = array('#type' => 'radios', '#options' => $yes_no, '#title' => t('Clean up Sessions table'), '#default_value' => variable_get('cleaner_clean_sessions', 0), '#description' => t('The sessions table can quickly become full with old, abandoned sessions. This will delete all sessions older than @interval (as set by your site administrator). There are currently @count such sessions.', array('@interval' => format_interval($cookie['lifetime']), '@count' => $count)), '#attributes' => $inline);
    $form['cleaner_clean_cssdir'] = array('#type' => 'radios', '#options' => $yes_no, '#title' => t('Clean up CSS files'), '#default_value' => variable_get('cleaner_clean_cssdir', 0), '#description' => t('The CSS directory can become full with stale and outdated cache files.  This will delete all CSS cache files but the latest.'), '#attributes' => $inline);
    $form['cleaner_clean_jsdir'] = array('#type' => 'radios', '#options' => $yes_no, '#title' => t('Clean up JS files'), '#default_value' => variable_get('cleaner_clean_jsdir', 0), '#description' => t('The JS directory can become full with stale and outdated cache files.  This will delete all JS cache files but the latest.'), '#attributes' => $inline);
    // We can only offer OPTIMIZE to MySQL users.
    if (db_driver() == 'mysql') {
        $form['cleaner_optimize_db'] = array('#type' => 'radios', '#options' => $yes_no + array('2' => 'Local only'), '#title' => t('Optimize tables with "overhead" space'), '#default_value' => variable_get('cleaner_optimize_db', 0), '#description' => t('The module will compress (optimize) all database tables with unused space. <strong>NOTE</strong>: During an optimization, the table will locked against any other activity; on a high vloume site, this may be undesirable. "Local only" means do not replicate the optimization (if it is being done).'), '#attributes' => $inline);
    } else {
        // If not MySQL, delete(reset) the variable.
        variable_del('cleaner_optimize_db');
    }
    return array('cleaner' => $form);
}
Exemplo n.º 4
0
 /**
  * Tests the listing.
  */
 public function testUserListing()
 {
     $this->drupalGet('admin/people');
     $this->assertResponse(403, 'Anonymous user does not have access to the user admin listing.');
     // Create a bunch of users.
     $accounts = array();
     for ($i = 0; $i < 3; $i++) {
         $account = $this->drupalCreateUser();
         $accounts[$account->label()] = $account;
     }
     // Create a blocked user.
     $account = $this->drupalCreateUser();
     $account->block();
     $account->save();
     $accounts[$account->label()] = $account;
     // Create a user at a certain timestamp.
     $account = $this->drupalCreateUser();
     $account->created = 1363219200;
     $account->save();
     $accounts[$account->label()] = $account;
     $timestamp_user = $account->label();
     $rid_1 = $this->drupalCreateRole(array(), 'custom_role_1', 'custom_role_1');
     $rid_2 = $this->drupalCreateRole(array(), 'custom_role_2', 'custom_role_2');
     $account = $this->drupalCreateUser();
     $account->addRole($rid_1);
     $account->addRole($rid_2);
     $account->save();
     $accounts[$account->label()] = $account;
     $role_account_name = $account->label();
     // Create an admin user and look at the listing.
     $admin_user = $this->drupalCreateUser(array('administer users'));
     $accounts[$admin_user->label()] = $admin_user;
     $accounts['admin'] = entity_load('user', 1);
     $this->drupalLogin($admin_user);
     $this->drupalGet('admin/people');
     $this->assertResponse(200, 'The admin user has access to the user admin listing.');
     $result = $this->xpath('//table[contains(@class, "responsive-enabled")]/tbody/tr');
     $result_accounts = array();
     foreach ($result as $account) {
         $name = (string) $account->td[0]->span;
         $roles = array();
         if (isset($account->td[2]->div->ul)) {
             foreach ($account->td[2]->div->ul->li as $element) {
                 $roles[] = (string) $element;
             }
         }
         $result_accounts[$name] = array('name' => $name, 'status' => (string) $account->td[1], 'roles' => $roles, 'member_for' => (string) $account->td[3]);
     }
     $this->assertFalse(array_diff(array_keys($result_accounts), array_keys($accounts)), 'Ensure all accounts are listed.');
     foreach ($result_accounts as $name => $values) {
         $this->assertEqual($values['status'] == t('active'), $accounts[$name]->status->value, 'Ensure the status is displayed properly.');
     }
     $expected_roles = array('custom_role_1', 'custom_role_2');
     $this->assertEqual($result_accounts[$role_account_name]['roles'], $expected_roles, 'Ensure roles are listed properly.');
     $this->assertEqual($result_accounts[$timestamp_user]['member_for'], format_interval(REQUEST_TIME - $accounts[$timestamp_user]->created->value), 'Ensure the right member time is displayed.');
 }
Exemplo n.º 5
0
/**
 * Implement hook_preprocess_page()
 */
function adminlte_preprocess_page(&$vars, $hook)
{
    global $user;
    global $base_url;
    $vars['front_page'] = $base_url;
    $theme_path = drupal_get_path('theme', 'adminlte');
    // Fontawesome 4.5.0
    drupal_add_css('https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.5.0/css/font-awesome.min.css', array('type' => 'external', 'scope' => 'header'));
    // Ionicons 2.0.1
    drupal_add_css('https://code.ionicframework.com/ionicons/2.0.1/css/ionicons.min.css', array('type' => 'external', 'scope' => 'header'));
    // jQuery 2.2.3
    drupal_add_js($theme_path . '/plugins/jQuery/jQuery-2.2.3.min.js', array('type' => 'file', 'scope' => 'footer'));
    // Bootstrap 3.3.5
    drupal_add_js($theme_path . '/bootstrap/js/bootstrap.min.js', array('type' => 'file', 'scope' => 'footer'));
    // jQuery UI
    drupal_add_js('https://code.jquery.com/ui/1.11.4/jquery-ui.min.js', array('type' => 'external', 'scope' => 'footer'));
    // FastClick
    drupal_add_js($theme_path . '/plugins/fastclick/fastclick.min.js', array('type' => 'file', 'scope' => 'footer'));
    // AdminLTE App
    drupal_add_js($theme_path . '/dist/js/app.min.js', array('type' => 'file', 'scope' => 'footer'));
    // Moment
    drupal_add_js('https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.10.2/moment.min.js', array('type' => 'external', 'scope' => 'footer'));
    // Fullcalendar
    drupal_add_js($theme_path . '/plugins/fullcalendar/fullcalendar.min.js', array('type' => 'file', 'scope' => 'footer'));
    // Additional js for theme.
    drupal_add_js($theme_path . '/assets/js/script.js', array('type' => 'file', 'scope' => 'footer'));
    $vars['logout'] = '/user/logout';
    $vars['profile'] = 'user/' . $user->uid;
    $roles = end($user->roles);
    $vars['role'] = ucfirst($roles);
    reset($user->roles);
    // Check if user is login
    if (user_is_logged_in()) {
        $account = user_load($user->uid);
        $avatar_uri = drupal_get_path('theme', 'adminlte') . '/img/avatar.png';
        $alt = t("@user's picture", array('@user' => format_username($user)));
        // Display profile picture.
        if (!empty($account->picture)) {
            $user_picture = theme('image_style', array('style_name' => 'thumbnail', 'path' => $account->picture->uri, 'alt' => $alt, 'title' => $alt, 'attributes' => array('class' => 'img-circle')));
            $user_picture_m = theme('image_style', array('style_name' => 'thumbnail', 'path' => $account->picture->uri, 'alt' => $alt, 'title' => $alt, 'attributes' => array('class' => 'user-image')));
        } else {
            $user_picture_config = array('style_name' => 'thumbnail', 'path' => $avatar_uri, 'alt' => $alt, 'title' => $alt, 'attributes' => array('class' => 'img-circle'));
            $user_picture_m_config = array('style_name' => 'thumbnail', 'path' => $avatar_uri, 'alt' => $alt, 'title' => $alt, 'attributes' => array('class' => 'user-image'));
            $user_picture = adminlte_image_style($user_picture_config);
            $user_picture_m = adminlte_image_style($user_picture_m_config);
        }
        // Assign profile picture in variables.
        $vars['avatar'] = $user_picture;
        $vars['avatarsm'] = $user_picture_m;
        // Display history of member.
        $vars['history'] = 'Member for ' . format_interval(time() - $user->created);
        // Display username or you can change this to set the fullname of user login.
        $vars['fullname'] = $account->name;
    }
}
Exemplo n.º 6
0
 /**
  * {@inheritdoc}
  */
 public function buildForm(array $form, array &$form_state)
 {
     $config = $this->config('system.cron');
     $form['description'] = array('#markup' => '<p>' . t('Cron takes care of running periodic tasks like checking for updates and indexing content for search.') . '</p>');
     $form['run'] = array('#type' => 'submit', '#value' => t('Run cron'), '#submit' => array(array($this, 'submitCron')));
     $status = '<p>' . t('Last run: %cron-last ago.', array('%cron-last' => format_interval(REQUEST_TIME - $this->state->get('system.cron_last')))) . '</p>';
     $form['status'] = array('#markup' => $status);
     $form['cron_url'] = array('#markup' => '<p>' . t('To run cron from outside the site, go to <a href="!cron">!cron</a>', array('!cron' => url('cron/' . $this->state->get('system.cron_key'), array('absolute' => TRUE)))) . '</p>');
     $form['cron'] = array('#title' => t('Cron settings'), '#type' => 'details', '#open' => TRUE);
     $options = array(3600, 10800, 21600, 43200, 86400, 604800);
     $form['cron']['cron_safe_threshold'] = array('#type' => 'select', '#title' => t('Run cron every'), '#description' => t('More information about setting up scheduled tasks can be found by <a href="@url">reading the cron tutorial on drupal.org</a>.', array('@url' => url('http://drupal.org/cron'))), '#default_value' => $config->get('threshold.autorun'), '#options' => array(0 => t('Never')) + array_map('format_interval', array_combine($options, $options)));
     return parent::buildForm($form, $form_state);
 }
Exemplo n.º 7
0
 public function testFieldDate()
 {
     $view = Views::getView('test_view');
     $view->setDisplay();
     $view->displayHandlers->get('default')->overrideOption('fields', array('created' => array('id' => 'created', 'table' => 'views_test_data', 'field' => 'created', 'relationship' => 'none', 'custom_date_format' => 'c')));
     $time = gmmktime(0, 0, 0, 1, 1, 2000);
     $this->executeView($view);
     $timezones = array(NULL, 'UTC', 'America/New_York');
     foreach ($timezones as $timezone) {
         $dates = array('short' => format_date($time, 'short', '', $timezone), 'medium' => format_date($time, 'medium', '', $timezone), 'long' => format_date($time, 'long', '', $timezone), 'custom' => format_date($time, 'custom', 'c', $timezone));
         $this->assertRenderedDatesEqual($view, $dates, $timezone);
     }
     $intervals = array('raw time ago' => format_interval(REQUEST_TIME - $time, 2), 'time ago' => t('%time ago', array('%time' => format_interval(REQUEST_TIME - $time, 2))));
     $this->assertRenderedDatesEqual($view, $intervals);
 }
Exemplo n.º 8
0
function neb_comment_block()
{
    $items = array();
    $number = variable_get('comment_block_count', 10);
    foreach (comment_get_recent($number) as $comment) {
        //kpr($comment->changed);
        //print date('Y-m-d H:i', $comment->changed);
        $items[] = '<h3>' . l($comment->subject, 'comment/' . $comment->cid, array('fragment' => 'comment-' . $comment->cid)) . '</h3>' . ' <time datetime="' . date('Y-m-d H:i', $comment->changed) . '">' . t('@time ago', array('@time' => format_interval(REQUEST_TIME - $comment->changed))) . '</time>';
    }
    if ($items) {
        return theme('item_list', array('items' => $items, 'daddy' => 'comments'));
    } else {
        return t('No comments available.');
    }
}
Exemplo n.º 9
0
function skype_history($threshold = 60, $since = "Last Monday")
{
    $calls = SkypeHistory_Call::getCalls();
    $since = strtotime($since);
    $table = new Console_Table();
    $table->setHeaders(array('Date', 'Time', 'Duration', '<>', 'Participants'));
    $types = array('INCOMING_PSTN' => '<-', 'INCOMING_P2P' => '<-', 'OUTGOING_PSTN' => '->', 'OUTGOING_P2P' => '->');
    $previous_date = NULL;
    $total_duration = 0;
    printf("Gathering skype call history, this may take a few seconds.\n");
    foreach ($calls as $i => $id) {
        $call = new SkypeHistory_Call($id);
        // Bail out once the cutoff is reached.
        if ($call->timestamp < $since) {
            break;
        }
        if ($call->duration < $threshold) {
            continue;
        }
        $participants = array();
        $participants[] = $call->PARTNER_DISPNAME;
        if ($call->conf_participants_count > 1) {
            for ($j = 1; $j < (int) $call->conf_participants_count; $j++) {
                $p = $call->getProperty("CONF_PARTICIPANT {$j}");
                // drewstephens0815 OUTGOING_P2P FINISHED Andrew Stephens
                list($nick, $type, $status, $display_name) = explode(" ", $p, 4);
                $participants[] = $display_name;
            }
        }
        $date = date('D M d,Y', (int) $call->timestamp);
        if ($date == $previous_date) {
            $date = '';
        } else {
            if (!empty($previous_date)) {
                $table->addSeparator();
            }
            $previous_date = $date;
        }
        $total_duration += (int) $call->duration;
        $table->addRow(array($date, date('g:ia', (int) $call->timestamp), format_interval($call->duration), $types[$call->type], format_participants($participants)));
        printf("\r%s", str_repeat('.', $i));
    }
    printf("\r");
    print $table->getTable();
    printf("Number of calls: %s\n", count($calls));
    printf("Total duration: %s\n", format_interval($total_duration));
}
Exemplo n.º 10
0
function worksafe_theme_status_time_link($status, $is_link = true)
{
    $time = strtotime($status->created_at);
    if ($time > 0) {
        if (twitter_date('dmy') == twitter_date('dmy', $time)) {
            $out = format_interval(time() - $time, 1) . ' ago';
        } else {
            $out = twitter_date('H:i', $time);
        }
    } else {
        $out = $status->created_at;
    }
    if ($is_link) {
        $out = "<a href='status/{$status->id}'>{$out}</a>";
    }
    return $out;
}
 public function formatInterval($date, $now = null)
 {
     $timestamp = $this->dateToTimestamp($date);
     if (null === $timestamp) {
         return '';
         // I'm really sorry I'm not Mme Irma
     }
     if (null === $now) {
         $referenceTimestamp = time();
     } else {
         $referenceTimestamp = $this->dateToTimestamp($now);
         if (null === $referenceTimestamp) {
             return '';
             // Still not Mme Irma
         }
     }
     return format_interval($referenceTimestamp - $timestamp);
 }
Exemplo n.º 12
0
/**
 * Returns themed html for individual tweets
 */
function rhok_twitter_block_tweets($tweet_object, $variables = array())
{
    $tweet = get_object_vars($tweet_object['tweet']);
    $tweet['text'] = twitter_block_linkify($tweet['text']);
    $tweet['time_ago'] = format_interval(time() - strtotime($tweet['created_at']));
    $html = <<<EOHTML
<div class="twitter_block tweet">
  <div class="tweet_text"><p class="tweet">{$tweet['text']}</p></div> 
  <div class="twitter_block_user">
    <a class="twitter_block profile_image" href="http://twitter.com/{$tweet['from_user']}">
      <span class="twitter_block_user_name">@{$tweet['from_user']}</span>
    </a>
    <span class="twitter_block_time_ago">{$tweet['time_ago']}</span>
  </div>
</div>
EOHTML;
    return $html;
}
Exemplo n.º 13
0
/**
 * Preprocess variables for node.tpl.php
 *
 * @see node.tpl.php
 */
function apigee_base_preprocess_node(&$variables)
{
    if ($variables['teaser']) {
        $variables['classes_array'][] = 'row-fluid';
    }
    $author = $variables['name'];
    $time_ago_short = format_interval(time() - $variables['created'], 1) . t(' ago');
    $time_ago_long = format_interval(time() - $variables['created'], 2) . t(' ago');
    // Add some date variables
    if ($variables['type'] = 'blog') {
        if ($variables['uid'] != 0) {
            $variables['posted'] = 'Posted by ' . $author . '&nbsp;|&nbsp;about&nbsp;' . $time_ago_short;
        } else {
            $variables['posted'] = 'Posted ' . $time_ago_short;
        }
        $variables['submitted_day'] = format_date($variables['node']->created, 'custom', 'j');
        $variables['submitted_month'] = format_date($variables['node']->created, 'custom', 'M');
    }
    if ($variables['type'] == 'forum') {
        $variables['submitted'] = 'Topic created by: ' . $author . '&nbsp;&nbsp;' . $time_ago_long;
    }
}
Exemplo n.º 14
0
/**
 * Override a formatted list of recent comments to be displayed in the comment block.
 */
function phptemplate_comment_block()
{
    $items = array();
    foreach (phptemplate_comment_get_recent() as $comment) {
        $link = l($comment->subject, 'node/' . $comment->nid, array('fragment' => 'comment-' . $comment->cid));
        $date = t('@time ago', array('@time' => format_interval(time() - $comment->timestamp)));
        if ($author = _member_get_node($comment->uid)) {
            $capacity = ($author->jobtitle === '' ? '' : $author->jobtitle . ', ') . ($author->affiliation === '' ? '' : $author->affiliation);
            $author = theme('member_link', $author);
        } else {
            $author = theme_username(user_load(array('uid' => $comment->uid)));
            $capacity = '';
        }
        $content = '<div class="title clear-block">' . $link . ' <span class="date">' . $date . '</span></div>';
        $content .= '<div class="comment clear-block">' . scf_au_truncate_by_word_count($comment->comment, 30) . '</div>';
        $content .= '<div class="byline vcard clear-block">By <span class="fn">' . $author . '</span>';
        $content .= ($capacity === '' ? '' : ', <span class="title">' . $capacity . '</span>') . '</div>';
        $items[] = $content;
    }
    if ($items) {
        return theme('item_list', $items);
    }
}
Exemplo n.º 15
0
function nesi_bootstrap_menu_tree__user_menu($variables)
{
    global $base_url;
    global $user;
    $user_data = user_load($user->uid);
    $profile_data = profile2_load_by_user($user_data->uid);
    $admin_links = '';
    if (user_access('nesi website config')) {
        $admin_links .= '<li><a href="' . $base_url . '/nesi-config">Administration Dashboard</a></li>';
    }
    $output = '';
    $output .= '<ul id="nesi-user-profile-dropdown" class="dropdown-menu pull-right">';
    $output .= '<li id="nesi-user-picture"><div class="nesi-user-picture"><div class="pull-left">' . theme('user_picture', array('account' => $user)) . '</div>
              <h2>' . format_username($user_data) . '</h2>
              <h3>Institution</h3>
              <p>' . $profile_data['researcher_profile']->field_user_institution[LANGUAGE_NONE][0]['value'] . '</p>
              <p><em>Member for ' . format_interval(REQUEST_TIME - $user_data->created) . '</em></p>
              </div></li>';
    $output .= $admin_links;
    $output .= $variables['tree'];
    $output .= '<li id="nesi-base-actions"><ul class="nav nav-pills nesi-base-actions"><li class="pull-left"><a href="' . $base_url . '/user">Profile</a></li><li class="pull-right"><a href="/user/logout">Log out</a></li></ul></li>';
    $output .= '</ul>';
    return $output;
}
 /**
  * Label for schedule.
  */
 public function formatLabel($job)
 {
     $settings = $job->getSettings($this->type);
     return t('Every @interval', array('@interval' => format_interval($this->presets[$settings['rules'][0]])));
 }
Exemplo n.º 17
0
 /**
  * Get summary information about the Solr Core.
  */
 public function getStatsSummary()
 {
     $stats = $this->getStats();
     $summary = array('@pending_docs' => '', '@autocommit_time_seconds' => '', '@autocommit_time' => '', '@deletes_by_id' => '', '@deletes_by_query' => '', '@deletes_total' => '');
     if (!empty($stats)) {
         $docs_pending_xpath = $stats->xpath('//stat[@name="docsPending"]');
         $summary['@pending_docs'] = (int) trim($docs_pending_xpath[0]);
         $max_time_xpath = $stats->xpath('//stat[@name="autocommit maxTime"]');
         $max_time = (int) trim(current($max_time_xpath));
         // Convert to seconds.
         $summary['@autocommit_time_seconds'] = $max_time / 1000;
         $summary['@autocommit_time'] = format_interval($max_time / 1000);
         $deletes_id_xpath = $stats->xpath('//stat[@name="deletesById"]');
         $summary['@deletes_by_id'] = (int) trim($deletes_id_xpath[0]);
         $deletes_query_xpath = $stats->xpath('//stat[@name="deletesByQuery"]');
         $summary['@deletes_by_query'] = (int) trim($deletes_query_xpath[0]);
         $summary['@deletes_total'] = $summary['@deletes_by_id'] + $summary['@deletes_by_query'];
     }
     return $summary;
 }
Exemplo n.º 18
0
</div>
  </div>
  
  <div class="author-data">
    <?php 
print $picture;
?>
	  <?php 
if (!$account->created == 0) {
    ?>
      <div class="user-member"><?php 
    print t('<strong>Member since:</strong><br /> !date', array('!date' => format_date($account->created, 'custom', 'j F Y')));
    ?>
</div>  
      <div class="user-access"><?php 
    print t('<strong>Last activity:</strong><br /> !ago', array('!ago' => format_interval(time() - $account->access)));
    ?>
</div>  
    <?php 
}
?>
  </div>

  <div class="comment-main">
    <?php 
if ($comment->new) {
    ?>
      <span class="new"><?php 
    print $new;
    ?>
</span>
Exemplo n.º 19
0
/**
 * Implements hook_process_node().
 */
function commons_beehive_process_node(&$variables, $hook)
{
    $node = $variables['node'];
    $wrapper = entity_metadata_wrapper('node', $node);
    // Use timeago module for formatting node submission date
    // if it is enabled and also configured to be used on nodes.
    if (module_exists('timeago') && variable_get('timeago_node', 1)) {
        $variables['date'] = timeago_format_date($node->created, $variables['date']);
        $use_timeago_date_format = TRUE;
    } else {
        $use_timeago_date_format = FALSE;
    }
    // Replace the submitted text on nodes with something a bit more pertinent to
    // the content type.
    if (variable_get('node_submitted_' . $node->type, TRUE)) {
        $node_type_info = node_type_get_type($variables['node']);
        $type_attributes = array('class' => array('node-content-type', drupal_html_class('node-content-type-' . $node->type)));
        $placeholders = array('!type' => '<span' . drupal_attributes($type_attributes) . '>' . check_plain($node_type_info->name) . '</span>', '!user' => $variables['name'], '!date' => $variables['date'], '@interval' => format_interval(REQUEST_TIME - $node->created));
        // Show what group the content belongs to if applicable.
        if (!empty($node->{OG_AUDIENCE_FIELD}) && $wrapper->{OG_AUDIENCE_FIELD}->count() == 1) {
            $placeholders['!group'] = l($wrapper->{OG_AUDIENCE_FIELD}->get(0)->label(), 'node/' . $wrapper->{OG_AUDIENCE_FIELD}->get(0)->getIdentifier());
            if ($use_timeago_date_format == TRUE) {
                $variables['submitted'] = t('!type created !date in the !group group by !user', $placeholders);
            } else {
                $variables['submitted'] = t('!type created @interval ago in the !group group by !user', $placeholders);
            }
        } else {
            if ($use_timeago_date_format == TRUE) {
                $variables['submitted'] = t('!type created !date by !user', $placeholders);
            } else {
                $variables['submitted'] = t('!type created @interval ago by !user', $placeholders);
            }
        }
    }
    // Append a feature label to featured node teasers.
    if ($variables['teaser'] && $variables['promote']) {
        $variables['submitted'] .= ' <span class="featured-node-tooltip">' . t('Featured') . ' ' . $variables['type'] . '</span>';
    }
}
Exemplo n.º 20
0
 /**
  * AJAX entry point to create the controller form for an IPE.
  */
 function ajax_save_form($break = NULL)
 {
     ctools_include('form');
     if (!empty($this->cache->locked)) {
         if ($break != 'break') {
             $account = user_load($this->cache->locked->uid);
             $name = theme('username', $account);
             $lock_age = format_interval(time() - $this->cache->locked->updated);
             $message = t("This panel is being edited by user !user, and is therefore locked from editing by others. This lock is !age old.\n\nClick OK to break this lock and discard any changes made by !user.", array('!user' => $name, '!age' => $lock_age));
             $this->commands[] = array('command' => 'unlockIPE', 'message' => $message, 'break_path' => url($this->get_url('save-form', 'break')));
             return;
         }
         // Break the lock.
         panels_edit_cache_break_lock($this->cache);
     }
     $form_state = array('display' => &$this->display, 'content_types' => $this->cache->content_types, 'rerender' => FALSE, 'no_redirect' => TRUE, 'layout' => $this->plugins['layout']);
     $output = ctools_build_form('panels_ipe_edit_control_form', $form_state);
     if ($output) {
         // At this point, we want to save the cache to ensure that we have a lock.
         panels_edit_cache_set($this->cache);
         $this->commands[] = array('command' => 'initIPE', 'key' => $this->clean_key, 'data' => $output);
         return;
     }
     // no output == submit
     if (!empty($form_state['clicked_button']['#save-display'])) {
         // Saved. Save the cache.
         panels_edit_cache_save($this->cache);
     } else {
         // Cancelled. Clear the cache.
         panels_edit_cache_clear($this->cache);
     }
     $this->commands[] = array('command' => 'endIPE', 'key' => $this->clean_key, 'data' => $output);
 }
foreach ($items as $item) {
    ?>
  <li class="item">
    <span class="facebook-note-picture"><img alt="<?php 
    echo $feedid;
    ?>
" src="//graph.facebook.com/<?php 
    echo $feedid;
    ?>
/picture" /></span>
    <span class="facebook-note-title"><a rel="external" href="<?php 
    echo $item->link['href'];
    ?>
"><?php 
    echo $item->title;
    ?>
</a></span>
    <span class="facebook-note-message"><?php 
    echo $item->summary;
    ?>
</span>
    <span class="facebook-note-time"><?php 
    echo t('!time ago.', array('!time' => format_interval(time() - strtotime($item->published))));
    ?>
</span>
  </li>
<?php 
}
?>
</ul>
Exemplo n.º 22
0
<div class="comment">
	<div class="meta">
  	<?php 
print l('#' . $comment_count, 'node/' . $comment->nid, array('fragment' => 'comment-' . $comment->cid));
?>
		<?php 
if ($submitted) {
    ?>
      <?php 
    print theme('username', $comment) . ' ' . t('wrote !date ago', array('!date' => format_interval(time() - $comment->timestamp)));
    ?>
    <?php 
}
?>
  </div>
    
	<div class="content">
    <?php 
print $content;
?>
  </div>

	<?php 
if ($links) {
    ?>
    <div class="links"><?php 
    print $links;
    ?>
</div>
  <?php 
}
Exemplo n.º 23
0
/**
 * Check installation requirements and do status reporting.
 *
 * This hook has three closely related uses, determined by the $phase argument:
 * - Checking installation requirements ($phase == 'install').
 * - Checking update requirements ($phase == 'update').
 * - Status reporting ($phase == 'runtime').
 *
 * Note that this hook, like all others dealing with installation and updates,
 * must reside in a module_name.install file, or it will not properly abort
 * the installation of the module if a critical requirement is missing.
 *
 * During the 'install' phase, modules can for example assert that
 * library or server versions are available or sufficient.
 * Note that the installation of a module can happen during installation of
 * Drupal itself (by install.php) with an installation profile or later by hand.
 * As a consequence, install-time requirements must be checked without access
 * to the full Drupal API, because it is not available during install.php.
 * For localization you should for example use $t = get_t() to
 * retrieve the appropriate localization function name (t() or st()).
 * If a requirement has a severity of REQUIREMENT_ERROR, install.php will abort
 * or at least the module will not install.
 * Other severity levels have no effect on the installation.
 * Module dependencies do not belong to these installation requirements,
 * but should be defined in the module's .info file.
 *
 * The 'runtime' phase is not limited to pure installation requirements
 * but can also be used for more general status information like maintenance
 * tasks and security issues.
 * The returned 'requirements' will be listed on the status report in the
 * administration section, with indication of the severity level.
 * Moreover, any requirement with a severity of REQUIREMENT_ERROR severity will
 * result in a notice on the administration configuration page.
 *
 * @param $phase
 *   The phase in which requirements are checked:
 *   - install: The module is being installed.
 *   - update: The module is enabled and update.php is run.
 *   - runtime: The runtime requirements are being checked and shown on the
 *     status report page.
 *
 * @return
 *   An associative array where the keys are arbitrary but must be unique (it
 *   is suggested to use the module short name as a prefix) and the values are
 *   themselves associative arrays with the following elements:
 *   - title: The name of the requirement.
 *   - value: The current value (e.g., version, time, level, etc). During
 *     install phase, this should only be used for version numbers, do not set
 *     it if not applicable.
 *   - description: The description of the requirement/status.
 *   - severity: The requirement's result/severity level, one of:
 *     - REQUIREMENT_INFO: For info only.
 *     - REQUIREMENT_OK: The requirement is satisfied.
 *     - REQUIREMENT_WARNING: The requirement failed with a warning.
 *     - REQUIREMENT_ERROR: The requirement failed with an error.
 */
function hook_requirements($phase)
{
    $requirements = array();
    // Ensure translations don't break during installation.
    $t = get_t();
    // Report Drupal version
    if ($phase == 'runtime') {
        $requirements['drupal'] = array('title' => $t('Drupal'), 'value' => VERSION, 'severity' => REQUIREMENT_INFO);
    }
    // Test PHP version
    $requirements['php'] = array('title' => $t('PHP'), 'value' => $phase == 'runtime' ? l(phpversion(), 'admin/reports/status/php') : phpversion());
    if (version_compare(phpversion(), DRUPAL_MINIMUM_PHP) < 0) {
        $requirements['php']['description'] = $t('Your PHP installation is too old. Drupal requires at least PHP %version.', array('%version' => DRUPAL_MINIMUM_PHP));
        $requirements['php']['severity'] = REQUIREMENT_ERROR;
    }
    // Report cron status
    if ($phase == 'runtime') {
        $cron_last = variable_get('cron_last');
        if (is_numeric($cron_last)) {
            $requirements['cron']['value'] = $t('Last run !time ago', array('!time' => format_interval(REQUEST_TIME - $cron_last)));
        } else {
            $requirements['cron'] = array('description' => $t('Cron has not run. It appears cron jobs have not been setup on your system. Check the help pages for <a href="@url">configuring cron jobs</a>.', array('@url' => 'http://drupal.org/cron')), 'severity' => REQUIREMENT_ERROR, 'value' => $t('Never run'));
        }
        $requirements['cron']['description'] .= ' ' . $t('You can <a href="@cron">run cron manually</a>.', array('@cron' => url('admin/reports/status/run-cron')));
        $requirements['cron']['title'] = $t('Cron maintenance tasks');
    }
    return $requirements;
}
Exemplo n.º 24
0
/**
 * Convience wrapper around the drupal format_interval method
 * *
 * Instead of receiving the calculated difference in seconds
 * you can just give it a date and it calculates the difference
 * for you.
 *
 * @see format_interval();
 *
 * @param $date  String containing the date, or unix timestamp
 * @param int $granularity
 */
function tfd_interval($date, $granularity = 2, $display_ago = TRUE, $langcode = NULL)
{
    $now = time();
    if (preg_match('/[^\\d]/', $date)) {
        $then = strtotime($date);
    } else {
        $then = $date;
    }
    $interval = $now - $then;
    if ($interval > 0) {
        return $display_ago ? t('!time ago', array('!time' => format_interval($interval, $granularity, $langcode))) : t('!time', array('!time' => format_interval($interval, $granularity, $langcode)));
    } else {
        return format_interval(abs($interval), $granularity, $langcode);
    }
}
Exemplo n.º 25
0
/**
 * Process variables for alttracker_node.tpl.php.
 *
 * The $variables array contains the following arguments:
 * - $node: Node data.
 *
 * @see alttracker_node.tpl.php
 */
function alpha_preprocess_alttracker_node(&$variables)
{
    $node = $variables['node'];
    $variables['timeago'] = t('@time ago', array('@time' => format_interval(time() - $node->changed)));
    $variables['url'] = $node->url;
    $variables['title'] = check_plain($node->title);
    $variables['sticky'] = $node->sticky;
    $variables['promote'] = $node->promote;
    $variables['status'] = $node->status;
    $variables['date'] = format_date($node->created);
    $variables['name'] = theme('username', array('account' => $node));
    if (!empty($node->terms)) {
        $terms_links = array();
        foreach ($node->terms as $term) {
            $terms_links[] = array('title' => check_plain($term->name), 'href' => url("taxonomy/term/" . $term->tid), 'html' => TRUE);
        }
        $variables['term'] = theme('links', array('links' => $terms_links));
    }
    $variables['icon'] = theme('alttracker_icon', array('node' => $node));
    // Gather node classes.
    $variables['classes_array'][] = drupal_html_class('node-' . $node->type);
    if ($variables['promote']) {
        $variables['classes_array'][] = 'node-promoted';
    }
    if ($variables['sticky']) {
        $variables['classes_array'][] = 'node-sticky';
    }
    if (!$variables['status']) {
        $variables['classes_array'][] = 'node-unpublished';
    }
}
Exemplo n.º 26
0
function theme_status_time_link($status, $is_link = true)
{
    $time = strtotime($status->created_at);
    if ($time > 0) {
        if (twitter_date('dmy') == twitter_date('dmy', $time) && !setting_fetch('timestamp')) {
            $out = format_interval(time() - $time, 1) . ' ago';
        } else {
            $out = twitter_date('H:i', $time);
        }
    } else {
        $out = $status->created_at;
    }
    if ($is_link) {
        $out = "<a href='status/{$status->id}' class='time'>{$out}</a>";
    }
    return $out;
}
 /**
  * Get summary information about the Solr Core.
  */
 public function getStatsSummary()
 {
     $stats = $this->getStats();
     $solr_version = $this->getSolrVersion();
     $summary = array('@pending_docs' => '', '@autocommit_time_seconds' => '', '@autocommit_time' => '', '@deletes_by_id' => '', '@deletes_by_query' => '', '@deletes_total' => '', '@schema_version' => '', '@core_name' => '', '@index_size' => '');
     if (!empty($stats)) {
         if ($solr_version <= 3) {
             $docs_pending_xpath = $stats->xpath('//stat[@name="docsPending"]');
             $summary['@pending_docs'] = (int) trim(current($docs_pending_xpath));
             $max_time_xpath = $stats->xpath('//stat[@name="autocommit maxTime"]');
             $max_time = (int) trim(current($max_time_xpath));
             // Convert to seconds.
             $summary['@autocommit_time_seconds'] = $max_time / 1000;
             $summary['@autocommit_time'] = format_interval($max_time / 1000);
             $deletes_id_xpath = $stats->xpath('//stat[@name="deletesById"]');
             $summary['@deletes_by_id'] = (int) trim(current($deletes_id_xpath));
             $deletes_query_xpath = $stats->xpath('//stat[@name="deletesByQuery"]');
             $summary['@deletes_by_query'] = (int) trim(current($deletes_query_xpath));
             $summary['@deletes_total'] = $summary['@deletes_by_id'] + $summary['@deletes_by_query'];
             $schema = $stats->xpath('/solr/schema[1]');
             $summary['@schema_version'] = trim($schema[0]);
             $core = $stats->xpath('/solr/core[1]');
             $summary['@core_name'] = trim($core[0]);
             $size_xpath = $stats->xpath('//stat[@name="indexSize"]');
             $summary['@index_size'] = trim(current($size_xpath));
         } else {
             $system_info = $this->getSystemInfo();
             $docs_pending_xpath = $stats->xpath('//lst["stats"]/long[@name="docsPending"]');
             $summary['@pending_docs'] = (int) trim(current($docs_pending_xpath));
             $max_time_xpath = $stats->xpath('//lst["stats"]/str[@name="autocommit maxTime"]');
             $max_time = (int) trim(current($max_time_xpath));
             // Convert to seconds.
             $summary['@autocommit_time_seconds'] = $max_time / 1000;
             $summary['@autocommit_time'] = format_interval($max_time / 1000);
             $deletes_id_xpath = $stats->xpath('//lst["stats"]/long[@name="deletesById"]');
             $summary['@deletes_by_id'] = (int) trim(current($deletes_id_xpath));
             $deletes_query_xpath = $stats->xpath('//lst["stats"]/long[@name="deletesByQuery"]');
             $summary['@deletes_by_query'] = (int) trim(current($deletes_query_xpath));
             $summary['@deletes_total'] = $summary['@deletes_by_id'] + $summary['@deletes_by_query'];
             $schema = $system_info->core->schema;
             $summary['@schema_version'] = $schema;
             $core = $stats->xpath('//lst["core"]/str[@name="coreName"]');
             $summary['@core_name'] = trim(current($core));
             $size_xpath = $stats->xpath('//lst["core"]/str[@name="indexSize"]');
             $summary['@index_size'] = trim(current($size_xpath));
         }
     }
     return $summary;
 }
          <?php 
    print $tweet->text;
    ?>
        </p>
        <cite class="tweeter">&mdash; <a href="http://twitter.com/<?php 
    print $tweet->screen_name;
    ?>
" title="<?php 
    print t("@name on Twitter", array('@name' => $tweet->screen_name));
    ?>
" ><?php 
    print $tweet->screen_name;
    ?>
</a></cite>
        <time class="time-ago">
          <span class="field-content"><a href="<?php 
    print $tweet->url;
    ?>
" title="Permalink"><?php 
    print format_interval(time() - $tweet->timestamp);
    ?>
 ago</a></span>
        </time>
    </article>
  <?php 
}
?>
</div>
<footer>
  <a href="http://twitter.com/thewebahead" class="twitfaves-follow-link">Follow me on twitter</a>
</footer>
Exemplo n.º 29
0
 /**
  * This is a generic lock test.
  */
 function ipe_test_lock($url, $break)
 {
     if (!empty($this->cache->locked)) {
         if ($break != 'break') {
             $account = user_load($this->cache->locked->uid);
             $name = format_username($account);
             $lock_age = format_interval(time() - $this->cache->locked->updated);
             $message = t("This panel is being edited by user !user, and is therefore locked from editing by others. This lock is !age old.\n\nClick OK to break this lock and discard any changes made by !user.", array('!user' => $name, '!age' => $lock_age));
             $this->commands[] = array('command' => 'unlockIPE', 'message' => $message, 'break_path' => url($this->get_url($url, 'break')), 'key' => $this->clean_key);
             return TRUE;
         }
         // Break the lock.
         panels_edit_cache_break_lock($this->cache);
     }
 }
Exemplo n.º 30
0
/**
 * The user's account information is being displayed.
 *
 * The module should format its custom additions for display and add them to the
 * $account->content array.
 *
 * Note that when this hook is invoked, the changes have not yet been written to
 * the database, because a database transaction is still in progress. The
 * transaction is not finalized until the save operation is entirely completed
 * and user_save() goes out of scope. You should not rely on data in the
 * database at this time as it is not updated yet. You should also note that any
 * write/update database queries executed from this hook are also not committed
 * immediately. Check user_save() and db_transaction() for more info.
 *
 * @param $account
 *   The user object on which the operation is being performed.
 * @param $view_mode
 *   View mode, e.g. 'full'.
 * @param $langcode
 *   The language code used for rendering.
 *
 * @see hook_user_view_alter()
 * @see hook_entity_view()
 */
function hook_user_view($account, $view_mode, $langcode)
{
    $account->content['user_picture'] = array('#markup' => theme('user_picture', array('account' => $account)), '#weight' => -10);
    $account->content['member_for'] = array('#type' => 'item', '#title' => t('Member for'), '#markup' => format_interval(REQUEST_TIME - $account->created));
}