当前位置: 首页>>代码示例>>PHP>>正文


PHP JApplication::getInstance方法代码示例

本文整理汇总了PHP中JApplication::getInstance方法的典型用法代码示例。如果您正苦于以下问题:PHP JApplication::getInstance方法的具体用法?PHP JApplication::getInstance怎么用?PHP JApplication::getInstance使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在JApplication的用法示例。


在下文中一共展示了JApplication::getInstance方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: loadMultilangData

function loadMultilangData($prepareElementCallback)
{
    $languages = JLanguageHelper::getLanguages();
    $app = JApplication::getInstance('site');
    $menu = $app->getMenu();
    $config = JFactory::getConfig();
    $sef = $config->get('sef', 0);
    $sefRewrite = $config->get('sef_rewrite', 0);
    $defaultLangCode = JFactory::getLanguage()->getDefault();
    $websites = array();
    //$websites['*'] = $menu->getDefault('*'); // TODO add?
    $languageFilterEnabled = JPluginHelper::isEnabled('system', 'languagefilter');
    if (!$languageFilterEnabled || $sef != '1') {
        // TODO check also if sef is enabled
        return $websites;
    }
    $oldLanguageFilterValue = $app->setLanguageFilter(true);
    // necessary that $menu->getDefault() works
    foreach ($languages as $language) {
        $langCode = $language->lang_code;
        $default = $menu->getDefault($langCode);
        if ($default && $default->language == $langCode) {
            $websites[$langCode] = $prepareElementCallback($language, $langCode, $defaultLangCode, $sefRewrite);
        }
    }
    $app->setLanguageFilter($oldLanguageFilterValue);
    return $websites;
}
开发者ID:webguerilla,项目名称:joomla-linkchecker,代码行数:28,代码来源:shared_functions.php

示例2: display

 /**
  * @return mixed
  */
 public function display()
 {
     $menu = JFactory::getApplication()->getMenu();
     $lang = JFactory::getLanguage();
     $category = $this->getModel()->getItem();
     $category->layout = end(explode(':', $category->layout));
     $this->setLayout($category->layout ? $category->layout : 'default');
     header('X-Category-ID: ' . $category->id);
     $doc =& JFactory::getDocument();
     if ($category->title) {
         $doc->setTitle($category->title);
     }
     if ($category->meta_keywords) {
         $doc->setMetaData('Keywords', $category->meta_keywords);
     }
     if ($category->meta_description) {
         $doc->setMetaData('Description', $category->meta_description);
     }
     if ($menu->getActive() == $menu->getDefault($lang->getTag()) || !$menu->getActive()) {
         $pathway = JFactory::getApplication()->getPathway();
         if (!JApplication::getInstance('site')->getMenu()->getItems('link', 'index.php?option=com_makundi&view=category&id=' . $category->id, true)) {
             foreach ($category->getAncestors(array('level' => 1)) as $ancestor) {
                 $item = JApplication::getInstance('site')->getMenu()->getItems('link', 'index.php?option=com_makundi&view=category&id=' . $ancestor->id, true);
                 if ($item) {
                     $i = 0;
                     foreach (explode('/', $item->route) as $part) {
                         $pathway->addItem(ucfirst($part), 'index.php?Itemid=' . $item->tree[$i]);
                         $i++;
                     }
                 } else {
                     if (!JSite::getMenu()->getActive()->id) {
                         $pathway->addItem($ancestor->title, JRoute::_('index.php?option=com_makundi&view=category&parent_slug_path=' . $ancestor->parent_slug_path . '&slug=' . $ancestor->slug));
                     }
                 }
             }
             $pathway->addItem($category->title);
         }
     }
     $descendants = array();
     $descendants[] = $category->id;
     $config = new KConfig();
     if ($params = $menu->getActive()->params) {
         $config->append($params->toArray());
     }
     if ($config->show_subcategories) {
         $descendants = array_merge($descendants, $category->getDescendants(array('level' => 1))->getColumn('id'));
     }
     $config->append(array('show_description' => 1, 'show_articles' => 1));
     // TODO: Set the limit default limit inside $category so we can make this more flexable.
     $limit = $this->getModel()->getState()->limit;
     if (!$limit) {
         $this->getModel()->getState()->limit = $config->limit;
     } else {
         $this->getModel()->getState()->limit = 4;
     }
     $this->assign('params', $config);
     $this->assign('parent', $this->getModel()->getItem()->getParent());
     $this->assign('descendants', $descendants);
     return parent::display();
 }
