Zikula_Value_Addons
[ class tree: Zikula_Value_Addons ] [ index: Zikula_Value_Addons ] [ all elements ]

Source for file pnuser.php

Documentation is available at pnuser.php

  1. <?php
  2. /**
  3.  * Zikula Application Framework
  4.  *
  5.  * @copyright (c) 2002, Zikula Development Team
  6.  * @link http://www.zikula.org
  7.  * @version $Id: pnuser.php 24342 2008-06-06 12:03:14Z markwest $
  8.  * @license GNU/GPL - http://www.gnu.org/copyleft/gpl.html
  9.  * @package Zikula_Value_Addons
  10.  * @subpackage Feeds
  11.  */
  12.  
  13. /**
  14.  * the main user function
  15.  * This function is the default function, and is called whenever the module is
  16.  * initiated without defining arguments.  As such it can be used for a number
  17.  * of things, but most commonly it either just shows the module menu and
  18.  * returns or calls whatever the module designer feels should be the default
  19.  * function (often this is the view() function)
  20.  */
  21. function feeds_user_main()
  22. {
  23.     // Security check
  24.     if (!SecurityUtil::checkPermission'Feeds::''::'ACCESS_READ)) {
  25.         return LogUtil::registerPermissionError();
  26.     }
  27.  
  28.     // Create output object
  29.     $pnRender pnRender::getInstance('Feeds');
  30.  
  31.     $enablecategorization pnModGetVar('Feeds''enablecategorization');
  32.  
  33.     if ($enablecategorization{
  34.         if (!($class Loader::loadClass ('CategoryRegistryUtil'))) {
  35.             pn_exit (pnML('_UNABLETOLOADCLASS'array('s' => 'CategoryRegistryUtil')));
  36.         }
  37.         // get the categories registered for the Pages
  38.         $catregistry CategoryRegistryUtil::getRegisteredModuleCategories('Feeds''feeds');
  39.         $properties  array_keys($catregistry);
  40.  
  41.         // Assign some useful vars to customize the main
  42.         $pnRender->assign('properties'$properties);
  43.     }
  44.  
  45.     // Assign the module vars
  46.     $pnRender->assign('enablecategorization'$enablecategorization);
  47.  
  48.     // Return the output that has been generated by this function
  49.     return $pnRender->fetch('feeds_user_main.htm');
  50. }
  51.  
  52. /**
  53.  * view items
  54.  * This is a standard function to provide an overview of all of the items
  55.  * available from the module.
  56.  */
  57. function feeds_user_view()
  58. {
  59.     // Security check
  60.     if (!SecurityUtil::checkPermission'Feeds::''::'ACCESS_OVERVIEW)) {
  61.         return LogUtil::registerPermissionError();
  62.     }
  63.  
  64.     // Get parameters from whatever input we need.
  65.     $startnum = (int)FormUtil::getPassedValue('startnum'isset($args['startnum']$args['startnum'1'GET');
  66.     $prop     = (string)FormUtil::getPassedValue('prop'isset($args['prop']$args['prop'null'GET');
  67.     $cat      = (string)FormUtil::getPassedValue('cat'isset($args['cat']$args['cat'null'GET');
  68.  
  69.     // defaults and input validation
  70.     if (!is_numeric($startnum|| $startnum 0{
  71.         $startnum 1;
  72.     }
  73.  
  74.     // get all module vars for later use
  75.     $modvars pnModGetVar('Feeds');
  76.  
  77.     // check if categorisation is enabled
  78.     if ($modvars['enablecategorization']{
  79.         if (!($class Loader::loadClass('CategoryUtil')) || !($class Loader::loadClass('CategoryRegistryUtil'))) {
  80.             pn_exit (pnML('_UNABLETOLOADCLASS'array('s' => 'CategoryUtil || CategoryRegistryUtil')));
  81.         }
  82.         // get the categories registered for the Pages
  83.         $catregistry CategoryRegistryUtil::getRegisteredModuleCategories('Feeds''feeds');
  84.         $props array_keys($catregistry);
  85.  
  86.         // validate the property
  87.         if (empty($prop|| !in_array($prop$props)) {
  88.             $prop $props[0];
  89.         }
  90.         
  91.         // if the property and the category are specified
  92.         // means that we'll list the feeds that belongs to that category
  93.         if (!empty($cat)) {
  94.             if (!is_numeric($cat)) {
  95.                 $rootCat CategoryUtil::getCategoryByID($catregistry[$prop]);
  96.                 $cat CategoryUtil::getCategoryByPath($rootCat['path'].'/'.$cat);
  97.             else {
  98.                 $cat CategoryUtil::getCategoryByID($cat);
  99.             }
  100.             if (!empty($cat&& isset($cat['path'])) {
  101.                 // include all it's subcategories and build the filter
  102.                 $categories categoryUtil::getCategoriesByPath($cat['path']'''path');
  103.                 $catstofilter array();
  104.                 foreach ($categories as $category{
  105.                     $catstofilter[$category['id'];
  106.                 }
  107.                 $catFilter array($prop => $catstofilter)
  108.             else {
  109.                 return LogUtil::registerError(_NOTAVALIDCATEGORY);
  110.             }
  111.  
  112.         // if nothing or only property is specified
  113.         // means that we'll list the subcategories available on that property
  114.         else {
  115.             $rootCat CategoryUtil::getCategoryByID($catregistry[$prop]);
  116.             $rootCat['path'.= '/'// add this to make the relative paths of the subcategories with ease
  117.             $categories CategoryUtil::getCategoriesByParentID($rootCat['id']);
  118.         }
  119.     }
  120.  
  121.     // Create output object
  122.     $pnRender pnRender::getInstance('Feeds');
  123.  
  124.     // List of subcategories
  125.     if (!isset($catFilter&& $modvars['enablecategorization']{
  126.         //Assign the action to perform
  127.         $pnRender->assign('action''subcatslist');
  128.         // Assign the data to display
  129.         $pnRender->assign('rootCat'$rootCat);
  130.         $pnRender->assign('property'$prop);
  131.         $pnRender->assign('categories'$categories);
  132.  
  133.     // List of Feeds
  134.     // of an specific category if enabledcategorization
  135.     else {
  136.         //Assign the action to perform
  137.         $pnRender->assign('action''feedslist');
  138.  
  139.         if ($modvars['enablecategorization']{
  140.             // Assign the data to display
  141.             $pnRender->assign('category'$cat);
  142.         }
  143.  
  144.         // Get all matching feeds
  145.         $items pnModAPIFunc('Feeds''user''getall',
  146.                               array('startnum' => $startnum,
  147.                                     'numitems' => $modvars['itemsperpage'],
  148.                                     'category' => isset($catFilter$catFilter null,
  149.                                     'catregistry' => isset($catregistry$catregistry null));
  150.  
  151.         if ($items == false{
  152.             LogUtil::registerStatus (_NOITEMSFOUND);
  153.         }
  154.  
  155.         // assign the values for the smarty plugin to produce a pager
  156.         $pnRender->assign('pager'array('numitems'     => pnModAPIFunc('Feeds''user''countitems'array('category' => isset($catFilter$catFilter null)),
  157.                                          'itemsperpage' => $modvars['itemsperpage']));
  158.  
  159.         // assign the items to the template
  160.         $pnRender->assign('items'$items);
  161.  
  162.     }
  163.  
  164.     // assign various useful template variables
  165.     $pnRender->assign('startnum'$startnum);
  166.     $pnRender->assign('lang'pnUserGetLang());
  167.     $pnRender->assign($modvars);
  168.     $pnRender->assign('shorturls'pnConfigGetVar('shorturls'));
  169.     $pnRender->assign('shorturlstype'pnConfigGetVar('shorturlstype'));
  170.  
  171.     // Return the output that has been generated by this function
  172.     return $pnRender->fetch('feeds_user_view.htm');
  173. }
  174.  
  175. /**
  176.  * display item
  177.  * This is a standard function to provide detailed informtion on a single item
  178.  * available from the module.
  179.  */
  180. function feeds_user_display($args)
  181. {
  182.     $fid FormUtil::getPassedValue('fid'isset($args['fid']$args['fid'null'GET');
  183.     $title FormUtil::getPassedValue('title'isset($args['title']$args['title'null'REQUEST');
  184.     $objectid FormUtil::getPassedValue('objectid'isset($args['objectid']$args['objectid'null'GET');
  185.     if (!empty($objectid)) {
  186.         $fid $objectid;
  187.     }
  188.  
  189.     // Create output object
  190.     $pnRender pnRender::getInstance('Feeds');
  191.  
  192.     // Define the cache id
  193.     if (isset($fid&& is_numeric($fid)) {
  194.         $pnRender->cache_id $fid;
  195.     else {
  196.         $pnRender->cache_id $title;
  197.     }
  198.  
  199.     // check out if the contents are cached.
  200.     if ($pnRender->is_cached('feeds_user_display.htm')) {
  201.        return $pnRender->fetch('feeds_user_display.htm');
  202.     }
  203.  
  204.     // Get the feed
  205.     if (isset($fid&& is_numeric($fid)) {
  206.         $item pnModAPIFunc('Feeds''user''get'array('fid' => $fid));
  207.     else {
  208.         $item pnModAPIFunc('Feeds''user''get'array('title' => $title));
  209.     }
  210.  
  211.     if ($item == false{
  212.         return DataUtil::formatForDisplayHTML(_GETFAILED);
  213.     }
  214.  
  215.     // read the feed source
  216.     $feed pnModAPIFunc('Feeds''user''getfeed'array('fid' => $item['fid']));
  217.  
  218.     // Assign the module vars
  219.     $pnRender->assign(pnModGetVar('Feeds'));
  220.  
  221.     // Display details of the item.
  222.     $pnRender->assign('item'$item);
  223.     $pnRender->assign('feed'$feed);
  224.  
  225.     // Return the output that has been generated by this function
  226.     return $pnRender->fetch('feeds_user_display.htm');
  227. }

Documentation generated on Fri, 18 Jul 2008 21:55:16 +0200 by phpDocumentor 1.4.1