本文整理汇总了PHP中Album::where_related方法的典型用法代码示例。如果您正苦于以下问题:PHP Album::where_related方法的具体用法?PHP Album::where_related怎么用?PHP Album::where_related使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Album
的用法示例。
在下文中一共展示了Album::where_related方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: albums
function albums()
{
list($params, $id) = $this->parse_params(func_get_args());
$a = new Album();
if (isset($params['context'])) {
$a->where('id !=', $params['context']);
}
$params['auth'] = $this->auth;
$params['flat'] = true;
$final = $a->where_related('content', 'id', $id)->listing($params);
$this->set_response_data($final);
}
示例2: url
function url($object, $options = array())
{
$model = $object->model;
$tail = '';
$content = false;
if ($model === 'tag') {
$object->slug = $object->name;
if (is_numeric($object->slug)) {
$object->slug = 'tag-' . $object->slug;
}
}
if ($model === 'text') {
$model = $object->page_type > 0 ? 'page' : 'essay';
}
if ($model === 'album' && $object->album_type == 2) {
$model = 'set';
}
if ($model === 'content' && isset($options['album']) && $options['album']) {
if ($options['album']->album_type == 2) {
$actual_album = new Album();
$actual_album->where_related('content', 'id', $object->id)->where('left_id >=', $options['album']->left_id)->where('right_id <=', $options['album']->right_id)->get();
$options['album'] = $actual_album;
}
$model = 'album';
$content_template = $this->get_url('content');
$content_url = $this->url_data['content']['url'];
$tail = $this->segments['content'] . '/' . (strpos($content_url, 'slug') === false ? ':content_id' : ':content_slug') . '/';
if (!$content_template) {
$tail .= 'lightbox/';
}
$content = $object;
$object = $options['album'];
$date = $options['album']->published_on;
} else {
if (isset($options['date'])) {
$date = $options['date']['timestamp'];
}
}
if (isset($options['tag']) && $options['tag'] && strpos($options['tag'], ',') === false && $model !== 'set' && $this->get_url("tag_{$model}")) {
$content_template = $this->get_url($model);
$content_url = $this->url_data[$model]['url'];
if (is_numeric($options['tag'])) {
$options['tag'] = 'tag-' . $options['tag'];
}
$template = str_replace(':tag_slug', str_replace(' ', '+', $options['tag']), $this->urls["tag_{$model}"]);
} else {
if (isset($options['category']) && $options['category'] && $model !== 'set' && isset($this->urls["category_{$model}"])) {
$content_template = $this->get_url($model);
$content_url = $this->url_data[$model]['url'];
$template = str_replace(':category_slug', $options['category'], $this->urls["category_{$model}"]);
} else {
if ($model === 'content' && isset($options['favorite']) && $options['favorite']) {
$template = $this->get_url('favorite');
} else {
if ($model === 'content' && isset($options['feature']) && $options['feature']) {
$template = $this->get_url('feature');
} else {
if (isset($options['limit_to']) && $options['limit_to']) {
$model .= '_' . rtrim($options['limit_to'], 's') . 's';
}
$template = $this->get_url($model);
}
}
}
}
if (!$template) {
if ($model === 'content') {
$template = '/' . $this->segments['content'] . '/:slug/lightbox/';
$tail = '';
} else {
return false;
}
}
$template .= $tail;
$data = array();
if (isset($object->visibility) && (int) $object->visibility === 1 || isset($object->listed) && $object->listed < 1) {
$data['id'] = $data['slug'] = $object->internal_id;
} else {
$data = array('id' => $object->id, 'slug' => $object->slug);
if ($model === 'tag' && is_numeric($data['slug'])) {
$data['slug'] = 'tag-' . $data['slug'];
}
}
if (isset($options['date'])) {
date_default_timezone_set($this->get_tz());
$data['year'] = date('Y', $date);
$data['month'] = date('m', $date);
$data['day'] = date('d', $date);
date_default_timezone_set('UTC');
}
if ($content) {
if ((int) $content->visibility === 1) {
$data['content_id'] = $data['content_slug'] = $content->internal_id;
} else {
$data['content_id'] = $content->id;
$data['content_slug'] = $content->slug;
}
}
preg_match_all('/:([a-z_]+)/', $template, $matches);
foreach ($matches[1] as $magic) {
//.........这里部分代码省略.........
示例3: Album
function do_delete()
{
$a = new Album();
$previews = $a->where_related('cover', 'id', $this->id)->get_iterated();
foreach ($previews as $a) {
$a->reset_covers();
}
$albums = $a->where_related('content', 'id', $this->id)->get_iterated();
foreach ($albums as $a) {
$a->update_counts();
}
$this->clear_cache();
if (empty($this->storage_url)) {
$original = $this->path_to_original();
$info = pathinfo($original);
$mid = preg_replace('/\\.' . $info['extension'] . '$/', '.1600.' . $info['extension'], $original);
unlink($original);
if (file_exists($mid)) {
unlink($mid);
}
if ($this->file_type > 0 && is_dir($original . '_previews')) {
delete_files($original . '_previews', true, 1);
}
if (@rmdir(dirname($original))) {
@rmdir(dirname(dirname($original)));
}
} else {
Shutter::delete_original($this->storage_url);
if (!empty($this->storage_url_midsize)) {
Shutter::delete_original($this->storage_url_midsize);
}
}
Shutter::hook('content.delete', $this->to_array(array('auth' => true)));
$s = new Slug();
$this->db->query("DELETE FROM {$s->table} WHERE id = 'content.{$this->slug}'");
$this->delete();
}
示例4: aggregate
function aggregate($type, $options = array())
{
$options = array_merge(array('featured' => false), $options);
$shared_params = array();
if ($type === 'tag') {
$shared_params['tags'] = $options['tag_slug'];
} else {
if ($type === 'category') {
$shared_params['category'] = $options['category'];
}
}
$album_params = $shared_params;
$date_marker = false;
if ($type === 'date') {
$s = new Setting();
$s->where('name', 'site_timezone')->get();
$tz = new DateTimeZone($s->value);
$offset = $tz->getOffset(new DateTime('now', new DateTimeZone('UTC')));
if ($offset === 0) {
$shift = '';
} else {
$shift = ($offset < 0 ? '-' : '+') . abs($offset);
}
// Need to - the offset here, as we need to shift this timestamp by the inverse of the offset to match DB UTC time.
// For example. Midnight in user's time (say, CT -5) is UTC+5.
$album_params['before'] = $date_marker = strtotime("{$options['year']}-{$options['month']}-{$options['day']} 23:59:59") - $offset;
}
$aggregate = $essay_ids = $album_ids = $content_ids = $updated_album_ids = $exclude_albums = $exclude_content = $sets = $range = array();
$t = new Text();
$t->select('id, featured, featured_image_id, published_on')->where('page_type', 0)->where('published', 1);
if ($type === 'date') {
$t->where("YEAR(FROM_UNIXTIME({$t->table}.published_on{$shift}))", $options['year'])->where("MONTH(FROM_UNIXTIME({$t->table}.published_on{$shift}))", $options['month'])->where("DAY(FROM_UNIXTIME({$t->table}.published_on{$shift}))", $options['day']);
} else {
if ($type === 'tag') {
$t->where_related('tag', 'id', $options['tag']);
} else {
$t->where_related('category', 'id', $options['category']);
}
}
if ($options['featured']) {
$t->where('featured', 1);
}
$t->include_related('album', 'id')->order_by($t->table . '.published_on DESC')->get_iterated();
foreach ($t as $essay) {
$essay_ids[$essay->id] = $essay->published_on;
$aggregate[] = array('type' => 'essay', 'id' => $essay->id, 'date' => $essay->published_on, 'featured' => $essay->featured);
if ($essay->album_id) {
$exclude_albums[] = $essay->album_id;
}
if (is_numeric($essay->featured_image_id)) {
$exclude_content[] = $essay->featured_image_id;
}
}
$a = new Album();
$a->select('id, featured, published_on, left_id, right_id, level')->where('visibility', 0)->where('deleted', 0)->where('total_count >', 0);
if ($type === 'date') {
$a->where("YEAR(FROM_UNIXTIME({$a->table}.published_on{$shift}))", $options['year'])->where("MONTH(FROM_UNIXTIME({$a->table}.published_on{$shift}))", $options['month'])->where("DAY(FROM_UNIXTIME({$a->table}.published_on{$shift}))", $options['day']);
} else {
if ($type === 'tag') {
$a->where_related('tag', 'id', $options['tag']);
} else {
$a->where_related('category', 'id', $options['category']);
}
}
if ($options['featured']) {
$a->where('featured', 1);
}
$a->include_related('content', 'id')->order_by($a->table . '.published_on DESC')->get_iterated();
foreach ($a as $album) {
if (is_numeric($album->content_id)) {
$exclude_content[] = $album->content_id;
}
if (!array_key_exists($album->id, $album_ids) && !in_array($album->id, $exclude_albums)) {
$album_ids[$album->id] = $album->published_on;
$aggregate[] = array('type' => 'album', 'id' => $album->id, 'date' => $album->published_on, 'featured' => $album->featured);
}
if ($album->level < 2) {
$range = array_merge($range, range($album->left_id, $album->right_id));
}
if ($album->level > 1) {
$sets[$album->id] = $album->left_id;
}
}
foreach ($sets as $id => $left) {
if (in_array($left, $range)) {
unset($album_ids[$id]);
foreach ($aggregate as $i => $info) {
if ($info['type'] === 'album' && $info['id'] == $id) {
unset($aggregate[$i]);
}
}
}
}
$c = new Content();
$c->select('id, published_on, featured');
if (!empty($exclude_content)) {
$c->where_not_in('id', $exclude_content);
}
$c->where('visibility', 0)->where('deleted', 0);
if ($type === 'date') {
//.........这里部分代码省略.........
示例5: topics
function topics()
{
list($params, $id) = $this->parse_params(func_get_args());
if ($this->method === 'get') {
$a = new Album();
$params['auth'] = $this->auth;
$params['flat'] = true;
$final = $a->where_related('text', 'id', $id)->listing($params);
$this->set_response_data($final);
} else {
list($text_id, $album_id) = $id;
$text = new Text();
$t = $text->get_by_id($text_id);
if (is_numeric($album_id)) {
$album_id = array($album_id);
} else {
$album_id = explode(',', $album_id);
}
$album = new Album();
$albums = $album->where_in('id', $album_id)->get_iterated();
foreach ($albums as $a) {
if ($this->method === 'post') {
$a->save($t);
} else {
$a->delete($t);
}
}
$this->redirect("/text/{$text_id}");
exit;
}
}