[ Поиск ] - [ Пользователи ] - [ Календарь ]
Полная Версия: template.inc.php
shahin
ошибка вот такая Warning: Invalid argument supplied for foreach() in Z:\home\uasvit.re\www\templates\bt_creative\template.inc.php on line 144

<?php



defined( '_JEXEC' ) or die( 'Restricted access' );


class TplBtCreative {

var $width = 960;

var $btlogo = 'on';

var $header_menu = 'menu';
var $header_menu_name = 'topmenu';

var $seocp = 'off';

var $virtuemart = 'on';

var $blogstyle = '';

function TplBtCreative() {
$this->__construct();
}

function __construct() {
$this->document =& JFactory::getDocument();

$this->prepare_parameters();
$this->prepare_path();


// canonicalize widths for left columns

$width = 0;

if ($this->modcount('left_toolbar') && isset($this->pos_left_toolbar_width) && $this->pos_left_toolbar_width > 0 && $width < $this->pos_left_toolbar_width)
$width = $this->pos_left_toolbar_width;

if ($this->modcount('left_up') && isset($this->pos_left_up_width) && $this->pos_left_up_width > 0 && $width < $this->pos_left_up_width)
$width = $this->pos_left_up_width;

if ($this->modcount('left_slide') && isset($this->pos_left_slide_width) && $this->pos_left_slide_width > 0 && $width < $this->pos_left_slide_width)
$width = $this->pos_left_slide_width;

if ($this->modcount('left') && isset($this->pos_left_width) && $this->pos_left_width > 0 && $width < $this->pos_left_width)
$width = $this->pos_left_width;

if ($this->modcount('left_down') && isset($this->pos_left_down_width) && $this->pos_left_down_width > 0 && $width < $this->pos_left_down_width)
$width = $this->pos_left_down_width;

if ($width == 0)
$width = 200;

$this->pos_left_toolbar_width = $width;
$this->pos_left_up_width = $width;
$this->pos_left_slide_width = $width;
$this->pos_left_width = $width;
$this->pos_left_down_width = $width;


// canonicalize widths for right columns

$width = 0;

if ($this->modcount('right_toolbar') && isset($this->pos_right_toolbar_width) && $this->pos_right_toolbar_width > 0 && $width < $this->pos_right_toolbar_width)
$width = $this->pos_right_toolbar_width;

if ($this->modcount('right_up') && isset($this->pos_right_up_width) && $this->pos_right_up_width > 0 && $width < $this->pos_right_up_width)
$width = $this->pos_right_up_width;

if ($this->modcount('right_slide') && isset($this->pos_right_slide_width) && $this->pos_right_slide_width > 0 && $width < $this->pos_right_slide_width)
$width = $this->pos_right_slide_width;

if ($this->modcount('right') && isset($this->pos_right_width) && $this->pos_right_width > 0 && $width < $this->pos_right_width)
$width = $this->pos_right_width;

if ($this->modcount('right_down') && isset($this->pos_right_down_width) && $this->pos_right_down_width > 0 && $width < $this->pos_right_down_width)
$width = $this->pos_right_down_width;

if ($width == 0)
$width = 200;

$this->pos_right_toolbar_width = $width;
$this->pos_right_up_width = $width;
$this->pos_right_slide_width = $width;
$this->pos_right_width = $width;
$this->pos_right_down_width = $width;


// continue with rest of adjustments

$this->left_main = $this->modcount('left_up') || $this->modcount('left_slide') || $this->modcount('left');
$this->right_main = $this->modcount('right_up') || $this->modcount('right_slide') || $this->modcount('right');

if ($this->blogstyle == 'blogout' && $this->left_main)
$this->blogstyle = 'blogin';

$this->side_gap = 15;
$this->inner_width = $this->width;
$this->width += 2 * $this->side_gap;
$this->left_container_width = $this->pos_left_width + 2 * $this->side_gap;
$this->right_container_width = $this->pos_right_width + 2 * $this->side_gap;

$this->lshow = strtolower($this->btlogo) == 'on';

$this->show_body = $this->show_body();

$this->seocp = $this->show_body && strtolower($this->seocp) == 'on';

$this->virtuemart = strtolower($this->virtuemart) == 'on';

// load styles
require(dirname(__FILE__) . '/zl_styles.php');
$this->mstyles = $mstyles;

$this->show_menu = $this->header_menu == 'menu';

if ($this->show_menu)
$this->load_menu($this->header_menu_name, $this->menu_head_tags, $this->menu_js);
}

function str($str) {
return JText::_($str);
}

function show_body() {
return JRequest::getCmd('option') != 'com_nb';
}

function get_home() {
return $this->document->baseurl;
}

function prepare_parameters() {
foreach ($this->document->params->_registry[$this->document->params->_defaultNameSpace]['data'] as $k => $v) {
if ($k == 'pos_widths') {
$lines = explode("\n", str_replace("\r", '', $v));
foreach ($lines as $line) {
$e = explode(':', $line, 2);
$k = strtolower(trim(@$e[0]));
$v = trim(@$e[1]);
if (preg_match('/^[a-z0-9_]+$/', $k) && ctype_digit($v)) {
if ($k == 'mainbody')
$k .= '_width';
else
$k = 'pos_' . $k . '_width';

$this->$k = $v;
}
}
}

else {
$this->$k = $v;
}
}
}


function prepare_path() {
$this->path = $this->document->baseurl . '/templates/' . $this->document->template;
}

function modcount($position_name) {
static $modules = array();

if (!isset($modules[$position_name]))
$modules[$position_name] = $this->document->countModules($position_name);

return $modules[$position_name];
}

function td_width($position_name, $shrink = false) {
if (is_array($position_name)) {
$max = 0;
foreach ($position_name as $name) {
$k = 'pos_' . $name . '_width';
if (isset($this->$k) && intval($this->$k) > $max)
$max = intval($this->$k);
}

if ($max > 0)
return ' width="' . $max . '"';
}
else {
$k = 'pos_' . $position_name . '_width';
if (isset($this->$k))
return ' width="' . $this->$k . '"';
}

if ($shrink)
return ' width="1%" nowrap="nowrap"';
else
return
'';
}

function get_hidden_position($position_name) {
$result = '';
if ($this->modcount($position_name))
$result =
'<div id="pos_' . $position_name . '" style="display:none">
<jdoc:include type="modules" name="'
. $position_name . '" style="xhtml" />
</div>'
;

return $result;
}

function get_pathway() {
return '<jdoc:include type="modules" name="breadcrumb" />' . "\n";
}

function get_mainbody_pragma() {
$var = 'mainbody_width';
return
'<div id="mainbody"' . (isset($this->$var) && !empty($this->$var) ? ' style="width:' . $this->$var . 'px"' : '') . '>
<jdoc:include type="component" />
</div>
'
;
}

function get_mainbody_wrapper() {
if (!$this->show_body)
return '';

$result = $this->seocp ? '<div id="mainbody_area"></div>' . "\n" : $this->get_mainbody_pragma();
$result .= '<div class="clearfix"></div>' . "\n"; // fix for IE7
return $result;
}

function get_position($position_name, $direct = false, $clearfix = true) {
$result = '';
if ($direct || $this->modcount($position_name)) {
$width = '';
$var = 'pos_' . $position_name . '_width';
if (isset($this->$var) && !empty($this->$var))
$width = $this->$var;

$result .= sprintf(
'<div id="pos_%s"%s>' . "\n",
$position_name,
empty($width) ? '' : ' style="width:' . $width . 'px"'
);
$result .= ' <jdoc:include type="modules" name="' . $position_name . '" style="zlmod" />' . "\n";
$result .= '</div>' . "\n";

if ($clearfix)
$result .= '<div class="clearfix"></div>' . "\n"; // fix for IE7
}
return $result;
}

function get_positions($pos_names, $spacer = '', $spacer_down = true, $clearfix = true, $id = '', $tdgap = false) {
$result = '';
$positions = array();
for ($i = 0, $len = count($pos_names); $i < $len; $i++)
if ($this->modcount($pos_names[$i]))
$positions[] = $pos_names[$i];

if (empty($positions))
return;

$count = count($positions);

if ($spacer != '' && !$spacer_down)
$result .= '<div id="' . $spacer . '"></div>' . "\n";

if ($count > 1)
$result .= '<table ' . ($id == '' ? '' : ' id="' . $id . '"') . 'cellspacing="0" cellpadding="0" width="100%"><tr>' . "\n";

if ($tdgap === false)
$tdgap = '<td class="tdgap"></td>' . "\n";

$first = true;
foreach ($positions as $position_name) {
if ($first)
$first = false;
else
$result .= $tdgap;

if ($count > 1)
$result .= '<td valign="top"' . $this->td_width($position_name) . '>' . "\n";

$result .= $this->get_position($position_name, true, $clearfix);

if ($count > 1)
$result .= '</td>' . "\n";
}

if ($count > 1)
$result .= '</tr></table>' . "\n";

if ($spacer != '' && $spacer_down)
$result .= '<div id="' . $spacer . '"></div>' . "\n";

return $result;
}

function load_menu($menu_name, &$out_head_tags, &$out_js) {
$user =& JFactory::getUser();
$user_access = (int) $user->get('aid', 0);

$contentConfig = &JComponentHelper::getParams( 'com_content' );
$shownoauth = $contentConfig->get('shownoauth');

$db =& JFactory::getDBO();
$db->setQuery( sprintf(
"SELECT * FROM #__menu WHERE menutype=%s AND published='1' %s ORDER BY ordering",
$db->Quote($menu_name),
$shownoauth ? "" : "AND access <= '$user_access'"
) );
$menu = $db->loadObjectList('id');

// initialize menu tree
$menu_base = array();
foreach ($menu as $k => $mitem) {
$mi = $this->load_menu_item($mitem);
$menu[$k]->is_active = $mi['selection'] > 0;
$menu[$k]->selection = $mi['selection'];
$menu[$k]->type = $mi['type'];
$menu[$k]->link = $mi['link'];
$menu[$k]->href = $mi['href'];
$menu[$k]->name = $mi['name'];
$menu[$k]->image = $mi['image'];
$menu[$k]->sub_menu_items = array();
}

// load virtuemart menu items
if ($this->virtuemart) {
if (!defined('_VM_PARSER_LOADED')) {
$ini_filename = dirname(__FILE__) . '/../../components/com_virtuemart/virtuemart_parser.php';
if (file_exists($ini_filename))
require_once($ini_filename);
}

if (defined('_VM_PARSER_LOADED')) {
require_once(dirname(__FILE__) . '/vm_loader.inc.php');
$vm_loader = new BtMenuVMLoader();
$vm_menu = array();
foreach ($menu as $k => $mi) {
if ($mi->link != '' && $mi->link{0} == ':' && $mi->type == 'link') {
$link = trim(strtolower($mi->link));
if (substr($link, 0, 4) == ':vm:') {
$menu[$k]->link = '#';
$menu[$k]->href = 'href="#"';

$new_menu = $vm_loader->load($k, $link);
foreach ($new_menu as $k => $v)
$vm_menu[$k] = $v;
}
}
}


foreach ($vm_menu as $k => $v)
$menu[$k] = $v;
}
}


// set tree hierarchy
foreach ($menu as $k => $mitem) {
if ($mitem->parent == '0')
$menu_base[] = $k;
else if (isset($menu[$mitem->parent]))
$menu[$mitem->parent]->sub_menu_items[] = $k;
}

// prepare javascript code
$out_head_tags = array();
$out_js = '';
if (!empty($menu_base)) {
$stack = array('base' => $menu_base);
while (!empty($stack)) {
reset($stack);
list($base, $items) = each($stack);
array_shift($stack);

foreach ($items as $item) {
$mi = &$menu[$item];

if (!empty($mi->sub_menu_items))
$stack = array_merge($stack, array('cmi' . $item => $mi->sub_menu_items));

if (!empty($mi->image))
$mi->name = $mi->image . ' ' . $mi->name;

if ($base == 'base') {
$mi->head_id = 'cmi' . $item;
$mi->full_link = $mi->href != '' ? '<a ' . $mi->href . '>' . $mi->name . '</a>' : $mi->name;
$out_head_tags[] = $mi;
$out_js .= sprintf(
"document['cmenu_items'].push({id: '%s', type: '%s', link: '%s', selection: %u});\n",
'cmi' . $item,
json_esc($mi->type),
json_esc(str_replace('&', '&', $mi->link)),
$mi->selection
);
}
else {
$out_js .= sprintf(
"document['cmenu_items'].push({id: '%s', parent_id: '%s', type: '%s', link: '%s', caption: '%s', selection: %u});\n",
'cmi' . $item,
$base,
json_esc($mi->type),
json_esc(str_replace('&', '&', $mi->link)),
json_esc(str_replace('&', '&', $mi->name)),
$mi->selection
);
}
}
}
}

}


function load_menu_item($item) {
$result = array(
'type' => 'text', // text, link, link_new, link_popup, separator
'name' => $item->name,
'link' => '',
'href' => '',
'image' => '',
'selection' => 0, // 0 = none, 1 = parent, 2 = current
);

// Menu Link is a special type that is a link to another item
if ($item->type == 'menulink') {
$target_id = 0;

if (!empty($item->params)) {
$source_params = new JParameter($item->params);
$target_id = $source_params->get('menu_item', 0);
}

if ($target_id == 0 && preg_match('/Itemid=([0-9]+)/', $item->link, $m))
$target_id = intval($m[1]);

if ($target_id > 0) {
$menu = &JSite::getMenu();
if ($tmp = $menu->getItem($target_id))
$item = $tmp;
}
}


static $path = false;
if ($path === false) {
$menu = &JSite::getMenu();
$active = $menu->getActive();
$path = isset($active) ? array_reverse($active->tree) : null;
}

if (!is_array($path) || empty($path))
{ } // ignore cases
else if ($path[0] == $item->id)
$result['selection'] = 2;
else if (in_array($item->id, $path))
$result['selection'] = 1;

$iParams = new JParameter($item->params);
if ($iParams->get('menu_image') && $iParams->get('menu_image') != -1)
$result['image'] = '<img src="'.JURI::base(true).'/images/stories/'.$iParams->get('menu_image').'" alt="" border="0" />';

switch ($item->type) {
case 'separator' :
$result['type'] = 'separator';
break;

case 'url' :
if ((strpos($item->link, 'index.php?') !== false) && (strpos($item->link, 'Itemid=') === false)) {
$item->url = $item->link.'&Itemid='.$item->id;
} else {
$item->url = $item->link;
}
break;

default :
$router = JSite::getRouter();
$item->url = $router->getMode() == JROUTER_MODE_SEF ? 'index.php?Itemid='.$item->id : $item->link.'&Itemid='.$item->id;
break;
}

// Print a link if it exists
if ($item->type != 'separator' && $item->url != null)
{
// Handle SSL links
$iSecure = $iParams->def('secure', 0);
if ($item->home == 1) {
$item->url = JURI::base();
} elseif (strcasecmp(substr($item->url, 0, 4), 'http') && (strpos($item->link, 'index.php?') !== false)) {
$item->url = JRoute::_($item->url, true, $iSecure);
} else {
$item->url = str_replace('&', '&', $item->url);
}

$result['link'] = $item->url;

switch ($item->browserNav) {
case 1:
// _blank
$result['href'] = 'href="'.$item->url.'" target="_blank"';
$result['type'] = 'link_new';
break;

case 2:
// window.open
$attribs = 'toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,resizable=yes';
$link = str_replace('index.php', 'index2.php', $item->url);
$result['href'] = 'href="'.$link.'" onclick="window.open(this.href,\'targetWindow\',\''.$attribs.'\');return false;"';
$result['type'] = 'link_popup';
$result['link'] = $link;
break;

case 0:
default:
// _top
$result['href'] = 'href="'.$item->url.'"';
$result['type'] = 'link';
break;
}

if ($result['type'] == 'text')
$result['type'] = 'link';
}

return $result;
}

}




