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


PHP CrowdfundingHelperRoute::getProject方法代码示例

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


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

示例1: CrowdfundingParseRoute

/**
 * Method to parse Route
 *
 * @param array $segments
 *
 * @return array
 */
function CrowdfundingParseRoute($segments)
{
    $total = count($segments);
    $vars = array();
    for ($i = 0; $i < $total; $i++) {
        $segments[$i] = preg_replace('/-/', ':', $segments[$i], 1);
    }
    //Get the active menu item.
    $app = JFactory::getApplication();
    $menu = $app->getMenu();
    $item = $menu->getActive();
    // Count route segments
    $count = count($segments);
    // Standard routing for articles.  If we don't pick up an Itemid then we get the view from the segments
    // the first segment is the view and the last segment is the id of the details, category or payment.
    if (!isset($item)) {
        $vars['view'] = $segments[0];
        $vars['id'] = $segments[$count - 1];
        return $vars;
    }
    // COUNT == 1
    // Category
    if ($count == 1) {
        // We check to see if an alias is given.  If not, we assume it is a project,
        // because categories have always alias.
        // If it is a menu item "Details" that could be one of its specific views - backing, embed,...
        if (false == strpos($segments[0], ':')) {
            switch ($segments[0]) {
                case "backing":
                case "embed":
                    $id = $item->query["id"];
                    $project = CrowdfundingHelperRoute::getProject($id);
                    $vars['view'] = $segments[0];
                    $vars['catid'] = (int) $project["catid"];
                    $vars['id'] = (int) $project["id"];
                    break;
                default:
                    $vars['view'] = 'details';
                    $vars['id'] = (int) $segments[0];
                    break;
            }
            return $vars;
        }
        list($id, $alias) = explode(':', $segments[0], 2);
        $alias = str_replace(":", "-", $alias);
        // first we check if it is a category
        $category = JCategories::getInstance('Crowdfunding')->get($id);
        if ($category and strcmp($category->alias, $alias) == 0) {
            $vars['view'] = 'category';
            $vars['id'] = $id;
            return $vars;
        } else {
            $project = CrowdfundingHelperRoute::getProject($id);
            if (!empty($project)) {
                if ($project["alias"] == $alias) {
                    $vars['view'] = 'details';
                    $vars['catid'] = (int) $project["catid"];
                    $vars['id'] = (int) $id;
                    return $vars;
                }
            }
        }
    }
    // COUNT >= 2
    if ($count >= 2) {
        $view = $segments[$count - 1];
        switch ($view) {
            case "backing":
                $itemId = (int) $segments[$count - 2];
                // Get catid from menu item
                if (!empty($item->query["id"])) {
                    $catId = (int) $item->query["id"];
                } else {
                    $catId = (int) $segments[$count - 3];
                }
                $vars['view'] = 'backing';
                $vars['id'] = (int) $itemId;
                $vars['catid'] = (int) $catId;
                break;
            case "embed":
                // Backing without reward
                $itemId = (int) $segments[$count - 2];
                // Get catid from menu item
                if (!empty($item->query["id"])) {
                    $catId = (int) $item->query["id"];
                } else {
                    $catId = (int) $segments[$count - 3];
                }
                $vars['view'] = 'embed';
                $vars['id'] = (int) $itemId;
                $vars['catid'] = (int) $catId;
                break;
            case "updates":
//.........这里部分代码省略.........
开发者ID:pashakiz,项目名称:crowdf,代码行数:101,代码来源:router.php

示例2: CrowdfundingParseRoute

/**
 * Method to parse Route
 *
 * @param array $segments
 *
 * @return array
 */
function CrowdfundingParseRoute($segments)
{
    $total = count($segments);
    $vars = array();
    for ($i = 0; $i < $total; $i++) {
        $segments[$i] = str_replace('-', ':', $segments[$i]);
    }
    //Get the active menu item.
    $app = JFactory::getApplication();
    $menu = $app->getMenu();
    $item = $menu->getActive();
    // Count route segments
    $count = count($segments);
    // Standard routing for articles.  If we don't pick up an Itemid then we get the view from the segments
    // the first segment is the view and the last segment is the id of the details, category or payment.
    if (null === $item) {
        $vars['view'] = $segments[0];
        $vars['id'] = $segments[$count - 1];
        return $vars;
    }
    // COUNT == 1
    // Category or backing layout.
    if ($count === 1) {
        // We check to see if an alias is given.  If not, we assume it is a project,
        // because categories have always alias.
        // If it is a menu item "Details" that could be one of its specific views - backing, embed,...
        if (false === strpos($segments[0], ':')) {
            switch ($segments[0]) {
                case 'backing':
                case 'friendmail':
                case 'embed':
                    $id = $item->query['id'];
                    $project = CrowdfundingHelperRoute::getProject($id);
                    $vars['view'] = $segments[0];
                    $vars['catid'] = (int) $project['catid'];
                    $vars['id'] = (int) $project['id'];
                    break;
                default:
                    $vars['view'] = 'details';
                    $vars['id'] = (int) $segments[0];
                    break;
            }
            return $vars;
        }
        $vars = CrowdfundingHelperRoute::prepareCategoryOrDetails($segments);
        if (0 !== count($vars)) {
            return $vars;
        }
    }
    // COUNT >= 2
    if ($count >= 2) {
        $view = $segments[$count - 1];
        switch ($view) {
            case 'embed':
            case 'backing':
                $itemId = (int) $segments[$count - 2];
                // Get catid from menu item
                if (!empty($item->query['id'])) {
                    $catId = (int) $item->query['id'];
                } else {
                    $catId = (int) $segments[$count - 3];
                }
                $vars['view'] = $view;
                $vars['id'] = (int) $itemId;
                $vars['catid'] = (int) $catId;
                break;
            case 'updates':
                // Screens of details - 'updates', 'comments', 'funders'
            // Screens of details - 'updates', 'comments', 'funders'
            case 'comments':
            case 'funders':
                $itemId = (int) $segments[$count - 2];
                // Get catid from menu item
                if (!empty($item->query['id'])) {
                    $catId = (int) $item->query['id'];
                } else {
                    $catId = (int) $segments[$count - 3];
                }
                $vars['view'] = 'details';
                $vars['id'] = (int) $itemId;
                $vars['catid'] = (int) $catId;
                // Get screen
                $screen = $segments[$count - 1];
                $allowedScreens = array('updates', 'comments', 'funders');
                if (in_array($screen, $allowedScreens, true)) {
                    $vars['screen'] = $screen;
                }
                break;
            default:
                // Subcategory or details page.
                // if there was more than one segment, then we can determine where the URL points to
                // because the first segment will have the target category id prepended to it.  If the
                // last segment has a number prepended, it is details, otherwise, it is a category.
//.........这里部分代码省略.........
开发者ID:ITPrism,项目名称:CrowdfundingDistribution,代码行数:101,代码来源:router.php


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