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


PHP URLify::transliterate方法代码示例

本文整理汇总了PHP中URLify::transliterate方法的典型用法代码示例。如果您正苦于以下问题:PHP URLify::transliterate方法的具体用法?PHP URLify::transliterate怎么用?PHP URLify::transliterate使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在URLify的用法示例。


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

示例1: filter

 /**
  * @param string $value
  * @return string
  */
 public function filter($value)
 {
     $transliterated = \URLify::transliterate($value);
     if ($this->replaceSpacesWithDashes) {
         $filter = new SeparatorToSeparator(' ', '_');
         $transliterated = $filter->filter($transliterated);
     } else {
         if ($this->replaceSpacesWithSeparator) {
             $filter = new SeparatorToSeparator(' ', $this->separator);
             $transliterated = $filter->filter($transliterated);
         }
     }
     return $transliterated;
 }
开发者ID:spalax,项目名称:zf2-libs,代码行数:18,代码来源:Transliterate.php

示例2: new_channel_init

function new_channel_init(&$a)
{
    $cmd = argc() > 1 ? argv(1) : '';
    if ($cmd === 'autofill.json') {
        require_once 'library/urlify/URLify.php';
        $result = array('error' => false, 'message' => '');
        $n = trim($_REQUEST['name']);
        $x = strtolower(URLify::transliterate($n));
        $test = array();
        // first name
        if (strpos($x, ' ')) {
            $test[] = legal_webbie(substr($x, 0, strpos($x, ' ')));
        }
        if ($test[0]) {
            // first name plus first initial of last
            $test[] = strpos($x, ' ') ? $test[0] . legal_webbie(trim(substr($x, strpos($x, ' '), 2))) : '';
            // first name plus random number
            $test[] = $test[0] . mt_rand(1000, 9999);
        }
        // fullname
        $test[] = legal_webbie($x);
        // fullname plus random number
        $test[] = legal_webbie($x) . mt_rand(1000, 9999);
        json_return_and_die(check_webbie($test));
    }
    if ($cmd === 'checkaddr.json') {
        require_once 'library/urlify/URLify.php';
        $result = array('error' => false, 'message' => '');
        $n = trim($_REQUEST['nick']);
        $x = strtolower(URLify::transliterate($n));
        $test = array();
        $n = legal_webbie($x);
        if (strlen($n)) {
            $test[] = $n;
            $test[] = $n . mt_rand(1000, 9999);
        }
        for ($y = 0; $y < 100; $y++) {
            $test[] = 'id' . mt_rand(1000, 9999);
        }
        json_return_and_die(check_webbie($test));
    }
}
开发者ID:Gillesq,项目名称:hubzilla,代码行数:42,代码来源:new_channel.php

示例3: urlify

 public function urlify($url)
 {
     $url = \URLify::transliterate($url);
     // remove all these words from the string before urlifying
     $remove_pattern = '~[^-.\\w\\s/?&+]~u';
     $url = preg_replace($remove_pattern, '', $url);
     $url = str_replace('_', ' ', $url);
     $url = preg_replace('~^\\s+|\\s+$~', '', $url);
     //        $url = preg_replace ('~\s{2,}~', ' ', $url);
     $url = preg_replace('~[-\\s]+~', '-', $url);
     $url = strtolower(trim($url, '-'));
     return $url;
 }
开发者ID:etconsilium,项目名称:applejackyll,代码行数:13,代码来源:Applejackyll.php

示例4: get


