Example #1
0
 public static function render_instance(BlockInstance $instance, $editing = false)
 {
     $configdata = $instance->get('configdata');
     $result = '';
     if (!empty($configdata['artefactids'])) {
         $artefactids = implode(', ', array_map('db_quote', $configdata['artefactids']));
         if (!($mostrecent = get_records_sql_array('SELECT a.title, ' . db_format_tsfield('a.ctime', 'ctime') . ', p.title AS parenttitle, a.id, a.parent
             FROM {artefact} a
             JOIN {artefact} p ON a.parent = p.id
             WHERE a.artefacttype = \'blogpost\'
             AND a.parent IN ( ' . $artefactids . ' ) 
             AND a.owner = (SELECT owner from {view} WHERE id = ?)
             ORDER BY a.ctime DESC
             LIMIT 10', array($instance->get('view'))))) {
             $mostrecent = array();
         }
         // format the dates
         foreach ($mostrecent as &$data) {
             $data->displaydate = format_date($data->ctime);
         }
         $smarty = smarty_core();
         $smarty->assign('mostrecent', $mostrecent);
         $smarty->assign('view', $instance->get('view'));
         $result = $smarty->fetch('blocktype:recentposts:recentposts.tpl');
     }
     return $result;
 }
 /**
  * Creates a "ticket" support_ticket and verifies its consistency in the database.
  */
 function testTicketCreation()
 {
     $ticket_type_storage = \Drupal::entityManager()->getStorage('support_ticket_type');
     // Test /support_ticket/add page with only one content type.
     $this->drupalGet('support_ticket/add');
     $this->assertResponse(200);
     $this->assertUrl('support_ticket/add/ticket');
     // Create a ticket.
     $edit = array();
     $edit['title[0][value]'] = $this->randomMachineName(8);
     $edit['body[0][value]'] = $this->randomMachineName(16);
     $edit['field_priority'] = '120';
     // 120 = 'high'
     $edit['field_state'] = 'inactive';
     $this->drupalPostForm('support_ticket/add/ticket', $edit, t('Save'));
     // Check that the ticket has been created.
     $this->assertRaw(t('@post %title has been created.', array('@post' => 'Ticket', '%title' => $edit['title[0][value]'])), 'Ticket created.');
     // Check that the support_ticket exists in the database.
     $ticket = $this->supportTicketGetTicketByTitle($edit['title[0][value]']);
     $this->assertTrue($ticket, 'Ticket found in database.');
     // View ticket to test single ticket output.
     $this->drupalGet('support_ticket/' . $ticket->id());
     // Base "Submitted by..." heading.
     $this->assertText($ticket->getOwner()->getUsername());
     $this->assertText(format_date($ticket->getCreatedTime()));
     // Check field display output for basic ticket fields.
     $elements = $this->cssSelect("div.field--name-field-priority div.field__item:contains('high')");
     $this->assertEqual(count($elements), 1, 'Priority was set correctly.');
     $elements = $this->cssSelect("div.field--name-field-state div.field__item:contains('inactive')");
     $this->assertEqual(count($elements), 1, 'State was set correctly.');
 }
 public function autoLogin()
 {
     if (cookie('token')) {
         $token = cookie('token');
         $userId = $token['userId'];
         if (!is_numeric($userId)) {
             return 0;
         }
         $User = D('User');
         $user = $User->find($userId);
         if ($user['userId'] != $userId) {
             return 0;
         }
         if ($token['verify'] != sha1(md5($user['password']))) {
             return 0;
         }
         session('userId', $user['userId']);
         session('userName', $user['userName']);
         session('icon', $user['icon']);
         session('email', $user['email']);
         session('signature', $user['signature']);
         session('score', $user['score']);
         session('registerTime', format_date($user['registerTime']));
         session('lastLoginTime', format_date($user['lastLoginTime']));
         //更新上次登录时间
         $User->where("userId={$userId}")->setField('lastLoginTime', date('Y-m-d H:i:s', time()));
         cookie('token', $token, 864000);
         return 1;
     } else {
         return 0;
     }
 }
 public static function render_instance(BlockInstance $instance, $editing = false)
 {
     $configdata = $instance->get('configdata');
     if (!empty($configdata['feedid'])) {
         $data = get_record('blocktype_externalfeed_data', 'id', $configdata['feedid'], null, null, null, null, 'id,url,link,title,description,content,' . db_format_tsfield('lastupdate') . ',image');
         $data->content = unserialize($data->content);
         $data->image = unserialize($data->image);
         // only keep the number of entries the user asked for
         $chunks = array_chunk($data->content, isset($configdata['count']) ? $configdata['count'] : 10);
         $data->content = $chunks[0];
         // Attempt to fix relative URLs in the feeds
         if (!empty($data->image['link'])) {
             $data->description = preg_replace('/src="(\\/[^"]+)"/', 'src="' . $data->image['link'] . '$1"', $data->description);
             foreach ($data->content as &$entry) {
                 $entry->description = preg_replace('/src="(\\/[^"]+)"/', 'src="' . $data->image['link'] . '$1"', $entry->description);
             }
         }
         $smarty = smarty_core();
         $smarty->assign('title', $data->title);
         $smarty->assign('description', $data->description);
         $smarty->assign('url', $data->url);
         // 'full' won't be set for feeds created before 'full' support was added
         $smarty->assign('full', isset($configdata['full']) ? $configdata['full'] : false);
         $smarty->assign('link', $data->link);
         $smarty->assign('entries', $data->content);
         $smarty->assign('feedimage', self::make_feed_image_tag($data->image));
         $smarty->assign('lastupdated', get_string('lastupdatedon', 'blocktype.externalfeed', format_date($data->lastupdate)));
         return $smarty->fetch('blocktype:externalfeed:feed.tpl');
     }
     return '';
 }
Example #5
0
    function getMembers($incl_archived = TRUE, $order_by = NULL)
    {
        $db =& $GLOBALS['db'];
        $sql = 'SELECT p.*, gm.membership_status AS membership_status_id, ms.label as membership_status, gm.created as joined_group, c.name as congregation
				FROM person_group_membership gm 
				JOIN person p ON gm.personid = p.id
				';
        if ($order_by != NULL) {
            $sql .= '
				JOIN family f ON f.id = p.familyid
			';
        }
        $sql .= '
				LEFT JOIN congregation c ON c.id = p.congregationid
				LEFT JOIN person_group_membership_status ms ON ms.id = gm.membership_status
				WHERE gm.groupid = ' . $db->quote((int) $this->id) . '
				';
        if (!$incl_archived) {
            $sql .= ' AND p.status <> "archived"
					';
        }
        if ($order_by == NULL) {
            $order_by = 'ms.rank, p.last_name, p.first_name';
        } else {
            $order_by = preg_replace("/(^|[^.])status(\$| |,)/", '\\1p.status\\2', $order_by);
        }
        $sql .= 'ORDER BY ' . $order_by;
        $res = $db->queryAll($sql, null, null, true);
        check_db_result($res);
        foreach ($res as $k => &$v) {
            $v['joined_group'] = format_date($v['joined_group']);
        }
        return $res;
    }
Example #6
0
 /**
  * Get all folders and files within a folder
  *
  * @param   int     $parent The id of this folder
  * @return  array
  *
  **/
 public static function folder_contents($parent = 0, $type = null)
 {
     // they can also pass a url hash such as #foo/bar/some-other-folder-slug
     if (!is_numeric($parent)) {
         $segment = explode('/', trim($parent, '/#'));
         $result = ci()->file_folders_m->get_by('slug', array_pop($segment));
         $parent = $result ? $result->id : 0;
     }
     $folders = ci()->file_folders_m->where('parent_id', $parent)->where('hidden', 0)->order_by('sort')->get_all();
     // $files = ci()->file_m->where(array('folder_id' => $parent))
     //     ->order_by('sort')
     //     ->get_all();
     $files = ci()->file_m->where(array('folder_id' => $parent, 'type' => $type))->order_by('sort')->get_all();
     // let's be nice and add a date in that's formatted like the rest of the CMS
     if ($folders) {
         foreach ($folders as &$folder) {
             $folder->formatted_date = format_date($folder->date_added);
             $folder->file_count = ci()->file_m->count_by('folder_id', $folder->id);
         }
     }
     if ($files) {
         ci()->load->library('keywords/keywords');
         foreach ($files as &$file) {
             $file->keywords_hash = $file->keywords;
             $file->keywords = ci()->keywords->get_string($file->keywords);
             $file->formatted_date = format_date($file->date_added);
         }
     }
     return Files::result(true, null, null, array('folder' => $folders, 'file' => $files, 'parent_id' => $parent));
 }
Example #7
0
function sca_responsive_sort_repertoire($results)
{
    //  dpm($results);
    $sorted = array('remarks' => array());
    $x = 0;
    $doubled_entries = array(2425 => 2425, 2427 => 2427);
    foreach ($results as $entry) {
        // Views'as kažkodėl dubliuoja visus rezultatus, neturėjau laiko aiškintis kodėl, tad tiesiog atfiltruoju kas antrą.
        if ($x % 2 !== 0 || in_array($entry->nid, $doubled_entries)) {
            //      $x++;
            //      continue;
        }
        // O kai kurie rezultatai (filmų rinkiniai), kažkodėl atrenkami po 4 kartus...
        if (in_array($entry->node_field_data_field_filmas_nid, $doubled_entries)) {
            //      unset($doubled_entries[$entry->node_field_data_field_filmas_nid]);
            //      $x++;
            //      continue;
        }
        $x++;
        $director = !empty($entry->field_field_motrezisierius) ? $entry->field_field_motrezisierius[0]['rendered']['#markup'] : '';
        $director .= !empty($entry->field_field_vyrrezisierius) ? $entry->field_field_vyrrezisierius[0]['rendered']['#markup'] : '';
        $director .= !empty($entry->field_field_daugrezisieriu) ? $entry->field_field_daugrezisieriu[0]['rendered']['#markup'] : '';
        $sorted[$entry->taxonomy_term_data_field_data_field_vieta_tid][] = array('nid' => $entry->node_field_data_field_filmas_nid, 'entry_nid' => $entry->nid, 'alias' => drupal_get_path_alias('node/' . $entry->node_field_data_field_filmas_nid), 'time' => $entry->field_field_data[0]['rendered']['#markup'], 'small_date' => format_date(strtotime($entry->field_field_data_1[0]['raw']['value']), 'kalendoriaus'), 'title' => $entry->field_title_field[0]['rendered']['#markup'], 'title_lt' => $entry->node_field_data_field_filmas_title, 'title_en' => isset($entry->field_field_engpav[0]) ? $entry->field_field_engpav[0]['rendered']['#markup'] : NULL, 'year' => isset($entry->field_field_metaiirtrukme[0]) ? $entry->field_field_metaiirtrukme[0]['rendered']['#markup'] : NULL, 'country' => !empty($entry->field_field_salis) ? $entry->field_field_salis[0]['rendered']['#markup'] : NULL, 'director' => $director, 'color' => !empty($entry->field_field_programos_spalva) ? $entry->field_field_programos_spalva[0]['rendered']['#markup'] : 'fff', 'extra_text' => !empty($entry->field_field_extra_text) ? $entry->field_field_extra_text[0]['rendered']['#markup'] : NULL, 'program_name' => !empty($entry->field_name_field) ? $entry->field_name_field[0]['rendered']['#markup'] : '', 'remarks' => !empty($entry->field_field_rep_iraso_pastabos) ? $entry->field_field_rep_iraso_pastabos[0]['rendered']['#markup'] : '');
        if (!empty($entry->field_field_rep_iraso_pastabos)) {
            $sorted['remarks'][] = array('time' => $entry->field_field_data_2[0]['rendered']['#markup'], 'place' => $entry->field_field_pilnas_pavadinimas[0]['rendered']['#markup'], 'remark' => $entry->field_field_rep_iraso_pastabos[0]['rendered']['#markup']);
        }
    }
    //  dpm($sorted);
    return $sorted;
}
Example #8
0
function alternator_preprocess_node(&$vars)
{
    if (in_array($vars['type'], array('article', 'event'))) {
        unset($vars['links']);
        unset($vars['field_library_ref_rendered']);
        unset($vars['field_list_image_rendered']);
        unset($vars['field_content_images_rendered']);
        unset($vars['field_file_attachments_rendered']);
        #var_dump($vars);
        $vars['submitted'] = format_date($vars['created'], 'large', 'Europe/Copenhagen', 'dk');
        if ($vars['type'] == 'event') {
            $vars['submitted'] = $vars['node']->field_datetime[0]['view'];
            $vars['price'] = $vars['node']->field_entry_price[0]['view'];
        }
        /*
         * 'Unprint' some node elements and rerender. Not really the right
         * way to handle this, but legacy code simply grabbed
         * $node->content['body']['#value'], and redoing it properly would
         * require updating of too many existing sites.
         */
        unset($vars['node']->content['#printed']);
        unset($vars['node']->content['body']['#printed']);
        if (isset($vars['node']->content['place2book_infolink'])) {
            unset($vars['node']->content['place2book_infolink']['#printed']);
        }
        $vars['content'] = drupal_render($vars['node']->content);
    }
}
Example #9
0
 /**
  * Creates a "Basic page" node and verifies its consistency in the database.
  */
 function testNodeCreation()
 {
     $node_type_storage = \Drupal::entityManager()->getStorage('node_type');
     // Test /node/add page with only one content type.
     $node_type_storage->load('article')->delete();
     $this->drupalGet('node/add');
     $this->assertResponse(200);
     $this->assertUrl('node/add/page');
     // Create a node.
     $edit = array();
     $edit['title[0][value]'] = $this->randomMachineName(8);
     $edit['body[0][value]'] = $this->randomMachineName(16);
     $this->drupalPostForm('node/add/page', $edit, t('Save'));
     // Check that the Basic page has been created.
     $this->assertText(t('@post @title has been created.', array('@post' => 'Basic page', '@title' => $edit['title[0][value]'])), 'Basic page created.');
     // Verify that the creation message contains a link to a node.
     $view_link = $this->xpath('//div[@class="messages"]//a[contains(@href, :href)]', array(':href' => 'node/'));
     $this->assert(isset($view_link), 'The message area contains a link to a node');
     // Check that the node exists in the database.
     $node = $this->drupalGetNodeByTitle($edit['title[0][value]']);
     $this->assertTrue($node, 'Node found in database.');
     // Verify that pages do not show submitted information by default.
     $this->drupalGet('node/' . $node->id());
     $this->assertNoText($node->getOwner()->getUsername());
     $this->assertNoText(format_date($node->getCreatedTime()));
     // Change the node type setting to show submitted by information.
     /** @var \Drupal\node\NodeTypeInterface $node_type */
     $node_type = $node_type_storage->load('page');
     $node_type->setDisplaySubmitted(TRUE);
     $node_type->save();
     $this->drupalGet('node/' . $node->id());
     $this->assertText($node->getOwner()->getUsername());
     $this->assertText(format_date($node->getCreatedTime()));
 }
Example #10
0
 function display()
 {
     if (!$_POST and $this->mdl_mcb_data->setting('dashboard_total_paid_cutoff_date')) {
         $this->mdl_mcb_data->set_setting('dashboard_total_paid_cutoff_date', format_date($this->mdl_mcb_data->setting('dashboard_total_paid_cutoff_date')));
     }
     $this->load->view('settings');
 }
Example #11
0
function add_comment_feeditem($item)
{
    global $db, $rss_items, $atom_items, $Cfg, $Weblogs, $Current_weblog, $Allow_RSS, $Paths;
    if (!siteurl_isset()) {
        $weblog = $Paths['host'] . $Paths['pivot_url'];
    } else {
        $weblog = $Weblogs[$Current_weblog]['siteurl'];
    }
    $entry = $db->read_entry($item['code']);
    $link = make_fileurl($item['uid'], "", "");
    $title = $db->entry['title'];
    $date = format_date($item['date'], "%year%-%month%-%day%T%hour24%:%minute%:00") . rss_offset();
    $description = htmlspecialchars(strip_tags($item['comment']));
    $description = str_replace("&nbsp;", " ", $description);
    $id = safe_string($item["name"], TRUE) . "-" . format_date($item["date"], "%ye%%month%%day%%hour24%%minute%");
    $tag = str_replace("_", "", strtolower(safe_string($Cfg['sitename'], TRUE))) . "," . date("Y") . ":" . $id;
    // make sure description is not too long..
    if (isset($Weblogs[$Current_weblog]['rss_full']) && $Weblogs[$Current_weblog]['rss_full'] == 0) {
        // don't put anything in the content.
        $content = "";
    } else {
        // put the introduction and body in the content..
        $content = str_replace("&nbsp;", " ", $introduction . $body);
    }
    if (isemail($item['email'])) {
        $email = "\n<email>" . $item['email'] . "</email>";
    } else {
        $email = "";
    }
    if (isurl($item['url'])) {
        if (strpos($item["url"], "ttp://") < 1) {
            $item["url"] = "http://" . $item["url"];
        }
        $url = "\n<uri>" . $item['url'] . "</uri>";
    } else {
        $url = "";
    }
    $atom_item = '
	<entry>
	    <title>%author% on %title%</title>
	    <link rel="alternate" type="text/html" href="%link%#%id%"/>
	    <updated>%date%</updated>
	    <published>%date%</published>
	    <id>tag:%tag%</id>
	    <summary type="text">%description%</summary>
	    <content type="html" xml:lang="%lang%" xml:base="%link%">
		<![CDATA[ 
			%content%
		]]>
	    </content>
	    <author>
		<name>%author%</name>%url%%email%
	    </author>
	</entry>
';
    $from = array("%title%", "%link%", "%id%", "%description%", "%content%", "%author%", "%guid%", "%date%", "%tag%", "%lang%", "%url%", "%email%");
    $to = array(htmlspecialchars(strip_tags($entry['title'])), $link, $id, RelativeToAbsoluteURLS($description), trim(comment_format($item['comment'])), htmlspecialchars(unentify($item['name'])), $item['uid'] . "@" . $weblog, $date, $tag, snippet_lang(), $url, $email);
    $atom_item = str_replace($from, $to, $atom_item);
    $atom_items[$date] = $atom_item;
}
Example #12
0
function snippet_posted_by($code, $with_tags = true)
{
    $params = array();
    // Contributor parameter is set.
    if ($code->getUserId()) {
        $params['%contributor%'] = link_to($code->getContributor(), 'user/viewProfile?username='******'%contributor%'] = $code->getContributor();
    }
    // Date parameter is set.
    $params['%date%'] = format_date($code->getCreatedAt());
    if ($with_tags) {
        // Tags parameter is set.
        $tag_links = array();
        $tags = explode(', ', $code->getTag());
        for ($i = 0; $i < count($tags); $i++) {
            if ($tags[$i]) {
                $tag_links[$i] = link_to($tags[$i], 'tag/show?tag=' . $tags[$i]);
            }
        }
        $params['%tags%'] = implode(', ', $tag_links);
    }
    if (isset($params['%tags%'])) {
        return __('posted by %contributor% on %date% with tags %tags%', $params);
    } else {
        return __('posted by %contributor% on %date%', $params);
    }
}
/**
 * Override or insert variables into the node template.
 */
function jeugdwerksupport_preprocess_node(&$variables)
{
    $node = $variables['node'];
    // Add template suggestions
    if (!$variables['page']) {
        if ($variables['teaser']) {
            $variables['theme_hook_suggestions'][] = 'node__' . $variables['node']->type . '__teaser';
            $variables['theme_hook_suggestions'][] = 'node__' . $variables['node']->nid . '__teaser';
            $variables['theme_hook_suggestions'][] = 'node__teaser';
        }
    }
    // Add class 'node-full'
    if ($variables['view_mode'] == 'full' && node_is_page($node)) {
        $variables['classes_array'][] = 'node-full';
    }
    // Set custom date format
    $variables['date'] = format_date($node->created, 'custom', 'F jS Y');
    // Add summary variable
    if ($variables['view_mode'] == 'full') {
        $items = field_get_items('node', $node, 'body', $node->language);
        if ($items) {
            // If there's a single summary, just set the summary variable
            if (count($items) == 1) {
                $variables['summary'] = $items[0]['summary'];
            } else {
                foreach ($items as $item) {
                    $variables['summary'][] = $item['summary'];
                }
            }
        }
    }
}
Example #14
0
/**
 * Формирует заголовок таблицы
 * @return [type] [description]
 */
function generete_dates()
{
    $monday = time() - (date("N") - 1) * 24 * 60 * 60;
    $monday = strtotime(format_date($monday));
    $days_array = array(0 => $monday, 1 => strtotime("+1 day", $monday), 2 => strtotime("+2 day", $monday), 3 => strtotime("+3 day", $monday), 4 => strtotime("+4 day", $monday), 5 => strtotime("+5 day", $monday), 6 => strtotime("+6 day", $monday));
    return $days_array;
}
Example #15
0
 /**
  * LOCALE_TRANSLATION_REMOTE
  * and LOCALE_TRANSLATION_LOCAL indicate available new translations,
  * LOCALE_TRANSLATION_CURRENT indicate that the current translation is them
  * most recent.
  */
 protected function projectsStatus()
 {
     $status_report = [];
     $status = locale_translation_get_status();
     foreach ($status as $project_id => $project) {
         foreach ($project as $langcode => $project_info) {
             $info = '';
             if ($project_info->type == LOCALE_TRANSLATION_LOCAL || $project_info->type == LOCALE_TRANSLATION_REMOTE) {
                 $local = isset($project_info->files[LOCALE_TRANSLATION_LOCAL]) ? $project_info->files[LOCALE_TRANSLATION_LOCAL] : null;
                 $remote = isset($project_info->files[LOCALE_TRANSLATION_REMOTE]) ? $project_info->files[LOCALE_TRANSLATION_REMOTE] : null;
                 $local_age = $local->timestamp ? format_date($local->timestamp, 'html_date') : '';
                 $remote_age = $remote->timestamp ? format_date($remote->timestamp, 'html_date') : '';
                 if ($local_age >= $remote_age) {
                     $info = $this->trans('commands.locale.translation.status.messages.translation-project-updated');
                 } else {
                     $info = $this->trans('commands.locale.translation.status.messages.translation-project-available');
                 }
             } elseif ($project_info->type == LOCALE_TRANSLATION_CURRENT) {
                 $info = $this->trans('commands.locale.translation.status.messages.translation-project-updated');
             } else {
                 $local_age = '';
                 $remote_age = '';
                 $info = $this->createInfoString($project_info);
             }
             $status_report[$langcode][] = [$project_info->name, $project_info->version, $local_age, $remote_age, $info];
         }
     }
     return $status_report;
 }
Example #16
0
 /**
  * Date
  *
  * Displays the current date or formats a timestamp that is passed to it.
  * 
  * Usage:
  * {{ helper:date format="Y" }} Outputs: 2011
  * {{ helper:date format="Y" timestamp="2524608000" }} Outputs: 2050
  * 
  * @return string The date and time formatted appropriately.
  */
 public function date()
 {
     $this->load->helper('date');
     $format = $this->attribute('format');
     $timestamp = $this->attribute('timestamp');
     return $timestamp ? format_date($timestamp, $format) : format_date(now(), $format);
 }
Example #17
0
 function getContent()
 {
     $hp = Codendi_HTMLPurifier::instance();
     $content = '';
     if ($this->rss_url) {
         require_once 'common/rss/libs/SimplePie/simplepie.inc';
         if (!is_dir($GLOBALS['codendi_cache_dir'] . '/rss')) {
             mkdir($GLOBALS['codendi_cache_dir'] . '/rss');
         }
         $rss = new SimplePie($this->rss_url, $GLOBALS['codendi_cache_dir'] . '/rss', null, $GLOBALS['sys_proxy']);
         $max_items = 10;
         $items = array_slice($rss->get_items(), 0, $max_items);
         $content .= '<table width="100%">';
         $i = 0;
         foreach ($items as $item) {
             $content .= '<tr class="' . util_get_alt_row_color($i++) . '"><td WIDTH="99%">';
             if ($image = $item->get_link(0, 'image')) {
                 //hack to display twitter avatar
                 $content .= '<img src="' . $hp->purify($image, CODENDI_PURIFIER_CONVERT_HTML) . '" width="48" height="48" style="float:left; margin-right:1em;" />';
             }
             $content .= '<a href="' . $item->get_link() . '">' . $hp->purify($item->get_title(), CODENDI_PURIFIER_STRIP_HTML) . '</a>';
             if ($item->get_date()) {
                 $content .= '<span style="color:#999;" title="' . format_date($GLOBALS['Language']->getText('system', 'datefmt'), $item->get_date('U')) . '"> - ' . DateHelper::timeAgoInWords($item->get_date('U')) . '</span>';
             }
             $content .= '</td></tr>';
         }
         $content .= '</table>';
     }
     return $content;
 }
Example #18
0
function phptemplate_node_submitted($node) {
  return t('!datetime — !username',
    array(
      '!username' => theme('username', $node),
      '!datetime' => format_date($node->created),
    ));
}
Example #19
0
/**
 * @file
 * Template overrides as well as (pre-)process and alter hooks for the
 * cac theme.
 */
function cac_preprocess_node(&$vars)
{
    if (variable_get('node_submitted_' . $vars['node']->type, TRUE)) {
        $date = format_date($vars['node']->created, 'date_type');
        $vars['submitted'] = t('Submitted by !username on !datetime', array('!username' => 'editor', '!datetime' => $date));
    }
}
 function getTable($params)
 {
     $this->defaultUrl = $params['default_url'];
     $content = '';
     $content .= html_build_list_table_top(array($GLOBALS['Language']->getText('plugin_docman', 'view_documenttable_title'), $GLOBALS['Language']->getText('plugin_docman', 'view_documenttable_location'), $GLOBALS['Language']->getText('plugin_docman', 'admin_lock_infos_who'), $GLOBALS['Language']->getText('plugin_docman', 'admin_lock_infos_when')));
     // Get list of all locked documents in the project.
     $dPM = Docman_PermissionsManager::instance($params['group_id']);
     $lockInfos = $dPM->getLockFactory()->getProjectLockInfos($params['group_id']);
     $uH = UserHelper::instance();
     $hp = Codendi_HTMLPurifier::instance();
     require_once dirname(__FILE__) . '/../Docman_ItemFactory.class.php';
     $dIF = new Docman_ItemFactory($params['group_id']);
     $altRowClass = 0;
     foreach ($lockInfos as $row) {
         $trclass = html_get_alt_row_color($altRowClass++);
         $item = $dIF->getItemFromDb($row['item_id']);
         $parent = $dIF->getItemFromDb($item->getParentId());
         $content .= '<tr class="' . $trclass . '">';
         $content .= '<td>' . '<a href="/plugins/docman/?group_id=' . $params['group_id'] . '&action=details&id=' . $item->getId() . '">' . $item->getTitle() . '</a></td>';
         $content .= '<td>';
         if ($dIF->isRoot($parent)) {
             $content .= '</td>';
         } else {
             $content .= '<a href="' . $this->defaultUrl . '&action=show&id=' . $parent->getId() . '">' . $parent->getTitle() . '</a></td>';
         }
         $content .= '<td>' . $hp->purify($uH->getDisplayNameFromUserId($row['user_id'])) . '</td>';
         $content .= '<td>' . format_date($GLOBALS['Language']->getText('system', 'datefmt'), $row['lock_date']) . '</td>';
         $content .= '</tr>';
     }
     $content .= '</table>';
     return $content;
 }
 /**
  * Creates a node, then tests the statistics tokens generated from it.
  */
 function testStatisticsTokenReplacement()
 {
     $language_interface = \Drupal::languageManager()->getCurrentLanguage();
     // Create user and node.
     $user = $this->drupalCreateUser(array('create page content'));
     $this->drupalLogin($user);
     $node = $this->drupalCreateNode(array('type' => 'page', 'uid' => $user->id()));
     // Hit the node.
     $this->drupalGet('node/' . $node->id());
     // Manually calling statistics.php, simulating ajax behavior.
     $nid = $node->id();
     $post = http_build_query(array('nid' => $nid));
     $headers = array('Content-Type' => 'application/x-www-form-urlencoded');
     global $base_url;
     $stats_path = $base_url . '/' . drupal_get_path('module', 'statistics') . '/statistics.php';
     $client = \Drupal::service('http_client_factory')->fromOptions(['config/curl' => [CURLOPT_TIMEOUT => 10]]);
     $client->post($stats_path, array('headers' => $headers, 'body' => $post));
     $statistics = statistics_get($node->id());
     // Generate and test tokens.
     $tests = array();
     $tests['[node:total-count]'] = 1;
     $tests['[node:day-count]'] = 1;
     $tests['[node:last-view]'] = format_date($statistics['timestamp']);
     $tests['[node:last-view:short]'] = format_date($statistics['timestamp'], 'short');
     // Test to make sure that we generated something for each token.
     $this->assertFalse(in_array(0, array_map('strlen', $tests)), 'No empty tokens generated.');
     foreach ($tests as $input => $expected) {
         $output = \Drupal::token()->replace($input, array('node' => $node), array('langcode' => $language_interface->getId()));
         $this->assertEqual($output, $expected, format_string('Statistics token %token replaced.', array('%token' => $input)));
     }
 }
Example #22
0
 public static function oneDate($start_date, $finish_date)
 {
     if (format_date($start_date) == format_date($finish_date)) {
         return date('D, j M Y', strtotime($start_date));
     }
     return date('D, j M Y', strtotime($start_date)) . " - " . date('D, j M Y', strtotime($finish_date));
 }
Example #23
0
 public function excel($startDate, $endDate)
 {
     $arrData = array();
     $allData = $this->Report_Model->getAllUnapprove(null, null, $startDate, $endDate);
     foreach ($allData as $key => $value) {
         //$marketing = $this->Report_Model->getName($value->marketing_id);
         $arrData[$key]["nopaket"] = $value->no_paket;
         $arrData[$key]["nopaketuser"] = $value->no_paket_user;
         $arrData[$key]["agency"] = $value->agency;
         $arrData[$key]["client"] = $value->client;
         $arrData[$key]["requestdate"] = $value->request_date;
         //$arrData[$key]["marketing"] = (isset($marketing->name)) ? $marketing->name : "";
         $arrData[$key]["marketing"] = $value->marketing;
         $allDetail = $this->Order_Model->getDetail($value->no_paket);
         foreach ($allDetail as $keyb => $detail) {
             $ads = $this->Order_Model->getAds($detail->ads_id);
             $kanal = $this->Order_Model->getKanal($detail->kanal_id);
             $productGroup = $this->Order_Model->getProductGroup($detail->product_group_id);
             $position = $this->Order_Model->getPosition($detail->position_id);
             $periode = format_date($detail->start_date, TRUE) . " - " . format_date($detail->end_date, TRUE);
             $arrData[$key]["detail"][$keyb]["iklan"] = $ads->name;
             $arrData[$key]["detail"][$keyb]["kanal"] = $kanal->name;
             $arrData[$key]["detail"][$keyb]["productgroup"] = $productGroup->name;
             $arrData[$key]["detail"][$keyb]["position"] = $position->name;
             $arrData[$key]["detail"][$keyb]["periode"] = $periode;
         }
     }
     $data["all_data"] = $arrData;
     //            $data["yearmonth"] = $yearMonth;
     $data["start_date"] = $startDate;
     $data["end_date"] = $endDate;
     $this->load->view("report/unapprove/excel", $data);
 }
Example #24
0
 /**
  * {@inheritdoc}
  */
 public function form(array $form, array &$form_state)
 {
     $feed = $this->entity;
     $importer = $feed->getImporter();
     $args = array('@importer' => $importer->label(), '@title' => $feed->label());
     if ($this->operation == 'update') {
         drupal_set_title($this->t('<em>Edit @importer</em> @title', $args), PASS_THROUGH);
     } elseif ($this->operation == 'create') {
         drupal_set_title($this->t('<em>Add @importer</em>', $args), PASS_THROUGH);
     }
     $user_config = \Drupal::config('user.settings');
     $form['title'] = array('#type' => 'textfield', '#title' => $this->t('Title'), '#default_value' => $feed->label(), '#required' => TRUE);
     foreach ($importer->getPlugins() as $plugin) {
         if ($plugin instanceof FeedPluginFormInterface) {
             // Store the plugin for validate and submit.
             $this->configurablePlugins[] = $plugin;
             $form = $plugin->buildFeedForm($form, $form_state, $feed);
         }
     }
     $form['advanced'] = array('#type' => 'vertical_tabs', '#weight' => 99);
     // Feed author information for administrators.
     $form['author'] = array('#type' => 'details', '#access' => $this->currentUser()->hasPermission('administer feeds'), '#title' => $this->t('Authoring information'), '#collapsed' => TRUE, '#group' => 'advanced', '#weight' => 90);
     $form['author']['name'] = array('#type' => 'textfield', '#title' => $this->t('Authored by'), '#maxlength' => 60, '#autocomplete_path' => 'user/autocomplete', '#default_value' => $feed->getAuthor()->getUsername(), '#description' => $this->t('Leave blank for %anonymous.', array('%anonymous' => $user_config->get('anonymous'))));
     $form['author']['date'] = array('#type' => 'textfield', '#title' => $this->t('Authored on'), '#maxlength' => 25, '#description' => $this->t('Format: %time. The date format is YYYY-MM-DD and %timezone is the time zone offset from UTC. Leave blank to use the time of form submission.', array('%time' => format_date($feed->getCreatedTime(), 'custom', 'Y-m-d H:i:s O'), '%timezone' => format_date($feed->getCreatedTime(), 'custom', 'O'))));
     // Feed options for administrators.
     $form['options'] = array('#type' => 'details', '#access' => $this->currentUser()->hasPermission('administer feeds'), '#title' => $this->t('Import options'), '#collapsed' => TRUE, '#group' => 'advanced');
     $form['options']['status'] = array('#type' => 'checkbox', '#title' => $this->t('Active'), '#default_value' => $feed->isActive());
     return parent::form($form, $form_state);
 }
 function getContent()
 {
     $html = '';
     $i = 1;
     $UH = UserHelper::instance();
     $hp = Codendi_HTMLPurifier::instance();
     while ($data = db_fetch_array($this->getLatestRevisions())) {
         $html .= '<div class="' . util_get_alt_row_color($i++) . '" style="border-bottom:1px solid #ddd">';
         $html .= '<div style="font-size:0.98em;">';
         $html .= '<a href="' . $this->_getLinkToCommit($data) . '">#' . $data['revision'] . '</a>';
         $html .= ' by ';
         if (isset($data['whoid'])) {
             $name = $UH->getDisplayNameFromUserId($data['whoid']);
         } else {
             $name = $UH->getDisplayNameFromUserName($data['who']);
         }
         $html .= $hp->purify($name, CODENDI_PURIFIER_CONVERT_HTML) . ' on ';
         //In the db, svn dates are stored as int whereas cvs dates are stored as timestamp
         $html .= format_date($GLOBALS['Language']->getText('system', 'datefmt'), is_numeric($data['date']) ? $data['date'] : strtotime($data['date']));
         $html .= '</div>';
         $html .= '<div style="padding-left:20px; padding-bottom:4px; color:#555">';
         $html .= util_make_links(substr($data['description'], 0, 255), $this->group_id);
         if (strlen($data['description']) > 255) {
             $html .= '&nbsp;[...]';
         }
         $html .= '</div>';
         $html .= '</div>';
     }
     $html .= '<div style="text-align:center" class="' . util_get_alt_row_color($i++) . '">';
     $html .= '<a href="' . $this->_getLinkToMore() . '">[ More ]</a>';
     $html .= '</div>';
     return $html;
 }
Example #26
0
/**
 *  Implements hook_preprocess_node().
 */
function dguk_preprocess_node(&$variables)
{
    $variables['classes_array'][] = 'boxed';
    $full_node = node_load($variables['node']->nid);
    $variables['title'] = $full_node->title;
    $variables['theme_hook_suggestions'][] = 'node__' . $variables['view_mode'];
    $variables['theme_hook_suggestions'][] = 'node__' . $variables['node']->type . '__' . $variables['view_mode'];
    if ($variables['node']->type == 'resource' || $variables['node']->type == 'book') {
        $variables['submitted'] = 'Submitted on ' . format_date($variables['created']);
    }
    $variables['updated'] = $variables['created'] != $variables['changed'] ? '| Updated on ' . format_date($variables['changed']) : FALSE;
    // We render user picture only on forum and blog nodes.
    if ($variables['node']->type == 'forum' || $variables['node']->type == 'blog') {
        $fields = field_info_instances('user', 'user');
        $field_id = $fields['field_avatar']['field_id'];
        $user = new stdClass();
        $user->uid = $variables['node']->uid;
        field_attach_load('user', array($user->uid => $user), FIELD_LOAD_CURRENT, array('field_id' => $field_id));
        if (!empty($user->field_avatar)) {
            $field = field_get_items('user', $user, 'field_avatar');
            $image = field_view_value('user', $user, 'field_avatar', $field[0], array('settings' => array('image_style' => 'avatar')));
        } else {
            $image_info = dguk_default_field_image('field_avatar');
            $image = field_view_value('user', $user, 'field_avatar', (array) $image_info, array('settings' => array('image_style' => 'avatar')));
        }
        $colour = $variables['node']->uid % 10;
        if ($variables['node']->uid) {
            $variables['avatar'] = l(render($image), 'user/' . $variables['node']->uid, array('html' => true, 'attributes' => array('class' => array('field-avatar', 'bg-colour-' . $colour))));
        } else {
            $variables['avatar'] = '<div class="field-avatar bg-colour-0">' . render($image) . '</div>';
        }
    }
}
 function daftar()
 {
     /*SELECT
     		a.PENDATAAN_ID,
     		a.JENIS_PUNGUTAN,
     		a.PENDATAAN_NO,
     		a.TGL_PROSES,
     		b.TGL_KIRIM,
     		vp.PEMOHON,
     		vp.NPWP,
     		pp.NO_PENETAPAN,
     		pp.TGL_PENETAPAN
     		from PENDATAAN_SPT a
     		left join spt b on b.PENDAFTARAN_ID=a.PENDAFTARAN_ID
     		left join v_pendaftaran vp on vp.PENDAFTARAN_ID=a.PENDAFTARAN_ID
     		left join penetapan_pr_content ppc on ppc.pendataan_id=a.pendataan_id
     		left join penetapan_pr pp on pp.penetapan_pr_id=ppc.penetapan_pr_id
     		where a.JENIS_PENDATAAN='RETRIBUSI'*/
     if (!isset($_POST['oper'])) {
         $id = $this->uri->segment(3);
         $owhere['where'] = "a.jenis_pendataan='AIRTANAH' ";
         $limit = jqgrid_set_limit('pendataan_spt a', $owhere);
         $limit['where'] = $owhere['where'];
         $response->page = $limit['page'];
         $response->total = $limit['total_pages'];
         $response->records = $limit['records'];
         $result = $this->data_model->get_data($limit)->result_array();
         for ($i = 0; $i < count($result); $i++) {
             $response->rows[$i]['id'] = $result[$i]['PENDATAAN_ID'];
             $sistem_pungutan = $result[$i]['JENIS_PUNGUTAN'] == 'OFFICE' ? 'Office Assestment' : 'Selft Assestment';
             if (isset($result[$i]['TGL_KIRIM'])) {
                 $periode = date('Y', strtotime($result[$i]['TGL_KIRIM']));
             } else {
                 $periode = date('Y', strtotime($result[$i]['TGL_PROSES']));
             }
             $response->rows[$i]['cell'] = array($result[$i]['PENDATAAN_ID'], $sistem_pungutan, $result[$i]['JENIS_PUNGUTAN'], sprintf('%05d', $result[$i]['PENDATAAN_NO']), format_date($result[$i]['PERIODE_AWAL']) . ' - ' . format_date($result[$i]['PERIODE_AKHIR']), $result[$i]['NPWP'], $result[$i]['PEMOHON'], format_date($result[$i]['TGL_PENETAPAN']), $result[$i]['NO_PENETAPAN'], format_date($result[$i]['TGL_PENERIMAAN']), format_date($result[$i]['TGL_PROSES']), format_date($result[$i]['TGL_ENTRY']), substr($result[$i]['NPWP'], 1, strlen($result[$i]['NPWP'])), $result[$i]['MEMO'], date('Y', strtotime($result[$i]['TGL_KIRIM'])), format_date($result[$i]['TGL_KIRIM']), sprintf('%05d', $result[$i]['SPT_NO']), $result[$i]['SPT_ID'], $result[$i]['PENDAFTARAN_ID'], $result[$i]['ALAMAT'], $result[$i]['NAMA_KECAMATAN'], $result[$i]['NAMA_DESA'], format_date($result[$i]['PERIODE_AWAL']), format_date($result[$i]['PERIODE_AKHIR']), $result[$i]['NOMINAL']);
         }
         echo json_encode($response);
     } else {
         $id = $this->input->post('id');
         if ($_POST['oper'] === 'add') {
             $this->insert();
         } else {
             if ($_POST['oper'] === 'edit') {
                 $this->update($id);
             } else {
                 if ($_POST['oper'] === 'del') {
                     if (!$this->data_model->isAbleDelete()) {
                         $this->db->trans_start();
                         if ($this->data_model->delete_rincian_data($id)) {
                             if ($this->data_model->delete_data($id)) {
                             }
                         }
                         $this->db->trans_complete();
                     }
                 }
             }
         }
     }
 }
  /**
   * Tests admin-defined formats in format_date().
   */
  function testAdminDefinedFormatDate() {
    // Create and log in an admin user.
    $this->drupalLogin($this->drupalCreateUser(array('administer site configuration')));

    // Add new date format.
    $edit = array(
      'id' => 'example_style',
      'label' => 'Example Style',
      'date_format_pattern' => 'j M y',
    );
    $this->drupalPostForm('admin/config/regional/date-time/formats/add', $edit, t('Add format'));

    // Add a second date format with a different case than the first.
    $edit = array(
      'id' => 'example_style_uppercase',
      'label' => 'Example Style Uppercase',
      'date_format_pattern' => 'j M Y',
    );
    $this->drupalPostForm('admin/config/regional/date-time/formats/add', $edit, t('Add format'));
    $this->assertText(t('Custom date format added.'));

    $timestamp = strtotime('2007-03-10T00:00:00+00:00');
    $this->assertIdentical(format_date($timestamp, 'example_style', '', 'America/Los_Angeles'), '9 Mar 07');
    $this->assertIdentical(format_date($timestamp, 'example_style_uppercase', '', 'America/Los_Angeles'), '9 Mar 2007');
    $this->assertIdentical(format_date($timestamp, 'undefined_style'), format_date($timestamp, 'fallback'), 'Test format_date() defaulting to `fallback` when $type not found.');
  }
 /**
  * Creates a "Basic page" node and verifies its consistency in the database.
  */
 function testNodeCreation()
 {
     // Test /node/add page with only one content type.
     entity_load('node_type', 'article')->delete();
     $this->drupalGet('node/add');
     $this->assertResponse(200);
     $this->assertUrl('node/add/page');
     // Create a node.
     $edit = array();
     $edit['title[0][value]'] = $this->randomMachineName(8);
     $edit['body[0][value]'] = $this->randomMachineName(16);
     $this->drupalPostForm('node/add/page', $edit, t('Save'));
     // Check that the Basic page has been created.
     $this->assertRaw(t('!post %title has been created.', array('!post' => 'Basic page', '%title' => $edit['title[0][value]'])), 'Basic page created.');
     // Check that the node exists in the database.
     $node = $this->drupalGetNodeByTitle($edit['title[0][value]']);
     $this->assertTrue($node, 'Node found in database.');
     // Verify that pages do not show submitted information by default.
     $this->drupalGet('node/' . $node->id());
     $this->assertNoText($node->getOwner()->getUsername());
     $this->assertNoText(format_date($node->getCreatedTime()));
     // Change the node type setting to show submitted by information.
     $node_type = entity_load('node_type', 'page');
     $node_type->setDisplaySubmitted(TRUE);
     $node_type->save();
     $this->drupalGet('node/' . $node->id());
     $this->assertText($node->getOwner()->getUsername());
     $this->assertText(format_date($node->getCreatedTime()));
 }
 protected function fetch_data()
 {
     $query_alone = "select serialcirc_expl_state_circ, serialcirc_expl_bulletine_date, serialcirc_duration_before_send, num_serialcirc_abt, num_serialcirc_expl_id, serialcirc_virtual, serialcirc_expl_start_date, serialcirc_checked, num_serialcirc_expl_current_empr from serialcirc_diff join serialcirc on num_serialcirc_diff_serialcirc = id_serialcirc left join serialcirc_expl on num_serialcirc_expl_serialcirc = id_serialcirc where num_serialcirc_diff_serialcirc=" . $this->id_serialcirc . " and num_serialcirc_diff_empr =" . $this->empr_id . ($this->expl_id != 0 ? " and num_serialcirc_expl_id=" . $this->expl_id : "");
     $query_grp = "select serialcirc_expl_state_circ, serialcirc_expl_bulletine_date, serialcirc_duration_before_send,num_serialcirc_abt, num_serialcirc_expl_id, serialcirc_virtual, serialcirc_expl_start_date, serialcirc_checked, num_serialcirc_expl_current_empr from serialcirc_diff join serialcirc_group on id_serialcirc_diff = num_serialcirc_group_diff join serialcirc on num_serialcirc_diff_serialcirc = id_serialcirc left join serialcirc_expl on num_serialcirc_expl_serialcirc = id_serialcirc where num_serialcirc_diff_serialcirc=" . $this->id_serialcirc . " and num_serialcirc_group_empr = " . $this->empr_id . ($this->expl_id != 0 ? " and num_serialcirc_expl_id=" . $this->expl_id : "");
     $query = $query_alone . " union " . $query_grp;
     $res = mysql_query($query);
     if (mysql_num_rows($res)) {
         while ($row = mysql_fetch_object($res)) {
             $this->state = $row->serialcirc_expl_state_circ;
             $this->virtual = $row->serialcirc_virtual;
             $this->check_activate = $row->serialcirc_checked;
             $this->num_abt = $row->num_serialcirc_abt * 1;
             $this->expl_id = $row->num_serialcirc_expl_id * 1;
             $this->duration_before_start = $row->serialcirc_duration_before_send;
             $this->bulletine_date = $row->serialcirc_expl_bulletine_date;
             $this->get_expl_infos();
             $this->get_serial_infos();
             $this->get_rank();
             $start_date = $row->serialcirc_expl_start_date;
             if ($start_date != 0) {
                 $this->start_date = format_date($start_date);
             } else {
                 $this->start_date = "";
             }
         }
     }
 }