开发者ID:kedweber,项目名称:com_makundi,代码行数:63,代码来源:html.php

示例3: addMenuItems

/**
 * Method to add menu's item.
 *
 * @return boolean true on success false on failure.
 */
function addMenuItems()
{
    $db = JFactory::getDBO();
    // Get new component id.
    $component = JComponentHelper::getComponent('com_community');
    $component_id = 0;
    if (is_object($component) && isset($component->id)) {
        $component_id = $component->id;
    }
    $column_name = JOOMLA_MENU_NAME;
    $column_cid = JOOMLA_MENU_COMPONENT_ID;
    // Get the default menu type
    // 2 Joomla bugs occur in /Administrator mode
    // Bug 1: JFactory::getApplication('site') failed. It always return id = 'administrator'.
    // Bug 2: JMenu::getDefault('*') failed. JAdministrator::getLanguageFilter() doesn't exist.
    // If these 2 bugs are fixed, we can call the following syntax:
    // $defaultMenuType	= JFactory::getApplication('sites')->getMenu()->getDefault()->menutype;
    jimport('joomla.application.application');
    $defaultMenuType = JApplication::getInstance('site')->getMenu()->getDefault('workaround_joomla_bug')->menutype;
    $query = 'SELECT ' . $db->nameQuote('ordering') . ' ' . 'FROM ' . $db->nameQuote('#__menu') . ' ' . 'ORDER BY ' . $db->nameQuote('ordering') . ' DESC LIMIT 1';
    $db->setQuery($query);
    $order = $db->loadResult() + 1;
    // Update the existing menu items.
    $row = JTable::getInstance('menu', 'JTable');
    $row->menutype = $defaultMenuType;
    $row->{$column_name} = 'JomSocial';
    $row->alias = 'JomSocial';
    $row->link = 'index.php?option=com_community&view=frontpage';
    $row->type = 'component';
    $row->published = '1';
    $row->{$column_cid} = $component_id;
    $row->ordering = $order;
    $row->id = null;
    //new item
    if (!JOOMLA_LEGACY_VERSION) {
        $row->language = '*';
    }
    $row->check();
    if (!$row->store()) {
        // $row->getError()
        return false;
    }
    //for version 1.6 only. The parent_id is not updated correctly via JTable
    if (!JOOMLA_LEGACY_VERSION) {
        $query = 'UPDATE ' . $db->nameQuote('#__menu') . ' SET `parent_id` = ' . $db->quote(1) . ', `level` = ' . $db->quote(1) . ' WHERE `id` = ' . $db->quote($row->id);
        $db->setQuery($query);
        $db->query();
        if ($db->getErrorNum()) {
            return false;
        }
    }
    if (!addDefaultToolbarMenus()) {
        return false;
    }
    // update memu items with component id
    if (!updateMenuItems()) {
        return false;
    }
    return true;
}
开发者ID:Simarpreet05,项目名称:joomla,代码行数:65,代码来源:defaultItems.php

示例4: getItems

 /**
  *
  */
 public static function getItems($option = '')
 {
     static $items;
     if (empty($option)) {
         $com = DSC::getApp();
         $option = 'com_' . $com->getName();
     }
     $app = JApplication::getInstance('site');
     $menus = $app->getMenu();
     if (empty($menus)) {
         return array();
     }
     if (empty($items)) {
         $items = array();
     }
     if (empty($items[$option])) {
         $component = JComponentHelper::getComponent($option);
         foreach ($menus->getItems('component', $option) as $item) {
             if (!is_object($item)) {
                 continue;
             }
             if ($item->component_id == $component->id || $item->componentid == $component->id || !empty($item->query['option']) && $item->query['option'] == $option) {
                 $items[$option][] = $item;
             }
         }
     }
     if (empty($items[$option])) {
         return array();
     }
     return $items[$option];
 }
