当前位置: 首页>>代码示例>>PHP>>正文


PHP prepare_text函数代码示例

本文整理汇总了PHP中prepare_text函数的典型用法代码示例。如果您正苦于以下问题:PHP prepare_text函数的具体用法?PHP prepare_text怎么用?PHP prepare_text使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了prepare_text函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: save

 /**
  * Prepare the text fields and save them
  *
  * @param int $id
  * @return bool|int
  */
 public function save($data = '')
 {
     if (!empty($data[$this->pkey])) {
         $this->delete($data[$this->pkey]);
     }
     $data['full'] = prepare_text($data['original']);
     $data['short'] = mb_strcut($data['full'], 0, 250);
     // @todo: 250 should be in CONFIG
     return parent::insert($data);
 }
开发者ID:ak826843,项目名称:bmf,代码行数:16,代码来源:text.php

示例2: connect_content

function connect_content(&$a)
{
    $edit = local_user() && local_user() == $a->data['channel']['channel_id'] ? true : false;
    $text = get_pconfig($a->data['channel']['channel_id'], 'system', 'selltext');
    if ($edit) {
        $o = replace_macros(get_markup_template('sellpage_edit.tpl'), array('$header' => t('Premium Channel Setup'), '$address' => $a->data['channel']['channel_address'], '$premium' => array('premium', t('Enable premium channel connection restrictions'), $a->data['channel']['channel_pageflags'] & PAGE_PREMIUM ? '1' : '', ''), '$lbl_about' => t('Please enter your restrictions or conditions, such as paypal receipt, usage guidelines, etc.'), '$text' => $text, '$desc' => t('This channel may require additional steps or acknowledgement of the following conditions prior to connecting:'), '$lbl2' => t('Potential connections will then see the following text before proceeding:'), '$desc2' => t('By continuing, I certify that I have complied with any instructions provided on this page.'), '$submit' => t('Submit')));
        return $o;
    } else {
        if (!$text) {
            $text = t('(No specific instructions have been provided by the channel owner.)');
        }
        $submit = replace_macros(get_markup_template('sellpage_submit.tpl'), array('$continue' => t('Continue'), '$address' => $a->data['channel']['channel_address']));
        $o = replace_macros(get_markup_template('sellpage_view.tpl'), array('$header' => t('Restricted or Premium Channel'), '$desc' => t('This channel may require additional steps or acknowledgement of the following conditions prior to connecting:'), '$text' => prepare_text($text), '$desc2' => t('By continuing, I certify that I have complied with any instructions provided on this page.'), '$submit' => $submit));
        $arr = array('channel' => $a->data['channel'], 'observer' => $a->get_observer(), 'sellpage' => $o, 'submit' => $submit);
        call_hooks('connect_premium', $arr);
        $o = $arr['sellpage'];
    }
    return $o;
}
开发者ID:Mauru,项目名称:red,代码行数:19,代码来源:connect.php

