本文整理汇总了PHP中JCckDevHelper类的典型用法代码示例。如果您正苦于以下问题:PHP JCckDevHelper类的具体用法?PHP JCckDevHelper怎么用?PHP JCckDevHelper使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了JCckDevHelper类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: addScript
public static function addScript($url, $type = "text/javascript", $defer = false, $async = false)
{
$app = JFactory::getApplication();
if (!isset($app->cck_document)) {
$app->cck_document = array();
}
// Make sure to have only one inclusion of special external scripts
if (strpos($url, 'http') !== false) {
if (strpos($url, '//maps.googleapis.com/maps/api/js?') !== false) {
if (isset(self::$_urls['google_maps'])) {
$cur = self::$_urls['google_maps'];
$vars2 = JCckDevHelper::getUrlVars($url);
if (!$vars2->def('libraries')) {
return;
}
$vars = JCckDevHelper::getUrlVars($cur);
$libraries = array();
$libraries[$vars->get('libraries')] = '';
$libraries[$vars2->get('libraries')] = '';
$libraries = array_keys($libraries);
$url = str_replace('libraries=' . $vars2->get('libraries'), 'libraries=' . implode(',', $libraries), $url);
unset($app->cck_document['scripts'][$cur]);
}
self::$_urls['google_maps'] = $url;
}
}
$app->cck_document['scripts'][$url]['mime'] = $type;
$app->cck_document['scripts'][$url]['defer'] = $defer;
$app->cck_document['scripts'][$url]['async'] = $async;
}
示例2: onCCK_Storage_LocationAfterRender
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);
}
示例3: createThumb
public function createThumb($image, $tnumber, $twidth, $theight, $tformat, $quality = 100)
{
if (!($twidth && trim($twidth) != '' && is_numeric($twidth)) && !($theight && trim($theight) != '' && is_numeric($theight))) {
return false;
}
$path = $this->_pathinfo['dirname'];
$resImage = $this->_resource;
// Calcul Thumb Size
$values = $this->_prepareDimensions($this->_width, $this->_height, $twidth, $theight, $tformat);
list($thumbX, $thumbY, $newX, $newY, $thumbWidth, $thumbHeight, $newWidth, $newHeight) = $values;
// Add transparence for PNG
$thumbImage = imageCreateTrueColor($thumbWidth, $thumbHeight);
if ($this->_extension == 'png') {
imagealphablending($thumbImage, false);
}
// Generate thumb ressource
imagecopyresampled($thumbImage, $resImage, $thumbX, $thumbY, $newX, $newY, $thumbWidth, $thumbHeight, $newWidth, $newHeight);
// Set Folder
// $file_path ='';
if ($tnumber == 0) {
$thumbLocation = $path . '/' . $this->_pathinfo['basename'];
} else {
JCckDevHelper::createFolder($path . '/_thumb' . $tnumber);
$thumbLocation = $path . '/_thumb' . $tnumber . '/' . $this->_pathinfo['basename'];
}
// Create image
$this->_generateThumb($this->_extension, $thumbImage, $thumbLocation, $quality);
return true;
}
示例4: onCCK_FieldConstruct
public function onCCK_FieldConstruct($type, &$data = array())
{
if (self::$type != $type) {
return;
}
if ($data['json']['options2']['path'][strlen($data['json']['options2']['path']) - 1] != '/') {
$data['json']['options2']['path'] .= '/';
}
$data['json']['options2']['path'] = trim($data['json']['options2']['path']);
JCckDevHelper::createFolder(JPATH_SITE . '/' . $data['json']['options2']['path']);
parent::g_onCCK_FieldConstruct($data);
}
示例5: onCCK_FieldPrepareForm
public function onCCK_FieldPrepareForm(&$field, $value = '', &$config = array(), $inherit = array(), $return = false)
{
if (self::$type != $field->type) {
return;
}
self::$path = parent::g_getPath(self::$type . '/');
parent::g_onCCK_FieldPrepareForm($field, $config);
// Init
if (count($inherit)) {
$id = isset($inherit['id']) && $inherit['id'] != '' ? $inherit['id'] : $field->name;
$name = isset($inherit['name']) && $inherit['name'] != '' ? $inherit['name'] : $field->name;
} else {
$id = $field->name;
$name = $field->name;
}
$value = $value != '' ? $value : $field->defaultvalue;
$value = $value != ' ' ? $value : '';
// Validate
$validate = '';
if ($config['doValidation'] > 1) {
plgCCK_Field_ValidationRequired::onCCK_Field_ValidationPrepareForm($field, $id, $config);
$validate = count($field->validate) ? ' validate[' . implode(',', $field->validate) . ']' : '';
}
// Prepare
$assoc = JCckDevHelper::hasLanguageAssociations();
$form = '';
if ($assoc && $config['pk']) {
if (isset($config['base']->location) && $config['base']->location) {
$location = $config['base']->location;
} else {
$location = JCckdatabase::loadResult('SELECT storage_location FROM #__cck_core_types WHERE name = "' . $config['type'] . '"');
}
if (is_file(JPATH_SITE . '/plugins/cck_storage_location/' . $location . '/classes/helper.php')) {
require_once JPATH_SITE . '/plugins/cck_storage_location/' . $location . '/classes/helper.php';
$form = JCck::callFunc_Array('plgCCK_Storage_Location' . $location . '_Helper', 'getAssociationsForm', array($id, $name, $config));
}
}
// Set
if (!$field->variation) {
$field->form = $form;
if ($field->script) {
parent::g_addScriptDeclaration($field->script);
}
} else {
//
}
$field->value = $value;
// Return
if ($return === true) {
return $field;
}
}
示例6: export_variation
public function export_variation()
{
$app = JFactory::getApplication();
$model = $this->getModel();
$name = $app->input->getString('variation', '');
$folder = $app->input->getString('folder', '');
if ($file = $model->prepareExport_Variation($name, $folder)) {
$file = JCckDevHelper::getRelativePath($file, false);
$this->setRedirect(JUri::base() . 'index.php?option=com_cck&task=download&file=' . $file);
} else {
$this->setRedirect('index.php?option=com_cck&view=variations');
}
}
示例7: CckParseRoute
function CckParseRoute($segments)
{
$app = JFactory::getApplication();
$count = count($segments);
$menu = $app->getMenu();
$menuItem = $menu->getActive();
$vars = array();
if ($segments[0] == 'form') {
$menu->setActive($app->input->getInt('Itemid', 0));
$vars['option'] = 'com_cck';
$vars['view'] = 'form';
$vars['layout'] = 'edit';
$vars['type'] = $segments[1];
} else {
$legacy = 0;
// check later
if (!($menuItem->query['option'] == 'com_cck' && $menuItem->query['view'] == 'list')) {
$legacy = 0;
}
if (!$legacy) {
if (isset($menuItem->query['search'])) {
$params = JCckDevHelper::getRouteParams($menuItem->query['search']);
}
if (isset($params['location']) && $params['location'] && is_file(JPATH_SITE . '/plugins/cck_storage_location/' . $params['location'] . '/' . $params['location'] . '.php')) {
require_once JPATH_SITE . '/plugins/cck_storage_location/' . $params['location'] . '/' . $params['location'] . '.php';
JCck::callFunc_Array('plgCCK_Storage_Location' . $params['location'], 'parseRoute', array(&$vars, $segments, $count, $params));
} else {
$legacy = 1;
}
}
if ($legacy) {
if ($count == 2) {
$vars['option'] = 'com_content';
$vars['view'] = 'article';
$vars['catid'] = $segments[0];
$vars['id'] = $segments[1];
} elseif ($count == 1) {
$vars['option'] = 'com_content';
@(list($id, $alias) = explode(':', $segments[0], 2));
$category = JCategories::getInstance('Content')->get($id);
if ($category && $category->id == $id && $category->alias == $alias) {
$vars['view'] = 'categories';
} else {
$vars['view'] = 'article';
}
$vars['id'] = $segments[0];
}
}
}
return $vars;
}
示例8: prepareTable2
protected function prepareTable2(&$table, &$data)
{
if (is_array($data['elements'])) {
$data['elements'] = implode(',', $data['elements']);
} else {
$data['elements'] = '';
}
if (!$data['jform']['id'] && !$data['jform']['rules']) {
$data['jform']['rules'] = array('core.create' => array(), 'core.delete' => array(), 'core.delete.own' => array(), 'core.edit' => array(), 'core.edit.state' => array(), 'core.edit.own' => array());
}
if ($data['jform']['rules']) {
if (!is_array($data['jform']['rules'])) {
$data['jform']['rules'] = json_decode($data['jform']['rules']);
}
$rules = new JAccessRules(JCckDevHelper::getRules($data['jform']['rules']));
$table->setRules($rules);
}
}
示例9: onCCK_FieldPrepareForm
public function onCCK_FieldPrepareForm(&$field, $value = '', &$config = array(), $inherit = array(), $return = false)
{
if (self::$type != $field->type) {
return;
}
self::$path = parent::g_getPath(self::$type . '/');
parent::g_onCCK_FieldPrepareForm($field, $config);
// Init
if (count($inherit)) {
$id = isset($inherit['id']) && $inherit['id'] != '' ? $inherit['id'] : $field->name;
$name = isset($inherit['name']) && $inherit['name'] != '' ? $inherit['name'] : $field->name;
} else {
$id = $field->name;
$name = $field->name;
}
$value = $field->defaultvalue;
// Prepare
$value = JCckDevHelper::replaceLive($value);
if ($field->bool8) {
$field->bool8 = $config['doTranslation'];
}
if ($field->bool8) {
$value = trim(preg_replace('/[^A-Za-z0-9_ ]/', '', strip_tags($value)));
if ($value) {
$value = JText::_('COM_CCK_' . str_replace(' ', '_', $value));
}
}
$form = htmlspecialchars_decode($value);
// Set
if (!$field->variation) {
$field->form = $form;
if ($field->script) {
parent::g_addScriptDeclaration($field->script);
}
} else {
parent::g_getDisplayVariation($field, $field->variation, $value, $value, $form, $id, $name, '', '', '', $config);
}
$field->value = $value;
// Return
if ($return === true) {
return $field;
}
}
示例10: export
public function export()
{
$app = JFactory::getApplication();
$model = $this->getModel();
$recordId = $app->input->getInt('id', 0);
$elements = $app->input->getString('elements', '');
$elements = array_flip(explode(',', $elements));
$dependencies = array();
$menu = $app->input->getInt('dep_menu', 0);
$options = $app->input->get('options', array(), 'array');
if ($app->input->getInt('dep_categories', 0)) {
$dependencies['categories'] = 1;
}
if ($menu) {
$dependencies['menu'] = $menu;
}
if ($file = $model->prepareExport($recordId, $elements, $dependencies, $options)) {
$file = JCckDevHelper::getRelativePath($file, false);
$this->setRedirect(JUri::base() . 'index.php?option=com_cck&task=download&file=' . $file);
} else {
$this->setRedirect(_C0_LINK, JText::_('JERROR_AN_ERROR_HAS_OCCURRED'), 'error');
}
}
示例11: prepareTable2
protected function prepareTable2(&$table, &$data)
{
if (!$data['jform']['id'] && !$data['jform']['rules']) {
$data['jform']['rules'] = array('core.create' => array(), 'core.create.max.parent' => array('8' => "0"), 'core.create.max.parent.author' => array('8' => "0"), 'core.create.max.author' => array('8' => "0"), 'core.delete' => array(), 'core.delete.own' => array(), 'core.edit' => array(), 'core.edit.own' => array());
}
if ($data['jform']['rules']) {
if (!is_array($data['jform']['rules'])) {
$data['jform']['rules'] = json_decode($data['jform']['rules']);
}
jimport('cck.joomla.access.access');
$rules = new CCKRules(JCckDevHelper::getRules($data['jform']['rules']), 'com_cck', 'form');
$table->setRules($rules);
}
}
示例12: getRouteByStorage
public static function getRouteByStorage(&$storage, $sef, $itemId, $config = array(), $lang_tag = '')
{
if (isset($storage[self::$table]->_route) && !$lang_tag) {
return JRoute::_($storage[self::$table]->_route);
}
if ($sef) {
if ($sef == '0' || $sef == '1') {
$path = '&catid=' . $storage[self::$table]->catid;
} elseif ($sef[0] == '4') {
$path = '&catid=' . (isset($storage[self::$table]->category_alias) ? $storage[self::$table]->category_alias : $storage[self::$table]->catid);
} elseif ($sef[0] == '3') {
$path = '&typeid=' . $config['type'];
} else {
$path = '';
}
if (is_object($storage[self::$table])) {
$storage[self::$table]->_route = self::_getRoute($sef, $itemId, $storage[self::$table]->slug, $path);
}
// Multilanguage Associations
if (JCckDevHelper::hasLanguageAssociations()) {
$app = JFactory::getApplication();
$pk = $storage[self::$table]->id;
if ($app->input->get('view') == 'article' && $app->input->get('id') == $storage[self::$table]->id && !count(self::$routes)) {
JLoader::register('MenusHelper', JPATH_ADMINISTRATOR . '/components/com_menus/helpers/menus.php');
$assoc_c = JLanguageAssociations::getAssociations('com_content', '#__content', 'com_content.item', $pk);
$assoc_m = MenusHelper::getAssociations($itemId);
$languages = JLanguageHelper::getLanguages();
$lang_code = JFactory::getLanguage()->getTag();
foreach ($languages as $l) {
if ($lang_code == $l->lang_code) {
self::$routes[$l->lang_code] = $storage[self::$table]->_route;
} else {
$itemId2 = isset($assoc_m[$l->lang_code]) ? $assoc_m[$l->lang_code] : 0;
$pk2 = isset($assoc_c[$l->lang_code]) ? (int) $assoc_c[$l->lang_code]->id : 0;
self::$routes[$l->lang_code] = '';
if ($pk2 && $itemId2) {
self::$routes[$l->lang_code] = self::getRoute($pk2, $sef, $itemId2, $config, $l->sef);
}
}
}
}
}
} else {
require_once JPATH_SITE . '/components/com_content/helpers/route.php';
$storage[self::$table]->_route = ContentHelperRoute::getArticleRoute($storage[self::$table]->slug, $storage[self::$table]->catid, $storage[self::$table]->language);
}
return JRoute::_($storage[self::$table]->_route);
}
示例13: _core
protected function _core($data, &$config = array(), $pk = 0)
{
if (!$config['id']) {
$isNew = true;
$config['id'] = parent::g_onCCK_Storage_LocationPrepareStore();
} else {
$isNew = false;
}
// Init
$table = self::_getTable($pk);
$isNew = $pk > 0 ? false : true;
if (isset($table->tags)) {
$tags = $table->tags;
unset($table->tags);
} else {
$tags = null;
}
if (isset($data['tags'])) {
if (!empty($data['tags']) && $data['tags'][0] != '') {
$table->newTags = $data['tags'];
}
unset($data['tags']);
}
self::_initTable($table, $data, $config);
// Check Error
if (self::$error === true) {
return false;
}
// Prepare
if (is_array($data)) {
$table->bind($data);
}
if ($isNew && !isset($data['rules'])) {
$data['rules'] = array('core.create' => array(), 'core.delete' => array(), 'core.edit' => array(), 'core.edit.state' => array(), 'core.edit.own' => array());
}
if (isset($data['rules']) && $data['rules']) {
if (!is_array($data['rules'])) {
$data['rules'] = json_decode($data['rules']);
}
$rules = new JAccessRules(JCckDevHelper::getRules($data['rules']));
$table->setRules($rules);
}
$table->check();
self::_completeTable($table, $data, $config);
// Store
$dispatcher = JDispatcher::getInstance();
JPluginHelper::importPlugin('content');
$dispatcher->trigger('onContentBeforeSave', array(self::$context, &$table, $isNew));
if ($isNew === true && parent::g_isMax($table->{self::$author}, $table->{self::$parent}, $config)) {
return;
}
if (!$table->store()) {
JFactory::getApplication()->enqueueMessage($table->getError(), 'error');
if ($isNew) {
parent::g_onCCK_Storage_LocationRollback($config['id']);
}
return false;
}
// Checkin
parent::g_checkIn($table);
self::$pk = $table->{self::$key};
if (!$config['pk']) {
$config['pk'] = self::$pk;
}
$config['author'] = $table->{self::$author};
$config['parent'] = $table->{self::$parent};
parent::g_onCCK_Storage_LocationStore($data, self::$table, self::$pk, $config);
$dispatcher->trigger('onContentAfterSave', array(self::$context, &$table, $isNew));
// Associations
// todo
}
示例14: process
public function process()
{
// JSession::checkToken() or jexit( JText::_( 'JINVALID_TOKEN' ) );
if (!is_file(JPATH_ADMINISTRATOR . '/components/com_cck_toolbox/models/cck_toolbox.php')) {
$this->setRedirect($this->_getReturnPage(), JText::_('JERROR_AN_ERROR_HAS_OCCURRED'), 'error');
return;
}
$app = JFactory::getApplication();
$ids = $app->input->get('cid', array(), 'array');
$task_id = $app->input->getInt('tid', 0);
jimport('joomla.utilities.arrayhelper');
JArrayHelper::toInteger($ids);
require_once JPATH_ADMINISTRATOR . '/components/com_cck_toolbox/models/cck_toolbox.php';
$model = JModelLegacy::getInstance('CCK_Toolbox', 'CCK_ToolboxModel');
$params = JComponentHelper::getParams('com_cck_toolbox');
$output = 1;
// $params->get( 'output', 0 );
if ($file = $model->prepareProcess($params, $task_id, $ids)) {
if ($output > 0) {
$this->setRedirect($this->_getReturnPage(), JText::_('COM_CCK_SUCCESSFULLY_PROCESSED'), 'message');
} else {
$file = JCckDevHelper::getRelativePath($file, false);
$this->setRedirect(JUri::base() . 'index.php?option=com_cck&task=download&file=' . $file);
}
} else {
$this->setRedirect($this->_getReturnPage(), JText::_('JERROR_AN_ERROR_HAS_OCCURRED'), 'error');
}
}
示例15: getRouteByStorage
public static function getRouteByStorage(&$storage, $sef, $itemId, $config = array())
{
if (isset($storage[self::$table]->_route)) {
return JRoute::_($storage[self::$table]->_route);
}
if ($sef) {
if ($sef == '0' || $sef == '1') {
$path = '&catid=' . $storage[self::$table]->catid;
} elseif ($sef[0] == '4') {
$path = '&catid=' . (isset($storage[self::$table]->parent_alias) ? $storage[self::$table]->parent_alias : $storage[self::$table]->parent_id);
} elseif ($sef[0] == '3') {
$path = '&typeid=' . $config['type'];
} else {
$path = '';
}
if (is_object($storage[self::$table])) {
$storage[self::$table]->_route = self::_getRoute($sef, $itemId, $storage[self::$table]->slug, $path);
}
// Multilanguage Associations
if (JCckDevHelper::hasLanguageAssociations()) {
// TODO (mod_cck_lang...)
}
} else {
require_once JPATH_SITE . '/components/com_content/helpers/route.php';
$storage[self::$table]->_route = ContentHelperRoute::getCategoryRoute($storage[self::$table]->id);
}
return JRoute::_($storage[self::$table]->_route);
}