开发者ID:joomlacorner,项目名称:citruscart,代码行数:34,代码来源:route.php

示例5: document

 /**
  * Create a route for a document
  *
  * @param array|KObjectConfig $config
  * @param bool                $fqr
  * @param bool                $escape
  * @return string Routed URL
  */
 public function document($config = array(), $fqr = false, $escape = true)
 {
     $config = new KObjectConfigJson($config);
     $config->append(array('admin_link' => JFactory::getApplication()->isAdmin()));
     // Return a generic link for administrator
     if ($config->admin_link) {
         return $this->entity($config);
     }
     unset($config->admin_link);
     $document = $config->entity;
     $query = array('option' => 'com_docman', 'view' => 'document', 'alias' => $document->alias);
     if ($document->category_slug) {
         $query['category_slug'] = $document->category_slug;
     }
     if (!$config->Itemid) {
         $menu = JApplication::getInstance('site')->getMenu()->getActive();
         if ($menu && $menu->query['view'] === 'userlist') {
             $query['Itemid'] = $document->itemid;
         }
     }
     $config->append($query);
     $route = $this->_getRoute($config, $fqr, $escape);
     $query = $route->getQuery(true);
     if (isset($query['view']) && $query['view'] === 'download') {
         unset($query['format']);
         $route->setQuery($query);
     }
     return $route;
 }
开发者ID:kosmosby,项目名称:medicine-prof,代码行数:37,代码来源:route.php

示例6: display

 public function display()
 {
     $portal = $this->getModel()->getItem();
     header('X-Portal-ID: ' . $portal->id);
     $doc =& JFactory::getDocument();
     if ($portal->title) {
         $doc->setTitle($portal->title);
     }
     if ($portal->meta_keywords) {
         $doc->setMetaData('Keywords', $portal->meta_keywords);
     }
     if ($portal->meta_description) {
         $doc->setMetaData('Description', $portal->meta_description);
     }
     //TODO: Check if itemId
     $pathway = JFactory::getApplication()->getPathway();
     if (!JApplication::getInstance('site')->getMenu()->getItems('link', 'index.php?option=com_portals&view=portal&id=' . $portal->id, true)) {
         $category = $this->getService('com://site/portals.model.categories')->id($portal->portals_category_id)->getItem();
         if ($category->id) {
             $item = JApplication::getInstance('site')->getMenu()->getItems('link', 'index.php?option=com_portals&view=category&id=' . $category->id, true);
             if ($item) {
                 $i = 0;
                 foreach (explode('/', $item->route) as $part) {
                     $pathway->addItem(ucfirst($part), 'index.php?Itemid=' . $item->tree[$i]);
                     $i++;
                 }
             }
             $pathway->addItem($portal->title);
         }
     }
     return parent::display();
 }
开发者ID:kedweber,项目名称:com_portals,代码行数:32,代码来源:html.php

示例7: _getPages

    /**
     * Returns an array of component pages.
     *
     * Each page includes a children property that contains a list of all categories reachable by the page
     *
     * @return array
     */
    protected function _getPages()
    {
        if (!self::$_pages)
        {
            $component	= JComponentHelper::getComponent('com_'.$this->getIdentifier()->package);
            $items		= JApplication::getInstance('site')->getMenu()->getItems('component_id', $component->id);

            foreach ($items as $item)
            {
                $item = clone $item;
                $item->children = array();

                self::$_pages[$item->id] = $item;
            }

            foreach (self::$_pages as &$item)
            {
                // Assign categories and their children to pages
                if ($item->query['view'] === 'list') {
                    $item->children = $this->_getCategoryChildren($item->query['slug']);
                }
            }
            unset($item);
        }

        return self::$_pages;
    }
