Пример #1
0
 public function onCCK_Field_LivePrepareForm(&$field, &$value = '', &$config = array())
 {
     if (self::$type != $field->live) {
         return;
     }
     // Init
     $app = JFactory::getApplication();
     $live = '';
     $options = parent::g_getLive($field->live_options);
     // Prepare
     $crypt = $options->get('crypt', '');
     $default = $options->get('default_value', '');
     $ignore_null = $options->get('ignore_null', 0);
     $multiple = $options->get('multiple', 0);
     $return = $options->get('return', 'first');
     if ($multiple) {
         $variables = $options->get('variables', '');
         $variables = explode('||', $variables);
         if (count($variables)) {
             foreach ($variables as $variable) {
                 $request = 'get' . ucfirst($options->get('type', 'string'));
                 $variable = preg_replace('/\\s+/', '', $variable);
                 $result = (string) $app->input->{$request}($variable, '');
                 if ($ignore_null) {
                     $live = $result ? $result : $live;
                     if ($return == 'first' && $live) {
                         break;
                     }
                 } else {
                     $live = $result != '' ? $result : $live;
                     if ($return == 'first' && $live != '') {
                         break;
                     }
                 }
             }
         }
     } else {
         $variable = $options->get('variable', $field->name);
         if ($variable) {
             $filter = $options->get('type', 'string');
             if ($filter == 'array') {
                 $live = $app->input->get($variable, $default, 'array');
             } else {
                 $request = 'get' . ucfirst($filter);
                 $live = (string) $app->input->{$request}($variable, $default);
                 if ($crypt == 'base64') {
                     $live = base64_decode($live);
                 }
             }
         }
     }
     // Set
     $value = $ignore_null && !$live ? '' : (is_array($live) ? $live : (string) $live);
 }
Пример #2
0
 public function onCCK_Field_LivePrepareForm(&$field, &$value = '', &$config = array())
 {
     if (self::$type != $field->live) {
         return;
     }
     // Init
     $live = '';
     $options = parent::g_getLive($field->live_options);
     // Prepare
     $default = $options->get('default_value', '');
     $excluded = $options->get('excluded');
     $property = $options->get('property');
     if ($property) {
         $user = JCck::getUser();
         if ($user->id > 0 && $user->guest == 1) {
             if (!($property == 'ip' || $property == 'session_id')) {
                 $user = new JUser(0);
             }
         }
         if ($property == 'access') {
             $viewlevels = $user->getAuthorisedViewLevels();
             if ($excluded != '') {
                 $excluded = explode(',', $excluded);
                 $viewlevels = array_diff($viewlevels, $excluded);
             }
             if (empty($viewlevels)) {
                 $live = $default;
             } else {
                 $live = implode(',', $viewlevels);
             }
         } elseif (isset($user->{$property})) {
             $live = $user->{$property};
             if (is_array($live)) {
                 if ($excluded != '') {
                     $excluded = explode(',', $excluded);
                     $live = array_diff($live, $excluded);
                 }
                 if (empty($live)) {
                     $live = $default;
                 } else {
                     $live = implode(',', $live);
                 }
             } elseif ($live == '') {
                 $live = $default;
             }
         } else {
             $live = $default;
         }
     }
     // Set
     $value = (string) $live;
 }
Пример #3
0
 public function onCCK_Field_LivePrepareForm(&$field, &$value = '', &$config = array())
 {
     if (self::$type != $field->live) {
         return;
     }
     // Init
     $live = '';
     $options = parent::g_getLive($field->live_options);
     $method = $options->get('uri', 'current');
     // Prepare
     if ($method == 'custom') {
         $parts = $options->get('parts', 'scheme,user,pass,host,port,path,query,fragment');
         $parts = explode(',', $parts);
         $live = JUri::getInstance()->toString($parts);
     } else {
         $live = JUri::$method();
     }
     // Set
     $value = (string) $live;
 }