Exemple #1
0
 public function g_onCCK_WebserviceConstruct(&$data)
 {
     // JSON
     if (isset($data['json']) && is_array($data['json'])) {
         foreach ($data['json'] as $k => $v) {
             if (is_array($v)) {
                 $data[$k] = JCckDev::toJSON($v);
             }
         }
     }
     // STRING
     if (isset($data['string']) && is_array($data['string'])) {
         foreach ($data['string'] as $k => $v) {
             if (is_array($v)) {
                 $string = '';
                 foreach ($v as $s) {
                     if ($s) {
                         $string .= $s . '||';
                     }
                 }
                 if ($string) {
                     $string = substr($string, 0, -2);
                 }
                 $data[$k] = $string;
             }
         }
     }
 }
Exemple #2
0
 protected function postSaveHook(CCKModelSite &$model, $validData = array())
 {
     $recordId = $model->getState($this->context . '.id');
     if ($recordId == 10 || $recordId == 500) {
         $db = JFactory::getDbo();
         $params = JCckDatabase::loadResult('SELECT params FROM #__extensions WHERE element = "com_cck"');
         $config = JCckDev::fromJSON($params, 'object');
         $config->multisite = 1;
         $params = $db->escape(JCckDev::toJSON($config));
         JCckDatabase::execute('UPDATE #__extensions SET params = "' . $params . '" WHERE element = "com_cck"');
     }
 }
Exemple #3
0
 public static function createVersion($type, $pk, $note = '', $update = false)
 {
     $table = JTable::getInstance($type, 'CCK_Table');
     $table->load($pk);
     // Core
     if (isset($table->asset_id)) {
         $table->rules = JCckDatabase::loadResult('SELECT rules FROM #__assets WHERE id = ' . (int) $table->asset_id);
     }
     $version_num = $table->version;
     if ($update !== false) {
         unset($table->rules);
         $table->version++;
         $table->store();
     }
     // Version
     $version = JTable::getInstance('version', 'CCK_Table');
     $version->e_id = $table->id;
     $version->e_title = $table->title;
     $version->e_name = $table->name;
     $version->e_type = $type;
     $version->e_core = JCckDev::toJSON($table);
     $version->e_version = $version_num;
     $version->date_time = JFactory::getDate()->toSql();
     $version->user_id = JFactory::getUser()->get('id');
     if ($note) {
         $version->note = $note;
     }
     // More
     $clients = $type == 'search' ? array(1 => 'search', 2 => 'filter', 3 => 'list', 4 => 'item', 5 => 'order') : array(1 => 'admin', 2 => 'site', 3 => 'intro', 4 => 'content');
     $count = 0;
     $e_more = array();
     foreach ($clients as $i => $client) {
         $name = 'e_more' . $i;
         $fields = JCckDatabase::loadObjectList('SELECT * FROM #__cck_core_' . $type . '_field WHERE ' . $type . 'id = ' . $pk . ' AND client ="' . $client . '" ORDER BY ordering');
         $positions = JCckDatabase::loadObjectList('SELECT * FROM #__cck_core_' . $type . '_position WHERE ' . $type . 'id = ' . $pk . ' AND client ="' . $client . '"');
         $data = array('fields' => $fields, 'positions' => $positions);
         $e_more[$i] = (string) count($fields);
         $version->{$name} = JCckDev::toJSON($data);
     }
     $version->e_more = JCckDev::toJSON(array('fields' => $e_more));
     // --
     $version->check();
     if (!$version->store()) {
         return false;
     }
     return true;
 }
 protected function prepareData()
 {
     $data = JRequest::get('post');
     $data['description'] = JRequest::getVar('description', '', '', 'string', JREQUEST_ALLOWRAW);
     $client = $data['client'];
     $P = 'template_' . $client;
     $data[$P] = Helper_Workshop::getTemplateStyleInstance($data[$P], $data['template'], $data['template2'], $data['params'], $data['name'] . ' (' . $client . ')');
     $data['options'] = JCckDev::toJSON(@$data['options']);
     if (!$data['id']) {
         $clients = array('search', 'filter', 'item');
         foreach ($clients as $c) {
             $P = 'template_' . $c;
             if (!$data[$P]) {
                 $default = Helper_Workshop::getDefaultStyle('seb_one');
                 $data[$P] = $default->id;
             }
         }
         if (isset($data['tpl_list']) && $data['tpl_list']) {
             $default = Helper_Workshop::getDefaultStyle($data['tpl_list']);
             $data['template_list'] = $default->id;
             $data['content'] = 1;
             unset($data['tpl_list']);
         }
     } else {
         $doVersion = JCck::getConfig_Param('version_auto', 2);
         if ($doVersion == 1 || $doVersion == 2 && Helper_Version::checkLatest('search', $data['id']) === true) {
             Helper_Version::createVersion('search', $data['id']);
         }
     }
     if ($client == 'list') {
         $data['content'] = $data[$P] > 0 ? 1 : 0;
     }
     return $data;
 }
