コード例 #1
0
 function plgSystemCCK(&$subject, $config)
 {
     $app = JFactory::getApplication();
     if ($app->isAdmin()) {
         JFactory::getLanguage()->load('lib_cck', JPATH_SITE);
         if (file_exists(JPATH_SITE . '/plugins/cck_storage_location/joomla_user_note/joomla_user_note.php')) {
             $this->content_objects['joomla_user_note'] = 1;
         }
     }
     jimport('joomla.filesystem.file');
     jimport('cck.base.cck');
     // deprecated
     // Content
     jimport('cck.content.article');
     //jimport( 'cck.content.category' );
     jimport('cck.content.content');
     jimport('cck.content.user');
     // Development
     jimport('cck.development.database');
     // deprecated
     $this->multisite = JCck::_setMultisite();
     if ($this->multisite === true) {
         $this->site = null;
         $this->site_cfg = new JRegistry();
         if (JCck::isSite()) {
             $this->site = JCck::getSite();
             $this->site_cfg->loadString($this->site->configuration);
             if ($app->isSite() && $this->site) {
                 // --- Redirect to Homepage
                 $homepage = $this->site_cfg->get('homepage', 0);
                 if ($homepage > 0) {
                     $current = JUri::current(true);
                     $len = strlen($current);
                     if ($current[$len - 1] == '/') {
                         $current = substr($current, 0, -1);
                     }
                     $current = str_replace(array('http://', 'https://'), '', $current);
                     if ($current == $this->site->host) {
                         $redirect_url = JRoute::_('index.php?Itemid=' . $homepage);
                         if ($redirect_url != JUri::root(true) . '/') {
                             JFactory::getApplication()->redirect($redirect_url);
                         }
                     }
                 }
                 // ---
                 $tag = $this->site_cfg->get('language');
                 if ($tag) {
                     JFactory::getConfig()->set('language', $tag);
                     JFactory::getLanguage()->setLanguage($tag);
                 }
             }
         }
     }
     parent::__construct($subject, $config);
 }
コード例 #2
0
 public static function setDynamicVars(&$vars, $format, $parameters, $fields)
 {
     $app = JFactory::getApplication();
     if (is_array($format)) {
         $format_params = $format['options'];
         $format = $format['format'];
         $format = str_replace(array('nvp_array', 'nvp_object'), array('kvp_array', 'kvp_object'), $format);
     }
     $format = str_replace('nvp', 'kvp', $format);
     if ($format == 'array' || $format == 'kvp_array' || $format == 'kvp_object') {
         if (!is_array($vars)) {
             $vars = array();
         }
     } elseif ($format == 'object') {
         if (!is_object($vars)) {
             $vars = new stdClass();
         }
     } else {
         if (!is_string($vars)) {
             $vars = '';
         }
     }
     if ($app->isSite() && JCck::isSite()) {
         $site = JCck::getSite();
         $site_options = is_object($site) ? new JRegistry($site->options) : new JRegistry();
     } else {
         $site_options = new JRegistry();
     }
     foreach ($parameters as $k => $p) {
         $v = '';
         if ($p['type'] == 'site') {
             $v = $site_options->get($p['value']);
         } elseif ($p['type'] == 'field') {
             if (isset($fields[$p['value']])) {
                 $v = $fields[$p['value']]->value;
             }
         } else {
             $v = $p['value'];
         }
         if ($format == 'array') {
             $vars[$k] = $v;
         } elseif ($format == 'object') {
             $vars->{$k} = $v;
         } elseif ($format == 'kvp_array') {
             $vars[] = array($format_params['key'] => $k, $format_params['value'] => $v);
         } elseif ($format == 'kvp_object') {
             $vars[] = (object) array($format_params['key'] => $k, $format_params['value'] => $v);
         } elseif ($format == 'kvp_string') {
             $vars .= $k . '=' . urlencode($v) . '&';
         } else {
             $vars = $v;
         }
     }
     if ($format == 'kvp_string' && $vars != '') {
         $vars = substr($vars, 0, -1);
     }
 }
コード例 #3
0
ファイル: jform_accesslevel.php プロジェクト: hamby/SEBLOD
    public function onCCK_FieldPrepareForm(&$field, $value = '', &$config = array(), $inherit = array(), $return = false)
    {
        if (self::$type != $field->type) {
            return;
        }
        self::$path = parent::g_getPath(self::$type . '/');
        parent::g_onCCK_FieldPrepareForm($field, $config);
        // Init
        if (count($inherit)) {
            $id = isset($inherit['id']) && $inherit['id'] != '' ? $inherit['id'] : $field->name;
            $name = isset($inherit['name']) && $inherit['name'] != '' ? $inherit['name'] : $field->name;
        } else {
            $id = $field->name;
            $name = $field->name;
        }
        $value = $value != '' ? $value : $field->defaultvalue;
        $value = $value != ' ' ? $value : '';
        // Validate
        $validate = '';
        if ($config['doValidation'] > 1) {
            plgCCK_Field_ValidationRequired::onCCK_Field_ValidationPrepareForm($field, $id, $config);
            $validate = count($field->validate) ? ' validate[' . implode(',', $field->validate) . ']' : '';
        }
        // Prepare
        if (JCck::isSite() === true && !$config['pk'] && ($config['client'] == 'admin' || $config['client'] == 'site') && $value != '') {
            $levels = JCck::getSite()->viewlevels;
            $levels = explode(',', $levels);
            sort($levels);
            $value = $levels[0];
        }
        $opt = '';
        if (trim($field->selectlabel)) {
            if ($config['doTranslation']) {
                $field->selectlabel = JText::_('COM_CCK_' . str_replace(' ', '_', trim($field->selectlabel)));
            }
            $opt = '<option value="">' . '- ' . $field->selectlabel . ' -' . '</option>';
        }
        $class = 'inputbox select' . $validate . ($field->css ? ' ' . $field->css : '');
        $xml = '
					<form>
						<field
							type="' . self::$type2 . '"
							name="' . $name . '"
							id="' . $id . '"
							label="' . htmlspecialchars($field->label) . '"
							extension="com_content"
							class="' . $class . '"
						>' . $opt . '</field>
					</form>
				';
        $form = JForm::getInstance($id, $xml);
        $form = $form->getInput($name, '', $value);
        // Set
        if (!$field->variation) {
            $field->form = $form;
            if ($field->script) {
                parent::g_addScriptDeclaration($field->script);
            }
        } else {
            $field->text = JCckDatabase::loadResult('SELECT title FROM #__viewlevels WHERE id = ' . (int) $value);
            parent::g_getDisplayVariation($field, $field->variation, $value, $field->text, $form, $id, $name, '<select', '', '', $config);
        }
        $field->value = $value;
        // Return
        if ($return === true) {
            return $field;
        }
    }