本文整理汇总了PHP中JMenu::getInstance方法的典型用法代码示例。如果您正苦于以下问题:PHP JMenu::getInstance方法的具体用法?PHP JMenu::getInstance怎么用?PHP JMenu::getInstance使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类JMenu
的用法示例。
在下文中一共展示了JMenu::getInstance方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getItems
public function getItems()
{
if ($items = parent::getItems()) {
$component = JComponentHelper::getComponent('com_tz_portfolio_plus');
$menus = JMenu::getInstance('site');
$menu_assigned = array();
if ($menu_items = $menus->getItems(array('component_id'), $component->id)) {
if (count($menu_items)) {
foreach ($menu_items as $m) {
if (isset($m->params)) {
$params = $m->params;
if ($tpl_style_id = $params->get('tz_template_style_id')) {
if (!isset($menu_assigned[$tpl_style_id])) {
$menu_assigned[$tpl_style_id] = 0;
}
$menu_assigned[$tpl_style_id]++;
}
}
}
}
}
foreach ($items as $i => &$item) {
$item->menu_assigned = 0;
if (isset($menu_assigned[$item->id])) {
$item->menu_assigned = $menu_assigned[$item->id];
}
}
return $items;
}
return false;
}
示例2: display
function display($tpl = null)
{
global $option, $mainframe;
$model =& $this->getModel();
$menu =& JMenu::getInstance('site');
$item = $menu->getActive();
$params =& $menu->getParams($item->id);
//get controller
$controller = new VnffhotelController();
$cityid = $params->get('cityid', '1');
$cityid = JRequest::getVar('cityid', $cityid);
//if($cityid==1)
$hotels = $model->getHotelsByCity($cityid);
$pagination = $model->getPagination();
for ($i = 0; $i < count($hotels); $i++) {
$hotels[$i]->images = $model->getHotelImages($hotels[$i]->hotel_ID, 'm');
if (count($hotels[$i]->images) == 0) {
$image->image_Name = "noimage.png";
$hotels[$i]->images[0] = $image;
}
$hotels[$i]->shortDes = $controller->cutDes($hotels[$i]->Overview, 30);
$hotels[$i]->linkToHotel = $controller->linkToHotel($hotels[$i]->hotel_ID);
}
//get controller
$mainframe->setPageTitle(JTEXT::_("HOTELS IN") . " " . $hotels[0]->city_Name);
//echo $hotels[0]->images[0]->image_Name;
//echo $hotels[0]->city_ID."hehehejhe";
$this->assignRef('hotels', $hotels);
$this->assignRef('pagination', $pagination);
$this->assignRef('controller', $controller);
//echo $this->cutDes("thang nay khung qua di thoi");
parent::display($tpl);
}
示例3: jimport
function &getMenu()
{
jimport('joomla.application.menu');
$options = array();
$menu =& JMenu::getInstance('site', $options);
if (JError::isError($menu)) {
$null = null;
return $null;
}
return $menu;
}
示例4: __construct
function __construct()
{
$this->alltimepoints = JRequest::getVar("points", 0);
$menu =& JMenu::getInstance('site');
$item = $menu->getActive();
$params =& $menu->getParams($item->id);
//$menu = &JSite::getMenu();
$show_debug_info = JComponentHelper::getParams('com_joomleague')->get('show_debug_info', 0);
if ($show_debug_info) {
$this->debug_info = true;
} else {
$this->debug_info = false;
}
if ($item->id) {
// diddipoeler
// menueeintrag vorhanden
$registry = new JRegistry();
$registry->loadArray($params);
//$newparams = $registry->toString('ini');
$newparams = $registry->toArray();
//echo "<b>menue newparams</b><pre>" . print_r($newparams, true) . "</pre>";
foreach ($newparams['data'] as $key => $value) {
$this->_params[$key] = $value;
}
} else {
$strXmlFile = JLG_PATH_SITE . DS . 'settings' . DS . 'default' . DS . 'rankingalltime.xml';
// get the JForm object
$form =& JForm::getInstance('jlattform', $strXmlFile);
//echo "<b>menue form</b><pre>" . print_r($form, true) . "</pre>";
foreach ($form->getFieldset($fieldset->name) as $field) {
// echo ' -> '. $field->name.'<br>';
// echo ' -> '. $field->type.'<br>';
// echo ' -> '. $field->input.'<br>';
$this->_params[$field->name] = $field->value;
}
/*
$registry = new JRegistry();
$registry->loadArray($strXmlFile);
//$newparams = $registry->toString('ini');
$newparams = $registry->toArray();
//echo "<b>menue newparams</b><pre>" . print_r($newparams, true) . "</pre>";
foreach ($newparams['data'] as $key => $value ) {
$this->_params[$key] = $value;
}
*/
}
parent::__construct();
}
示例5: getParams
/**
*
*
*/
public function getParams($pks)
{
$app = JFactory::getApplication('site');
$siteMenu = JMenu::getInstance('site');
$menuParams = $siteMenu->getItem($pks['Itemid']);
if (isset($menuParams->params)) {
$params = $menuParams->params;
} else {
$params = $this->getState()->get('params');
}
$JSNConfig = JSNFactory::getConfig();
$JSNConfig->megreGlobalParams($pks['option'], $params);
return $params;
}
示例6: step1
function step1()
{
global $option, $mainframe;
$mainframe->setPageTitle(JTEXT::_("STEP 1"));
$model =& $this->getModel();
$hid = JRequest::getVar('hid', '');
if ($hid == '') {
echo '<div class="invalid_hotel">' . JTEXT::_("INVALID HOTEL...!") . '</div>';
return;
}
$menu =& JMenu::getInstance('site');
$item = $menu->getActive();
$params =& $menu->getParams($item->id);
//get controller
$controller = new VnffhotelController();
$today = getdate();
$next2day = getdate(($today["0"] / (60 * 60 * 24) + 2) * (60 * 60 * 24));
$checkin_date = JRequest::getVar('checkin_date', $today["mday"] . '/' . $today["mon"] . '/' . $today["year"]);
$checkout_date = JRequest::getVar('checkout_date', $next2day["mday"] . '/' . $next2day["mon"] . '/' . $next2day["year"]);
$room_id = JRequest::getVar('room_id', '');
$checkin_date_r = explode('/', $checkin_date);
$checkout_date_r = explode('/', $checkout_date);
//$checkin_date = getdate(mktime(0, 0, 0, $checkin_date_r[1], $checkin_date_r[0], $checkin_date_r[2]));
$days_count = round((-mktime(0, 0, 0, $checkin_date_r[1], $checkin_date_r[0], $checkin_date_r[2]) + mktime(0, 0, 0, $checkout_date_r[1], $checkout_date_r[0], $checkout_date_r[2])) / (60 * 60 * 24), 0);
if ($days_count < 1) {
$checkin_date = $today["mday"] . '/' . $today["mon"] . '/' . $today["year"];
$checkout_date = $next2day["mday"] . '/' . $next2day["mon"] . '/' . $next2day["year"];
$days_count = 2;
}
//get controller
//$controller = new VnffhotelController();
//get rooms types of a hotel
$roomTypes = $model->getRoomTypes($hid);
if (count($roomTypes) == 0) {
echo '<div class="notroom_hotel">' . JTEXT::_("HOTEL NOT YET FOR BOOKING") . '</div>';
return;
}
$hotel = $model->getHotel($hid);
//echo $roomTypes[0]->room_Name;
//$cityid = $params->get('cityid', '32');
$this->assignRef('controller', $controller);
$this->assignRef('checkin_date', $checkin_date);
$this->assignRef('checkout_date', $checkout_date);
$this->assignRef('room_id', $room_id);
$this->assignRef('roomTypes', $roomTypes);
$this->assignRef('hotel', $hotel);
$this->assignRef('days_count', $days_count);
parent::display("step1");
}
示例7: getInput
/**
* Method to get the field input markup.
*
* @return string The field input markup.
* @since 1.6
*/
protected function getInput()
{
$app = JFactory::getApplication();
$options = array();
$module_id = $app->input->getInt('id');
$menus = JMenu::getInstance('site');
$menu_id = null;
$menuItems = array();
foreach ($menus->getMenu() as $item) {
if ($item->type == 'component') {
if (isset($item->query['option']) && $item->query['option'] == 'com_j2store') {
if (isset($item->query['catid'])) {
$options[$item->id] = $item->title;
}
}
}
}
return JHTML::_('select.genericlist', $options, $this->name, array('class' => "input"), 'value', 'text', $this->value);
}
示例8: __construct
function __construct()
{
$comp_config =& JComponentHelper::getParams('com_imagebrowser');
$config['root_folder'] = $comp_config->get('root_folder', 'images/stories/imagebrowser');
$config['order_by'] = $comp_config->get('order_by', 'date_modified');
$config['order_direction'] = $comp_config->get('order_direction', 'DESC');
$config['show_comp_description'] = $comp_config->get('show_comp_description', 1);
$config['comp_description'] = $comp_config->get('comp_description', '');
$config['language'] = $comp_config->get('language', '');
$config['max_width'] = $comp_config->get('max_width', 800);
$config['max_height'] = $comp_config->get('max_height', 600);
$config['thumb_width'] = $comp_config->get('thumb_width', 120);
$config['thumb_height'] = $comp_config->get('thumb_height', 90);
$config['imgcomp'] = $comp_config->get('imgcomp', 0);
$config['max_upload_size'] = $comp_config->get('max_upload_size', 2);
// The mode is read from menu item (for frontend only)
$menu =& JMenu::getInstance('site');
$item = $menu->getActive();
if (is_object($item)) {
$params =& $menu->getParams($item->id);
$config['mode'] = $params->get('mode', false);
$config['page_title'] = $params->get('page_title', '');
$config['show_page_title'] = $params->get('show_page_title', 0);
$config['pageclass_sfx'] = $params->get('pageclass_sfx', '');
// Override global component settings with menu item settings
$config['root_folder'] = $params->get('root_folder', $config['root_folder']);
$config['order_by'] = $params->get('order_by', $config['order_by']);
$config['order_direction'] = $params->get('order_direction', $config['order_direction']);
$config['show_comp_description'] = $params->get('show_comp_description', $config['show_comp_description']);
$config['comp_description'] = $params->get('comp_description', $config['comp_description']);
$config['language'] = $params->get('language', $config['language']);
$config['max_width'] = $params->get('max_width', $config['max_width']);
$config['max_height'] = $params->get('max_height', $config['max_height']);
$config['thumb_width'] = $params->get('thumb_width', $config['thumb_width']);
$config['thumb_height'] = $params->get('thumb_height', $config['thumb_height']);
$config['imgcomp'] = $params->get('imgcomp', $config['imgcomp']);
$config['max_upload_size'] = $params->get('max_upload_size', $config['max_upload_size']);
}
$this->config = $config;
}
示例9: _getItemid
protected static function _getItemid($view = 'galleries', $id = 0, $default = 0)
{
$item = null;
$menu = JMenu::getInstance('site');
if ($id && ($items = $menu->getItems('link', 'index.php?option=com_fwgallery&view=' . $view))) {
foreach ($items as $menuItem) {
if (is_string($menuItem->params) && preg_match('/id\\=' . $id . '\\s/ms', $menuItem->params) || is_object($menuItem->params) && $id == $menuItem->params->get('id')) {
$item = $menuItem;
break;
}
}
}
if ($item === null) {
$item = $menu->getItems('link', 'index.php?option=com_fwgallery&view=galleries', true);
}
if ($item) {
return $item->id;
} elseif ($default) {
return $default;
} elseif ($item = $menu->getActive()) {
return $item->id;
}
}
示例10: __construct
function __construct()
{
$this->projectid = JRequest::getInt("p", 0);
$menu =& JMenu::getInstance('site');
$item = $menu->getActive();
$params =& $menu->getParams($item->id);
$registry = new JRegistry();
$registry->loadArray($params);
//$newparams = $registry->toString('ini');
$newparams = $registry->toArray();
//echo "<b>menue newparams</b><pre>" . print_r($newparams, true) . "</pre>";
foreach ($newparams['data'] as $key => $value) {
$this->_params[$key] = $value;
}
// $this->round = JRequest::getInt( "r", $this->current_round);
// $this->part = JRequest::getInt( "part", 0);
// $this->from = JRequest::getInt( 'from', $this->round );
// $this->to = JRequest::getInt( 'to', $this->round);
// $this->type = JRequest::getInt( 'type', 0 );
// $this->last = JRequest::getInt( 'last', 0 );
// $this->selDivision = JRequest::getInt( 'division', 0 );
parent::__construct();
}
示例11: createMenu
public function createMenu($menu, $submenu)
{
jimport('joomla.utilities.string');
jimport('joomla.application.component.helper');
$component_id = JComponentHelper::getComponent('com_judirectory')->id;
$db = JFactory::getDbo();
$query = "UPDATE #__menu SET component_id=" . $db->quote($component_id) . " WHERE type = 'component' AND link LIKE '%option=com_judirectory%'";
$db->setQuery($query);
$db->execute();
if ($db->getErrorNum()) {
throw new Exception($db->getErrorMsg(), $db->getErrorNum());
}
$table = JTable::getInstance('MenuType');
$data = array('menutype' => 'judirectorymenu', 'title' => 'JU Directory', 'description' => '');
if (!$table->bind($data) || !$table->check()) {
return true;
}
if (!$table->store()) {
throw new Exception($table->getError());
}
$table = JTable::getInstance('menu');
$table->load(array('menutype' => 'judirectorymenu', 'link' => $menu['link']));
$paramdata = array('menu-anchor_title' => '', 'menu-anchor_css' => '', 'menu_image' => '', 'menu_text' => 1, 'page_title' => '', 'show_page_heading' => 0, 'page_heading' => '', 'pageclass_sfx' => '', 'menu-meta_description' => '', 'menu-meta_keywords' => '', 'robots' => '', 'secure' => 0);
$gparams = new JRegistry($paramdata);
$params = clone $gparams;
$params->loadArray($menu['params']);
$data = array('menutype' => 'judirectorymenu', 'title' => $menu['name'], 'alias' => $menu['alias'], 'link' => $menu['link'], 'type' => 'component', 'published' => 1, 'parent_id' => 1, 'component_id' => $component_id, 'access' => $menu['access'], 'params' => (string) $params, 'home' => 0, 'language' => '*', 'client_id' => 0);
$table->setLocation(1, 'last-child');
if (!$table->bind($data) || !$table->check() || !$table->store()) {
$table->alias = 'joomultra-directory';
if (!$table->check() || !$table->store()) {
throw new Exception($table->getError());
}
}
$parent = $table;
foreach ($submenu as $menuitem) {
$params = clone $gparams;
$params->loadArray($menuitem['params']);
$table = JTable::getInstance('menu');
$table->load(array('menutype' => 'judirectorymenu', 'link' => $menuitem['link']));
$data = array('menutype' => 'judirectorymenu', 'title' => $menuitem['name'], 'alias' => $menuitem['alias'], 'link' => $menuitem['link'], 'type' => 'component', 'published' => 1, 'parent_id' => $parent->id, 'component_id' => $component_id, 'access' => $menuitem['access'], 'params' => (string) $params, 'home' => 0, 'language' => '*', 'client_id' => 0);
$table->setLocation($parent->id, 'last-child');
if (!$table->bind($data) || !$table->check() || !$table->store()) {
throw new Exception($table->getError());
}
}
$defaultmenu = JMenu::getInstance('site')->getDefault();
if (!$defaultmenu) {
return true;
}
$table = JTable::getInstance('menu');
$table->load(array('menutype' => $defaultmenu->menutype, 'type' => 'alias', 'title' => 'JU Directory'));
if (!$table->id) {
$data = array('menutype' => $defaultmenu->menutype, 'title' => 'JU Directory', 'alias' => 'judirectory-' . JFactory::getDate()->format('Y-m-d'), 'link' => 'index.php?Itemid=' . $parent->id, 'type' => 'alias', 'published' => 0, 'parent_id' => 1, 'component_id' => 0, 'access' => 1, 'params' => '{"aliasoptions":"' . (int) $parent->id . '","menu-anchor_title":"","menu-anchor_css":"","menu_image":""}', 'home' => 0, 'language' => '*', 'client_id' => 0);
$table->setLocation(1, 'last-child');
} else {
$data = array('alias' => 'judirectory-' . JFactory::getDate()->format('Y-m-d'), 'link' => 'index.php?Itemid=' . $parent->id, 'params' => '{"aliasoptions":"' . (int) $parent->id . '","menu-anchor_title":"","menu-anchor_css":"","menu_image":""}');
}
if (!$table->bind($data) || !$table->check() || !$table->store()) {
throw new Exception($table->getError());
}
return true;
}
示例12: saveDataToTableMenu
/**
* Saves data to the core menu table
*
* @param string $title
* @param string $description
* @param string $keywords
*/
private function saveDataToTableMenu($title, $description, $keywords)
{
$menu = JMenu::getInstance('site')->getActive();
// Check whether menu entry for the specific item exists - e.g. do not overwrite data of blog entry
foreach ($menu->query as $key => $value) {
if ($value != $this->request->get($key, 'cmd')) {
return;
}
}
$menu_params_array = JMenu::getInstance('site')->getParams($menu->id)->toArray();
$save_data_table_menu = $this->params->get('save_data_table_menu');
$title_array = array(1, 4, 5, 7);
$description_array = array(2, 4, 6, 7);
$keywords_array = array(3, 5, 6, 7);
if (in_array($save_data_table_menu, $title_array)) {
$menu_params_array['page_title'] = $title;
}
if (in_array($save_data_table_menu, $description_array)) {
$menu_params_array['menu-meta_description'] = $description;
}
if (in_array($save_data_table_menu, $keywords_array)) {
$menu_params_array['menu-meta_keywords'] = $keywords;
}
$menu_params = json_encode($menu_params_array);
$query = "UPDATE " . $this->db->quoteName('#__menu') . " SET " . $this->db->quoteName('params') . " = " . $this->db->quote($menu_params) . " WHERE " . $this->db->quoteName('id') . " = " . $this->db->quote((int) $this->request->get('Itemid'));
$this->db->setQuery($query);
$this->db->execute();
}
示例13: _setHomepage
protected function _setHomepage($id)
{
if (!$id) {
return;
}
$app = JFactory::getApplication();
$menu = JMenu::getInstance('site');
$home = $menu->getDefault();
$my = $menu->getItem($id);
$path = substr(JURI::getInstance()->getPath(), 1);
// todo: need to be improved!
if (!(!$path || $path == 'index.php/' . @$my->alias || $path == @$my->alias . '.html')) {
$home->title = @$my->title;
} else {
$home->id = @$my->id;
$home->title = @$my->title;
$home->type = @$my->type;
$home->access = @$my->access;
$home->component = @$my->component;
$home->component_id = @$my->component_id;
$home->link = @$my->link;
$home->params = @$my->params;
$home->query = @$my->query;
}
}
示例14: ajaxComments
public function ajaxComments()
{
$input = JFactory::getApplication()->input;
$data = json_decode(base64_decode($input->getString('url')));
$id = json_decode(base64_decode($input->getString('id')));
if ($data) {
require_once JPATH_COMPONENT_ADMINISTRATOR . DIRECTORY_SEPARATOR . 'libraries' . DIRECTORY_SEPARATOR . 'phpclass' . DIRECTORY_SEPARATOR . 'http_fetcher.php';
require_once JPATH_COMPONENT_ADMINISTRATOR . DIRECTORY_SEPARATOR . 'libraries' . DIRECTORY_SEPARATOR . 'phpclass' . DIRECTORY_SEPARATOR . 'readfile.php';
$params = JComponentHelper::getParams('com_tz_portfolio_plus');
$Itemid = $input->getInt('Itemid');
$menu = JMenu::getInstance('site');
$menuParams = $menu->getParams($Itemid);
$params->merge($menuParams);
$threadLink = null;
$_id = null;
if (is_array($data) && count($data)) {
foreach ($data as $i => &$contentUrl) {
if (!preg_match('/http\\:\\/\\//i', $contentUrl)) {
$uri = JUri::getInstance();
$contentUrl = $uri->getScheme() . '://' . $uri->getHost() . $contentUrl;
}
if (preg_match('/(.*?)(\\?tmpl\\=component)|(\\&tmpl\\=component)/i', $contentUrl)) {
$contentUrl = preg_replace('/(.*?)(\\?tmpl\\=component)|(\\&tmpl\\=component)/i', '$1', $contentUrl);
}
$_id[$contentUrl] = $id[$i];
if ($params->get('tz_comment_type', 'disqus') == 'facebook') {
$threadLink .= '&urls[]=' . $contentUrl;
} elseif ($params->get('tz_comment_type', 'disqus') == 'disqus') {
$threadLink .= '&thread[]=link:' . $contentUrl;
}
}
}
if (!is_array($data)) {
$threadLink = $data;
}
$fetch = new Services_Yadis_Plainhttp_fetcher();
$comments = null;
if ($params->get('tz_show_count_comment', 1) == 1) {
// From Facebook
if ($params->get('tz_comment_type', 'disqus') == 'facebook') {
if ($threadLink) {
$url = 'http://api.facebook.com/restserver.php?method=links.getStats' . $threadLink;
$content = $fetch->get($url);
if ($content) {
if ($bodies = $content->body) {
if (preg_match_all('/\\<link_stat\\>(.*?)\\<\\/link_stat\\>/ims', $bodies, $matches)) {
if (isset($matches[1]) && !empty($matches[1])) {
foreach ($matches[1] as $val) {
$match = null;
if (preg_match('/\\<url\\>(.*?)\\<\\/url\\>.*?\\<comment_count\\>(.*?)\\<\\/comment_count\\>/msi', $val, $match)) {
if (isset($match[1]) && isset($match[2])) {
if (in_array($match[1], $data)) {
$comments[$_id[$match[1]]] = $match[2];
}
}
}
}
}
}
}
}
}
}
// Disqus Comment count
if ($params->get('tz_comment_type', 'disqus') == 'disqus') {
$url = 'https://disqus.com/api/3.0/threads/list.json?api_secret=' . $params->get('disqusApiSecretKey', '4sLbLjSq7ZCYtlMkfsG7SS5muVp7DsGgwedJL5gRsfUuXIt6AX5h6Ae6PnNREMiB') . '&forum=' . $params->get('disqusSubDomain', 'templazatoturials') . $threadLink . '&include=open';
if ($_content = $fetch->get($url)) {
$body = json_decode($_content->body);
if (isset($body->response)) {
if ($responses = $body->response) {
foreach ($responses as $response) {
if (in_array($response->link, $data)) {
$comments[$_id[$response->link]] = $response->posts;
}
}
}
}
}
}
if ($comments) {
if (is_array($comments)) {
return json_encode($comments);
}
return 0;
}
return 0;
}
}
}
示例15: getMenu
/**
* Returns the application JMenu object.
*
* @param string $name The name of the application/client.
* @param array $options An optional associative array of configuration settings.
*
* @return JMenu|null
*
* @since 3.2
*/
public function getMenu($name = null, $options = array())
{
if (!isset($name)) {
$name = $this->getName();
}
// Inject this application object into the JMenu tree if one isn't already specified
if (!isset($options['app'])) {
$options['app'] = $this;
}
try {
$menu = JMenu::getInstance($name, $options);
} catch (Exception $e) {
return null;
}
return $menu;
}