示例3: prepare_body

 function prepare_body($item, $attach = false)
 {
     $a = get_app();
     call_hooks('prepare_body_init', $item);
     //$cachefile = get_cachefile($item["guid"]."-".strtotime($item["edited"])."-".hash("crc32", $item['body']));
     $cachefile = get_cachefile($item["guid"] . "-" . hash("md5", $item['body']));
     if ($cachefile != '') {
         if (file_exists($cachefile)) {
             $stamp1 = microtime(true);
             $s = file_get_contents($cachefile);
             $a->save_timestamp($stamp1, "file");
         } else {
             redir_private_images($a, $item);
             $s = prepare_text($item['body']);
             $stamp1 = microtime(true);
             file_put_contents($cachefile, $s);
             $a->save_timestamp($stamp1, "file");
             logger('prepare_body: put item ' . $item["id"] . ' into cachefile ' . $cachefile);
         }
     } else {
         redir_private_images($a, $item);
         $s = prepare_text($item['body']);
     }
     $prep_arr = array('item' => $item, 'html' => $s);
     call_hooks('prepare_body', $prep_arr);
     $s = $prep_arr['html'];
     if (!$attach) {
         // Replace the blockquotes with quotes that are used in mails
         $mailquote = '<blockquote type="cite" class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">';
         $s = str_replace(array('<blockquote>', '<blockquote class="spoiler">', '<blockquote class="author">'), array($mailquote, $mailquote, $mailquote), $s);
         return $s;
     }
     $arr = explode('[/attach],', $item['attach']);
     if (count($arr)) {
         $s .= '<div class="body-attach">';
         foreach ($arr as $r) {
             $matches = false;
             $icon = '';
             $cnt = preg_match_all('|\\[attach\\]href=\\"(.*?)\\" length=\\"(.*?)\\" type=\\"(.*?)\\" title=\\"(.*?)\\"|', $r, $matches, PREG_SET_ORDER);
             if ($cnt) {
                 foreach ($matches as $mtch) {
                     $filetype = strtolower(substr($mtch[3], 0, strpos($mtch[3], '/')));
                     if ($filetype) {
                         $filesubtype = strtolower(substr($mtch[3], strpos($mtch[3], '/') + 1));
                         $filesubtype = str_replace('.', '-', $filesubtype);
                     } else {
                         $filetype = 'unkn';
                         $filesubtype = 'unkn';
                     }
                     $icon = '<div class="attachtype icon s22 type-' . $filetype . ' subtype-' . $filesubtype . '"></div>';
                     /*$icontype = strtolower(substr($mtch[3],0,strpos($mtch[3],'/')));
                     		switch($icontype) {
                     			case 'video':
                     			case 'audio':
                     			case 'image':
                     			case 'text':
                     				$icon = '<div class="attachtype icon s22 type-' . $icontype . '"></div>';
                     				break;
                     			default:
                     				$icon = '<div class="attachtype icon s22 type-unkn"></div>';
                     				break;
                     		}*/
                     $title = strlen(trim($mtch[4])) ? escape_tags(trim($mtch[4])) : escape_tags($mtch[1]);
                     $title .= ' ' . $mtch[2] . ' ' . t('bytes');
                     if (local_user() == $item['uid'] && $item['contact-id'] != $a->contact['id'] && $item['network'] == NETWORK_DFRN) {
                         $the_url = $a->get_baseurl() . '/redir/' . $item['contact-id'] . '?f=1&url=' . $mtch[1];
                     } else {
                         $the_url = $mtch[1];
                     }
                     $s .= '<a href="' . strip_tags($the_url) . '" title="' . $title . '" class="attachlink" target="external-link" >' . $icon . '</a>';
                 }
             }
         }
         $s .= '<div class="clear"></div></div>';
     }
     // Look for spoiler
     $spoilersearch = '<blockquote class="spoiler">';
     // Remove line breaks before the spoiler
     while (strpos($s, "\n" . $spoilersearch) !== false) {
         $s = str_replace("\n" . $spoilersearch, $spoilersearch, $s);
     }
     while (strpos($s, "<br />" . $spoilersearch) !== false) {
         $s = str_replace("<br />" . $spoilersearch, $spoilersearch, $s);
     }
     while (strpos($s, $spoilersearch) !== false) {
         $pos = strpos($s, $spoilersearch);
         $rnd = random_string(8);
         $spoilerreplace = '<br /> <span id="spoiler-wrap-' . $rnd . '" style="white-space:nowrap;" class="fakelink" onclick="openClose(\'spoiler-' . $rnd . '\');">' . sprintf(t('Click to open/close')) . '</span>' . '<blockquote class="spoiler" id="spoiler-' . $rnd . '" style="display: none;">';
         $s = substr($s, 0, $pos) . $spoilerreplace . substr($s, $pos + strlen($spoilersearch));
     }
     // Look for quote with author
     $authorsearch = '<blockquote class="author">';
     while (strpos($s, $authorsearch) !== false) {
         $pos = strpos($s, $authorsearch);
         $rnd = random_string(8);
         $authorreplace = '<br /> <span id="author-wrap-' . $rnd . '" style="white-space:nowrap;" class="fakelink" onclick="openClose(\'author-' . $rnd . '\');">' . sprintf(t('Click to open/close')) . '</span>' . '<blockquote class="author" id="author-' . $rnd . '" style="display: block;">';
         $s = substr($s, 0, $pos) . $authorreplace . substr($s, $pos + strlen($authorsearch));
     }
     $prep_arr = array('item' => $item, 'html' => $s);
     call_hooks('prepare_body_final', $prep_arr);
//.........这里部分代码省略.........
开发者ID:ridcully,项目名称:friendica,代码行数:101,代码来源:text.php

示例4: api_format_items

function api_format_items($r, $user_info)
{
    //logger('api_format_items: ' . print_r($r,true));
    //logger('api_format_items: ' . print_r($user_info,true));
    $a = get_app();
    $ret = array();
    if (!$r) {
        return $ret;
    }
    foreach ($r as $item) {
        localize_item($item);
        $status_user = $item['author_xchan'] == $user_info['guid'] ? $user_info : api_item_get_user($a, $item);
        if (array_key_exists('status', $status_user)) {
            unset($status_user['status']);
        }
        if ($item['parent'] != $item['id']) {
            $r = q("select id from item where parent= %d and id < %d order by id desc limit 1", intval($item['parent']), intval($item['id']));
            if ($r) {
                $in_reply_to_status_id = $r[0]['id'];
            } else {
                $in_reply_to_status_id = $item['parent'];
            }
            xchan_query($r, true);
            $in_reply_to_screen_name = $r[0]['author']['xchan_name'];
            $in_reply_to_user_id = $r[0]['author']['abook_id'];
        } else {
            $in_reply_to_screen_name = '';
            $in_reply_to_user_id = 0;
            $in_reply_to_status_id = 0;
        }
        unobscure($item);
        // Workaround for ostatus messages where the title is identically to the body
        $statusbody = trim(html2plain(prepare_text($item['body'], $item['mimetype']), 0));
        $statustitle = trim($item['title']);
        if ($statustitle != '' and strpos($statusbody, $statustitle) !== false) {
            $statustext = trim($statusbody);
        } else {
            $statustext = trim($statustitle . "\n\n" . $statusbody);
        }
        $status = array('text' => $statustext, 'truncated' => False, 'created_at' => api_date($item['created']), 'in_reply_to_status_id' => $in_reply_to_status_id, 'source' => $item['app'] ? $item['app'] : 'web', 'id' => intval($item['id']), 'in_reply_to_user_id' => $in_reply_to_user_id, 'in_reply_to_screen_name' => $in_reply_to_screen_name, 'geo' => '', 'favorited' => intval($item['item_starred']) ? true : false, 'user' => $status_user, 'statusnet_html' => trim(prepare_text($item['body'], $item['mimetype'])), 'statusnet_conversation_id' => $item['parent']);
        // Seesmic doesn't like the following content
        if ($_SERVER['HTTP_USER_AGENT'] != 'Seesmic') {
            $status2 = array('updated' => api_date($item['edited']), 'published' => api_date($item['created']), 'message_id' => $item['mid'], 'url' => $item['plink'], 'coordinates' => $item['coord'], 'place' => $item['location'], 'contributors' => '', 'annotations' => '', 'entities' => '', 'objecttype' => $item['obj_type'] ? $item['obj_type'] : ACTIVITY_OBJ_NOTE, 'verb' => $item['verb'] ? $item['verb'] : ACTIVITY_POST, 'self' => $a->get_baseurl() . "/api/statuses/show/" . $item['id'] . "." . $type, 'edit' => $a->get_baseurl() . "/api/statuses/show/" . $item['id'] . "." . $type);
            $status = array_merge($status, $status2);
        }
        $ret[] = $status;
    }
    return $ret;
}
开发者ID:msooon,项目名称:hubzilla,代码行数:49,代码来源:api.php

示例5: atom_entry

function atom_entry($item, $type, $author, $owner, $comment = false, $cid = 0)
{
    if (!$item['parent']) {
        return;
    }
    if ($item['deleted']) {
        return '<at:deleted-entry ref="' . xmlify($item['mid']) . '" when="' . xmlify(datetime_convert('UTC', 'UTC', $item['edited'] . '+00:00', ATOM_TIME)) . '" />' . "\r\n";
    }
    if ($item['allow_cid'] || $item['allow_gid'] || $item['deny_cid'] || $item['deny_gid']) {
        $body = fix_private_photos($item['body'], $owner['uid'], $item, $cid);
    } else {
        $body = $item['body'];
    }
    $o = "\r\n\r\n<entry>\r\n";
    if (is_array($author)) {
        $o .= atom_author('author', $author['xchan_name'], $author['xchan_url'], 80, 80, $author['xchan_photo_mimetype'], $author['xchan_photo_m']);
    } else {
        $o .= atom_author('author', $item['author']['xchan_name'], $item['author']['xchan_url'], 80, 80, $item['author']['xchan_photo_mimetype'], $item['author']['xchan_photo_m']);
    }
    $o .= atom_author('zot:owner', $item['owner']['xchan_name'], $item['owner']['xchan_url'], 80, 80, $item['owner']['xchan_photo_mimetype'], $item['owner']['xchan_photo_m']);
    if ($item['parent'] != $item['id'] || $item['parent_mid'] !== $item['mid'] || $item['thr_parent'] !== '' && $item['thr_parent'] !== $item['mid']) {
        $parent_item = $item['thr_parent'] ? $item['thr_parent'] : $item['parent_mid'];
        $o .= '<thr:in-reply-to ref="' . xmlify($parent_item) . '" type="text/html" href="' . xmlify($item['plink']) . '" />' . "\r\n";
    }
    $o .= '<id>' . xmlify($item['mid']) . '</id>' . "\r\n";
    $o .= '<title>' . xmlify($item['title']) . '</title>' . "\r\n";
    $o .= '<published>' . xmlify(datetime_convert('UTC', 'UTC', $item['created'] . '+00:00', ATOM_TIME)) . '</published>' . "\r\n";
    $o .= '<updated>' . xmlify(datetime_convert('UTC', 'UTC', $item['edited'] . '+00:00', ATOM_TIME)) . '</updated>' . "\r\n";
    $o .= '<content type="' . $type . '" >' . xmlify(prepare_text($body, $item['mimetype'])) . '</content>' . "\r\n";
    $o .= '<link rel="alternate" type="text/html" href="' . xmlify($item['plink']) . '" />' . "\r\n";
    if ($item['location']) {
        $o .= '<zot:location>' . xmlify($item['location']) . '</zot:location>' . "\r\n";
        $o .= '<poco:address><poco:formatted>' . xmlify($item['location']) . '</poco:formatted></poco:address>' . "\r\n";
    }
    if ($item['coord']) {
        $o .= '<georss:point>' . xmlify($item['coord']) . '</georss:point>' . "\r\n";
    }
    if ($item['item_private'] || strlen($item['allow_cid']) || strlen($item['allow_gid']) || strlen($item['deny_cid']) || strlen($item['deny_gid'])) {
        $o .= '<zot:private>' . ($item['item_private'] ? $item['item_private'] : 1) . '</zot:private>' . "\r\n";
    }
    if ($item['app']) {
        $o .= '<statusnet:notice_info local_id="' . $item['id'] . '" source="' . xmlify($item['app']) . '" ></statusnet:notice_info>' . "\r\n";
    }
    $verb = construct_verb($item);
    $o .= '<as:verb>' . xmlify($verb) . '</as:verb>' . "\r\n";
    $actobj = construct_activity_object($item);
    if (strlen($actobj)) {
        $o .= $actobj;
    }
    $actarg = construct_activity_target($item);
    if (strlen($actarg)) {
        $o .= $actarg;
    }
    // FIXME
    //	$tags = item_getfeedtags($item);
    //	if(count($tags)) {
    //		foreach($tags as $t) {
    //			$o .= '<category scheme="X-DFRN:' . xmlify($t[0]) . ':' . xmlify($t[1]) . '" term="' . xmlify($t[2]) . '" />' . "\r\n";
    //		}
    //	}
    // FIXME
    //	$o .= item_getfeedattach($item);
    //	$mentioned = get_mentions($item,$tags);
    //	if($mentioned)
    //		$o .= $mentioned;
    call_hooks('atom_entry', $o);
    $o .= '</entry>' . "\r\n";
    return $o;
}
开发者ID:einervonvielen,项目名称:redmatrix,代码行数:69,代码来源:items.php

示例6: comment

 /**
  * Add new comment to topic
  */
 public function comment()
 {
     $this->load->model('comment');
     $comment['post_id'] = param('post_id');
     if (empty($comment['post_id'])) {
         set_flash_error('Ошибка в параметрах комментария');
         redirect();
     }
     $post = $this->post->find($comment['post_id'], 1);
     if (empty($post)) {
         set_flash_error('Такого топика не существует');
         redirect();
     }
     $comment['parent_id'] = param('parent_id');
     $comment['text'] = prepare_text(param('text', TRUE, FALSE));
     if (empty($comment['text'])) {
         set_flash_error('Вы не написали свой комментарий к топику');
         redirect(post_link($post));
     }
     $comment['user_id'] = $this->current_user['id'];
     $comment['added_at'] = now2mysql();
     $id = $this->comment->save($comment);
     if ($id) {
         set_flash_ok('Спасибо за ваш комментарий');
     } else {
         set_flash_error('Извините, но произошла ошибка и ваш комментарий сохранить не удалось');
     }
     redirect(post_link($post) . '#com' . $id);
 }
开发者ID:ak826843,项目名称:bmf,代码行数:32,代码来源:post.php

示例7: prepare_body

function prepare_body(&$item, $attach = false)
{
    require_once 'include/identity.php';
    //	if($item['html']) {
    //		$s = bb_observer($item['html']);
    //	}
    //	else {
    call_hooks('prepare_body_init', $item);
    //		unobscure($item);
    $s = prepare_text($item['body'], $item['mimetype'], false);
    //	}
    $photo = '';
    $is_photo = $item['obj_type'] === ACTIVITY_OBJ_PHOTO ? true : false;
    if ($is_photo) {
        $object = json_decode($item['object'], true);
        // if original photo width is <= 640px prepend it to item body
        if ($object['link'][0]['width'] && $object['link'][0]['width'] <= 640) {
            $s = '<div class="inline-photo-item-wrapper"><a href="' . zid(rawurldecode($object['id'])) . '" target="_newwin"><img class="inline-photo-item" style="max-width:' . $object['link'][0]['width'] . 'px; width:100%; height:auto;" src="' . zid(rawurldecode($object['link'][0]['href'])) . '"></a></div>' . $s;
        }
        // if original photo width is > 640px make it a cover photo
        if ($object['link'][0]['width'] && $object['link'][0]['width'] > 640) {
            $scale = $object['link'][1]['width'] == 1024 || $object['link'][1]['height'] == 1024 ? 1 : 0;
            $photo = '<a href="' . zid(rawurldecode($object['id'])) . '" target="_newwin"><img style="max-width:' . $object['link'][$scale]['width'] . 'px; width:100%; height:auto;" src="' . zid(rawurldecode($object['link'][$scale]['href'])) . '"></a>';
        }
    }
    $prep_arr = array('item' => $item, 'html' => $s, 'photo' => $photo);
    call_hooks('prepare_body', $prep_arr);
    $s = $prep_arr['html'];
    $photo = $prep_arr['photo'];
    //	q("update item set html = '%s' where id = %d",
    //		dbesc($s),
    //		intval($item['id'])
    //	);
    if (!$attach) {
        return $s;
    }
    if (strpos($s, '<div class="map">') !== false && $item['coord']) {
        $x = generate_map(trim($item['coord']));
        if ($x) {
            $s = preg_replace('/\\<div class\\=\\"map\\"\\>/', '$0' . $x, $s);
        }
    }
    $attachments = theme_attachments($item);
    $writeable = get_observer_hash() == $item['owner_xchan'] ? true : false;
    $tags = format_hashtags($item);
    if ($item['resource_type']) {
        $mentions = format_mentions($item);
    }
    $categories = format_categories($item, $writeable);
    if (local_channel() == $item['uid']) {
        $filer = format_filer($item);
    }
    $s = sslify($s);
    // Look for spoiler
    $spoilersearch = '<blockquote class="spoiler">';
    // Remove line breaks before the spoiler
    while (strpos($s, "\n" . $spoilersearch) !== false) {
        $s = str_replace("\n" . $spoilersearch, $spoilersearch, $s);
    }
    while (strpos($s, "<br />" . $spoilersearch) !== false) {
        $s = str_replace("<br />" . $spoilersearch, $spoilersearch, $s);
    }
    while (strpos($s, $spoilersearch) !== false) {
        $pos = strpos($s, $spoilersearch);
        $rnd = random_string(8);
        $spoilerreplace = '<br /> <span id="spoiler-wrap-' . $rnd . '" style="white-space:nowrap;" class="fakelink" onclick="openClose(\'spoiler-' . $rnd . '\');">' . sprintf(t('Click to open/close')) . '</span>' . '<blockquote class="spoiler" id="spoiler-' . $rnd . '" style="display: none;">';
        $s = substr($s, 0, $pos) . $spoilerreplace . substr($s, $pos + strlen($spoilersearch));
    }
    // Look for quote with author
    $authorsearch = '<blockquote class="author">';
    while (strpos($s, $authorsearch) !== false) {
        $pos = strpos($s, $authorsearch);
        $rnd = random_string(8);
        $authorreplace = '<br /> <span id="author-wrap-' . $rnd . '" style="white-space:nowrap;" class="fakelink" onclick="openClose(\'author-' . $rnd . '\');">' . sprintf(t('Click to open/close')) . '</span>' . '<blockquote class="author" id="author-' . $rnd . '" style="display: block;">';
        $s = substr($s, 0, $pos) . $authorreplace . substr($s, $pos + strlen($authorsearch));
    }
    $prep_arr = array('item' => $item, 'photo' => $photo, 'html' => $s, 'categories' => $categories, 'folders' => $filer, 'tags' => $tags, 'mentions' => $mentions, 'attachments' => $attachments);
    call_hooks('prepare_body_final', $prep_arr);
    unset($prep_arr['item']);
    return $prep_arr;
}
开发者ID:23n,项目名称:hubzilla,代码行数:81,代码来源:text.php

示例8: store_doc_file

function store_doc_file($s)
{
    if (is_dir($s)) {
        return;
    }
    $item = array();
    $sys = get_sys_channel();
    $item['aid'] = 0;
    $item['uid'] = $sys['channel_id'];
    if (strpos($s, '.md')) {
        $mimetype = 'text/markdown';
    } elseif (strpos($s, '.html')) {
        $mimetype = 'text/html';
    } else {
        $mimetype = 'text/bbcode';
    }
    require_once 'include/html2plain.php';
    $item['body'] = html2plain(prepare_text(file_get_contents($s), $mimetype, true));
    $item['mimetype'] = 'text/plain';
    $item['plink'] = z_root() . '/' . str_replace('doc', 'help', $s);
    $item['owner_xchan'] = $item['author_xchan'] = $sys['channel_hash'];
    $item['item_type'] = ITEM_TYPE_DOC;
    $r = q("select item.* from item left join iconfig on item.id = iconfig.iid \n\t\twhere iconfig.cat = 'system' and iconfig.k = 'docfile' and\n\t\ticonfig.v = '%s' and item_type = %d limit 1", dbesc($s), intval(ITEM_TYPE_DOC));
    \Zotlabs\Lib\IConfig::Set($item, 'system', 'docfile', $s);
    if ($r) {
        $item['id'] = $r[0]['id'];
        $item['mid'] = $item['parent_mid'] = $r[0]['mid'];
        $x = item_store_update($item);
    } else {
        $item['mid'] = $item['parent_mid'] = item_message_id();
        $x = item_store($item);
    }
    return $x;
}
开发者ID:BlaBlaNet,项目名称:hubzilla,代码行数:34,代码来源:help.php

示例9: post_is_importable

function post_is_importable($item, $abook)
{
    if (!$abook) {
        return true;
    }
    if ($abook['abook_channel'] && !feature_enabled($abook['abook_channel'], 'connfilter')) {
        return true;
    }
    if (!$item) {
        return false;
    }
    if (!($abook['abook_incl'] || $abook['abook_excl'])) {
        return true;
    }
    require_once 'include/html2plain.php';
    unobscure($item);
    $text = prepare_text($item['body'], $item['mimetype']);
    $text = html2plain($item['title'] ? $item['title'] . ' ' . $text : $text);
    $lang = null;
    if (strpos($abook['abook_incl'], 'lang=') !== false || strpos($abook['abook_excl'], 'lang=') !== false) {
        $lang = detect_language($text);
    }
    $tags = count($item['term']) ? $item['term'] : false;
    // exclude always has priority
    $exclude = $abook['abook_excl'] ? explode("\n", $abook['abook_excl']) : null;
    if ($exclude) {
        foreach ($exclude as $word) {
            $word = trim($word);
            if (!$word) {
                continue;
            }
            if (substr($word, 0, 1) === '#' && $tags) {
                foreach ($tags as $t) {
                    if (($t['ttype'] == TERM_HASHTAG || $t['ttype'] == TERM_COMMUNITYTAG) && ($t['term'] === substr($word, 1) || substr($word, 1) === '*')) {
                        return false;
                    }
                }
            } elseif (strpos($word, '/') === 0 && preg_match($word, $text)) {
                return false;
            } elseif (strpos($word, 'lang=') === 0 && $lang && strcasecmp($lang, trim(substr($word, 5))) == 0) {
                return false;
            } elseif (stristr($text, $word) !== false) {
                return false;
            }
        }
    }
    $include = $abook['abook_incl'] ? explode("\n", $abook['abook_incl']) : null;
    if ($include) {
        foreach ($include as $word) {
            $word = trim($word);
            if (!$word) {
                continue;
            }
            if (substr($word, 0, 1) === '#' && $tags) {
                foreach ($tags as $t) {
                    if (($t['ttype'] == TERM_HASHTAG || $t['ttype'] == TERM_COMMUNITYTAG) && ($t['term'] === substr($word, 1) || substr($word, 1) === '*')) {
                        return true;
                    }
                }
            } elseif (strpos($word, '/') === 0 && preg_match($word, $text)) {
                return true;
            } elseif (strpos($word, 'lang=') === 0 && $lang && strcasecmp($lang, trim(substr($word, 5))) == 0) {
                return true;
            } elseif (stristr($text, $word) !== false) {
                return true;
            }
        }
    } else {
        return true;
    }
    return false;
}
开发者ID:phellmes,项目名称:hubzilla,代码行数:72,代码来源:items.php

示例10: advanced_profile

function advanced_profile(&$a)
{
    $o = '';
    $uid = $a->profile['uid'];
    $o .= replace_macros(get_markup_template('section_title.tpl'), array('$title' => t('Profile')));
    if ($a->profile['name']) {
        $tpl = get_markup_template('profile_advanced.tpl');
        $profile = array();
        $profile['fullname'] = array(t('Full Name:'), $a->profile['name']);
        if ($a->profile['gender']) {
            $profile['gender'] = array(t('Gender:'), $a->profile['gender']);
        }
        if ($a->profile['dob'] && $a->profile['dob'] != '0000-00-00') {
            $year_bd_format = t('j F, Y');
            $short_bd_format = t('j F');
            $val = intval($a->profile['dob']) ? day_translate(datetime_convert('UTC', 'UTC', $a->profile['dob'] . ' 00:00 +00:00', $year_bd_format)) : day_translate(datetime_convert('UTC', 'UTC', '2001-' . substr($a->profile['dob'], 5) . ' 00:00 +00:00', $short_bd_format));
            $profile['birthday'] = array(t('Birthday:'), $val);
        }
        if ($age = age($a->profile['dob'], $a->profile['timezone'], '')) {
            $profile['age'] = array(t('Age:'), $age);
        }
        if ($a->profile['marital']) {
            $profile['marital'] = array(t('Status:'), $a->profile['marital']);
        }
        if ($a->profile['with']) {
            $profile['marital']['with'] = $a->profile['with'];
        }
        if (strlen($a->profile['howlong']) && $a->profile['howlong'] !== '0000-00-00 00:00:00') {
            $profile['howlong'] = relative_date($a->profile['howlong'], t('for %1$d %2$s'));
        }
        if ($a->profile['sexual']) {
            $profile['sexual'] = array(t('Sexual Preference:'), $a->profile['sexual']);
        }
        if ($a->profile['homepage']) {
            $profile['homepage'] = array(t('Homepage:'), linkify($a->profile['homepage']));
        }
        if ($a->profile['hometown']) {
            $profile['hometown'] = array(t('Hometown:'), linkify($a->profile['hometown']));
        }
        if ($a->profile['pub_keywords']) {
            $profile['pub_keywords'] = array(t('Tags:'), $a->profile['pub_keywords']);
        }
        if ($a->profile['politic']) {
            $profile['politic'] = array(t('Political Views:'), $a->profile['politic']);
        }
        if ($a->profile['religion']) {
            $profile['religion'] = array(t('Religion:'), $a->profile['religion']);
        }
        if ($txt = prepare_text($a->profile['about'])) {
            $profile['about'] = array(t('About:'), $txt);
        }
        if ($txt = prepare_text($a->profile['interest'])) {
            $profile['interest'] = array(t('Hobbies/Interests:'), $txt);
        }
        if ($txt = prepare_text($a->profile['likes'])) {
            $profile['likes'] = array(t('Likes:'), $txt);
        }
        if ($txt = prepare_text($a->profile['dislikes'])) {
            $profile['dislikes'] = array(t('Dislikes:'), $txt);
        }
        if ($txt = prepare_text($a->profile['contact'])) {
            $profile['contact'] = array(t('Contact information and Social Networks:'), $txt);
        }
        if ($txt = prepare_text($a->profile['music'])) {
            $profile['music'] = array(t('Musical interests:'), $txt);
        }
        if ($txt = prepare_text($a->profile['book'])) {
            $profile['book'] = array(t('Books, literature:'), $txt);
        }
        if ($txt = prepare_text($a->profile['tv'])) {
            $profile['tv'] = array(t('Television:'), $txt);
        }
        if ($txt = prepare_text($a->profile['film'])) {
            $profile['film'] = array(t('Film/dance/culture/entertainment:'), $txt);
        }
        if ($txt = prepare_text($a->profile['romance'])) {
            $profile['romance'] = array(t('Love/Romance:'), $txt);
        }
        if ($txt = prepare_text($a->profile['work'])) {
            $profile['work'] = array(t('Work/employment:'), $txt);
        }
        if ($txt = prepare_text($a->profile['education'])) {
            $profile['education'] = array(t('School/education:'), $txt);
        }
        //show subcribed forum if it is enabled in the usersettings
        if (feature_enabled($uid, 'forumlist_profile')) {
            $profile['forumlist'] = array(t('Forums:'), forumlist_profile_advanced($uid));
        }
        if ($a->profile['uid'] == local_user()) {
            $profile['edit'] = array($a->get_baseurl() . '/profiles/' . $a->profile['id'], t('Edit profile'), "", t('Edit profile'));
        }
        return replace_macros($tpl, array('$title' => t('Profile'), '$profile' => $profile));
    }
    return '';
}
开发者ID:vinzv,项目名称:friendica,代码行数:95,代码来源:identity.php

示例11: prepare_body

 function prepare_body($item, $attach = false)
 {
     $a = get_app();
     call_hooks('prepare_body_init', $item);
     $cache = get_config('system', 'itemcache');
     if ($cache != '') {
         $cachefile = $cache . "/" . $item["guid"] . "-" . strtotime($item["edited"]) . "-" . hash("crc32", $item['body']);
         if (file_exists($cachefile)) {
             $s = file_get_contents($cachefile);
         } else {
             $s = prepare_text($item['body']);
             file_put_contents($cachefile, $s);
         }
     } else {
         $s = prepare_text($item['body']);
     }
     $prep_arr = array('item' => $item, 'html' => $s);
     call_hooks('prepare_body', $prep_arr);
     $s = $prep_arr['html'];
     if (!$attach) {
         return $s;
     }
     $arr = explode(',', $item['attach']);
     if (count($arr)) {
         $s .= '<div class="body-attach">';
         foreach ($arr as $r) {
             $matches = false;
             $icon = '';
             $cnt = preg_match_all('|\\[attach\\]href=\\"(.*?)\\" length=\\"(.*?)\\" type=\\"(.*?)\\" title=\\"(.*?)\\"\\[\\/attach\\]|', $r, $matches, PREG_SET_ORDER);
             if ($cnt) {
                 foreach ($matches as $mtch) {
                     $icontype = strtolower(substr($mtch[3], 0, strpos($mtch[3], '/')));
                     switch ($icontype) {
                         case 'video':
                         case 'audio':
                         case 'image':
                         case 'text':
                             $icon = '<div class="attachtype icon s22 type-' . $icontype . '"></div>';
                             break;
                         default:
                             $icon = '<div class="attachtype icon s22 type-unkn"></div>';
                             break;
                     }
                     $title = strlen(trim($mtch[4])) ? escape_tags(trim($mtch[4])) : escape_tags($mtch[1]);
                     $title .= ' ' . $mtch[2] . ' ' . t('bytes');
                     if (local_user() == $item['uid'] && $item['contact-id'] != $a->contact['id']) {
                         $the_url = $a->get_baseurl() . '/redir/' . $item['contact-id'] . '?f=1&url=' . $mtch[1];
                     } else {
                         $the_url = $mtch[1];
                     }
                     $s .= '<a href="' . strip_tags($the_url) . '" title="' . $title . '" class="attachlink" target="external-link" >' . $icon . '</a>';
                 }
             }
         }
         $s .= '<div class="clear"></div></div>';
     }
     $matches = false;
     $cnt = preg_match_all('/<(.*?)>/', $item['file'], $matches, PREG_SET_ORDER);
     if ($cnt) {
         //		logger('prepare_text: categories: ' . print_r($matches,true), LOGGER_DEBUG);
         foreach ($matches as $mtch) {
             if (strlen($x)) {
                 $x .= ',';
             }
             $x .= xmlify(file_tag_decode($mtch[1])) . (local_user() == $item['uid'] ? ' <a href="' . $a->get_baseurl() . '/filerm/' . $item['id'] . '?f=&cat=' . xmlify(file_tag_decode($mtch[1])) . '" title="' . t('remove') . '" >' . t('[remove]') . '</a>' : '');
         }
         if (strlen($x)) {
             $s .= '<div class="categorytags"><span>' . t('Categories:') . ' </span>' . $x . '</div>';
         }
     }
     $matches = false;
     $x = '';
     $cnt = preg_match_all('/\\[(.*?)\\]/', $item['file'], $matches, PREG_SET_ORDER);
     if ($cnt) {
         //		logger('prepare_text: filed_under: ' . print_r($matches,true), LOGGER_DEBUG);
         foreach ($matches as $mtch) {
             if (strlen($x)) {
                 $x .= '&nbsp;&nbsp;&nbsp;';
             }
             $x .= xmlify(file_tag_decode($mtch[1])) . ' <a href="' . $a->get_baseurl() . '/filerm/' . $item['id'] . '?f=&term=' . xmlify(file_tag_decode($mtch[1])) . '" title="' . t('remove') . '" >' . t('[remove]') . '</a>';
         }
         if (strlen($x) && local_user() == $item['uid']) {
             $s .= '<div class="filesavetags"><span>' . t('Filed under:') . ' </span>' . $x . '</div>';
         }
     }
     // Look for spoiler
     $spoilersearch = '<blockquote class="spoiler">';
     // Remove line breaks before the spoiler
     while (strpos($s, "\n" . $spoilersearch) !== false) {
         $s = str_replace("\n" . $spoilersearch, $spoilersearch, $s);
     }
     while (strpos($s, "<br />" . $spoilersearch) !== false) {
         $s = str_replace("<br />" . $spoilersearch, $spoilersearch, $s);
     }
     while (strpos($s, $spoilersearch) !== false) {
         $pos = strpos($s, $spoilersearch);
         $rnd = random_string(8);
         $spoilerreplace = '<br /> <span id="spoiler-wrap-' . $rnd . '" style="white-space:nowrap;" class="fakelink" onclick="openClose(\'spoiler-' . $rnd . '\');">' . sprintf(t('Click to open/close')) . '</span>' . '<blockquote class="spoiler" id="spoiler-' . $rnd . '" style="display: none;">';
         $s = substr($s, 0, $pos) . $spoilerreplace . substr($s, $pos + strlen($spoilersearch));
     }
//.........这里部分代码省略.........
开发者ID:robhell,项目名称:friendica,代码行数:101,代码来源:text.php

示例12: photos_content


//.........这里部分代码省略.........
                }
            }
            $alike = array();
            $dlike = array();
            $like = '';
            $dislike = '';
            // display comments
            if ($r) {
                foreach ($r as $item) {
                    like_puller($a, $item, $alike, 'like');
                    like_puller($a, $item, $dlike, 'dislike');
                }
                $like = isset($alike[$link_item['id']]) ? format_like($alike[$link_item['id']], $alike[$link_item['id'] . '-l'], 'like', $link_item['id']) : '';
                $dislike = isset($dlike[$link_item['id']]) ? format_like($dlike[$link_item['id']], $dlike[$link_item['id'] . '-l'], 'dislike', $link_item['id']) : '';
                foreach ($r as $item) {
                    $comment = '';
                    $template = $tpl;
                    $sparkle = '';
                    if ((activity_match($item['verb'], ACTIVITY_LIKE) || activity_match($item['verb'], ACTIVITY_DISLIKE)) && $item['id'] != $item['parent']) {
                        continue;
                    }
                    $redirect_url = $a->get_baseurl() . '/redir/' . $item['cid'];
                    $profile_url = zid($item['author']['xchan_url']);
                    $sparkle = '';
                    $profile_name = $item['author']['xchan_name'];
                    $profile_avatar = $item['author']['xchan_photo_m'];
                    $profile_link = $profile_url;
                    $drop = '';
                    if ($observer['xchan_hash'] === $item['author_xchan'] || $observer['xchan_hash'] === $item['owner_xchan']) {
                        $drop = replace_macros(get_markup_template('photo_drop.tpl'), array('$id' => $item['id'], '$delete' => t('Delete')));
                    }
                    $name_e = $profile_name;
                    $title_e = $item['title'];
                    unobscure($item);
                    $body_e = prepare_text($item['body'], $item['mimetype']);
                    $comments .= replace_macros($template, array('$id' => $item['item_id'], '$mode' => 'photos', '$profile_url' => $profile_link, '$name' => $name_e, '$thumb' => $profile_avatar, '$sparkle' => $sparkle, '$title' => $title_e, '$body' => $body_e, '$ago' => relative_date($item['created']), '$indent' => $item['parent'] != $item['item_id'] ? ' comment' : '', '$drop' => $drop, '$comment' => $comment));
                }
                if ($can_post || $can_comment) {
                    $comments .= replace_macros($cmnt_tpl, array('$return_path' => '', '$jsreload' => $return_url, '$type' => 'wall-comment', '$id' => $link_item['id'], '$parent' => $link_item['id'], '$profile_uid' => $owner_uid, '$mylink' => $observer['xchan_url'], '$mytitle' => t('This is you'), '$myphoto' => $observer['xchan_photo_s'], '$comment' => t('Comment'), '$submit' => t('Submit'), '$ww' => ''));
                }
            }
            $paginate = paginate($a);
        }
        $album_e = array($album_link, $ph[0]['album']);
        $like_e = $like;
        $dislike_e = $dislike;
        $photo_tpl = get_markup_template('photo_view.tpl');
        $o .= replace_macros($photo_tpl, array('$id' => $ph[0]['id'], '$album' => $album_e, '$tools' => $tools, '$lock' => $lock, '$photo' => $photo, '$prevlink' => $prevlink, '$nextlink' => $nextlink, '$desc' => $ph[0]['description'], '$tag_hdr' => t('In This Photo:'), '$tags' => $tags, '$edit' => $edit, '$likebuttons' => $likebuttons, '$like' => $like_e, '$dislike' => $dislike_e, '$comments' => $comments, '$paginate' => $paginate));
        $a->data['photo_html'] = $o;
        return $o;
    }
    // Default - show recent photos with upload link (if applicable)
    //$o = '';
    $r = q("SELECT `resource_id`, max(`scale`) AS `scale` FROM `photo` WHERE `uid` = %d AND `album` != '%s' AND `album` != '%s' \n\t\tand ( photo_flags = %d or photo_flags = %d ) {$sql_extra} GROUP BY `resource_id`", intval($a->data['channel']['channel_id']), dbesc('Contact Photos'), dbesc(t('Contact Photos')), intval(PHOTO_NORMAL), intval(PHOTO_PROFILE));
    if (count($r)) {
        $a->set_pager_total(count($r));
        $a->set_pager_itemspage(60);
    }
    $r = q("SELECT `resource_id`, `id`, `filename`, type, `album`, max(`scale`) AS `scale` FROM `photo`\n\t\tWHERE `uid` = %d AND `album` != '%s' AND `album` != '%s'\n\t\tand ( photo_flags = %d or photo_flags = %d )  \n\t\t{$sql_extra} GROUP BY `resource_id` ORDER BY `created` DESC LIMIT %d , %d", intval($a->data['channel']['channel_id']), dbesc('Contact Photos'), dbesc(t('Contact Photos')), intval(PHOTO_NORMAL), intval(PHOTO_PROFILE), intval($a->pager['start']), intval($a->pager['itemspage']));
    $photos = array();
    if (count($r)) {
        $twist = 'rotright';
        foreach ($r as $rr) {
            if ($twist == 'rotright') {
                $twist = 'rotleft';
            } else {
                $twist = 'rotright';
            }
            $ext = $phototypes[$rr['type']];
            if ($a->get_template_engine() === 'internal') {
                $alt_e = template_escape($rr['filename']);
                $name_e = template_escape($rr['album']);
            } else {
                $alt_e = $rr['filename'];
                $name_e = $rr['album'];
            }
            $photos[] = array('id' => $rr['id'], 'twist' => ' ' . $twist . rand(2, 4), 'link' => $a->get_baseurl() . '/photos/' . $a->data['channel']['channel_address'] . '/image/' . $rr['resource_id'], 'title' => t('View Photo'), 'src' => $a->get_baseurl() . '/photo/' . $rr['resource_id'] . '-' . ($rr['scale'] == 6 ? 4 : $rr['scale']) . '.' . $ext, 'alt' => $alt_e, 'album' => array('link' => $a->get_baseurl() . '/photos/' . $a->data['channel']['channel_address'] . '/album/' . bin2hex($rr['album']), 'name' => $name_e, 'alt' => t('View Album')));
        }
    }
    if ($_REQUEST['aj']) {
        if ($photos) {
            $o = replace_macros(get_markup_template('photosajax.tpl'), array('$photos' => $photos));
        } else {
            $o = '<div id="content-complete"></div>';
        }
        echo $o;
        killme();
    } else {
        $o .= "<script> var page_query = '" . $_GET['q'] . "'; var extra_args = '" . extra_query_args() . "' ; </script>";
        $tpl = get_markup_template('photos_recent.tpl');
        $o .= replace_macros($tpl, array('$title' => t('Recent Photos'), '$can_post' => $can_post, '$upload' => array(t('Upload New Photos'), $a->get_baseurl() . '/photos/' . $a->data['channel']['channel_address'] . '/upload'), '$photos' => $photos));
    }
    if (!$photos && $_REQUEST['aj']) {
        $o .= '<div id="content-complete"></div>';
        echo $o;
        killme();
    }
    //	$o .= paginate($a);
    return $o;
}
开发者ID:Mauru,项目名称:red,代码行数:101,代码来源:photos.php

