Exemple #1
0
 protected function _render($context, &$article, $tpl, $contentType, $fields, $property, $client, $cck, $parent_type)
 {
     $app = JFactory::getApplication();
     $dispatcher = JDispatcher::getInstance();
     $user = JFactory::getUser();
     $params = array('template' => $tpl['folder'], 'file' => 'index.php', 'directory' => $tpl['root']);
     $lang = JFactory::getLanguage();
     $lang->load('com_cck_default', JPATH_SITE);
     JPluginHelper::importPlugin('cck_field');
     JPluginHelper::importPlugin('cck_field_link');
     JPluginHelper::importPlugin('cck_field_restriction');
     $p_sef = isset($this->loaded[$contentType . '_' . $client . '_options']['sef']) ? $this->loaded[$contentType . '_' . $client . '_options']['sef'] : JCck::getConfig_Param('sef', '2');
     $p_title = isset($this->loaded[$contentType . '_' . $client . '_options']['title']) ? $this->loaded[$contentType . '_' . $client . '_options']['title'] : '';
     $p_typo = isset($this->loaded[$contentType . '_' . $client . '_options']['typo']) ? $this->loaded[$contentType . '_' . $client . '_options']['typo'] : 1;
     if ($p_typo) {
         JPluginHelper::importPlugin('cck_field_typo');
     }
     jimport('cck.rendering.document.document');
     $doc = CCK_Document::getInstance('html');
     $positions = array();
     if ($parent_type != '') {
         $w_type = '(b.name = "' . $contentType . '" OR b.name = "' . $parent_type . '")';
     } else {
         $w_type = 'b.name = "' . $contentType . '"';
     }
     if ($client == 'intro') {
         $positions_more = JCckDatabaseCache::loadObjectList('SELECT * FROM #__cck_core_type_position AS a LEFT JOIN #__cck_core_types AS b ON b.id = a.typeid' . ' WHERE ' . $w_type . ' AND a.client ="' . $client . '"', 'position');
         // todo::improve
     } else {
         $positions_more = JCckDatabase::loadObjectList('SELECT * FROM #__cck_core_type_position AS a LEFT JOIN #__cck_core_types AS b ON b.id = a.typeid' . ' WHERE ' . $w_type . ' AND a.client ="' . $client . '"', 'position');
         // todo::improve
     }
     // Fields
     if (count($fields)) {
         JPluginHelper::importPlugin('cck_storage');
         $config = array('author' => 0, 'client' => $client, 'doSEF' => $p_sef, 'doTranslation' => JCck::getConfig_Param('language_jtext', 0), 'doTypo' => $p_typo, 'error' => 0, 'fields' => array(), 'id' => $cck->id, 'isNew' => 0, 'Itemid' => $app->input->getInt('Itemid', 0), 'location' => $cck->storage_location, 'pk' => $article->id, 'pkb' => $cck->pkb, 'storages' => array(), 'store_id' => (int) $cck->store_id, 'type' => $cck->cck, 'type_id' => (int) $cck->type_id, 'type_alias' => $cck->type_alias ? $cck->type_alias : $cck->cck);
         foreach ($fields as $field) {
             $field->typo_target = 'value';
             $fieldName = $field->name;
             $value = '';
             $name = !empty($field->storage_field2) ? $field->storage_field2 : $fieldName;
             //-
             if ($fieldName) {
                 $Pt = $field->storage_table;
                 if ($Pt && !isset($config['storages'][$Pt])) {
                     $config['storages'][$Pt] = '';
                     $dispatcher->trigger('onCCK_Storage_LocationPrepareContent', array(&$field, &$config['storages'][$Pt], $config['pk'], &$config, &$article));
                 }
                 $dispatcher->trigger('onCCK_StoragePrepareContent', array(&$field, &$value, &$config['storages'][$Pt]));
                 if (is_string($value)) {
                     $value = trim($value);
                 }
                 if ($p_title != '' && $p_title == $field->name) {
                     $this->title = $value;
                 }
                 $hasLink = $field->link != '' ? 1 : 0;
                 $dispatcher->trigger('onCCK_FieldPrepareContent', array(&$field, $value, &$config));
                 $target = $field->typo_target;
                 if ($hasLink) {
                     $dispatcher->trigger('onCCK_Field_LinkPrepareContent', array(&$field, &$config));
                     if ($field->link) {
                         JCckPluginLink::g_setHtml($field, $target);
                     }
                 }
                 if (@$field->typo && ($field->{$target} !== '' || $field->typo_label == -2) && $p_typo) {
                     $dispatcher->trigger('onCCK_Field_TypoPrepareContent', array(&$field, $field->typo_target, &$config));
                 } else {
                     $field->typo = '';
                 }
                 $position = $field->position;
                 $positions[$position][] = $fieldName;
                 // Was it the last one?
                 if ($config['error']) {
                     break;
                 }
             }
         }
         // Merge
         if (count($config['fields'])) {
             $fields = array_merge($fields, $config['fields']);
             // Test: a loop may be faster.
             $config['fields'] = NULL;
             unset($config['fields']);
         }
     }
     // BeforeRender
     if (isset($config['process']['beforeRenderContent']) && count($config['process']['beforeRenderContent'])) {
         foreach ($config['process']['beforeRenderContent'] as $process) {
             if ($process->type) {
                 JCck::callFunc_Array('plg' . $process->group . $process->type, 'on' . $process->group . 'BeforeRenderContent', array($process->params, &$fields, &$config['storages'], &$config));
             }
         }
     }
     // Finalize
     $doc->fields =& $fields;
     $infos = array('context' => $context, 'params' => $tpl['params'], 'path' => $tpl['path'], 'root' => JURI::root(true), 'template' => $tpl['folder'], 'theme' => $tpl['home']);
     $doc->finalize('content', $contentType, $client, $positions, $positions_more, $infos, $cck->id);
     $data = $doc->render(false, $params);
     $article->{$property} = str_replace($article->{$property}, $data, $article->{$property});
 }