开发者ID:kosmosby,项目名称:medicine-prof,代码行数:34,代码来源:pages.php

示例8: display

 public function display($tpl = null)
 {
     Model::addIncludePath(JPATH_BASE . DIRECTORY_SEPARATOR . 'components' . DIRECTORY_SEPARATOR . 'com_menus' . DIRECTORY_SEPARATOR . 'models');
     $model = Model::getInstance('Menus', 'MenusModel');
     $this->menutypes = $model->getItems();
     $this->menu = JApplication::getInstance('site')->getMenu();
     parent::display($tpl);
 }
开发者ID:ursbraem,项目名称:staticcontent,代码行数:8,代码来源:view.html.php

示例9: __construct

 function __construct($txt = null, $path = null)
 {
     $this->loadExtension();
     if (!$this->_id) {
         $jApp =& JApplication::getInstance();
         $jApp->redirect('index2.php', JText::_('ERR_XMLLOADFAIL'), 'error');
     }
     self::$_instance = $this;
 }
开发者ID:WebuddhaInc,项目名称:Joomla-com-wbAdvert,代码行数:9,代码来源:wbAdvert_config.class.php

示例10: getApplication

 /**
  * Get a application object
  *
  * Returns the global {@link JApplication} object, only creating it
  * if it doesn't already exist.
  *
  * @param mixed	 $id     A client identifier or name.
  * @param array	 $config An optional associative array of configuration settings.
  * @param string $prefix application prefix
  *
  * @return JApplication	object
  */
 public static function getApplication($id = null, $config = array(), $prefix = 'J')
 {
     if (!self::$application) {
         jimport('joomla.application.application');
         if (!$id) {
             JError::raiseError(500, 'Application Instantiation Error');
         }
         self::$application = JApplication::getInstance($id, $config, $prefix);
     }
     return self::$application;
 }
开发者ID:Joomla-on-NoSQL,项目名称:LaMojo,代码行数:23,代码来源:factory.php

示例11: guestCanAccess

 /**
  * Check if guest can access menu item
  * 
  * @param object $menuItem
  * @return boolean TRUE if guest can access
  */
 public static function guestCanAccess($menuItem)
 {
     $app = JApplication::getInstance('site');
     $menu = $app->getMenu('site')->getItem($menuItem->id);
     $isInternal = JURI::isInternal($menuItem->flink);
     $canAccess = is_object($menu) ? in_array((int) $menu->access, JFactory::getUser(0)->getAuthorisedViewLevels()) : false;
     if ($isInternal && $canAccess || ($menuItem->type = 'url')) {
         return true;
     } else {
         return false;
     }
 }
开发者ID:ursbraem,项目名称:staticcontent,代码行数:18,代码来源:menu.php

示例12: array

 /**
  * Get a application object
  *
  * Returns a reference to the global {@link JApplication} object, only creating it
  * if it doesn't already exist.
  *
  * @access public
  * @param	mixed	$id 		A client identifier or name.
  * @param	array	$config 	An optional associative array of configuration settings.
  * @return object JApplication
  */
 public static function &getApplication($id = null, $config = array(), $prefix = 'J')
 {
     static $instance;
     if (!is_object($instance)) {
         jimport('joomla.application.application');
         if (!$id) {
             JError::raiseError(500, 'Application Instantiation Error');
         }
         $instance = JApplication::getInstance($id, $config, $prefix);
     }
     return $instance;
 }
开发者ID:stonyyi,项目名称:anahita,代码行数:23,代码来源:factory.php

