function index_get($zv_id, $year, $week) { // Load helper $this->load->helper('mijnpluto'); // Get week start and end date $week = start_end_week($year, $week); // Where array $where = array('zv_id' => $zv_id, 'datum >=' => $week['start'], 'datum <=' => $week['end']); // Query database $diensten = $this->dienst->get_many_by($where); // Handle response if (!empty($diensten)) { $this->response(array('status' => 'success', 'data' => $diensten)); } else { $this->response(array('status' => 'failure', 'message' => 'Couldn\'t get any diensten'), REST_Controller::HTTP_NOT_FOUND); } }
function smarty_function_mtarchivelink($args, &$ctx) { $blog = $ctx->stash('blog'); $at = $args['type']; $at or $at = $args['archive_type']; $at or $at = $ctx->stash('current_archive_type'); $ts = $ctx->stash('current_timestamp'); if ($at == 'Monthly') { $ts = substr($ts, 0, 6) . '01000000'; } elseif ($at == 'Daily') { $ts = substr($ts, 0, 8) . '000000'; } elseif ($at == 'Weekly') { require_once "MTUtil.php"; list($ws, $we) = start_end_week($ts); $ts = $ws; } elseif ($at == 'Yearly') { $ts = substr($ts, 0, 4) . '0101000000'; } elseif ($at == 'Individual') { $args['archive_type'] or $args['archive_type'] = $at; return $ctx->tag('EntryPermalink', $args); } elseif ($at == 'Category') { return $ctx->tag('CategoryArchiveLink', $args); } $args['blog_id'] = $blog['blog_id']; global $_archivers; if (!isset($_archivers[$at])) { return ''; } $link_sql = $_archivers[$at]->get_archive_link_sql($ctx, $ts, $at, $args); $link = $ctx->mt->db->archive_link($ts, $at, $link_sql, $args); if ($args['with_index'] && preg_match('/\\/(#.*)$/', $link)) { $blog = $ctx->stash('blog'); $index = $ctx->mt->config('IndexBasename'); $ext = $blog['blog_file_extension']; if ($ext) { $ext = '.' . $ext; } $index .= $ext; $link = preg_replace('/\\/(#.*)?$/', "/{$index}\$1", $link); } return $link; }
function get_range(&$ctx, &$row) { if (is_array($row)) { $week_yr = substr($row[0], 0, 4); $week_wk = substr($row[0], 4); list($y, $m, $d) = week2ymd($week_yr, $week_wk); $period_start = sprintf("%04d%02d%02d000000", $y, $m, $d); } else { $period_start = $row; } return start_end_week($period_start, $ctx->stash('blog')); }
function entry_link($eid, $at = "Individual", $args = null) { $blog_id = intval($args['blog_id']); if (isset($this->_entry_link_cache[$eid . ';' . $at])) { $url = $this->_entry_link_cache[$eid . ';' . $at]; } else { if (preg_match('/Category/', $at)) { $table = ", mt_placement"; $filter = "and placement_entry_id = {$eid}\n and fileinfo_category_id = placement_category_id\n and placement_is_primary = 1"; } if (preg_match('/Page/', $at)) { $entry = $this->fetch_page($eid); } else { $entry = $this->fetch_entry($eid); } $ts = $entry['entry_authored_on']; if (preg_match('/Monthly$/', $at)) { $ts = substr($ts, 0, 6) . '01000000'; } elseif (preg_match('/Daily$/', $at)) { $ts = substr($ts, 0, 8) . '000000'; } elseif (preg_match('/Weekly$/', $at)) { require_once "MTUtil.php"; list($ws, $we) = start_end_week($ts); $ts = $ws; } elseif (preg_match('/Yearly$/', $at)) { $ts = substr($ts, 0, 4) . '0101000000'; } elseif ($at == 'Individual' || $at == 'Page') { $filter .= "and fileinfo_entry_id = {$eid}"; } if ($ts != $entry['entry_authored_on']) { $filter .= " and fileinfo_startdate = '{$ts}'"; } if (preg_match('/Author/', $at)) { $filter .= " and fileinfo_author_id = " . $entry['entry_author_id']; } $sql = "select fileinfo_url, fileinfo_blog_id\n from mt_fileinfo, mt_templatemap {$table}\n where templatemap_id = fileinfo_templatemap_id\n and fileinfo_blog_id = {$blog_id}\n {$filter}\n and templatemap_archive_type = '{$at}'\n and templatemap_is_preferred = 1"; $rows = $this->get_results($sql, ARRAY_A); if (count($rows)) { $link =& $rows[0]; } else { return null; } $blog =& $this->fetch_blog($link['fileinfo_blog_id']); if ($at == 'Page') { $blog_url = $blog['blog_site_url']; } else { $blog_url = $blog['blog_archive_url']; $blog_url or $blog_url = $blog['blog_site_url']; } $blog_url = preg_replace('!(https?://(?:[^/]+))/.*!', '$1', $blog_url); $url = $blog_url . $link['fileinfo_url']; $url = _strip_index($url, $blog); $this->_entry_link_cache[$eid . ';' . $at] = $url; } if ($at != 'Individual' && $at != 'Page') { if (!$args || !isset($args['no_anchor'])) { $url .= '#' . (!$args || isset($args['valid_html']) ? 'a' : '') . sprintf("%06d", $eid); } } return $url; }
public function entry_link($eid, $at = "Individual", $args = null) { $eid = intval($eid); if (isset($this->_entry_link_cache[$eid . ';' . $at])) { $url = $this->_entry_link_cache[$eid . ';' . $at]; } else { $extras['join'] = array('mt_templatemap' => array('condition' => "templatemap_id = fileinfo_templatemap_id")); $filter = ''; if (preg_match('/Category/', $at)) { $extras['join']['mt_placement'] = array('condition' => "fileinfo_category_id = placement_category_id"); $filter = " and placement_entry_id = {$eid}\n and placement_is_primary = 1"; } if (preg_match('/Page/', $at)) { $entry = $this->fetch_page($eid); } else { $entry = $this->fetch_entry($eid); } $ts = $this->db2ts($entry->entry_authored_on); if (preg_match('/Monthly$/', $at)) { $ts = substr($ts, 0, 6) . '01000000'; } elseif (preg_match('/Daily$/', $at)) { $ts = substr($ts, 0, 8) . '000000'; } elseif (preg_match('/Weekly$/', $at)) { require_once "MTUtil.php"; list($ws, $we) = start_end_week($ts); $ts = $ws; } elseif (preg_match('/Yearly$/', $at)) { $ts = substr($ts, 0, 4) . '0101000000'; } elseif ($at == 'Individual' || $at == 'Page') { $filter .= " and fileinfo_entry_id = {$eid}"; } if (preg_match('/(Monthly|Daily|Weekly|Yearly)$/', $at)) { $filter .= " and fileinfo_startdate = '{$ts}'"; } if (preg_match('/Author/', $at)) { $filter .= " and fileinfo_author_id = " . $entry->entry_author_id; } $where .= "templatemap_archive_type = '{$at}'\n and templatemap_is_preferred = 1\n {$filter}"; if (isset($args['blog_id'])) { $where .= " and fileinfo_blog_id = " . $args['blog_id']; } require_once 'class.mt_fileinfo.php'; $finfo = new FileInfo(); $infos = $finfo->Find($where, false, false, $extras); if (empty($infos)) { return null; } $finfo = $infos[0]; $blog = $finfo->blog(); if ($at == 'Page') { $blog_url = $blog->site_url(); } else { $blog_url = $blog->archive_url(); if (empty($blog_url)) { $blog_url = $blog->site_url(); } } require_once 'MTUtil.php'; $blog_url = preg_replace('!(https?://(?:[^/]+))/.*!', '$1', $blog_url); $url = $blog_url . $finfo->fileinfo_url; $url = _strip_index($url, $blog); $this->_entry_link_cache[$eid . ';' . $at] = $url; } if ($at != 'Individual' && $at != 'Page') { if (!$args || !isset($args['no_anchor'])) { $url .= '#' . (!$args || isset($args['valid_html']) ? 'a' : '') . sprintf("%06d", $eid); } } return $url; }
public function get_range($period_start) { $mt = MT::get_instance(); $ctx =& $mt->context(); if (is_array($period_start)) { require_once 'MTUtil.php'; $week_yr = substr($period_start['entry_week_number'], 0, 4); $week_num = substr($period_start['entry_week_number'], 4); list($y, $m, $d) = week2ymd($week_yr, $week_num); $period_start = sprintf("%04d%02d%02d000000", $y, $m, $d); } return start_end_week($period_start, $ctx->stash('blog')); }