/** * function bdb_idtofile * * <p>Takes the id $id and returns a filepath</p> * * @param string $id string formatted like "prefixYYMMDD-HHMMSS.EXT" * @return string */ function bdb_idtofile($id, $type = null) { $fname = $id . EXT; $date = date_from_id($id); if (!$date) { return false; } $path = CONTENT_DIR . $date['y'] . '/' . $date['m'] . '/'; if ($type == null || $type == BDB_ENTRY) { $path .= $fname; } elseif ($type == BDB_COMMENT) { $path .= $id . '/comments/'; } return $path; }
function entry_dir($id, $month_only = false) { if (!preg_match('|^entry[0-9]{6}-[0-9]{6}$|', $id)) { return false; } $date = date_from_id($id); if ($month_only) { $f = CONTENT_DIR . "{$date['y']}/{$date['m']}/"; } else { $f = CONTENT_DIR . "{$date['y']}/{$date['m']}/{$id}"; } return $f; }
function nextprevlink($nextprev, $v) { global $fpdb; $q =& $fpdb->getQuery(); list($caption, $id) = call_user_func(array(&$q, 'get' . $nextprev)); if (!$id) { return array(); } if ($q->single) { $date = date_from_id($id); if (PRETTYURLS_TITLES) { $title = sanitize_title($caption); } else { $title = $id; } $url = $this->baseurl . "20{$date['y']}/{$date['m']}/{$date['d']}/{$title}/"; if ($v > 0) { $caption = $caption . ' » '; } else { $caption = ' « ' . $caption; } return array($caption, $url); } // else, we build a complete url /* todo: clean up this mess... which means cleaning up the mess above. oh, my! */ $l = $this->baseurl; if (is_numeric($cid = @$this->fp_params['category']) || is_numeric($cid = @$this->fp_params['cat'])) { $l = $this->categorylink($l, $cid); } if (isset($this->fp_params['y']) && $this->fp_params['y']) { $l .= '20' . $this->fp_params['y'] . '/'; if (isset($this->fp_params['m']) && $this->fp_params['m']) { $l .= $this->fp_params['m'] . '/'; if (isset($this->fp_params['d']) && $this->fp_params['d']) { $l .= $this->fp_params['d'] . '/'; } } } $page = 1; if (isset($this->fp_params['paged']) && $this->fp_params['paged'] > 1) { $page = $this->fp_params['paged']; } $page += $v; if ($page > 0) { $l .= 'page/' . $page . '/'; } return array($caption, $l); }
function plugin_calendar_widget() { global $fp_params; $y = isset($fp_params['y']) ? $fp_params['y'] : date('y'); $m = isset($fp_params['m']) ? $fp_params['m'] : date('m'); global $fpdb; $q =& new FPDB_Query(array('fullparse' => false, 'y' => $y, 'm' => $m, 'count' => -1), null); $days = array(); while ($q->hasmore($queryId)) { list($id, $entry) = $q->getEntry($queryId); $date = date_from_id($id); $d = (int) $date['d']; $days[$d] = array(get_day_link($y, $m, str_pad($d, 2, '0', STR_PAD_LEFT)), 'linked-day'); $count++; } // load plugin strings // they're located under plugin.PLUGINNAME/lang/LANGID/ $lang = lang_load('plugin:calendar'); $widget = array(); $widget['subject'] = $lang['plugin']['calendar']['subject']; $widget['content'] = '<ul id="widget_calendar"><li>' . generate_calendar($y, $m, $days) . '</li></ul>'; return $widget; }