예제 #1
0
 public function onCCK_FieldPrepareContent(&$field, $value = '', &$config = array())
 {
     if (self::$type != $field->type) {
         return;
     }
     parent::g_onCCK_FieldPrepareContent($field, $config);
     $html = '';
     if ($value || ($config['client'] == 'list' || $config['client'] == 'item')) {
         $location = isset($config['location']) && $config['location'] ? $config['location'] : 'joomla_article';
         $properties = array('context');
         $properties = JCck::callFunc('plgCCK_Storage_Location' . $location, 'getStaticProperties', $properties);
         /* temporary fix for content categories */
         if ($properties['context'] == 'com_categories.category') {
             $properties['context'] = 'com_content.category';
             // todo: dynamic context per extension (#__categories)
         }
         /* temporary fix for content categories */
         if (is_object($value) && isset($value->tags)) {
             $value = $value->tags;
         }
         $tags = new JHelperTags();
         $tags->getItemTags($properties['context'], $config['pk']);
         $tagLayout = new JLayoutFile('joomla.content.tags');
         $html = $tagLayout->render($tags->itemTags);
     }
     // Set
     $field->value = $value;
     $field->html = $html;
 }
예제 #2
0
 public static function getPermalink($types = 'canonical', $object = 'joomla_article')
 {
     $lang_code = JFactory::getLanguage()->getTag();
     $permalink = '';
     $root = substr(JUri::root(), 0, -1);
     if (!is_array($types)) {
         $types = array(0 => $types);
     }
     if (count($types)) {
         foreach ($types as $type) {
             if ($permalink != '') {
                 break;
             }
             if ($type == 'canonical') {
                 if (isset(JFactory::getApplication()->cck_canonical_url)) {
                     $permalink = $root . JFactory::getApplication()->cck_canonical_url;
                 }
             } elseif ($type == 'current') {
                 $properties = array('routes');
                 require_once JPATH_SITE . '/plugins/cck_storage_location/' . $object . '/' . $object . '.php';
                 $properties = JCck::callFunc('plgCCK_Storage_Location' . $object, 'getStaticProperties', $properties);
                 if (isset($properties['routes'][$lang_code]) && $properties['routes'][$lang_code] != '') {
                     $permalink = $root . JRoute::_($properties['routes'][$lang_code]);
                 }
             }
         }
     }
     return $permalink;
 }
예제 #3
0
 public function cancel($key = 'config')
 {
     JSession::checkToken() or jexit(JText::_('JINVALID_TOKEN'));
     $app = JFactory::getApplication();
     $config = $app->input->post->get($key, array(), 'array');
     $id = (int) $config['id'];
     if ($id > 0) {
         $core = JCckDatabase::loadObject('SELECT pk, storage_location as location FROM #__cck_core WHERE id = ' . (int) $id);
         if ($core->location != '') {
             require_once JPATH_SITE . '/plugins/cck_storage_location/' . $core->location . '/' . $core->location . '.php';
             JCck::callFunc('plgCCK_Storage_Location' . $core->location, 'checkIn', $core->pk);
         }
     }
     $this->setRedirect($this->_getReturnPage());
 }
예제 #4
0
 public function load($identifier, $data = true)
 {
     if (is_array($identifier)) {
         $core = JCckDatabase::loadObject('SELECT cck, pk, storage_location as location FROM #__cck_core WHERE storage_location = "' . (string) $identifier[0] . '" AND pk = ' . (int) $identifier[1]);
     } else {
         $core = JCckDatabase::loadObject('SELECT cck, pk, storage_location as location FROM #__cck_core WHERE id = ' . (int) $identifier);
     }
     if (is_file(JPATH_SITE . '/plugins/cck_storage_location/' . $core->location . '/' . $core->location . '.php')) {
         require_once JPATH_SITE . '/plugins/cck_storage_location/' . $core->location . '/' . $core->location . '.php';
         $properties = array('table', 'key');
         $properties = JCck::callFunc('plgCCK_Storage_Location' . $core->location, 'getStaticProperties', $properties);
         $this->_table = $properties['table'];
     }
     if (!$this->_table) {
         return;
     }
     if ($data === true) {
         $this->_properties = JCckDatabase::loadObject('SELECT a.*, b.* FROM ' . $this->_table . ' AS a' . ' LEFT JOIN #__cck_store_form_' . $core->cck . ' AS b ON b.id = a.' . $properties['key'] . ' WHERE a.' . $properties['key'] . ' = ' . (int) $core->pk);
     } elseif (is_array($data)) {
         if (isset($data[$this->_table])) {
             $select = implode(',', $data[$this->_table]);
             unset($data[$this->_table]);
         } else {
             $select = '*';
         }
         $b = 'a';
         $i = 98;
         foreach ($data as $k => $v) {
             $a = chr($i);
             $select .= ', ' . $a . '.' . implode(', ' . $a . '.', $v);
             $join .= ' LEFT JOIN ' . $k . ' AS ' . $a . ' ON ' . $a . '.id = ' . $b . '.' . $properties['key'];
             $b = $a;
             $i++;
         }
         $query = 'SELECT a.' . $select . ' FROM ' . $this->_table . ' AS a' . $join . ' WHERE a.' . $properties['key'] . ' = ' . (int) $core->pk;
         $this->_properties = JCckDatabase::loadObject($query);
     }
 }
예제 #5
0
 public static function getForm($field, $value, &$config = array('doTranslation' => 1, 'doValidation' => 1, 'client' => 'site', 'pk' => 0), $override = array())
 {
     if (!is_object($field)) {
         $field = JCckDatabase::loadObject('SELECT a.* FROM #__cck_core_fields AS a WHERE a.name = "' . $field . '"');
         //#
         if (!$field) {
             return;
         }
     }
     $field->required_alert = '';
     $field->validation_options = '';
     $field->variation = '';
     $field->variation_override = '';
     $field->access = '';
     $field->restriction = '';
     $field->restriction_options = '';
     $field->computation = '';
     $field->computation_options = '';
     $field->conditional = '';
     $field->conditional_options = '';
     $field->markup = '';
     $field->markup_class = '';
     if (count($override)) {
         foreach ($override as $k => $v) {
             $field->{$k} = $v;
         }
     }
     $dispatcher = JDispatcher::getInstance();
     $dispatcher->trigger('onCCK_FieldPrepareForm', array(&$field, $value, &$config));
     return JCck::callFunc('plgCCK_Field' . $field->type, 'onCCK_FieldRenderForm', $field);
 }
