function loadAssets($params)
 {
     if ($this->_assetsLoaded) {
         return;
     }
     $filterInput = JFilterInput::getInstance();
     $defaultParams = array('loadJQ' => true, 'jqNC' => true, 'theme' => 'ui-lightness');
     $params = JPlantParamsHelper::normalizeParameters($defaultParams, $params, false);
     $params['theme'] = $filterInput->clean($params['theme'], 'CMD');
     $assetsUri = JPlantUriHelper::getRootUri(dirname(__FILE__) . '/../assets');
     $doc = JFactory::getDocument();
     if ($params['loadJQ']) {
         $doc->addScript('https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js');
         if ($params['jqNC']) {
             $doc->addScript($assetsUri . 'js/jquery.noconflict.js');
         }
     }
     $doc->addScript($assetsUri . 'js/jquery.accordionlight.min.js?ver=' . ACCORDIONPLANTLIGHT_VERSION);
     $doc->addStyleSheet($assetsUri . 'css/' . $params['theme'] . '/styles.css');
     $doc->addStyleSheet($assetsUri . 'css/accordion.css');
     $this->_assetsLoaded = true;
 }
示例#2
0
 static function normalizeParameters($originalParams, $inputParams, $diff = true, $merge = false)
 {
     $outputParams = array();
     if (empty($originalParams) || empty($inputParams)) {
         if (!$diff) {
             $outputParams = $originalParams;
         }
         return $outputParams;
     }
     $filterInput = JFilterInput::getInstance();
     foreach ($originalParams as $key => $val) {
         if (array_key_exists($key, $inputParams)) {
             if (is_array($val)) {
                 $childParams = JPlantParamsHelper::normalizeParameters($val, isset($inputParams[$key]) ? $inputParams[$key] : array(), $diff, $merge);
                 if (count($childParams) != 0) {
                     $outputParams[$key] = $childParams;
                 }
             } else {
                 $inputVal = $filterInput->clean($inputParams[$key], gettype($val));
                 if (!$diff || $inputVal !== $val) {
                     $outputParams[$key] = $inputVal;
                 }
             }
         } else {
             if (!$diff) {
                 $outputParams[$key] = $val;
             }
         }
     }
     if ($merge) {
         $outputParams = array_merge($inputParams, $outputParams);
     }
     return $outputParams;
 }