本文整理汇总了PHP中JParameter::merge方法的典型用法代码示例。如果您正苦于以下问题:PHP JParameter::merge方法的具体用法?PHP JParameter::merge怎么用?PHP JParameter::merge使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类JParameter
的用法示例。
在下文中一共展示了JParameter::merge方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: readmoreLink
/**
* ReadMore Link
* @param object $article
* @return string
*/
function readmoreLink(&$article)
{
// Получить слитые параметры
jimport('joomla.html.parameter');
$params = new JParameter($article->attribs, JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_content' . DS . 'models' . DS . 'article.xml');
$menuitemid = JRequest::getInt('Itemid');
if ($menuitemid) {
$menu = JSite::getMenu();
$menuparams = $menu->getParams($menuitemid);
$params->merge($menuparams);
}
$params->merge($article->params);
// Если для статьи есть уже ссылка, сделать ссылкой и изобржение
if (@$article->readmore || $params->get('link_titles')) {
if ($this->plugin->jVersion == '1.5') {
$readmore = JRoute::_(ContentHelperRoute::getArticleRoute($article->slug, $article->catslug, $article->sectionid));
} else {
$readmore = JRoute::_(ContentHelperRoute::getArticleRoute($article->slug, $article->catid));
}
} else {
$readmore = '';
}
return $readmore;
}
示例2: prepareItem
function prepareItem($item, $view, $task)
{
jimport('joomla.filesystem.file');
JTable::addIncludePath(JPATH_COMPONENT_ADMINISTRATOR . DS . 'tables');
$limitstart = JRequest::getInt('limitstart');
//Initialize params
if ($view != 'item') {
$component = JComponentHelper::getComponent('com_k2');
$params = new JParameter($component->params);
$itemid = JRequest::getInt('Itemid');
if ($itemid) {
$menu = JSite::getMenu();
$menuparams = $menu->getParams($itemid);
$params->merge($menuparams);
}
} else {
$params =& JComponentHelper::getParams('com_k2');
}
//Category
$db =& JFactory::getDBO();
$query = "SELECT * FROM #__k2_categories WHERE id={$item->catid}";
$db->setQuery($query, 0, 1);
$category = $db->loadObject();
$item->category = $category;
$item->category->link = urldecode(JRoute::_(K2HelperRoute::getCategoryRoute($category->id . ':' . urlencode($category->alias))));
//Read more link
$link = K2HelperRoute::getItemRoute($item->id . ':' . urlencode($item->alias), $item->catid . ':' . urlencode($item->category->alias));
$item->link = urldecode(JRoute::_($link));
//Print link
$item->printLink = urldecode(JRoute::_($link . '&tmpl=component&print=1'));
//Params
$cparams = new JParameter($category->params);
$iparams = new JParameter($item->params);
$item->params = $params;
if ($cparams->get('inheritFrom')) {
$masterCategoryID = $cparams->get('inheritFrom');
$query = "SELECT * FROM #__k2_categories WHERE id={$masterCategoryID}";
$db->setQuery($query, 0, 1);
$masterCategory = $db->loadObject();
$cparams = new JParameter($masterCategory->params);
}
$item->params->merge($cparams);
$item->params->merge($iparams);
//Edit link
if (K2HelperPermissions::canEditItem($item->created_by, $item->catid)) {
$item->editLink = JRoute::_('index.php?option=com_k2&view=item&task=edit&cid=' . $item->id . '&tmpl=component');
}
//Tags
if ($view == 'item' && ($item->params->get('itemTags') || $item->params->get('itemRelated')) || $view == 'itemlist' && ($task == '' || $task == 'category') && $item->params->get('catItemTags') || $view == 'itemlist' && $task == 'user' && $item->params->get('userItemTags') || $view == 'latest' && $params->get('latestItemTags')) {
$tags = K2ModelItem::getItemTags($item->id);
for ($i = 0; $i < sizeof($tags); $i++) {
$tags[$i]->link = urldecode(JRoute::_(K2HelperRoute::getTagRoute($tags[$i]->name)));
}
$item->tags = $tags;
}
//Image
$item->imageXSmall = '';
$item->imageSmall = '';
$item->imageMedium = '';
$item->imageLarge = '';
$item->imageXLarge = '';
if (JFile::exists(JPATH_SITE . DS . 'media' . DS . 'k2' . DS . 'items' . DS . 'cache' . DS . md5("Image" . $item->id) . '_XS.jpg')) {
$item->imageXSmall = JURI::root() . 'media/k2/items/cache/' . md5("Image" . $item->id) . '_XS.jpg';
}
if (JFile::exists(JPATH_SITE . DS . 'media' . DS . 'k2' . DS . 'items' . DS . 'cache' . DS . md5("Image" . $item->id) . '_S.jpg')) {
$item->imageSmall = JURI::root() . 'media/k2/items/cache/' . md5("Image" . $item->id) . '_S.jpg';
}
if (JFile::exists(JPATH_SITE . DS . 'media' . DS . 'k2' . DS . 'items' . DS . 'cache' . DS . md5("Image" . $item->id) . '_M.jpg')) {
$item->imageMedium = JURI::root() . 'media/k2/items/cache/' . md5("Image" . $item->id) . '_M.jpg';
}
if (JFile::exists(JPATH_SITE . DS . 'media' . DS . 'k2' . DS . 'items' . DS . 'cache' . DS . md5("Image" . $item->id) . '_L.jpg')) {
$item->imageLarge = JURI::root() . 'media/k2/items/cache/' . md5("Image" . $item->id) . '_L.jpg';
}
if (JFile::exists(JPATH_SITE . DS . 'media' . DS . 'k2' . DS . 'items' . DS . 'cache' . DS . md5("Image" . $item->id) . '_XL.jpg')) {
$item->imageXLarge = JURI::root() . 'media/k2/items/cache/' . md5("Image" . $item->id) . '_XL.jpg';
}
if (JFile::exists(JPATH_SITE . DS . 'media' . DS . 'k2' . DS . 'items' . DS . 'cache' . DS . md5("Image" . $item->id) . '_Generic.jpg')) {
$item->imageGeneric = JURI::root() . 'media/k2/items/cache/' . md5("Image" . $item->id) . '_Generic.jpg';
}
//Extra fields
if ($view == 'item' && $item->params->get('itemExtraFields') || $view == 'itemlist' && ($task == '' || $task == 'category') && $item->params->get('catItemExtraFields') || $view == 'itemlist' && ($task == 'search' || $task == 'tag' || $task == 'date') && $item->params->get('genericItemExtraFields')) {
$item->extra_fields = K2ModelItem::getItemExtraFields($item->extra_fields);
}
//Attachments
if ($view == 'item' && $item->params->get('itemAttachments') || $view == 'itemlist' && ($task == '' || $task == 'category') && $item->params->get('catItemAttachments')) {
$item->attachments = K2ModelItem::getItemAttachments($item->id);
}
//Import plugins
$dispatcher =& JDispatcher::getInstance();
JPluginHelper::importPlugin('content');
//Gallery
if ($view == 'item' && $item->params->get('itemImageGallery') || $view == 'itemlist' && ($task == '' || $task == 'category') && $item->params->get('catItemImageGallery')) {
$params->set('galleries_rootfolder', 'media/k2/galleries');
$params->set('popup_engine', 'mootools_slimbox');
$params->set('enabledownload', '0');
$item->text = $item->gallery;
$dispatcher->trigger('onPrepareContent', array(&$item, &$params, $limitstart));
$item->gallery = $item->text;
}
//Video
//.........这里部分代码省略.........
示例3: prepareItem
function prepareItem($item, $view, $task){
jimport('joomla.filesystem.file');
JTable::addIncludePath(JPATH_COMPONENT_ADMINISTRATOR.DS.'tables');
$limitstart=JRequest::getInt('limitstart');
//Initialize params
if ($view!='item'){
$component = JComponentHelper::getComponent( 'com_k2' );
$params = new JParameter( $component->params );
$itemid = JRequest::getInt( 'Itemid' );
if ($itemid) {
$menu = JSite::getMenu();
$menuparams = $menu->getParams( $itemid );
$params->merge( $menuparams );
}
}
else {
$params = & JComponentHelper::getParams('com_k2');
}
//Category
$db = & JFactory::getDBO();
$query = "SELECT * FROM #__k2_categories WHERE id=".(int)$item->catid;
$db->setQuery($query, 0, 1);
$category = $db->loadObject();
$item->category=$category;
$item->category->link=urldecode(JRoute::_(K2HelperRoute::getCategoryRoute($category->id.':'.urlencode($category->alias))));
//Read more link
$link = K2HelperRoute::getItemRoute($item->id.':'.urlencode($item->alias),$item->catid.':'.urlencode($item->category->alias));
$item->link=urldecode(JRoute::_($link));
//Print link
$item->printLink = urldecode(JRoute::_($link.'&tmpl=component&print=1'));
//Params
$cparams = new JParameter( $category->params );
$iparams = new JParameter( $item->params );
$item->params= $params;
if ($cparams->get('inheritFrom')){
$masterCategoryID = $cparams->get('inheritFrom');
$query = "SELECT * FROM #__k2_categories WHERE id=".(int)$masterCategoryID;
$db->setQuery($query, 0, 1);
$masterCategory = $db->loadObject();
$cparams = new JParameter( $masterCategory->params );
}
$item->params->merge($cparams);
$item->params->merge($iparams);
//Edit link
if (K2HelperPermissions::canEditItem($item->created_by,$item->catid))
$item->editLink = JRoute::_('index.php?option=com_k2&view=item&task=edit&cid='.$item->id.'&tmpl=component');
//Tags
if(
($view=='item' && ($item->params->get('itemTags') || $item->params->get('itemRelated'))) ||
($view=='itemlist' && ($task=='' || $task=='category') && $item->params->get('catItemTags')) ||
($view=='itemlist' && $task=='user' && $item->params->get('userItemTags')) ||
($view=='latest' && $params->get('latestItemTags'))
)
{
$tags = K2ModelItem::getItemTags($item->id);
for ($i=0; $i<sizeof($tags); $i++) {
$tags[$i]->link = JRoute::_(K2HelperRoute::getTagRoute($tags[$i]->name));
}
$item->tags=$tags;
}
//Image
$item->imageXSmall='';
$item->imageSmall='';
$item->imageMedium='';
$item->imageLarge='';
$item->imageXLarge='';
if (JFile::exists(JPATH_SITE.DS.'media'.DS.'k2'.DS.'items'.DS.'cache'.DS.md5("Image".$item->id).'_XS.jpg'))
$item->imageXSmall = JURI::root().'media/k2/items/cache/'.md5("Image".$item->id).'_XS.jpg';
if (JFile::exists(JPATH_SITE.DS.'media'.DS.'k2'.DS.'items'.DS.'cache'.DS.md5("Image".$item->id).'_S.jpg'))
$item->imageSmall = JURI::root().'media/k2/items/cache/'.md5("Image".$item->id).'_S.jpg';
if (JFile::exists(JPATH_SITE.DS.'media'.DS.'k2'.DS.'items'.DS.'cache'.DS.md5("Image".$item->id).'_M.jpg'))
$item->imageMedium = JURI::root().'media/k2/items/cache/'.md5("Image".$item->id).'_M.jpg';
if (JFile::exists(JPATH_SITE.DS.'media'.DS.'k2'.DS.'items'.DS.'cache'.DS.md5("Image".$item->id).'_L.jpg'))
$item->imageLarge = JURI::root().'media/k2/items/cache/'.md5("Image".$item->id).'_L.jpg';
if (JFile::exists(JPATH_SITE.DS.'media'.DS.'k2'.DS.'items'.DS.'cache'.DS.md5("Image".$item->id).'_XL.jpg'))
$item->imageXLarge = JURI::root().'media/k2/items/cache/'.md5("Image".$item->id).'_XL.jpg';
if (JFile::exists(JPATH_SITE.DS.'media'.DS.'k2'.DS.'items'.DS.'cache'.DS.md5("Image".$item->id).'_Generic.jpg'))
$item->imageGeneric = JURI::root().'media/k2/items/cache/'.md5("Image".$item->id).'_Generic.jpg';
//Extra fields
//.........这里部分代码省略.........
示例4: shGetDefaultDisplayNum
function shGetDefaultDisplayNum($menuItemid, $url, $fromSession = false, $includeBlogLinks = false) {
$app = JFactory::getApplication();
// default value is general configuration list length param
$ret = $app->getCfg( 'list_limit', 10 );
// get elements of the url
$option = shGetURLVar($url, 'option');
$layout = shGetURLVar( $url, 'layout');
if (empty( $layout)) {
$layout = 'default';
}
$view = shGetURLVar( $url, 'view');
// is this a sobi2 url ? we must read config from database
if ($option == 'com_sobi2') {
$itemsPerLine = (int) shGetSobi2Config( 'itemsInLine', 'frontpage');
$linesPerPage = (int) shGetSobi2Config( 'lineOnSite', 'frontpage');
return $itemsPerLine * $linesPerPage;
}
// if there is a menu item, we can try read more params
if (!empty($menuItemid)) {
// itemid, try read params from the menu item
$menu = & JFactory::getApplication()->getMenu();
$menuItem = $menu->getItem($menuItemid); // load menu item from DB
if (empty($menuItem)) return $ret; // if none, default
jimport( 'joomla.html.parameter');
// Load the parameters. Merge Global and Menu Item params into new object
$currentOption = JRequest::getCmd('option');
$params = new JParameter( $menuItem->params ); // get params from menu item
if(!empty($currentOption)) {
$params->merge($app->getParams());
}
// layout = blog and frontpage
if ( ($option =='com_content' && $layout == 'blog')
|| ($option == 'com_content' && $view == 'frontpage')) {
$num_leading_articles = $params->get('num_leading_articles');
$num_intro_articles = $params->get('num_intro_articles');
//adjust limit and listLimit for page calculation as blog views include
//# of links in the limit value, while it should not be included for
// page number calculation
$num_links = $includeBlogLinks ? $params->get('num_links') : 0;
$ret = $num_leading_articles + $num_intro_articles + $num_links; // calculate how many items on a page
return $ret;
}
// elements with a display_num parameter
$displayNum = intval($params->get('display_num'));
$ret = !empty( $displayNum) ? $displayNum : $ret;
}
if ($fromSession) {
// now handle special cases
if ( $option =='com_content' && $layout != 'blog' && ($view == 'category' || $view == 'section')) {
$limit = $app->getUserStateFromRequest( 'com_content.sh.' . $view . '.' . $layout . '.limit', 'limit', null);
if (!is_null($limit)) {
return $limit;
}
}
if ($option == 'com_contact') {
$limit = $app->getUserState( $option . '.' . $view. '.limit');
if (!is_null($limit)) {
return $limit;
}
}
if ($option == 'com_weblinks') {
$limit = $app->getUserState( $option . '.limit');
if (!is_null($limit)) {
return $limit;
}
}
}
// return calculated value
return $ret;
}
示例5: die
<?php
defined('_JEXEC') or die('Restricted access');
$oldsectionid = -1;
$oldcatid = -1;
$contentarray = array();
foreach ($list as $article) {
$component = JComponentHelper::getComponent('com_content');
$cparams = new JParameter($component->params);
$aparams = $article->parameters;
$cparams->merge($aparams);
ob_start();
if ($article->catid == $oldcatid && $article->sectionid == $oldsectionid) {
$article->catid = 0;
$article->sectionid = 0;
} else {
$oldcatid = $article->catid;
$oldsectionid = $article->sectionid;
}
// DO NOT EDIT BEFORE THIS
?>
<?php
if ($cparams->get('show_title')) {
?>
<h2 class="contentheading<?php
echo $params->get('pageclass_sfx');
?>
">
<?php
示例6: autoResizerProcess
function autoResizerProcess(&$article)
{
$app = JFactory::getApplication();
if (get_class($app) === "JAdministrator") {
return true;
}
// get image information of article
$image_infos = json_decode($article->images, true);
if (empty($image_infos['image_intro']) && empty($image_infos['image_fulltext'])) {
return true;
}
// get plugin parameter
$plugin = JPluginHelper::getPlugin('content', 'autoresizer');
if (version_compare(JVERSION, '1.6.0', '<')) {
$pluginParams = new JParameter($plugin->params);
$option = JRequest::getVar('option', '');
if ($option) {
$mergeparams = $app->getParams($option);
}
if (isset($mergeparams)) {
$pluginParams->merge($mergeparams);
}
} else {
$version = new JVersion();
$pluginParams = new JRegistry();
if (version_compare($version->getShortVersion(), '3.0.0', '>=')) {
$pluginParams->loadString($plugin->params);
} else {
$pluginParams->loadJSON($plugin->params);
}
}
$resize_image_intro = $pluginParams->def('resize_image_intro', '0');
$resize_image_article = $pluginParams->def('resize_image_article', '0');
if (!$resize_image_intro && !$resize_image_article) {
return true;
}
// resize image intro
if ($resize_image_intro && !$resize_image_article) {
if (empty($image_infos['image_intro'])) {
return true;
}
}
// resize image fulltext
if (!$resize_image_intro && $resize_image_article) {
if (empty($image_infos['image_fulltext'])) {
return true;
}
}
// process convert image
if ($resize_image_intro) {
// Get parameter for image intro
$scale_img_intro_width = $pluginParams->def('scale_img_intro_width', 160);
$scale_img_intro_height = $pluginParams->def('scale_img_intro_height', 120);
// check path file and get information of image
$path = JPATH_ROOT . "/";
$original_img_file = $path . $image_infos['image_intro'];
if (file_exists($original_img_file) && is_file($original_img_file)) {
$original_img_file_info = pathinfo($original_img_file);
// check extension support
$is_img = $original_img_file_info['extension'] == 'jpg' || $original_img_file_info['extension'] == 'jpeg' || $original_img_file_info['extension'] == 'png' || $original_img_file_info['extension'] == 'gif' || $original_img_file_info['extension'] == 'JPG' || $original_img_file_info['extension'] == 'JPEG' || $original_img_file_info['extension'] == 'PNG' || $original_img_file_info['extension'] == 'GIF';
if ($is_img) {
// create new file
$file_name = md5($original_img_file_info['filename'] . $scale_img_intro_width . $scale_img_intro_height) . "." . $original_img_file_info['extension'];
// check exist resized image
$resize_image_store_dir = $pluginParams->def('resize_image_store_dir', 1);
if ($resize_image_store_dir == 0) {
} else {
if ($resize_image_store_dir == 1) {
if (!file_exists(JPATH_ROOT . "/cache/" . $file_name) || !is_file(JPATH_ROOT . "/cache/" . $file_name)) {
// process resize image
list($original_width, $original_height) = getimagesize($original_img_file);
if ($scale_img_intro_width != $original_width || $scale_img_intro_height != $original_height) {
$image = new Image($original_img_file);
$image->resize($scale_img_intro_width, $scale_img_intro_height, $original_img_file_info['extension']);
$image->save(JPATH_ROOT . "/cache/" . $file_name);
}
}
$image_infos['image_intro'] = "cache/" . $file_name;
} else {
}
}
}
}
/*
$old_image = $file_name;
$new_image = 'cache/' . utf8_substr($file_name, 0, utf8_strrpos($file_name, '.')) . '-' . $scale_img_intro_width . 'x' . $scale_img_intro_height . $type .'.' . $extension;
if (!file_exists(DIR_IMAGE . $new_image) || (filemtime(DIR_IMAGE . $old_image) > filemtime(DIR_IMAGE . $new_image))) {
$path = '';
$directories = explode('/', dirname(str_replace('../', '', $new_image)));
foreach ($directories as $directory) {
$path = $path . '/' . $directory;
if (!file_exists(DIR_IMAGE . $path)) {
@mkdir(DIR_IMAGE . $path, 0777);
}
}
//.........这里部分代码省略.........
示例7: onPrepareContent
function onPrepareContent(&$article, &$params, $limitstart = 0)
{
$mainframe =& JFactory::getApplication();
if (get_class($mainframe) === "JAdministrator") {
return true;
}
$plugin =& JPluginHelper::getPlugin('content', 'smartresizer');
$option = JRequest::getVar('option', '');
if (version_compare(JVERSION, '1.6.0', '<')) {
$pluginParams = new JParameter($plugin->params);
if ($option) {
$mergeparams =& $mainframe->getParams($option);
}
if (isset($mergeparams)) {
$pluginParams->merge($mergeparams);
}
} else {
$version = new JVersion();
$pluginParams = new JRegistry();
if (version_compare($version->getShortVersion(), '3.0.0', '>=')) {
$pluginParams->loadString($plugin->params);
} else {
$pluginParams->loadJSON($plugin->params);
}
}
$processall = (int) $pluginParams->def('processall', '0');
//for J1.7
$isblogintro = 0;
if (!version_compare(JVERSION, '1.6.0', '<')) {
$view = JRequest::getCmd('view');
if ($option == 'com_content') {
if ($view == 'article') {
if (empty($article->text)) {
$article->text = $article->introtext . $article->fulltext;
}
} else {
if ($article->introtext) {
$isblogintro = 1;
}
if (empty($article->text)) {
$article->text = $article->introtext;
}
}
}
}
if (strpos($article->text, 'smartresize') === false && !$processall) {
return true;
}
if ($processall && strpos($article->text, 'img') === false && strpos($article->text, 'IMG') === false) {
return true;
}
if ($processall) {
$runword = "";
} else {
$runword = "smartresize";
}
$regex_img = "|<[\\s\v]*img[\\s\v]([^>]*" . $runword . "[^>]*)>|Ui";
preg_match_all($regex_img, $article->text, $matches_img);
$count_img = count($matches_img[0]);
// plugin only processes if there are any instances of the plugin in the text
if ($count_img) {
$this->plgContentProcessSmartResizeImages($article, $pluginParams, $matches_img, $count_img);
if ($isblogintro) {
$article->introtext = $article->text;
}
}
}