本文整理汇总了PHP中EB::blocks方法的典型用法代码示例。如果您正苦于以下问题:PHP EB::blocks方法的具体用法?PHP EB::blocks怎么用?PHP EB::blocks使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类EB
的用法示例。
在下文中一共展示了EB::blocks方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: validate
/**
* Validates if the block contains any contents
*
* @since 5.0
* @access public
* @param string
* @return
*/
public function validate($block)
{
$content = EB::blocks()->renderViewableBlock($block, true);
// convert html entities back to it string. e.g. back to empty space
$content = html_entity_decode($content);
// strip html tags to precise length count.
$content = strip_tags($content);
// remove any blank space.
$content = trim($content);
// get content length
$contentLength = JString::strlen($content);
if ($contentLength > 0) {
return true;
} else {
return false;
}
}
示例2: format
/**
* Formats blocks in the blog post.
*
* @since 4.0
* @access public
* @param string
* @return
*/
public function format(EasyBlogPost &$blog, $blocks, $type = 'list')
{
static $_cache = array();
if (!$blocks) {
return array();
}
// Determines the total number of blocks
$total = count($blocks);
// Get the maximum number of blocks
$max = $this->config->get('composer_truncation_blocks');
// Determines if content truncation should happen
if ($type == 'list' && $this->config->get('composer_truncation_enabled') && $max) {
// Get the total number of blocks
$blocks = array_splice($blocks, 0, $max);
}
// Default read more to false
$blog->readmore = false;
// Default contents
$contents = '';
foreach ($blocks as $item) {
// If the read more is present at this point of time, we should skip processing the rest of the blocks
if ($blog->readmore && $type == 'list') {
continue;
}
// Load from cache
if (!isset($_cache[$item->type])) {
$tblElement = EB::table('Block');
$tblElement->load(array('element' => $item->type));
$_cache[$item->type] = $tblElement;
}
$table = $_cache[$item->type];
$block = EB::blocks()->get($table);
$contents .= $block->formatDisplay($item, $blog);
}
// If the total is larger than the iterated blocks, we need to display the read more
if ($total > count($blocks)) {
$blog->readmore = true;
}
return $contents;
}
示例3: getEditableContent
/**
* Retrieves the editable html codes for each blocks
*
* @since 5.0
* @access public
* @param string
* @return
*/
public function getEditableContent()
{
$output = '';
foreach ($this->blocks as $block) {
$output .= EB::blocks()->renderEditableBlock($block);
}
return $output;
}
示例4: process
/**
* Retrieves a list of galleries associated with the post
*
* @since 5.0
* @access public
* @param string
* @return
*/
public function process($content, $userId = '')
{
$pattern = '/\\[embed=gallery\\](.*)\\[\\/embed\\]/i';
$galleries = array();
preg_match_all($pattern, $content, $matches, PREG_SET_ORDER);
if (!$matches) {
return $content;
}
// Get the image block so that we can construct it
$block = EB::blocks()->getBlockByType('image');
foreach ($matches as $match) {
$totalColumns = 4;
$columns = array();
for ($i = 0; $i < $totalColumns; $i++) {
$columns[$i] = array();
}
// The full text of the matched content
list($text, $json) = $match;
// Ensure that the property is valid
$json = str_ireplace('file:', '"file":', $json);
$json = str_ireplace('place:', '"place":', $json);
// Parse the raw json
$gallery = json_decode($json);
if ($gallery === null) {
continue;
}
$images = $this->getImages($gallery);
// We need to construct a block for each of these items
for ($i = 0; $i < count($images); $i++) {
$image = $block->getHtml($images[$i]);
$column = $i - floor($i / $totalColumns) * $totalColumns;
$columns[$column][] = $image;
}
$theme = EB::template();
$theme->set('columns', $columns);
$output = $theme->output('site/blogs/latest/blog.gallery');
$content = str_ireplace($match, $output, $content);
}
return $content;
}
示例5: defined
<?php
/**
* @package EasyBlog
* @copyright Copyright (C) 2010 - 2014 Stack Ideas Sdn Bhd. All rights reserved.
* @license GNU/GPL, see LICENSE.php
* EasyBlog is free software. This version may have been modified pursuant
* to the GNU General Public License, and as distributed it includes or
* is derivative of works licensed under the GNU General Public License or
* other free or open source software licenses.
* See COPYRIGHT.php for copyright notices and details.
*/
defined('_JEXEC') or die('Unauthorized Access');
?>
<ul class="nav nav-tabs" role="tablist">
<li class="active"><a href="#firsttab" role="tab" data-bp-toggle="tab" contenteditable="true"><?php
echo JText::_('COM_EASYBLOG_BLOCK_TABS_DEFAULT_TITLE');
?>
</a></li>
</ul>
<div class="tab-content" data-tabs-content>
<div class="tab-pane active" id="firsttab" contenteditable="false">
<div class="ebd-nest" data-type="block" data-tab-wrapper="">
<?php
echo EB::blocks()->renderEditableBlock(EB::blocks()->createBlock('text', array(), array('nested' => true)));
?>
</div>
</div>
</div>
示例6: renderManager
/**
* Retrieves the html codes for composer
*
* @since 4.0
* @access public
* @param int The unique item id.
* @param string The type of the post, whether this is a post or a draft
* @return
*/
public function renderManager($uid = null)
{
// Get the current post library
$post = EB::post($uid);
// Check if user has permissions to write new entry
if (!$post->canCreate()) {
return JError::raiseError(500, JText::_('COM_EASYBLOG_NO_PERMISSION_TO_CREATE_BLOG'));
}
// If the blog post is edited, ensure that the user has access to edit this entry
if (!$post->canEdit()) {
return JError::raiseError(500, JText::_('COM_EASYBLOG_NO_PERMISSION_TO_EDIT_BLOG'));
}
// Get the editor to use
$editorSetting = $this->user->getEditor();
$editorSetting = $editorSetting == 'composer' ? JFactory::getConfig()->get('editor') : $editorSetting;
$editor = JFactory::getEditor($editorSetting);
// Get a list of parent categories
$parentCategories = $this->getParentCategories();
// Get the default category.
$defaultCategoryId = EB::model('Category')->getDefaultCategoryId();
$primaryCategory = $post->getPrimaryCategory();
// Get a list of categories
// Prepare selected category
$selectedCategories = array();
foreach ($post->getCategories() as $row) {
$selectedCategories[] = (int) $row->id;
}
// if there is no category selected, or this is a new blog post, lets use the default category id.
if (!$selectedCategories && $defaultCategoryId) {
$selectedCategories[] = $defaultCategoryId;
}
// Prepare categories object
$categories = array();
$cats = EB::model('Categories')->getCategoriesHierarchy(false);
foreach ($cats as $row) {
$category = new stdClass();
$category->id = (int) $row->id;
$category->title = $row->title;
$category->parent_id = (int) $row->parent_id;
$params = new JRegistry($row->params);
$category->tags = $params->get('tags');
if (!$category->tags) {
$category->tags = array();
} else {
$tags = explode(',', $category->tags);
for ($i = 0; $i < count($tags); $i++) {
$tags[$i] = JString::trim($tags[$i]);
}
$category->tags = implode(',', $tags);
}
// Cross check if this category is selected
$category->selected = in_array($category->id, $selectedCategories);
// check if this is a primary category or not
$category->isprimary = $category->id == $primaryCategory->id;
$categories[] = $category;
}
// Prepare tags
$tags = array();
foreach ($post->getTags() as $row) {
$tag = new stdClass();
$tag->id = (int) $row->id;
$tag->title = $row->title;
$tags[] = $tag;
}
// Render default post templates
$postTemplatesModel = EB::model('Templates');
$postTemplates = $postTemplatesModel->getPostTemplates($this->my->id);
// Get the post's author
$author = $post->getAuthor();
// Get a list of revisions for this post
$revisions = $post->getRevisions();
// Get the current revision for the post
$workingRevision = $post->getWorkingRevision();
// Determines if the current page load should be loading from block templates
$postTemplate = EB::table('PostTemplate');
$postTemplate->load($this->input->get('block_template', 0, 'int'));
if (!$postTemplate->id || $postTemplate->id == 1) {
$postTemplate = false;
}
// Get available blocks on the site
$blocks = EB::blocks()->getAvailableBlocks();
// Determines if we should display the custom fields tab by default
$displayFieldsTab = false;
// Get a list of selected categories
$selectedCategories = $post->getCategories();
// If there's no selected categories, we assume that the primary category
if (!$selectedCategories) {
$selectedCategories = array($primaryCategory);
}
// If explicitly configured to be hidden, skip the checks altogether
if ($this->config->get('layout_composer_fields')) {
//.........这里部分代码省略.........
示例7: meta
/**
* Standard meta data of a block object
*
* @since 5.0
* @access public
* @param string
* @return
*/
public function meta()
{
$meta = new stdClass();
// Standard descriptors
$meta->type = $this->type;
$meta->icon = $this->icon;
$meta->title = $this->title;
$meta->keywords = $this->keywords;
$meta->data = $this->data();
// Nestable
$meta->nestable = $this->nestable;
// Dimensions
$meta->dimensions = new stdClass();
$meta->dimensions->enabled = true;
$meta->dimensions->respectMinContentSize = false;
// Others
$meta->properties = array('fonts' => true, 'textpanel' => true);
$template = EB::template();
$template->set('block', $this);
$template->set('data', $meta->data);
// HTML & Block
$meta->html = $template->output('site/composer/blocks/handlers/' . $this->type . '/html');
$meta->block = EB::blocks()->renderBlockContainer(EASYBLOG_BLOCK_MODE_EDITABLE, $this, $meta->html);
// Fieldset & fieldgroup
$meta->fieldset = $template->output('site/composer/blocks/handlers/' . $this->type . '/fieldset');
$meta->fieldgroup = $template->output('site/composer/blocks/fieldgroup', array('fieldset' => $meta->fieldset));
return $meta;
}
示例8: renderEditorContent
/**
* Used during post editing so we can render the necessary blocks
*
* @since 5.0
* @access public
* @param string
* @return
*/
public function renderEditorContent()
{
if ($this->doctype == 'ebd') {
// If this is a empty document,
// start with a text block.
if (empty($this->document)) {
$blocks = EB::blocks();
$block = $blocks->createBlock("text");
$content = $blocks->renderEditableBlock($block);
// If this is an existing document,
// get editable content.
} else {
$document = EB::document($this->document);
$content = $document->getEditableContent();
}
} else {
// Format the post content now
$content = $this->intro;
// Append the readmore if necessary
if (!empty($this->intro) && !empty($this->content)) {
$content .= '<hr id="system-readmore" />';
}
// Append the rest of the contents
$content .= $this->content;
}
return $content;
}
示例9: foreach
?>
<?php
foreach ($blocks as $block) {
?>
<tr>
<td>
<?php
echo $this->html('grid.id', $i, $block->id);
?>
</td>
<td align="left">
<div class="media">
<div class="media-object pull-left">
<i class="<?php
echo EB::blocks()->get($block)->getIcon();
?>
" style="font-size:12px;"></i>
</div>
<div class="media-body">
<b><?php
echo $block->title;
?>
</b>
<p class="small"><?php
echo $block->description;
?>
</p>
</div>
</div>
</td>
示例10: getAvailableBlocks
/**
* Retrieves a list of available blocks
*
* @since 4.0
* @access public
* @param string
* @return
*/
public function getAvailableBlocks()
{
$db = EB::db();
$query = $this->getQuery(array('filter_state' => 'all'));
$query[] = 'AND(';
$query[] = $db->qn('published') . '=' . $db->Quote(EASYBLOG_COMPOSER_BLOCKS_PUBLISHED);
$query[] = 'OR';
$query[] = $db->qn('published') . '=' . $db->Quote(EASYBLOG_COMPOSER_BLOCKS_NOT_VISIBLE);
$query[] = ')';
$query[] = "order by " . $db->qn('ordering');
$query = implode(' ', $query);
$db->setQuery($query);
$result = $db->loadObjectList();
if (!$result) {
return $result;
}
$categories = array();
foreach ($result as $row) {
$block = EB::table('Block');
$block->bind($row);
if (!isset($categories[$block->group])) {
$categories[$block->group] = array();
}
$categories[$block->group][] = EB::blocks()->get($block);
}
return $categories;
}