//.........这里部分代码省略.........
                 $_SESSION['my_url'] = $r[0]['xchan_url'];
                 $_SESSION['my_address'] = $r[0]['xchan_addr'];
                 $arr = array('xchan' => $r[0], 'session' => $_SESSION);
                 call_hooks('magic_auth_openid_success', $arr);
                 \App::set_observer($r[0]);
                 require_once 'include/security.php';
                 \App::set_groups(init_groups_visitor($_SESSION['visitor_id']));
                 info(sprintf(t('Welcome %s. Remote authentication successful.'), $r[0]['xchan_name']));
                 logger('mod_openid: remote auth success from ' . $r[0]['xchan_addr']);
                 if ($_SESSION['return_url']) {
                     goaway($_SESSION['return_url']);
                 }
                 goaway(z_root());
             }
             // no xchan...
             // create one.
             // We should probably probe the openid url and figure out if they have any kind of
             // social presence we might be able to scrape some identifying info from.
             $name = $authid;
             $url = trim($_REQUEST['openid_identity'], '/');
             if (strpos($url, 'http') === false) {
                 $url = 'https://' . $url;
             }
             $pphoto = z_root() . '/' . get_default_profile_photo();
             $parsed = @parse_url($url);
             if ($parsed) {
                 $host = $parsed['host'];
             }
             $attr = $openid->getAttributes();
             if (is_array($attr) && count($attr)) {
                 foreach ($attr as $k => $v) {
                     if ($k === 'namePerson/friendly') {
                         $nick = notags(trim($v));
                     }
                     if ($k === 'namePerson/first') {
                         $first = notags(trim($v));
                     }
                     if ($k === 'namePerson') {
                         $name = notags(trim($v));
                     }
                     if ($k === 'contact/email') {
                         $addr = notags(trim($v));
                     }
                     if ($k === 'media/image/aspect11') {
                         $photosq = trim($v);
                     }
                     if ($k === 'media/image/default') {
                         $photo_other = trim($v);
                     }
                 }
             }
             if (!$nick) {
                 if ($first) {
                     $nick = $first;
                 } else {
                     $nick = $name;
                 }
             }
             require_once 'library/urlify/URLify.php';
             $x = strtolower(\URLify::transliterate($nick));
             if ($nick & $host) {
                 $addr = $nick . '@' . $host;
             }
             $network = 'unknown';
             if ($photosq) {
                 $pphoto = $photosq;
             } elseif ($photo_other) {
                 $pphoto = $photo_other;
             }
             $mimetype = guess_image_type($pphoto);
             $x = q("insert into xchan ( xchan_hash, xchan_guid, xchan_guid_sig, xchan_pubkey, xchan_photo_mimetype,\n\t                xchan_photo_l, xchan_addr, xchan_url, xchan_connurl, xchan_follow, xchan_connpage, xchan_name, xchan_network, xchan_photo_date, \n\t\t\t\t\txchan_name_date, xchan_hidden)\n\t                values ( '%s', '%s', '%s', '%s' , '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', 1) ", dbesc($url), dbesc(''), dbesc(''), dbesc(''), dbesc($mimetype), dbesc($pphoto), dbesc($addr), dbesc($url), dbesc(''), dbesc(''), dbesc(''), dbesc($name), dbesc($network), dbesc(datetime_convert()), dbesc(datetime_convert()));
             if ($x) {
                 $r = q("select * from xchan where xchan_hash = '%s' limit 1", dbesc($url));
                 if ($r) {
                     $photos = import_xchan_photo($pphoto, $url);
                     if ($photos) {
                         $z = q("update xchan set xchan_photo_date = '%s', xchan_photo_l = '%s', xchan_photo_m = '%s', \n\t\t\t\t\t\t\t\txchan_photo_s = '%s', xchan_photo_mimetype = '%s' where xchan_hash = '%s'", dbesc(datetime_convert()), dbesc($photos[0]), dbesc($photos[1]), dbesc($photos[2]), dbesc($photos[3]), dbesc($url));
                     }
                     set_xconfig($url, 'system', 'openid', $authid);
                     $_SESSION['authenticated'] = 1;
                     $_SESSION['visitor_id'] = $r[0]['xchan_hash'];
                     $_SESSION['my_url'] = $r[0]['xchan_url'];
                     $_SESSION['my_address'] = $r[0]['xchan_addr'];
                     $arr = array('xchan' => $r[0], 'session' => $_SESSION);
                     call_hooks('magic_auth_openid_success', $arr);
                     \App::set_observer($r[0]);
                     info(sprintf(t('Welcome %s. Remote authentication successful.'), $r[0]['xchan_name']));
                     logger('mod_openid: remote auth success from ' . $r[0]['xchan_addr']);
                     if ($_SESSION['return_url']) {
                         goaway($_SESSION['return_url']);
                     }
                     goaway(z_root());
                 }
             }
         }
     }
     notice(t('Login failed.') . EOL);
     goaway(z_root());
     // NOTREACHED
 }
开发者ID:phellmes,项目名称:hubzilla-addons,代码行数:101,代码来源:Mod_Openid.php

示例5: item_post