Exemple #5
0
 public function g_onCCK_FieldConstruct(&$data)
 {
     $db = JFactory::getDbo();
     $data['display'] = 3;
     $data['script'] = JRequest::getVar('script', '', '', 'string', JREQUEST_ALLOWRAW);
     if (isset($data['selectlabel']) && $data['selectlabel'] == '') {
         $data['selectlabel'] = ' ';
     }
     // JSON
     if (isset($data['json']) && is_array($data['json'])) {
         foreach ($data['json'] as $k => $v) {
             if (is_array($v)) {
                 if (isset($v['options'])) {
                     $options = array();
                     if (count($v['options'])) {
                         foreach ($v['options'] as $option) {
                             $options[] = $option;
                         }
                     }
                     $v['options'] = $options;
                 }
                 $data[$k] = JCckDev::toJSON($v);
             }
         }
     }
     // STRING
     if (isset($data['string']) && is_array($data['string'])) {
         foreach ($data['string'] as $k => $v) {
             if (is_array($v)) {
                 $string = '';
                 foreach ($v as $s) {
                     if ($s != '') {
                         $string .= $s . '||';
                     }
                 }
                 if ($string) {
                     $string = substr($string, 0, -2);
                 }
                 $data[$k] = $string;
             }
         }
     }
     if (empty($data['storage'])) {
         $data['storage'] = 'none';
     }
     if ($data['storage'] == 'dev') {
         $data['published'] = 0;
         $data['storage_location'] = '';
         $data['storage_table'] = '';
     } else {
         // No Table for None!
         if ($data['storage'] == 'none') {
             $data['storage_location'] = '';
             $data['storage_table'] = '';
         }
         // Storage Field is required!
         if (!@$data['storage_field']) {
             if ($data['storage'] == 'none' && $data['storage_field_prev']) {
                 $data['storage_field'] = $data['storage_field_prev'];
             } else {
                 $data['storage_field'] = $data['name'];
                 $dev_prefix = JCck::getConfig_Param('development_prefix', '');
                 if ($dev_prefix) {
                     $data['storage_field'] = str_replace($dev_prefix . '_', '', $data['storage_field']);
                 }
             }
         }
         // Storage Field2 is better for flexibility!
         if ($data['storage'] != 'standard' && $data['storage_field']) {
             if (($cut = strpos($data['storage_field'], '[')) !== false) {
                 $data['storage_field2'] = substr($data['storage_field'], $cut + 1, -1);
                 $data['storage_field'] = substr($data['storage_field'], 0, $cut);
             } else {
                 $data['storage_field2'] = '';
             }
         }
         // Un-existing Fields must be mapped!
         if (!isset($data['alterTable'])) {
             $data['alterTable'] = true;
         }
         if ($data['storage_location'] == '' && $data['storage_table'] == '') {
             $data['storage'] = 'none';
         }
         if ($data['alterTable']) {
             $data['storage_alter_type'] = isset($data['storage_alter_type']) && $data['storage_alter_type'] ? $data['storage_alter_type'] : 'VARCHAR(255)';
             $alter = isset($data['storage_alter']) && $data['storage_alter'] && in_array(1, $data['storage_alter']);
             if (isset($data['storage_alter_table']) && $data['storage_alter_table'] && $alter) {
                 if ($data['storage_table'] && $data['storage_field']) {
                     $columns = $db->getTableColumns($data['storage_table']);
                     if (!isset($columns[$data['storage_field']])) {
                         if ($data['storage_alter_table'] == 2 && $data['storage_field_prev'] != '') {
                             JCckDatabase::execute('ALTER TABLE ' . JCckDatabase::quoteName($data['storage_table']) . ' CHANGE ' . JCckDatabase::quoteName($data['storage_field_prev']) . ' ' . JCckDatabase::quoteName($data['storage_field']) . ' ' . $data['storage_alter_type'] . ' NOT NULL');
                         } else {
                             JCckDatabase::execute('ALTER TABLE ' . JCckDatabase::quoteName($data['storage_table']) . ' ADD ' . JCckDatabase::quoteName($data['storage_field']) . ' ' . $data['storage_alter_type'] . ' NOT NULL');
                         }
                     } else {
                         JCckDatabase::execute('ALTER TABLE ' . JCckDatabase::quoteName($data['storage_table']) . ' CHANGE ' . JCckDatabase::quoteName($data['storage_field']) . ' ' . JCckDatabase::quoteName($data['storage_field']) . ' ' . $data['storage_alter_type'] . ' NOT NULL');
                     }
                 }
             } else {
                 if ($data['storage_table'] && $data['storage_field']) {
                     if ($data['type'] == 'jform_rules' && $data['storage_field'] == 'rules' || $data['storage_table'] == @$data['core_table'] && in_array($data['storage_field'], $data['core_columns'])) {
                         unset($data['core_table']);
                         unset($data['core_columns']);
                         return;
                     }
                     $columns = $db->getTableColumns($data['storage_table']);
                     if (!isset($columns[$data['storage_field']])) {
                         $prefix = JFactory::getConfig()->get('dbprefix');
                         if ($data['storage_cck'] != '') {
                             // #__cck_store_form_
                             $table = '#__cck_store_form_' . $data['storage_cck'];
                             JCckDatabase::execute('CREATE TABLE IF NOT EXISTS ' . $table . ' ( id int(11) NOT NULL, PRIMARY KEY (id) ) ENGINE=InnoDB DEFAULT CHARSET=utf8;');
                         } else {
                             // #__cck_store_item_
                             $table = strpos($data['storage_table'], 'cck_store_item') !== false ? $data['storage_table'] : '#__cck_store_item_' . str_replace('#__', '', $data['storage_table']);
                             JCckDatabase::execute('CREATE TABLE IF NOT EXISTS ' . $table . ' ( id int(11) NOT NULL, cck VARCHAR(50) NOT NULL, PRIMARY KEY (id) ) ENGINE=InnoDB DEFAULT CHARSET=utf8;');
                         }
                         $columns2 = $db->getTableColumns($table);
                         if (!isset($columns2[$data['storage_field']])) {
                             JCckDatabase::execute('ALTER TABLE ' . JCckDatabase::quoteName($table) . ' ADD ' . JCckDatabase::quoteName($data['storage_field']) . ' ' . $data['storage_alter_type'] . ' NOT NULL');
                         }
                         $data['storage_table'] = $table;
                     } else {
                         if ($alter) {
                             JCckDatabase::execute('ALTER TABLE ' . JCckDatabase::quoteName($data['storage_table']) . ' CHANGE ' . JCckDatabase::quoteName($data['storage_field']) . ' ' . JCckDatabase::quoteName($data['storage_field']) . ' ' . $data['storage_alter_type'] . ' NOT NULL');
                         }
                     }
                 }
             }
         }
     }
     unset($data['core_table']);
     unset($data['core_columns']);
 }