Exemple #2
0
 protected static function _getOptionsList($options2, $free_sql, $lang_code, $static = false)
 {
     $options = '';
     if ($free_sql == 0) {
         $opt_table = isset($options2['table']) ? ' FROM ' . $options2['table'] : '';
         $opt_name = isset($options2['name']) ? $options2['name'] : '';
         $opt_value = isset($options2['value']) ? $options2['value'] : '';
         $opt_where = @$options2['where'] != '' ? ' WHERE ' . $options2['where'] : '';
         $opt_orderby = @$options2['orderby'] != '' ? ' ORDER BY ' . $options2['orderby'] . ' ' . (@$options2['orderby_direction'] != '' ? $options2['orderby_direction'] : 'ASC') : '';
         // Language Detection
         $opt_value = str_replace('[lang]', $lang_code, $opt_value);
         $opt_name = str_replace('[lang]', $lang_code, $opt_name);
         $opt_where = str_replace('[lang]', $lang_code, $opt_where);
         $opt_orderby = str_replace('[lang]', $lang_code, $opt_orderby);
         if ($opt_name && $opt_table) {
             $query = 'SELECT ' . $opt_name . ',' . $opt_value . $opt_table . $opt_where . $opt_orderby;
             $query = JCckDevHelper::replaceLive($query);
             $lists = $static ? JCckDatabaseCache::loadObjectList($query) : JCckDatabase::loadObjectList($query);
             if (count($lists)) {
                 foreach ($lists as $list) {
                     $options .= $list->{$opt_name} . '=' . $list->{$opt_value} . '||';
                 }
             }
         }
     } else {
         $opt_query = isset($options2['query']) ? $options2['query'] : '';
         // Language Detection
         $opt_query = str_replace('[lang]', $lang_code, $opt_query);
         $opt_query = JCckDevHelper::replaceLive($opt_query);
         $lists = $static ? JCckDatabaseCache::loadObjectList($opt_query) : JCckDatabase::loadObjectList($opt_query);
         if (count($lists)) {
             foreach ($lists as $list) {
                 $options .= @$list->text . '=' . @$list->value . '||';
             }
         }
     }
     return $options;
 }