if (!function_exists('json_esc')) {
function json_esc($input, $esc_lt_gt = true) {
$result = '';
$input = (string) $input;
$conv = array( "'" => "'", '"' => '"', '&' => '&', '\\' => '\\', "\n" => 'n', "\r" => 'r', "\t" => 't', "\b" => 'b', "\f" => 'f' );

if ($esc_lt_gt)
$conv = array_merge($conv, array( '<' => 'u003C', '>' => 'u003E' ));

for ($i = 0, $len = strlen($input); $i < $len; $i++)
$result .= isset($conv[$input{$i}]) ? '\\' . $conv[$input{$i}] : $input{$i};

return $result;
}
}


global $tpl;
$tpl = new TplBtCreative();

?>


как можно исправить эту ошибку?



Спустя 1 минута, 22 секунды (10.01.2011 - 10:50) shahin написал(а):
вот строка 144

foreach ($this->document->params->_registry[$this->document->params->_defaultNameSpace]['da ta'] as $k => $v) 
[code]

Спустя 19 минут, 40 секунд (10.01.2011 - 11:10) alex12060 написал(а):
foreach ($this->document->params->_registry[$this->document->params->_defaultNameSpace]['data'] as $k => $v)


$this->document->params->_registry


Это как я понял массив, узнай, он точно двумерный, или нет?

