Inheritance: extends Helper
示例#1
0
 /**
  * @covers FilterHelper
  */
 public function testCompareFilters()
 {
     $filterHelper = new FilterHelper();
     import('lib.pkp.classes.filter.FilterGroup');
     $someGroup = new FilterGroup();
     $someGroup->setInputType('primitive::string');
     $someGroup->setOutputType('primitive::string');
     import('lib.pkp.classes.filter.PersistableFilter');
     $filterA = new PersistableFilter($someGroup);
     $filterBSettings = array('some-key' => 'some-value');
     $filterBSubfilters = array();
     self::assertFalse($filterHelper->compareFilters($filterA, $filterBSettings, $filterBSubfilters));
     import('lib.pkp.classes.filter.FilterSetting');
     $filterA->addSetting(new FilterSetting('some-key', null, null));
     self::assertFalse($filterHelper->compareFilters($filterA, $filterBSettings, $filterBSubfilters));
     $filterA->setData('some-key', 'some-value');
     self::assertTrue($filterHelper->compareFilters($filterA, $filterBSettings, $filterBSubfilters));
     $filterA = new CompositeFilter($someGroup);
     $filterBSettings = array();
     $filterBSubfilter = new CompositeFilter($someGroup);
     $filterBSubfilter->setSeq(1);
     $filterBSubfilters = array($filterBSubfilter);
     self::assertFalse($filterHelper->compareFilters($filterA, $filterBSettings, $filterBSubfilters));
     $filterASubfilter = new OtherCompositeFilter($someGroup);
     $filterA->addFilter($filterASubfilter);
     self::assertFalse($filterHelper->compareFilters($filterA, $filterBSettings, $filterBSubfilters));
     $filterA = new CompositeFilter($someGroup);
     $filterASubfilter = new CompositeFilter($someGroup);
     $filterA->addFilter($filterASubfilter);
     self::assertTrue($filterHelper->compareFilters($filterA, $filterBSettings, $filterBSubfilters));
     $filterBSubfilter->addSetting(new FilterSetting('some-key', null, null));
     $filterASubfilter->addSetting(new FilterSetting('some-key', null, null));
     $filterBSubfilter->setData('some-key', 'some-value');
     self::assertFalse($filterHelper->compareFilters($filterA, $filterBSettings, $filterBSubfilters));
     $filterASubfilter->setData('some-key', 'some-value');
     self::assertTrue($filterHelper->compareFilters($filterA, $filterBSettings, $filterBSubfilters));
 }
示例#2
0
 /**
  * Install the given filter configuration file.
  * @param $filterConfigFile string
  * @return boolean true when successful, otherwise false
  */
 function installFilterConfig($filterConfigFile)
 {
     static $filterHelper = false;
     // Parse the filter configuration.
     $xmlParser = new XMLParser();
     $tree =& $xmlParser->parse($filterConfigFile);
     // Validate the filter configuration.
     if (!$tree) {
         $xmlParser->destroy();
         return false;
     }
     // Get the filter helper.
     if ($filterHelper === false) {
         import('lib.pkp.classes.filter.FilterHelper');
         $filterHelper = new FilterHelper();
     }
     // Are there any filter groups to be installed?
     $filterGroupsNode =& $tree->getChildByName('filterGroups');
     if (is_a($filterGroupsNode, 'XMLNode')) {
         $filterHelper->installFilterGroups($filterGroupsNode);
     }
     // Are there any filters to be installed?
     $filtersNode =& $tree->getChildByName('filters');
     if (is_a($filtersNode, 'XMLNode')) {
         foreach ($filtersNode->getChildren() as $filterNode) {
             /* @var $filterNode XMLNode */
             $filterHelper->configureFilter($filterNode);
         }
     }
     // Get rid of the parser.
     $xmlParser->destroy();
     unset($xmlParser);
     return true;
 }
示例#3
0
 /**
  * @brief lazy way to create the admin index page headers
  *
  * @param array $filterOptions the filters to show
  * @param array $massActions the mass actions to show
  * @access public
  *
  * @return string the markup generated
  */
 public function adminIndexHead($filterOptions = array(), $massActions = null)
 {
     if (!class_exists('FilterHelper')) {
         App::uses('FilterHelper', 'Filter.View/Helper');
     }
     return sprintf('<div class="adminTopBar">%s%s</div><div class="filters">%s</div>', $this->adminPageHead(), $massActions, FilterHelper::form('Post', $filterOptions) . FilterHelper::clear($filterOptions));
 }
示例#4
0
文件: init.php 项目: happyxlq/pd
require_once 'zee/message/Messages.class.php';
require_once 'zee/lang/Language.class.php';
require_once 'zee/lang/LanguageContentValue.class.php';
require_once 'zee/lang/LanguageValue.class.php';
require_once 'zee/lang/LanguageService.class.php';
require_once 'zee/lang/LanguageContentService.class.php';
//==================
// Request
//==================
Request::init($_REQUEST);
//==================
// DB
//==================
Zee::register('DB', new DB());
//==================
// Language
//==================
//==================
// Exec Pre Filters
//==================
FilterHelper::execFilters(FilterHelper::PRE_FILTER);
//==================
// Do Module
//==================
$controller = Dispatch::getController(Request::getModule());
$controller->execute(Request::getAction());
//==================
// Exec Post Filters
//==================
FilterHelper::execFilters(FilterHelper::POST_FILTER);
示例#5
0
 function adminIndexHead($view = array(), $pagintion = array(), $filterOptions = array(), $massActions = null)
 {
     if (empty($view)) {
         $this->errors[] = 'I need the view.';
         return false;
     }
     App::import('Helper', 'FilterHelper');
     $filters = $this->Design->niceBox('filter', FilterHelper::form('Post', $filterOptions) . FilterHelper::clear($filterOptions));
     return $this->Design->niceBox('adminTopBar', $this->adminPageHead($view) . $massActions) . $filters;
 }
示例#6
0
 /**
  * Get filter by name.
  *
  * @param string $name
  *
  * @return callable
  */
 protected function getFilter($name)
 {
     $helper = new FilterHelper($this->filters, $this->filterAutoLoad);
     return $helper->getValidFilter($name);
 }