示例13: __construct

 /**
  * Class constructor.
  *
  * @param   array  $options  The class options.
  *
  * @since   1.5
  */
 public function __construct($options = array())
 {
     $this->_pathway = array();
     $app = JApplication::getInstance('site');
     $menu = $app->getMenu();
     $lang = JFactory::getLanguage();
     if ($item = $menu->getActive()) {
         $menus = $menu->getMenu();
         // Look for the home menu
         if (JLanguageMultilang::isEnabled()) {
             $home = $menu->getDefault($lang->getTag());
         } else {
             $home = $menu->getDefault();
         }
         if (is_object($home) && $item->id != $home->id) {
             foreach ($item->tree as $menupath) {
                 $url = '';
                 $link = $menu->getItem($menupath);
                 switch ($link->type) {
                     case 'separator':
                     case 'heading':
                         $url = null;
                         break;
                     case 'url':
                         if (strpos($link->link, 'index.php?') === 0 && strpos($link->link, 'Itemid=') === false) {
                             // If this is an internal Joomla link, ensure the Itemid is set.
                             $url = $link->link . '&Itemid=' . $link->id;
                         } else {
                             $url = $link->link;
                         }
                         break;
                     case 'alias':
                         // If this is an alias use the item id stored in the parameters to make the link.
                         $url = 'index.php?Itemid=' . $link->params->get('aliasoptions');
                         break;
                     default:
                         $router = $app::getRouter();
                         if ($router->getMode() == JROUTER_MODE_SEF) {
                             $url = 'index.php?Itemid=' . $link->id;
                         } else {
                             $url .= $link->link . '&Itemid=' . $link->id;
                         }
                         break;
                 }
                 $this->addItem($menus[$menupath]->title, $url);
             }
         }
     }
 }
开发者ID:educakanchay,项目名称:kanchay,代码行数:56,代码来源:site.php

示例14: repeat_emails_get_article

function repeat_emails_get_article($contentTemplate)
{
    require_once COM_FABRIK_BASE . 'components' . DS . 'com_content' . DS . 'helpers' . DS . 'query.php';
    JModel::addIncludePath(COM_FABRIK_BASE . 'components' . DS . 'com_content' . DS . 'models');
    $articleModel = JModel::getInstance('Article', 'ContentModel');
    // $$$ rob when sending from admin we need to alter $mainframe to be the
    //front end application otherwise com_content errors out trying to create
    //the article
    global $mainframe;
    $origMainframe = $mainframe;
    jimport('joomla.application.application');
    $mainframe = JApplication::getInstance('site', array(), 'J');
    $res = $articleModel->getItem($contentTemplate);
    $mainframe = $origMainframe;
    return $res->introtext . " " . $res->fulltext;
}
开发者ID:romuland,项目名称:khparts,代码行数:16,代码来源:repeat_emails.php

示例15: _getPages

    /**
     * Returns an array of component pages.
     *
     * Each page includes a children property that contains a list of all categories reachable by the page
     *
     * @return array
     */
    protected function _getPages()
    {
        if (!self::$_pages)
        {
            $component = JComponentHelper::getComponent('com_' . $this->getIdentifier()->package);

            $attributes = array('component_id');
            $values     = array($component->id);

            if ($this->getState()->language !== null)
            {
                $attributes[] = 'language';

                if ($this->getState()->language === 'all') {
                    $values[] = JFactory::getDbo()->setQuery('SELECT DISTINCT language FROM #__menu')->loadColumn();
                } else {
                    $values[] = $this->getState()->language;
                }
            }

            $items = JApplication::getInstance('site')->getMenu()->getItems($attributes, $values);

            foreach ($items as $item)
            {
                $item           = clone $item;
                $item->children = array();

                if ($item->language === '*') {
                    $item->language = '';
                }

                self::$_pages[$item->id] = $item;
            }

            foreach (self::$_pages as &$item)
            {
                // Assign categories and their children to pages
                if (isset($item->query['view']) && $item->query['view'] === 'list' && isset($item->query['slug'])) {
                    $item->children = $this->_getCategoryChildren($item->query['slug']);
                }
            }
            unset($item);
        }

        return self::$_pages;
    }
开发者ID:kosmosby,项目名称:medicine-prof,代码行数:53,代码来源:pages.php


注:本文中的JApplication::getInstance方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。