public static function getRow($id, $content_type = '') { if (!$id) { return NULL; } $index = $id . '_' . $content_type; if (isset(self::$_items[$index])) { return self::$_items[$index]; } $row = JTable::getInstance('content'); $row->load($id); if (!$content_type) { $content_type = JCckDatabase::loadResult('SELECT cck FROM #__cck_core WHERE storage_location = "joomla_article" AND pk = ' . $row->id); } if ($content_type) { $fields = JCckDatabase::loadObject('SELECT * FROM #__cck_store_form_' . $content_type . ' WHERE id = ' . $row->id); if (count($fields)) { foreach ($fields as $k => $v) { $row->{$k} = $v; } } } self::$_items[$index] = $row; return $row; }
public static function processById($id = 0) { $processing = JCckDatabase::loadObject('SELECT type, scriptfile FROM #__cck_more_processings WHERE published = 1 AND id = ' . (int) $id); if (is_object($processing) && is_file(JPATH_SITE . $processing->scriptfile)) { include_once JPATH_SITE . $processing->scriptfile; } }
public function prepareExport($id = 0) { $config = JFactory::getConfig(); $tmp_path = $config->get('tmp_path'); $tmp_dir = uniqid('cck_'); $path = $tmp_path . '/' . $tmp_dir; $extension = JCckDatabase::loadObject('SELECT name, type, element, folder FROM #__extensions WHERE extension_id=' . (int) $id); if (!$extension) { return; } jimport('cck.base.install.export'); $name = $extension->element; $prefix = CCK_Export::getPrefix($extension->type); $src = JPATH_SITE . '/plugins/' . $extension->folder . '/' . $extension->element; $xml = JCckDev::fromXML($src . '/' . $name . '.xml'); $version = isset($xml->version) ? '_' . $xml->version : ''; $filename = $prefix . '_' . $extension->folder . '_' . $name . $version; $path_zip = $tmp_path . '/' . $filename . '.zip'; if (!$filename) { return; } if ($src && JFolder::exists($src)) { JFolder::copy($src, $path); CCK_Export::clean($path); } CCK_Export::exportLanguage($src . '/' . $name . '.xml', JPATH_ADMINISTRATOR, $path); CCK_Export::findFields(array($src . '/tmpl/edit.php', $src . '/tmpl/edit2.php'), $path . '/install'); return CCK_Export::zip($path, $path_zip); }
public static function getCall($name) { static $cache = array(); if (!isset($cache[$name])) { $cache[$name] = JCckDatabase::loadObject('SELECT b.name, b.type, b.options, a.request, a.request_object, a.request_options, a.response' . 'FROM #__cck_more_webservices_calls AS a' . ' LEFT JOIN #__cck_more_webservices AS b ON b.id = a.webservice' . ' WHERE a.name = "' . $name . '"'); } return $cache[$name]; }
public static function loadObject($query) { static $cache = array(); $idx = md5($query); if (!isset($cache[$idx])) { $cache[$idx] = parent::loadObject($query); } return $cache[$idx]; }
public static function &getUser($userid = 0, $content_type = '', $profile = true) { if (!$userid) { $user = JFactory::getUser(); } else { $user = JFactory::getUser($userid); } // Core if ($user->id && $user->guest != 1) { $user->session_id = null; $user->where_clause = 'user_id=' . $user->id; } else { $user->session_id = JFactory::getSession()->getId(); if (empty($user->session_id)) { $user->session_id = uniqid(); /* Not good, but better than empty */ } $user->where_clause = 'session_id="' . $user->session_id . '"'; } // IP $user->ip = getenv('REMOTE_ADDR'); // $_SERVER["REMOTE_ADDR"]; // More if ($user->id && $profile) { if (!$content_type) { $content_type = ''; // todo: config if (!$content_type) { $content_type = JCckDatabase::loadResult('SELECT cck FROM #__cck_core WHERE storage_location = "joomla_user" AND pk = ' . (int) $user->id); } } $db = JFactory::getDbo(); $prefix = $db->getPrefix(); $tables = $db->getTableList(); $tables = array_flip($tables); if (isset($tables[$prefix . 'cck_store_item_users'])) { $fields = JCckDatabase::loadObject('SELECT * FROM #__cck_store_item_users WHERE id = ' . (int) $user->id); if (count($fields)) { foreach ($fields as $k => $v) { $user->{$k} = $v; } } } if (isset($tables[$prefix . 'cck_store_form_' . $content_type])) { $fields = JCckDatabase::loadObject('SELECT * FROM #__cck_store_form_' . $content_type . ' WHERE id = ' . (int) $user->id); if (count($fields)) { foreach ($fields as $k => $v) { $user->{$k} = $v; } } } } return $user; }
public function delete($pk = null) { if ($this->id) { $clients = array('search', 'filter', 'list', 'item'); foreach ($clients as $client) { $Pf = 'template_' . $client; $style = JCckDatabase::loadObject('SELECT a.id, a.template FROM #__template_styles AS a' . ' WHERE a.template IN ( SELECT b.template FROM #__template_styles as b WHERE b.id = ' . (int) $this->{$Pf} . ' )' . ' ORDER BY a.id'); if ($style->id != $this->{$Pf}) { JCckDatabase::execute('DELETE a.* FROM #__template_styles AS a WHERE a.id=' . (int) $this->{$Pf}); } } JCckDatabase::execute('DELETE IGNORE a.*, b.*' . ' FROM #__cck_core_search_field AS a' . ' LEFT JOIN #__cck_core_search_position AS b ON b.searchid = a.searchid' . ' WHERE a.searchid=' . (int) $this->id); } return parent::delete(); }
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); // Prepare $app = JFactory::getApplication(); if ($app->input->get('option') == 'com_cck' && $app->input->get('view') == 'form') { $form = ''; $value = ''; } else { $alter = true; $alter_type_default = isset($inherit['alter_type_value']) ? $inherit['alter_type_value'] : ''; if (isset($config['item']->id) && $config['item']->id && isset($config['item']->storage_table) && $config['item']->storage_table != '') { $db = JFactory::getDbo(); $prefix = $db->getPrefix(); $table = str_replace('#__', $prefix, $config['item']->storage_table); $tables = $db->getTableList(); if (in_array($table, $tables)) { $column = JCckDatabase::loadObject('SHOW COLUMNS FROM ' . $table . ' WHERE field = "' . $config['item']->storage_field . '"'); $alter_type_value = isset($column->Type) ? strtoupper($column->Type) : $alter_type_default; } else { $alter = false; $alter_type_value = $alter_type_default; $alter_type_default = ''; } } else { $alter_type_value = $alter_type_default; $alter_type_default = ''; } ob_start(); include_once dirname(__FILE__) . '/tmpl/form.php'; $form = ob_get_clean(); } // Set $field->form = $form; $field->value = $value; // Return if ($return === true) { return $field; } }
public static function getStore($id) { static $cache = array(); if (!isset($cache[$id])) { $cache[$id] = JCckDatabase::loadObject('SELECT id, title, home, parent_id, parent_fee, parent_amount, options' . ' FROM #__cck_more_ecommerce_stores WHERE id = ' . (int) $id); $cache[$id]->options = new JRegistry($cache[$id]->options); } return $cache[$id]; }
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]; }
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'; }
public static function getRouteByStorage(&$storage, $sef, $itemId, $config = array()) { if (isset($storage[self::$table]->_route)) { return JRoute::_($storage[self::$table]->_route); } $bridge = JCckDatabase::loadObject('SELECT a.id, a.title, a.alias, a.catid, b.title AS category_title, b.alias AS category_alias' . ' FROM #__content AS a LEFT JOIN #__categories AS b ON b.id = a.catid' . ' WHERE a.id=' . (int) $config['pkb']); if (!is_object($bridge)) { $storage[self::$table]->_route = ''; return $storage[self::$table]->_route; } $bridge->slug = $bridge->alias ? $bridge->id . ':' . $bridge->alias : $bridge->id; if ($sef) { if ($sef == '0' || $sef == '1') { $path = '&catid=' . $bridge->catid; } elseif ($sef[0] == '4') { $path = '&catid=' . (isset($bridge->category_alias) ? $bridge->category_alias : $bridge->catid); } elseif ($sef[0] == '3') { $path = '&typeid=' . $config['type']; } else { $path = ''; } $storage[self::$table]->_route = plgCCK_Storage_LocationJoomla_Article::_getRoute($sef, $itemId, $bridge->slug, $path); } else { require_once JPATH_SITE . '/components/com_content/helpers/route.php'; $storage[self::$table]->_route = ContentHelperRoute::getArticleRoute($bridge->slug, $bridge->catid); } return JRoute::_($storage[self::$table]->_route); }
public static function getType($name, $id, $location = '') { // todo: API (move) $query = 'SELECT a.id, a.title, a.name, a.description, a.location, a.parent, a.storage_location, b.app as folder_app,' . ' a.options_admin, a.options_site, a.options_content, a.options_intro, a.template_admin, a.template_site, a.template_content, a.template_intro, a.stylesheets' . ' FROM #__cck_core_types AS a' . ' LEFT JOIN #__cck_core_folders AS b ON b.id = a.folder' . ' WHERE a.name ="' . (string) $name . '" AND a.published = 1'; return JCckDatabase::loadObject($query); }
public static function onCCK_Storage_LocationDelete($pk, &$config = array()) { $app = JFactory::getApplication(); $dispatcher = JDispatcher::getInstance(); $item = JCckDatabase::loadObject('SELECT id, cck as type, pk, storage_table FROM #__cck_core WHERE cck = "' . $config['type'] . '" AND pk = ' . (int) $pk); if (!is_object($item)) { return false; } $table = JCckTable::getInstance($item->storage_table, 'id'); $table->load($pk); if (!$table) { return false; } // Check $user = JCck::getUser(); $canDelete = $user->authorise('core.delete', 'com_cck.form.' . $config['type_id']); $canDeleteOwn = $user->authorise('core.delete.own', 'com_cck.form.' . $config['type_id']); if (!$canDelete && !$canDeleteOwn || !$canDelete && $canDeleteOwn && $config['author'] != $user->get('id') || $canDelete && !$canDeleteOwn && $config['author'] == $user->get('id')) { $app->enqueueMessage(JText::_('COM_CCK_ERROR_DELETE_NOT_PERMITTED'), 'error'); return; } // Process // -- onContentBeforeDelete? if (!$table->delete($pk)) { return false; } // Delete Core if ($item->id) { $table = JCckTable::getInstance('#__cck_core', 'id', $item->id); $table->delete(); } // Delete More $base = str_replace('#__', '', $item->storage_table); $tables = JCckDatabase::loadColumn('SHOW TABLES'); $prefix = JFactory::getConfig()->get('dbprefix'); if (in_array($prefix . 'cck_store_item_' . $base, $tables)) { $table = JCckTable::getInstance('#__cck_store_item_' . $base, 'id', $pk); if ($table->id) { $table->delete(); } } if (in_array($prefix . 'cck_store_form_' . $item->type, $tables)) { $table = JCckTable::getInstance('#__cck_store_form_' . $item->type, 'id', $pk); if ($table->id) { $table->delete(); } } // -- onContentAfterDelete? return true; }
protected function _setTemplateStyle($style) { $style = JCckDatabase::loadObject('SELECT template, params FROM #__template_styles WHERE id = ' . (int) $style); if (is_object($style)) { JFactory::getApplication()->setTemplate($style->template, $style->params); } }
<?php /** * @version SEBLOD 3.x Core ~ $Id: preview.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; // Prepare $field = JCckDatabase::loadObject('SELECT * FROM #__cck_core_fields WHERE name = "' . $this->item->name . '"'); $field->required_alert = ''; $field->selectlabel = trim($field->selectlabel) ? $field->selectlabel : ''; $field->variation = ''; $field->variation_override = ''; $field->restriction = ''; if ($field->type == 'checkbox' || $field->type == 'radio') { $field->bool = 1; } // Set $doc = JFactory::getDocument(); $doc->addStyleSheet(JURI::root(true) . '/media/cck/css/cck.admin.css'); $doc->addStyleDeclaration('div.cck_forms.cck_admin div.cck_form {float:none;}'); $doc->addScriptDeclaration('jQuery(document).ready(function($){ $("#titlebox").html("' . JText::_('COM_CCK_PREVIEW') . '"); $("#submitBox,#resetBox").hide(); });'); Helper_Include::addDependencies('box', 'edit'); ?> <div class="seblod preview"> <div align="center" style="text-align:center;">
protected function addToolbar($search) { $bar = JToolBar::getInstance('toolbar'); $canDo = Helper_Admin::getActions(); $separator = false; $title = empty($search->title) ? 'List' : $search->title; $user = JFactory::getUser(); require_once JPATH_COMPONENT . '/helpers/toolbar/link.php'; require_once JPATH_COMPONENT . '/helpers/toolbar/separator.php'; JToolBarHelper::title($title, 'stack'); if (!(is_object($search) && $search->id)) { return; } $form = JCckDatabase::loadResult('SELECT live_value FROM #__cck_core_search_field WHERE fieldid = 1 AND searchid = ' . $search->id . ' AND stage = 0'); if ($canDo->get('core.create') || $canDo->get('core.edit')) { $form = JCckDatabase::loadObject('SELECT id, name, location FROM #__cck_core_types WHERE name = "' . $form . '"'); if (is_object($form)) { $canCreate = $user->authorise('core.create', 'com_cck.form.' . $form->id); $creation = !$form->location || $form->location == 'admin' ? true : false; } else { $canCreate = false; $creation = false; } if ($canCreate && $creation) { $link = 'index.php?option=com_cck&view=form&type=' . $form->name . '&return_o=cck&return_v=list&return=' . base64_encode(JFactory::getURI()); $bar->prependButton('CckLink', 'new', JText::_('JTOOLBAR_NEW'), $link, '_self'); } } }
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'); } }
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); }
public function onCCK_Storage_LocationPrepareSearch($type, &$query, &$tables, &$t, &$config = array(), &$inherit = array(), $user) { if (self::$type != $type) { return; } // Init if (empty($inherit['table'])) { return; } $table = $inherit['table']; $keys = JCckDatabase::loadObject('SHOW KEYS FROM ' . $table . ' WHERE Key_name = "PRIMARY"'); // Prepare if (!isset($tables[$table])) { $tables[$table] = array('_' => 't' . $t++, 'fields' => array(), 'join' => 1, 'location' => self::$type); } $tables[$table]['key'] = isset($keys->Column_name) ? $keys->Column_name : 'id'; }
protected static function _getChild($parent, $config = array()) { $field = JCckDatabase::loadObject('SELECT a.* FROM #__cck_core_fields AS a WHERE a.name="' . $parent->extended . '"'); //# if (is_object($field)) { $field->access = @$parent->access; $field->variation = @$parent->variation; $field->variation_override = @$parent->variation_override; $field->required = @$parent->required; $field->required_alert = @$parent->required_alert; $field->validation = @$parent->validation; $field->validation_options = @$parent->validation_options; $field->restriction = @$parent->restriction; $field->restriction_options = @$parent->restriction_options; $field->computation = @$parent->computation; $field->computation_options = @$parent->computation_options; $field->conditional = @$parent->conditional; $field->conditional_options = @$parent->conditional_options; $field->link = ''; $field->link_options = ''; $field->typo = ''; $field->typo_label = ''; $field->typo_options = ''; $field->storage = $parent->storage; $field->storage_table = $parent->storage_table; $field->storage_field = $parent->storage_field; } return $field; }
public static function getText($id) { $obj = JCckDatabase::loadObject('SELECT s.id, s.introtext, s.fulltext FROM #__content AS s WHERE s.id=' . $id); $res = @$obj->introtext . @$obj->fulltext; return $res; }
protected static function _getTable($pk = 0, $join = false) { $table = JTable::getInstance('category'); if ($pk > 0) { $table->load($pk); if ($table->id) { if ($join) { // todo:join $join = JCckDatabase::loadObject('SELECT a.title, a.alias FROM #__categories AS a WHERE a.id = ' . $table->parent_id); //@ if (is_object($join) && isset($join->title)) { $table->parent_title = $join->title; $table->parent_alias = $join->alias; } else { $table->parent_title = ''; $table->parent_alias = ''; } } if (JCck::on('3.1')) { $table->tags = new JHelperTags(); $table->tags->getTagIds($table->id, 'com_content.category'); // todo: dynamic context per extension } } } return $table; }
function updateContent($id, $data_content = null, $data_more = null) { $this->_columns = $this->_getProperties(); $this->_instance_core = JTable::getInstance($this->_columns['table_object'][0], $this->_columns['table_object'][1]); if (!isset($id)) { return; } $base = JCckDatabase::loadObject('SELECT id, cck, pk, storage_location FROM #__cck_core WHERE storage_location = "' . (string) $this->_object . '" AND pk = ' . (int) $id); $this->_type = $base->cck; $this->_pk = $base->pk; $this->_id = $base->id; if (!$this->_columns['table']) { return; } $this->_table = $this->_columns['table']; $db = JFactory::getDbo(); //MAIN if (count($data_content) > 0) { // Create a new query object. $query = $db->getQuery(true); // Fields to update. foreach ($data_content as $key => $value) { $fields[] = $db->quoteName($key) . '=' . $db->quote($value); } // Conditions for which records should be updated. $conditions = array($db->quoteName('id') . '= ' . $id); $query->update($db->quoteName($this->_table))->set($fields)->where($conditions); // Set the query using our newly populated query object and execute it. $db->setQuery($query); $db->execute(); } $fields = null; //EXTRA if (count($data_more) > 0) { // Create a new query object. $query = $db->getQuery(true); $updatesession = 0; // Fields to update. foreach ($data_more as $key => $value) { //usergroup process if ($this->_object == "joomla_user" && $key == "usergroup") { //Check IF Exist $uid = $id; $table = '#__user_usergroup_map'; $query = $db->getQuery(true); // Fields to update. $fields2 = array($db->quoteName('user_id') . ' = ' . $db->quote($uid), $db->quoteName('group_id') . '= ' . $db->quote($value)); // Conditions for which records should be updated. $conditions2 = array($db->quoteName('user_id') . '= ' . $db->quote($uid)); $query->update($db->quoteName($table))->set($fields2)->where($conditions2); // Set the query using our newly populated query object and execute it. $db->setQuery($query); $db->execute(); } //FIELDX OR NOT if (!is_array($value)) { if (!($this->_object == "joomla_user" && $key == "usergroup")) { $fields[] = $db->quoteName($key) . '=' . $db->quote($value); } } else { $session =& JFactory::getSession(); $field_x = $session->get('seblodapi_fieldx'); //Get a db connection. if (!isset($field_x[$key])) { $query = $db->getQuery(true); $query->select($db->quoteName(array('extended', 'storage_table', 'storage_field'))); $query->from($db->quoteName('#__cck_core_fields')); $query->where($db->quoteName('type') . '= ' . $db->quote('field_x')); $query->where($db->quoteName('name') . '= ' . $db->quote($key)); $db->setQuery($query); $result = $db->loadObject(); $updatesession = 1; } else { $result = new stdClass(); $result->extended = $field_x[$key]['extended']; $result->storage_table = $field_x[$key]['storage_table']; $result->storage_field = $field_x[$key]['storage_field']; } $store = ""; if ($result) { $field_x[$key] = array("extended" => $result->extended, "storage_table" => $result->storage_table, "storage_field" => $result->storage_field); $counter = 0; $store .= "<br />::" . $key . "::" . count($value) . "::/" . $key . "::<br />"; if (isset($result->extended)) { foreach ($value as $fieldXValue) { $f_name = $result->extended; $store .= '<br />::' . $f_name . '|' . $counter . '|' . $key . '::' . $fieldXValue . '::/' . $f_name . '|' . $counter . '|' . $key . '::'; $counter++; } $store .= "<br />"; } //DO UPDATE INSTEAD $table = $field_x[$key]['storage_table']; $storagefield = $field_x[$key]['storage_field']; $extendedfield = $field_x[$key]['extended']; $cckfield = $key; $totalData = count($value); $value = $store; $check_update = $this->update_fieldX($id, $table, $extendedfield, $storagefield, $cckfield, $totalData, $value); } if ($updatesession == 1) { $session->set('seblodapi_fieldx', $field_x); } } } $query = $db->getQuery(true); // Conditions for which records should be updated. $conditions = array($db->quoteName('id') . '= ' . $id); $query->update($db->quoteName('#__cck_store_form_' . $this->_type))->set($fields)->where($conditions); // Set the query using our newly populated query object and execute it. $db->setQuery($query); $db->execute(); } return $this->_pk; }
public function prepareExport($id = 0, $elements = array(), $dependencies = array(), $options = array()) { $config = JFactory::getConfig(); $tmp_path = $config->get('tmp_path'); $tmp_dir = uniqid('cck_'); $path = $tmp_path . '/' . $tmp_dir; $folders = isset($elements['subfolders']) ? Helper_Folder::getBranch($id, ',') : $id; $folders = JCckDatabase::loadObjectList('SELECT * FROM #__cck_core_folders WHERE id IN (' . (string) $folders . ') ORDER BY lft'); if (!@$folders[0]) { return; } $isApp = false; $isCck = false; $name = $folders[0]->name; if (!$name) { return; } // Core jimport('joomla.filesystem.file'); jimport('cck.base.install.export'); $data = array('root' => $path, 'root_content' => $path . '/content', 'root_elements' => $path . '/elements', 'root_extensions' => $path . '/extensions', 'root_sql' => $path . '/sql', 'root_category' => '', 'elements' => array(), 'db_prefix' => $config->get('dbprefix')); $extensions = array(0 => (object) array('type' => 'plugin', 'id' => 'plg_system_blank', 'group' => 'system', '_file' => 'plg_system_blank.zip')); $data['folders'] = JCckDatabase::loadObjectList('SELECT id, name, path FROM #__cck_core_folders WHERE lft', 'id'); $data['folders2'] = JCckDatabase::loadObjectList('SELECT id, name, path FROM #__cck_core_folders WHERE lft', 'name'); $data['plugins'] = CCK_Export::getCorePlugins(); $data['plugins']['cck_field_live']['stage'] = true; $data['processings'] = JCckDatabase::loadObjectList('SELECT * FROM #__cck_more_processings', 'id'); $data['processings2'] = JCckDatabase::loadObjectList('SELECT folder FROM #__cck_more_processings', 'folder'); $data['styles'] = JCckDatabase::loadObjectList('SELECT * FROM #__template_styles', 'id'); $data['tables'] = array_flip(JCckDatabase::loadColumn('SHOW TABLES')); $data['tables_excluded'] = CCK_Export::getCoreTables(); $data['variations'] = array('empty' => true, 'joomla' => true, 'seb_css3' => true, 'seb_css3b' => true); // Copyright if (JCckDatabase::loadResult('SELECT extension_id FROM #__extensions WHERE type = "component" AND element = "com_cck_packager"') > 0) { $params = JComponentHelper::getParams('com_cck_packager'); $copyright = $params->get('copyright'); } else { $copyright = ''; } CCK_Export::createDir($data['root_content']); CCK_Export::createDir($data['root_elements']); CCK_Export::createDir($data['root_extensions']); CCK_Export::createDir($data['root_sql']); if (isset($dependencies['categories'])) { $data['root_category'] = CCK_Export::exportRootCategory($folders['0'], $data, $extensions); } if (isset($dependencies['menu'])) { $data['root_menu'] = CCK_Export::exportMenus($dependencies['menu'], $data, $extensions); } foreach ($folders as $i => $folder) { if ($i == 0) { if ($folder->path && $folder->path != $folder->name) { $branch = explode('/', $folder->path); array_pop($branch); if (count($branch)) { $parent_id = 2; foreach ($branch as $k => $v) { $elem = JCckDatabase::loadObject('SELECT * FROM #__cck_core_folders WHERE name = "' . (string) $v . '" AND parent_id = ' . (int) $parent_id); $parent_id = $elem->id; CCK_Export::createDir($data['root_elements'] . '/folder' . 's'); CCK_Export::exportElement('folder', $elem, $data, $extensions, 0); } } } } CCK_Export::exportElements('folder', $folders, $data, $extensions, 0, $copyright); if (isset($elements['fields'])) { $fields = JCckDatabase::loadObjectList('SELECT a.* FROM #__cck_core_fields AS a WHERE a.folder = ' . (int) $folder->id); CCK_Export::exportElements('field', $fields, $data, $extensions, 500, $copyright); } if (isset($elements['templates'])) { $templates = JCckDatabase::loadObjectList('SELECT a.* FROM #__cck_core_templates AS a WHERE a.folder = ' . (int) $folder->id); CCK_Export::exportElements('template', $templates, $data, $extensions, 0, $copyright); } if (isset($elements['types'])) { $types = JCckDatabase::loadObjectList('SELECT a.* FROM #__cck_core_types AS a WHERE a.folder = ' . (int) $folder->id); if (count($types)) { $isApp = true; } CCK_Export::exportElements('type', $types, $data, $extensions, 0, $copyright); } if (isset($elements['searchs'])) { $searchs = JCckDatabase::loadObjectList('SELECT a.* FROM #__cck_core_searchs AS a WHERE a.folder = ' . (int) $folder->id); if (count($searchs)) { $isApp = true; } CCK_Export::exportElements('search', $searchs, $data, $extensions, 0, $copyright); } } if (count($data['elements']['tables'])) { CCK_Export::exportTables($data); } if (count($data['elements']['processings'])) { $isCck = true; CCK_Export::exportProcessings($data, $extensions); } // Name & Root if ($isApp) { $filename = 'app_cck_' . $name; } else { if ($isCck) { $filename = 'cck_' . $name; } else { $filename = $name; } if (isset($dependencies['categories']) && file_exists($data['root_content'] . '/joomla_category')) { $items = JFolder::files($data['root_content'] . '/joomla_category', '\\.xml$'); if (count($items) == 1 && isset($items[0]) && $data['root_category'] != '' && JFile::stripExt($items[0]) == $data['root_category']) { JFolder::delete($data['root_content'] . '/joomla_category'); } } } // Elements if ($copyright) { CCK_Export::update($data['root_elements'], $copyright); } // Xml $folders[0]->description = 'SEBLOD 3.x ' . $folders[0]->title . ' App - www.seblod.com'; $folders[0]->name = $filename; $folders[0]->title = 'pkg_' . $folders['0']->name; $manifest = NULL; $xml = CCK_Export::preparePackage($folders[0]); if (is_object($xml)) { $manifest = JPATH_ADMINISTRATOR . '/manifests/packages/pkg_' . $filename . '.xml'; if (is_file($manifest)) { if ($copyright) { CCK_Export::update($manifest, $copyright); } $manifest = JCckDev::fromXML($manifest); $tags = array('copyright', 'creationDate', 'description', 'packager', 'packageurl', 'version'); if (is_object($manifest)) { foreach ($tags as $tag) { if (isset($manifest->{$tag}) && isset($xml->{$tag}) && $manifest->{$tag} != $xml->{$tag}) { $xml->{$tag} = (string) $manifest->{$tag}; } } } } } // Filename $path_zip = $tmp_path . '/' . $filename; if (isset($options['filename_version']) && $options['filename_version']) { $path_zip .= '_' . (isset($manifest->version) ? $manifest->version : '1.0.0'); } if (isset($options['filename_date']) && $options['filename_date']) { $path_zip .= '_' . JFactory::getDate()->format('Y_m_d'); } $path_zip .= '.zip'; // Script if (is_file(JPATH_ADMINISTRATOR . '/manifests/packages/' . $name . '/pkg_script.php')) { if ($copyright) { CCK_Export::update(JPATH_ADMINISTRATOR . '/manifests/packages/' . $name . '/pkg_script.php', $copyright); } } // todo: else $script = $xml->addChild('scriptfile', 'pkg_script.php'); JFile::copy(JPATH_SITE . '/libraries/cck/development/apps/script.php', $path . '/pkg_script.php'); $buffer = JFile::read($path . '/pkg_script.php'); $buffer = str_replace('%class%', $filename, $buffer); JFile::write($path . '/pkg_script.php', $buffer); if ($copyright) { CCK_Export::update($path . '/pkg_script.php', $copyright); } // Extensions $files = $xml->addChild('files'); $files->addAttribute('folder', 'extensions'); $names = array(); foreach ($extensions as $ext) { $file = $files->addChild('file', $ext->_file); $names[$ext->_file] = ''; foreach ($ext as $k => $v) { if ($k != '_file') { $file->addAttribute($k, $v); } } } if (isset($manifest->files->file) && count($manifest->files->file)) { foreach ($manifest->files->file as $f) { $f_name = (string) $f; if (!isset($names[$f_name])) { $f_file = array('_' => $f_name); $f_client = (string) $f->attributes()->client; $f_id = (string) $f->attributes()->id; $f_type = (string) $f->attributes()->type; if ($f_type == 'template') { $f_file['lang_root'] = JPATH_SITE; $f_file['src'] = JPATH_SITE . '/templates/' . (strpos($f_id, 'tpl_') !== false && strpos($f_id, 'tpl_') == 0 ? substr($f_id, 4) : $f_id); $f_file['lang_src'] = $f_file['src'] . '/templateDetails.xml'; } else { // todo } if (is_array($f_file) && $f_file['src'] != '') { CCK_Export::exportFile($f_type, $data, $f_file, array(), $copyright); $file = $files->addChild('file', $f_name); $file->addAttribute('type', $f_type); $file->addAttribute('id', $f_id); $file->addAttribute('client', $f_client); } } } } // Languages $dest = CCK_Export::createDir($path . '/languages'); $languages = JCckDatabase::loadColumn('SELECT element FROM #__extensions WHERE type = "language" AND client_id = 0'); if (count($languages)) { $lang = $xml->addChild('languages'); $lang->addAttribute('folder', 'languages'); foreach ($languages as $language) { if (is_file(JPATH_SITE . '/language/' . $language . '/' . $language . '.pkg_' . $filename . '.ini')) { $l = $lang->addChild('language', $language . '/' . $language . '.pkg_' . $filename . '.ini'); $l->addAttribute('tag', $language); CCK_Export::createDir($path . '/languages/' . $language); if ($copyright) { CCK_Export::update(JPATH_SITE . '/language/' . $language . '/' . $language . '.pkg_' . $filename . '.ini', $copyright); } JFile::copy(JPATH_SITE . '/language/' . $language . '/' . $language . '.pkg_' . $filename . '.ini', $dest . '/' . $language . '/' . $language . '.pkg_' . $filename . '.ini'); } if (is_file(JPATH_SITE . '/language/' . $language . '/' . $language . '.pkg_' . $filename . '.sys.ini')) { $l = $lang->addChild('language', $language . '/' . $language . '.pkg_' . $filename . '.sys.ini'); $l->addAttribute('tag', $language); CCK_Export::createDir($path . '/languages/' . $language); if ($copyright) { CCK_Export::update(JPATH_SITE . '/language/' . $language . '/' . $language . '.pkg_' . $filename . '.sys.ini', $copyright); } JFile::copy(JPATH_SITE . '/language/' . $language . '/' . $language . '.pkg_' . $filename . '.sys.ini', $dest . '/' . $language . '/' . $language . '.pkg_' . $filename . '.sys.ini'); } } } // Media if (file_exists(JPATH_SITE . '/media/cck/apps/' . $name)) { JFolder::copy(JPATH_SITE . '/media/cck/apps/' . $name, $path . '/media'); } // Manifest JFile::copy(JPATH_LIBRARIES . '/cck/base/install/_plg_system_blank.zip', $path . '/extensions/plg_system_blank.zip'); if (is_object($manifest) && isset($manifest->updateservers)) { $servers = $xml->addChild('updateservers'); if (count($manifest->updateservers->server)) { foreach ($manifest->updateservers->server as $server) { $s = $servers->addChild('server', (string) $server); $s->addAttribute('type', (string) $server->attributes()->type); $s->addAttribute('priority', (string) $server->attributes()->priority); $s->addAttribute('name', (string) $server->attributes()->name); } } } CCK_Export::clean($path); CCK_Export::createFile($path . '/pkg_' . $filename . '.xml', '<?xml version="1.0" encoding="utf-8"?>' . $xml->asIndentedXML()); if ($copyright) { CCK_Export::update($path . '/pkg_' . $filename . '.xml', $copyright); } return CCK_Export::zip($path, $path_zip); }
public static function rebuildBranch($root_id) { $app = ''; $branch = self::getBranch($root_id); $tree = self::getRoot($root_id); if (count($tree)) { foreach ($tree as $parent) { if ($parent->app) { $app = $parent->app; break; } } } if (!$app) { $isRoot = JCckDatabase::loadObject('SELECT name, home FROM #__cck_core_folders WHERE id = ' . (int) $root_id); if ($isRoot->home) { $app = $isRoot->name; } } if (count($branch)) { $set_app = $app ? ', app = "' . $app . '"' : ''; foreach ($branch as $folder) { $path = self::getPath($folder, '/'); JCckDatabase::doQuery('UPDATE #__cck_core_folders SET path = "' . (string) $path . '"' . $set_app . ' WHERE id = ' . (int) $folder); } } }
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 getTemplateStyle($vName, $selected, $default = '', $null = '') { $style = null; if ($selected != $null) { $style = JCckDatabase::loadObject('SELECT id, title, template, params FROM #__template_styles WHERE id=' . (int) $selected); } if (!$style) { $style = JCckDatabase::loadObject('SELECT id, title, template, params FROM #__template_styles WHERE template="' . (string) $default . '" ORDER BY id'); } if (!$style) { return $style; } $lang = JFactory::getLanguage(); $values = JCckDev::fromJSON($style->params); $style->xml = JPath::clean(JPATH_SITE . '/templates/' . $style->template . '/templateDetails.xml'); $lang->load('tpl_' . $style->template . '.sys', JPATH_SITE, null, false, true); $lang->load('tpl_' . $style->template, JPATH_SITE, null, false, true); $style->positions = array(); if (file_exists($style->xml)) { $xml = simplexml_load_file($style->xml); if (isset($xml->positions[0])) { foreach ($xml->positions[0] as $position) { $toggle = true; if (isset($position->attributes()->toggle) && (string) $position->attributes()->toggle) { $idx = (string) $position->attributes()->toggle; $val = isset($values[$idx]) ? $values[$idx] : 0; if (isset($position->attributes()->toggle_value)) { $value = (string) $position->attributes()->toggle_value; if (strpos($value, ',') !== false) { $values = explode(',', $value); if (count($values)) { $toggle2 = false; foreach ($values as $v) { if ($val == $v) { $toggle2 = true; } } if (!$toggle2) { $toggle = false; } } } else { if ($val != $value) { $toggle = false; } } } else { if (!$val) { $toggle = false; } } } if ($toggle) { $pos = (string) $position; $key = 'TPL_' . $style->template . '_POSITION_' . $pos; $label = $lang->hasKey($key) ? JText::_('TPL_' . $style->template . '_POSITION_' . $pos) : $pos; $style->positions[] = JHtml::_('select.option', $pos, $label); } } } } return $style; }
public static function renderContent($field, $value = '', &$config = array('doTranslation' => 1, 'doValidation' => 2)) { if (!is_object($field)) { $field = JCckDatabase::loadObject('SELECT a.* FROM #__cck_core_fields AS a WHERE a.name = "' . $field . '"'); //# if (!$field) { return; } } $dispatcher = JDispatcher::getInstance(); $dispatcher->trigger('onCCK_FieldPrepareContent', array(&$field, $value, &$config)); return JCck::callFunc_Array('plgCCK_Field' . $field->type, 'onCCK_FieldRenderContent', array($field, &$config)); }
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::root(), 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.id, a.pk, a.author_id, a.cck as type, a.storage_location, b.' . $field->storage_field . ' as value, c.id as type_id' . ' FROM #__cck_core AS a' . ' LEFT JOIN ' . $field->storage_table . ' AS b on b.id = a.pk' . ' LEFT JOIN #__cck_core_types AS c on c.name = a.cck' . ' WHERE a.id =' . (int) $id; $core = JCckDatabase::loadObject($query); $config = array('author' => $core->author_id, 'client' => $client, 'collection' => $collection, 'fieldname' => $fieldname, 'id' => $core->id, 'isNew' => 0, 'location' => $core->storage_location, 'pk' => $core->pk, 'pkb' => 0, 'task' => 'download', 'type' => $core->type, 'type_id' => $core->type_id, 'xi' => $xi); $dispatcher = JDispatcher::getInstance(); $field->value = $core->value; $pk = $core->pk; $value = ''; JPluginHelper::importPlugin('cck_storage'); $dispatcher->trigger('onCCK_StoragePrepareDownload', array(&$field, &$value, &$config)); // Access $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) $config['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(JUri::root(), JText::_('COM_CCK_ALERT_FILE_NOT_AUTH'), "error"); return; } JPluginHelper::importPlugin('cck_field'); $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(JUri::root(), JText::_('COM_CCK_ALERT_FILE_NOT_AUTH'), "error"); return; } } $dispatcher->trigger('onCCK_FieldPrepareDownload', array(&$field, $value, &$config)); $file = $field->filename; } $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) { $task2 = isset($field->task) ? $field->task : 'download'; if ($task2 == 'read') { $this->setRedirect(JURI::root(true) . '/' . $file); } else { if ($id) { $event = 'onCckDownloadSuccess'; if (JCckToolbox::getConfig()->get('processing', 0)) { $processing = JCckDatabaseCache::loadObjectListArray('SELECT type, scriptfile FROM #__cck_more_processings WHERE published = 1 ORDER BY ordering', 'type'); if (isset($processing[$event])) { foreach ($processing[$event] as $p) { if (is_file(JPATH_SITE . $p->scriptfile)) { include_once JPATH_SITE . $p->scriptfile; } } } } $this->_download_hits($id, $fieldname, $collection, $xi); } set_time_limit(0); @ob_end_clean(); include JPATH_ROOT . '/components/com_cck/download.php'; } } } else { $this->setRedirect(JUri::root(), JText::_('COM_CCK_ALERT_FILE_DOESNT_EXIST'), 'error'); } }