function item_post(&$a)
{
    // This will change. Figure out who the observer is and whether or not
    // they have permission to post here. Else ignore the post.
    if (!local_channel() && !remote_channel() && !x($_REQUEST, 'commenter')) {
        return;
    }
    require_once 'include/security.php';
    $uid = local_channel();
    $channel = null;
    $observer = null;
    /**
     * Is this a reply to something?
     */
    $parent = x($_REQUEST, 'parent') ? intval($_REQUEST['parent']) : 0;
    $parent_mid = x($_REQUEST, 'parent_mid') ? trim($_REQUEST['parent_mid']) : '';
    $remote_xchan = x($_REQUEST, 'remote_xchan') ? trim($_REQUEST['remote_xchan']) : false;
    $r = q("select * from xchan where xchan_hash = '%s' limit 1", dbesc($remote_xchan));
    if ($r) {
        $remote_observer = $r[0];
    } else {
        $remote_xchan = $remote_observer = false;
    }
    $profile_uid = x($_REQUEST, 'profile_uid') ? intval($_REQUEST['profile_uid']) : 0;
    require_once 'include/identity.php';
    $sys = get_sys_channel();
    if ($sys && $profile_uid && $sys['channel_id'] == $profile_uid && is_site_admin()) {
        $uid = intval($sys['channel_id']);
        $channel = $sys;
        $observer = $sys;
    }
    if (x($_REQUEST, 'dropitems')) {
        require_once 'include/items.php';
        $arr_drop = explode(',', $_REQUEST['dropitems']);
        drop_items($arr_drop);
        $json = array('success' => 1);
        echo json_encode($json);
        killme();
    }
    call_hooks('post_local_start', $_REQUEST);
    //	 logger('postvars ' . print_r($_REQUEST,true), LOGGER_DATA);
    $api_source = x($_REQUEST, 'api_source') && $_REQUEST['api_source'] ? true : false;
    $consensus = intval($_REQUEST['consensus']);
    // 'origin' (if non-zero) indicates that this network is where the message originated,
    // for the purpose of relaying comments to other conversation members.
    // If using the API from a device (leaf node) you must set origin to 1 (default) or leave unset.
    // If the API is used from another network with its own distribution
    // and deliveries, you may wish to set origin to 0 or false and allow the other
    // network to relay comments.
    // If you are unsure, it is prudent (and important) to leave it unset.
    $origin = $api_source && array_key_exists('origin', $_REQUEST) ? intval($_REQUEST['origin']) : 1;
    // To represent message-ids on other networks - this will create an item_id record
    $namespace = $api_source && array_key_exists('namespace', $_REQUEST) ? strip_tags($_REQUEST['namespace']) : '';
    $remote_id = $api_source && array_key_exists('remote_id', $_REQUEST) ? strip_tags($_REQUEST['remote_id']) : '';
    $owner_hash = null;
    $message_id = x($_REQUEST, 'message_id') && $api_source ? strip_tags($_REQUEST['message_id']) : '';
    $created = x($_REQUEST, 'created') ? datetime_convert('UTC', 'UTC', $_REQUEST['created']) : datetime_convert();
    $post_id = x($_REQUEST, 'post_id') ? intval($_REQUEST['post_id']) : 0;
    $app = x($_REQUEST, 'source') ? strip_tags($_REQUEST['source']) : '';
    $return_path = x($_REQUEST, 'return') ? $_REQUEST['return'] : '';
    $preview = x($_REQUEST, 'preview') ? intval($_REQUEST['preview']) : 0;
    $categories = x($_REQUEST, 'category') ? escape_tags($_REQUEST['category']) : '';
    $webpage = x($_REQUEST, 'webpage') ? intval($_REQUEST['webpage']) : 0;
    $pagetitle = x($_REQUEST, 'pagetitle') ? escape_tags(urlencode($_REQUEST['pagetitle'])) : '';
    $layout_mid = x($_REQUEST, 'layout_mid') ? escape_tags($_REQUEST['layout_mid']) : '';
    $plink = x($_REQUEST, 'permalink') ? escape_tags($_REQUEST['permalink']) : '';
    $obj_type = x($_REQUEST, 'obj_type') ? escape_tags($_REQUEST['obj_type']) : ACTIVITY_OBJ_NOTE;
    // allow API to bulk load a bunch of imported items with sending out a bunch of posts.
    $nopush = x($_REQUEST, 'nopush') ? intval($_REQUEST['nopush']) : 0;
    /*
     * Check service class limits
     */
    if ($uid && !x($_REQUEST, 'parent') && !x($_REQUEST, 'post_id')) {
        $ret = item_check_service_class($uid, $_REQUEST['webpage'] == ITEM_WEBPAGE ? true : false);
        if (!$ret['success']) {
            notice(t($ret['message']) . EOL);
            if (x($_REQUEST, 'return')) {
                goaway($a->get_baseurl() . "/" . $return_path);
            }
            killme();
        }
    }
    if ($pagetitle) {
        require_once 'library/urlify/URLify.php';
        $pagetitle = strtolower(URLify::transliterate($pagetitle));
    }
    $item_flags = $item_restrict = 0;
    $route = '';
    $parent_item = null;
    $parent_contact = null;
    $thr_parent = '';
    $parid = 0;
    $r = false;
    if ($parent || $parent_mid) {
        if (!x($_REQUEST, 'type')) {
            $_REQUEST['type'] = 'net-comment';
        }
        if ($obj_type == ACTIVITY_OBJ_POST) {
            $obj_type = ACTIVITY_OBJ_COMMENT;
        }
//.........这里部分代码省略.........
开发者ID:einervonvielen,项目名称:redmatrix,代码行数:101,代码来源:item.php

示例6: purify_username

 /**
  * Modifies a given username accordingly to the specification for valid characters and length.
  * @param $username string                The input username.
  * @param bool $strict (optional)        When this flag is TRUE, the result is guaranteed for full compliance, otherwise compliance may be partial. The default value is FALSE.
  * @param string $encoding (optional)    The character encoding for the input names. If it is omitted, the platform character set will be used by default.
  * @return string                        The resulting purified username.
  */
 public static function purify_username($username, $strict = false, $encoding = null)
 {
     if ($strict) {
         // 1. Conversion of unacceptable letters (latinian letters with accents for example) into ASCII letters in order they not to be totally removed.
         // 2. Applying the strict purifier.
         // 3. Length limitation.
         $return = api_get_setting('login_is_email') == 'true' ? substr(preg_replace(USERNAME_PURIFIER_MAIL, '', $username), 0, USERNAME_MAX_LENGTH) : substr(preg_replace(USERNAME_PURIFIER, '', $username), 0, USERNAME_MAX_LENGTH);
         $return = URLify::transliterate($return);
         return $return;
     }
     // 1. Applying the shallow purifier.
     // 2. Length limitation.
     return substr(preg_replace(USERNAME_PURIFIER_SHALLOW, '', $username), 0, USERNAME_MAX_LENGTH);
 }
开发者ID:secuencia24,项目名称:chamilo-lms,代码行数:21,代码来源:usermanager.lib.php

示例7: transliterate

 /**
  * Converts UTF8 into Latin
  *
  * @param $value
  *
  * @return mixed
  */
 public static function transliterate($value)
 {
     return \URLify::transliterate($value);
 }
开发者ID:Jandersolutions,项目名称:mautic,代码行数:11,代码来源:InputHelper.php

示例8: api_transliterate

/**
 * Transliterates a string with arbitrary encoding into a plain ASCII string.
 *
 * Example:
 * echo api_transliterate(api_html_entity_decode(
 *     '&#1060;&#1105;&#1076;&#1086;&#1088; '.
 *     '&#1052;&#1080;&#1093;&#1072;&#1081;&#1083;&#1086;&#1074;&#1080;&#1095; '.
 *     '&#1044;&#1086;&#1089;&#1090;&#1086;&#1077;&#1074;&#1082;&#1080;&#1081;',
 *     ENT_QUOTES, 'UTF-8'), 'X', 'UTF-8');
 * The output should be: Fyodor Mihaylovich Dostoevkiy
 *
 * @param string $string                    The input string.
 * @param string $unknown (optional)        Replacement character for unknown characters and illegal UTF-8 sequences.
 * @param string $from_encoding (optional)    The encoding of the input string. If it is omited, the platform character set is assumed.
 * @return string                            Plain ASCII output.
 */
function api_transliterate($string, $unknown = '?', $from_encoding = null)
{
    return URLify::transliterate($string);
}
开发者ID:ragebat,项目名称:chamilo-lms,代码行数:20,代码来源:internationalization.lib.php

示例9: impel_init

function impel_init(&$a)
{
    $ret = array('success' => false);
    if (!local_channel()) {
        json_return_and_die($ret);
    }
    logger('impel: ' . print_r($_REQUEST, true), LOGGER_DATA);
    $elm = $_REQUEST['element'];
    $x = base64url_decode($elm);
    if (!$x) {
        json_return_and_die($ret);
    }
    $j = json_decode($x, true);
    if (!$j) {
        json_return_and_die($ret);
    }
    $channel = $a->get_channel();
    $arr = array();
    switch ($j['type']) {
        case 'webpage':
            $arr['item_restrict'] = ITEM_WEBPAGE;
            $namespace = 'WEBPAGE';
            $installed_type = t('webpage');
            break;
        case 'block':
            $arr['item_restrict'] = ITEM_BUILDBLOCK;
            $namespace = 'BUILDBLOCK';
            $installed_type = t('block');
            break;
        case 'layout':
            $arr['item_restrict'] = ITEM_PDL;
            $namespace = 'PDL';
            $installed_type = t('layout');
            break;
        default:
            logger('mod_impel: unrecognised element type' . print_r($j, true));
            break;
    }
    $arr['uid'] = local_channel();
    $arr['aid'] = $channel['channel_account_id'];
    $arr['title'] = $j['title'];
    $arr['body'] = $j['body'];
    $arr['term'] = $j['term'];
    $arr['created'] = datetime_convert('UTC', 'UTC', $j['created']);
    $arr['edited'] = datetime_convert('UTC', 'UTC', $j['edited']);
    $arr['owner_xchan'] = get_observer_hash();
    $arr['author_xchan'] = $j['author_xchan'] ? $j['author_xchan'] : get_observer_hash();
    $arr['mimetype'] = $j['mimetype'] ? $j['mimetype'] : 'text/bbcode';
    if (!$j['mid']) {
        $j['mid'] = item_message_id();
    }
    $arr['mid'] = $arr['parent_mid'] = $j['mid'];
    if ($j['pagetitle']) {
        require_once 'library/urlify/URLify.php';
        $pagetitle = strtolower(URLify::transliterate($j['pagetitle']));
    }
    // Verify ability to use html or php!!!
    $execflag = false;
    if ($arr['mimetype'] === 'application/x-php') {
        $z = q("select account_id, account_roles, channel_pageflags from account left join channel on channel_account_id = account_id where channel_id = %d limit 1", intval(local_channel()));
        if ($z && ($z[0]['account_roles'] & ACCOUNT_ROLE_ALLOWCODE || $z[0]['channel_pageflags'] & PAGE_ALLOWCODE)) {
            $execflag = true;
        }
    }
    $remote_id = 0;
    $z = q("select * from item_id where sid = '%s' and service = '%s' and uid = %d limit 1", dbesc($pagetitle), dbesc($namespace), intval(local_channel()));
    $i = q("select id from item where mid = '%s' and uid = %d limit 1", dbesc($arr['mid']), intval(local_channel()));
    if ($z && $i) {
        $remote_id = $z[0]['id'];
        $arr['id'] = $i[0]['id'];
        // don't update if it has the same timestamp as the original
        if ($arr['edited'] > $i[0]['edited']) {
            $x = item_store_update($arr, $execflag);
        }
    } else {
        $x = item_store($arr, $execflag);
    }
    if ($x['success']) {
        $item_id = $x['item_id'];
    }
    update_remote_id($channel, $item_id, $arr['item_restrict'], $pagetitle, $namespace, $remote_id, $arr['mid']);
    $ret['success'] = true;
    info(sprintf(t('%s element installed'), $installed_type));
    json_return_and_die(true);
}
开发者ID:redmatrix,项目名称:red,代码行数:85,代码来源:impel.php

示例10: dirname

<?php

//Transliterate the provided argument or stdin if the argument was not present
require_once dirname(__DIR__) . '/URLify.php';
//Print usage and exit if arguments are invalid
if ($argc < 1 || $argc > 2) {
    die("Usage (argument): php " . basename(__FILE__) . " \"<text to transliterate>\"\nUsage (pipe): <Arbitrary command> | php " . basename(__FILE__) . "\n");
}
//Process the provided argument
if ($argc === 2) {
    $s = $argv[1];
    //Or read from stdin if the argument wasn't present
} else {
    $piped = true;
    $s = file_get_contents("php://stdin");
}
echo URLify::transliterate($s) . ($piped ? "\n" : "");
开发者ID:MartinStefani,项目名称:urlify,代码行数:17,代码来源:transliterate.php

示例11: impel_init


//.........这里部分代码省略.........
        if ($j['edited']) {
            $m['menu_edited'] = datetime_convert($j['edited']);
        }
        $m['menu_flags'] = 0;
        if ($j['flags']) {
            if (in_array('bookmark', $j['flags'])) {
                $m['menu_flags'] |= MENU_BOOKMARK;
            }
            if (in_array('system', $j['flags'])) {
                $m['menu_flags'] |= MENU_SYSTEM;
            }
        }
        $menu_id = menu_create($m);
        if ($menu_id) {
            if (is_array($j['items'])) {
                foreach ($j['items'] as $it) {
                    $mitem = array();
                    $mitem['mitem_link'] = str_replace('[baseurl]', z_root(), $it['link']);
                    $mitem['mitem_desc'] = escape_tags($it['desc']);
                    $mitem['mitem_order'] = intval($it['order']);
                    if (is_array($it['flags'])) {
                        $mitem['mitem_flags'] = 0;
                        if (in_array('zid', $it['flags'])) {
                            $mitem['mitem_flags'] |= MENU_ITEM_ZID;
                        }
                        if (in_array('new-window', $it['flags'])) {
                            $mitem['mitem_flags'] |= MENU_ITEM_NEWWIN;
                        }
                        if (in_array('chatroom', $it['flags'])) {
                            $mitem['mitem_flags'] |= MENU_ITEM_CHATROOM;
                        }
                    }
                    menu_add_item($menu_id, local_channel(), $mitem);
                }
                if ($j['edited']) {
                    $x = q("update menu set menu_edited = '%s' where menu_id = %d and menu_channel_id = %d", dbesc(datetime_convert('UTC', 'UTC', $j['edited'])), intval($menu_id), intval(local_channel()));
                }
            }
            $ret['success'] = true;
        }
        $x = $ret;
    } else {
        $arr['uid'] = local_channel();
        $arr['aid'] = $channel['channel_account_id'];
        $arr['title'] = $j['title'];
        $arr['body'] = $j['body'];
        $arr['term'] = $j['term'];
        $arr['layout_mid'] = $j['layout_mid'];
        $arr['created'] = datetime_convert('UTC', 'UTC', $j['created']);
        $arr['edited'] = datetime_convert('UTC', 'UTC', $j['edited']);
        $arr['owner_xchan'] = get_observer_hash();
        $arr['author_xchan'] = $j['author_xchan'] ? $j['author_xchan'] : get_observer_hash();
        $arr['mimetype'] = $j['mimetype'] ? $j['mimetype'] : 'text/bbcode';
        if (!$j['mid']) {
            $j['mid'] = item_message_id();
        }
        $arr['mid'] = $arr['parent_mid'] = $j['mid'];
        if ($j['pagetitle']) {
            require_once 'library/urlify/URLify.php';
            $pagetitle = strtolower(URLify::transliterate($j['pagetitle']));
        }
        // Verify ability to use html or php!!!
        $execflag = false;
        if ($arr['mimetype'] === 'application/x-php') {
            $z = q("select account_id, account_roles, channel_pageflags from account left join channel on channel_account_id = account_id where channel_id = %d limit 1", intval(local_channel()));
            if ($z && ($z[0]['account_roles'] & ACCOUNT_ROLE_ALLOWCODE || $z[0]['channel_pageflags'] & PAGE_ALLOWCODE)) {
                $execflag = true;
            }
        }
        $remote_id = 0;
        $z = q("select * from item_id where sid = '%s' and service = '%s' and uid = %d limit 1", dbesc($pagetitle), dbesc($namespace), intval(local_channel()));
        $i = q("select id, edited, item_deleted from item where mid = '%s' and uid = %d limit 1", dbesc($arr['mid']), intval(local_channel()));
        if ($z && $i) {
            $remote_id = $z[0]['id'];
            $arr['id'] = $i[0]['id'];
            // don't update if it has the same timestamp as the original
            if ($arr['edited'] > $i[0]['edited']) {
                $x = item_store_update($arr, $execflag);
            }
        } else {
            if ($i && intval($i[0]['item_deleted'])) {
                // was partially deleted already, finish it off
                q("delete from item where mid = '%s' and uid = %d", dbesc($arr['mid']), intval(local_channel()));
            }
            $x = item_store($arr, $execflag);
        }
        if ($x['success']) {
            $item_id = $x['item_id'];
            update_remote_id($channel, $item_id, $arr['item_type'], $pagetitle, $namespace, $remote_id, $arr['mid']);
        }
    }
    if ($x['success']) {
        $ret['success'] = true;
        info(sprintf(t('%s element installed'), $installed_type));
    } else {
        notice(sprintf(t('%s element installation failed'), $installed_type));
    }
    //??? should perhaps return ret?
    json_return_and_die(true);
}
开发者ID:TamirAl,项目名称:hubzilla,代码行数:101,代码来源:impel.php

