Exemple #1
0
function status_editor($a, $x, $popup = false)
{
    $o = '';
    $geotag = $x['allow_location'] ? replace_macros(get_markup_template('jot_geotag.tpl'), array()) : '';
    $plaintext = true;
    //	if(feature_enabled(local_channel(),'richtext'))
    //		$plaintext = false;
    $voting = feature_enabled(local_channel(), 'consensus_tools');
    $mimeselect = '';
    if (array_key_exists('mimetype', $x) && $x['mimetype']) {
        if ($x['mimetype'] != 'text/bbcode') {
            $plaintext = true;
        }
        if ($x['mimetype'] === 'choose') {
            $mimeselect = mimetype_select($x['profile_uid']);
        } else {
            $mimeselect = '<input type="hidden" name="mimetype" value="' . $x['mimetype'] . '" />';
        }
    }
    $layoutselect = '';
    if (array_key_exists('layout', $x) && $x['layout']) {
        if ($x['layout'] === 'choose') {
            $layoutselect = layout_select($x['profile_uid']);
        } else {
            $layoutselect = '<input type="hidden" name="layout_mid" value="' . $x['layout'] . '" />';
        }
    }
    if (array_key_exists('channel_select', $x) && $x['channel_select']) {
        require_once 'include/identity.php';
        $id_select = identity_selector();
    } else {
        $id_select = '';
    }
    $webpage = x($x, 'webpage') ? $x['webpage'] : '';
    $tpl = get_markup_template('jot-header.tpl');
    $a->page['htmlhead'] .= replace_macros($tpl, array('$newpost' => 'true', '$baseurl' => $a->get_baseurl(true), '$editselect' => $plaintext ? 'none' : '/(profile-jot-text|prvmail-text)/', '$geotag' => $geotag, '$nickname' => $x['nickname'], '$ispublic' => t('Visible to <strong>everybody</strong>'), '$linkurl' => t('Please enter a link URL:'), '$vidurl' => t('Please enter a video link/URL:'), '$audurl' => t('Please enter an audio link/URL:'), '$term' => t('Tag term:'), '$fileas' => t('Save to Folder:'), '$whereareu' => t('Where are you right now?'), '$expireswhen' => t('Expires YYYY-MM-DD HH:MM')));
    $tpl = get_markup_template('jot.tpl');
    $jotplugins = '';
    $jotnets = '';
    $preview = t('Preview');
    //	$preview = ((feature_enabled($x['profile_uid'],'preview')) ? t('Preview') : '');
    if (x($x, 'nopreview')) {
        $preview = '';
    }
    $defexpire = ($z = get_pconfig($x['profile_uid'], 'system', 'default_post_expire')) && !$webpage ? $z : '';
    if ($defexpire) {
        $defexpire = datetime_convert('UTC', date_default_timezone_get(), $defexpire, 'Y-m-d H:i');
    }
    $cipher = get_pconfig($x['profile_uid'], 'system', 'default_cipher');
    if (!$cipher) {
        $cipher = 'aes256';
    }
    call_hooks('jot_tool', $jotplugins);
    call_hooks('jot_networks', $jotnets);
    $o .= replace_macros($tpl, array('$return_path' => x($x, 'return_path') ? $x['return_path'] : $a->query_string, '$action' => $a->get_baseurl(true) . '/item', '$share' => x($x, 'button') ? $x['button'] : t('Share'), '$webpage' => $webpage, '$placeholdpagetitle' => x($x, 'ptlabel') ? $x['ptlabel'] : t('Page link title'), '$pagetitle' => x($x, 'pagetitle') ? $x['pagetitle'] : '', '$id_select' => $id_select, '$id_seltext' => t('Post as'), '$writefiles' => perm_is_allowed($x['profile_uid'], get_observer_hash(), 'post_photos') || perm_is_allowed($x['profile_uid'], get_observer_hash(), 'write_storage'), '$bold' => t('Bold'), '$italic' => t('Italic'), '$underline' => t('Underline'), '$quote' => t('Quote'), '$code' => t('Code'), '$upload' => t('Upload photo'), '$shortupload' => t('upload photo'), '$attach' => t('Attach file'), '$shortattach' => t('attach file'), '$weblink' => t('Insert web link'), '$shortweblink' => t('web link'), '$video' => t('Insert video link'), '$shortvideo' => t('video link'), '$audio' => t('Insert audio link'), '$shortaudio' => t('audio link'), '$setloc' => t('Set your location'), '$shortsetloc' => t('set location'), '$voting' => t('Toggle voting'), '$feature_voting' => $voting, '$consensus' => 0, '$noloc' => get_pconfig($x['profile_uid'], 'system', 'use_browser_location') ? t('Clear browser location') : '', '$shortnoloc' => t('clear location'), '$title' => x($x, 'title') ? htmlspecialchars($x['title'], ENT_COMPAT, 'UTF-8') : '', '$placeholdertitle' => t('Title (optional)'), '$catsenabled' => feature_enabled($x['profile_uid'], 'categories') && !$webpage ? 'categories' : '', '$category' => "", '$placeholdercategory' => t('Categories (optional, comma-separated list)'), '$wait' => t('Please wait'), '$permset' => t('Permission settings'), '$shortpermset' => t('permissions'), '$ptyp' => $notes_cid ? 'note' : 'wall', '$content' => x($x, 'body') ? htmlspecialchars($x['body'], ENT_COMPAT, 'UTF-8') : '', '$post_id' => '', '$baseurl' => $a->get_baseurl(true), '$defloc' => $x['default_location'], '$visitor' => $x['visitor'], '$public' => t('Public post'), '$jotnets' => $jotnets, '$emtitle' => t('Example: bob@example.com, mary@example.com'), '$lockstate' => $x['lockstate'], '$acl' => $x['acl'], '$mimeselect' => $mimeselect, '$layoutselect' => $layoutselect, '$showacl' => array_key_exists('showacl', $x) ? $x['showacl'] : true, '$bang' => $x['bang'], '$profile_uid' => $x['profile_uid'], '$preview' => $preview, '$source' => x($x, 'source') ? $x['source'] : '', '$jotplugins' => $jotplugins, '$defexpire' => $defexpire, '$feature_expire' => feature_enabled($x['profile_uid'], 'content_expire') && !$webpage ? true : false, '$expires' => t('Set expiration date'), '$feature_encrypt' => feature_enabled($x['profile_uid'], 'content_encrypt') && !$webpage ? true : false, '$encrypt' => t('Encrypt text'), '$cipher' => $cipher, '$expiryModalOK' => t('OK'), '$expiryModalCANCEL' => t('Cancel')));
    if ($popup === true) {
        $o = '<div id="jot-popup" style="display:none">' . $o . '</div>';
    }
    return $o;
}
/**
 * This is our general purpose content editor. 
 * It was once nicknamed "jot" and you may see references to "jot" littered throughout the code.
 * They are referring to the content editor or components thereof. 
 */