$this->document->params->_defaultNameSpace


Узнай, что выводит эта строка.

Спустя 7 минут, 54 секунды (10.01.2011 - 11:18) shahin написал(а):
Цитата
Узнай, что выводит эта строка.


если честно я даже не знаю как узнать что выводит это строка. думаю это текст какой то

Спустя 12 минут, 7 секунд (10.01.2011 - 11:30) shahin написал(а):
Цитата
Узнай, что выводит эта строка

это текст название сайта на шапке

Спустя 27 минут, 54 секунды (10.01.2011 - 11:58) alex12060 написал(а):
Ну, теперь давай посмеемся)

Допустим, название сайта: Автомобили)

Тогда:


foreach ($this->document->params->_registry[$this->document->params->_defaultNameSpace]['data'] as $k => $v)


Выглядит вот так:


foreach ($this->document->params->_registry[Автомобили]['data'] as $k => $v)


Посмотри, какие значения этот массив имеет:

$this->document->params->_registry

Спустя 17 минут, 14 секунд (10.01.2011 - 12:15) Guest написал(а):
Цитата
Ну, теперь давай посмеемся)

не до смеха друг.
опишу всё подробно.
это шаблон для Joomla 1.5 я хотел переделать его для Joomla 1.6 и в XML файле поменял кое что: вот эту строку
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE install PUBLIC "-//Joomla! 1.5//DTD template 1.0//EN" "http://dev.joomla.org/xml/1.5/template-install.dtd">
<install version="1.5" type="template">