示例13: item_store


//.........这里部分代码省略.........
            // The original author commented, but as this is a comment, the permissions
            // weren't fixed up so it will still show the comment as private unless we fix it here.
            if (intval($r[0]['forum_mode']) == 1 && !$r[0]['private']) {
                $arr['private'] = 0;
            }
        } else {
            // Allow one to see reply tweets from status.net even when
            // we don't have or can't see the original post.
            if ($force_parent) {
                logger('item_store: $force_parent=true, reply converted to top-level post.');
                $parent_id = 0;
                $arr['parent-uri'] = $arr['uri'];
                $arr['gravity'] = 0;
            } else {
                logger('item_store: item parent was not found - ignoring item');
                return 0;
            }
            $parent_deleted = 0;
        }
    }
    $r = q("SELECT `id` FROM `item` WHERE `uri` = '%s' AND `uid` = %d LIMIT 1", dbesc($arr['uri']), intval($arr['uid']));
    if ($r && count($r)) {
        logger('item-store: duplicate item ignored. ' . print_r($arr, true));
        return 0;
    }
    call_hooks('post_remote', $arr);
    if (x($arr, 'cancel')) {
        logger('item_store: post cancelled by plugin.');
        return 0;
    }
    dbesc_array($arr);
    logger('item_store: ' . print_r($arr, true), LOGGER_DATA);
    $r = dbq("INSERT INTO `item` (`" . implode("`, `", array_keys($arr)) . "`) VALUES ('" . implode("', '", array_values($arr)) . "')");
    // find the item we just created
    $r = q("SELECT `id` FROM `item` WHERE `uri` = '%s' AND `uid` = %d ORDER BY `id` ASC ", $arr['uri'], intval($arr['uid']));
    if (count($r)) {
        $current_post = $r[0]['id'];
        logger('item_store: created item ' . $current_post);
        create_tags_from_item($r[0]['id']);
    } else {
        logger('item_store: could not locate created item');
        return 0;
    }
    if (count($r) > 1) {
        logger('item_store: duplicated post occurred. Removing duplicates.');
        q("DELETE FROM `item` WHERE `uri` = '%s' AND `uid` = %d AND `id` != %d ", $arr['uri'], intval($arr['uid']), intval($current_post));
    }
    if (!$parent_id || $arr['parent-uri'] === $arr['uri']) {
        $parent_id = $current_post;
    }
    if (strlen($allow_cid) || strlen($allow_gid) || strlen($deny_cid) || strlen($deny_gid)) {
        $private = 1;
    } else {
        $private = $arr['private'];
    }
    // Set parent id - and also make sure to inherit the parent's ACL's.
    $r = q("UPDATE `item` SET `parent` = %d, `allow_cid` = '%s', `allow_gid` = '%s',\n\t\t`deny_cid` = '%s', `deny_gid` = '%s', `private` = %d, `deleted` = %d WHERE `id` = %d LIMIT 1", intval($parent_id), dbesc($allow_cid), dbesc($allow_gid), dbesc($deny_cid), dbesc($deny_gid), intval($private), intval($parent_deleted), intval($current_post));
    create_tags_from_item($current_post);
    // Complete ostatus threads
    if ($ostatus_conversation) {
        complete_conversation($current_post, $ostatus_conversation);
    }
    $arr['id'] = $current_post;
    $arr['parent'] = $parent_id;
    $arr['allow_cid'] = $allow_cid;
    $arr['allow_gid'] = $allow_gid;
    $arr['deny_cid'] = $deny_cid;
    $arr['deny_gid'] = $deny_gid;
    $arr['private'] = $private;
    $arr['deleted'] = $parent_deleted;
    // update the commented timestamp on the parent
    q("UPDATE `item` set `commented` = '%s', `changed` = '%s' WHERE `id` = %d LIMIT 1", dbesc(datetime_convert()), dbesc(datetime_convert()), intval($parent_id));
    if ($dsprsig) {
        q("insert into sign (`iid`,`signed_text`,`signature`,`signer`) values (%d,'%s','%s','%s') ", intval($current_post), dbesc($dsprsig->signed_text), dbesc($dsprsig->signature), dbesc($dsprsig->signer));
    }
    /**
     * If this is now the last-child, force all _other_ children of this parent to *not* be last-child
     */
    if ($arr['last-child']) {
        $r = q("UPDATE `item` SET `last-child` = 0 WHERE `parent-uri` = '%s' AND `uid` = %d AND `id` != %d", dbesc($arr['uri']), intval($arr['uid']), intval($current_post));
    }
    tag_deliver($arr['uid'], $current_post);
    // Store the fresh generated item into the cache
    $cachefile = get_cachefile($arr["guid"] . "-" . hash("md5", $arr['body']));
    if ($cachefile != '' and !file_exists($cachefile)) {
        $s = prepare_text($arr['body']);
        $a = get_app();
        $stamp1 = microtime(true);
        file_put_contents($cachefile, $s);
        $a->save_timestamp($stamp1, "file");
        logger('item_store: put item ' . $current_post . ' into cachefile ' . $cachefile);
    }
    $r = q('SELECT * FROM `item` WHERE id = %d', intval($current_post));
    if (count($r) == 1) {
        call_hooks('post_remote_end', $r[0]);
    } else {
        logger('item_store: new item not found in DB, id ' . $current_post);
    }
    return $current_post;
}
开发者ID:ridcully,项目名称:friendica,代码行数:101,代码来源:items.php