function status_editor($a, $x, $popup = false)
{
    $o = '';
    $c = channelx_by_n($x['profile_uid']);
    if ($c && $c['channel_moved']) {
        return $o;
    }
    $plaintext = true;
    //	if(feature_enabled(local_channel(),'richtext'))
    //		$plaintext = false;
    $feature_voting = feature_enabled($x['profile_uid'], 'consensus_tools');
    if (x($x, 'hide_voting')) {
        $feature_voting = false;
    }
    $feature_expire = feature_enabled($x['profile_uid'], 'content_expire') && !$webpage ? true : false;
    if (x($x, 'hide_expire')) {
        $feature_expire = false;
    }
    $feature_future = feature_enabled($x['profile_uid'], 'delayed_posting') && !$webpage ? true : false;
    if (x($x, 'hide_future')) {
        $feature_future = false;
    }
    $geotag = $x['allow_location'] ? replace_macros(get_markup_template('jot_geotag.tpl'), array()) : '';
    $setloc = t('Set your location');
    $clearloc = get_pconfig($x['profile_uid'], 'system', 'use_browser_location') ? t('Clear browser location') : '';
    if (x($x, 'hide_location')) {
        $geotag = $setloc = $clearloc = '';
    }
    $mimetype = x($x, 'mimetype') ? $x['mimetype'] : 'text/bbcode';
    $mimeselect = x($x, 'mimeselect') ? $x['mimeselect'] : false;
    if ($mimeselect) {
        $mimeselect = mimetype_select($x['profile_uid'], $mimetype);
    } else {
        $mimeselect = '<input type="hidden" name="mimetype" value="' . $mimetype . '" />';
    }
    $weblink = $mimetype === 'text/bbcode' ? t('Insert web link') : false;
    if (x($x, 'hide_weblink')) {
        $weblink = false;
    }
    $embedPhotos = t('Embed image from photo albums');
    $writefiles = $mimetype === 'text/bbcode' ? perm_is_allowed($x['profile_uid'], get_observer_hash(), 'write_storage') : false;
    if (x($x, 'hide_attach')) {
        $writefiles = false;
    }
    $layout = x($x, 'layout') ? $x['layout'] : '';
    $layoutselect = x($x, 'layoutselect') ? $x['layoutselect'] : false;
    if ($layoutselect) {
        $layoutselect = layout_select($x['profile_uid'], $layout);
    } else {
        $layoutselect = '<input type="hidden" name="layout_mid" value="' . $layout . '" />';
    }
    if (array_key_exists('channel_select', $x) && $x['channel_select']) {
        require_once 'include/channel.php';
        $id_select = identity_selector();
    } else {
        $id_select = '';
    }
    $webpage = x($x, 'webpage') ? $x['webpage'] : '';
    $tpl = get_markup_template('jot-header.tpl');
    App::$page['htmlhead'] .= replace_macros($tpl, array('$baseurl' => z_root(), '$editselect' => $plaintext ? 'none' : '/(profile-jot-text|prvmail-text)/', '$pretext' => x($x, 'pretext') ? $x['pretext'] : '', '$geotag' => $geotag, '$nickname' => $x['nickname'], '$linkurl' => t('Please enter a link URL:'), '$term' => t('Tag term:'), '$whereareu' => t('Where are you right now?'), '$editor_autocomplete' => x($x, 'editor_autocomplete') ? $x['editor_autocomplete'] : '', '$bbco_autocomplete' => x($x, 'bbco_autocomplete') ? $x['bbco_autocomplete'] : '', '$modalchooseimages' => t('Choose images to embed'), '$modalchoosealbum' => t('Choose an album'), '$modaldiffalbum' => t('Choose a different album...'), '$modalerrorlist' => t('Error getting album list'), '$modalerrorlink' => t('Error getting photo link'), '$modalerroralbum' => t('Error getting album')));
    $tpl = get_markup_template('jot.tpl');
    $jotplugins = '';
    $preview = t('Preview');
    if (x($x, 'hide_preview')) {
        $preview = '';
    }
    $defexpire = ($z = get_pconfig($x['profile_uid'], 'system', 'default_post_expire')) && !$webpage ? $z : '';
    if ($defexpire) {
        $defexpire = datetime_convert('UTC', date_default_timezone_get(), $defexpire, 'Y-m-d H:i');
    }
    $defpublish = ($z = get_pconfig($x['profile_uid'], 'system', 'default_post_publish')) && !$webpage ? $z : '';
    if ($defpublish) {
        $defpublish = datetime_convert('UTC', date_default_timezone_get(), $defpublish, 'Y-m-d H:i');
    }
    $cipher = get_pconfig($x['profile_uid'], 'system', 'default_cipher');
    if (!$cipher) {
        $cipher = 'aes256';
    }
    call_hooks('jot_tool', $jotplugins);
    $o .= replace_macros($tpl, array('$return_path' => x($x, 'return_path') ? $x['return_path'] : App::$query_string, '$action' => z_root() . '/item', '$share' => x($x, 'button') ? $x['button'] : t('Share'), '$webpage' => $webpage, '$placeholdpagetitle' => x($x, 'ptlabel') ? $x['ptlabel'] : t('Page link name'), '$pagetitle' => x($x, 'pagetitle') ? $x['pagetitle'] : '', '$id_select' => $id_select, '$id_seltext' => t('Post as'), '$writefiles' => $writefiles, '$bold' => t('Bold'), '$italic' => t('Italic'), '$underline' => t('Underline'), '$quote' => t('Quote'), '$code' => t('Code'), '$attach' => t('Attach file'), '$weblink' => $weblink, '$embedPhotos' => $embedPhotos, '$embedPhotosModalTitle' => t('Embed an image from your albums'), '$embedPhotosModalCancel' => t('Cancel'), '$embedPhotosModalOK' => t('OK'), '$setloc' => $setloc, '$voting' => t('Toggle voting'), '$feature_voting' => $feature_voting, '$consensus' => 0, '$clearloc' => $clearloc, '$title' => x($x, 'title') ? htmlspecialchars($x['title'], ENT_COMPAT, 'UTF-8') : '', '$placeholdertitle' => x($x, 'placeholdertitle') ? $x['placeholdertitle'] : t('Title (optional)'), '$catsenabled' => feature_enabled($x['profile_uid'], 'categories') && !$webpage ? 'categories' : '', '$category' => x($x, 'category') ? $x['category'] : '', '$placeholdercategory' => t('Categories (optional, comma-separated list)'), '$permset' => t('Permission settings'), '$ptyp' => x($x, 'ptyp') ? $x['ptyp'] : '', '$content' => x($x, 'body') ? htmlspecialchars($x['body'], ENT_COMPAT, 'UTF-8') : '', '$attachment' => x($x, 'attachment') ? $x['attachment'] : '', '$post_id' => x($x, 'post_id') ? $x['post_id'] : '', '$defloc' => $x['default_location'], '$visitor' => $x['visitor'], '$lockstate' => $x['lockstate'], '$acl' => $x['acl'], '$mimeselect' => $mimeselect, '$layoutselect' => $layoutselect, '$showacl' => array_key_exists('showacl', $x) ? $x['showacl'] : true, '$bang' => $x['bang'], '$profile_uid' => $x['profile_uid'], '$preview' => $preview, '$source' => x($x, 'source') ? $x['source'] : '', '$jotplugins' => $jotplugins, '$defexpire' => $defexpire, '$feature_expire' => $feature_expire, '$expires' => t('Set expiration date'), '$defpublish' => $defpublish, '$feature_future' => $feature_future, '$future_txt' => t('Set publish date'), '$feature_encrypt' => feature_enabled($x['profile_uid'], 'content_encrypt') && !$webpage ? true : false, '$encrypt' => t('Encrypt text'), '$cipher' => $cipher, '$expiryModalOK' => t('OK'), '$expiryModalCANCEL' => t('Cancel'), '$expanded' => x($x, 'expanded') ? $x['expanded'] : false, '$bbcode' => x($x, 'bbcode') ? $x['bbcode'] : false));
    if ($popup === true) {
        $o = '<div id="jot-popup" style="display:none">' . $o . '</div>';
    }
    return $o;
}