public function sample() { add_page_info("title", " Home " . ($this->type ? "- " . $this->type : "")); add_page_info("stylesheet", "main", "main-style"); add_page_info("javascript", "main", "main-script"); add_page_content("container", "container"); add_page_content("top_nav", 'sample/top_nav/content'); add_page_content("user_nav", 'sample/top_nav/user_nav/content'); add_page_content("page_header", 'sample/page_header/content'); add_page_content("page_top_menu", 'sample/page_top_menu/content'); add_page_content("page_content", 'sample/page_content/content'); add_page_content("left_sidebar", 'sample/page_content/left_sidebar/content'); add_page_content("right_sidebar", 'sample/page_content/right_sidebar/content'); add_page_content("page_footer", 'sample/page_footer/content'); set_active("collapse_side_nav_link", true); $this->load->view('template/frame', $this->data); }
function bookmarklet_content(&$a) { if (!local_user()) { $o = '<h2>' . t('Login') . '</h2>'; $o .= login($a->config['register_policy'] == REGISTER_CLOSED ? false : true); return $o; } $referer = normalise_link($_SERVER["HTTP_REFERER"]); $page = normalise_link($a->get_baseurl() . "/bookmarklet"); if (!strstr($referer, $page)) { $content = add_page_info($_REQUEST["url"]); $x = array('is_owner' => true, 'allow_location' => $a->user['allow_location'], 'default_location' => $a->user['default-location'], 'nickname' => $a->user['nickname'], 'lockstate' => is_array($a->user) && (strlen($a->user['allow_cid']) || strlen($a->user['allow_gid']) || strlen($a->user['deny_cid']) || strlen($a->user['deny_gid'])) ? 'lock' : 'unlock', 'default_perms' => get_acl_permissions($a->user), 'acl' => populate_acl($a->user, true), 'bang' => '', 'visitor' => 'block', 'profile_uid' => local_user(), 'acl_data' => construct_acl_data($a, $a->user), 'title' => trim($_REQUEST["title"], "*"), 'content' => $content); $o = status_editor($a, $x, 0, false); $o .= "<script>window.resizeTo(800,550);</script>"; } else { $o = '<h2>' . t('The post was created') . '</h2>'; $o .= "<script>window.close()</script>"; } return $o; }
function add_page_info_to_body($body, $texturl = false, $no_photos = false) { logger('add_page_info_to_body: fetch page info for body ' . $body, LOGGER_DEBUG); $URLSearchString = "^\\[\\]"; // Adding these spaces is a quick hack due to my problems with regular expressions :) preg_match("/[^!#@]\\[url\\]([{$URLSearchString}]*)\\[\\/url\\]/ism", " " . $body, $matches); if (!$matches) { preg_match("/[^!#@]\\[url\\=([{$URLSearchString}]*)\\](.*?)\\[\\/url\\]/ism", " " . $body, $matches); } // Convert urls without bbcode elements if (!$matches and $texturl) { preg_match("/([^\\]\\='" . '"' . "]|^)(https?\\:\\/\\/[a-zA-Z0-9\\:\\/\\-\\?\\&\\;\\.\\=\\_\\~\\#\\%\$\\!\\+\\,]+)/ism", " " . $body, $matches); // Yeah, a hack. I really hate regular expressions :) if ($matches) { $matches[1] = $matches[2]; } } if ($matches) { $footer = add_page_info($matches[1], $no_photos); } // Remove the link from the body if the link is attached at the end of the post if (isset($footer) and trim($footer) != "" and strpos($footer, $matches[1])) { $removedlink = trim(str_replace($matches[1], "", $body)); if ($removedlink == "" or strstr($body, $removedlink)) { $body = $removedlink; } $url = str_replace(array('/', '.'), array('\\/', '\\.'), $matches[1]); $removedlink = preg_replace("/\\[url\\=" . $url . "\\](.*?)\\[\\/url\\]/ism", '', $body); if ($removedlink == "" or strstr($body, $removedlink)) { $body = $removedlink; } } // Add the page information to the bottom if (isset($footer) and trim($footer) != "") { $body .= $footer; } return $body; }
<?php set_active("bdcisubjectslink", true); add_page_content("dashboard_curriculums_content", "management/dashboard/curriculums/info/subjects/page_content/content"); add_page_content("dashboard_curriculums_content_title", "Curriculum Subjects"); add_page_content("page_action_menu", "management/dashboard/curriculums/info/subjects/page_action_menu/content"); add_page_info("javascript", "select-all-checkbox", "select-all-checkbox-script"); set_link_url("backlink", site_url("dashboard/curriculums/" . ($curriculuminfo ? $curriculuminfo->getCurriculumid() : 0))); set_hide_this("backlink", false); set_hide_this("refreshlink", false); set_link_url("refreshlink", current_url() . (has_value("filtercurriculumsubjects") ? "?filter=" . get_value("filtercurriculumsubjects") . (has_value("fcurriculumsubjectsyearlevel") ? "&fyearlevel=" . get_value("fcurriculumsubjectsyearlevel") : "") . (has_value("fcurriculumsubjectssemester") ? "&fsemester=" . get_value("fcurriculumsubjectssemester") : "") . (has_value("searchcurriculumsubjects") ? "&search=" . get_value("searchcurriculumsubjects") . (has_value("searchcurriculumsubjectskey") ? "&searchkey=" . get_value("searchcurriculumsubjectskey") : "") : "") : (has_value("searchcurriculumsubjects") ? "?search=" . get_value("searchcurriculumsubjects") . (has_value("searchcurriculumsubjectskey") ? "&searchkey=" . get_value("searchcurriculumsubjectskey") : "") : ""))); $this->load->view("management/dashboard/curriculums/info/subjects/view");
<?php add_page_info("stylesheet", "main", "main-style"); add_page_info("javascript", "main", "main-script"); add_page_content("container", "container-fluid"); add_page_content("top_nav", 'management/dashboard/top_nav/content'); add_page_content("user_nav", 'management/dashboard/top_nav/user_nav/content'); add_page_content("collapse_side_nav", 'management/dashboard/top_nav/collapse_side_nav/content'); add_page_content("page_header", "management/dashboard/page_header/content"); add_page_content("page_top_menu", 'management/dashboard/page_top_menu/content'); add_page_content("page_content", 'management/dashboard/page_content/container'); $breadcrumb = array("name" => "bdashboardlink", "text" => 'Dashboard', "uri" => "dashboard"); add_breadcrumb($breadcrumb); add_page_content("page_footer", 'management/dashboard/page_footer/content'); $this->load->view('management/template/frame');
<?php set_active("bdccreatelink", true); add_page_info("stylesheet", "spinner/bootstrap-spinner", "spinner-style"); add_page_info("javascript", "spinner/jquery.spinner", "spinner-script"); $this->load->view("management/dashboard/curriculums/create/view");
function ostatus_import($xml, $importer, &$contact, &$hub) { $a = get_app(); logger("Import OStatus message", LOGGER_DEBUG); if ($xml == "") { return; } $doc = new DOMDocument(); @$doc->loadXML($xml); $xpath = new DomXPath($doc); $xpath->registerNamespace('atom', "http://www.w3.org/2005/Atom"); $xpath->registerNamespace('thr', "http://purl.org/syndication/thread/1.0"); $xpath->registerNamespace('georss', "http://www.georss.org/georss"); $xpath->registerNamespace('activity', "http://activitystrea.ms/spec/1.0/"); $xpath->registerNamespace('media', "http://purl.org/syndication/atommedia"); $xpath->registerNamespace('poco', "http://portablecontacts.net/spec/1.0"); $xpath->registerNamespace('ostatus', "http://ostatus.org/schema/1.0"); $xpath->registerNamespace('statusnet', "http://status.net/schema/api/1/"); $gub = ""; $hub_attributes = $xpath->query("/atom:feed/atom:link[@rel='hub']")->item(0)->attributes; if (is_object($hub_attributes)) { foreach ($hub_attributes as $hub_attribute) { if ($hub_attribute->name == "href") { $hub = $hub_attribute->textContent; logger("Found hub " . $hub, LOGGER_DEBUG); } } } $header = array(); $header["uid"] = $importer["uid"]; $header["network"] = NETWORK_OSTATUS; $header["type"] = "remote"; $header["wall"] = 0; $header["origin"] = 0; $header["gravity"] = GRAVITY_PARENT; // it could either be a received post or a post we fetched by ourselves // depending on that, the first node is different $first_child = $doc->firstChild->tagName; if ($first_child == "feed") { $entries = $xpath->query('/atom:feed/atom:entry'); } else { $entries = $xpath->query('/atom:entry'); } $conversation = ""; $conversationlist = array(); $item_id = 0; // Reverse the order of the entries $entrylist = array(); foreach ($entries as $entry) { $entrylist[] = $entry; } foreach (array_reverse($entrylist) as $entry) { $mention = false; // fetch the author if ($first_child == "feed") { $author = ostatus_fetchauthor($xpath, $doc->firstChild, $importer, $contact); } else { $author = ostatus_fetchauthor($xpath, $entry, $importer, $contact); } $item = array_merge($header, $author); // Now get the item $item["uri"] = $xpath->query('atom:id/text()', $entry)->item(0)->nodeValue; $r = q("SELECT `id` FROM `item` WHERE `uid` = %d AND `uri` = '%s'", intval($importer["uid"]), dbesc($item["uri"])); if ($r) { logger("Item with uri " . $item["uri"] . " for user " . $importer["uid"] . " already existed under id " . $r[0]["id"], LOGGER_DEBUG); continue; } $item["body"] = add_page_info_to_body(html2bbcode($xpath->query('atom:content/text()', $entry)->item(0)->nodeValue)); $item["object-type"] = $xpath->query('activity:object-type/text()', $entry)->item(0)->nodeValue; if ($item["object-type"] == ACTIVITY_OBJ_BOOKMARK or $item["object-type"] == ACTIVITY_OBJ_EVENT) { $item["title"] = $xpath->query('atom:title/text()', $entry)->item(0)->nodeValue; $item["body"] = $xpath->query('atom:summary/text()', $entry)->item(0)->nodeValue; } elseif ($item["object-type"] == ACTIVITY_OBJ_QUESTION) { $item["title"] = $xpath->query('atom:title/text()', $entry)->item(0)->nodeValue; } $item["object"] = $xml; $item["verb"] = $xpath->query('activity:verb/text()', $entry)->item(0)->nodeValue; // To-Do: // Delete a message if ($item["verb"] == "qvitter-delete-notice") { // ignore "Delete" messages (by now) continue; } if ($item["verb"] == ACTIVITY_JOIN) { // ignore "Join" messages continue; } if ($item["verb"] == ACTIVITY_FOLLOW) { // ignore "Follow" messages continue; } if ($item["verb"] == ACTIVITY_FAVORITE) { // ignore "Favorite" messages continue; } $item["created"] = $xpath->query('atom:published/text()', $entry)->item(0)->nodeValue; $item["edited"] = $xpath->query('atom:updated/text()', $entry)->item(0)->nodeValue; $conversation = $xpath->query('ostatus:conversation/text()', $entry)->item(0)->nodeValue; $related = ""; $inreplyto = $xpath->query('thr:in-reply-to', $entry); if (is_object($inreplyto->item(0))) { foreach ($inreplyto->item(0)->attributes as $attributes) { if ($attributes->name == "ref") { $item["parent-uri"] = $attributes->textContent; } if ($attributes->name == "href") { $related = $attributes->textContent; } } } $georsspoint = $xpath->query('georss:point', $entry); if ($georsspoint) { $item["coord"] = $georsspoint->item(0)->nodeValue; } // To-Do // $item["location"] = $categories = $xpath->query('atom:category', $entry); if ($categories) { foreach ($categories as $category) { foreach ($category->attributes as $attributes) { if ($attributes->name == "term") { $term = $attributes->textContent; if (strlen($item["tag"])) { $item["tag"] .= ','; } $item["tag"] .= "#[url=" . $a->get_baseurl() . "/search?tag=" . $term . "]" . $term . "[/url]"; } } } } $self = ""; $enclosure = ""; $links = $xpath->query('atom:link', $entry); if ($links) { $rel = ""; $href = ""; $type = ""; $length = "0"; $title = ""; foreach ($links as $link) { foreach ($link->attributes as $attributes) { if ($attributes->name == "href") { $href = $attributes->textContent; } if ($attributes->name == "rel") { $rel = $attributes->textContent; } if ($attributes->name == "type") { $type = $attributes->textContent; } if ($attributes->name == "length") { $length = $attributes->textContent; } if ($attributes->name == "title") { $title = $attributes->textContent; } } if ($rel != "" and $href != "") { switch ($rel) { case "alternate": $item["plink"] = $href; if ($item["object-type"] == ACTIVITY_OBJ_QUESTION or $item["object-type"] == ACTIVITY_OBJ_EVENT) { $item["body"] .= add_page_info($href); } break; case "ostatus:conversation": $conversation = $href; break; case "enclosure": $enclosure = $href; if (strlen($item["attach"])) { $item["attach"] .= ','; } $item["attach"] .= '[attach]href="' . $href . '" length="' . $length . '" type="' . $type . '" title="' . $title . '"[/attach]'; break; case "related": if ($item["object-type"] != ACTIVITY_OBJ_BOOKMARK) { if (!isset($item["parent-uri"])) { $item["parent-uri"] = $href; } if ($related == "") { $related = $href; } } else { $item["body"] .= add_page_info($href); } break; case "self": $self = $href; break; case "mentioned": // Notification check if ($importer["nurl"] == normalise_link($href)) { $mention = true; } break; } } } } $local_id = ""; $repeat_of = ""; $notice_info = $xpath->query('statusnet:notice_info', $entry); if ($notice_info and $notice_info->length > 0) { foreach ($notice_info->item(0)->attributes as $attributes) { if ($attributes->name == "source") { $item["app"] = strip_tags($attributes->textContent); } if ($attributes->name == "local_id") { $local_id = $attributes->textContent; } if ($attributes->name == "repeat_of") { $repeat_of = $attributes->textContent; } } } // Is it a repeated post? if ($repeat_of != "") { $activityobjects = $xpath->query('activity:object', $entry)->item(0); if (is_object($activityobjects)) { $orig_uri = $xpath->query("activity:object/atom:id", $activityobjects)->item(0)->nodeValue; if (!isset($orig_uri)) { $orig_uri = $xpath->query('atom:id/text()', $activityobjects)->item(0)->nodeValue; } $orig_links = $xpath->query("activity:object/atom:link[@rel='alternate']", $activityobjects); if ($orig_links and $orig_links->length > 0) { foreach ($orig_links->item(0)->attributes as $attributes) { if ($attributes->name == "href") { $orig_link = $attributes->textContent; } } } if (!isset($orig_link)) { $orig_link = $xpath->query("atom:link[@rel='alternate']", $activityobjects)->item(0)->nodeValue; } if (!isset($orig_link)) { $orig_link = ostatus_convert_href($orig_uri); } $orig_body = $xpath->query('activity:object/atom:content/text()', $activityobjects)->item(0)->nodeValue; if (!isset($orig_body)) { $orig_body = $xpath->query('atom:content/text()', $activityobjects)->item(0)->nodeValue; } $orig_created = $xpath->query('atom:published/text()', $activityobjects)->item(0)->nodeValue; $orig_contact = $contact; $orig_author = ostatus_fetchauthor($xpath, $activityobjects, $importer, $orig_contact); //if (!intval(get_config('system','wall-to-wall_share'))) { // $prefix = share_header($orig_author['author-name'], $orig_author['author-link'], $orig_author['author-avatar'], "", $orig_created, $orig_link); // $item["body"] = $prefix.add_page_info_to_body(html2bbcode($orig_body))."[/share]"; //} else { $item["author-name"] = $orig_author["author-name"]; $item["author-link"] = $orig_author["author-link"]; $item["author-avatar"] = $orig_author["author-avatar"]; $item["body"] = add_page_info_to_body(html2bbcode($orig_body)); $item["created"] = $orig_created; $item["uri"] = $orig_uri; $item["plink"] = $orig_link; //} $item["verb"] = $xpath->query('activity:verb/text()', $activityobjects)->item(0)->nodeValue; $item["object-type"] = $xpath->query('activity:object/activity:object-type/text()', $activityobjects)->item(0)->nodeValue; if (!isset($item["object-type"])) { $item["object-type"] = $xpath->query('activity:object-type/text()', $activityobjects)->item(0)->nodeValue; } } } //if ($enclosure != "") // $item["body"] .= add_page_info($enclosure); if (isset($item["parent-uri"])) { $r = q("SELECT `id` FROM `item` WHERE `uid` = %d AND `uri` = '%s'", intval($importer["uid"]), dbesc($item["parent-uri"])); if (!$r and $related != "") { $reply_path = str_replace("/notice/", "/api/statuses/show/", $related) . ".atom"; if ($reply_path != $related) { logger("Fetching related items for user " . $importer["uid"] . " from " . $reply_path, LOGGER_DEBUG); $reply_xml = fetch_url($reply_path); $reply_contact = $contact; ostatus_import($reply_xml, $importer, $reply_contact, $reply_hub); // After the import try to fetch the parent item again $r = q("SELECT `id` FROM `item` WHERE `uid` = %d AND `uri` = '%s'", intval($importer["uid"]), dbesc($item["parent-uri"])); } } if ($r) { $item["type"] = 'remote-comment'; $item["gravity"] = GRAVITY_COMMENT; } } else { $item["parent-uri"] = $item["uri"]; } $item_id = ostatus_completion($conversation, $importer["uid"], $item); if (!$item_id) { logger("Error storing item", LOGGER_DEBUG); continue; } logger("Item was stored with id " . $item_id, LOGGER_DEBUG); $item["id"] = $item_id; if ($mention) { $u = q("SELECT `notify-flags`, `language`, `username`, `email` FROM user WHERE uid = %d LIMIT 1", intval($item['uid'])); $r = q("SELECT `parent` FROM `item` WHERE `id` = %d", intval($item_id)); notification(array('type' => NOTIFY_TAGSELF, 'notify_flags' => $u[0]["notify-flags"], 'language' => $u[0]["language"], 'to_name' => $u[0]["username"], 'to_email' => $u[0]["email"], 'uid' => $item["uid"], 'item' => $item, 'link' => $a->get_baseurl() . '/display/' . urlencode(get_item_guid($item_id)), 'source_name' => $item["author-name"], 'source_link' => $item["author-link"], 'source_photo' => $item["author-avatar"], 'verb' => ACTIVITY_TAG, 'otype' => 'item', 'parent' => $r[0]["parent"])); } } }
function appnet_createpost($a, $uid, $post, $me, $user, $ownid, $createuser, $threadcompletion = true, $nodupcheck = false) { require_once 'include/items.php'; if ($post["machine_only"]) { return; } if ($post["is_deleted"]) { return; } $postarray = array(); $postarray['gravity'] = 0; $postarray['uid'] = $uid; $postarray['wall'] = 0; $postarray['verb'] = ACTIVITY_POST; $postarray['network'] = dbesc(NETWORK_APPNET); if (is_array($post["repost_of"])) { // You can't reply to reposts. So use the original id and thread-id $postarray['uri'] = "adn::" . $post["repost_of"]["id"]; $postarray['parent-uri'] = "adn::" . $post["repost_of"]["thread_id"]; } else { $postarray['uri'] = "adn::" . $post["id"]; $postarray['parent-uri'] = "adn::" . $post["thread_id"]; } if (!$nodupcheck) { $r = q("SELECT * FROM `item` WHERE `uri` = '%s' AND `uid` = %d LIMIT 1", dbesc($postarray['uri']), intval($uid)); if (count($r)) { return $r[0]; } $r = q("SELECT * FROM `item` WHERE `extid` = '%s' AND `uid` = %d LIMIT 1", dbesc($postarray['uri']), intval($uid)); if (count($r)) { return $r[0]; } } if (isset($post["reply_to"]) and $post["reply_to"] != "") { $postarray['thr-parent'] = "adn::" . $post["reply_to"]; // Complete the thread (if the parent doesn't exists) if ($threadcompletion) { //$r = q("SELECT * FROM `item` WHERE `uri` = '%s' AND `uid` = %d LIMIT 1", // dbesc($postarray['thr-parent']), // intval($uid) // ); //if (!count($r)) { logger("appnet_createpost: completing thread " . $post["thread_id"] . " for user " . $uid, LOGGER_DEBUG); require_once "addon/appnet/AppDotNet.php"; $token = get_pconfig($uid, 'appnet', 'token'); $clientId = get_pconfig($uid, 'appnet', 'clientid'); $clientSecret = get_pconfig($uid, 'appnet', 'clientsecret'); $app = new AppDotNet($clientId, $clientSecret); $app->setAccessToken($token); $param = array("count" => 200, "include_deleted" => false, "include_directed_posts" => true, "include_html" => false, "include_post_annotations" => true); try { $thread = $app->getPostReplies($post["thread_id"], $param); } catch (AppDotNetException $e) { logger("appnet_createpost: Error fetching thread for user " . $uid . " " . appnet_error($e->getMessage())); } $thread = array_reverse($thread); logger("appnet_createpost: fetched " . count($thread) . " items for thread " . $post["thread_id"] . " for user " . $uid, LOGGER_DEBUG); foreach ($thread as $tpost) { $threadpost = appnet_createpost($a, $uid, $tpost, $me, $user, $ownid, false, false); $item = item_store($threadpost); $threadpost["id"] = $item; logger("appnet_createpost: stored post " . $post["id"] . " thread " . $post["thread_id"] . " in item " . $item, LOGGER_DEBUG); } //} } // Don't create accounts of people who just comment something $createuser = false; $postarray['object-type'] = ACTIVITY_OBJ_COMMENT; } else { $postarray['thr-parent'] = $postarray['uri']; $postarray['object-type'] = ACTIVITY_OBJ_NOTE; } if ($post["user"]["id"] != $ownid or $postarray['thr-parent'] == $postarray['uri']) { $postarray['owner-name'] = $post["user"]["name"]; $postarray['owner-link'] = $post["user"]["canonical_url"]; $postarray['owner-avatar'] = $post["user"]["avatar_image"]["url"]; $postarray['contact-id'] = appnet_fetchcontact($a, $uid, $post["user"], $me, $createuser); } else { $postarray['owner-name'] = $me["name"]; $postarray['owner-link'] = $me["url"]; $postarray['owner-avatar'] = $me["thumb"]; $postarray['contact-id'] = $me["id"]; } $links = array(); if (is_array($post["repost_of"])) { $postarray['author-name'] = $post["repost_of"]["user"]["name"]; $postarray['author-link'] = $post["repost_of"]["user"]["canonical_url"]; $postarray['author-avatar'] = $post["repost_of"]["user"]["avatar_image"]["url"]; $content = $post["repost_of"]; } else { $postarray['author-name'] = $postarray['owner-name']; $postarray['author-link'] = $postarray['owner-link']; $postarray['author-avatar'] = $postarray['owner-avatar']; $content = $post; } $postarray['plink'] = $content["canonical_url"]; if (is_array($content["entities"])) { $converted = appnet_expand_entities($a, $content["text"], $content["entities"]); $postarray['body'] = $converted["body"]; $postarray['tag'] = $converted["tags"]; } else { $postarray['body'] = $content["text"]; } if (sizeof($content["entities"]["links"])) { foreach ($content["entities"]["links"] as $link) { $url = normalise_link($link["url"]); $links[$url] = $link["url"]; } } /* if (sizeof($content["annotations"])) foreach($content["annotations"] AS $annotation) { if ($annotation[type] == "net.app.core.oembed") { if (isset($annotation["value"]["embeddable_url"])) { $url = normalise_link($annotation["value"]["embeddable_url"]); if (isset($links[$url])) unset($links[$url]); } } elseif ($annotation[type] == "com.friendica.post") { //$links = array(); //if (isset($annotation["value"]["post-title"])) // $postarray['title'] = $annotation["value"]["post-title"]; //if (isset($annotation["value"]["post-body"])) // $postarray['body'] = $annotation["value"]["post-body"]; //if (isset($annotation["value"]["post-tag"])) // $postarray['tag'] = $annotation["value"]["post-tag"]; if (isset($annotation["value"]["author-name"])) $postarray['author-name'] = $annotation["value"]["author-name"]; if (isset($annotation["value"]["author-link"])) $postarray['author-link'] = $annotation["value"]["author-link"]; if (isset($annotation["value"]["author-avatar"])) $postarray['author-avatar'] = $annotation["value"]["author-avatar"]; } } */ $page_info = ""; if (is_array($content["annotations"])) { $photo = appnet_expand_annotations($a, $content["annotations"]); if ($photo["large"] != "" and $photo["url"] != "") { $page_info = "\n[url=" . $photo["url"] . "][img]" . $photo["large"] . "[/img][/url]"; } elseif ($photo["url"] != "") { $page_info = "\n[img]" . $photo["url"] . "[/img]"; } if ($photo["url"] != "") { $postarray['object-type'] = ACTIVITY_OBJ_IMAGE; } } else { $photo = array("url" => "", "large" => ""); } if (sizeof($links)) { $link = array_pop($links); $url = str_replace(array('/', '.'), array('\\/', '\\.'), $link); $page_info = add_page_info($link, false, $photo["url"]); if (trim($page_info) != "") { $removedlink = preg_replace("/\\[url\\=" . $url . "\\](.*?)\\[\\/url\\]/ism", '', $postarray['body']); if ($removedlink == "" or strstr($postarray['body'], $removedlink)) { $postarray['body'] = $removedlink; } } } $postarray['body'] .= $page_info; $postarray['created'] = datetime_convert('UTC', 'UTC', $post["created_at"]); $postarray['edited'] = datetime_convert('UTC', 'UTC', $post["created_at"]); $postarray['app'] = $post["source"]["name"]; return $postarray; }
function twitter_expand_entities($a, $body, $item, $no_tags = false, $picture) { require_once "include/oembed.php"; require_once "include/network.php"; $tags = ""; if (isset($item->entities->urls)) { $type = ""; $footerurl = ""; $footerlink = ""; $footer = ""; foreach ($item->entities->urls as $url) { if ($url->url and $url->expanded_url and $url->display_url) { $expanded_url = original_url($url->expanded_url); $oembed_data = oembed_fetch_url($expanded_url); // Quickfix: Workaround for URL with "[" and "]" in it if (strpos($expanded_url, "[") or strpos($expanded_url, "]")) { $expanded_url = $url->url; } if ($type == "") { $type = $oembed_data->type; } if ($oembed_data->type == "video") { //$body = str_replace($url->url, // "[video]".$expanded_url."[/video]", $body); //$dontincludemedia = true; $type = $oembed_data->type; $footerurl = $expanded_url; $footerlink = "[url=" . $expanded_url . "]" . $expanded_url . "[/url]"; $body = str_replace($url->url, $footerlink, $body); //} elseif (($oembed_data->type == "photo") AND isset($oembed_data->url) AND !$dontincludemedia) { } elseif ($oembed_data->type == "photo" and isset($oembed_data->url)) { $body = str_replace($url->url, "[url=" . $expanded_url . "][img]" . $oembed_data->url . "[/img][/url]", $body); //$dontincludemedia = true; } elseif ($oembed_data->type != "link") { $body = str_replace($url->url, "[url=" . $expanded_url . "]" . $expanded_url . "[/url]", $body); } else { $img_str = fetch_url($expanded_url, true, $redirects, 4); $tempfile = tempnam(get_temppath(), "cache"); file_put_contents($tempfile, $img_str); $mime = image_type_to_mime_type(exif_imagetype($tempfile)); unlink($tempfile); if (substr($mime, 0, 6) == "image/") { $type = "photo"; $body = str_replace($url->url, "[img]" . $expanded_url . "[/img]", $body); //$dontincludemedia = true; } else { $type = $oembed_data->type; $footerurl = $expanded_url; $footerlink = "[url=" . $expanded_url . "]" . $expanded_url . "[/url]"; $body = str_replace($url->url, $footerlink, $body); } } } } if ($footerurl != "") { $footer = add_page_info($footerurl, false, $picture); } if ($footerlink != "" and trim($footer) != "") { $removedlink = trim(str_replace($footerlink, "", $body)); if ($removedlink == "" or strstr($body, $removedlink)) { $body = $removedlink; } $body .= $footer; } if ($footer == "" and $picture != "") { $body .= "\n\n[img]" . $picture . "[/img]\n"; } elseif ($footer == "" and $picture == "") { $body = add_page_info_to_body($body); } if ($no_tags) { return array("body" => $body, "tags" => ""); } $tags_arr = array(); foreach ($item->entities->hashtags as $hashtag) { $url = "#[url=" . $a->get_baseurl() . "/search?tag=" . rawurlencode($hashtag->text) . "]" . $hashtag->text . "[/url]"; $tags_arr["#" . $hashtag->text] = $url; $body = str_replace("#" . $hashtag->text, $url, $body); } foreach ($item->entities->user_mentions as $mention) { $url = "@[url=https://twitter.com/" . rawurlencode($mention->screen_name) . "]" . $mention->screen_name . "[/url]"; $tags_arr["@" . $mention->screen_name] = $url; $body = str_replace("@" . $mention->screen_name, $url, $body); } // it seems as if the entities aren't always covering all mentions. So the rest will be checked here $tags = get_tags($body); if (count($tags)) { foreach ($tags as $tag) { if (strstr(trim($tag), " ")) { continue; } if (strpos($tag, '#') === 0) { if (strpos($tag, '[url=')) { continue; } // don't link tags that are already embedded in links if (preg_match('/\\[(.*?)' . preg_quote($tag, '/') . '(.*?)\\]/', $body)) { continue; } if (preg_match('/\\[(.*?)\\]\\((.*?)' . preg_quote($tag, '/') . '(.*?)\\)/', $body)) { continue; } $basetag = str_replace('_', ' ', substr($tag, 1)); $url = '#[url=' . $a->get_baseurl() . '/search?tag=' . rawurlencode($basetag) . ']' . $basetag . '[/url]'; $body = str_replace($tag, $url, $body); $tags_arr["#" . $basetag] = $url; continue; } elseif (strpos($tag, '@') === 0) { if (strpos($tag, '[url=')) { continue; } $basetag = substr($tag, 1); $url = '@[url=https://twitter.com/' . rawurlencode($basetag) . ']' . $basetag . '[/url]'; $body = str_replace($tag, $url, $body); $tags_arr["@" . $basetag] = $url; } } } $tags = implode($tags_arr, ","); } return array("body" => $body, "tags" => $tags); }
function statusnet_convertmsg($a, $body, $no_tags = false) { require_once "include/oembed.php"; require_once "include/items.php"; require_once "include/network.php"; $body = preg_replace("=\\[url\\=https?://([0-9]*).([0-9]*).([0-9]*).([0-9]*)/([0-9]*)\\](.*?)\\[\\/url\\]=ism", "\$1.\$2.\$3.\$4/\$5", $body); $URLSearchString = "^\\[\\]"; $links = preg_match_all("/[^!#@]\\[url\\=([{$URLSearchString}]*)\\](.*?)\\[\\/url\\]/ism", $body, $matches, PREG_SET_ORDER); $footer = ""; $footerurl = ""; $footerlink = ""; $type = ""; if ($links) { foreach ($matches as $match) { $search = "[url=" . $match[1] . "]" . $match[2] . "[/url]"; logger("statusnet_convertmsg: expanding url " . $match[1], LOGGER_DEBUG); $expanded_url = original_url($match[1]); logger("statusnet_convertmsg: fetching data for " . $expanded_url, LOGGER_DEBUG); $oembed_data = oembed_fetch_url($expanded_url, true); logger("statusnet_convertmsg: fetching data: done", LOGGER_DEBUG); if ($type == "") { $type = $oembed_data->type; } if ($oembed_data->type == "video") { //$body = str_replace($search, "[video]".$expanded_url."[/video]", $body); $type = $oembed_data->type; $footerurl = $expanded_url; $footerlink = "[url=" . $expanded_url . "]" . $expanded_url . "[/url]"; $body = str_replace($search, $footerlink, $body); } elseif ($oembed_data->type == "photo" and isset($oembed_data->url) and !$dontincludemedia) { $body = str_replace($search, "[url=" . $expanded_url . "][img]" . $oembed_data->url . "[/img][/url]", $body); } elseif ($oembed_data->type != "link") { $body = str_replace($search, "[url=" . $expanded_url . "]" . $expanded_url . "[/url]", $body); } else { $img_str = fetch_url($expanded_url, true, $redirects, 4); $tempfile = tempnam(get_temppath(), "cache"); file_put_contents($tempfile, $img_str); $mime = image_type_to_mime_type(exif_imagetype($tempfile)); unlink($tempfile); if (substr($mime, 0, 6) == "image/") { $type = "photo"; $body = str_replace($search, "[img]" . $expanded_url . "[/img]", $body); } else { $type = $oembed_data->type; $footerurl = $expanded_url; $footerlink = "[url=" . $expanded_url . "]" . $expanded_url . "[/url]"; $body = str_replace($search, $footerlink, $body); } } } if ($footerurl != "") { $footer = add_page_info($footerurl); } if ($footerlink != "" and trim($footer) != "") { $removedlink = trim(str_replace($footerlink, "", $body)); if ($removedlink == "" or strstr($body, $removedlink)) { $body = $removedlink; } $body .= $footer; } } if ($no_tags) { return array("body" => $body, "tags" => ""); } $str_tags = ''; $cnt = preg_match_all("/([!#@])\\[url\\=([{$URLSearchString}]*)\\](.*?)\\[\\/url\\]/ism", $body, $matches, PREG_SET_ORDER); if ($cnt) { foreach ($matches as $mtch) { if (strlen($str_tags)) { $str_tags .= ','; } if ($mtch[1] == "#") { // Replacing the hash tags that are directed to the GNU Social server with internal links $snhash = "#[url=" . $mtch[2] . "]" . $mtch[3] . "[/url]"; $frdchash = '#[url=' . $a->get_baseurl() . '/search?tag=' . rawurlencode($mtch[3]) . ']' . $mtch[3] . '[/url]'; $body = str_replace($snhash, $frdchash, $body); $str_tags .= $frdchash; } else { $str_tags .= "@[url=" . $mtch[2] . "]" . $mtch[3] . "[/url]"; } // To-Do: // There is a problem with links with to GNU Social groups, so these links are stored with "@" like friendica groups //$str_tags .= $mtch[1]."[url=".$mtch[2]."]".$mtch[3]."[/url]"; } } return array("body" => $body, "tags" => $str_tags); }
<?php add_page_info("title", "Settings - Dashboard"); set_active("dsettings", true); add_page_content("dashboard_header_subtitle", "Settings"); add_page_content("dashboard_content", 'management/dashboard/settings/page_content/content'); add_page_content("dashboard_content_title", "Settings"); set_active("collapse_side_nav_link", true); $breadcrumb = array("name" => "bdsettingslink", "text" => ' Settings', "uri" => "dashboard/settings"); add_breadcrumb($breadcrumb); set_hide_this("backlink", false); set_hide_this("refreshlink", false); $this->load->view("management/dashboard/view");
<?php add_page_info("title", "Dashboard"); add_page_content("dashboard_content", 'management/dashboard/page_content/content'); add_page_content("dashboard_content_title", "Dashboard"); set_active("collapse_side_nav_link", true); $this->load->view("management/dashboard/view");
function feed_import($xml, $importer, &$contact, &$hub) { $a = get_app(); logger("Import Atom/RSS feed", LOGGER_DEBUG); if ($xml == "") { return; } $doc = new DOMDocument(); @$doc->loadXML($xml); $xpath = new DomXPath($doc); $xpath->registerNamespace('atom', "http://www.w3.org/2005/Atom"); $xpath->registerNamespace('dc', "http://purl.org/dc/elements/1.1/"); $xpath->registerNamespace('content', "http://purl.org/rss/1.0/modules/content/"); $xpath->registerNamespace('rdf', "http://www.w3.org/1999/02/22-rdf-syntax-ns#"); $xpath->registerNamespace('rss', "http://purl.org/rss/1.0/"); $xpath->registerNamespace('media', "http://search.yahoo.com/mrss/"); $author = array(); // Is it RDF? if ($xpath->query('/rdf:RDF/rss:channel')->length > 0) { //$author["author-link"] = $xpath->evaluate('/rdf:RDF/rss:channel/rss:link/text()')->item(0)->nodeValue; $author["author-name"] = $xpath->evaluate('/rdf:RDF/rss:channel/rss:title/text()')->item(0)->nodeValue; if ($author["author-name"] == "") { $author["author-name"] = $xpath->evaluate('/rdf:RDF/rss:channel/rss:description/text()')->item(0)->nodeValue; } $entries = $xpath->query('/rdf:RDF/rss:item'); } // Is it Atom? if ($xpath->query('/atom:feed/atom:entry')->length > 0) { //$self = $xpath->query("/atom:feed/atom:link[@rel='self']")->item(0)->attributes; //if (is_object($self)) // foreach($self AS $attributes) // if ($attributes->name == "href") // $author["author-link"] = $attributes->textContent; //if ($author["author-link"] == "") { // $alternate = $xpath->query("/atom:feed/atom:link[@rel='alternate']")->item(0)->attributes; // if (is_object($alternate)) // foreach($alternate AS $attributes) // if ($attributes->name == "href") // $author["author-link"] = $attributes->textContent; //} $author["author-name"] = $xpath->evaluate('/atom:feed/atom:title/text()')->item(0)->nodeValue; if ($author["author-name"] == "") { $author["author-name"] = $xpath->evaluate('/atom:feed/atom:subtitle/text()')->item(0)->nodeValue; } if ($author["author-name"] == "") { $author["author-name"] = $xpath->evaluate('/atom:feed/atom:author/atom:name/text()')->item(0)->nodeValue; } //$author["author-avatar"] = $xpath->evaluate('/atom:feed/atom:logo/text()')->item(0)->nodeValue; $author["edited"] = $author["created"] = $xpath->query('/atom:feed/atom:updated/text()')->item(0)->nodeValue; $author["app"] = $xpath->evaluate('/atom:feed/atom:generator/text()')->item(0)->nodeValue; $entries = $xpath->query('/atom:feed/atom:entry'); } // Is it RSS? if ($xpath->query('/rss/channel')->length > 0) { //$author["author-link"] = $xpath->evaluate('/rss/channel/link/text()')->item(0)->nodeValue; $author["author-name"] = $xpath->evaluate('/rss/channel/title/text()')->item(0)->nodeValue; //$author["author-avatar"] = $xpath->evaluate('/rss/channel/image/url/text()')->item(0)->nodeValue; if ($author["author-name"] == "") { $author["author-name"] = $xpath->evaluate('/rss/channel/copyright/text()')->item(0)->nodeValue; } if ($author["author-name"] == "") { $author["author-name"] = $xpath->evaluate('/rss/channel/description/text()')->item(0)->nodeValue; } $author["edited"] = $author["created"] = $xpath->query('/rss/channel/pubDate/text()')->item(0)->nodeValue; $author["app"] = $xpath->evaluate('/rss/channel/generator/text()')->item(0)->nodeValue; $entries = $xpath->query('/rss/channel/item'); } //if ($author["author-link"] == "") $author["author-link"] = $contact["url"]; if ($author["author-name"] == "") { $author["author-name"] = $contact["name"]; } //if ($author["author-avatar"] == "") $author["author-avatar"] = $contact["thumb"]; $author["owner-link"] = $contact["url"]; $author["owner-name"] = $contact["name"]; $author["owner-avatar"] = $contact["thumb"]; $header = array(); $header["uid"] = $importer["uid"]; $header["network"] = NETWORK_FEED; $header["type"] = "remote"; $header["wall"] = 0; $header["origin"] = 0; $header["gravity"] = GRAVITY_PARENT; $header["private"] = 2; $header["verb"] = ACTIVITY_POST; $header["object-type"] = ACTIVITY_OBJ_NOTE; $header["contact-id"] = $contact["id"]; if (!strlen($contact["notify"])) { // one way feed - no remote comment ability $header["last-child"] = 0; } if (!is_object($entries)) { return; } $entrylist = array(); foreach ($entries as $entry) { $entrylist[] = $entry; } foreach (array_reverse($entrylist) as $entry) { $item = array_merge($header, $author); $item["title"] = $xpath->evaluate('atom:title/text()', $entry)->item(0)->nodeValue; if ($item["title"] == "") { $item["title"] = $xpath->evaluate('title/text()', $entry)->item(0)->nodeValue; } if ($item["title"] == "") { $item["title"] = $xpath->evaluate('rss:title/text()', $entry)->item(0)->nodeValue; } $alternate = $xpath->query("atom:link[@rel='alternate']", $entry)->item(0)->attributes; if (!is_object($alternate)) { $alternate = $xpath->query("atom:link", $entry)->item(0)->attributes; } if (is_object($alternate)) { foreach ($alternate as $attributes) { if ($attributes->name == "href") { $item["plink"] = $attributes->textContent; } } } if ($item["plink"] == "") { $item["plink"] = $xpath->evaluate('link/text()', $entry)->item(0)->nodeValue; } if ($item["plink"] == "") { $item["plink"] = $xpath->evaluate('rss:link/text()', $entry)->item(0)->nodeValue; } $item["plink"] = original_url($item["plink"]); $item["uri"] = $xpath->evaluate('atom:id/text()', $entry)->item(0)->nodeValue; if ($item["uri"] == "") { $item["uri"] = $xpath->evaluate('guid/text()', $entry)->item(0)->nodeValue; } if ($item["uri"] == "") { $item["uri"] = $item["plink"]; } $item["parent-uri"] = $item["uri"]; $published = $xpath->query('atom:published/text()', $entry)->item(0)->nodeValue; if ($published == "") { $published = $xpath->query('pubDate/text()', $entry)->item(0)->nodeValue; } if ($published == "") { $published = $xpath->query('dc:date/text()', $entry)->item(0)->nodeValue; } $updated = $xpath->query('atom:updated/text()', $entry)->item(0)->nodeValue; if ($updated == "") { $updated = $published; } if ($published != "") { $item["created"] = $published; } if ($updated != "") { $item["edited"] = $updated; } $creator = $xpath->query('author/text()', $entry)->item(0)->nodeValue; if ($creator == "") { $creator = $xpath->query('atom:author/atom:name/text()', $entry)->item(0)->nodeValue; } if ($creator == "") { $creator = $xpath->query('dc:creator/text()', $entry)->item(0)->nodeValue; } if ($creator != "") { $item["author-name"] = $creator; } if ($pubDate != "") { $item["edited"] = $item["created"] = $pubDate; } $creator = $xpath->query('dc:creator/text()', $entry)->item(0)->nodeValue; if ($creator != "") { $item["author-name"] = $creator; } //$item["object"] = $xml; $r = q("SELECT `id` FROM `item` WHERE `uid` = %d AND `uri` = '%s' AND `network` IN ('%s', '%s')", intval($importer["uid"]), dbesc($item["uri"]), dbesc(NETWORK_FEED), dbesc(NETWORK_DFRN)); if ($r) { logger("Item with uri " . $item["uri"] . " for user " . $importer["uid"] . " already existed under id " . $r[0]["id"], LOGGER_DEBUG); continue; } // To-Do? // <category>Ausland</category> // <media:thumbnail width="152" height="76" url="http://www.taz.de/picture/667875/192/14388767.jpg"/> $attachments = array(); $enclosures = $xpath->query("enclosure", $entry); foreach ($enclosures as $enclosure) { $href = ""; $length = ""; $type = ""; $title = ""; foreach ($enclosure->attributes as $attributes) { if ($attributes->name == "url") { $href = $attributes->textContent; } elseif ($attributes->name == "length") { $length = $attributes->textContent; } elseif ($attributes->name == "type") { $type = $attributes->textContent; } } if (strlen($item["attach"])) { $item["attach"] .= ','; } $attachments[] = array("link" => $href, "type" => $type, "length" => $length); $item["attach"] .= '[attach]href="' . $href . '" length="' . $length . '" type="' . $type . '"[/attach]'; } if ($contact["fetch_further_information"]) { $preview = ""; // Handle enclosures and treat them as preview picture foreach ($attachments as $attachment) { if ($attachment["type"] == "image/jpeg") { $preview = $attachment["link"]; } } $item["body"] = $item["title"] . add_page_info($item["plink"], false, $preview, $contact["fetch_further_information"] == 2, $contact["ffi_keyword_blacklist"]); $item["tag"] = add_page_keywords($item["plink"], false, $preview, $contact["fetch_further_information"] == 2, $contact["ffi_keyword_blacklist"]); $item["title"] = ""; $item["object-type"] = ACTIVITY_OBJ_BOOKMARK; unset($item["attach"]); } else { $body = trim($xpath->evaluate('atom:content/text()', $entry)->item(0)->nodeValue); if ($body == "") { $body = trim($xpath->evaluate('content:encoded/text()', $entry)->item(0)->nodeValue); } if ($body == "") { $body = trim($xpath->evaluate('description/text()', $entry)->item(0)->nodeValue); } if ($body == "") { $body = trim($xpath->evaluate('atom:summary/text()', $entry)->item(0)->nodeValue); } // remove the content of the title if it is identically to the body // This helps with auto generated titles e.g. from tumblr if (title_is_body($item["title"], $body)) { $item["title"] = ""; } $item["body"] = html2bbcode($body); } logger("Stored feed: " . print_r($item, true), LOGGER_DEBUG); $notify = item_is_remote_self($contact, $item); $id = item_store($item, false, $notify); //print_r($item); logger("Feed for contact " . $contact["url"] . " stored under id " . $id); } }
<?php add_page_info("javascript", "newcurriculumscript", "add-curriculum-script"); add_page_content("dashboard_curriculums_content", "management/dashboard/curriculums/create/page_content/content"); add_page_content("dashboard_curriculums_content_title", "Create Curriculum"); set_link_url("backlink", site_url("dashboard/curriculums")); set_hide_this("backlink", false); set_hide_this("refreshlink", false); set_active("createlink", true); $breadcrumb = array("name" => "bdccreatelink", "text" => ' New ', "uri" => "dashboard/curriculums/create"); add_breadcrumb($breadcrumb); $this->load->view("management/dashboard/curriculums/view");
<?php add_page_info("title", " Login "); add_page_info("stylesheet", "main", "main-style"); add_page_info("javascript", "main", "main-script"); add_page_info("stylesheet", "login", "custom-style"); add_page_info("javascript", "login", "custom-script"); add_page_content("container", "container"); add_page_content("top_nav", 'main/top_nav/content'); add_page_content("user_nav", 'main/login/top_nav/user_nav/content'); add_page_content("page_header", 'main/page_header/content'); add_page_content("page_content_container", 'main/login/page_content/container'); add_page_content("page_footer", 'main/page_footer/content'); $this->load->view('template/frame');
<?php add_page_info("title", " Dashboard - Curriculums"); add_page_info("javascript", "dcurriculumscript", "dashboard-curriculum-script"); add_page_content("curriculum_page_sub_menu", "management/dashboard/curriculums/page_sub_menu/content"); add_page_content("dashboard_header_subtitle", "Curriculums"); add_page_content("page_content", 'management/dashboard/curriculums/page_content/container'); set_active("dcurriculums", true); $breadcrumb = array("name" => "bdcurriculumslink", "text" => ' Curriculums', "uri" => "dashboard/curriculums"); add_breadcrumb($breadcrumb); set_active("collapse_side_nav_link", false); set_page_links("curriculum_sub_menu_links", array(array("name" => "settingslink", "text" => ' <span class="glyphicon glyphicon-wrench"> ', "attributes" => array("class" => ' btn btn-sm btn-primary ' . (is_active("settingslink") ? " active " : " "), "title" => 'Settings'), "uri" => "dashboard/curriculums/settings"), array("name" => "createlink", "text" => ' <span class="glyphicon glyphicon-plus"> ', "attributes" => array("class" => ' btn btn-sm btn-primary ' . (is_active("createlink") ? " active " : " "), "title" => 'Create '), "uri" => "dashboard/curriculums/create"), array("name" => "listlink", "text" => ' <span class="glyphicon glyphicon-list"> ', "attributes" => array("class" => ' btn btn-sm btn-primary ' . (is_active("listlink") ? " active " : " "), "title" => 'List '), "uri" => "dashboard/curriculums/list"))); $this->load->view("management/dashboard/view");