예제 #6
0
파일: edit.php 프로젝트: hamby/SEBLOD
        }
        $field = JCckDev::get($fieldname, '', $config);
        if (!is_object($field)) {
            continue;
        }
        if (isset($fieldnames[$field->name])) {
            continue;
        }
        $id = str_replace(array('json[options][', ']'), '', $field->storage_field);
        $value = isset($this->item->options[$id]) ? $this->item->options[$id] : '';
        $class = 'inputbox text' . ($field->css ? ' ' . $field->css : '');
        $maxlen = $field->maxlength > 0 ? ' maxlength="' . $field->maxlength . '"' : '';
        $attr = 'class="' . $class . '" size="' . $field->size . '"' . $maxlen . ($field->attributes ? ' ' . $field->attributes : '');
        $picker = '';
        $type = $field->type == 'password' ? $field->type : 'text';
        if (JCck::callFunc('plgCCK_Field' . $field->type, 'isFriendly')) {
            $picker = '<span id="storage_field_pick_' . $field->name . '" name="' . $field->name . '" class="value-picker">&laquo;</span>';
        }
        $fieldnames[$field->name] = '';
        $hasOpts = true;
        echo '<li><label>' . $field->label . '</label>' . '<input type="' . $type . '" id="json_options_' . $field->name . '" name="' . $field->storage_field . '" value="' . $value . '" ' . $attr . '>' . $picker . '</li>';
    }
    ?>
        </ul>
        <?php 
}
if (!$hasOpts) {
    ?>
            <p class="legend-desc"><?php 
    echo JText::_('COM_CCK_SITE_OPTIONS_DESC');
    ?>
예제 #7
0
파일: cck.php 프로젝트: densem-2013/exikom
 protected function _prepare($context, &$article, &$params, $page = 0)
 {
     $property = 'text';
     preg_match('#::cck::(.*)::/cck::#U', $article->{$property}, $matches);
     if (!@$matches[1]) {
         return;
     }
     $join = ' LEFT JOIN #__cck_core_folders AS f ON f.id = b.folder';
     $join_select = ', f.app as folder_app';
     $query = 'SELECT a.id, a.pk, a.pkb, a.cck, a.storage_location, a.store_id, b.id as type_id, b.alias as type_alias, b.indexed, b.parent, b.stylesheets,' . ' b.options_content, b.options_intro, c.template as content_template, c.params as content_params, d.template as intro_template, d.params as intro_params' . $join_select . ' FROM #__cck_core AS a' . ' LEFT JOIN #__cck_core_types AS b ON b.name = a.cck' . ' LEFT JOIN #__template_styles AS c ON c.id = b.template_content' . ' LEFT JOIN #__template_styles AS d ON d.id = b.template_intro' . $join . ' WHERE a.id = "' . (string) $matches[1] . '"';
     $cck = JCckDatabase::loadObject($query);
     $contentType = (string) $cck->cck;
     $parent_type = (string) $cck->parent;
     $article->id = (int) $cck->pk;
     if (!$contentType) {
         return;
     }
     JPluginHelper::importPlugin('cck_storage_location');
     if ($context == 'text') {
         $client = 'intro';
     } elseif ($context == 'com_finder.indexer') {
         if ($cck->indexed == 'none') {
             $article->{$property} = '';
             return;
         }
         $client = empty($cck->indexed) ? 'intro' : $cck->indexed;
     } else {
         if ($cck->storage_location != '') {
             $properties = array('contexts');
             $properties = JCck::callFunc('plgCCK_Storage_Location' . $cck->storage_location, 'getStaticProperties', $properties);
             $client = in_array($context, $properties['contexts']) ? 'content' : 'intro';
         } else {
             $client = 'intro';
         }
     }
     // Fields
     $app = JFactory::getApplication();
     $fields = array();
     $lang = JFactory::getLanguage();
     $user = JFactory::getUser();
     $access = implode(',', $user->getAuthorisedViewLevels());
     if ($client == 'intro' && $this->cache) {
         $query = 'SELECT cc.*, c.label as label2, c.variation, c.link, c.link_options, c.markup, c.markup_class, c.typo, c.typo_label, c.typo_options, c.access, c.restriction, c.restriction_options, c.position' . ' FROM #__cck_core_type_field AS c' . ' LEFT JOIN #__cck_core_types AS sc ON sc.id = c.typeid' . ' LEFT JOIN #__cck_core_fields AS cc ON cc.id = c.fieldid' . ' WHERE sc.name = "' . $contentType . '" AND sc.published = 1 AND c.client = "' . $client . '" AND c.access IN (' . $access . ')' . ' ORDER BY c.ordering ASC';
         $fields = JCckDatabaseCache::loadObjectList($query, 'name');
         //#
         if (!count($fields) && $client == 'intro') {
             $client = 'content';
             $query = 'SELECT cc.*, c.label as label2, c.variation, c.link, c.link_options, c.markup, c.markup_class, c.typo, c.typo_label, c.typo_options, c.access, c.restriction, c.restriction_options, c.position' . ' FROM #__cck_core_type_field AS c' . ' LEFT JOIN #__cck_core_types AS sc ON sc.id = c.typeid' . ' LEFT JOIN #__cck_core_fields AS cc ON cc.id = c.fieldid' . ' WHERE sc.name = "' . $contentType . '" AND sc.published = 1 AND c.client = "' . $client . '" AND c.access IN (' . $access . ')' . ' ORDER BY c.ordering ASC';
             $fields = JCckDatabaseCache::loadObjectList($query, 'name');
             //#
         }
     } else {
         if ($parent_type != '') {
             $w_type = '(sc.name = "' . $contentType . '" OR sc.name = "' . $parent_type . '")';
         } else {
             $w_type = 'sc.name = "' . $contentType . '"';
         }
         $query = 'SELECT cc.*, c.label as label2, c.variation, c.link, c.link_options, c.markup, c.markup_class, c.typo, c.typo_label, c.typo_options, c.access, c.restriction, c.restriction_options, c.position' . ' FROM #__cck_core_type_field AS c' . ' LEFT JOIN #__cck_core_types AS sc ON sc.id = c.typeid' . ' LEFT JOIN #__cck_core_fields AS cc ON cc.id = c.fieldid' . ' WHERE ' . $w_type . ' AND sc.published = 1 AND c.client = "' . $client . '" AND c.access IN (' . $access . ')' . ' ORDER BY';
         if ($parent_type != '') {
             $query .= ' c.typeid ASC,';
         }
         $query .= ' c.ordering ASC';
         $fields = JCckDatabase::loadObjectList($query, 'name');
         //#
         if (!count($fields) && $client == 'intro') {
             $client = 'content';
             $query = 'SELECT cc.*, c.label as label2, c.variation, c.link, c.link_options, c.markup, c.markup_class, c.typo, c.typo_label, c.typo_options, c.access, c.restriction, c.restriction_options, c.position' . ' FROM #__cck_core_type_field AS c' . ' LEFT JOIN #__cck_core_types AS sc ON sc.id = c.typeid' . ' LEFT JOIN #__cck_core_fields AS cc ON cc.id = c.fieldid' . ' WHERE ' . $w_type . ' AND sc.published = 1 AND c.client = "' . $client . '" AND c.access IN (' . $access . ')' . ' ORDER BY';
             if ($parent_type != '') {
                 $query .= ' c.typeid ASC,';
             }
             $query .= ' c.ordering ASC';
             $fields = JCckDatabase::loadObjectList($query, 'name');
             //#
         }
     }
     if (!isset($this->loaded[$contentType . '_' . $client . '_options'])) {
         $lang->load('pkg_app_cck_' . $cck->folder_app, JPATH_SITE, null, false, false);
         $registry = new JRegistry();
         $registry->loadString($cck->{'options_' . $client});
         $this->loaded[$contentType . '_' . $client . '_options'] = $registry->toArray();
         if (isset($this->loaded[$contentType . '_' . $client . '_options']['title'])) {
             if ($this->loaded[$contentType . '_' . $client . '_options']['title'] != '' && $this->loaded[$contentType . '_' . $client . '_options']['title'][0] == '{') {
                 $titles = json_decode($this->loaded[$contentType . '_' . $client . '_options']['title']);
                 $lang_tag = JFactory::getLanguage()->getTag();
                 $this->loaded[$contentType . '_' . $client . '_options']['title'] = isset($titles->{$lang_tag}) ? $titles->{$lang_tag} : '';
             }
         }
         if (isset($this->loaded[$contentType . '_' . $client . '_options']['sef'])) {
             if ($this->loaded[$contentType . '_' . $client . '_options']['sef'] == '') {
                 $this->loaded[$contentType . '_' . $client . '_options']['sef'] = JCck::getConfig_Param('sef', '2');
             }
         }
     }
     // Template
     $tpl['home'] = $app->getTemplate();
     $tpl['folder'] = $cck->{$client . '_template'};
     $tpl['params'] = json_decode($cck->{$client . '_params'}, true);
     $tpl['params']['rendering_css_core'] = $cck->stylesheets;
     if (file_exists(JPATH_SITE . '/templates/' . $tpl['home'] . '/html/tpl_' . $tpl['folder'])) {
         $tpl['folder'] = 'tpl_' . $tpl['folder'];
         $tpl['root'] = JPATH_SITE . '/templates/' . $tpl['home'] . '/html';
     } else {
         $tpl['root'] = JPATH_SITE . '/templates';
     }
     $tpl['path'] = $tpl['root'] . '/' . $tpl['folder'];
     if (!$tpl['folder'] || !file_exists($tpl['path'] . '/index.php')) {
         $article->{$property} = str_replace($article->{$property}, 'Template Style does not exist. Open the Content Type & save it again. (Intro + Content views)', $article->{$property});
         return;
     }
     $this->_render($context, $article, $tpl, $contentType, $fields, $property, $client, $cck, $parent_type);
 }
예제 #8
0
파일: export.php 프로젝트: kolydart/SEBLOD
 public static function getCoreTables()
 {
     $core = array();
     $plugins = JCckDatabase::loadColumn('SELECT element FROM #__extensions WHERE folder = "cck_storage_location"');
     if (count($plugins)) {
         foreach ($plugins as $plugin) {
             if ($plugin != '' && is_file(JPATH_SITE . '/plugins/cck_storage_location/' . $plugin . '/' . $plugin . '.php')) {
                 require_once JPATH_SITE . '/plugins/cck_storage_location/' . $plugin . '/' . $plugin . '.php';
                 $properties = array('table');
                 $properties = JCck::callFunc('plgCCK_Storage_Location' . $plugin, 'getStaticProperties', $properties);
                 if ($properties['table']) {
                     $core[$properties['table']] = '';
                 }
             }
         }
     }
     return $core;
 }
예제 #9
0
 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;
         $inherited = true;
     } else {
         $id = $field->name;
         $name = $field->name;
         $inherited = false;
     }
     $value = $value != '' ? htmlspecialchars($value, ENT_COMPAT, 'UTF-8') : @$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
     $app = JFactory::getApplication();
     $options2 = JCckDev::fromJSON($field->options2);
     $user = JFactory::getUser();
     if ($config['pk'] && @$options2['import'] && $field->storage_location) {
         if (!JCckDatabase::loadResult('SELECT pk FROM #__cck_core WHERE pk=' . (int) $config['pk'] . ' AND storage_location="' . (string) $field->storage_location . '"')) {
             $properties = array('custom', 'table');
             $properties = JCck::callFunc('plgCCK_Storage_Location' . $field->storage_location, 'getStaticProperties', $properties);
             $custom = $options2['import'] == 2 ? 'fulltext' : $properties['custom'];
             $value = $config['storages'][$properties['table']]->{$custom};
         }
     }
     if (!$user->id && $this->params->get('guest_access', 0) == 0) {
         $form = '';
     } else {
         $width = @$options2['width'] ? str_replace('px', '', $options2['width']) : '100%';
         $height = @$options2['height'] ? str_replace('px', '', $options2['height']) : '280';
         $asset = $config['asset_id'] > 0 ? $config['asset_id'] : $config['asset'];
         if ($app->input->get('option') == 'com_cck' && $app->input->get('view') == 'form' && $config['client'] == '') {
             $field->bool = 1;
         }
         if ($field->bool) {
             // Default
             $buttons = array('pagebreak', 'readmore');
             $editor = JFactory::getEditor(@$options2['editor'] ? $options2['editor'] : null);
             $form = '<div>' . $editor->display($name, $value, $width, $height, '60', '20', $buttons, $id, $asset) . '</div>';
         } else {
             // Modal Box
             if (trim($field->selectlabel)) {
                 if ($config['doTranslation']) {
                     $field->selectlabel = JText::_('COM_CCK_' . str_replace(' ', '_', trim($field->selectlabel)));
                 }
                 $buttonlabel = $field->selectlabel;
             } else {
                 $buttonlabel = JText::_('COM_CCK_EDITOR');
             }
             $e_type = @$options2['editor'] != '' ? '&type=' . $options2['editor'] : '';
             $link = 'index.php?option=com_cck&task=box.add&tmpl=component&file=plugins/cck_field/' . self::$type . '/tmpl/form.php' . '&id=' . $id . '&name=' . $name . $e_type . '&params=' . urlencode(urlencode($width)) . '||' . $height . '||' . $asset;
             $app = JFactory::getApplication();
             $class = 'wysiwyg_editor_box variation_href';
             $component = $app->input->get('option');
             if ($component == 'com_cck' && $app->input->get('view') != 'form' || $component == 'com_cck_ecommerce' || $component == 'com_cck_toolbox' || $component == 'com_cck_webservices') {
                 // todo: remove later
                 $class .= ' btn';
             }
             $class = 'class="' . $class . '" ';
             $attr = $class;
             $form = '<textarea style="display: none;" id="' . $id . '" name="' . $name . '">' . $value . '</textarea>';
             $form .= '<a href="' . $link . '" ' . $attr . '>' . $buttonlabel . '</a>';
             $field->markup_class .= ' cck_form_wysiwyg_editor_box';
         }
     }
     // Set
     if (!$field->variation) {
         $field->form = $form;
         self::_addScripts($field->bool, array('height' => @$height, 'inherited' => $inherited), $config);
     } else {
         $hidden = '<textarea class="inputbox" style="display: none;" id="' . $id . '" name="' . $name . '" />' . $value . '</textarea>';
         parent::g_getDisplayVariation($field, $field->variation, $value, $value, $form, $id, $name, '<textarea', $hidden, '', $config);
     }
     $field->value = $value;
     // Return
     if ($return === true) {
         return $field;
     }
 }