示例14: advanced_profile

function advanced_profile(&$a)
{
    $o .= '';
    $o .= '<h2>' . t('Profile') . '</h2>';
    if ($a->profile['name']) {
        $tpl = get_markup_template('profile_advanced.tpl');
        $profile = array();
        $profile['fullname'] = array(t('Full Name:'), $a->profile['name']);
        if ($a->profile['gender']) {
            $profile['gender'] = array(t('Gender:'), $a->profile['gender']);
        }
        if ($a->profile['dob'] && $a->profile['dob'] != '0000-00-00') {
            $year_bd_format = t('j F, Y');
            $short_bd_format = t('j F');
            $val = intval($a->profile['dob']) ? day_translate(datetime_convert('UTC', 'UTC', $a->profile['dob'] . ' 00:00 +00:00', $year_bd_format)) : day_translate(datetime_convert('UTC', 'UTC', '2001-' . substr($a->profile['dob'], 6) . ' 00:00 +00:00', $short_bd_format));
            $profile['birthday'] = array(t('Birthday:'), $val);
        }
        if ($age = age($a->profile['dob'], $a->profile['timezone'], '')) {
            $profile['age'] = array(t('Age:'), $age);
        }
        if ($a->profile['marital']) {
            $profile['marital'] = array(t('Status:'), $a->profile['marital']);
        }
        if ($a->profile['with']) {
            $profile['marital']['with'] = $a->profile['with'];
        }
        if ($a->profile['sexual']) {
            $profile['sexual'] = array(t('Sexual Preference:'), $a->profile['sexual']);
        }
        if ($a->profile['homepage']) {
            $profile['homepage'] = array(t('Homepage:'), linkify($a->profile['homepage']));
        }
        if ($a->profile['pub_keywords']) {
            $profile['pub_keywords'] = array(t('Tags:'), $a->profile['pub_keywords']);
        }
        if ($a->profile['politic']) {
            $profile['politic'] = array(t('Political Views:'), $a->profile['politic']);
        }
        if ($a->profile['religion']) {
            $profile['religion'] = array(t('Religion:'), $a->profile['religion']);
        }
        if ($txt = prepare_text($a->profile['about'])) {
            $profile['about'] = array(t('About:'), $txt);
        }
        if ($txt = prepare_text($a->profile['interest'])) {
            $profile['interest'] = array(t('Hobbies/Interests:'), $txt);
        }
        if ($txt = prepare_text($a->profile['contact'])) {
            $profile['contact'] = array(t('Contact information and Social Networks:'), $txt);
        }
        if ($txt = prepare_text($a->profile['music'])) {
            $profile['music'] = array(t('Musical interests:'), $txt);
        }
        if ($txt = prepare_text($a->profile['book'])) {
            $profile['book'] = array(t('Books, literature:'), $txt);
        }
        if ($txt = prepare_text($a->profile['tv'])) {
            $profile['tv'] = array(t('Television:'), $txt);
        }
        if ($txt = prepare_text($a->profile['film'])) {
            $profile['film'] = array(t('Film/dance/culture/entertainment:'), $txt);
        }
        if ($txt = prepare_text($a->profile['romance'])) {
            $profile['romance'] = array(t('Love/Romance:'), $txt);
        }
        if ($txt = prepare_text($a->profile['work'])) {
            $profile['work'] = array(t('Work/employment:'), $txt);
        }
        if ($txt = prepare_text($a->profile['education'])) {
            $profile['education'] = array(t('School/education:'), $txt);
        }
    }
    return replace_macros($tpl, array('$title' => t('Profile'), '$profile' => $profile));
}
开发者ID:nextgensh,项目名称:friendica,代码行数:74,代码来源:profile_advanced.php