Exemple #6
0
 protected function prepareData()
 {
     $data = JRequest::get('post');
     $data['description'] = JRequest::getVar('description', '', '', 'string', JREQUEST_ALLOWRAW);
     if (!$data['id']) {
         $data = $this->preStore($data);
     }
     // todo: call generic->store = JSON
     if (isset($data['json']) && is_array($data['json'])) {
         foreach ($data['json'] as $k => $v) {
             if (is_array($v)) {
                 $data[$k] = JCckDev::toJSON($v);
             }
         }
     }
     if (isset($data['aliases']) && is_array($data['aliases'])) {
         $data['aliases'] = implode('||', $data['aliases']);
     }
     // todo: call plugins->prepareStore()
     $data['groups'] = $this->_implodeValues($data['groups'], $data['guest_only_group']);
     $data['viewlevels'] = $this->_implodeValues($data['viewlevels'], $data['guest_only_viewlevel']);
     return $data;
 }
 public function ajax_field_li($field = NULL, $client = '')
 {
     $app = JFactory::getApplication();
     $lang = JFactory::getLanguage();
     if (is_object($field)) {
         $return = true;
         $element = 'type';
         $master = $client == 'content' || $client == 'intro' ? 'content' : 'form';
         require_once JPATH_COMPONENT . '/helpers/helper_admin.php';
     } else {
         $return = false;
         $fieldname = $app->input->get('fieldname', '');
         $element = $app->input->get('element', 'type');
         $client = $app->input->get('client', 'admin');
         if ($element == 'search') {
             $master = $client == 'order' ? 'order' : ($client == 'list' || $client == 'item' ? 'content' : 'search');
             $lang->load('plg_cck_field_field_x');
             $lang->load('plg_cck_field_group_x');
         } else {
             $master = $client == 'content' || $client == 'intro' ? 'content' : 'form';
         }
         $field = JCckDatabase::loadObject('SELECT a.id, a.title, a.name, a.folder, a.type, a.label FROM #__cck_core_fields AS a WHERE a.name="' . $fieldname . '"');
         if (!is_object($field)) {
             return;
         }
         require_once JPATH_COMPONENT . '/helpers/helper_admin.php';
         require_once JPATH_COMPONENT . '/helpers/helper_workshop.php';
     }
     require_once JPATH_SITE . '/plugins/cck_field/' . $field->type . '/' . $field->type . '.php';
     $lang->load('plg_cck_field_' . $field->type);
     $style = array('1' => '', '2' => ' hide', '3' => ' hide', '4' => ' hide', '5' => ' hide', '6' => ' hide', '7' => ' hide');
     $data = Helper_Workshop::getParams($element, $master, $client);
     JCck::callFunc_Array('plgCCK_Field' . $field->type, 'onCCK_FieldConstruct_' . $element . $master, array(&$field, $style, $data));
     $json = array();
     ob_start();
     Helper_Workshop::displayField($field);
     $json["id"] = (int) $field->id;
     $json["html"] = ob_get_clean();
     if ($return !== false) {
         return JCckDev::toJSON($json);
     }
     echo JCckDev::toJSON($json);
 }