예제 #10
0
$separator = '';
if ($this->item->title == 'search') {
    $isConvertible = JCck::callFunc('plgCCK_Field' . $field->type, 'isConvertible');
    if ($isConvertible == 1) {
        $toggle = 1;
        if ($field->divider != '') {
            $toggle = 0;
            $separator = $field->divider;
        } else {
            $separator = ',';
        }
    } else {
        $separator = $field->divider != '' ? $field->divider : ',';
    }
} elseif ($this->item->title == 'conditionnal' || $this->item->title == 'dev') {
    $isConvertible = JCck::callFunc('plgCCK_Field' . $field->type, 'isConvertible');
    $separator = ',';
    if ($isConvertible == 1) {
        $toggle = 1;
        if ($field->divider != '') {
            $toggle = 0;
        }
    }
}
// Set
$doc = JFactory::getDocument();
$js = '
			(function($) {
				$.fn.isMultiple = function() {
					if (this.is("select") && this.prop("multiple")) {
						return "select";
예제 #11
0
파일: cck.php 프로젝트: pctechnikch/SEBLOD
 public function onContentSearch($text = '', $phrase = '', $ordering = '', $areas = NULL, $fields = array(), $fields_order = array(), &$config = array(), $current = array(), $options = NULL, $user = NULL)
 {
     if (is_array($areas)) {
         if (!array_intersect($areas, array_keys($this->onContentSearchAreas()))) {
             return array();
         }
     } else {
         return array();
     }
     if (!count($fields)) {
         return array();
     }
     if (!$user) {
         $user = JCck::getUser();
     }
     if (!is_object($options)) {
         $options = new JRegistry();
     }
     $db = JFactory::getDbo();
     $dispatcher = JDispatcher::getInstance();
     $doClean = false;
     $doLimit = false;
     $limit = $options->get('limit');
     $glues = 1;
     $order = '';
     $order_string = '';
     $where = '';
     $w = -1;
     $where2 = array();
     $t = 1;
     $t2 = 1;
     $tables = array('#__cck_core' => array('_' => 't0', 'fields' => array(), 'join' => 1));
     $colums = array();
     if (isset($config['joins'][$current['stage']]) && is_array($config['joins'][$current['stage']])) {
         foreach ($config['joins'][$current['stage']] as $j) {
             if ($j->table) {
                 if (!isset($tables[$j->table])) {
                     $tables[$j->table] = array('_' => 't' . $t++, 'fields' => array(), 'key' => $j->column, 'join' => 2, 'join_key' => $j->column2, 'join_table' => $j->table2);
                 }
             }
         }
         $t2 = count($tables);
     }
     foreach ($fields as $field) {
         if (!$field->state) {
             continue;
         }
         if ($current['stage'] != (int) $field->stage) {
             continue;
         }
         $name2 = $field->match_collection != '' ? '\\\\|[0-9]+\\\\|' . $field->match_collection : '';
         // -
         if ($field->live == 'stage') {
             $live_options = new JRegistry();
             $live_options->loadString($field->live_options);
             $live_value = $live_options->get('value', $field->live_value);
             $live_value = $live_value ? $live_value : 1;
             $value = $current['stages'][$live_value];
             if ($value == '' && $live_options->get('default_value') != '') {
                 $value = (string) $live_options->get('default_value');
             }
         } else {
             $value = $field->value;
         }
         // -
         $Pf = $field->storage_field;
         $Pt = $field->storage_table;
         if (($value !== '' && $field->match_mode != 'none' || ($field->match_mode == 'empty' || $field->match_mode == 'not_empty' || $field->match_mode == 'not_null')) && $field->storage != 'none' || $field->type == 'search_operator' && $field->match_mode != 'none') {
             $glue = '';
             $sql = '';
             if ($field->match_options != '') {
                 $field->match_options = new JRegistry($field->match_options);
             }
             // Glue
             if ($glues == 1) {
                 $glue = $where != '' ? 'AND' : '';
                 $where .= $glue;
                 if ($glue != '') {
                     $where2[++$w] = $glue;
                 }
                 $glue = '';
             }
             // Sql
             if ($field->type == 'search_generic') {
                 if (count($field->children)) {
                     $sql = '(';
                     $k = 0;
                     foreach ($field->children as $child) {
                         if ($k > 0) {
                             $sql .= ' OR ';
                         }
                         $child->match_mode = $field->match_mode;
                         $child->match_options = $field->match_options;
                         $child->match_value = $field->match_value;
                         if ($child->storage && $child->storage != 'none') {
                             $Pf = $child->storage_field;
                             $Pt = $child->storage_table;
                             // -
                             if ($Pt && !isset($tables[$Pt])) {
                                 $tables[$Pt] = array('_' => 't' . $t, 'fields' => array(), 'join' => 1);
                                 $t++;
                             }
                             $tables[$Pt]['location'] = $child->storage_location;
                             // -
                             $name = $child->storage_field2 ? $child->storage_field2 : $child->name;
                             if ($Pt != '') {
                                 $target = $tables[$Pt]['_'] . '.' . $Pf;
                                 $tables[$Pt]['fields'][$Pf] = $Pt == '#__cck_core' ? $value : $name;
                             }
                             if (JCck::callFunc('plgCCK_Field' . $child->type, 'isFriendly')) {
                                 if (isset($fields[$child->name])) {
                                     $value2 = JCck::callFunc_Array('plgCCK_Field' . $child->type, 'getValueFromOptions', array($fields[$child->name], $value, $config));
                                 } else {
                                     $value2 = JCck::callFunc_Array('plgCCK_Field' . $child->type, 'getValueFromOptions', array($child, $value, $config));
                                 }
                             } else {
                                 $value2 = $value;
                             }
                             require_once JPATH_PLUGINS . '/cck_storage/' . $child->storage . '/' . $child->storage . '.php';
                             $sql .= JCck::callFunc_Array('plgCCK_Storage' . $child->storage, 'onCCK_StoragePrepareSearch', array(&$child, $child->match_mode, $value2, $name, $name2, $target, $fields, &$config));
                         }
                         $k++;
                     }
                     $sql .= ')';
                 }
             } elseif ($field->type == 'search_ordering') {
                 $sql = '';
                 array_pop($where2);
                 if (isset($field->children[$value])) {
                     if (!isset($fields_order[$field->children[$value]->name])) {
                         $fields_order[$field->children[$value]->name] = $field->children[$value];
                     }
                 }
             } elseif ($field->type == 'search_operator') {
                 // Glue
                 if ($field->value == '((') {
                     $glues = 0;
                     $sql = '(';
                 } elseif ($field->value == '))') {
                     $glues = 1;
                     $sql = ')';
                 } else {
                     if ($where2[$w] != '(') {
                         $glue = $field->value;
                         $sql = $glue;
                     }
                 }
                 $doClean = true;
             } else {
                 // -
                 if ($Pt && !isset($tables[$Pt])) {
                     $tables[$Pt] = array('_' => 't' . $t, 'fields' => array(), 'join' => 1);
                     $t++;
                 }
                 $tables[$Pt]['location'] = $field->storage_location;
                 // -
                 $name = $field->storage_field2 ? $field->storage_field2 : $field->name;
                 if ($Pt != '') {
                     $target = $tables[$Pt]['_'] . '.' . $Pf;
                     $tables[$Pt]['fields'][$Pf] = $Pt == '#__cck_core' ? $value : $name;
                 }
                 require_once JPATH_PLUGINS . '/cck_storage/' . $field->storage . '/' . $field->storage . '.php';
                 $sql = JCck::callFunc_Array('plgCCK_Storage' . $field->storage, 'onCCK_StoragePrepareSearch', array(&$field, $field->match_mode, $value, $name, $name2, $target, $fields, &$config));
             }
             $where .= $sql;
             $where2[++$w] = $sql;
         } else {
             if (@$glue) {
                 $where2[$w] = '';
             }
             // unset( $fields[$field->name] );
         }
     }
     // Finalize
     $where = implode(' ', $where2);
     if ($doClean !== false) {
         $where = preg_replace('/\\s+/', ' ', $where);
         $where = str_replace('AND (  )', '', $where);
         $where = str_replace('AND ( )', '', $where);
         $where = str_replace('OR OR', 'OR', $where);
         $where = str_replace('( OR', '(', $where);
         $where = str_replace('OR )', ')', $where);
     }
     $where = str_replace('AND ()', '', $where);
     // -------- -------- Order
     if (!$order) {
         $order = ' t1.title ASC';
     }
     $inherit = array('bridge' => '', 'query' => '');
     $query = NULL;
     $results = array();
     self::_setStorage($tables, $config, $inherit);
     JPluginHelper::importPlugin('cck_storage_location');
     if (isset($config['location']) && $config['location']) {
         $dispatcher->trigger('onCCK_Storage_LocationSearch', array($config['location'], $tables, $fields, $fields_order, &$config, &$inherit, &$results));
         $query = $inherit['query'];
     }
     if ($config['doQuery'] !== false) {
         if ($current['stage'] == 0) {
             $query = $db->getQuery(true);
             $query->select('t0.id AS pid,t0.pk AS pk,t0.pkb AS pkb');
             $query->from('`#__cck_core` AS t0');
             self::_buildQuery($dispatcher, $query, $tables, $t, $config, $inherit, $user, $config['doSelect']);
             $query->select('t0.cck AS cck,t0.storage_location AS loc');
             $query->select('tt.id AS type_id,tt.alias AS type_alias');
             $query->join('LEFT', '`#__cck_core_types` AS tt ON tt.name = t0.cck');
             if (isset($config['query_parts']['select']) && $config['query_parts']['select'] != '') {
                 $query->select($config['query_parts']['select']);
             }
             if ($where != '') {
                 $query->where($where);
             }
             if (isset($config['query_parts']['having']) && $config['query_parts']['having'] != '') {
                 $query->having($config['query_parts']['having']);
             }
             $query->group('t0.pk');
             self::_buildQueryOrdering($order, $ordering, $fields_order, $dispatcher, $query, $tables, $t, $config, $current, $inherit, $user);
             if ($doLimit) {
                 $db->setQuery($query, $config['limitstart'], $config['limitend']);
             } else {
                 $db->setQuery($query, 0, $limit > 0 ? $limit : '');
             }
             $results = $db->loadObjectList();
         } else {
             $query = $db->getQuery(true);
             $query->select('t0.pk as pk');
             $query->from('`#__cck_core` AS t0');
             self::_buildQuery($dispatcher, $query, $tables, $t, $config, $inherit, $user, false);
             if ($where != '') {
                 $query->where($where);
             }
             $query->group('t0.pk');
             $db->setQuery($query);
             $results = $db->loadColumn();
         }
     }
     // Debug
     if ($options->get('debug')) {
         echo str_replace(array('SELECT', 'FROM', 'LEFT JOIN', 'WHERE', 'ORDER BY', 'UNION'), array('<br />SELECT', '<br />FROM', '<br />LEFT JOIN', '<br />WHERE', '<br />ORDER BY', '<br />UNION'), (string) $query) . '<br /><br />';
     }
     unset($fields);
     unset($fields_order);
     unset($tables);
     return $results;
 }
예제 #12
0
if ($translate_id > 0) {
    $config['asset_id'] = 0;
    $config['author'] = 0;
    $config['custom'] = '';
    $config['pk'] = 0;
    $config['storages'] = array();
    $id = 0;
    unset($config['base']);
}
if ($config['pk'] && empty($config['id'])) {
    if (!(isset($config['base']) && is_object($config['base']))) {
        $config['base'] = new stdClass();
        $config['base']->location = '';
        $config['base']->table = '';
    }
    if (!(isset($config['base']->location) && $config['base']->location)) {
        $config['base']->location = $type->storage_location;
        if ($config['base']->location) {
            $properties = array('table');
            $properties = JCck::callFunc('plgCCK_Storage_Location' . $config['base']->location, 'getStaticProperties', $properties);
            $config['base']->table = $properties['table'];
        }
    }
    $config['id'] = JCck::callFunc('plgCCK_Storage_Location' . $config['base']->location, 'getId', $config);
} else {
    $config['id'] = @$config['id'] ? $config['id'] : 0;
}
// Versions
if ($app->isAdmin() && JCck::on('3.2') && @$config['base']->location == 'joomla_article') {
    JToolbarHelper::versions('com_content.article', $config['pk']);
}
예제 #13
0
파일: cck.php 프로젝트: codigoaberto/SEBLOD
 public function onContentSearch($text = '', $phrase = '', $ordering = '', $areas = NULL, $fields = array(), $fields_order = array(), &$config = array(), $current = array(), $options = NULL, $user = NULL)
 {
     if (is_array($areas)) {
         if (!array_intersect($areas, array_keys($this->onContentSearchAreas()))) {
             return array();
         }
     } else {
         return array();
     }
     if (!count($fields)) {
         return array();
     }
     if (!$user) {
         $user = JCck::getUser();
     }
     if (!is_object($options)) {
         $options = new JRegistry();
     }
     $app = JFactory::getApplication();
     $db = JFactory::getDbo();
     $dispatcher = JDispatcher::getInstance();
     $doClean = false;
     $doCount = (int) $options->get('count');
     $doLimit = false;
     $limit = (int) $options->get('limit');
     $doLimit = $limit > 0 ? false : true;
     $isLoadingMore = $app->input->get('format') == 'raw' && $app->input->get('infinite') > 0 ? 1 : 0;
     $glues = 1;
     $order = '';
     $order_string = '';
     $where = '';
     $w = -1;
     $where2 = array();
     $t = 1;
     $t2 = 1;
     $tables = array('#__cck_core' => array('_' => 't0', 'fields' => array(), 'join' => 1));
     $colums = array();
     if (isset($config['joins'][$current['stage']]) && is_array($config['joins'][$current['stage']])) {
         foreach ($config['joins'][$current['stage']] as $j) {
             if ($j->table) {
                 if (!isset($tables[$j->table])) {
                     $tables[$j->table] = array('_' => 't' . $t++, 'fields' => array(), 'key' => $j->column, 'join' => 2, 'join_key' => $j->column2, 'join_table' => $j->table2, 'join_and' => @$j->and, 'join_type' => @$j->type, 'join_mode' => @$j->mode, 'join_query' => @$j->query);
                 } elseif (@$j->and != '') {
                     $tables[$j->table . '@' . md5($j->and)] = array('_' => 't' . $t++, 'fields' => array(), 'key' => $j->column, 'join' => 2, 'join_key' => $j->column2, 'join_table' => $j->table2, 'join_and' => $j->and, 'join_type' => @$j->type, 'join_mode' => @$j->mode, 'join_query' => @$j->query);
                 }
             }
         }
         $t2 = count($tables);
     }
     foreach ($fields as $field) {
         if (!$field->state) {
             continue;
         }
         if ($current['stage'] != (int) $field->stage) {
             continue;
         }
         $hasSQL = true;
         $name2 = $field->match_collection != '' ? '\\\\|[0-9]+\\\\|' . $field->match_collection : '';
         // -
         if ($field->live == 'stage') {
             $live_options = new JRegistry();
             $live_options->loadString($field->live_options);
             $live_value = $live_options->get('value', $field->live_value);
             $live_value = $live_value ? $live_value : 1;
             $value = $current['stages'][$live_value];
             if ($value == '' && $live_options->get('default_value') != '') {
                 $value = (string) $live_options->get('default_value');
             }
         } else {
             $value = $field->value;
         }
         // -
         $Pf = $field->storage_field;
         $Pt = $field->storage_table;
         if (($value !== '' && $field->match_mode != 'none' || ($field->match_mode == 'empty' || $field->match_mode == 'not_empty' || $field->match_mode == 'not_null')) && $field->storage != 'none' || $field->type == 'search_operator' && $field->match_mode != 'none') {
             $glue = '';
             $sql = '';
             if ($field->match_options != '') {
                 $field->match_options = new JRegistry($field->match_options);
             }
             // Glue
             if ($glues == 1) {
                 $glue = $where != '' ? 'AND' : '';
                 $where .= $glue;
                 if ($glue != '') {
                     $where2[++$w] = $glue;
                 }
                 $glue = '';
             }
             // Sql
             if ($field->type == 'search_generic') {
                 if (count($field->children)) {
                     $sql = '(';
                     $k = 0;
                     foreach ($field->children as $child) {
                         if ($k > 0) {
                             $sql .= ' OR ';
                         }
                         $child->match_mode = $field->match_mode;
                         $child->match_options = $field->match_options;
                         $child->match_value = $field->match_value;
                         if ($child->storage && $child->storage != 'none') {
                             $Pf = $child->storage_field;
                             $Pt = $child->storage_table;
                             // -
                             if ($Pt && !isset($tables[$Pt])) {
                                 $tables[$Pt] = array('_' => 't' . $t, 'fields' => array(), 'join' => 1);
                                 $t++;
                             }
                             $tables[$Pt]['location'] = $child->storage_location;
                             // -
                             $name = $child->storage_field2 ? $child->storage_field2 : $child->name;
                             if ($Pt != '') {
                                 $target = $tables[$Pt]['_'] . '.' . $Pf;
                                 $tables[$Pt]['fields'][$Pf] = $Pt == '#__cck_core' ? $value : $name;
                             }
                             if (JCck::callFunc('plgCCK_Field' . $child->type, 'isFriendly')) {
                                 if (isset($fields[$child->name])) {
                                     $value2 = JCck::callFunc_Array('plgCCK_Field' . $child->type, 'getValueFromOptions', array($fields[$child->name], $value, $config));
                                 } else {
                                     $value2 = JCck::callFunc_Array('plgCCK_Field' . $child->type, 'getValueFromOptions', array($child, $value, $config));
                                 }
                             } else {
                                 $value2 = $value;
                             }
                             require_once JPATH_PLUGINS . '/cck_storage/' . $child->storage . '/' . $child->storage . '.php';
                             $sql .= JCck::callFunc_Array('plgCCK_Storage' . $child->storage, 'onCCK_StoragePrepareSearch', array(&$child, $child->match_mode, $value2, $name, $name2, $target, $fields, &$config));
                         }
                         $k++;
                     }
                     $sql .= ')';
                 }
             } elseif ($field->type == 'search_ordering') {
                 $sql = '';
                 array_pop($where2);
                 if (isset($field->children[$value])) {
                     if (!isset($fields_order[$field->children[$value]->name])) {
                         $fields_order[$field->children[$value]->name] = $field->children[$value];
                     }
                 }
             } elseif ($field->type == 'search_operator') {
                 // Glue
                 if ($field->value == '((') {
                     $glues = 0;
                     $sql = '(';
                 } elseif ($field->value == '))') {
                     $glues = 1;
                     $sql = ')';
                 } else {
                     if ($where2[$w] != '(') {
                         $glue = $field->value;
                         $sql = $glue;
                     }
                 }
                 $doClean = true;
             } else {
                 // -
                 if ($Pt && !isset($tables[$Pt])) {
                     $tables[$Pt] = array('_' => 't' . $t, 'fields' => array(), 'join' => 1);
                     $t++;
                 }
                 $tables[$Pt]['location'] = $field->storage_location;
                 // -
                 $name = $field->storage_field2 ? $field->storage_field2 : $field->name;
                 if ($Pt != '') {
                     $target = $tables[$Pt]['_'] . '.' . $Pf;
                     $tables[$Pt]['fields'][$Pf] = $Pt == '#__cck_core' ? $value : $name;
                 } else {
                     $target = $Pf;
                     $hasSQL = false;
                 }
                 require_once JPATH_PLUGINS . '/cck_storage/' . $field->storage . '/' . $field->storage . '.php';
                 $sql = JCck::callFunc_Array('plgCCK_Storage' . $field->storage, 'onCCK_StoragePrepareSearch', array(&$field, $field->match_mode, $value, $name, $name2, $target, $fields, &$config));
             }
             if ($hasSQL === false) {
                 if ($glues == 1) {
                     if ($where != '') {
                         $where = substr($where, 0, -3);
                         $where2[$w] = '';
                     }
                 }
                 $config['query_parts']['having'][] = $sql;
                 $sql = '';
             } else {
                 $where .= $sql;
                 $where2[++$w] = $sql;
             }
         } else {
             if (@$glue) {
                 $where2[$w] = '';
             }
             // unset( $fields[$field->name] );
         }
     }
     // Finalize
     $where = implode(' ', $where2);
     if ($doClean !== false) {
         $where = preg_replace('/\\s+/', ' ', $where);
         $where = str_replace('AND (  )', '', $where);
         $where = str_replace('AND ( )', '', $where);
         $where = str_replace('OR OR', 'OR', $where);
         $where = str_replace('( OR', '(', $where);
         $where = str_replace('OR ) )', ')', $where);
         $where = str_replace('OR )', ')', $where);
     }
     $where = str_replace('AND ()', '', $where);
     // -------- -------- Order
     if (!$order) {
         $order = ' t1.title ASC';
     }
     $inherit = array('bridge' => '', 'query' => '');
     $query = NULL;
     $query2 = '';
     $results = array();
     self::_setStorage($tables, $config, $inherit);
     JPluginHelper::importPlugin('cck_storage_location');
     if (isset($config['location']) && $config['location']) {
         $dispatcher->trigger('onCCK_Storage_LocationSearch', array($config['location'], $tables, $fields, $fields_order, &$config, &$inherit, &$results));
         $query = $inherit['query'];
     }
     if ($config['doQuery'] !== false) {
         if ($current['stage'] == 0) {
             if (isset($config['query_variables']) && count($config['query_variables'])) {
                 foreach ($config['query_variables'] as $var) {
                     if ($var != '') {
                         $db->setQuery($var);
                         $db->execute();
                     }
                 }
             }
             $query = $db->getQuery(true);
             $query->select('t0.id AS pid,t0.pk AS pk,t0.pkb AS pkb,t0.parent_id AS parent,t0.author_id AS author');
             $query->from('`#__cck_core` AS t0');
             self::_buildQuery($dispatcher, $query, $tables, $t, $config, $inherit, $user, $config['doSelect']);
             $query->select('t0.cck AS cck,t0.storage_location AS loc');
             if ($config['location'] == 'cck_type') {
                 $query->select($tables['#__cck_core_types']['_'] . '.id AS type_id,' . $tables['#__cck_core_types']['_'] . '.alias AS type_alias');
             } else {
                 $query->select('tt.id AS type_id,tt.alias AS type_alias');
                 $query->join('LEFT', '`#__cck_core_types` AS tt ON tt.name = t0.cck');
             }
             if (isset($config['query_parts']['select'])) {
                 if (is_string($config['query_parts']['select']) && $config['query_parts']['select'] != '' || count($config['query_parts']['select'])) {
                     $query->select($config['query_parts']['select']);
                 }
             }
             if ($where != '') {
                 $query->where($where);
             }
             if (isset($config['query_parts']['having'])) {
                 if (is_string($config['query_parts']['having']) && $config['query_parts']['having'] != '' || count($config['query_parts']['having'])) {
                     $query->having($config['query_parts']['having']);
                 }
             }
             if (isset($config['query_parts']['group']) && count($config['query_parts']['group'])) {
                 $query->group($config['query_parts']['group']);
             }
             self::_buildQueryOrdering($order, $ordering, $fields_order, $dispatcher, $query, $tables, $t, $config, $current, $inherit, $user);
             if ($doLimit && $config['limitstart'] >= 0) {
                 $db->setQuery($query, $config['limitstart'], $config['limitend']);
             } else {
                 $db->setQuery($query, 0, $limit);
             }
             $results = $db->loadObjectList();
             if ($doLimit) {
                 $count = count($results);
                 if ($count < $config['limitend'] && !$config['limitstart'] || $isLoadingMore) {
                     $config['total'] = $count;
                 } else {
                     if ($doCount == 1 && strpos(JUri::getInstance()->toString(), 'task=') === false) {
                         $query2 = 'SELECT COUNT(id) FROM #__cck_core WHERE cck = "' . $tables['#__cck_core']['fields']['cck'] . '"';
                         $config['total'] = JCckDatabaseCache::loadResult($query2);
                     } else {
                         if (JCck::on()) {
                             $query1 = (string) $query;
                             if (strpos($query1, 'HAVING') !== false) {
                                 $query->clear('order')->clear('limit');
                                 $query2 = $db->getQuery(true);
                                 $query2->select('COUNT(*)');
                                 $query2->from('(' . (string) $query . ') AS Count');
                                 $db->setQuery($query2);
                                 $config['total'] = $db->loadResult();
                                 $query2 = (string) $query2;
                             } else {
                                 $query->clear('order')->clear('limit');
                                 $query->clear('select')->select('COUNT(t0.id)');
                                 $db->setQuery($query);
                                 $config['total'] = $db->loadResult();
                                 $query2 = (string) $query;
                             }
                         } else {
                             $query2 = $db->getQuery(true);
                             $query2->select('COUNT(t0.id)');
                             $query2->from('`#__cck_core` AS t0');
                             self::_buildQuery($dispatcher, $query2, $tables, $t, $config, $inherit, $user, $config['doSelect']);
                             if ($where != '') {
                                 $query2->where($where);
                             }
                             $db->setQuery($query2, 0, 0);
                             $config['total'] = $db->loadResult();
                             $query2 = (string) $query2;
                         }
                     }
                 }
             }
         } else {
             $query = $db->getQuery(true);
             $query->select('t0.pk as pk');
             $query->from('`#__cck_core` AS t0');
             self::_buildQuery($dispatcher, $query, $tables, $t, $config, $inherit, $user, false);
             if ($where != '') {
                 $query->where($where);
             }
             $db->setQuery($query);
             $results = $db->loadColumn();
         }
     }
     // Debug
     if ($options->get('debug')) {
         if (!isset($query1)) {
             $query1 = (string) $query;
         }
         if ($query2) {
             $query2 .= '<br />';
         }
         echo str_replace(array('SELECT', 'FROM', 'LEFT JOIN', 'RIGHT JOIN', 'INNER JOIN', 'WHERE', 'AND', 'ORDER BY', 'LIMIT', 'UNION', ') AS Count'), array('<br />SELECT', '<br />FROM', '<br />LEFT JOIN', '<br />RIGHT JOIN', '<br />INNER JOIN', '<br />WHERE', '<br />&nbsp;&nbsp;AND', '<br />ORDER BY', '<br />LIMIT', '<br />UNION', '<br />) AS Count'), $query1 . '<br />' . $query2) . '<br />';
     }
     unset($fields);
     unset($fields_order);
     unset($tables);
     return $results;
 }
예제 #14
0
파일: content.php 프로젝트: hamby/SEBLOD
 protected function _getProperties()
 {
     $values = array('author', 'custom', 'key', 'parent', 'table', 'table_object');
     $properties = array();
     if (is_file(JPATH_SITE . '/plugins/cck_storage_location/' . $this->_object . '/' . $this->_object . '.php')) {
         require_once JPATH_SITE . '/plugins/cck_storage_location/' . $this->_object . '/' . $this->_object . '.php';
         $properties = JCck::callFunc('plgCCK_Storage_Location' . $this->_object, 'getStaticProperties', $values);
     }
     return $properties;
 }
예제 #15
0
 public function onCCK_FieldPrepareContent(&$field, $value = '', &$config = array())
 {
     if (self::$type != $field->type) {
         return;
     }
     parent::g_onCCK_FieldPrepareContent($field, $config);
     $app = JFactory::getApplication();
     $user = JFactory::getUser();
     $access = implode(',', $user->getAuthorisedViewLevels());
     $text = '';
     if ($field->extended && $field->extended != @$config['type']) {
         $options2 = JCckDev::fromJSON($field->options2);
         $name = $field->storage_field2 ? $field->storage_field2 : $field->storage_field;
         $value = array();
         if (@$options2['child_language']) {
             $language = $options2['child_language'] == '-1' ? JFactory::getLanguage()->getTag() : $options2['child_language'];
             $language = ' AND a.language = "' . $language . '"';
         } else {
             $language = '';
         }
         $location = @$options2['child_location'] ? $options2['child_location'] : 'joomla_article';
         $order = @$options2['child_orderby'] ? ' ORDER BY a.' . $options2['child_orderby'] . ' ' . $options2['child_orderby_direction'] : ' ORDER BY a.title ASC';
         $limit = @$options2['child_limit'] ? ' LIMIT ' . $options2['child_limit'] : '';
         switch ($field->bool2) {
             case 2:
                 $properties = array('table', 'access', 'custom', 'status');
                 $properties = JCck::callFunc('plgCCK_Storage_Location' . $location, 'getStaticProperties', $properties);
                 $and = $properties['status'] ? ' AND a.' . $properties['status'] . ' = 1' : '';
                 $and .= $properties['access'] ? ' AND a.' . $properties['access'] . ' IN (' . $access . ')' : '';
                 $items = JCckDatabase::loadObjectList('SELECT a.id as pk, a.' . $properties['custom'] . ' FROM ' . $properties['table'] . ' AS a LEFT JOIN #__cck_store_join_' . $name . ' AS b on b.id = a.id' . ' WHERE b.id2 = ' . (int) $config['pk'] . $and . $language . $order . $limit);
                 if (count($items)) {
                     foreach ($items as $item) {
                         $text .= JHtml::_('content.prepare', $item->{$properties}['custom']);
                         $value[] = $item->pk;
                     }
                 }
                 break;
             case 1:
                 $properties = array('table', 'access', 'status');
                 $properties = JCck::callFunc('plgCCK_Storage_Location' . $location, 'getStaticProperties', $properties);
                 $and = $properties['status'] ? ' AND a.' . $properties['status'] . ' = 1' : '';
                 $and .= $properties['access'] ? ' AND a.' . $properties['access'] . ' IN (' . $access . ')' : '';
                 $items = JCckDatabase::loadObjectList('SELECT a.id as pk, a.title FROM ' . $properties['table'] . ' AS a LEFT JOIN #__cck_store_join_' . $name . ' AS b ON b.id = a.id' . ' WHERE b.id2 = ' . (int) $config['pk'] . $and . $language . $order . $limit);
                 if (count($items)) {
                     foreach ($items as $item) {
                         $text .= ', ' . $item->title;
                         $value[] = $item->pk;
                     }
                 }
                 if ($text) {
                     $text = substr($text, 2);
                 }
                 break;
             default:
                 $options2 = new JRegistry();
                 $options2->loadString($field->options2);
                 $options3_json = $options2->get('child_link_options');
                 $options3 = new JRegistry();
                 $options3->loadString($options3_json);
                 // todo >> href
                 $properties = array('table', 'access', 'status', 'to_route');
                 $properties = JCck::callFunc('plgCCK_Storage_Location' . $location, 'getStaticProperties', $properties);
                 $and = $properties['status'] ? ' AND a.' . $properties['status'] . ' = 1' : '';
                 $and .= $properties['access'] ? ' AND a.' . $properties['access'] . ' IN (' . $access . ')' : '';
                 $items = JCckDatabase::loadObjectList('SELECT ' . $properties['to_route'] . ' FROM ' . $properties['table'] . ' AS a LEFT JOIN #__cck_store_join_' . $name . ' AS b ON b.id = a.id' . ' WHERE b.id2 = ' . (int) $config['pk'] . $and . $language . $order . $limit);
                 if (count($items)) {
                     $sef = JFactory::getConfig()->get('sef') ? $options3->get('sef', 2) : 0;
                     JCck::callFunc_Array('plgCCK_Storage_Location' . $location, 'setRoutes', array(&$items, $sef, $options3->get('itemid', $app->input->getInt('Itemid', 0))));
                     foreach ($items as $item) {
                         $text .= ', ' . '<a href="' . $item->link . '">' . $item->title . '</a>';
                         $value[] = $item->pk;
                     }
                     if ($text) {
                         $text = substr($text, 2);
                     }
                 }
                 break;
         }
         $field->divider = ',';
         $value = implode($field->divider, $value);
     } else {
         if ($value) {
             switch ($field->bool) {
                 case 2:
                     $text = JCckDatabase::loadResult('SELECT a.introtext FROM ' . self::$table . ' AS a WHERE a.id = ' . (int) $value . ' AND a.state = 1 AND a.access IN (' . $access . ')');
                     $text = JHtml::_('content.prepare', $text);
                     break;
                 case 1:
                     $text = JCckDatabase::loadResult('SELECT a.title FROM ' . self::$table . ' AS a WHERE a.id = ' . (int) $value . ' AND a.state = 1 AND a.access IN (' . $access . ')');
                     break;
                 default:
                     require_once JPATH_SITE . '/plugins/cck_storage_location/' . self::$type . '/' . self::$type . '.php';
                     $item = JCckDatabase::loadObject('SELECT a.id, a.title, a.alias, a.catid, a.language FROM ' . self::$table . ' AS a WHERE a.id = ' . (int) $value . ' AND a.state = 1 AND a.access IN (' . $access . ')');
                     if (is_object($item)) {
                         $options2 = new JRegistry();
                         $options2->loadString($field->options2);
                         $options3_json = $options2->get('parent_link_options');
                         $options3 = new JRegistry();
                         $options3->loadString($options3_json);
                         $field2 = (object) array('link' => 'content', 'link_options' => $options3_json, 'id' => $field->name, 'name' => $field->name, 'text' => htmlspecialchars($item->title), 'value' => '');
                         JCckPluginLink::g_setLink($field2, $config);
                         $field2->link = plgCCK_Storage_LocationJoomla_Article::getRoute($item, $options3->get('sef', 2), $options3->get('itemid', $app->input->getInt('Itemid', 0)));
                         JCckPluginLink::g_setHtml($field2, 'text');
                         $text = $field2->html;
                         $field->link = $field2->link;
                         $field->html = $field2->html;
                     }
                     break;
             }
         }
     }
     $field->value = $value;
     $field->text = $text;
     $field->typo_target = 'text';
 }
예제 #16
0
파일: field.php 프로젝트: kolydart/SEBLOD
 public static function g_onCCK_FieldConstruct_SearchSearch(&$field, $style, $data)
 {
     $id = $field->id;
     $name = $field->name;
     $field->params = array();
     // 1
     $column1 = '<input class="thin blue" type="text" name="ffp[' . $name . '][label]" size="22" ' . 'value="' . (@$field->label2 != '' ? htmlspecialchars($field->label2) : htmlspecialchars($field->label)) . '" />' . '<input class="thin blue" type="hidden" name="ffp[' . $name . '][label2]" value="' . $field->label . '" />';
     $column2 = JHtml::_('select.genericlist', $data['variation'], 'ffp[' . $name . '][variation]', 'size="1" class="thin"', 'value', 'text', @$field->variation, $name . '_variation') . '<input type="hidden" id="' . $name . '_variation_override" name="ffp[' . $name . '][variation_override]" ' . 'value="' . (@$field->variation_override != '' ? htmlspecialchars($field->variation_override) : '') . '" />';
     $field->params[] = self::g_getParamsHtml(1, $style, $column1, $column2);
     // 2
     if (!$data['live']) {
         $column1 = '';
         $column2 = '';
     } else {
         if (@$field->live != '') {
             $hide0 = ' hide';
             $hide = ' hide';
             $hide2 = '';
         } else {
             $hide0 = '';
             $hide = ' show';
             $hide2 = ' hide';
         }
         $text = JCck::callFunc('plgCCK_Field' . $field->type, 'isFriendly') ? '&laquo;' : '';
         // ( static::$friendly ) ? '&laquo;' : '';
         $column1 = JHtml::_('select.genericlist', $data['live'], 'ffp[' . $name . '][live]', 'size="1" class="thin c_live_ck"', 'value', 'text', @$field->live, $name . '_live');
         $column2 = '<input class="thin blue c_live0' . $hide0 . '" type="text" id="' . $name . '_live_value" name="ffp[' . $name . '][live_value]" size="22" ' . 'value="' . (@$field->live_value != '' ? htmlspecialchars($field->live_value) : '') . '" />' . '<input type="hidden" id="' . $name . '_live_options" name="ffp[' . $name . '][live_options]" ' . 'value="' . (@$field->live_options != '' ? htmlspecialchars($field->live_options) : '') . '" />' . ' <span class="c_live' . $hide . '" name="' . $name . '">' . $text . '</span>' . ' <span class="text blue c_live2' . $hide2 . '" name="' . $name . '">' . $data['_']['configure'] . '</span>';
     }
     $field->params[] = self::g_getParamsHtml(2, $style, $column1, $column2);
     // 3
     if (!$data['match_mode']) {
         $column1 = '';
     } else {
         $hide = @$field->match_mode != 'none' ? '' : ' hidden';
         $column1 = JHtml::_('select.genericlist', $data['match_mode'], 'ffp[' . $name . '][match_mode]', 'size="1" class="thin c_mat_ck"', 'value', 'text', @$field->match_mode, $name . '_match_mode') . '<input type="hidden" id="' . $name . '_match_value" name="ffp[' . $name . '][match_value]" value="' . @$field->match_value . '" />' . '<input type="hidden" id="' . $name . '_match_collection" name="ffp[' . $name . '][match_collection]" value="' . @$field->match_collection . '" />' . '<input type="hidden" id="' . $name . '_match_options" name="ffp[' . $name . '][match_options]" value="' . htmlspecialchars(@$field->match_options) . '" />' . '<span class="c_mat' . $hide . '" name="' . $name . '">+</span>';
     }
     $column2 = JHtml::_('select.genericlist', $data['stage'], 'ffp[' . $name . '][stage]', 'size="1" class="thin"', 'value', 'text', @$field->stage);
     $field->params[] = self::g_getParamsHtml(3, $style, $column1, $column2);
     // 4
     $hide = @$field->restriction != '' ? '' : ' hidden';
     $column1 = JHtml::_('select.genericlist', $data['access'], 'ffp[' . $name . '][access]', 'size="1" class="thin c_acc_ck"', 'value', 'text', @$field->access ? $field->access : 1);
     $column2 = JHtml::_('select.genericlist', $data['restriction'], 'ffp[' . $name . '][restriction]', 'size="1" class="thin c_res_ck"', 'value', 'text', @$field->restriction, $name . '_restriction') . '<input type="hidden" id="' . $name . '_restriction_options" name="ffp[' . $name . '][restriction_options]" ' . 'value="' . (@$field->restriction_options != '' ? htmlspecialchars($field->restriction_options) : '') . '" />' . ' <span class="c_res' . $hide . '" name="' . $name . '">+</span>';
     $field->params[] = self::g_getParamsHtml(4, $style, $column1, $column2);
     // 5
     $column1 = '<input type="hidden" id="ffp_' . $name . '_conditional" name="ffp[' . $name . '][conditional]" value="' . (@$field->conditional != '' ? $field->conditional : '') . '" />' . '<span class="text blue c_cond" name="' . $name . '">' . (@$field->conditional != '' ? '&lt; ' . $data['_']['edit'] . ' /&gt;' : $data['_']['add']) . '</span>' . '<input type="hidden" id="ffp_' . $name . '_conditional_options" name="ffp[' . $name . '][conditional_options]" ' . 'value="' . (@$field->conditional_options != '' ? htmlspecialchars($field->conditional_options) : '') . '" />';
     $column2 = '';
     $field->params[] = self::g_getParamsHtml(5, $style, $column1, $column2);
     // 6
     if (!$data['markup']) {
         $column1 = '';
     } else {
         $column1 = JHtml::_('select.genericlist', $data['markup'], 'ffp[' . $name . '][markup]', 'size="1" class="thin c_markup_ck"', 'value', 'text', @$field->markup, $name . '_markup');
     }
     $column2 = '<input class="thin blue" type="text" name="ffp[' . $name . '][markup_class]" size="22" ' . 'value="' . (@$field->markup_class != '' ? htmlspecialchars(trim($field->markup_class)) : '') . '" />';
     $field->params[] = self::g_getParamsHtml(6, $style, $column1, $column2);
     // 7
     if (!$data['validation']) {
         $column1 = '';
     } else {
         $required = @$field->required ? $data['_']['required'] : $data['_']['optional'];
         if (@$field->validation) {
             $required .= ' + 1';
         }
         $column1 = '<input type="hidden" id="' . $name . '_required" name="ffp[' . $name . '][required]" value="' . @$field->required . '" />' . '<input type="hidden" id="' . $name . '_required_alert" name="ffp[' . $name . '][required_alert]" value="' . @$field->required_alert . '" />' . '<input type="hidden" id="' . $name . '_validation" name="ffp[' . $name . '][validation]" value="' . @$field->validation . '" />' . '<input type="hidden" id="' . $name . '_validation_options" name="ffp[' . $name . '][validation_options]" ' . 'value="' . (@$field->validation_options != '' ? htmlspecialchars($field->validation_options) : '') . '" />' . ' <span class="text blue c_val" name="' . $name . '">' . $required . '</span>';
     }
     $column2 = '';
     $field->params[] = self::g_getParamsHtml(7, $style, $column1, $column2);
 }
예제 #17
0
 public function parse(&$segments)
 {
     $app = JFactory::getApplication();
     $count = count($segments);
     $menu = $app->getMenu();
     $menuItem = $menu->getActive();
     $vars = array();
     if ($segments[0] == 'form') {
         $menu->setActive($app->input->getInt('Itemid', 0));
         $vars['option'] = 'com_cck';
         $vars['view'] = 'form';
         $vars['layout'] = 'edit';
         $vars['type'] = $segments[1];
     } else {
         $legacy = 0;
         // check later
         if (!($menuItem->query['option'] == 'com_cck' && $menuItem->query['view'] == 'list')) {
             $legacy = 0;
         }
         if (!$legacy) {
             if (isset($menuItem->query['search'])) {
                 $params = JCckDevHelper::getRouteParams($menuItem->query['search']);
                 if ($count == 1 && $params['doSEF'][0] == '4') {
                     if (isset($params['location']) && $params['location'] && is_file(JPATH_SITE . '/plugins/cck_storage_location/' . $params['location'] . '/' . $params['location'] . '.php')) {
                         require_once JPATH_SITE . '/plugins/cck_storage_location/' . $params['location'] . '/' . $params['location'] . '.php';
                         $properties = array('parent_object');
                         $properties = JCck::callFunc('plgCCK_Storage_Location' . $params['location'], 'getStaticProperties', $properties);
                         if ($properties['parent_object'] != '') {
                             $params['doSEF'][0] = '2';
                             $params['location'] = $properties['parent_object'];
                         }
                     }
                 }
             }
             if (isset($params['location']) && $params['location'] && is_file(JPATH_SITE . '/plugins/cck_storage_location/' . $params['location'] . '/' . $params['location'] . '.php')) {
                 require_once JPATH_SITE . '/plugins/cck_storage_location/' . $params['location'] . '/' . $params['location'] . '.php';
                 JCck::callFunc_Array('plgCCK_Storage_Location' . $params['location'], 'parseRoute', array(&$vars, $segments, $count, $params));
             } else {
                 $legacy = 1;
             }
         }
         if ($legacy) {
             if ($count == 2) {
                 $vars['option'] = 'com_content';
                 $vars['view'] = 'article';
                 $vars['catid'] = $segments[0];
                 $vars['id'] = $segments[1];
             } elseif ($count == 1) {
                 $vars['option'] = 'com_content';
                 @(list($id, $alias) = explode(':', $segments[0], 2));
                 $category = JCategories::getInstance('Content')->get($id);
                 if ($category && $category->id == $id && $category->alias == $alias) {
                     $vars['view'] = 'categories';
                 } else {
                     $vars['view'] = 'article';
                 }
                 $vars['id'] = $segments[0];
             }
         }
     }
     return $vars;
 }
예제 #18
0
 public static function onCCK_FieldRenderContent($field, &$config = array())
 {
     if ($field->typo) {
         return $field->typo;
     } else {
         $doc = JFactory::getDocument();
         $doc->addStyleSheet(self::$path . 'assets/css/' . self::$type . '.css');
         $count = count($field->value);
         $html = '';
         if ($count) {
             $i = 0;
             foreach ($field->value as $group) {
                 $row = '';
                 $isRow = false;
                 foreach ($group as $elem) {
                     if ($elem->display) {
                         $value = JCck::callFunc('plgCCK_Field' . $elem->type, 'onCCK_FieldRenderContent', $elem);
                         if ($value != '') {
                             if ($elem->markup == 'none') {
                                 $row .= $elem->label . $value;
                             } else {
                                 $row .= '<div id="' . $field->name . '_' . $i . '_' . $elem->name . '" class="cck_' . $elem->type . '">';
                                 if ($elem->label != '') {
                                     $row .= '<label class="cck_label_' . $elem->type . '">' . $elem->label . '</label>';
                                 }
                                 $row .= $value . '</div>';
                             }
                         }
                         $isRow = true;
                     }
                 }
                 if ($isRow) {
                     if ($field->markup == 'none') {
                         $html .= $row;
                     } else {
                         $html .= '<div id="' . $field->name . '_' . $i . '" class="gxi"><div>' . $row . '</div></div>';
                     }
                 }
                 $i++;
             }
             if ($html && $field->markup != 'none') {
                 $html = '<div id="' . $field->name . '" class="gx">' . $html . '</div>';
             }
         }
         return $html;
     }
 }
예제 #19
0
파일: field_x.php 프로젝트: hamby/SEBLOD
 public static function onCCK_FieldRenderContent($field, &$config = array())
 {
     if ($field->typo) {
         return $field->typo;
     }
     $html = '';
     if (count($field->value)) {
         $html .= '<ul class="cck-fl">';
         foreach ($field->value as $elem) {
             $html .= '<li>' . JCck::callFunc('plgCCK_Field' . $elem->type, 'onCCK_FieldRenderContent', $elem) . '</li>';
         }
         $html .= '</ul>';
     }
     return $html;
 }