поменял на:
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE install PUBLIC "-//Joomla! 1.6//DTD template 1.0//EN" "http://www.joomla.org/xml/dtd/1.6/template-install.dtd">
<extension version="1.6" type="template" client="site">


а это:
<params>

<param
name="width" type="text" default="689" label="Total width" description="Total width in pixels. Example: 689" />

<param
name="blogstyle" type="list" default="blogout" label="Article Date Style" description="Style for the articles' date tag. Default: Blog external">
<option
value="blogout">Blog External</option>
<option
value="blogin">Blog Internal</option>
<option
value="native">Native</option>
</param>

<param
name="pos_widths" type="textarea" cols="20" rows="5" default="" label="Position widths" description="Widths of positions. Each line should have one position, a semi-colon and an integer number that represents a width in pixels. Example: left:200. To set the width of main body use the keyword: mainbody" />

<param
name="header_menu" type="radio" default="menu" label="Header Menu Type" description="Enables the default menu on the top of the page or position header. Default: Menu">
<option
value="menu">Menu</option>
<option
value="header">Position Header</option>
</param>

<param
name="header_menu_name" type="mos_menu" default="topmenu" label="Header menu name" description="Name of the Joomla menu that will be used as source for the menu on the page header. Default: topmenu" />

<param
name="virtuemart" type="radio" default="on" label="VirtueMart support" description="Enables the link of the menu with VirtueMart's content. Default: On">
<option
value="on">On</option>
<option
value="off">Off</option>
</param>