示例15: item_store


//.........这里部分代码省略.........
    }
    call_hooks('post_remote', $arr);
    if (x($arr, 'cancel')) {
        logger('item_store: post cancelled by plugin.');
        return 0;
    }
    dbesc_array($arr);
    logger('item_store: ' . print_r($arr, true), LOGGER_DATA);
    $r = dbq("INSERT INTO `item` (`" . implode("`, `", array_keys($arr)) . "`) VALUES ('" . implode("', '", array_values($arr)) . "')");
    // find the item we just created
    $r = q("SELECT `id` FROM `item` WHERE `uri` = '%s' AND `uid` = %d ORDER BY `id` ASC ", $arr['uri'], intval($arr['uid']));
    if (count($r)) {
        $current_post = $r[0]['id'];
        logger('item_store: created item ' . $current_post);
        // Only check for notifications on start posts
        if ($arr['parent-uri'] === $arr['uri']) {
            add_thread($r[0]['id']);
            logger('item_store: Check notification for contact ' . $arr['contact-id'] . ' and post ' . $current_post, LOGGER_DEBUG);
            // Send a notification for every new post?
            $r = q("SELECT `notify_new_posts` FROM `contact` WHERE `id` = %d AND `uid` = %d AND `notify_new_posts` LIMIT 1", intval($arr['contact-id']), intval($arr['uid']));
            if (count($r)) {
                logger('item_store: Send notification for contact ' . $arr['contact-id'] . ' and post ' . $current_post, LOGGER_DEBUG);
                $u = q("SELECT * FROM user WHERE uid = %d LIMIT 1", intval($arr['uid']));
                $item = q("SELECT * FROM `item` WHERE `id` = %d AND `uid` = %d", intval($current_post), intval($arr['uid']));
                $a = get_app();
                require_once 'include/enotify.php';
                notification(array('type' => NOTIFY_SHARE, 'notify_flags' => $u[0]['notify-flags'], 'language' => $u[0]['language'], 'to_name' => $u[0]['username'], 'to_email' => $u[0]['email'], 'uid' => $u[0]['uid'], 'item' => $item[0], 'link' => $a->get_baseurl() . '/display/' . urlencode($arr['guid']), 'source_name' => $item[0]['author-name'], 'source_link' => $item[0]['author-link'], 'source_photo' => $item[0]['author-avatar'], 'verb' => ACTIVITY_TAG, 'otype' => 'item'));
                logger('item_store: Notification sent for contact ' . $arr['contact-id'] . ' and post ' . $current_post, LOGGER_DEBUG);
            }
        }
    } else {
        logger('item_store: could not locate created item');
        return 0;
    }
    if (count($r) > 1) {
        logger('item_store: duplicated post occurred. Removing duplicates.');
        q("DELETE FROM `item` WHERE `uri` = '%s' AND `uid` = %d AND `id` != %d ", $arr['uri'], intval($arr['uid']), intval($current_post));
    }
    if (!$parent_id || $arr['parent-uri'] === $arr['uri']) {
        $parent_id = $current_post;
    }
    if (strlen($allow_cid) || strlen($allow_gid) || strlen($deny_cid) || strlen($deny_gid)) {
        $private = 1;
    } else {
        $private = $arr['private'];
    }
    // Set parent id - and also make sure to inherit the parent's ACLs.
    $r = q("UPDATE `item` SET `parent` = %d, `allow_cid` = '%s', `allow_gid` = '%s',\n\t\t`deny_cid` = '%s', `deny_gid` = '%s', `private` = %d, `deleted` = %d WHERE `id` = %d", intval($parent_id), dbesc($allow_cid), dbesc($allow_gid), dbesc($deny_cid), dbesc($deny_gid), intval($private), intval($parent_deleted), intval($current_post));
    // Complete ostatus threads
    if ($ostatus_conversation) {
        complete_conversation($current_post, $ostatus_conversation);
    }
    $arr['id'] = $current_post;
    $arr['parent'] = $parent_id;
    $arr['allow_cid'] = $allow_cid;
    $arr['allow_gid'] = $allow_gid;
    $arr['deny_cid'] = $deny_cid;
    $arr['deny_gid'] = $deny_gid;
    $arr['private'] = $private;
    $arr['deleted'] = $parent_deleted;
    // update the commented timestamp on the parent
    q("UPDATE `item` set `commented` = '%s', `changed` = '%s' WHERE `id` = %d", dbesc(datetime_convert()), dbesc(datetime_convert()), intval($parent_id));
    update_thread($parent_id);
    if ($dsprsig) {
        q("insert into sign (`iid`,`signed_text`,`signature`,`signer`) values (%d,'%s','%s','%s') ", intval($current_post), dbesc($dsprsig->signed_text), dbesc($dsprsig->signature), dbesc($dsprsig->signer));
    }
    /**
     * If this is now the last-child, force all _other_ children of this parent to *not* be last-child
     */
    if ($arr['last-child']) {
        $r = q("UPDATE `item` SET `last-child` = 0 WHERE `parent-uri` = '%s' AND `uid` = %d AND `id` != %d", dbesc($arr['uri']), intval($arr['uid']), intval($current_post));
    }
    $deleted = tag_deliver($arr['uid'], $current_post);
    // current post can be deleted if is for a communuty page and no mention are
    // in it.
    if (!$deleted) {
        // Store the fresh generated item into the cache
        $cachefile = get_cachefile($arr["guid"] . "-" . hash("md5", $arr['body']));
        if ($cachefile != '' and !file_exists($cachefile)) {
            $s = prepare_text($arr['body']);
            $a = get_app();
            $stamp1 = microtime(true);
            file_put_contents($cachefile, $s);
            $a->save_timestamp($stamp1, "file");
            logger('item_store: put item ' . $current_post . ' into cachefile ' . $cachefile);
        }
        $r = q('SELECT * FROM `item` WHERE id = %d', intval($current_post));
        if (count($r) == 1) {
            call_hooks('post_remote_end', $r[0]);
        } else {
            logger('item_store: new item not found in DB, id ' . $current_post);
        }
    }
    create_tags_from_item($current_post);
    create_files_from_item($current_post);
    if ($notify) {
        proc_run('php', "include/notifier.php", $notify_type, $current_post);
    }
    return $current_post;
}
开发者ID:jzacman,项目名称:friendica,代码行数:101,代码来源:items.php


注:本文中的prepare_text函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。