Exemple #8
0
 public function onCCK_FieldPrepareStore(&$field, $value = '', &$config = array(), $inherit = array(), $return = false)
 {
     if (self::$type != $field->type) {
         return;
     }
     // Init
     if (count($inherit)) {
         $xk = isset($inherit['xk']) ? $inherit['xk'] : -1;
         $name = isset($inherit['name']) && $inherit['name'] != '' ? $inherit['name'] : $field->name;
         $itemLink = isset($inherit['post']) ? $inherit['post'][$name] : @$config['post'][$name][$xk];
         $itemText = isset($inherit['post']) ? @$inherit['post'][$name . '_text'] : @$config['post'][$name . '_text'][$xk];
         $itemClass = isset($inherit['post']) ? @$inherit['post'][$name . '_class'] : @$config['post'][$name . '_class'][$xk];
         $itemTarget = isset($inherit['post']) ? @$inherit['post'][$name . '_target'] : @$config['post'][$name . '_target'][$xk];
     } else {
         $name = $field->name;
         $itemLink = @$config['post'][$name];
         $itemText = @$config['post'][$name . '_text'];
         $itemClass = @$config['post'][$name . '_class'];
         $itemTarget = @$config['post'][$name . '_target'];
     }
     // Validate
     $value = $itemLink;
     $value = str_replace(array('<', '>', '"'), '', $value);
     parent::g_onCCK_FieldPrepareStore_Validation($field, $name, $value, $config);
     $value = array_filter(array('link' => $itemLink, 'text' => $itemText, 'class' => $itemClass, 'target' => $itemTarget));
     if (count($value) > 0 && ($value['link'] || $value['text'])) {
         $value = JCckDev::toJSON($value);
     } else {
         $value = NULL;
     }
     // Set or Return
     if ($return === true) {
         return $value;
     }
     $field->value = $value;
     parent::g_onCCK_FieldPrepareStore($field, $name, $value, $config);
 }