<param
name="btlogo" type="radio" default="on" label="BT Logo" description="Shows or hides the BonusThemes logo. Default: On">
<option
value="on">On</option>
<option
value="off">Off</option>
</param>

<param
name="seocp" type="radio" default="off" label="SEOCP" description="Enable SEOCP (Search Engine Optimized Content Positioning) to position put the content of your website in the start of the HTML content. This helps search engines find and analyse the content easier. On the downside if SEOCP is enabled users who disabled the JavaScript engine of their browser will not be able to see the page's main content. Default: Off">
<option
value="on">On</option>
<option
value="off">Off</option>
</param>

</params>

</install>



на это:
<config>
<fields
name="params">
<fieldset
name="advanced">

<field
name="width" type="text" default="689" label="Total width" description="Total width in pixels. Example: 689" />

<field
name="blogstyle" type="list" default="blogout" label="Article Date Style" description="Style for the articles' date tag. Default: Blog external">
<option
value="blogout">Blog External</option>
<option
value="blogin">Blog Internal</option>
<option
value="native">Native</option>
</field>

<field
name="pos_widths" type="textarea" cols="20" rows="5" default="" label="Position widths" description="Widths of positions. Each line should have one position, a semi-colon and an integer number that represents a width in pixels. Example: left:200. To set the width of main body use the keyword: mainbody" />

