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


PHP Pages::findByCategory方法代码示例

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


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

示例1: smarty_function_select_page

/**
 * Render select page control
 * 
 * Parameters:
 * 
 * - project - Parent project
 * - value - ID of selected page
 *
 * @param array $params
 * @param Smarty $smarty
 * @return string
 */
function smarty_function_select_page($params, &$smarty)
{
    $project = array_var($params, 'project', null, true);
    if (!instance_of($project, 'Project')) {
        return new InvalidParamError('project', $project, '$project is expected to be an instance of Project class', true);
    }
    // if
    $user = array_var($params, 'user');
    if (!instance_of($user, 'User')) {
        return new InvalidParamError('user', $user, '$user is exepcted to be an instance of User class', true);
    }
    // if
    $options = array();
    $value = array_var($params, 'value', null, true);
    $skip = array_var($params, 'skip');
    $categories = Categories::findByModuleSection($project, PAGES_MODULE, 'pages');
    if (is_foreachable($categories)) {
        foreach ($categories as $category) {
            $option_attributes = $category->getId() == $value ? array('selected' => true) : null;
            $options[] = option_tag($category->getName(), $category->getId(), $option_attributes);
            $pages = Pages::findByCategory($category, STATE_VISIBLE, $user->getVisibility());
            if (is_foreachable($pages)) {
                foreach ($pages as $page) {
                    smarty_function_select_page_populate_options($page, $value, $user, $skip, $options, '- ');
                }
                // foreach
            }
            // if
        }
        // foreach
    }
    // if
    return select_box($options, $params);
}
开发者ID:NaszvadiG,项目名称:activecollab_loc,代码行数:46,代码来源:function.select_page.php

示例2: index

 /**
  * List of pages
  *
  */
 function index()
 {
     $per_page = 20;
     $page = (int) $this->request->get('page');
     if ($page < 1) {
         $page = 1;
     }
     // if
     $pagination = null;
     if ($this->active_category->isLoaded()) {
         $this->addBreadcrumb($this->active_category->getName());
         $pages = Pages::findByCategory($this->active_category, STATE_VISIBLE, $this->logged_user->getVisibility());
     } else {
         $this->addBreadcrumb(lang('Recently Modified'));
         list($pages, $pagination) = Pages::paginateByProject($this->active_project, $page, $per_page, STATE_VISIBLE, $this->logged_user->getVisibility());
     }
     // if
     $this->smarty->assign(array('pages' => $pages, 'pagination' => $pagination, 'categories' => Categories::findByModuleSection($this->active_project, PAGES_MODULE, 'pages'), 'pagination_url' => assemble_url('mobile_access_view_pages', array('project_id' => $this->active_project->getId())), 'page_back_url' => assemble_url('mobile_access_view_project', array('project_id' => $this->active_project->getId()))));
 }
开发者ID:NaszvadiG,项目名称:activecollab_loc,代码行数:23,代码来源:MobileAccessProjectPagesController.class.php

示例3: reorder

 /**
  * Reorder pages
  * 
  * @param void
  * @return null
  */
 function reorder()
 {
     $this->skip_layout = $this->request->isAsyncCall();
     if (!$this->active_category->isLoaded()) {
         $this->httpError(HTTP_ERR_BAD_REQUEST);
     }
     // if
     $ordered_pages = $this->request->post('ordered_pages');
     $layout_pages = Pages::findByCategory($this->active_category, STATE_VISIBLE, $this->logged_user->getVisibility());
     js_assign('is_async_call', $this->request->isAsyncCall());
     $this->smarty->assign(array('pages' => $layout_pages, 'opened' => implode(',', $opened), 'reorder_pages_url' => assemble_url('project_pages_reorder', array('project_id' => $this->active_project->getId(), 'category_id' => $this->active_category->getId()))));
     if ($this->request->isSubmitted()) {
         if (is_foreachable($ordered_pages)) {
             $sorted_pages = array();
             $positions = array();
             foreach ($ordered_pages as $ordered_page_id => $ordered_page_parent_id) {
                 $ordered_page_parent_id = $ordered_page_parent_id ? $ordered_page_parent_id : $this->active_category->getId();
                 $position = array_var($positions, $ordered_page_parent_id, 1);
                 $sorted_pages[$ordered_page_id] = array('position' => $position, 'parent_id' => $ordered_page_parent_id);
                 $position++;
                 $positions[$ordered_page_parent_id] = $position;
             }
             // if
             $pages = Pages::findByIds(array_keys($ordered_pages), STATE_VISIBLE, $this->logged_user->getVisibility());
             if (is_foreachable($pages)) {
                 foreach ($pages as $page) {
                     if (isset($sorted_pages[$page->getId()])) {
                         $page->setPosition(array_var($sorted_pages[$page->getId()], 'position'));
                         $parent_id = array_var($sorted_pages[$page->getId()], 'parent_id');
                         if ($parent_id) {
                             $page->setParentId($parent_id);
                         }
                         // if
                         $page->save();
                     }
                     // if
                 }
                 // foreach
             }
             // if
         }
         // if
         if ($this->request->isAsyncCall()) {
             $per_page = 30;
             $page = (int) $this->request->get('page');
             if ($page < 1) {
                 $page = 1;
             }
             // if
             if ($this->active_category->isLoaded()) {
                 $this->setTemplate(array('module' => PAGES_MODULE, 'controller' => 'pages', 'template' => 'category'));
                 $this->smarty->assign(array('pages' => Pages::findByCategory($this->active_category, STATE_VISIBLE, $this->logged_user->getVisibility()), 'categories' => Categories::findByModuleSection($this->active_project, PAGES_MODULE, 'pages'), 'can_manage_categories' => $this->logged_user->isProjectLeader($this->active_project) || $this->logged_user->isProjectManager()));
             }
             // if
         }
         // if
     }
     // if submitted
 }
开发者ID:NaszvadiG,项目名称:activecollab_loc,代码行数:65,代码来源:PagesController.class.php


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