本文整理汇总了PHP中EB::string方法的典型用法代码示例。如果您正苦于以下问题:PHP EB::string方法的具体用法?PHP EB::string怎么用?PHP EB::string使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类EB
的用法示例。
在下文中一共展示了EB::string方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: crawl
/**
* Invoke the crawling.
*
* @since 1.0
* @access public
* @author Mark Lee <mark@stackideas.com>
*/
public function crawl($url)
{
$tmp = str_ireplace(array('http://', 'https://'), '', $url);
if (!EB::string()->isValidDomain($tmp)) {
return false;
}
// Ensure that urls always contains a protocol
if (stristr($url, 'http://') === false && stristr($url, 'https://') === false) {
$url = 'http://' . $url;
}
// Load up the connector first.
$connector = EB::connector();
$connector->addUrl($url);
$connector->execute();
// Get the result and parse them.
$info = parse_url($url);
$this->contents = $connector->getResult($url);
// Replace any href="// with href="scheme://"
$this->contents = str_ireplace('src="//', 'src="' . $info['scheme'] . '://', $this->contents);
// Get the final url, if there's any redirection.
$originalUrl = $url;
$url = $connector->getFinalUrl($url);
$this->parse($originalUrl, $url);
return $this;
}
示例2: crawl
/**
* Given a specific URL, try to crawl the site
*
* @since 4.0
* @access public
* @param string
* @return
*/
public function crawl()
{
// Get a list of urls to crawl
$urls = $this->input->get('url', array(), 'array');
if (!is_array($urls)) {
$urls = array($urls);
}
// Result placeholder
$result = array();
if (!$urls || empty($urls)) {
return $this->ajax->reject();
}
// Get the crawler library
$crawler = EB::crawler();
foreach ($urls as $url) {
// Ensures that the domain is valid
if (!EB::string()->isValidDomain($url)) {
return $this->ajax->reject(JText::_('COM_EASYBLOG_COMPOSER_BLOCKS_LINKS_EMPTY'));
}
// Crawl the url
$state = $crawler->crawl($url);
// Get the data from the crawled site
$data = $crawler->getData();
$result[$url] = $data;
}
return $this->ajax->resolve($result);
}
示例3: __construct
public function __construct()
{
// EasyBlog's configuration
$this->config = EB::config();
$this->jconfig = EB::jconfig();
// Joomla's document object
$this->doc = JFactory::getDocument();
// Joomla's application object
$this->app = JFactory::getApplication();
// Request input object
$this->input = EB::request();
// Current logged in user.
$this->my = JFactory::getUser();
// String library
$this->string = EB::string();
$this->lang = JFactory::getLanguage();
}
示例4: ping
/**
* Sends a ping to pingomatic servers
*
* @since 5.0
* @access public
* @param string
* @return
*/
public function ping(EasyBlogPost &$post)
{
// If this is disabled, don't do anything
if (!$this->config->get('main_pingomatic')) {
return false;
}
// Get the title of the blog post
$title = EB::string()->escape($post->title);
// Get the permalink to the post
$link = $post->getExternalPermalink();
$link = urlencode($link);
// Construct the xml content to send to pingomatic
$content = '<?xml version="1.0"?>' . '<methodCall>' . ' <methodName>weblogUpdates.ping</methodName>' . ' <params>' . ' <param>' . ' <value>' . $title . '</value>' . ' </param>' . ' <param>' . ' <value>' . $url . '</value>' . ' </param>' . ' </params>' . '</methodCall>';
$headers = "POST / HTTP/1.0\r\n" . "User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.1) Gecko/20090624 Firefox/3.5 (.NET CLR 3.5.30729)\r\n" . "Host: rpc.pingomatic.com\r\n" . "Content-Type: text/xml\r\n" . "Content-length: " . strlen($content);
$request = $headers . "\r\n\r\n" . $content;
$response = "";
$fs = fsockopen('rpc.pingomatic.com', 80, $errno, $errstr);
if ($fs) {
fwrite($fs, $request);
while (!feof($fs)) {
$response .= fgets($fs);
}
if ($debug) {
echo "<xmp>" . $response . "</xmp>";
}
fclose($fs);
preg_match_all("/<(name|value|boolean|string)>(.*)<\\/(name|value|boolean|string)>/U", $response, $ar, PREG_PATTERN_ORDER);
for ($i = 0; $i < count($ar[2]); $i++) {
$ar[2][$i] = strip_tags($ar[2][$i]);
}
return array('status' => $ar[2][1] == 1 ? 'ko' : 'ok', 'msg' => $ar[2][3]);
} else {
if ($debug) {
echo "<xmp>" . $errstr . " (" . $errno . ")</xmp>";
}
return array('status' => 'ko', 'msg' => $errstr . " (" . $errno . ")");
}
}
示例5: foreach
if ($teams) {
?>
<?php
foreach ($teams as $team) {
?>
<div class="mod-item mod-table cell-top">
<div class="mod-cell cell-tight pr-10">
<a class="mod-avatar" href="<?php
echo $team->getPermalink();
?>
">
<img src="<?php
echo $team->getAvatar();
?>
" alt="<?php
echo EB::string()->escape($team->title);
?>
" />
</a>
</div>
<div class="mod-cell">
<h3 class="mod-title">
<a href="<?php
echo $team->getPermalink();
?>
"><?php
echo $team->title;
?>
</a>
</h3>
<div>
示例6: escape
public static function escape($string)
{
return EB::string()->escape($string);
}
示例7:
?>
</div>
<?php
}
?>
<?php
if ($params->get('showcommentcount', 0)) {
?>
<div class="mod-cell pr-10">
<a href="<?php
echo $post->getPermalink();
?>
">
<?php
echo EB::string()->getNoun('MOD_TOPBLOGS_COMMENTS', EB::comment()->getCommentCount($post), true);
?>
</a>
</div>
<?php
}
?>
<?php
if ($params->get('showreadmore', true)) {
?>
<div class="mod-cell">
<a href="<?php
echo $post->getPermalink();
?>
"><?php
示例8: addOpenGraphTags
/**
* Attaches the open graph tags in the header
*
* @since 4.0
* @access public
* @param string
* @return
*/
public function addOpenGraphTags(EasyBlogPost &$post)
{
if (!$this->config->get('main_facebook_opengraph')) {
return;
}
// Get the absolute permalink for this blog item.
$url = $post->getExternalPermalink();
// Get the image of the blog post.
$image = self::getImage($post);
// Add the blog image.
$this->doc->addCustomTag('<meta property="og:image" content="' . $image . '"/> ');
// If app id is provided, attach it on the head
$appId = $this->config->get('main_facebook_like_appid');
$adminId = $this->config->get('main_facebook_like_admin');
if ($appId) {
$this->doc->addCustomTag('<meta property="fb:app_id" content="' . $appId . '"/> ');
}
if ($adminId) {
$this->doc->addCustomTag('<meta property="fb:admins" content="' . $adminId . '"/>');
}
// Add the title tag
$this->doc->addCustomTag('<meta property="og:title" content="' . $post->title . '" />');
// Load any necessary meta data for the blog
$meta = $post->loadMeta();
// If there's a meta set for the blog, use the stored meta version
$description = !empty($meta->description) ? $meta->description : $post->getIntro();
// Remove unwanted tags
$description = EB::stripEmbedTags($description);
// Add any slashes
$description = addslashes($description);
// Remove any html tags
$description = strip_tags($description);
// Ensure that newlines wouldn't affect the header
$description = trim($description);
// Replace htmlentities with the counterpert
// Perhaps we need to explicitly replace with a space?
$description = html_entity_decode($description);
// Remove any quotes (") from the content
$description = str_ireplace('"', '', $description);
// If there's a maximum length specified, we should respect it.
$max = $this->config->get('integrations_facebook_blogs_length');
if ($max) {
if (JString::strlen($description) > $max) {
$description = JString::substr($description, 0, $max) . JText::_('COM_EASYBLOG_ELLIPSES');
}
}
// Escape it again
$description = EB::string()->escape($description);
$this->doc->addCustomTag('<meta property="og:description" content="' . $description . '" />');
$this->doc->addCustomTag('<meta property="og:type" content="article" />');
$this->doc->addCustomTag('<meta property="og:url" content="' . $url . '" />');
return true;
}
示例9: subscribe
/**
* Allows caller to subscribe to the blog
*
* @since 5.0
* @access public
* @param string
* @return
*/
public function subscribe()
{
// Ensure that guests are allowed to subscribe
if (!$this->acl->get('allow_subscription') && !$this->my->id && !$this->config->get('main_allowguestsubscribe')) {
return $this->ajax->reject(JText::_('COM_EASYBLOG_NO_PERMISSION_TO_SUBSCRIBE_BLOG'));
}
// Validate the email address
$email = $this->input->get('email', '', 'default');
if (!$email) {
return $this->ajax->reject(JText::_('COM_EASYBLOG_SUBSCRIPTION_EMAIL_EMPTY_ERROR'));
}
// Test if email is valid
$valid = EB::string()->isValidEmail($email);
if (!$valid) {
return $this->ajax->reject(JText::_('COM_EASYBLOG_SUBSCRIPTION_EMAIL_INVALID_ERROR'));
}
// Determines if the user wants to register
$registered = $this->input->get('register', '', 'bool');
$name = $this->input->get('name', '', 'default');
$username = $this->input->get('username', '', 'default');
$id = $this->input->get('id', '', 'int');
$type = $this->input->get('type', '', 'string');
$userId = $this->input->get('userId', 0, 'int');
if (!$name) {
return $this->ajax->reject(JText::_('COM_EASYBLOG_SUBSCRIPTION_NAME_EMPTY_ERROR'));
}
if ($registered && !$this->my->id && !$username) {
return $this->ajax->reject(JText::_('COM_EASYBLOG_SUBSCRIPTION_USERNAME_EMPTY_ERROR'));
}
// Load up the registration library
$lib = EB::registration();
// Try to validate the username and email
$options = array('username' => $username, 'email' => $email);
$validated = $lib->validate();
if ($validated !== true) {
return $this->ajax->reject(JText::_($validated));
}
// Add the user's name
$options['name'] = $name;
// if the user is guest
if ($userId == 0 && $registered) {
// Add the user to the system
$userId = $lib->addUser($options);
}
// Process mailchimp subscriptions here.
$mailchimp = EB::mailchimp()->subscribe($email, $name);
// Process mailchimp subscriptions here.
$sendy = EB::sendy()->subscribe($email, $name);
// Only use our built in subscription if mailchimp and sendy didn't send anything
if (!$mailchimp && !$sendy) {
// Since we have already merged all these tables into one, we don't need to use separate methods
// to insert new subscriptions
$subscription = EB::table('Subscriptions');
$options = array('email' => $email, 'uid' => $id, 'utype' => $type);
if (!$userId) {
$options['user_id'] = 0;
} else {
$options['user_id'] = $userId;
}
if ($name) {
$options['fullname'] = $name;
}
// If this is a valid user, perhaps he's trying to change his email
if ($userId) {
$subscription->load(array('user_id' => $userId, 'utype' => $type, 'uid' => $id));
} else {
$subscription->load($options);
}
// Bind the data
$subscription->bind($options);
// Try to save the record now
$state = $subscription->store();
// We don't really need to do anythin
// If the subscribed method returns false, we could assume that they are already subscribed previously
if (!$state) {
return $this->ajax->reject(JText::_('COM_EASYBLOG_SUBSCRIPTION_ALREADY_SUBSCRIBED_ERROR'));
}
}
$theme = EB::template();
$theme->set('email', $email);
$theme->set('registered', $registered);
$output = $theme->output('site/subscription/dialog.subscribed');
return $this->ajax->resolve($output);
}
示例10:
?>
</div>
<?php
}
?>
<?php
if ($params->get('showcommentcount', 0)) {
?>
<div class="mod-cell pr-10">
<a href="<?php
echo $post->getPermalink();
?>
">
<?php
echo EB::string()->getNoun('MOD_EASYBLOGMOSTCOMMENTEDPOST_COMMENTS', $post->commentCount, true);
?>
</a>
</div>
<?php
}
?>
<?php
if ($params->get('showreadmore', true)) {
?>
<div class="mod-cell">
<a href="<?php
echo $post->getPermalink();
?>
"><?php
示例11: nl2br
<a href="<?php
echo $post->getPermalink();
?>
"><?php
echo nl2br($post->title);
?>
</a>
</h2>
<div class="eb-post-headline-source">
<a href="<?php
echo $post->getAsset('link');
?>
" target="_blank">
<?php
echo EB::string()->htmlAnchorLink($link, $link);
?>
</a>
</div>
</div>
<?php
}
?>
<!-- Twitter type -->
<?php
if ($post->posttype == 'twitter') {
?>
<?php
$screen_name = $post->getAsset('screen_name')->getValue();
$created_at = EB::date($post->getAsset('created_at')->getValue(), true)->format(JText::_('DATE_FORMAT_LC'));
示例12: setMeta
/**
* Allows caller to set the meta
*
* @since 4.0
* @access public
* @param string
* @return
*/
public static function setMeta($id, $type, $defaultViewDesc = '')
{
$doc = JFactory::getDocument();
$config = EB::config();
// Try to load the meta for the content
$meta = EB::table('Meta');
$meta->load(array('type' => $type, 'content_id' => $id));
// If the category was created without any meta, we need to automatically fill in the description
if ($type == META_TYPE_CATEGORY && !$meta->id) {
$category = '';
if (EB::cache()->exists($id, 'category')) {
$category = EB::cache()->get($id, 'category');
} else {
$category = EB::table('Category');
$category->load($id);
}
$doc->setMetadata('description', strip_tags($category->description));
}
// If the blogger was created, try to get meta from blogger biography/title
if ($type == META_TYPE_BLOGGER) {
$author = '';
if (EB::cache()->exists($id, 'author')) {
$author = EB::cache()->get($id, 'author');
} else {
$author = EB::table('Profile');
$author->load($id);
}
$doc->setMetadata('description', strip_tags($author->biography));
if (!empty($author->biography) || !empty($author->title)) {
$meta = new stdClass();
$meta->keywords = $author->title;
$meta->description = EB::string()->escape($author->biography);
}
}
// Automatically fill meta keywords
if ($type == META_TYPE_POST && ($config->get('main_meta_autofillkeywords') && empty($meta->keywords) || $config->get('main_meta_autofilldescription'))) {
// Retrieve data from cache
$post = EB::post();
$post->load($id);
$category = $post->getPrimaryCategory();
$keywords = array($category->getTitle());
if ($config->get('main_meta_autofillkeywords') && empty($meta->keywords)) {
$tags = $post->getTags();
foreach ($tags as $tag) {
$keywords[] = $tag->getTitle();
}
$meta->keywords = implode(',', $keywords);
}
// Automatically fill meta description
if ($config->get('main_meta_autofilldescription') && empty($meta->description)) {
$content = $post->getIntro(EASYBLOG_STRIP_TAGS);
$content = trim($content);
// Set description into meta headers
$meta->description = JString::substr($content, 0, $config->get('main_meta_autofilldescription_length'));
$meta->description = EB::string()->escape($meta->description);
// $content = !empty( $post->intro ) ? strip_tags( $post->intro ) : strip_tags( $post->content );
// $content = str_ireplace( "\r\n" , "" , $content );
// $content = str_ireplace( " " , " " , $content );
// $content = trim($content);
}
// Remove JFBConnect codes.
if ($meta->description) {
$pattern = '/\\{JFBCLike(.*)\\}/i';
$meta->description = preg_replace($pattern, '', $meta->description);
}
}
// Check if the descriptin or keysword still empty or not. if yes, try to get from joomla menu.
if (empty($meta->description) && empty($meta->keywords)) {
$active = JFactory::getApplication()->getMenu()->getActive();
if ($active) {
$params = $active->params;
$description = $params->get('menu-meta_description', '');
$keywords = $params->get('menu-meta_keywords', '');
if (!empty($description) || !empty($keywords)) {
$meta = new stdClass();
$meta->description = EB::string()->escape($description);
$meta->keywords = $keywords;
}
}
}
if (!$meta) {
return;
}
// If there's no meta description, try to get it from Joomla's settings
if (!$meta->description && $defaultViewDesc) {
$meta->description = $defaultViewDesc . ' - ' . EB::jconfig()->get('MetaDesc');
}
if ($meta->keywords) {
$doc->setMetadata('keywords', $meta->keywords);
}
if ($meta->description) {
$doc->setMetadata('description', $meta->description);
//.........这里部分代码省略.........
示例13: getName
/**
* Retrieves the blogger's name
*
* @since 4.0
* @access public
* @return string
*/
public function getName()
{
if ($this->id == 0) {
return JText::_('COM_EASYBLOG_GUEST');
}
if (!$this->user) {
$this->user = JFactory::getUser($this->id);
}
$config = EB::config();
$type = $config->get('layout_nameformat');
// Default to the person's name
$name = $this->user->name;
if ($type == 'username') {
$name = $this->user->username;
}
if ($type == 'nickname' && !empty($this->nickname)) {
$name = $this->nickname;
}
// Ensure that the name cannot be exploited.
$name = EB::string()->escape($name);
return $name;
}
示例14: listings
/**
* Displays blog posts created by specific users
*
* @since 4.0
* @access public
*/
public function listings()
{
// Get sorting options
$sort = $this->input->get('sort', $this->config->get('layout_postorder'), 'cmd');
$id = $this->input->get('id', 0, 'int');
// Load the author object
$author = EB::user($id);
// Disallow all users from being viewed
if (!$this->config->get('main_nonblogger_profile') && !EB::isBlogger($author->id) || !$author->id) {
return JError::raiseError(404, JText::_('COM_EASYBLOG_INVALID_AUTHOR_ID_PROVIDED'));
}
// Get the authors acl
$acl = EB::acl($author->id);
// Set meta tags for the author if allowed to
if ($acl->get('allow_seo')) {
EB::setMeta($author->id, META_TYPE_BLOGGER, true);
}
// Set the breadcrumbs
if (!EBR::isCurrentActiveMenu('blogger', $author->id) && !EBR::isCurrentActiveMenu('blogger')) {
$this->setPathway(JText::_('COM_EASYBLOG_BLOGGERS_BREADCRUMB'), EB::_('index.php?option=com_easyblog&view=blogger'));
$this->setPathway($author->getName());
}
// Get the current active menu
$active = $this->app->getMenu()->getActive();
// Excluded categories
$excludeCats = array();
if (isset($active->params)) {
$excludeCats = $active->params->get('exclusion');
// Ensure that this is an array
if (!is_array($excludeCats) && $excludeCats) {
$excludeCats = array($excludeCats);
}
}
// Get the blogs model now to retrieve our blog posts
$model = EB::model('Blog');
// Get blog posts
$posts = $model->getBlogsBy('blogger', $author->id, $sort, 0, '', false, false, '', false, false, false, $excludeCats);
$pagination = $model->getPagination();
// Format the blogs with our standard formatter
$posts = EB::formatter('list', $posts);
// Add canonical urls
$this->canonical('index.php?option=com_easyblog&view=blogger&layout=listings&id=' . $author->id);
// Add authors rss links on the header
if ($this->config->get('main_rss')) {
if ($this->config->get('main_feedburner') && $this->config->get('main_feedburnerblogger')) {
$this->doc->addHeadLink(EB::string()->escape($author->getRssLink()), 'alternate', 'rel', array('type' => 'application/rss+xml', 'title' => 'RSS 2.0'));
} else {
// Add rss feed link
$this->doc->addHeadLink($author->getRSS(), 'alternate', 'rel', array('type' => 'application/rss+xml', 'title' => 'RSS 2.0'));
$this->doc->addHeadLink($author->getAtom(), 'alternate', 'rel', array('type' => 'application/atom+xml', 'title' => 'Atom 1.0'));
}
}
// Set the title of the page
$title = EB::getPageTitle($author->getName());
$this->setPageTitle($title, $pagination, $this->config->get('main_pagetitle_autoappend'));
// Check if subscribed
$bloggerModel = EB::model('Blogger');
$isBloggerSubscribed = $bloggerModel->isBloggerSubscribedEmail($author->id, $this->my->email);
$return = base64_encode($author->getPermalink());
$this->set('return', $return);
$this->set('author', $author);
$this->set('posts', $posts);
$this->set('sort', $sort);
$this->set('isBloggerSubscribed', $isBloggerSubscribed);
parent::display('authors/item');
}
示例15: escape
/**
* Escapes a string
*
* @since 5.0
* @access public
* @param string
* @return
*/
public function escape($val)
{
return EB::string()->escape($val);
}