<field
name="header_menu" type="radio" default="menu" label="Header Menu Type" description="Enables the default menu on the top of the page or position header. Default: Menu">
<option
value="menu">Menu</option>
<option
value="header">Position Header</option>
</field>

<field
name="header_menu_name" type="mos_menu" default="topmenu" label="Header menu name" description="Name of the Joomla menu that will be used as source for the menu on the page header. Default: topmenu" />

<field
name="virtuemart" type="radio" default="on" label="VirtueMart support" description="Enables the link of the menu with VirtueMart's content. Default: On">
<option
value="on">On</option>
<option
value="off">Off</option>
</field>

<field
name="btlogo" type="radio" default="on" label="BT Logo" description="Shows or hides the BonusThemes logo. Default: On">
<option
value="on">On</option>
<option
value="off">Off</option>
</field>

<field
name="seocp" type="radio" default="off" label="SEOCP" description="Enable SEOCP (Search Engine Optimized Content Positioning) to position put the content of your website in the start of the HTML content. This helps search engines find and analyse the content easier. On the downside if SEOCP is enabled users who disabled the JavaScript engine of their browser will not be able to see the page's main content. Default: Off">
<option
value="on">On</option>
<option
value="off">Off</option>
</field>

</fieldset>
</fields>
</config>
</extension>



думаю все это правильно сделал. и шаблон устоновлвается на сайт. только ошибка которая на верху написал
Быстрый ответ:

 Графические смайлики |  Показывать подпись
Здесь расположена полная версия этой страницы.
Invision Power Board © 2001-2024 Invision Power Services, Inc.