示例#1
0
/**
 * Created by IntelliJ IDEA.
 * User: mlui
 * Date: 2/12/2016
 * Time: 11:32 AM
 *
 *
 * @param $context
 * @param int $limit
 * @param int $offset
 * @param $username
 * @return array
 * @throws InvalidParameterException
 */
function bookmark_get_posts($context, $limit = 20, $offset = 0, $username, $from_guid)
{
    if (!$username) {
        $user = elgg_get_logged_in_user_entity();
        throw new InvalidParameterException('registration:usernamenotvalid');
    } else {
        $user = get_user_by_username($username);
        if (!$user) {
            throw new InvalidParameterException('registration:usernamenotvalid');
        }
    }
    $loginUser = elgg_get_logged_in_user_entity();
    if ($from_guid > 0) {
        $offset = $offset + getBookmarkGuidPosition($from_guid, $context, $loginUser);
    }
    if ($context == "all") {
        $params = array('type' => 'object', 'subtype' => 'bookmarks', 'full_view' => false, 'view_toggle_type' => false, 'no_results' => elgg_echo('bookmarks:none'), 'preload_owners' => true, 'distinct' => false, 'limit' => $limit, 'offset' => $offset);
        $bookmarks = elgg_get_entities($params);
    } else {
        if ($context == 'mine') {
            $params = array('type' => 'object', 'subtype' => 'bookmarks', 'container_guid' => $loginUser->guid, 'full_view' => false, 'view_toggle_type' => false, 'no_results' => elgg_echo('bookmarks:none'), 'preload_owners' => true, 'distinct' => false, 'limit' => $limit, 'offset' => $offset);
            $bookmarks = elgg_get_entities($params);
        } else {
            if ($context == 'friends') {
                $bookmarks = elgg_get_entities_from_relationship(array('type' => 'object', 'subtype' => 'bookmarks', 'full_view' => false, 'relationship' => 'friend', 'relationship_guid' => $loginUser->guid, 'relationship_join_on' => 'container_guid', 'no_results' => elgg_echo('bookmarks:none'), 'preload_owners' => true, 'limit' => $limit, 'offset' => $offset));
            } else {
                $params = array('type' => 'object', 'subtype' => 'bookmarks', 'full_view' => false, 'view_toggle_type' => false, 'no_results' => elgg_echo('bookmarks:none'), 'preload_owners' => true, 'distinct' => false, 'limit' => $limit, 'offset' => $offset);
                $bookmarks = elgg_get_entities($params);
            }
        }
    }
    if ($bookmarks) {
        $return = array();
        foreach ($bookmarks as $single) {
            $bookmark['guid'] = $single->guid;
            if ($single->title != null) {
                $bookmark['title'] = $single->title;
            } else {
                $bookmark['title'] = '';
            }
            $bookmark['time_created'] = time_ago($single->time_created);
            if ($single->description != null) {
                if (strlen($single->description) > 300) {
                    $entityString = substr(strip_tags($single->description), 0, 300);
                    $bookmark['description'] = preg_replace('/\\W\\w+\\s*(\\W*)$/', '$1', $entityString) . '...';
                } else {
                    $bookmark['description'] = strip_tags($single->description);
                }
                $bookmark['image_link'] = getImageLink($single->description);
            } else {
                $bookmark['description'] = '';
            }
            $bookmark['address'] = $single->address;
            $bookmark['owner'] = getOwner($single->owner_guid);
            if ($single->tags == null) {
                $bookmark['tags'] = '';
            } else {
                $bookmark['tags'] = implode(",", $single->tags);
            }
            $bookmark['like_count'] = likes_count_number_of_likes($single->guid);
            $bookmark['comment_count'] = api_get_image_comment_count($single->guid);
            $bookmark['like'] = checkLike($single->guid, $loginUser->guid);
            $return[] = $bookmark;
        }
    } else {
        $msg = elgg_echo('bookmarks:none');
        throw new InvalidParameterException($msg);
    }
    return $return;
}
function buildTemplate5(&$stories)
{
    $s &= $stories;
    list($s_1, $s_2, $s_3, $s_4, $s_5, $s_6) = $stories;
    $s_1_image_url = getImageLink($s_1, 'large');
    $s_1_caption = getCaption($s_1);
    $s_2_image_url = getImageLink($s_2, 'small');
    $s_2_caption = getCaption($s_2);
    $s_3_image_url = getImageLink($s_3, 'small');
    $s_3_caption = getCaption($s_3);
    $s_4_image_url = getImageLink($s_4, 'large');
    $s_4_caption = getCaption($s_4);
    $s_5_image_url = getImageLink($s_5, 'small');
    $s_5_caption = getCaption($s_5);
    $s_6_image_url = getImageLink($s_6, 'small');
    $s_6_caption = getCaption($s_6);
    //$code = '<div id="featured_story" class="clearfix">';
    $code = '<div class="clearfix featured_story">';
    $code .= '<div id=story_1_image" class="thumb">' . $s_1_image_url . '</div>';
    $code .= '<div class="storyBlockWrap"><h1 id="story_1_title">' . getStoryLink($s_1) . '</h1>';
    $code .= '<p id="story_1_caption">' . $s_1_caption . '</p>';
    $code .= '<div class="related_story">';
    $code .= '<div id="story_2_image" class="slot">' . $s_2_image_url . '</div>';
    $code .= '<p id="story_2_title">' . getStoryLink($s_2) . '</p>';
    $code .= '</div>';
    $code .= '<div class="related_story">';
    $code .= '<div id="story_3_image" class="slot">' . $s_3_image_url . '</div>';
    $code .= '<p id="story_3_title">' . getStoryLink($s_3) . '</p>';
    $code .= '</div>';
    $code .= '</div><!-- end storyBlockWrap --></div><!-- end featured_story -->';
    //$code .= '<div id="featured_story" class="clearfix">';
    $code .= '<div class="clearfix featured_story">';
    $code .= '<div id=story_4_image" class="thumb">' . $s_4_image_url . '</div>';
    $code .= '<div class="storyBlockWrap"><h1 id="story_4_title">' . getStoryLink($s_4) . '</h1>';
    $code .= '<p id="story_4_caption">' . $s_4_caption . '</p>';
    $code .= '<div class="related_story">';
    $code .= '<div id="story_5_image" class="slot">' . $s_5_image_url . '</div>';
    $code .= '<p id="story_5_title">' . getStoryLink($s_5) . '</p>';
    $code .= '</div>';
    $code .= '<div class="related_story">';
    $code .= '<div id="story_6_image" class="slot">' . $s_6_image_url . '</div>';
    $code .= '<p id="story_6_title">' . getStoryLink($s_6) . '</p>';
    $code .= '</div>';
    $code .= '</div><!-- end storyBlockWrap --></div><!-- end featured_story -->';
    /*
    $code = '<div id="featured-story">';
    $code .= '<div id="story-1-image" style="margin: 0 10px 0 0; float: left">'.$s_1_image_url.'</div>';
    $code .= '<div class="story-content"><p id="story-1-title">'.getStoryLink($s_1).'</p>';
    $code .= '<p id="story-1-caption">'.$s_1_caption.'</p>';
    $code .= '<div id="story-2-image" class="slot" style="width: 40px; height: 30px; float: left; margin: 0 10px 0 0;">'.$s_2_image_url.'</div>';
    $code .= '<p id="story-2-title">'.getStoryLink($s_2).'</p>';
    $code .= '<div id="story-3-image" class="slot" style="width: 40px; height: 30px; float: left; margin: 0 10px 0 0;">'.$s_3_image_url.'</div>';
    $code .= '<p id="story-3-title">'.getStoryLink($s_3).'</p>';
    $code .= '</div>';
    $code .= '<div class="spacer" style="clear: both;">';
    $code .= '</div>';
    $code .= '<div id="story-4-image" style="margin: 0 40px 0 0; float: left">'.$s_4_image_url.'</div>';
    $code .= '<div class="story-content"><p id="story-4-title">'.getStoryLink($s_4).'</p>';
    $code .= '<p id="story-4-caption">'.$s_4_caption.'</p>';
    $code .= '<div id="story-5-image" class="slot" style="width: 40px; height: 30px; float: left; margin: 0 10px 0 0;">'.$s_5_image_url.'</div>';
    $code .= '<p id="story-5-title">'.getStoryLink($s_5).'</p>';
    $code .= '<div id="story-6-image" class="slot" style="width: 40px; height: 30px; float: left; margin: 0 10px 0 0;">'.$s_6_image_url.'</div>';
    $code .= '<p id="story-6-title">'.getStoryLink($s_6).'</p>';
    $code .= '</div>';
    $code .= '</div>';
    */
    return $code;
}
示例#3
0
文件: index.php 项目: rstrietzel/plav
$folders = array();
$imageFiles = array();
$otherFiles = array();
$folderCount = 0;
$imageCount = 0;
foreach (scandir($realDir) as $file) {
    if ($file != '.' and $file != '..') {
        if (is_dir("{$realDir}/{$file}")) {
            $folders[] = array("name" => $file, "file" => "{$realDir}/{$file}", "link" => "{$scriptUrl}{$simplePath}/{$file}");
            $folderCount++;
            exec("exec nohup setsid ./genWebQual.sh  \"{$realDir}/{$file}\" " . THUMB_DIR . " " . THUMB_SIZE . " >> /tmp/log1 2>&1 & sleep 0.1");
            exec("exec nohup setsid ./genWebQual.sh  \"{$realDir}/{$file}\" " . WEB_QUALITY_DIR . " " . WEB_SIZE . " >> /tmp/log1 2>&1 & sleep 0.1");
        } else {
            $ext = strtolower(substr($file, -4));
            if ($ext == ".jpg" or $ext == ".png") {
                $imageFiles[] = array("name" => $file, "file" => "{$realDir}/{$file}", "link" => getImageLink("{$simplePath}/{$file}"));
                $imageCount++;
            } else {
                $otherFiles[] = array("name" => $file, "link" => "{$rootUrl}{$realDir}/{$file}");
            }
        }
    }
}
if ($imageCount > 0) {
    $folders[] = array("name" => "Start Galleria here", "file" => "{$realDir}", "link" => "{$rootUrl}show.php?dir=" . WEB_QUALITY_DIR . "{$simplePath}");
    exec("exec nohup setsid ./genWebQual.sh  \"{$realDir}\" " . THUMB_DIR . " " . THUMB_SIZE . " >> /tmp/log1 2>&1 & sleep 0.1");
    exec("exec nohup setsid ./genWebQual.sh  \"{$realDir}\" " . WEB_QUALITY_DIR . " " . WEB_SIZE . " >> /tmp/log1 2>&1 & sleep 0.1");
}
if (dirname($simplePath) !== '') {
    $parentLink = $scriptUrl . dirname($simplePath);
} else {
示例#4
0
function getRiverActivity($activities, $user, $login_user)
{
    $handle = array();
    $site_url = get_config('wwwroot');
    foreach ($activities as $activity) {
        $userEntity = get_entity($activity->subject_guid);
        $avatar_url = getProfileIcon($userEntity);
        $object_guid = $activity->object_guid;
        $entity = get_entity($object_guid);
        $activity_like = checkLike($activity->object_guid, $login_user->guid);
        $activity_comment_count = getCommentCount($activity);
        $activity_like_count = likes_count_number_of_likes($activity->object_guid);
        $entityString = "";
        $entityTxt = "";
        $icon_url = "";
        $img_url = "";
        $message_board = "";
        $container_entity = "";
        $batch_images = array();
        $isObject = false;
        if ($activity->subtype == "tidypics_batch") {
            $isObject = true;
            $batch_images = getBatchImages($activity->object_guid, $user->guid);
            if (sizeof($batch_images) > 1) {
                $entityTxt = "added the photos to the album";
                $album_guid = $batch_images[0]['container_guid'];
                $activity_like = checkLike($album_guid, $login_user->guid);
                $activity_comment_count = api_get_image_comment_count($album_guid);
                $activity_like_count = likes_count_number_of_likes($album_guid);
            } else {
                if (sizeof($batch_images) == 1) {
                    $activity_like_count = $batch_images[0]['like_count'];
                    $activity_comment_count = $batch_images[0]['comment_count'];
                    $activity_like = $batch_images[0]['like'];
                    $img = get_entity($batch_images[0]['guid']);
                    $original_file_name = $img->originalfilename;
                    $container_entity = get_entity($entity->container_guid);
                    if ($img->title != null) {
                        $entityTxt = "added the photo " . $img->title . " to the album " . $container_entity->title;
                    } else {
                        $entityTxt = "added the photo " . $original_file_name . " to the album " . $container_entity->title;
                    }
                    if ($img->description != null) {
                        if (strlen($img->description) > 300) {
                            $entityString = substr(strip_tags($img->description), 0, 300);
                            $entityString = preg_replace('/\\W\\w+\\s*(\\W*)$/', '$1', $entityString) . '...';
                        } else {
                            $entityString = strip_tags($img->description);
                        }
                    } else {
                        $entityString = '';
                    }
                }
            }
        } else {
            if ($activity->action_type == "create" && $activity->subtype == "album") {
                $isObject = true;
                $album = get_entity($activity->object_guid);
                $entityTxt = "created a new photo album " . $album->title;
                $container_entity = get_entity($entity->container_guid);
                if ($container_entity->type == 'group') {
                    $entityTxt = $entityTxt . ' in the group ' . $container_entity->name;
                }
                $album_cover = $album->getCoverImage();
                $file_name = $album_cover->getFilenameOnFilestore();
                $image_join_date = $album_cover->time_created;
                $position = strrpos($file_name, '/');
                $position = $position + 1;
                $icon_file_name = substr_replace($file_name, 'largethumb', $position, 0);
                $image_icon_url = $site_url . 'services/api/rest/json/?method=image.get_post';
                $image_icon_url = $image_icon_url . '&joindate=' . $image_join_date . '&guid=' . $album_cover->guid . '&name=' . $icon_file_name;
                $image_icon_url = elgg_format_url($image_icon_url);
                $image_url = $site_url . 'services/api/rest/json/?method=image.get_post';
                $image_url = $image_url . '&joindate=' . $image_join_date . '&guid=' . $album_cover->guid . '&name=' . $file_name;
                $image_url = elgg_format_url($image_url);
                $batch_images[] = createAlbumCoverImage($album_cover, $image_join_date, $image_icon_url, $image_url, $user);
            } else {
                if ($activity->action_type == "friend" && $activity->subtype == "") {
                    $isObject = true;
                    $msg = "is now a friend with";
                    $friendEntity = get_entity($activity->object_guid);
                    $entityTxt = $msg . " " . $friendEntity->name;
                    $icon_url = getProfileIcon($friendEntity);
                    $icon_url = elgg_format_url($icon_url);
                    $img_url = getProfileIcon($friendEntity, 'master');
                    //$friendEntity->getIconURL('master');
                    if (strpos($img_url, 'user/defaultmaster.gif') !== false) {
                        $img_url = getProfileIcon($friendEntity, 'large');
                        //$friendEntity->getIconURL('large');
                    }
                    $img_url = elgg_format_url($img_url);
                } else {
                    if ($activity->action_type == "update" && $activity->view == 'river/user/default/profileiconupdate') {
                        $isObject = true;
                        $entityTxt = "has a new avatar";
                        $entityString = "";
                        $timeCreated = time_ago($activity->posted);
                        $batch_images[] = createProfileImageBatch($activity->object_guid, $timeCreated, $userEntity);
                    } else {
                        if ($activity->subtype == "comment" && $activity->action_type == "comment" && $activity->view == 'river/object/comment/album') {
                            $isObject = true;
                            $album_comment = get_entity($activity->object_guid);
                            $album_entity = '';
                            if ($album_comment) {
                                $album_entity = get_entity($album_comment->container_guid);
                            }
                            $entityTxt = 'comment on album ' . $album_entity->title;
                            $entityString = $album_comment->description;
                            $entityString = strip_tags($entityString);
                        } else {
                            if ($activity->subtype == "file" && $activity->action_type == "create" && $activity->view == 'river/object/file/create') {
                                $isObject = true;
                                $container_entity = get_entity($entity->container_guid);
                                if ($container_entity->type == 'group') {
                                    $entityTxt = 'uploaded the file ' . $entity->title . ' in the group ' . $container_entity->name;
                                } else {
                                    $entityTxt = 'uploaded the file ' . $entity->title;
                                }
                                if ($entity->description != null) {
                                    $entityString = $entity->description;
                                    $entityString = strip_tags($entityString);
                                } else {
                                    $entityString = $entity->title;
                                }
                                $simpletype = $entity->simpletype;
                                if ($simpletype == "image") {
                                    $activity->type = 'image';
                                    $icon_url = $site_url . 'services/api/rest/json/?method=file.get_post' . '&guid=' . $entity->guid . '&size=largethumb';
                                    $icon_url = elgg_format_url($icon_url);
                                    $img_url = $site_url . 'services/api/rest/json/?method=file.get_post' . '&guid=' . $entity->guid . '&size=original';
                                    $img_url = elgg_format_url($img_url);
                                } else {
                                    $activity->type = 'download';
                                    $icon_url = getProfileIcon($entity, 'large');
                                    //elgg_format_url($entity->getIconURL('large'));
                                    $img_url = $site_url . 'services/api/rest/json/?method=file.get_post' . '&guid=' . $entity->guid . '&size=' . $entity->originalfilename;
                                    $img_url = elgg_format_url($img_url);
                                }
                            } else {
                                if ($activity->subtype == "comment" && $activity->action_type == "comment" && $activity->view == 'river/object/comment/create') {
                                    $isObject = true;
                                    $file_entity = get_entity($activity->target_guid);
                                    if ($file_entity->title) {
                                        $entityTxt = 'comment on ' . $file_entity->title;
                                    } else {
                                        $entityTxt = 'comment on post';
                                    }
                                    $entityString = $entity->description;
                                    $entityString = strip_tags($entityString);
                                } else {
                                    if ($activity->action_type == "comment" && $activity->subtype == "comment" && $activity->view == 'river/object/comment/image') {
                                        $isObject = true;
                                        $image_entity = get_entity($activity->target_guid);
                                        $image_file_name = $image_entity->originalfilename;
                                        if ($image_file_name) {
                                            $entityTxt = 'comment on photo ' . $image_file_name;
                                        } else {
                                            $entityTxt = 'comment on post';
                                        }
                                        $entityString = $entity->description;
                                        $entityString = strip_tags($entityString);
                                    } else {
                                        if ($activity->action_type == "create" && $activity->subtype == "thewire" && $activity->view == 'river/object/thewire/create') {
                                            $isObject = true;
                                            $entityTxt = 'posted to the wire';
                                            $entityString = $entity->description;
                                            $entityString = strip_tags($entityString);
                                        } else {
                                            if ($activity->action_type == "create" && $activity->view == 'river/group/create') {
                                                $isObject = true;
                                                $entityTxt = 'created the group ' . $entity->name;
                                                $entityString = strip_tags($entity->description);
                                            } else {
                                                if ($activity->action_type == "join" && $activity->view == 'river/relationship/member/create') {
                                                    $isObject = true;
                                                    $entityTxt = 'joined the group ' . $entity->name;
                                                    $entityString = strip_tags($entity->description);
                                                } else {
                                                    if ($activity->action_type == "messageboard" && $activity->view == 'river/object/messageboard/create') {
                                                        $isObject = true;
                                                        $post_on_entity = get_entity($activity->object_guid);
                                                        $message_board = elgg_get_annotation_from_id($activity->annotation_id);
                                                        $entityTxt = 'posted on ' . $post_on_entity->name . '\'s message board';
                                                        $entityString = strip_tags($message_board->value);
                                                    } else {
                                                        if ($activity->action_type == "create" && $activity->view == 'river/object/blog/create' && $activity->subtype == 'blog') {
                                                            $isObject = true;
                                                            $container_entity = get_entity($entity->container_guid);
                                                            if ($container_entity->type == 'group') {
                                                                $entityTxt = 'published a blog post ' . $entity->title . ' in the group ' . $container_entity->name;
                                                            } else {
                                                                $entityTxt = 'published a blog post ' . $entity->title;
                                                            }
                                                            if ($entity->description != null) {
                                                                if (strlen($entity->description) > 300) {
                                                                    $entityString = substr(strip_tags($entity->description), 0, 300);
                                                                    $entityString = preg_replace('/\\W\\w+\\s*(\\W*)$/', '$1', $entityString) . '...';
                                                                } else {
                                                                    $entityString = strip_tags($entity->description);
                                                                }
                                                            } else {
                                                                $entityString = '';
                                                            }
                                                        } else {
                                                            if ($activity->subtype == "bookmarks" && $activity->action_type == "create" && $activity->view == 'river/object/bookmarks/create') {
                                                                $isObject = true;
                                                                $entity = get_entity($activity->object_guid);
                                                                $container_entity = get_entity($entity->container_guid);
                                                                if ($container_entity->type == 'group') {
                                                                    $entityTxt = 'bookmarked ' . $entity->title . ' in the group ' . $container_entity->name;
                                                                } else {
                                                                    $entityTxt = 'bookmarked ' . $entity->title;
                                                                }
                                                                if ($entity->description != null) {
                                                                    $icon_url = getImageLink($entity->description);
                                                                    if (strlen($entity->description) > 300) {
                                                                        $entityString = substr(strip_tags($entity->description), 0, 300);
                                                                        $entityString = preg_replace('/\\W\\w+\\s*(\\W*)$/', '$1', $entityString) . '...';
                                                                    } else {
                                                                        $entityString = $entity->description;
                                                                    }
                                                                } else {
                                                                    $entityString = '';
                                                                }
                                                                $entityString = strip_tags($entityString);
                                                                $img_url = $entity->address;
                                                            } else {
                                                                if ($activity->subtype == "discussion_reply" && $activity->action_type == "reply" && $activity->view == 'river/object/discussion_reply/create') {
                                                                    $isObject = true;
                                                                    $target_entity = get_entity($activity->target_guid);
                                                                    $entityTxt = 'replied on the discussion topic ' . $target_entity->title;
                                                                    $entityString = $entity->description;
                                                                    $entityString = strip_tags($entityString);
                                                                } else {
                                                                    if ($activity->subtype == "groupforumtopic" && $activity->action_type == "create" && $activity->view == 'river/object/groupforumtopic/create') {
                                                                        $isObject = true;
                                                                        $container_entity = get_entity($entity->container_guid);
                                                                        $entityTxt = 'added a new discussion topic ' . $entity->title . ' in the group ' . $container_entity->name;
                                                                        if ($entity->description != null) {
                                                                            if (strlen($entity->description) > 300) {
                                                                                $entityString = substr(strip_tags($entity->description), 0, 300);
                                                                                $entityString = preg_replace('/\\W\\w+\\s*(\\W*)$/', '$1', $entityString) . '...';
                                                                            } else {
                                                                                $entityString = $entity->description;
                                                                            }
                                                                            $entityString = strip_tags($entityString);
                                                                        } else {
                                                                            $entityString = '';
                                                                        }
                                                                    } else {
                                                                        //$isObject = true;
                                                                        //$entityTxt = get_object_entity_as_row($activity->object_guid)->description;
                                                                    }
                                                                }
                                                            }
                                                        }
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
        if ($isObject) {
            $handle[] = array('id' => $activity->id, 'time' => time_ago($activity->posted), 'type' => $activity->type, 'sub_type' => $activity->subtype, 'action_type' => $activity->action_type, 'object_guid' => $activity->object_guid, 'subject_guid' => $activity->subject_guid, 'view' => $activity->view, 'string' => $entityString, 'txt' => $entityTxt, 'name' => $userEntity->name, 'username' => $userEntity->username, 'avatar_url' => $avatar_url, 'icon_url' => $icon_url, 'img_url' => $img_url, 'like_count' => $activity_like_count, 'like' => $activity_like, 'comment_count' => $activity_comment_count, 'batch_images' => $batch_images);
        }
    }
    return $handle;
}