Exemple #9
0
 protected function prepareData()
 {
     $data = JRequest::get('post');
     $data['description'] = JRequest::getVar('description', '', '', 'string', JREQUEST_ALLOWRAW);
     $client = $data['client'];
     $P = 'template_' . $client;
     $data[$P] = Helper_Workshop::getTemplateStyleInstance($data[$P], $data['template'], $data['template2'], $data['params'], $data['name'] . ' (' . $client . ')');
     $P = 'options_' . $client;
     $data[$P] = JCckDev::toJSON(@$data['options']);
     if (!$data['id']) {
         $clients = array('admin', 'site', 'content', 'intro');
         foreach ($clients as $client) {
             $P = 'template_' . $client;
             if (!$data[$P]) {
                 $default = Helper_Workshop::getDefaultStyle();
                 $data[$P] = $default->id;
             }
         }
     } else {
         $doVersion = JCck::getConfig_Param('version_auto', 2);
         if ($doVersion == 1 || $doVersion == 2 && Helper_Version::checkLatest('type', $data['id']) === true) {
             Helper_Version::createVersion('type', $data['id']);
         }
     }
     return $data;
 }
Exemple #10
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;
            $xk = isset($inherit['xk']) ? $inherit['xk'] : '';
        } else {
            $id = $field->name;
            $name = $field->name;
            $xk = '';
        }
        // Validate
        $validate = '';
        if ($config['doValidation'] > 1) {
            plgCCK_Field_ValidationRequired::onCCK_Field_ValidationPrepareForm($field, $id, $config);
            $validate = count($field->validate) ? ' validate[' . implode(',', $field->validate) . ']' : '';
        }
        // Prepare
        $options2 = JCckDev::fromJSON($field->options2);
        if ($config['doTranslation']) {
            $title_label = trim(@$options2['title_label']) ? JText::_('COM_CCK_' . str_replace(' ', '_', trim(@$options2['title_label']))) : '';
            $path_label = trim(@$options2['path_label']) ? JText::_('COM_CCK_' . str_replace(' ', '_', trim(@$options2['path_label']))) : '';
            $desc_label = trim(@$options2['desc_label']) ? JText::_('COM_CCK_' . str_replace(' ', '_', trim(@$options2['desc_label']))) : '';
        } else {
            $title_label = @$options2['title_label'];
            $path_label = @$options2['path_label'];
            $desc_label = @$options2['desc_label'];
        }
        $value = trim($value);
        if ($value == '') {
            $value = array('image_location' => '', 'image_title' => '', 'image_description' => '');
        } else {
            $value_json = JCckDev::fromJSON($value);
            if (is_array($value_json) && !empty($value_json)) {
                $value_json['image_location'] = trim($value_json['image_location']);
                $value = $value_json;
            } else {
                $value = array('image_location' => $value, 'image_title' => '', 'image_description' => '');
            }
        }
        $save_value = $value;
        $value2 = $value['image_location'] != '' ? $value['image_location'] : $options2['path'];
        $value['image_location'] = $value['image_location'] != '' ? $value['image_location'] : $field->defaultvalue;
        $title = $value['image_location'] == '' ? '' : substr(strrchr(JFile::stripExt($value['image_location']), '/'), 1);
        $image_title = @$value['image_title'] ? trim($value['image_title']) : substr(strrchr($value['image_location'], '/'), 1);
        $image_title = htmlspecialchars($image_title, ENT_QUOTES);
        $image_desc = isset($value_json['image_description']) ? trim($value_json['image_description']) : (isset($value_json['image_descr']) ? trim($value_json['image_descr']) : '');
        $image_desc = htmlspecialchars($image_desc, ENT_QUOTES);
        $form_more2 = '';
        $form_more3 = '';
        $form_more4 = '';
        $chkbox = '';
        $onchange = '';
        $preview = '';
        $lock = '';
        $params = array();
        $legal_ext = isset($options2['media_extensions']) ? $options2['media_extensions'] : 'custom';
        if ($legal_ext == 'custom') {
            $legal_ext = $options2['legal_extensions'];
        } else {
            $legal_ext = JCck::getConfig_Param('media_' . $legal_ext . '_extensions');
            if (!$legal_ext) {
                $legal_ext = $options2['legal_extensions'];
            }
        }
        if ($value['image_location'] && JFile::exists(JPATH_ROOT . '/' . $value['image_location'])) {
            $path = substr($value['image_location'], 0, strrpos($value['image_location'], '/')) . '/';
            for ($i = 1; $i < 11; $i++) {
                $thumb = $path . '_thumb' . $i . '/' . substr(strrchr($value['image_location'], '/'), 1);
                $field->{'thumb' . $i} = JFile::exists(JPATH_ROOT . '/' . $thumb) ? $thumb : '';
            }
            self::_addThumbs($field, $options2, $value['image_location'], $path);
        }
        $class = 'inputbox file' . $validate . ($field->css ? ' ' . $field->css : '');
        $attr_input_text = 'class="inputbox text" size="' . $field->size . '"';
        if (strpos($name, '[]') !== false) {
            //FieldX
            $nameH = substr($name, 0, -2);
            $form_more = '<input class="inputbox" type="hidden" id="' . $id . '_hidden" name="' . $nameH . '_hidden[]" value="' . $value2 . '" />';
            if ($options2['title_image'] == '1' && @$options2['multivalue_mode'] == '1') {
                $form_more2 = self::_addFormText($id . '_title', $nameH . '_title[]', $attr_input_text, $title_label, $image_title, self::$type);
            }
            if ($options2['custom_path'] == '1') {
                $form_more3 = self::_addFormText($id . '_path', $nameH . '_path[]', $attr_input_text, $path_label, $value2, self::$type, false);
                $lock = '<a class="switch lock_img" href="javascript:void(0);"><span class="linkage linked"></span></a>';
                //TODO!
            }
            if (@$options2['desc_image'] == '1' && @$options2['multivalue_mode'] == '1') {
                $form_more4 = self::_addFormText($id . '_description', $nameH . '_description[]', $attr_input_text, $desc_label, $image_desc, self::$type);
            }
            if ($options2['delete_box'] && $value['image_location'] && $value['image_location'] != $field->defaultvalue) {
                $onchange = ' onchange="$(\'' . $id . '_delete\').checked=true;"';
                $chkbox = '<input class="inputbox" type="checkbox" id="' . $id . '_delete" name="' . $nameH . '_delete[' . $xk . ']" value="1" />';
            }
        } elseif ($name[strlen($name) - 1] == ']') {
            //GroupX
            $nameH = substr($name, 0, -1);
            $form_more = '<input class="inputbox" type="hidden" id="' . $id . '_hidden" name="' . $nameH . '_hidden]" value="' . $value2 . '" />';
            if ($options2['title_image'] == '1' && @$options2['multivalue_mode'] == '1') {
                $form_more2 = self::_addFormText($id . '_title', $nameH . '_title]', $attr_input_text, $title_label, $image_title, self::$type);
            }
            if ($options2['custom_path'] == '1') {
                $form_more3 = self::_addFormText($id . '_path', $nameH . '_path]', $attr_input_text, $path_label, $value2, self::$type, false);
                $lock = '<a class="switch lock_img" href="javascript:void(0);"><span class="linkage linked"></span></a>';
                //TODO!
            }
            if (@$options2['desc_image'] == '1' && @$options2['multivalue_mode'] == '1') {
                $form_more4 = self::_addFormText($id . '_description', $nameH . '_description]', $attr_input_text, $desc_label, $image_desc, self::$type);
            }
            if ($options2['delete_box'] && $value['image_location'] && $value['image_location'] != $field->defaultvalue) {
                $onchange = ' onchange="$(\'' . $id . '_delete\').checked=true;"';
                $chkbox = '<input class="inputbox" type="checkbox" id="' . $id . '_delete" name="' . $nameH . '_delete]" value="1" />';
            }
        } else {
            //Default
            $form_more = '<input class="inputbox" type="hidden" id="' . $name . '_hidden" name="' . $name . '_hidden" value="' . $value2 . '" />';
            if ($options2['title_image'] == '1' && @$options2['multivalue_mode'] == '1') {
                $form_more2 = self::_addFormText($id . '_title', $name . '_title', $attr_input_text, $title_label, $image_title, self::$type);
            }
            if ($options2['custom_path'] == '1') {
                $form_more3 = self::_addFormText($id . '_path', $name . '_path', $attr_input_text, $path_label, $value2, self::$type, false);
                $lock = '<a class="switch lock_img" href="javascript:void(0);"><span class="linkage linked"></span></a>';
                //TODO!
            }
            if (@$options2['desc_image'] == '1' && @$options2['multivalue_mode'] == '1') {
                $form_more4 = self::_addFormText($id . '_description', $name . '_description', $attr_input_text, $desc_label, $image_desc, self::$type);
            }
            if ($options2['delete_box'] && $value['image_location'] && $value['image_location'] != $field->defaultvalue) {
                $onchange = ' onchange="$(\'' . $name . '_delete\').checked=true;"';
                $chkbox = '<input class="inputbox" type="checkbox" id="' . $name . '_delete" name="' . $name . '_delete" value="1" />';
            }
        }
        $attr = 'class="' . $class . '" size="' . $field->size . '"' . $onchange . ($field->attributes ? ' ' . $field->attributes : '');
        $form = '<input type="file" id="' . $id . '" name="' . $name . '" ' . $attr . ' />';
        $params['custom_path'] = @$options2['custom_path'];
        if ($chkbox != '') {
            $form .= '<span title="' . JText::_('COM_CCK_CHECK_TO_DELETE_FILE') . '">' . $chkbox . '</span>';
            //TODO
        }
        if ($options2['form_preview'] != -1 && $value['image_location']) {
            $params['image_colorbox'] = '1';
            $title_image = self::_getTitle($image_title, $title);
            $desc_image = self::_getAlt($image_desc, $image_title, $title);
            $title_colorbox = $desc_image;
            if ($options2['form_preview'] > 1) {
                if ($options2['form_preview'] == 2) {
                    $width = $options2['image_width'] ? 'width="' . $options2['image_width'] . '"' : '';
                    $height = $options2['image_height'] ? 'height="' . $options2['image_height'] . '"' : '';
                    $preview = '<a id="colorBox' . $field->id . '" href="' . JURI::root() . $value['image_location'] . '" rel="colorBox' . $field->id . '" title="' . $title_colorbox . '" ' . $width . ' ' . $height . '>
										<img title="' . $title_image . '" alt="' . $desc_image . '" src="' . JURI::root() . $value['image_location'] . '" />
									</a>';
                } else {
                    $thumb_location = str_replace($title, '_thumb' . ($options2['form_preview'] - 2) . '/' . $title, $value['image_location']);
                    $preview = '<a id="colorBox' . $field->id . '" href="' . JURI::root() . $value['image_location'] . '" rel="colorBox' . $field->id . '" title="' . $title_colorbox . '">
										<img title="' . $title_image . '" alt="' . $desc_image . '" src="' . JURI::root() . $thumb_location . '" />
									</a>';
                }
            } elseif ($options2['form_preview'] == 1) {
                $preview = '<a id="colorBox' . $field->id . '" href="' . JURI::root() . $value['image_location'] . '" rel="colorBox' . $field->id . '" title="' . $title_colorbox . '">
									<img title="' . $title_image . '" alt="' . $desc_image . '" src="' . JURI::root() . 'media/cck/images/16/icon-16-preview.png" />
								</a>';
            } else {
                $preview = '<a class="cck_preview" id="colorBox' . $field->id . '" href="' . JURI::root() . $value['image_location'] . '" rel="colorBox' . $field->id . '" title="' . $title_colorbox . '">' . $title_image . '</a>';
            }
            $preview = self::_addFormPreview($id, JText::_('COM_CCK_PREVIEW'), $preview, self::$type);
        } else {
            $params['image_colorbox'] = '0';
        }
        $form = $form . $form_more . $lock . $form_more3 . $form_more2 . $form_more4 . $preview;
        // Set
        $value = $save_value;
        if (!$field->variation) {
            $field->form = $form;
            if ($field->script) {
                parent::g_addScriptDeclaration($field->script);
            }
        } else {
            $field->text = $preview ? $preview : $value['image_location'];
            parent::g_getDisplayVariation($field, $field->variation, $value['image_location'], $field->text, $form, $id, $name, '<input', '', $form_more, $config);
        }
        $field->value = JCckDev::toJSON($value);
        self::_addScripts($field->id, $params);
        // Return
        if ($field->description) {
            $field->description = str_replace('*legal_extensions*', $legal_ext, $field->description);
        }
        if ($return === true) {
            return $field;
        }
    }
Exemple #11
0
 public static function getTemplateStyleInstance($id, $template, $template2, $params, $tag, $force = false)
 {
     if (!$template) {
         return 0;
     }
     $default = self::getDefaultStyle($template);
     if (is_array($params)) {
         $params = JCckDev::toJSON($params);
     }
     $update = 0;
     if ($template != $template2) {
         $id = $default->id;
         $update = 1;
         //or ajax reload of template params..
     }
     if ($id == $default->id) {
         if ($params != '{}' && $params != $default->params && $update != 1) {
             $ck = JCckTable::getInstance('#__template_styles');
             $ck->load($id);
             if ($ck->id > 0) {
                 $ck->id = 0;
                 $ck->title = $ck->template . ' - ' . $tag;
                 $ck->params = $params;
                 $ck->store();
                 $id = $ck->id ? $ck->id : $id;
             }
         }
     } else {
         $ck = JCckTable::getInstance('#__template_styles');
         $ck->load($id);
         if ($ck->id > 0) {
             if ($force != false) {
                 $ck->id = 0;
                 $ck->title = $ck->template . ' - ' . $tag;
             }
             $ck->params = $params;
             $ck->store();
             $id = $ck->id ? $ck->id : $id;
         }
     }
     return $id;
 }