protected function prepareDisplay($preconfig) { if (JCck::getConfig_Param('debug', 0)) { jimport('joomla.error.profiler'); $profiler = new JProfiler(); } $app = JFactory::getApplication(); $this->form = $this->get('Form'); $this->option = $app->input->get('option', ''); $this->item = $this->get('Item'); $this->state = $this->get('State'); $option = $this->option; $params = new JRegistry(); $view = $this->getName(); $isNew = 1; $live = ''; $lives = array(); $variation = ''; jimport('cck.base.form.form'); include_once JPATH_LIBRARIES_CCK . '/base/form/form_inc.php'; if (isset($config['id'])) { JFactory::getSession()->set('cck_hash_seblod_form', JApplication::getHash($id . '|' . $type->name . '|' . $config['id'])); } $this->config =& $config; $this->data =& $data; $this->id =& $id; $this->isNew =& $isNew; $this->params =& $params; $this->stage =& $stage; $this->type =& $type; $title = isset($type->title) ? $type->title : ''; $name = isset($type->name) ? $type->name : ''; $this->addToolbar($title, $name); }
public static function addValidation($rules, $options, $id = '', &$config = array()) { $doc = JFactory::getDocument(); if (!$id) { $id = 'seblod_form'; } if (empty($rules)) { $rules = ''; } $rules = str_replace(array("\r\n", "\r", "\n", "\t", ' ', ' ', ' '), '', $rules); if (is_object($options)) { $bgcolor = $options->get('validation_background_color', JCck::getConfig_Param('validation_background_color', '')); $color = $options->get('validation_color', JCck::getConfig_Param('validation_color', '')); $position = $options->get('validation_position', JCck::getConfig_Param('validation_position', 'topRight')); $scroll = $options->get('validation_scroll', JCck::getConfig_Param('validation_scroll', 1)) ? 'scroll:true' : 'scroll:false'; if ($color != '') { if ($position == 'inline') { $doc->addStyleDeclaration('#' . $id . ' .formError .formErrorContent{color: ' . $color . '}'); } else { $doc->addStyleDeclaration('.formError .formErrorContent{color: ' . $color . '}'); } } if ($position != 'inline' && $bgcolor != '') { $doc->addStyleDeclaration('.formError .formErrorContent, .formError .formErrorArrow div{background: ' . $bgcolor . '}'); } $options = '{' . $scroll . ',promptPosition:"' . $position . '"}'; } else { $options = '{}'; } $doc->addStyleSheet(JURI::root(true) . '/media/cck/css/cck.validation.css'); $doc->addScript(JURI::root(true) . '/media/cck/js/cck.validation-3.2.0.min.js'); $js = 'jQuery(document).ready(function($){ $.validationEngineLanguage.newLang({' . $rules . '}); $("#' . $id . '").validationEngine(' . $options . '); });'; $doc->addScriptDeclaration($js); }
public static function onCCK_Field_ValidationPrepareForm(&$field, $fieldId, &$config) { if (self::$type != $field->validation) { return; } $and = ''; $extra = ''; $extraData2 = ''; $name = 'availability_' . $fieldId; $validation = parent::g_getValidation($field->validation_options); $alert = self::_alert($validation, 'alert', $config); $alert2 = self::_alert($validation, 'alert2', $config); $alert3 = self::_alert($validation, 'alert3', $config); $prefix = JCck::getConfig_Param('validation_prefix', '* '); if (isset($validation->fieldnames) && $validation->fieldnames) { $extra .= '&avWhere=' . str_replace('||', ',', $validation->fieldnames); $extraData2 = '"extraDataDynamic": "#' . str_replace('||', ',#', $validation->fieldnames) . '",'; $and = self::_where($validation->table, $validation->fieldnames, $config['storages'][$validation->table], 'object'); } if ($field->value) { $pk = (int) JCckDatabase::loadResult('SELECT ' . $validation->key . ' FROM ' . $validation->table . ' WHERE ' . $validation->column . '="' . JCckDatabase::escape($field->value) . '"' . $and); $extra .= '&avKey=' . $validation->key . '&avPk=' . $pk . '&avPv=' . htmlspecialchars(str_replace(array('<', '>', "'"), array('%26lt;', '%26gt;', '%27'), $field->value)); } $rule = ' "' . $name . '":{ "url": "' . JUri::base() . 'index.php?option=com_cck&task=ajax&format=raw&file=/plugins/cck_field_validation/ajax_availability/assets/ajax/script.php", "extraData": "avTable=' . str_replace('#__', '', $validation->table) . '&avColumn=' . $validation->column . $extra . '", ' . $extraData2 . ' "alertText": "' . $prefix . $alert . '", "alertTextOk": "' . $prefix . $alert2 . '", "alertTextLoad": "' . $prefix . $alert3 . '"} '; $config['validation'][$name] = $rule; $field->validate[] = 'ajax[' . $name . ']'; }
public function g_onCCK_Storage_LocationStore($location, $default, $pk, &$config, $params = array()) { if (!$pk) { return; } static $already = 0; $config['author'] = (int) $config['author'] > 0 ? $config['author'] : JCck::getConfig_Param('integration_user_default_author', 42); $config['parent'] = isset($config['parent']) && (int) $config['parent'] > 0 ? $config['parent'] : 0; $table = $location['_']->table; // Core if (!$already) { if (isset($params['bridge']) && $params['bridge']) { if (!isset($params['bridge_default_title'])) { $params['bridge_default_title'] = ''; } if (!isset($params['bridge_default_title_mode'])) { $params['bridge_default_title_mode'] = 0; } if ($params['bridge'] == 1) { self::g_doBridge('joomla_article', $pk, $location, $config, $params); } elseif ($params['bridge'] == 2) { self::g_doBridge('joomla_category', $pk, $location, $config, $params); } } else { $core = JCckTable::getInstance('#__cck_core', 'id'); $core->load($config['id']); $core->cck = $config['type']; if (!$core->pk) { $core->date_time = JFactory::getDate()->toSql(); } $core->pk = $pk; $core->storage_location = isset($location['_']->location) ? $location['_']->location : JCckDatabase::loadResult('SELECT storage_location FROM #__cck_core_types WHERE name = "' . $config['type'] . '"'); $core->author_id = $config['author']; $core->parent_id = $config['parent']; if (isset($config['storages']['#__cck_core']['store_id'])) { $core->store_id = $config['storages']['#__cck_core']['store_id']; } $core->storeIt(); } if (!(isset($config['component']) && $config['component'] == 'com_cck_importer')) { $already = 1; } } // More if ($table && $table != $default) { $more = JCckTable::getInstance($table, 'id'); $more->load($pk, true); if (isset($more->cck)) { $more->cck = $config['type']; } $more->bind($config['storages'][$table]); $more->check(); $more->store(); } if (!isset($config['primary'])) { $config['primary'] = $location['_']->location; } }
function __construct($path) { $this->_quality_jpg = JCck::getConfig_Param('media_quality_jpeg', 90); $this->_quality_png = JCck::getConfig_Param('media_quality_png', 3); $this->_pathinfo = pathinfo($path); $this->_extension = strtolower($this->_pathinfo['extension']); $this->_resource = $this->_createResource($this->_extension, $path); list($this->_width, $this->_height) = getimagesize($path); $this->_ratio = $this->_width / $this->_height; }
function uninstall($parent) { // Post Install Log self::_postInstallMessage('uninstall', $parent); $app = JFactory::getApplication(); $db = JFactory::getDbo(); $db->setQuery('SELECT extension_id FROM #__extensions WHERE type = "package" AND element = "pkg_cck"'); $eid = $db->loadResult(); $db->setQuery('SELECT extension_id FROM #__extensions WHERE type = "plugin" AND element = "cck" AND folder="system"'); $cck = $db->loadResult(); // Backup or Drop SQL Tables $prefix = $db->getPrefix(); $tables = $db->getTableList(); $tables = array_flip($tables); $uninstall_sql = (int) JCck::getConfig_Param('uninstall_sql', ''); if (count($tables)) { $length = strlen($prefix); $app->cck_nosql = true; foreach ($tables as $k => $v) { $pos = strpos($k, $prefix . 'cck_'); if ($pos !== false && $pos == 0) { $k2 = $prefix . '_' . substr($k, $length); if (isset($tables[$k2])) { $db->setQuery('DROP TABLE ' . $k2); $db->execute(); } if ($uninstall_sql == 1) { $db->setQuery('DROP TABLE ' . $k); $db->execute(); } else { $db->setQuery('RENAME TABLE ' . $k . ' TO ' . $k2); $db->execute(); } } } } // Uninstall FULL PACKAGE only if package exists && system plugin exists.. if ($eid && $cck) { $manifest = JPATH_ADMINISTRATOR . '/manifests/packages/pkg_cck.xml'; if (JFile::exists($manifest)) { $xml = JFactory::getXML($manifest); // Keep it this way until platform 13.x } if (isset($xml->files)) { unset($xml->files->file[3]); $xml->asXML($manifest); } jimport('joomla.installer.installer'); $installer = JInstaller::getInstance(); $installer->uninstall('package', $eid); } }
function __construct($path) { $this->_quality_jpg = JCck::getConfig_Param('media_quality_jpeg', 90); $this->_quality_png = JCck::getConfig_Param('media_quality_png', 3); $this->_pathinfo = pathinfo($path); $this->_extension = strtolower($this->_pathinfo['extension']); if (in_array($this->_extension, array('jpg', 'jpeg', 'tiff'))) { $this->_exif = exif_read_data($path, 0, true); } $this->_resource = $this->_createResource($this->_extension, $path); list($this->_width, $this->_height) = getimagesize($path); $this->_ratio = $this->_width / $this->_height; }
public static function onCCK_Field_ValidationPrepareForm(&$field, $fieldId, &$config) { if (self::$type != $field->required) { if (strpos($field->required, self::$type . '[') !== false) { $name = 'groupRequired'; $fieldId = explode('[', $field->required); $fieldId = substr($fieldId[1], 0, -1); $required = 'groupRequired[' . $fieldId . ']'; $required2 = 'groupRequire'; } else { return; } } else { $name = $field->required; $required = $field->required; $required2 = 'require'; } if ($field->required_alert != '') { $name = $name . '_' . $fieldId; $alert = $field->required_alert; if ($config['doTranslation']) { if (trim($alert)) { $alert = JText::_('COM_CCK_' . str_replace(' ', '_', trim($alert))); } } $prefix = JCck::getConfig_Param('validation_prefix', '* '); $rule = ' "' . $name . '":{ "regex": ' . self::$regex . ', "alertText":"' . $prefix . $alert . '"} '; $config['validation'][$name] = $rule; $field->validate[] = $required2 . '[' . $name . ']'; } else { $alert = JText::_('PLG_CCK_FIELD_VALIDATION_' . $name . '_ALERT'); $alert2 = JText::_('PLG_CCK_FIELD_VALIDATION_' . self::$type . '_ALERT2'); $alert3 = JText::_('PLG_CCK_FIELD_VALIDATION_' . self::$type . '_ALERT3'); $prefix = JCck::getConfig_Param('validation_prefix', '* '); $rule = ' "' . $name . '":{ "regex":' . self::$regex . ', "alertText":"' . $prefix . $alert . '", "alertTextCheckboxe":"' . $prefix . $alert2 . '", "alertTextCheckboxMultiple":"' . $prefix . $alert3 . '"} '; $config['validation'][$name] = $rule; $field->validate[] = $required; } }
public function onCCK_FieldPrepareContent(&$field, $value = '', &$config = array()) { if (self::$type != $field->type) { return; } parent::g_onCCK_FieldPrepareContent($field, $config); // Process if ($field->state) { $app = JFactory::getApplication(); $doc = JFactory::getDocument(); $postpone = false; if (count($doc->_links)) { foreach ($doc->_links as $k => $link) { if ($link['relation'] == 'canonical') { unset($doc->_links[$k]); } } } if ($field->options2 != '') { $fieldname = ''; $fieldname2 = ''; $options2 = new JRegistry($field->options2); $location = $config['location'] ? $config['location'] : 'joomla_article'; if ($options2->get('content') == '2') { $postpone = true; $fieldname = $options2->get('content_fieldname'); } if ($options2->get('itemid') == '-2') { $fieldname2 = $options2->get('itemid_fieldname'); $itemId = $config['Itemid']; $postpone = true; } else { $itemId = $options2->get('itemid', $config['Itemid']); } if ($postpone !== false) { parent::g_addProcess('beforeRenderContent', self::$type, $config, array('name' => $field->name, 'fieldname' => $fieldname, 'itemId' => $itemId, 'fieldname2' => $fieldname2, 'location' => $location, 'sef' => $options2->get('sef', JCck::getConfig_Param('sef')))); } elseif ($config['pk']) { $uri = JUri::getInstance(); $domain = $uri->toString(array('scheme', 'host', 'port')); $link = JCck::callFunc_Array('plgCCK_Storage_Location' . $location, 'getRoute', array($config['pk'], $options2->get('sef', JCck::getConfig_Param('sef')), $options2->get('itemid', $config['Itemid']), $config)); $doc->addHeadLink($domain . $link, 'canonical'); $app->cck_canonical_url = $link; } } $app->cck_canonical = true; } $field->display = 0; $field->value = ''; }
public static function addValidation($rules, $options, $id = '', &$config = array()) { $app = JFactory::getApplication(); $doc = JFactory::getDocument(); if (!$id) { $id = 'seblod_form'; } if (empty($rules)) { $rules = ''; } $rules = str_replace(array("\r\n", "\r", "\n", "\t", ' ', ' ', ' '), '', $rules); if (is_object($options)) { $bgcolor = $options->get('validation_background_color', JCck::getConfig_Param('validation_background_color', '')); $color = $options->get('validation_color', JCck::getConfig_Param('validation_color', '')); $position = $options->get('validation_position', JCck::getConfig_Param('validation_position', 'topRight')); $scroll = $options->get('validation_scroll', JCck::getConfig_Param('validation_scroll', 1)) ? 'scroll:true' : 'scroll:false'; if ($color != '') { if ($position == 'inline' && $id != '_') { $doc->addStyleDeclaration('#' . $id . ' .formError .formErrorContent{color: ' . $color . '}'); } else { $doc->addStyleDeclaration('.formError .formErrorContent{color: ' . $color . '}'); } } if ($position != 'inline' && $bgcolor != '') { $css = '.formError .formErrorContent{background: ' . $bgcolor . '}'; if ($position == 'topLeft' || $position == 'topRight') { $css .= '.formError .formErrorArrow{border-color: ' . $bgcolor . ' transparent transparent transparent;}'; } else { $css .= '.formError .formErrorArrow.formErrorArrowBottom{border-color: transparent transparent ' . $bgcolor . ' transparent;}'; } $doc->addStyleDeclaration($css); } $options = '{' . $scroll . ',promptPosition:"' . $position . '"}'; } else { $options = '{}'; } $js = $id == '_' ? '' : '$("#' . $id . '").validationEngine(' . $options . ');'; $js = 'jQuery(document).ready(function($){ $.validationEngineLanguage.newLang({' . $rules . '});' . $js . ' });'; if ($app->input->get('tmpl') == 'raw') { echo '<link rel="stylesheet" href="' . JURI::root(true) . '/media/cck/css/cck.validation-3.6.0.css" type="text/css" />'; echo '<script src="' . JURI::root(true) . '/media/cck/js/cck.validation-3.5.0.min.js" type="text/javascript"></script>'; echo '<script type="text/javascript">' . $js . '</script>'; } else { $doc->addStyleSheet(JURI::root(true) . '/media/cck/css/cck.validation-3.6.0.css'); $doc->addScript(JURI::root(true) . '/media/cck/js/cck.validation-3.5.0.min.js'); $doc->addScriptDeclaration($js); } }
function prepareDisplay() { $app = JFactory::getApplication(); $model = $this->getModel(); $this->form = $this->get('Form'); $this->item = $this->get('Item'); $this->option = $app->input->get('option', ''); $this->state = $this->get('State'); // Check Errors if (count($errors = $this->get('Errors'))) { JError::raiseError(500, implode("\n", $errors)); return false; } $this->isNew = @$this->item->id > 0 ? 0 : 1; $this->item->published = Helper_Admin::getSelected($this->vName, 'state', $this->item->published, 1); $this->item->type = $this->state->get('type', '2,7'); $this->item->fields = JCck::getConfig_Param('multisite_options', array()); $this->item->options = $this->item->options ? JCckDev::fromJSON($this->item->options) : array(); Helper_Admin::addToolbarEdit($this->vName, _C5_TEXT, array('isNew' => $this->isNew, 'folder' => 0, 'checked_out' => $this->item->checked_out)); }
public static function checkLatest($type, $pk) { $latest = JCckDatabase::loadResult('SELECT date_time FROM #__cck_core_versions WHERE e_type = "' . $type . '" AND e_id = ' . $pk . ' ORDER BY date_time DESC'); if (!$latest) { return true; } $current = JFactory::getDate()->toSql(); $diff = round(abs(strtotime($current) - strtotime($latest)) / 60, 2); $time = (int) JCck::getConfig_Param('version_auto_time', 180); $time_unit = (int) JCck::getConfig_Param('version_auto_unit', 0); if ($time_unit == 2) { $diff = $diff / 1440; } elseif ($time_unit == 1) { $diff = $diff / 60; } if ($diff > $time) { return true; } return false; }
public static function onCCK_Field_ValidationPrepareForm(&$field, $fieldId, &$config) { if (self::$type != $field->required) { return; } if ($field->required_alert != '') { $name = self::$type . '_' . $fieldId; $alert = $field->required_alert; if ($config['doTranslation']) { if (trim($alert)) { $alert = JText::_('COM_CCK_' . str_replace(' ', '_', trim($alert))); } } $prefix = JCck::getConfig_Param('validation_prefix', '* '); $rule = ' "' . $name . '":{ "regex": ' . self::$regex . ', "alertText":"' . $prefix . $alert . '"} '; $config['validation'][$name] = $rule; $field->validate[] = 'require[' . $name . ']'; } else { //$lang = JFactory::getLanguage(); //$lang->load( 'plg_cck_field_validation_'.self::$type, JPATH_ADMINISTRATOR, null, false, true ); $name = self::$type; $alert = JText::_('PLG_CCK_FIELD_VALIDATION_' . self::$type . '_ALERT'); $alert2 = JText::_('PLG_CCK_FIELD_VALIDATION_' . self::$type . '_ALERT2'); $alert3 = JText::_('PLG_CCK_FIELD_VALIDATION_' . self::$type . '_ALERT3'); $prefix = JCck::getConfig_Param('validation_prefix', '* '); $rule = ' "' . $name . '":{ "regex":' . self::$regex . ', "alertText":"' . $prefix . $alert . '", "alertTextCheckboxe":"' . $prefix . $alert2 . '", "alertTextCheckboxMultiple":"' . $prefix . $alert3 . '"} '; $config['validation'][$name] = $rule; $field->validate[] = 'required'; } }
public static function onCCK_Field_ValidationPrepareForm(&$field, $fieldId, &$config) { if (self::$type != $field->validation) { return; } $validation = parent::g_getValidation($field->validation_options); if (empty($validation->field)) { return; } if ($validation->alert != '') { $name = 'confirmed_' . $fieldId; $alert = $validation->alert; if ($config['doTranslation']) { if (trim($alert)) { $alert = JText::_('COM_CCK_' . str_replace(' ', '_', trim($alert))); } } $prefix = JCck::getConfig_Param('validation_prefix', '* '); $rule = ' "' . $name . '":{ "regex": "' . $validation->field . '", "alertText":"' . $prefix . $alert . '"} '; $config['validation'][$name] = $rule; $field->validate[] = 'confirm[' . $name . ']'; } else { $lang = JFactory::getLanguage(); $lang->load('plg_cck_field_validation_' . self::$type, JPATH_ADMINISTRATOR, null, false, true); $name = 'confirmed'; $alert = JText::_('PLG_CCK_FIELD_VALIDATION_' . self::$type . '_ALERT'); $prefix = JCck::getConfig_Param('validation_prefix', '* '); $rule = ' "' . $name . '":{ "regex": ' . self::$regex . ', "alertText":"' . $prefix . $alert . '"} '; $config['validation'][$name] = $rule; $field->validate[] = 'confirmed[' . $validation->field . ']'; } }
public function revert($pk, $type) { $db = $this->getDbo(); $table = $this->getTable(); if (!$pk || !$type) { return false; } $table->load($pk); if (JCck::getConfig_Param('version_revert', 1) == 1) { Helper_Version::createVersion($type, $table->e_id, JText::sprintf('COM_CCK_VERSION_AUTO_BEFORE_REVERT', $table->e_version)); } $row = JTable::getInstance($type, 'CCK_Table'); $row->load($table->e_id); $core = JCckDev::fromJSON($table->e_core); if (isset($row->asset_id) && $row->asset_id && isset($core['rules'])) { JCckDatabase::execute('UPDATE #__assets SET rules = "' . $db->escape($core['rules']) . '" WHERE id = ' . (int) $row->asset_id); } // More if ($type == 'search') { $clients = array(1 => 'search', 2 => 'filter', 3 => 'list', 4 => 'item', 5 => 'order'); } else { $clients = array(1 => 'admin', 2 => 'site', 3 => 'intro', 4 => 'content'); } foreach ($clients as $i => $client) { $name = 'e_more' . $i; $this->_revert_more($type, $client, $table->e_id, $table->{$name}); } // Override if ($row->version && $row->version != $table->e_version) { $core['version'] = ++$row->version; } $core['checked_out'] = 0; $core['checked_out_time'] = '0000-00-00 00:00:00'; $row->bind($core); $row->check(); $row->store(); return true; }
public static function g_onCCK_Field_ValidationPrepareForm(&$field, $fieldId, &$config, $rule, $definition) { $validation = self::g_getValidation($field->validation_options); if ($validation->alert != '') { if (is_array($definition)) { $def = $definition['definition']; } else { $def = $definition; } $validation->name = $field->validation . '_' . $fieldId; $alert = $validation->alert; if ($config['doTranslation']) { if (trim($alert)) { $alert = JText::_('COM_CCK_' . str_replace(' ', '_', trim($alert))); } } } else { if (is_array($definition)) { $def = $definition['definition']; $validation->name = isset($definition['suffix']) && $definition['suffix'] ? $field->validation . '_' . $definition['suffix'] : $field->validation; } else { $def = $definition; $validation->name = $field->validation; } JFactory::getLanguage()->load('plg_cck_field_validation_' . $field->validation, JPATH_ADMINISTRATOR, null, false, true); $alert = JText::_('PLG_CCK_FIELD_VALIDATION_' . $field->validation . '_ALERT'); } $prefix = JCck::getConfig_Param('validation_prefix', '* '); $rule = ' "' . $validation->name . '":{ "' . $rule . '": ' . $def . ', "alertText":"' . $prefix . $alert . '"} '; $config['validation'][$validation->name] = $rule; return $validation; }
public function save() { JSession::checkToken() or jexit(JText::_('JINVALID_TOKEN')); $app = JFactory::getApplication(); $model = $this->getModel('form'); $preconfig = $app->input->post->get('config', array(), 'array'); $task = $this->getTask(); $config = $model->store($preconfig, $task); $id = $config['pk']; $itemId = $preconfig['itemId']; if ($config['validate'] == 'retry') { if ($app->input->get('option', '') == 'com_cck') { $view = $app->input->get('view', ''); if ($view == 'list') { $app->input->set('task', 'search'); $app->input->set('retry', $config['type']); parent::display(); return false; } elseif ($view == 'form') { $app->input->set('retry', $config['type']); parent::display(); return false; } } } if ($id) { if ($config['message_style']) { if (isset($config['message'])) { $msg = $config['doTranslation'] ? JText::_('COM_CCK_' . str_replace(' ', '_', trim($config['message']))) : $config['message']; } else { $msg = JText::_('COM_CCK_SUCCESSFULLY_SAVED'); } $msgType = $config['message_style']; } else { $msg = ''; $msgType = ''; } if ($config['stage'] > -1 && $task != 'save2skip') { if ($config['url']) { $link = $config['url']; } elseif (!(isset($preconfig['skip']) && $preconfig['skip'] == '1')) { $link = 'index.php?option=com_cck&view=form&layout=edit&type=' . $config['type'] . '&id=' . $id; if ($itemId > 0) { $link .= '&Itemid=' . $itemId; } if ($config['stage'] > 0) { $link .= '&stage=' . $config['stage']; } $link = JRoute::_($link); } if ($link != '') { if ($msg != '') { $this->setRedirect(htmlspecialchars_decode($link), $msg, $msgType); } else { $this->setRedirect(htmlspecialchars_decode($link)); } return; } } } else { $msg = JText::_('JERROR_AN_ERROR_HAS_OCCURRED'); $msgType = 'error'; } $link = $this->_getReturnPage(false); $redirect = $config['options']['redirection']; $return = ''; if ($task == 'apply' || $task == 'save2copy') { $link = ''; $redirect = 'form_edition'; $return = $app->input->getBase64('return'); } elseif ($task == 'save2new') { $link = ''; $redirect = 'form'; $return = $app->input->getBase64('return'); } elseif ($task == 'save2view') { $link = ''; $redirect = 'content'; } elseif ($task == 'save2redirect') { $link = ''; $redirect = ''; } if (!$link) { switch ($redirect) { case 'content': $loc = JCckDatabase::loadResult('SELECT storage_location FROM #__cck_core WHERE id = ' . (int) $config['id']); $sef = 0; $itemId2 = isset($config['options']['redirection_itemid']) && $config['options']['redirection_itemid'] ? (int) $config['options']['redirection_itemid'] : $itemId; if ($itemId2 > 0) { $target = JCckDatabase::loadResult('SELECT link FROM #__menu WHERE id = ' . (int) $itemId2); if ($target) { $vars = explode('&', $target); foreach ($vars as $var) { $v = explode('=', $var); if ($v[0] == 'search') { $target = $v[1]; break; } } $vars = JCckDatabase::loadResult('SELECT options FROM #__cck_core_searchs WHERE name = "' . (string) $target . '"'); if ($vars) { $vars = new JRegistry($vars); $sef = $vars->get('sef', JCck::getConfig_Param('sef', '2')); } } } if ($loc) { require_once JPATH_SITE . '/plugins/cck_storage_location/' . $loc . '/' . $loc . '.php'; $link = JCck::callFunc_Array('plgCCK_Storage_Location' . $loc, 'getRoute', array($config['pk'], $sef, $itemId2, array('type' => $config['type']))); } else { $link = JUri::root(); } break; case 'form': $link = 'index.php?option=com_cck&view=form&layout=edit&type=' . $config['type']; if ($itemId > 0) { $link .= '&Itemid=' . $itemId; } if ($return != '') { $link .= '&return=' . $return; } $link = JRoute::_($link); break; case 'form_edition': $link = 'index.php?option=com_cck&view=form&layout=edit&type=' . $config['type'] . '&id=' . $id; if ($itemId > 0) { $link .= '&Itemid=' . $itemId; } if ($return != '') { $link .= '&return=' . $return; } $link = JRoute::_($link); break; case 'url': $link = JRoute::_($config['options']['redirection_url']); break; default: $link = $config['url'] ? $config['url'] : JUri::root(); break; } } if ($id) { $char = strpos($link, '?') > 0 ? '&' : '?'; if (isset($config['thanks'])) { if (!empty($config['thanks'])) { $thanks = @$config['thanks']->name ? $config['thanks']->name : 'thanks'; $thanks_value = @$config['thanks']->value ? $config['thanks']->value : $preconfig['type']; $link .= $char . $thanks . '=' . $thanks_value; } } else { $link .= $char . 'thanks=' . $preconfig['type']; } } if ($msg != '') { $this->setRedirect(htmlspecialchars_decode($link), $msg, $msgType); } else { $this->setRedirect(htmlspecialchars_decode($link)); } }
public static function afterImportCategory($elemtype, &$table, $xml, &$data) { $app = isset($xml->app) ? (string) $xml->app : ''; $core = $app ? JCckDatabase::loadObject('SELECT id, pk FROM #__cck_core WHERE app = "' . $app . '"') : 0; if (is_object($core)) { $id = $core->id; $isNew = false; } else { $id = JCckPluginLocation::g_onCCK_Storage_LocationPrepareStore(); $isNew = true; } if (@$core->pk > 0) { $table->id = $core->pk; } $table->description = '::cck::' . $id . '::/cck::<br />::description::::/description::'; //todo $table->parent_id = $data['root_category'] > 0 ? $data['root_category'] : 1; $rules = new JAccessRules('{"core.create":[],"core.delete":[],"core.edit":[],"core.edit.state":[],"core.edit.own":[]}'); $table->setRules($rules); $table->setLocation($table->parent_id, 'last-child'); $table->check(); $table->store(); $data['root_category'] = $data['root_category'] > 0 ? $data['root_category'] : $table->id; $data['categories'][$app] = $table->id; if ($table->rebuildPath($table->id)) { $table->rebuild($table->id, $table->lft, $table->level, $table->path); } if ($isNew === true) { $core = JCckTable::getInstance('#__cck_core', 'id'); $core->load($id); $core->pk = $table->id; $core->cck = 'category'; //todo $core->storage_location = 'joomla_category'; $core->author_id = JCck::getConfig_Param('integration_user_default_author', 42); //todo $core->parent_id = $table->parent_id; $core->date_time = ''; //todo $core->app = $app; $core->storeIt(); } }
public static function g_onCCK_FieldPrepareForm_Validation(&$field, $id, &$config = array(), $rules = false) { if ($field->validation) { require_once JPATH_PLUGINS . '/cck_field_validation/' . $field->validation . '/' . $field->validation . '.php'; JCck::callFunc_Array('plgCCK_Field_Validation' . $field->validation, 'onCCK_Field_ValidationPrepareForm', array(&$field, $id, &$config)); } if ($rules !== false) { $prefix = JCck::getConfig_Param('validation_prefix', '* '); if (isset($rules['maxSize'])) { if ($field->maxlength > 0) { $field->validate[] = 'maxSize[' . $field->maxlength . ']'; if (!isset($config['validation']['maxSize'])) { $config['validation']['maxSize'] = ' "maxSize":{ "regex":"none", "alertText":"' . $prefix . JText::_('PLG_CCK_FIELD_VALIDATION_MAXLENGTH_ALERT') . '", "alertText2":"' . JText::_('PLG_CCK_FIELD_VALIDATION_MAXLENGTH_ALERT2') . '"} '; } } } if (isset($rules['minSize'])) { if ($field->minlength > 0) { $field->validate[] = 'minSize[' . $field->minlength . ']'; if (!isset($config['validation']['minSize'])) { $config['validation']['minSize'] = ' "minSize":{ "regex":"none", "alertText":"' . $prefix . JText::_('PLG_CCK_FIELD_VALIDATION_MINLENGTH_ALERT') . '", "alertText2":"' . JText::_('PLG_CCK_FIELD_VALIDATION_MINLENGTH_ALERT2') . '"} '; } } } } }
protected function _initTable(&$table, &$data, &$config, $force = false) { $user = JFactory::getUser(); if (!$table->{self::$key}) { parent::g_initTable($table, isset($config['params']) ? $config['params'] : $this->params->toArray(), $force); $table->{self::$author} = $table->{self::$author} ? $table->{self::$author} : JCck::getConfig_Param('integration_user_default_author', 42); if (isset($config['params'])) { $table->access = isset($config['params']['base_default-access']) ? $config['params']['base_default-access'] : 1; if (!isset($data['parent_id'])) { $data['parent_id'] = isset($config['params']['base_default-parent_id']) ? $config['params']['base_default-parent_id'] : 1; } } else { $table->access = $this->params->get('base_default-access', 1); if (!isset($data['parent_id'])) { $data['parent_id'] = $this->params->get('base_default-parent_id', 1); } } if ($user->get('id') > 0 && @$user->guest != 1 && !isset($data[self::$author]) && !$force) { $data[self::$author] = $user->get('id'); } } else { $data[self::$key] = $table->{self::$key}; } if ($table->parent_id != $data['parent_id'] || $data['id'] == 0) { $table->setLocation($data['parent_id'], 'last-child'); } $table->{self::$custom} = ''; }
<?php /** * @version SEBLOD 3.x Core * @package SEBLOD (App Builder & CCK) // SEBLOD nano (Form Builder) * @url http://www.seblod.com * @editor Octopoos - www.octopoos.com * @copyright Copyright (C) 2013 SEBLOD. All Rights Reserved. * @license GNU General Public License version 2 or later; see _LICENSE.php **/ defined('_JEXEC') or die; JCckDev::initScript('field', $this->item, array('hasOptions' => true, 'doTranslation' => 1, 'customAttr' => JCck::getConfig_Param('development_attr', 6))); $options = JCckDev::fromSTRING($this->item->options); ?> <div class="seblod"> <?php echo JCckDev::renderLegend(JText::_('COM_CCK_CONSTRUCTION'), JText::_('PLG_CCK_FIELD_' . $this->item->type . '_DESC')); ?> <ul class="adminformlist adminformlist-2cols"> <?php echo JCckDev::renderForm('core_label', $this->item->label, $config); echo JCckDev::renderForm('core_defaultvalue', $this->item->defaultvalue, $config); echo JCckDev::renderForm('core_sorting', $this->item->sorting, $config); echo '<li><label>' . JText::_('COM_CCK_ORIENTATION') . '</label>' . JCckDev::getForm('core_orientation', $this->item->bool, $config) . JCckDev::getForm('core_orientation_vertical', $this->item->bool2, $config) . '</li>'; echo JCckDev::renderForm('core_options', $options, $config); echo JCckDev::renderForm('core_separator', $this->item->divider, $config); echo JCckDev::renderForm('core_bool', $this->item->bool7, $config, array('label' => 'Check All Toggle', 'defaultvalue' => '0', 'options' => 'Hide=0||Show=optgroup||Above=1||Below=2', 'storage_field' => 'bool7')); echo JCckDev::renderHelp('field', 'seblod-2-x-checkbox-field'); echo JCckDev::renderSpacer(JText::_('COM_CCK_STORAGE'), JText::_('COM_CCK_STORAGE_DESC')); echo JCckDev::getForm('core_storage', $this->item->storage, $config);
<?php /** * @version SEBLOD 3.x Core * @package SEBLOD (App Builder & CCK) // SEBLOD nano (Form Builder) * @url http://www.seblod.com * @editor Octopoos - www.octopoos.com * @copyright Copyright (C) 2013 SEBLOD. All Rights Reserved. * @license GNU General Public License version 2 or later; see _LICENSE.php **/ defined('_JEXEC') or die; $count = JCck::getConfig_Param('development_attr', 6); $location = JCckDev::fromSTRING($this->item->location); $options = JCckDev::fromSTRING($this->item->options); $options2 = JCckDev::fromJSON($this->item->options2); ?> <div class="seblod"> <?php echo JCckDev::renderLegend(JText::_('COM_CCK_CONSTRUCTION'), JText::_('PLG_CCK_FIELD_' . $this->item->type . '_DESC')); ?> <ul class="adminformlist adminformlist-2cols"> <?php echo JCckDev::renderForm('core_label', $this->item->label, $config); echo JCckDev::renderForm('core_defaultvalue', $this->item->defaultvalue, $config); echo JCckDev::renderForm('core_query', $this->item->bool2, $config); echo JCckDev::renderForm('core_selectlabel', $this->item->selectlabel, $config); // 1 echo JCckDev::renderForm('core_options_query', @$options2['query'], $config, array(), array(), 'w100'); // 2 echo JCckDev::renderForm('core_options_table', @$options2['table'], $config);
public static function getRouteParams($name) { static $params = array(); if ($name == '') { return array(); } if (!isset($params[$name])) { $object = JCckDatabase::loadObject('SELECT a.storage_location, a.options FROM #__cck_core_searchs AS a WHERE a.name = "' . $name . '"'); $object->options = json_decode($object->options); $params[$name] = array(); $params[$name]['doSEF'] = isset($object->options->sef) && $object->options->sef != '' ? $object->options->sef : JCck::getConfig_Param('sef', '2'); $params[$name]['join_key'] = 'pk'; $params[$name]['location'] = $object->storage_location ? $object->storage_location : 'joomla_article'; } return $params[$name]; }
$isCached = ' [Cache=ON]'; } else { if (${$target}->content > 0) { $data = CCK_List::render($items, ${$target}, $path, $preconfig['client'], $config['Itemid'], $options, $config); } $isCached = ' [Cache=OFF]'; } } else { $isCached = ''; $no_message = $options->get('message', ''); $no_action = $options->get('action', ''); $no_style = $options->get('message_style', 'message'); if (!$no_message) { $no_message = JText::_('COM_CCK_NO_RESULT'); } else { if (JCck::getConfig_Param('language_jtext', 0)) { $no_message = JText::_('COM_CCK_' . str_replace(' ', '_', trim($no_message))); } } if ($no_style) { if ($no_style == '-1') { $data = $no_message; } else { $app->enqueueMessage($no_message, $no_style); } } if ($no_action) { if ($no_action == 'auto_redirect') { if (isset($fields['cck']) && !$fields['cck']->live && $fields['cck']->live_value) { $uri = $_SERVER["HTTP_REFERER"]; $return = base64_encode($uri);
public function finalize() { $doc = JFactory::getDocument(); $js = ''; // Computation if ($this->mode == 'form' && $this->config['doComputation']) { $format = JCck::getConfig_Param('computation_format', 0); if (!$format) { $format = JText::_('COM_CCK_COMPUTATION_FORMAT_AUTO'); } $doc->addScript(JURI::root(true) . '/media/cck/js/cck.calculation-3.0.0.min.js'); if (!($format == '1,234,567.89' || $format == 'COM_CCK_COMPUTATION_FORMAT_AUTO')) { if ($format == '1 234 567.89') { $search = '/(-?\\$?)(\\d+( \\d{3})*(\\.\\d{1,})?|\\.\\d{1,})/g'; $replace = 'v.replace(/[^0-9.\\-]/g, "")'; $sepD = '.'; $sepT = ' '; } elseif ($format == '1 234 567,89') { $search = '/(-?\\$?)(\\d+( \\d{3})*(,\\d{1,})?|,\\d{1,})/g'; $replace = 'v.replace(/[^0-9,\\-]/g, "").replace(/,/g, ".")'; $sepD = ','; $sepT = ' '; } elseif ($format == '1.234.567,89') { $search = '/(-?\\$?)(\\d+(\\.\\d{3})*(,\\d{1,})?|,\\d{1,})/g'; $replace = 'v.replace(/[^0-9,\\-]/g, "").replace(/,/g, ".")'; $sepD = ','; $sepT = '.'; } $formatNumber = JCck::getConfig_Param('computation_format_out', 0) ? 'formatNumber:1, ' : ''; $doc->addScriptDeclaration('jQuery.Calculation.setDefaults({ ' . $formatNumber . 'sepDecimals:"' . $sepD . '", sepThousands:"' . $sepT . '", reNumbers:' . $search . ', cleanseNumber:function (v){ return ' . $replace . '; } });'); } elseif (JCck::getConfig_Param('computation_format_out', 0)) { $doc->addScriptDeclaration('jQuery.Calculation.setDefaults({ formatNumber:1 });'); } } if (count($this->config['computation'])) { $computation = ''; foreach ($this->config['computation'] as $event => $compute) { $ids = array(); if (count($compute)) { foreach ($compute as $k => $v) { $computation .= $v['js'] . ' '; $ids_k = explode(',', $v['_']); $ids = array_merge($ids, $ids_k); } } $ids = implode(', ', array_unique($ids)); if ($event != 'none') { $this->js .= '$("' . $ids . '").bind("' . $event . '", JCck.Core.recalc);'; } } $js = 'JCck.Core.recalc = function() {' . $computation . '}'; $this->js .= 'JCck.Core.recalc();'; } // Stuff if ($this->css != '') { $doc->addStyleDeclaration($this->css); } if ($this->js != '') { $doc->addScriptDeclaration('(function ($){' . $js . "\n" . '$(document).ready(function(){' . $this->js . '});})(jQuery);'); } if ($this->js2 != '') { $doc->addScriptDeclaration('(function ($){$(window).load(function(){' . $this->js2 . '});})(jQuery);'); } }
public function preStore($data) { $mode = JCck::getConfig_Param('multisite_integration', '1'); $groups = explode(',', $data['type']); $guest_only = count($groups) > 1 ? 1 : 0; $sitetitle = $data['title']; $sitename = $data['name']; $sitemail = JFactory::getConfig()->get('mailfrom'); $sitemail = substr($sitemail, strpos($sitemail, '@')); $users = array(); $usergroups = array(); $next_level = 0; require_once JPATH_LIBRARIES . '/joomla/user/user.php'; // Guest Group $guest_group = $mode ? $this->_addGroup($sitetitle, 1) : $this->_addGroup('Public' . ' - ' . $sitetitle, 1); $parent_id = $guest_group; $usergroups[] = $guest_group; if ($guest_only) { //$guest_group = ( $mode ) ? $this->_addGroup( 'Guest Only', $guest_group ) : $this->_addGroup( 'Guest Only' .' - '. $sitetitle, 1 ); // WAITING FOR JOOMLA 1.7.x FIX $guest_group = $mode ? $this->_addGroup('Guest Only' . ' - ' . $sitetitle, $guest_group) : $this->_addGroup('Guest Only' . ' - ' . $sitetitle, 1); } // Guest User $data['guest'] = $this->_addUser('', $sitetitle, $sitemail, array(0 => $guest_group)); // Groups $special = 0; $root = $this->_getRootAsset(); $rules = array(); foreach ($groups as $k => $g) { $group = JTable::getInstance('usergroup'); $group->load($g); if ($mode == 1) { //$parent_id = $this->_addGroup( $group->title, $parent_id ); $parent_id = $this->_addGroup($group->title . ' - ' . $sitetitle, $parent_id); // WAITING FOR JOOMLA 1.7.x FIX $usergroups[] = $parent_id; if ($special == 0) { $this->_updateViewlevel(2, $parent_id); $special++; } if (($g == 6 || $g == 7) && $special == 1) { $this->_updateViewlevel(3, $parent_id); $special++; if ($g == 7) { $this->_prepareRules($root, $rules, 6, $parent_id); } } $this->_prepareRules($root, $rules, $g, $parent_id); } else { $parent_id = $g; $usergroups[] = $this->_addGroup($group->title . ' - ' . $sitetitle, $parent_id); } $users[$k] = $this->_addUser($group->title, $sitetitle, $sitemail); if ($g < 6) { $levels[$k] = $this->_addViewlevel($sitetitle . ' - ' . $group->title, array(), $next_level); } } $data['groups'] = $usergroups; if ($mode == 1) { $this->_updateRootAsset($root, $rules); } // Users krsort($users); $accounts = array(); $usergroups[] = 0; foreach ($users as $u) { array_pop($usergroups); $u->groups = $usergroups; $u->save(); if ($u->authorise('core.login.admin')) { $accounts[] = (object) array('username' => $u->username, 'password' => $u->password_clear, 'location' => 'admin'); } else { $accounts[] = (object) array('username' => $u->username, 'password' => $u->password_clear, 'location' => 'site'); } } // Guest Viewlevel $usergroups = $data['groups']; if ($guest_only) { $data['guest_only_group'] = $guest_group; $usergroups[] = $guest_group; $guest_viewlevel = $this->_addViewlevel($sitetitle, $usergroups, $next_level); $usergroups = $data['groups']; $data['guest_only_viewlevel'] = $this->_addViewlevel($sitetitle . ' - ' . 'Guest Only', array(0 => $guest_group), $next_level); } else { $guest_viewlevel = $this->_addViewlevel($sitetitle, $usergroups, $next_level); } // Viewlevels $viewlevels[] = $guest_viewlevel; foreach ($levels as $l) { array_shift($usergroups); $levels = array('title' => $l->title, 'rules' => $usergroups); $l->bind($levels); if (is_null($l->ordering)) { $l->ordering = ++$next_level; } $l->store(); $viewlevels[] = $l->id; } $data['viewlevels'] = $viewlevels; $this->_sendSiteMail($data, $accounts); return $data; }
<?php /** * @version SEBLOD 3.x Core ~ $Id: default.php sebastienheraud $ * @package SEBLOD (App Builder & CCK) // SEBLOD nano (Form Builder) * @url http://www.seblod.com * @editor Octopoos - www.octopoos.com * @copyright Copyright (C) 2013 SEBLOD. All Rights Reserved. * @license GNU General Public License version 2 or later; see _LICENSE.php **/ defined('_JEXEC') or die; $app = JFactory::getApplication(); Helper_Include::addScriptDeclaration($this->config['javascript']); if (JCck::getConfig_Param('validation', 2) > 1 && $this->config['validation'] != '') { Helper_Include::addValidation($this->config['validation'], $this->config['validation_options']); $js = 'if (task == "form.cancel") { Joomla.submitform(task, document.getElementById("seblod_form")); } else { if (jQuery("#seblod_form").validationEngine("validate",task) === true) { if (jQuery("#seblod_form").isStillReady() === true) { jQuery("#seblod_form input[name=\'config[unique]\']").val("seblod_form"); Joomla.submitform(task, document.getElementById("seblod_form")); } } }'; } else { $js = 'if (jQuery("#seblod_form").isStillReady() === true) { jQuery("#seblod_form input[name=\'config[unique]\']").val("seblod_form"); Joomla.submitform(task, document.getElementById("seblod_form")); }'; } ?> <script type="text/javascript"> <?php echo $this->config['submit']; ?> = function(task) { <?php echo $js; ?> } </script>
public function download() { $app = JFactory::getApplication(); $id = $app->input->getInt('id', 0); $fieldname = $app->input->getString('file', ''); $collection = $app->input->getString('collection', ''); $xi = $app->input->getString('xi', 0); $client = $app->input->getString('client', 'content'); $restricted = ''; $user = JFactory::getUser(); if (!$id) { $file = $fieldname; $path = JPATH_ROOT . '/' . $file; $paths = JCck::getConfig_Param('media_paths', ''); if ($paths != '') { $allowed = false; $paths = strtr($paths, array("\r\n" => '<br />', "\r" => '<br />', "\n" => '<br />')); $paths = explode('<br />', $paths); if (count($paths)) { $paths[] = 'tmp/'; foreach ($paths as $p) { if (strpos($path, JPATH_ROOT . '/' . $p) !== false) { $allowed = true; break; } } } if (!$allowed) { $this->setRedirect(JUri::root(), JText::_('COM_CCK_ALERT_FILE_NOT_AUTH'), "error"); return; } } elseif (strpos($path, JPATH_ROOT . '/tmp/') === false) { $this->setRedirect(JUri::base(), JText::_('COM_CCK_ALERT_FILE_NOT_AUTH'), "error"); return; } } else { $field = JCckDatabase::loadObject('SELECT a.* FROM #__cck_core_fields AS a WHERE a.name="' . ($collection != '' ? $collection : $fieldname) . '"'); //# $query = 'SELECT a.pk, a.author_id, a.cck as type, b.' . $field->storage_field . ' as value FROM #__cck_core AS a LEFT JOIN ' . $field->storage_table . ' AS b on b.id = a.pk WHERE a.id =' . (int) $id; $core = JCckDatabase::loadObject($query); switch ($field->storage) { //todo: call plugins! case 'custom': if ($collection != '') { $regex = CCK_Content::getRegex_Group($fieldname, $collection, $xi); preg_match($regex, $core->value, $matches); $value = $matches[1]; } else { $regex = CCK_Content::getRegex_Field($fieldname); preg_match($regex, $core->value, $matches); $value = $matches[1]; } break; case 'standard': default: $value = $core->value; break; } // Access // $current = JSite::getMenu()->getActive()->id; $clients = JCckDatabase::loadObjectList('SELECT a.fieldid, a.client, a.access, a.restriction, a.restriction_options FROM #__cck_core_type_field AS a LEFT JOIN #__cck_core_types AS b ON b.id = a.typeid' . ' WHERE a.fieldid = ' . (int) $field->id . ' AND b.name="' . (string) $core->type . '"', 'client'); $access = isset($clients[$client]->access) ? (int) $clients[$client]->access : 0; $autorised = $user->getAuthorisedViewLevels(); $restricted = isset($clients[$client]->restriction) ? $clients[$client]->restriction : ''; if (!($access > 0 && array_search($access, $autorised) !== false)) { $this->setRedirect('index.php', JText::_('COM_CCK_ALERT_FILE_NOT_AUTH'), "error"); return; } JPluginHelper::importPlugin('cck_field'); $dispatcher = JDispatcher::getInstance(); $config = array('client' => $client, 'id' => id, 'pk' => $core->pk, 'pkb' => 0); $field = JCckDatabase::loadObject('SELECT a.* FROM #__cck_core_fields AS a WHERE a.name="' . $fieldname . '"'); //# if ($restricted) { JPluginHelper::importPlugin('cck_field_restriction'); $field->restriction = $restricted; $field->restriction_options = $clients[$client]->restriction_options; $allowed = JCck::callFunc_Array('plgCCK_Field_Restriction' . $restricted, 'onCCK_Field_RestrictionPrepareContent', array(&$field, &$config)); if ($allowed !== true) { $this->setRedirect('index.php', JText::_('COM_CCK_ALERT_FILE_NOT_AUTH'), "error"); return; } } $dispatcher->trigger('onCCK_FieldPrepareContent', array(&$field, $value, &$config)); // Path Folder if ($collection != '') { $group_x = JCckDatabase::loadObject('SELECT a.options2 FROM #__cck_core_fields AS a WHERE a.name="' . $fieldname . '"'); $f_opt2 = JCckDev::fromJSON($group_x->options2); } else { $f_opt2 = JCckDev::fromJSON($field->options2); } $file = ''; if (isset($f_opt2['storage_format']) && $f_opt2['storage_format']) { $file .= $f_opt2['path']; $file .= isset($f_opt2['path_user']) && $f_opt2['path_user'] ? $core->author_id . '/' : ''; $file .= isset($f_opt2['path_content']) && $f_opt2['path_content'] ? $core->pk . '/' : ''; } $file .= $field->value; } $path = JPATH_ROOT . '/' . $file; if (is_file($path) && $file) { $size = filesize($path); $ext = strtolower(substr(strrchr($path, '.'), 1)); if ($ext == 'php' || $file == '.htaccess') { return; } $name = substr($path, strrpos($path, '/') + 1, strrpos($path, '.')); if ($path) { set_time_limit(0); @ob_end_clean(); include JPATH_ROOT . '/components/com_cck/download.php'; } } else { $this->setRedirect('index.php', JText::_('COM_CCK_ALERT_FILE_DOESNT_EXIST'), 'error'); } }
public function duplicate($pk) { $app = JFactory::getApplication(); $db = $this->getDbo(); $title = $app->input->getString('duplicate_title', ''); $user = JFactory::getUser(); if (!$user->authorise('core.create', COM_CCK)) { throw new Exception(JText::_('JERROR_CORE_CREATE_NOT_PERMITTED')); } $table = $this->getTable(); $table->load($pk, true); if ($table->id) { $table->id = 0; if ($title) { $table->title = $title; } else { $table->title .= ' (2)'; } $table->name = ''; if (!$table->check()) { throw new Exception($table->getError()); } $prefix = JCck::getConfig_Param('development_prefix', ''); if ($prefix) { $table->name = $prefix . '_' . $table->name; } // Template Styles $clients = array('search', 'filter', 'list', 'item'); $styles = JCckDatabase::loadObjectList('SELECT * FROM #__template_styles WHERE id IN (' . (int) $table->template_search . ',' . (int) $table->template_filter . ',' . (int) $table->template_list . ',' . (int) $table->template_item . ')', 'id'); foreach ($clients as $client) { $property = 'template_' . $client; $style = $styles[$table->{$property}]; if (!(is_object($style) && $style->id)) { $style = Helper_Workshop::getDefaultStyle($client == 'list' ? 'seb_table' : 'seb_one'); } $table->{$property} = Helper_Workshop::getTemplateStyleInstance($style->id, $style->template, $style->template, $style->params, $table->name . ' (' . $client . ')', true); } if (!$table->store()) { throw new Exception($table->getError()); } if (!$table->id) { return 0; } // Fields $query = 'SELECT a.*, b.storage_table FROM #__cck_core_search_field AS a LEFT JOIN #__cck_core_fields AS b ON b.id = a.fieldid WHERE a.searchid = ' . (int) $pk; $string = $this->_table_no_key_batch('query', $query, '#__cck_core_search_field', 'searchid', $table->id, array('storage_table')); // Positions $string = $this->_table_no_key_batch('where', 'searchid = ' . (int) $pk, '#__cck_core_search_position', 'searchid', $table->id); } }
protected function _render($context, &$article, $tpl, $contentType, $fields, $property, $client, $cck, $parent_type) { $app = JFactory::getApplication(); $dispatcher = JDispatcher::getInstance(); $user = JFactory::getUser(); $params = array('template' => $tpl['folder'], 'file' => 'index.php', 'directory' => $tpl['root']); $lang = JFactory::getLanguage(); $lang->load('com_cck_default', JPATH_SITE); JPluginHelper::importPlugin('cck_field'); JPluginHelper::importPlugin('cck_field_link'); JPluginHelper::importPlugin('cck_field_restriction'); $p_sef = isset($this->loaded[$contentType . '_' . $client . '_options']['sef']) ? $this->loaded[$contentType . '_' . $client . '_options']['sef'] : JCck::getConfig_Param('sef', '2'); $p_title = isset($this->loaded[$contentType . '_' . $client . '_options']['title']) ? $this->loaded[$contentType . '_' . $client . '_options']['title'] : ''; $p_typo = isset($this->loaded[$contentType . '_' . $client . '_options']['typo']) ? $this->loaded[$contentType . '_' . $client . '_options']['typo'] : 1; if ($p_typo) { JPluginHelper::importPlugin('cck_field_typo'); } jimport('cck.rendering.document.document'); $doc = CCK_Document::getInstance('html'); $positions = array(); if ($parent_type != '') { $w_type = '(b.name = "' . $contentType . '" OR b.name = "' . $parent_type . '")'; } else { $w_type = 'b.name = "' . $contentType . '"'; } if ($client == 'intro') { $positions_more = JCckDatabaseCache::loadObjectList('SELECT * FROM #__cck_core_type_position AS a LEFT JOIN #__cck_core_types AS b ON b.id = a.typeid' . ' WHERE ' . $w_type . ' AND a.client ="' . $client . '"', 'position'); // todo::improve } else { $positions_more = JCckDatabase::loadObjectList('SELECT * FROM #__cck_core_type_position AS a LEFT JOIN #__cck_core_types AS b ON b.id = a.typeid' . ' WHERE ' . $w_type . ' AND a.client ="' . $client . '"', 'position'); // todo::improve } // Fields if (count($fields)) { JPluginHelper::importPlugin('cck_storage'); $config = array('author' => 0, 'client' => $client, 'doSEF' => $p_sef, 'doTranslation' => JCck::getConfig_Param('language_jtext', 0), 'doTypo' => $p_typo, 'error' => 0, 'fields' => array(), 'id' => $cck->id, 'isNew' => 0, 'Itemid' => $app->input->getInt('Itemid', 0), 'location' => $cck->storage_location, 'pk' => $article->id, 'pkb' => $cck->pkb, 'storages' => array(), 'store_id' => (int) $cck->store_id, 'type' => $cck->cck, 'type_id' => (int) $cck->type_id, 'type_alias' => $cck->type_alias ? $cck->type_alias : $cck->cck); foreach ($fields as $field) { $field->typo_target = 'value'; $fieldName = $field->name; $value = ''; $name = !empty($field->storage_field2) ? $field->storage_field2 : $fieldName; //- if ($fieldName) { $Pt = $field->storage_table; if ($Pt && !isset($config['storages'][$Pt])) { $config['storages'][$Pt] = ''; $dispatcher->trigger('onCCK_Storage_LocationPrepareContent', array(&$field, &$config['storages'][$Pt], $config['pk'], &$config, &$article)); } $dispatcher->trigger('onCCK_StoragePrepareContent', array(&$field, &$value, &$config['storages'][$Pt])); if (is_string($value)) { $value = trim($value); } if ($p_title != '' && $p_title == $field->name) { $this->title = $value; } $hasLink = $field->link != '' ? 1 : 0; $dispatcher->trigger('onCCK_FieldPrepareContent', array(&$field, $value, &$config)); $target = $field->typo_target; if ($hasLink) { $dispatcher->trigger('onCCK_Field_LinkPrepareContent', array(&$field, &$config)); if ($field->link) { JCckPluginLink::g_setHtml($field, $target); } } if (@$field->typo && ($field->{$target} !== '' || $field->typo_label == -2) && $p_typo) { $dispatcher->trigger('onCCK_Field_TypoPrepareContent', array(&$field, $field->typo_target, &$config)); } else { $field->typo = ''; } $position = $field->position; $positions[$position][] = $fieldName; // Was it the last one? if ($config['error']) { break; } } } // Merge if (count($config['fields'])) { $fields = array_merge($fields, $config['fields']); // Test: a loop may be faster. $config['fields'] = NULL; unset($config['fields']); } } // BeforeRender if (isset($config['process']['beforeRenderContent']) && count($config['process']['beforeRenderContent'])) { foreach ($config['process']['beforeRenderContent'] as $process) { if ($process->type) { JCck::callFunc_Array('plg' . $process->group . $process->type, 'on' . $process->group . 'BeforeRenderContent', array($process->params, &$fields, &$config['storages'], &$config)); } } } // Finalize $doc->fields =& $fields; $infos = array('context' => $context, 'params' => $tpl['params'], 'path' => $tpl['path'], 'root' => JURI::root(true), 'template' => $tpl['folder'], 'theme' => $tpl['home']); $doc->finalize('content', $contentType, $client, $positions, $positions_more, $infos, $cck->id); $data = $doc->render(false, $params); $article->{$property} = str_replace($article->{$property}, $data, $article->{$property}); }