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 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; } }
protected function getInput() { JPluginHelper::importPlugin('cck_field'); require_once JPATH_PLUGINS . '/cck_field_validation/required/required.php'; $name = 'core_options'; $override = array('rows' => 1); $storage = (string) $this->element['cck_storage_field_prefix']; $and = $storage != '' ? ' AND a.storage_field LIKE "' . $storage . '%"' : ''; $fields = JCckDatabase::loadObjectList('SELECT a.title as text, a.name as value FROM #__cck_core_fields AS a' . ' WHERE a.storage = "dev" AND a.id > 500' . $and . ' ORDER BY text'); $fields = is_array($fields) ? array_merge(array(JHtml::_('select.option', '', '- ' . JText::_('COM_CCK_ADD_A_FIELD') . ' -')), $fields) : array(); $html = JHtml::_('select.genericlist', $fields, 'fields_list', 'size="1" class="inputbox select" style="max-width:175px;"', 'value', 'text', '', 'fields_list'); $format = (string) $this->element['js_format']; $lang = JFactory::getLanguage(); $lang->load('com_cck'); $lang->load('com_cck_default', JPATH_SITE); if ($format != 'raw') { JCck::loadjQuery(true, true, true); } $force_id = (string) $this->element['id']; $config = array('asset' => '', 'asset_id' => 0, 'client' => '', 'doTranslation' => 1, 'doValidation' => 2, 'pk' => ''); if ($format == 'raw') { $config['tmpl'] = 'ajax'; } $inherit = $force_id != '' ? array('id' => (string) $this->element['id']) : array(); $field = JCckDevField::getObject($name); if (!$field) { return; } $storage_field = $field->storage_field; $field->storage_field = $this->name; $field = JCckDevField::get($field, $this->value, $config, $inherit, $override); $script = $this->_addScripts((string) $this->element['name'], array('value' => $this->value), $format); return $field->form . $html . $script; }
public static function addSubmenu($option, $vName) { $addons = array(); $items = array(); $uix = JCck::getUIX(); $vName2 = JFactory::getApplication()->input->get('filter_e_type', ''); if (JCck::on()) { $folder = JText::_('COM_CCK_' . _C0_TEXT . 'S'); if ($uix == 'compact') { $items = array(array('name' => $folder, 'link' => _C0_LINK, 'active' => $vName == _C0_NAME), array('val' => '2', 'pre' => '', 'key' => 'COM_CCK_')); } else { $items = array(array('name' => $folder, 'link' => _C0_LINK, 'active' => $vName == _C0_NAME), array('val' => '2', 'pre' => '- ', 'key' => 'COM_CCK_', 'active' => $vName == _C2_NAME || $vName == _C6_NAME && $vName2 == 'type'), array('val' => '3', 'pre' => '- ', 'key' => ''), array('val' => '4', 'pre' => '- ', 'key' => 'COM_CCK_', 'active' => $vName == _C4_NAME || $vName == _C6_NAME && $vName2 == 'search'), array('val' => '1', 'pre' => '- ', 'key' => '', 'active' => $vName == _C1_NAME || $vName == _C7_NAME), array('val' => '5', 'pre' => '', 'key' => '')); } if ($vName == 'cck') { $addons = JCckDatabase::loadObjectList('SELECT a.title, a.link, b.element FROM #__menu AS a LEFT JOIN #__extensions AS b ON b.extension_id = a.component_id' . ' WHERE a.link LIKE "index.php?option=com_cck\\_%" ORDER BY a.title ASC'); } } else { $folder = '<img src="' . JROOT_MEDIA_CCK . '/images/12/icon-12-folders.png" border="0" alt=" " width="12" height="12" />'; if ($uix == 'compact') { $items = array(array('val' => '2', 'pre' => '', 'key' => 'COM_CCK_'), array('name' => $folder, 'link' => _C0_LINK, 'active' => $vName == _C0_NAME)); } else { $items = array(array('val' => '2', 'pre' => '', 'key' => 'COM_CCK_'), array('val' => '3', 'pre' => '', 'key' => ''), array('val' => '4', 'pre' => '', 'key' => 'COM_CCK_'), array('val' => '1', 'pre' => '', 'key' => ''), array('name' => $folder, 'link' => _C0_LINK, 'active' => $vName == _C0_NAME), array('val' => '5', 'pre' => '', 'key' => '')); } } self::addSubmenuEntries($option, $vName, $items, $addons); }
public static function onCCK_Storage_LocationAfterRender(&$buffer, &$data, $uri = array()) { $app = JFactory::getApplication(); if ($uri['layout']) { return; } if ($uri['view'] == 'featured') { $data['return_view'] = 'featured'; $tag = '&return=featured'; } else { $data['return_view'] = ''; $tag = ''; } $class = JCck::on('3.4') ? ' class="hasTooltip"' : ''; $data['doIntegration'] = false; $data['multilanguage'] = $data['options']->get('multilanguage', 0); if ($data['multilanguage']) { $data['search'] = '#<a' . $class . ' href="(.*)index.php\\?option=com_content&task=article.edit' . $tag . '&id=([0-9]*)" (.*)>#U'; } else { $data['search'] = '#<a' . $class . ' href="(.*)index.php\\?option=com_content&task=article.edit' . $tag . '&id=([0-9]*)"#'; } $data['search_alt'] = '#<a href = "javascript://" onclick="listItemTask\\(\'cb([0-9]*)\', \'articles.archive\'\\)">(.*)</a>#sU'; if (JCckDevHelper::hasLanguageAssociations() && $data['multilanguage']) { $query = 'SELECT a.pk, a.cck, b.key, c.language FROM #__cck_core AS a' . ' LEFT JOIN #__associations AS b ON ( b.id = a.pk AND context = "com_content.item" )' . ' LEFT JOIN #__content AS c ON c.id = a.pk' . ' WHERE storage_location="joomla_article"'; $list_assoc = JCckDatabase::loadObjectListArray('SELECT a.id, a.key, b.language FROM #__associations AS a LEFT JOIN #__content AS b ON ( b.id = a.id AND a.context = "com_content.item" )', 'key', 'language'); } else { $query = 'SELECT pk, cck FROM #__cck_core WHERE storage_location="joomla_article"'; $list_assoc = array(); } $list = JCckDatabase::loadObjectList($query, 'pk'); $buffer = JCckDevIntegration::rewriteBuffer($buffer, $data, $list, $list_assoc); }
public static function g_onCCK_PaymentValidate($data, $success, &$config) { $update = 'pay_return = "' . JCckDatabase::escape(json_encode($data['order'])) . '",' . 'pay_return_payments = "' . JCckDatabase::escape(json_encode($data['payments'])) . '",' . 'state = ' . $data['order_state']; JCckDatabase::execute('UPDATE #__cck_more_ecommerce_orders SET ' . $update . ' WHERE pay_key = "' . $config['pay_key'] . '"'); if (!$success) { return; } // Cart $cart_id = (int) JCckDatabase::loadResult('SELECT a.id FROM #__cck_more_ecommerce_carts AS a WHERE a.pay_key = "' . $config['pay_key'] . '"'); if ($cart_id) { JCckDatabase::execute('UPDATE #__cck_more_ecommerce_carts SET pay_key = "" WHERE id = ' . $cart_id); JCckDatabase::execute('DELETE a.* FROM #__cck_more_ecommerce_cart_product AS a WHERE a.cart_id = ' . $cart_id); } // Execute Processings (Invoice, Notifications, ...) if (JCckToolbox::getConfig()->get('processing', 0)) { $event = 'onCckPaymentSuccess'; $processing = JCckDatabaseCache::loadObjectListArray('SELECT type, scriptfile, options 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)) { $options = new JRegistry($p->options); include_once JPATH_SITE . $p->scriptfile; } } } } }
protected function prepareSidebar() { if (!JCck::on()) { return; } $buttons = array(); if (JCck::getUIX() == 'compact') { $core = array(array('val' => '2', 'pre' => '', 'key' => 'COM_CCK_')); } else { $core = array(array('val' => '0', 'pre' => '', 'key' => 'COM_CCK_', 'img' => 'cck-application'), array('val' => '2', 'pre' => '- ', 'key' => 'COM_CCK_', 'img' => 'cck-form'), array('val' => '3', 'pre' => '- ', 'key' => '', 'img' => 'cck-plugin'), array('val' => '4', 'pre' => '- ', 'key' => 'COM_CCK_', 'img' => 'cck-search'), array('val' => '1', 'pre' => '- ', 'key' => '', 'img' => 'cck-template'), array('val' => '5', 'pre' => '', 'key' => '', 'img' => 'cck-multisite')); } $components = JCckDatabase::loadObjectList('SELECT a.title, a.link, b.element' . ' FROM #__menu AS a LEFT JOIN #__extensions AS b ON b.extension_id = a.component_id' . ' WHERE a.link LIKE "index.php?option=com_cck\\_%"' . ' AND a.link NOT IN ("index.php?option=com_cck_toolbox&view=processing","index.php?option=com_cck_webservices&view=api")' . ' ORDER BY a.title ASC'); $groupedButtons = array(); $more = array('ADDON' => 16, 'PLUGIN_FIELD' => 19, 'PLUGIN_LINK' => 20, 'PLUGIN_LIVE' => 21, 'PLUGIN_RESTRICTION' => 112, 'PLUGIN_TYPOGRAPHY' => 24, 'PLUGIN_VALIDATION' => 25, 'TEMPLATE' => 27); foreach ($core as $k => $v) { $buttons[] = array('access' => array('core.manage', 'com_cck'), 'group' => 'COM_CCK_CORE', 'image' => $v['img'], 'link' => JRoute::_(constant('_C' . $v['val'] . '_LINK')), 'target' => '_self', 'text' => $v['pre'] . JText::_($v['key'] . constant('_C' . $v['val'] . '_TEXT') . 'S')); } foreach ($components as $k => $v) { $buttons[] = array('access' => array('core.manage', $v->element), 'group' => 'COM_CCK_SEBLOD_MORE', 'image' => 'cck-addon', 'link' => JRoute::_($v->link), 'target' => '_self', 'text' => $v->title); } foreach ($more as $k => $v) { $buttons[] = array('access' => array('core.manage', 'com_cck'), 'group' => 'COM_CCK_SEBLOD_COM', 'image' => 'download', 'link' => JRoute::_('http://www.seblod.com/products?seb_item_category=' . $v), 'target' => '_blank', 'text' => JText::_('COM_CCK_PANE_MORE_' . $k)); } foreach ($buttons as $button) { $groupedButtons[$button['group']][] = $button; } $this->sidebar = '<div class="sidebar-nav quick-icons">' . JHtml::_('links.linksgroups', $groupedButtons) . '</div>'; }
public function save($key = null, $urlVar = null) { 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); $id = $config['pk']; if ($config['validate'] == 'retry') { parent::display(); return true; } if ($id) { if ($config['stage'] > -1) { $link = 'index.php?option=' . CCK_COM . '&view=form&type=' . $preconfig['type'] . '&id=' . $id . $this->_getRedirectQuery(); if ($config['stage'] > 0) { $link .= '&stage=' . $config['stage']; } $this->setRedirect(htmlspecialchars_decode($link)); return; } 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 = ''; } } else { $msg = JText::_('JERROR_AN_ERROR_HAS_OCCURRED'); $msgType = 'error'; } switch ($task) { case 'apply': $link = 'index.php?option=' . CCK_COM . '&view=form&type=' . $preconfig['type'] . '&id=' . $id . $this->_getRedirectQuery(); break; case 'save2new': $link = 'index.php?option=' . CCK_COM . '&view=form&type=' . $preconfig['type'] . $this->_getRedirectQuery(); break; case 'save2view': $location = JCckDatabase::loadResult('SELECT storage_location FROM #__cck_core WHERE id = ' . (int) $id); $sef = 0; $itemId2 = 0; if ($location) { require_once JPATH_SITE . '/plugins/cck_storage_location/' . $location . '/' . $location . '.php'; $link = JCck::callFunc_Array('plgCCK_Storage_Location' . $location, 'getRoute', array($config['pk'], $sef, $itemId2, array('type' => $config['type']))); $link = str_replace('/administrator/', '/', $link); break; } default: $link = $this->_getRedirectQuery(true); break; } $this->setRedirect(htmlspecialchars_decode($link), $msg, $msgType); }
protected function _delete($pk, $location, $base) { $id = JCckDatabase::loadResult('SELECT id FROM #__cck_core WHERE storage_location = "' . (string) $location . '" AND pk = ' . (int) $pk); if (!$id) { return true; } $table = JCckTable::getInstance('#__cck_core', 'id', $id); $type = $table->cck; $pkb = (int) $table->pkb; $table->delete(); if ($pkb > 0) { $table = JTable::getInstance('content'); $table->delete($pkb); } $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_' . $type, $tables)) { $table = JCckTable::getInstance('#__cck_store_form_' . $type, 'id', $pk); if ($table->id) { $table->delete(); } } }
public static function getGateway() { $user = JFactory::getUser(); $access = implode(',', $user->getAuthorisedViewLevels()); $name = JCckDatabase::loadResult('SELECT type' . ' FROM #__cck_more_ecommerce_gateways' . ' WHERE published = 1 AND access IN (' . $access . ')' . ' ORDER BY id DESC'); return $name; }
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 onCCK_FieldExportField(&$field, &$data, &$extensions) { $field->options = self::_exportCategories($field->options, '||', $data); $name = $field->storage_field2 != '' ? $field->storage_field2 : $field->storage_field; $sql_table = '#__cck_store_join_' . $name; $sql_path = $data['root_sql'] . '/' . $sql_table . '.sql'; $sql_buffer = JCckDatabase::getTableCreate(array($sql_table)); JFile::write($sql_path, $sql_buffer); }
public static function loadResult($query) { static $cache = array(); $idx = md5($query); if (!isset($cache[$idx])) { $cache[$idx] = parent::loadResult($query); } return $cache[$idx]; }
public static function getTargets($id) { static $cache = array(); if (!isset($cache[$id])) { $cache[$id] = JCckDatabase::loadColumn('SELECT product_id FROM #__cck_more_ecommerce_promotion_product WHERE promotion_id = ' . (int) $id); $cache[$id] = array_flip($cache[$id]); } return $cache[$id]; }
public static function countItems($store_id, $object = 'joomla_article') { $cache = array(); $count = 0; $user = JFactory::getUser(); if (!isset($cache[$store_id])) { $cache[$store_id] = JCckDatabase::loadResult('SELECT COUNT(a.id) FROM #__cck_core AS a' . ' LEFT JOIN #__content AS b ON (b.id = a.pk AND a.storage_location = "joomla_article")' . ' WHERE a.store_id = ' . $store_id . ' AND b.state = 1'); } return $cache[$store_id]; }
public static function countItems($definition) { static $cache = array(); $count = 0; $user = JCck::getUser(); if (!isset($cache[$definition])) { $cache[$definition] = JCckDatabase::loadResult('SELECT COUNT(a.id) FROM #__cck_more_ecommerce_cart_product AS a' . ' LEFT JOIN #__cck_more_ecommerce_carts AS b ON b.id = a.cart_id WHERE b.type = "' . $definition . '" AND b.' . (string) $user->where_clause . ' AND b.state = 1'); } return $cache[$definition]; }
public static function authorise(&$field, &$config) { $user = JCck::getUser(); $check = JCckDatabase::loadResult('SELECT COUNT(a.id) FROM #__cck_more_ecommerce_order_product AS a LEFT JOIN #__cck_more_ecommerce_orders AS b ON b.id = a.order_id' . ' WHERE a.product_id = ' . $config['pk'] . ' AND b.user_id =' . $user->id); if ((int) $check > 0) { // } else { $field->display = 0; } }
public static function _setMultisite() { if ((int) self::getConfig_Param('multisite', 0)) { self::$_host = JURI::getInstance()->getHost(); self::$_sites = JCckDatabase::loadObjectList('SELECT id, title, name, guest, guest_only_viewlevel, groups, viewlevels, configuration, options FROM #__cck_core_sites WHERE published = 1', 'name'); return true; } else { return false; } }
public function getItems() { jimport('joomla.filesystem.folder'); $folders = JFolder::folders(JPATH_LIBRARIES . '/cck/rendering/variations'); $i = 0; $items = array(); $variations = array('empty' => '', 'joomla' => '', 'seb_css3' => '', 'seb_css3b' => ''); // Filter Search $location = $this->getState('filter.location'); $search = $this->getState('filter.search'); // Library if (count($folders) && $location != 'template_name') { foreach ($folders as $k => $v) { if ($search && strpos($v, $search) === false) { continue; } $items[$i] = new stdClass(); $items[$i]->folder = '/libraries/cck/rendering/variations/'; $items[$i]->template = ''; $items[$i]->title = $v; $items[$i]->type = isset($variations[$v]) ? 0 : 1; $items[$i++]->id = $i; } } // Templates if ($search && $location == 'template_name') { $templates = array(0 => $search); $search = ''; } else { $templates = JCckDatabase::loadColumn('SELECT name FROM #__cck_core_templates'); } if (count($templates)) { foreach ($templates as $k => $template) { $path = '/templates/' . $template . '/variations'; if (JFolder::exists(JPATH_SITE . $path)) { $folders = JFolder::folders(JPATH_SITE . $path); if (count($folders)) { foreach ($folders as $k => $v) { if ($search && strpos($v, $search) === false) { continue; } $items[$i] = new stdClass(); $items[$i]->folder = $path; $items[$i]->template = $template; $items[$i]->title = $v; $items[$i]->type = 1; $items[$i++]->id = $i; } } } } } return $items; }
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; }
function prepareDisplay() { $app = JFactory::getApplication(); $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->item->cck_type = $this->state->get('content_type', ''); $this->item->skip = $this->state->get('skip'); if (@$this->item->id > 0) { $this->isNew = 0; $this->panel_class = 'closed'; $this->panel_style = 'display:none; '; $name = $this->item->name; $app->setUserState(CCK_COM . '.edit.search.client', NULL); } else { $this->isNew = 1; $this->panel_class = 'open'; $this->panel_style = ''; $name = ''; if ($this->item->cck_type != '') { $this->item->storage_location = JCckDatabase::loadResult('SELECT storage_location FROM #__cck_core_types WHERE name = "' . $this->item->cck_type . '"'); if ($this->item->storage_location == 'none') { $this->item->storage_location = ''; } } $this->tpl_list = $this->state->get('tpl.list'); } $this->item->folder = Helper_Admin::getSelected($this->vName, 'folder', $this->item->folder, 1); $this->item->published = Helper_Admin::getSelected($this->vName, 'state', $this->item->published, 1); if ($this->item->skip != '') { $this->item->client = $this->item->skip; $this->item->master = $this->item->client == 'list' || $this->item->client == 'item' ? 'content' : ($this->item->client == 'order' ? 'order' : 'search'); $this->item->layer = $app->input->getString('layer', 'fields'); $P = 'template_' . $this->item->client; $force_template = $this->item->client == 'list' ? $this->state->get('tpl.list') : Helper_Workshop::getDefaultTemplate(); } else { $this->item->client = $this->isNew ? 'search' : $this->state->get('client', $app->input->cookie->getString('cck_search' . $name . '_client', 'search')); $this->item->master = $this->item->client == 'list' || $this->item->client == 'item' ? 'content' : ($this->item->client == 'order' ? 'order' : 'search'); $this->item->layer = $app->input->getString('layer', 'fields'); $P = 'template_' . $this->item->client; $force_template = $this->item->client == 'list' ? '' : Helper_Workshop::getDefaultTemplate(); } $this->style = $this->item->client != 'order' ? Helper_Workshop::getTemplateStyle($this->vName, $this->item->{$P}, $this->state->get('tpl.' . $this->item->client, $force_template)) : ''; $this->item->template = isset($this->style->template) ? $this->style->template : ''; $this->insidebox = Helper_Admin::addInsidebox($this->isNew); Helper_Admin::addToolbarEdit($this->vName, 'COM_CCK_' . _C4_TEXT, array('isNew' => $this->isNew, 'folder' => $this->state->get('filter.folder'), 'checked_out' => $this->item->checked_out), array('template' => $this->item->template)); }
protected function postSaveHook(CCKModelSite &$model, $validData = array()) { $recordId = $model->getState($this->context . '.id'); if ($recordId == 10 || $recordId == 500) { $db = JFactory::getDbo(); $params = JCckDatabase::loadResult('SELECT params FROM #__extensions WHERE element = "com_cck"'); $config = JCckDev::fromJSON($params, 'object'); $config->multisite = 1; $params = $db->escape(JCckDev::toJSON($config)); JCckDatabase::execute('UPDATE #__extensions SET params = "' . $params . '" WHERE element = "com_cck"'); } }
public function load($pk = null, $force = false) { $return = parent::load($pk); $k = $this->_tbl_key; if (!$return) { if ($force === true) { JCckDatabase::execute('INSERT INTO ' . $this->_tbl . ' (' . $k . ') VALUES (' . (int) $pk . ')'); $return = parent::load($pk); } } return $return; }
public static function quickSession($options, $id = 'featured_session') { $doc = JFactory::getDocument(); $css = ' ul.toolbar-tiplist {padding: 0px; margin-left:0px; margin-right:0px;} ul.toolbar-tiplist li { list-style: none; padding: 5px;} ul.toolbar-tiplist li:hover {background-color: #ffffff; -webkit-border-radius: 1px; -moz-border-radius: 1px; border-radius: 1px;} .ui-tooltip-grey .ui-tooltip-content{background-color: #ffffff;} .ui-tooltip-rounded .ui-tooltip-titlebar{-webkit-border-radius: 2px; -moz-border-radius: 2px; border-radius: 2px;} .ui-tooltip-rounded .ui-tooltip-titlebar + .ui-tooltip-content{-webkit-border-radius: 2px; -moz-border-radius: 2px; border-radius: 2px;} '; $doc->addStyleDeclaration($css); $doc->addStyleSheet(JURI::root(true) . '/media/cck/scripts/jquery-qtip/css/jquery.qtip.css'); JCck::loadjQuery(); $doc->addScript(JURI::root(true) . '/media/cck/scripts/jquery-qtip/js/jquery.qtip.min.js'); $title = JText::_('COM_CCK_SESSIONS_SAVE_SELECT'); $html = ''; $where = 'extension="' . $options['extension'] . '"'; if (isset($options['folder'])) { $where .= 'type="' . $options['folder'] . '"'; } if (isset($options['type'])) { $where .= 'type="' . $options['type'] . '"'; } $items = JCckDatabase::loadObjectList('SELECT id, title, type, options FROM #__cck_more_sessions WHERE ' . $where . ' ORDER BY title'); if (!count($items)) { return; } foreach ($items as $item) { $html .= '<li><a class="featured_sessions" href="javascript:void(0);" mydata="' . $item->type . '"' . 'mydata2="' . htmlspecialchars($item->options) . '">' . $item->title . '</a>' . '<img class="featured_sessions_del" src="' . JROOT_MEDIA_CCK . '/images/14/icon-14-trash.png" mydata="' . $item->id . '" /></li>'; } // Tooltip $html = '<div><ul class="toolbar-tiplist">' . $html . '</ul></div>' . '<div class="clr"></div>'; $search = array('.', '<', '>', '"', '%', ';'); $replace = array('\\.', '\\<', '\\>', '\\"', '\\%', '\\;'); $html = preg_replace("/(\r\n|\n|\r)/", " ", $html); $html = str_replace($search, $replace, $html); $js = ' jQuery(document).ready(function($){ $("#' . $id . '").qtip({ prerender: true, content: { text: "' . $html . '", title: { text: "' . $title . '" } }, hide: { event: "unfocus" }, style: { tip: true, classes: "ui-tooltip-grey ui-tooltip-rounded" }, position: { at: "right center", my: "left center", adjust: { x: 23 } } }); }); '; $doc->addScriptDeclaration($js); }
public function getItems() { if ($items = parent::getItems()) { $group_map = JCckDatabase::loadObjectList('SELECT a.group_id, COUNT( DISTINCT a.user_id ) AS num FROM #__user_usergroup_map AS a GROUP BY a.group_id', 'group_id'); foreach ($items as $item) { $viewlevels = $item->guest_only_viewlevel ? $item->guest_only_viewlevel . ',' . $item->viewlevels : $item->viewlevels; $query = 'SELECT COUNT(a.id) FROM #__cck_core AS a LEFT JOIN #__content AS b ON b.id = a.pk WHERE a.storage_location = "joomla_article" AND b.access IN (' . $viewlevels . ');'; $item->articles = JCckDatabase::loadResult($query); $groups = $item->guest_only_group ? $item->guest_only_group . ',' . $item->groups : $item->groups; $query = 'SELECT COUNT(DISTINCT a.user_id) FROM #__user_usergroup_map AS a WHERE a.group_id IN (' . $groups . ');'; $item->users = JCckDatabase::loadResult($query); } } return $items; }
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 getItems() { if ($items = parent::getItems()) { $templates = JCckDatabase::loadObjectList('SELECT a.folder, COUNT( a.folder ) AS num FROM #__cck_core_templates AS a GROUP BY a.folder', 'folder'); $types = JCckDatabase::loadObjectList('SELECT a.folder, COUNT( a.folder ) AS num FROM #__cck_core_types AS a GROUP BY a.folder', 'folder'); $fields = JCckDatabase::loadObjectList('SELECT a.folder, COUNT( a.folder ) AS num FROM #__cck_core_fields AS a GROUP BY a.folder', 'folder'); $searchs = JCckDatabase::loadObjectList('SELECT a.folder, COUNT( a.folder ) AS num FROM #__cck_core_searchs AS a GROUP BY a.folder', 'folder'); foreach ($items as $item) { $item->templates_nb = @$templates[$item->id]->num ? $templates[$item->id]->num : 0; $item->types_nb = @$types[$item->id]->num ? $types[$item->id]->num : 0; $item->fields_nb = @$fields[$item->id]->num ? $fields[$item->id]->num : 0; $item->searchs_nb = @$searchs[$item->id]->num ? $searchs[$item->id]->num : 0; } } return $items; }
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; $type = $this->item->e_type ? $this->item->e_type : 'type'; $this->item->title = JCckDatabase::loadResult('SELECT title FROM #__cck_core_' . $type . 's WHERE id = ' . (int) $this->item->e_id); Helper_Admin::addToolbarEdit($this->vName, _C6_TEXT, array('isNew' => $this->isNew, 'folder' => 0, 'checked_out' => $this->item->checked_out)); }
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; } }