示例12: import_webpage_element

function import_webpage_element($element, $channel, $type)
{
    $arr = array();
    // construct information for the webpage element item table record
    switch ($type) {
        //
        //	PAGES
        //
        case 'page':
            $arr['item_type'] = ITEM_TYPE_WEBPAGE;
            $namespace = 'WEBPAGE';
            $name = $element['pagelink'];
            if ($name) {
                require_once 'library/urlify/URLify.php';
                $name = strtolower(\URLify::transliterate($name));
            }
            $arr['title'] = $element['title'];
            $arr['term'] = $element['term'];
            $arr['layout_mid'] = '';
            // by default there is no layout associated with the page
            // If a layout was specified, find it in the database and get its info. If
            // it does not exist, leave layout_mid empty
            if ($element['layout'] !== '') {
                $liid = q("select iid from iconfig where k = 'PDL' and v = '%s' and cat = 'system'", dbesc($element['layout']));
                if ($liid) {
                    $linfo = q("select mid from item where id = %d", intval($liid[0]['iid']));
                    $arr['layout_mid'] = $linfo[0]['mid'];
                }
            }
            break;
            //
            //	LAYOUTS
            //
        //
        //	LAYOUTS
        //
        case 'layout':
            $arr['item_type'] = ITEM_TYPE_PDL;
            $namespace = 'PDL';
            $name = $element['name'];
            $arr['title'] = $element['description'];
            $arr['term'] = $element['term'];
            break;
            //
            //	BLOCKS
            //
        //
        //	BLOCKS
        //
        case 'block':
            $arr['item_type'] = ITEM_TYPE_BLOCK;
            $namespace = 'BUILDBLOCK';
            $name = $element['name'];
            $arr['title'] = $element['title'];
            break;
        default:
            return null;
            // return null if invalid element type
    }
    $arr['uid'] = $channel['channel_id'];
    $arr['aid'] = $channel['channel_account_id'];
    // Check if an item already exists based on the name
    $iid = q("select iid from iconfig where k = '" . $namespace . "' and v = '%s' and cat = 'system'", dbesc($name));
    if ($iid) {
        // If the item does exist, get the item metadata
        $iteminfo = q("select mid,created,edited from item where id = %d", intval($iid[0]['iid']));
        $arr['mid'] = $arr['parent_mid'] = $iteminfo[0]['mid'];
        $arr['created'] = $iteminfo[0]['created'];
        $arr['edited'] = $element['edited'] ? datetime_convert('UTC', 'UTC', $element['edited']) : datetime_convert();
    } else {
        // otherwise, generate the creation times and unique id
        $arr['created'] = $element['created'] ? datetime_convert('UTC', 'UTC', $element['created']) : datetime_convert();
        $arr['edited'] = datetime_convert('UTC', 'UTC', '0000-00-00 00:00:00');
        $arr['mid'] = $arr['parent_mid'] = item_message_id();
    }
    // Import the actual element content
    $arr['body'] = file_get_contents($element['path']);
    // The element owner is the channel importing the elements
    $arr['owner_xchan'] = get_observer_hash();
    // The author is either the owner or whomever was specified
    $arr['author_xchan'] = $element['author_xchan'] ? $element['author_xchan'] : get_observer_hash();
    // Import mimetype if it is a valid mimetype for the element
    $mimetypes = ['text/bbcode', 'text/html', 'text/markdown', 'text/plain', 'application/x-pdl', 'application/x-php'];
    // Blocks and pages can have any mimetype, but layouts must be text/bbcode
    if (in_array($element['mimetype'], $mimetypes) && ($type === 'page' || $type === 'block')) {
        $arr['mimetype'] = $element['mimetype'];
    } else {
        $arr['mimetype'] = 'text/bbcode';
    }
    // Verify ability to use html or php!!!
    $execflag = false;
    if ($arr['mimetype'] === 'application/x-php') {
        $z = q("select account_id, account_roles, channel_pageflags from account " . "left join channel on channel_account_id = account_id where channel_id = %d limit 1", intval(local_channel()));
        if ($z && ($z[0]['account_roles'] & ACCOUNT_ROLE_ALLOWCODE || $z[0]['channel_pageflags'] & PAGE_ALLOWCODE)) {
            $execflag = true;
        }
    }
    $z = q("select * from iconfig where v = '%s' and k = '%s' and cat = 'service' limit 1", dbesc($name), dbesc($namespace));
    $i = q("select id, edited, item_deleted from item where mid = '%s' and uid = %d limit 1", dbesc($arr['mid']), intval(local_channel()));
    $remote_id = 0;
//.........这里部分代码省略.........
开发者ID:BlaBlaNet,项目名称:hubzilla,代码行数:101,代码来源:import.php

示例13: transliterate

 /**
  * Converts UTF8 into Latin.
  *
  * @param $value
  *
  * @return mixed
  */
 public static function transliterate($value)
 {
     $transId = 'Any-Latin; Latin-ASCII';
     if (function_exists('transliterator_transliterate') && ($trans = \Transliterator::create($transId))) {
         // Use intl by default
         return $trans->transliterate($value);
     }
     return \URLify::transliterate($value);
 }
开发者ID:dongilbert,项目名称:mautic,代码行数:16,代码来源:InputHelper.php

示例14: post

 function post()
 {
     // This will change. Figure out who the observer is and whether or not
     // they have permission to post here. Else ignore the post.
     if (!local_channel() && !remote_channel() && !x($_REQUEST, 'commenter')) {
         return;
     }
     require_once 'include/security.php';
     $uid = local_channel();
     $channel = null;
     $observer = null;
     /**
      * Is this a reply to something?
      */
     $parent = x($_REQUEST, 'parent') ? intval($_REQUEST['parent']) : 0;
     $parent_mid = x($_REQUEST, 'parent_mid') ? trim($_REQUEST['parent_mid']) : '';
     $remote_xchan = x($_REQUEST, 'remote_xchan') ? trim($_REQUEST['remote_xchan']) : false;
     $r = q("select * from xchan where xchan_hash = '%s' limit 1", dbesc($remote_xchan));
     if ($r) {
         $remote_observer = $r[0];
     } else {
         $remote_xchan = $remote_observer = false;
     }
     $profile_uid = x($_REQUEST, 'profile_uid') ? intval($_REQUEST['profile_uid']) : 0;
     require_once 'include/channel.php';
     $sys = get_sys_channel();
     if ($sys && $profile_uid && $sys['channel_id'] == $profile_uid && is_site_admin()) {
         $uid = intval($sys['channel_id']);
         $channel = $sys;
         $observer = $sys;
     }
     if (x($_REQUEST, 'dropitems')) {
         require_once 'include/items.php';
         $arr_drop = explode(',', $_REQUEST['dropitems']);
         drop_items($arr_drop);
         $json = array('success' => 1);
         echo json_encode($json);
         killme();
     }
     call_hooks('post_local_start', $_REQUEST);
     //	 logger('postvars ' . print_r($_REQUEST,true), LOGGER_DATA);
     $api_source = x($_REQUEST, 'api_source') && $_REQUEST['api_source'] ? true : false;
     $consensus = intval($_REQUEST['consensus']);
     $nocomment = intval($_REQUEST['nocomment']);
     // 'origin' (if non-zero) indicates that this network is where the message originated,
     // for the purpose of relaying comments to other conversation members.
     // If using the API from a device (leaf node) you must set origin to 1 (default) or leave unset.
     // If the API is used from another network with its own distribution
     // and deliveries, you may wish to set origin to 0 or false and allow the other
     // network to relay comments.
     // If you are unsure, it is prudent (and important) to leave it unset.
     $origin = $api_source && array_key_exists('origin', $_REQUEST) ? intval($_REQUEST['origin']) : 1;
     // To represent message-ids on other networks - this will create an iconfig record
     $namespace = $api_source && array_key_exists('namespace', $_REQUEST) ? strip_tags($_REQUEST['namespace']) : '';
     $remote_id = $api_source && array_key_exists('remote_id', $_REQUEST) ? strip_tags($_REQUEST['remote_id']) : '';
     $owner_hash = null;
     $message_id = x($_REQUEST, 'message_id') && $api_source ? strip_tags($_REQUEST['message_id']) : '';
     $created = x($_REQUEST, 'created') ? datetime_convert(date_default_timezone_get(), 'UTC', $_REQUEST['created']) : datetime_convert();
     $post_id = x($_REQUEST, 'post_id') ? intval($_REQUEST['post_id']) : 0;
     $app = x($_REQUEST, 'source') ? strip_tags($_REQUEST['source']) : '';
     $return_path = x($_REQUEST, 'return') ? $_REQUEST['return'] : '';
     $preview = x($_REQUEST, 'preview') ? intval($_REQUEST['preview']) : 0;
     $categories = x($_REQUEST, 'category') ? escape_tags($_REQUEST['category']) : '';
     $webpage = x($_REQUEST, 'webpage') ? intval($_REQUEST['webpage']) : 0;
     $pagetitle = x($_REQUEST, 'pagetitle') ? escape_tags(urlencode($_REQUEST['pagetitle'])) : '';
     $layout_mid = x($_REQUEST, 'layout_mid') ? escape_tags($_REQUEST['layout_mid']) : '';
     $plink = x($_REQUEST, 'permalink') ? escape_tags($_REQUEST['permalink']) : '';
     $obj_type = x($_REQUEST, 'obj_type') ? escape_tags($_REQUEST['obj_type']) : ACTIVITY_OBJ_NOTE;
     // allow API to bulk load a bunch of imported items with sending out a bunch of posts.
     $nopush = x($_REQUEST, 'nopush') ? intval($_REQUEST['nopush']) : 0;
     /*
      * Check service class limits
      */
     if ($uid && !x($_REQUEST, 'parent') && !x($_REQUEST, 'post_id')) {
         $ret = $this->item_check_service_class($uid, $_REQUEST['webpage'] == ITEM_TYPE_WEBPAGE ? true : false);
         if (!$ret['success']) {
             notice(t($ret['message']) . EOL);
             if (x($_REQUEST, 'return')) {
                 goaway(z_root() . "/" . $return_path);
             }
             killme();
         }
     }
     if ($pagetitle) {
         require_once 'library/urlify/URLify.php';
         $pagetitle = strtolower(\URLify::transliterate($pagetitle));
     }
     $item_flags = $item_restrict = 0;
     $route = '';
     $parent_item = null;
     $parent_contact = null;
     $thr_parent = '';
     $parid = 0;
     $r = false;
     if ($parent || $parent_mid) {
         if (!x($_REQUEST, 'type')) {
             $_REQUEST['type'] = 'net-comment';
         }
         if ($obj_type == ACTIVITY_OBJ_POST) {
             $obj_type = ACTIVITY_OBJ_COMMENT;
//.........这里部分代码省略.........
开发者ID:phellmes,项目名称:hubzilla,代码行数:101,代码来源:Item.php


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