Пример #1
0
 public static function onCCK_Field_LinkPrepareContent(&$field, &$config = array())
 {
     if (self::$type != $field->link) {
         return;
     }
     // Prepare
     $link = parent::g_getLink($field->link_options);
     // Set
     $field->link = '';
     self::_link($link, $field, $config);
 }
Пример #2
0
 public function onCCK_FieldPrepareContent(&$field, $value = '', &$config = array())
 {
     if (self::$type != $field->type) {
         return;
     }
     self::$path = parent::g_getPath(self::$type . '/');
     parent::g_onCCK_FieldPrepareContent($field, $config);
     /*
     if ( !$field->state ) {
     	$field->value	=	'';
     	return;
     }
     // TODO: SEBLOD 3.7 while checking for all Restriction plug-in behaviors..
     */
     // Prepare
     $name = $field->name;
     $dispatcher = JDispatcher::getInstance();
     $fields = self::_getChildren($field, $config);
     $xn = 1;
     $content = array();
     for ($xi = 0; $xi < $xn; $xi++) {
         foreach ($fields as $f) {
             if (is_object($f)) {
                 $f_name = $f->name;
                 $f_value = '';
                 $inherit = array();
                 $content[$f_name] = clone $f;
                 $table = $f->storage_table;
                 if ($table && !isset($config['storages'][$table])) {
                     $config['storages'][$table] = '';
                     $dispatcher->trigger('onCCK_Storage_LocationPrepareForm', array(&$f, &$config['storages'][$table], $config['pk']));
                 }
                 $dispatcher->trigger('onCCK_StoragePrepareForm_Xi', array(&$f, &$f_value, &$config['storages'][$table], $name, $xi));
                 //
                 $dispatcher->trigger('onCCK_FieldPrepareContent', array(&$content[$f_name], $f_value, &$config, $inherit, true));
                 $target = $content[$f_name]->typo_target;
                 if ($content[$f_name]->link != '') {
                     $dispatcher->trigger('onCCK_Field_LinkPrepareContent', array(&$content[$f_name], &$config));
                     if ($content[$f_name]->link && !@$content[$f_name]->linked) {
                         JCckPluginLink::g_setHtml($content[$f_name], $target);
                     }
                 }
                 if (@$content[$f_name]->typo && $content[$f_name]->{$target} != '' && $config['doTypo']) {
                     $dispatcher->trigger('onCCK_Field_TypoPrepareContent', array(&$content[$f_name], $content[$f_name]->typo_target, &$config));
                 } else {
                     $content[$f_name]->typo = '';
                 }
                 $config['fields'][$f->name] = $content[$f_name];
             }
         }
     }
     // Set
     $field->value = $content;
 }
Пример #3
0
 public function onCCK_FieldPrepareContent(&$field, $value = '', &$config = array())
 {
     if (self::$type != $field->type) {
         return;
     }
     self::$path = parent::g_getPath(self::$type . '/');
     parent::g_onCCK_FieldPrepareContent($field, $config);
     // Prepare
     $name = $field->name;
     $dispatcher = JDispatcher::getInstance();
     $fields = self::_getChildren($field, $config);
     // TODO: call storage plugin.
     $xn = $field->storage == 'xml' ? is_object($value) ? count($value->children()) : count($value) : $value;
     $content = array();
     for ($xi = 0; $xi < $xn; $xi++) {
         foreach ($fields as $f) {
             if (is_object($f)) {
                 $f_name = $f->name;
                 $f_value = '';
                 $inherit = array('parent' => $field->name, 'xi' => $xi);
                 $content[$xi][$f_name] = clone $f;
                 //
                 if ($field->storage == 'custom') {
                     $f->storage = $field->storage;
                     $f->storage_table = $field->storage_table;
                     $f->storage_field = $field->storage_field;
                 }
                 $table = $f->storage_table;
                 if ($table && !isset($config['storages'][$table])) {
                     $config['storages'][$table] = '';
                     $dispatcher->trigger('onCCK_Storage_LocationPrepareForm', array(&$f, &$config['storages'][$table], $config['pk']));
                 }
                 $dispatcher->trigger('onCCK_StoragePrepareForm_Xi', array(&$f, &$f_value, &$config['storages'][$table], $name, $xi, $field));
                 //
                 $f_value2 = (string) $f_value;
                 $dispatcher->trigger('onCCK_FieldPrepareContent', array(&$content[$xi][$f_name], $f_value2, &$config, $inherit, true));
                 $target = $content[$xi][$f_name]->typo_target;
                 if ($content[$xi][$f_name]->link != '') {
                     $dispatcher->trigger('onCCK_Field_LinkPrepareContent', array(&$content[$xi][$f_name], &$config));
                     if ($content[$xi][$f_name]->link && !@$content[$xi][$f_name]->linked) {
                         JCckPluginLink::g_setHtml($content[$xi][$f_name], $target);
                     }
                 }
                 if (@$content[$xi][$f_name]->typo && $content[$xi][$f_name]->{$target} != '' && $config['doTypo']) {
                     $dispatcher->trigger('onCCK_Field_TypoPrepareContent', array(&$content[$xi][$f_name], $content[$xi][$f_name]->typo_target, &$config));
                 } else {
                     $content[$xi][$f_name]->typo = '';
                 }
             }
         }
     }
     $field->value = $content;
 }
Пример #4
0
 protected static function _link($link, &$field, &$config)
 {
     $app = JFactory::getApplication();
     $custom = $link->get('custom', '');
     $form = $link->get('form', '');
     $edit = $link->get('form_edition', 1);
     $edit = !$form && $edit ? '&id=' . $config['pk'] : '';
     $form = $form ? $form : $config['type'];
     $itemId = $link->get('itemid', $app->input->getInt('Itemid', 0));
     $redirection = $link->get('redirection', '');
     $uri = (string) JFactory::getUri();
     if (strpos($uri, 'format=raw&infinite=1') !== false) {
         $return = $app->input->get('return');
     } else {
         $return = base64_encode($uri);
     }
     if (!$form) {
         return;
     }
     // Check
     if ($edit != '') {
         static $cache = array();
         $stage = $link->get('form_edition_stage', '');
         if ($stage != '') {
             $edit .= '&stage=' . (int) $stage;
         }
         $user = JCck::getUser();
         $canEdit = $user->authorise('core.edit', 'com_cck.form.' . $config['type_id']);
         // if ( $user->id && !$user->guest ) {
         $canEditOwn = $user->authorise('core.edit.own', 'com_cck.form.' . $config['type_id']);
         // } else {
         //	$canEditOwn		=	false; // todo: guest
         // }
         $canEditOwnContent = '';
         // canEditOwnContent
         jimport('cck.joomla.access.access');
         $canEditOwnContent = CCKAccess::check($user->id, 'core.edit.own.content', 'com_cck.form.' . $config['type_id']);
         if ($canEditOwnContent) {
             $field2 = JCckDatabaseCache::loadObject('SELECT storage, storage_table, storage_field FROM #__cck_core_fields WHERE name = "' . $canEditOwnContent . '"');
             $canEditOwnContent = false;
             if (is_object($field2) && $field2->storage == 'standard') {
                 $pks = isset($config['pks']) ? $config['pks'] : $config['pk'];
                 $query = 'SELECT ' . $field2->storage_field . ' as map, id FROM ' . $field2->storage_table . ' WHERE id IN (' . $pks . ')';
                 $index = md5($query);
                 if (!isset($cache[$index])) {
                     $cache[$index . '_pks'] = JCckDatabase::loadObjectList($query, 'id');
                     $values = array();
                     if (count($cache[$index . '_pks'])) {
                         foreach ($cache[$index . '_pks'] as $p) {
                             $values[] = $p->map;
                         }
                     }
                     $values = count($values) ? implode(',', $values) : '0';
                     $cache[$index] = JCckDatabase::loadObjectList('SELECT author_id, pk FROM #__cck_core WHERE storage_location = "joomla_article" AND pk IN ( ' . $values . ' )', 'pk');
                 }
                 if (isset($cache[$index . '_pks'][$config['pk']]) && isset($cache[$index][$cache[$index . '_pks'][$config['pk']]->map]) && $cache[$index][$cache[$index . '_pks'][$config['pk']]->map]->author_id == $user->get('id')) {
                     $canEditOwnContent = true;
                 }
             }
         } else {
             $canEditOwnContent = '';
         }
         // Check Permissions
         if (!($canEdit && $canEditOwn || $canEdit && !$canEditOwn && $config['author'] != $user->get('id') || $canEditOwn && $config['author'] == $user->get('id') || $canEditOwnContent)) {
             if (!$link->get('no_access', 0)) {
                 $field->display = 0;
             }
             return;
         }
     } elseif ($form != '') {
         $user = JCck::getUser();
         $type_id = (int) JCckDatabase::loadResult('SELECT id FROM #__cck_core_types WHERE name = "' . $form . '"');
         $canCreate = $type_id ? $user->authorise('core.create', 'com_cck.form.' . $type_id) : false;
         // Check Permissions
         if (!$canCreate) {
             return;
         }
     }
     // Prepare
     $link_class = $link->get('class', '');
     $link_rel = $link->get('rel', '');
     $link_target = $link->get('target', '');
     $link_title = $link->get('title', '');
     $link_title2 = $link->get('title_custom', '');
     $tmpl = $link->get('tmpl', '');
     $tmpl = $tmpl ? '&tmpl=' . $tmpl : '';
     $vars = $tmpl;
     // + live
     /*
     if ( $config['client'] == 'admin' || $config['client'] == 'site' || $config['client'] == 'search' ) {
     	$redirection		=	'-1'; // todo
     }
     */
     // Set
     if (is_array($field->value)) {
         foreach ($field->value as $f) {
             $c = $custom;
             $c = parent::g_getCustomSelfVars(self::$type, $f, $c, $config);
             $c = $c ? '&' . $c : '';
             $f->link = 'index.php?option=com_cck&view=form&layout=edit&type=' . $form . $edit . $vars . '&Itemid=' . $itemId . $c;
             if ($redirection != '-1') {
                 $f->link .= '&return=' . $return;
             }
             $f->link = JRoute::_($f->link);
             $f->link_class = $link_class ? $link_class : (isset($f->link_class) ? $f->link_class : '');
             $f->link_rel = $link_rel ? $link_rel : (isset($f->link_rel) ? $f->link_rel : '');
             $f->link_state = $link->get('state', 1);
             $f->link_target = $link_target ? $link_target : (isset($f->link_target) ? $f->link_target : '');
             $f->link_title = $link_title ? $link_title == '2' ? $link_title2 : (isset($f->link_title) ? $f->link_title : '') : '';
         }
         $field->link = '#';
         //todo
     } else {
         $custom = parent::g_getCustomVars(self::$type, $field, $custom, $config);
         $field->link = JRoute::_('index.php?option=com_cck&view=form&layout=edit&type=' . $form . $edit . $vars . '&Itemid=' . $itemId);
         $separator = strpos($field->link, '?') !== false ? '&' : '?';
         if ($custom) {
             $field->link .= $separator . $custom;
             $separator = '&';
         }
         if ($redirection != '-1') {
             $field->link .= $separator . 'return=' . $return;
         }
         $field->link_class = $link_class ? $link_class : (isset($field->link_class) ? $field->link_class : '');
         $field->link_rel = $link_rel ? $link_rel : (isset($field->link_rel) ? $field->link_rel : '');
         $field->link_state = $link->get('state', 1);
         $field->link_target = $link_target ? $link_target : (isset($field->link_target) ? $field->link_target : '');
         $field->link_title = $link_title ? $link_title == '2' ? $link_title2 : (isset($field->link_title) ? $field->link_title : '') : '';
     }
 }
Пример #5
0
 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';
 }
Пример #6
0
 public static function onCCK_Field_LinkBeforeRenderContent($process, &$fields, &$storages, &$config = array())
 {
     $itemId = @$process['itemId'];
     $name = $process['name'];
     $fieldname = $process['fieldname'];
     $location = $process['location'];
     if (isset($process['pk']) && $process['pk']) {
         $pk = $process['pk'];
     } else {
         $pk = isset($fields[$fieldname]) ? (int) $fields[$fieldname]->value : 0;
     }
     if (!$pk) {
         if (isset($process['matches']) && count($process['matches'][1])) {
             parent::g_setCustomVars($process, $fields, $name);
         }
         return;
     }
     if ($itemId == '-2') {
         $itemId = JFactory::getApplication()->input->get('Itemid');
         $fieldname2 = $process['fieldname2'];
         if (isset($fields[$fieldname2])) {
             $itemId = (int) $fields[$fieldname2]->value;
         }
     } elseif ($itemId == '-3') {
         $itemId = JFactory::getApplication()->input->get('Itemid');
         $itemIds = $process['fieldnames'];
         $items = explode('||', $itemIds);
         if (count($items)) {
             foreach ($items as $item) {
                 if ($item != '') {
                     $parts = explode('=', $item);
                     if ($parts[1]) {
                         $checks = json_decode($parts[0], true);
                         $count = count($checks);
                         $found = 0;
                         if ($count) {
                             foreach ($checks as $k => $v) {
                                 if (isset($fields[$k]) && $fields[$k]->value == $v) {
                                     $found++;
                                 }
                             }
                         }
                         if ($found == $count) {
                             $itemId = $parts[1];
                             break;
                         }
                     }
                 }
             }
         }
     }
     $fields[$name]->link = JCck::callFunc_Array('plgCCK_Storage_Location' . $location, 'getRoute', array($pk, $process['sef'], $itemId, $config));
     $target = $fields[$name]->typo_target;
     if ($fields[$name]->link) {
         if ($process['vars']) {
             $fields[$name]->link .= strpos($fields[$name]->link, '?') !== false ? '&' . $process['vars'] : '?' . $process['vars'];
         }
         if ($process['custom']) {
             $fields[$name]->link .= $process['custom'][0] == '#' ? $process['custom'] : (strpos($fields[$name]->link, '?') !== false ? '&' . $process['custom'] : '?' . $process['custom']);
         }
         JCckPluginLink::g_setHtml($fields[$name], $target);
     }
     if ($fields[$name]->typo) {
         $html = isset($fields[$name]->html) ? $fields[$name]->html : '';
         if (strpos($fields[$name]->typo, $fields[$name]->{$target}) === false) {
             $fields[$name]->typo = $html;
         } else {
             $fields[$name]->typo = str_replace($fields[$name]->{$target}, $html, $fields[$name]->typo);
         }
     }
     if (isset($process['matches']) && count($process['matches'][1])) {
         parent::g_setCustomVars($process, $fields, $name);
     }
 }
Пример #7
0
 protected function _render($context, &$article, $tpl, $contentType, $fields, $property, $client, $cck, $parent_type)
 {
     $app = JFactory::getApplication();
     $dispatcher = JDispatcher::getInstance();
     $user = JFactory::getUser();
     $params = array('template' => $tpl['folder'], 'file' => 'index.php', 'directory' => $tpl['root']);
     $lang = JFactory::getLanguage();
     $lang->load('com_cck_default', JPATH_SITE);
     JPluginHelper::importPlugin('cck_field');
     JPluginHelper::importPlugin('cck_field_link');
     JPluginHelper::importPlugin('cck_field_restriction');
     $p_sef = isset($this->loaded[$contentType . '_' . $client . '_options']['sef']) ? $this->loaded[$contentType . '_' . $client . '_options']['sef'] : JCck::getConfig_Param('sef', '2');
     $p_title = isset($this->loaded[$contentType . '_' . $client . '_options']['title']) ? $this->loaded[$contentType . '_' . $client . '_options']['title'] : '';
     $p_typo = isset($this->loaded[$contentType . '_' . $client . '_options']['typo']) ? $this->loaded[$contentType . '_' . $client . '_options']['typo'] : 1;
     if ($p_typo) {
         JPluginHelper::importPlugin('cck_field_typo');
     }
     jimport('cck.rendering.document.document');
     $doc = CCK_Document::getInstance('html');
     $positions = array();
     if ($parent_type != '') {
         $w_type = '(b.name = "' . $contentType . '" OR b.name = "' . $parent_type . '")';
     } else {
         $w_type = 'b.name = "' . $contentType . '"';
     }
     if ($client == 'intro') {
         $positions_more = JCckDatabaseCache::loadObjectList('SELECT * FROM #__cck_core_type_position AS a LEFT JOIN #__cck_core_types AS b ON b.id = a.typeid' . ' WHERE ' . $w_type . ' AND a.client ="' . $client . '"', 'position');
         // todo::improve
     } else {
         $positions_more = JCckDatabase::loadObjectList('SELECT * FROM #__cck_core_type_position AS a LEFT JOIN #__cck_core_types AS b ON b.id = a.typeid' . ' WHERE ' . $w_type . ' AND a.client ="' . $client . '"', 'position');
         // todo::improve
     }
     // Fields
     if (count($fields)) {
         JPluginHelper::importPlugin('cck_storage');
         $config = array('author' => 0, 'client' => $client, 'doSEF' => $p_sef, 'doTranslation' => JCck::getConfig_Param('language_jtext', 0), 'doTypo' => $p_typo, 'error' => 0, 'fields' => array(), 'id' => $cck->id, 'isNew' => 0, 'Itemid' => $app->input->getInt('Itemid', 0), 'location' => $cck->storage_location, 'pk' => $article->id, 'pkb' => $cck->pkb, 'storages' => array(), 'store_id' => (int) $cck->store_id, 'type' => $cck->cck, 'type_id' => (int) $cck->type_id, 'type_alias' => $cck->type_alias ? $cck->type_alias : $cck->cck);
         foreach ($fields as $field) {
             $field->typo_target = 'value';
             $fieldName = $field->name;
             $value = '';
             $name = !empty($field->storage_field2) ? $field->storage_field2 : $fieldName;
             //-
             if ($fieldName) {
                 $Pt = $field->storage_table;
                 if ($Pt && !isset($config['storages'][$Pt])) {
                     $config['storages'][$Pt] = '';
                     $dispatcher->trigger('onCCK_Storage_LocationPrepareContent', array(&$field, &$config['storages'][$Pt], $config['pk'], &$config, &$article));
                 }
                 $dispatcher->trigger('onCCK_StoragePrepareContent', array(&$field, &$value, &$config['storages'][$Pt]));
                 if (is_string($value)) {
                     $value = trim($value);
                 }
                 if ($p_title != '' && $p_title == $field->name) {
                     $this->title = $value;
                 }
                 $hasLink = $field->link != '' ? 1 : 0;
                 $dispatcher->trigger('onCCK_FieldPrepareContent', array(&$field, $value, &$config));
                 $target = $field->typo_target;
                 if ($hasLink) {
                     $dispatcher->trigger('onCCK_Field_LinkPrepareContent', array(&$field, &$config));
                     if ($field->link) {
                         JCckPluginLink::g_setHtml($field, $target);
                     }
                 }
                 if (@$field->typo && ($field->{$target} !== '' || $field->typo_label == -2) && $p_typo) {
                     $dispatcher->trigger('onCCK_Field_TypoPrepareContent', array(&$field, $field->typo_target, &$config));
                 } else {
                     $field->typo = '';
                 }
                 $position = $field->position;
                 $positions[$position][] = $fieldName;
                 // Was it the last one?
                 if ($config['error']) {
                     break;
                 }
             }
         }
         // Merge
         if (count($config['fields'])) {
             $fields = array_merge($fields, $config['fields']);
             // Test: a loop may be faster.
             $config['fields'] = NULL;
             unset($config['fields']);
         }
     }
     // BeforeRender
     if (isset($config['process']['beforeRenderContent']) && count($config['process']['beforeRenderContent'])) {
         foreach ($config['process']['beforeRenderContent'] as $process) {
             if ($process->type) {
                 JCck::callFunc_Array('plg' . $process->group . $process->type, 'on' . $process->group . 'BeforeRenderContent', array($process->params, &$fields, &$config['storages'], &$config));
             }
         }
     }
     // Finalize
     $doc->fields =& $fields;
     $infos = array('context' => $context, 'params' => $tpl['params'], 'path' => $tpl['path'], 'root' => JURI::root(true), 'template' => $tpl['folder'], 'theme' => $tpl['home']);
     $doc->finalize('content', $contentType, $client, $positions, $positions_more, $infos, $cck->id);
     $data = $doc->render(false, $params);
     $article->{$property} = str_replace($article->{$property}, $data, $article->{$property});
 }
Пример #8
0
                 $config['storages'][$storages['_']] = $storages[$storages['_']][$config['pk']];
             }
         }
     }
 }
 $dispatcher->trigger('onCCK_StoragePrepareContent', array(&$field, &$value, &$config['storages'][$Pt]));
 if (is_string($value)) {
     $value = trim($value);
 }
 $hasLink = $field->link != '' ? 1 : 0;
 $dispatcher->trigger('onCCK_FieldPrepareContent', array(&$field, $value, &$config));
 $target = $field->typo_target;
 if ($hasLink) {
     $dispatcher->trigger('onCCK_Field_LinkPrepareContent', array(&$field, &$config));
     if ($field->link) {
         JCckPluginLink::g_setHtml($field, $target);
     }
 }
 if (@$field->typo && ($field->{$target} !== '' || $field->typo_label == -2) && $p_typo) {
     $dispatcher->trigger('onCCK_Field_TypoPrepareContent', array(&$field, $field->typo_target, &$config));
 } else {
     $field->typo = '';
 }
 // Optimize Memory
 if ($optimize) {
     foreach ($properties as $property) {
         unset($field->{$property});
     }
 }
 $fieldsI[$fieldName] = $field;
 if ($i == 0) {
Пример #9
0
 public function onCCK_FieldPrepareForm(&$field, $value = '', &$config = array(), $inherit = array(), $return = false)
 {
     if (self::$type != $field->type) {
         return;
     }
     self::$path = parent::g_getPath(self::$type . '/');
     $field->label2 = trim(@$field->label2);
     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->label;
     $field->label = '';
     // Prepare
     $pre_task = '';
     $options2 = JCckDev::fromJSON($field->options2);
     $task = isset($options2['task']) && $options2['task'] ? $options2['task'] : 'save';
     $task_auto = isset($options2['task_auto']) && $options2['task_auto'] == '0' ? 0 : 1;
     $task_id = isset($options2['task_id']) && $options2['task_id'] ? $options2['task_id'] : 0;
     if (JFactory::getApplication()->isAdmin()) {
         $task = $config['client'] == 'admin' ? 'form.' . $task : 'list.' . $task;
     }
     if ($task_id) {
         $pre_task = htmlspecialchars('jQuery("#' . $config['formId'] . '").append(\'<input type="hidden" name="tid" value="' . $task_id . '">\');');
     }
     $class = 'button btn' . ($field->css ? ' ' . $field->css : '');
     if ($task == 'cancel') {
         $click = ' onclick="JCck.Core.submitForm(\'' . $task . '\', document.getElementById(\'seblod_form\'));"';
     } else {
         if ($task == 'export' || $task == 'process' || $task == 'list.export' || $task == 'list.process') {
             $click = $pre_task . $config['submit'] . '(\'' . $task . '\');return false;';
             if ($field->variation != 'toolbar_button') {
                 parent::g_addProcess('beforeRenderForm', self::$type, $config, array('name' => $field->name, 'task' => $task, 'task_auto' => $task_auto, 'task_id' => $task_id));
             }
             if (!$task_auto) {
                 $click = 'if (document.' . $config['formId'] . '.boxchecked.value==0){alert(\'' . JText::_('JLIB_HTML_PLEASE_MAKE_A_SELECTION_FROM_THE_LIST') . '\');}else{' . $click . '}';
             }
             $click = isset($config['submit']) ? ' onclick="' . $click . '"' : '';
         } elseif ($task == 'save2redirect') {
             $custom = '';
             if (isset($options2['custom']) && $options2['custom']) {
                 $custom = JCckDevHelper::replaceLive($options2['custom']);
                 $custom = $custom ? '&' . $custom : '';
             }
             if ($config['client'] == 'search') {
                 $pre_task = htmlspecialchars('jQuery("#' . $config['formId'] . '").attr(\'action\', \'' . JRoute::_('index.php?Itemid=' . $options2['itemid'] . $custom) . '\');');
             } else {
                 $pre_task = htmlspecialchars('jQuery("#' . $config['formId'] . ' input[name=\'config[url]\']").val(\'' . JRoute::_('index.php?Itemid=' . $options2['itemid'] . $custom) . '\');');
             }
             $click = isset($config['submit']) ? ' onclick="' . $pre_task . $config['submit'] . '(\'' . $task . '\');return false;"' : '';
         } else {
             $click = isset($config['submit']) ? ' onclick="' . $pre_task . $config['submit'] . '(\'' . $task . '\');return false;"' : '';
         }
     }
     if ($field->attributes && strpos($field->attributes, 'onclick="') !== false) {
         $matches = array();
         $search = '#onclick\\=\\"([a-zA-Z0-9_\\(\\)\\\'\\;\\.]*)"#';
         preg_match($search, $field->attributes, $matches);
         if (count($matches) && $matches[0]) {
             if ($matches[0] == $field->attributes) {
                 $field->attributes = substr(trim($field->attributes), 0, -1);
                 $click = ' ' . $field->attributes . '"';
                 $field->attributes = '';
             } else {
                 $click = ' onclick="' . $matches[1] . '"';
                 $field->attributes = trim(str_replace($matches[0], '', $field->attributes));
             }
         }
     }
     $attr = 'class="' . $class . '"' . $click . ($field->attributes ? ' ' . $field->attributes : '');
     if ($field->bool) {
         $label = $value;
         if (JCck::on()) {
             if ($field->bool6 == 3) {
                 $label = '<span class="icon-' . $options2['icon'] . '"></span>';
                 $attr .= ' title="' . $value . '"';
             } elseif ($field->bool6 == 2) {
                 $label = $value . "\n" . '<span class="icon-' . $options2['icon'] . '"></span>';
             } elseif ($field->bool6 == 1) {
                 $label = '<span class="icon-' . $options2['icon'] . '"></span>' . "\n" . $value;
             }
         }
         $type = $field->bool7 == 1 ? 'submit' : 'button';
         $form = '<button type="' . $type . '" id="' . $id . '" name="' . $name . '" ' . $attr . '>' . $label . '</button>';
         $tag = 'button';
     } else {
         $form = '<input type="submit" id="' . $id . '" name="' . $name . '" value="' . $value . '" ' . $attr . ' />';
         $tag = 'input';
     }
     if ($field->bool2 == 1) {
         $alt = $field->bool3 ? ' ' . JText::_('COM_CCK_OR') . ' ' : "\n";
         if ($config['client'] == 'search') {
             $onclick = 'onclick="jQuery(\'#' . $config['formId'] . '\').clearForm();"';
             $form .= $alt . '<a href="javascript: void(0);" ' . $onclick . ' title="' . JText::_('COM_CCK_RESET') . '">' . JText::_('COM_CCK_RESET') . '</a>';
         } else {
             $onclick = 'onclick="JCck.Core.submitForm(\'cancel\', document.getElementById(\'seblod_form\'));"';
             $form .= $alt . '<a href="javascript: void(0);" ' . $onclick . ' title="' . JText::_('COM_CCK_CANCEL') . '">' . JText::_('COM_CCK_CANCEL') . '</a>';
         }
     } elseif ($field->bool2 == 2) {
         $alt = $field->bool3 ? ' ' . JText::_('COM_CCK_OR') . ' ' : "\n";
         $field2 = (object) array('link' => $options2['alt_link'], 'link_options' => $options2['alt_link_options'], 'id' => $id, 'name' => $name, 'text' => htmlspecialchars($options2['alt_link_text']), 'value' => '');
         JCckPluginLink::g_setLink($field2, $config);
         JCckPluginLink::g_setHtml($field2, 'text');
         $form .= $alt . $field2->html;
     }
     // Set
     if (!$field->variation) {
         $field->form = $form;
         if ($field->script) {
             parent::g_addScriptDeclaration($field->script);
         }
     } else {
         if ($field->variation == 'toolbar_button') {
             $field->form = '';
             $icon = isset($options2['icon']) && $options2['icon'] ? 'icon-' . $options2['icon'] : '';
             $onclick = $pre_task . 'JCck.Core.submit(\'' . $task . '\')';
             if (!$task_auto) {
                 $onclick = 'if (document.' . $config['formId'] . '.boxchecked.value==0){alert(\'' . JText::_('JLIB_HTML_PLEASE_MAKE_A_SELECTION_FROM_THE_LIST') . '\');}else{' . $onclick . '}';
             }
             $html = '<button class="btn btn-small' . ($field->css ? ' ' . $field->css : '') . '" onclick="' . $onclick . '" href="#"><i class="' . $icon . '"></i> ' . $value . '</button>';
             parent::g_addProcess('beforeRenderForm', self::$type, $config, array('name' => $field->name, 'button' => array('html' => $html, 'icon' => @$options2['icon']), 'pre_task' => $pre_task, 'task' => $task, 'task_auto' => $task_auto, 'task_id' => $task_id));
         } else {
             parent::g_getDisplayVariation($field, $field->variation, $value, $value, $form, $id, $name, '<' . $tag, ' ', '', $config);
         }
     }
     $field->value = '';
     // Return
     if ($return === true) {
         return $field;
     }
 }
Пример #10
0
 protected static function _link($link, &$field, &$config)
 {
     $list = $link->get('list', '');
     $itemId = (int) $link->get('itemid', '');
     $search_field = $link->get('search_field', 0);
     $name = $search_field == -1 ? '' : ($search_field == 1 ? $link->get('search_fieldname', $field->name) : $field->name);
     $custom = $link->get('custom', '');
     if (!$list) {
         return;
     }
     // Prepare
     $link_class = $link->get('class', '');
     $link_rel = $link->get('rel', '');
     $link_target = $link->get('target', '');
     $tmpl = $link->get('tmpl', '');
     $tmpl = $tmpl ? '&tmpl=' . $tmpl : '';
     $vars = '&task=search' . $tmpl;
     // Set
     if (isset($field->values)) {
         foreach ($field->values as $f) {
             $c = $custom;
             $c = parent::g_getCustomSelfVars(self::$type, $f, $c, $config);
             $c = $c ? '&' . $c : '';
             $search_for = $search_field > -1 ? '&' . $name . '=' . $f->value : '';
             $f->link = 'index.php?option=com_cck&view=list&search=' . $list . $vars . '&Itemid=' . $itemId . $search_for . $c;
             if ($itemId > 0) {
                 $f->link = JRoute::_($f->link);
             }
             $f->link_class = $link_class ? $link_class : (isset($f->link_class) ? $f->link_class : '');
             $f->link_rel = $link_rel ? $link_rel : (isset($f->link_rel) ? $f->link_rel : '');
             $f->link_state = $link->get('state', 1);
             $f->link_target = $link_target ? $link_target : (isset($f->link_target) ? $f->link_target : '');
         }
         $field->link = '#';
         //todo
     } elseif (is_array($field->value)) {
         foreach ($field->value as $f) {
             $c = $custom;
             $c = parent::g_getCustomSelfVars(self::$type, $f, $c, $config);
             $c = $c ? '&' . $c : '';
             $search_for = $search_field > -1 ? '&' . $name . '=' . $f->value : '';
             $f->link = 'index.php?option=com_cck&view=list&search=' . $list . $vars . '&Itemid=' . $itemId . $search_for . $c;
             if ($itemId > 0) {
                 $f->link = JRoute::_($f->link);
             }
             $f->link_class = $link_class ? $link_class : (isset($f->link_class) ? $f->link_class : '');
             $f->link_rel = $link_rel ? $link_rel : (isset($f->link_rel) ? $f->link_rel : '');
             $f->link_state = $link->get('state', 1);
             $f->link_target = $link_target ? $link_target : (isset($f->link_target) ? $f->link_target : '');
         }
         $field->link = '#';
         //todo
     } else {
         $custom = parent::g_getCustomVars(self::$type, $field, $custom, $config);
         $search_for = $search_field > -1 ? '&' . $name . '=' . $field->value : '';
         $field->link = 'index.php?option=com_cck&view=list&search=' . $list . $vars . '&Itemid=' . $itemId . $search_for;
         if ($itemId > 0) {
             $field->link = JRoute::_($field->link);
         }
         $separator = strpos($field->link, '?') !== false ? '&' : '?';
         if ($custom) {
             $field->link .= $separator . $custom;
         }
         $field->link_class = $link_class ? $link_class : (isset($field->link_class) ? $field->link_class : '');
         $field->link_rel = $link_rel ? $link_rel : (isset($field->link_rel) ? $field->link_rel : '');
         $field->link_state = $link->get('state', 1);
         $field->link_target = $link_target ? $link_target : (isset($field->link_target) ? $field->link_target : '');
     }
 }
Пример #11
0
 protected static function _link($link, &$field, &$config)
 {
     $app = JFactory::getApplication();
     $custom = $link->get('custom', '#');
     $itemId = $link->get('itemid', 0);
     $link_attr = $link->get('attributes', '');
     $link_class = $link->get('class', '');
     $link_rel = $link->get('rel', '');
     $link_target = $link->get('target', '');
     $link_title = $link->get('title', '');
     $link_title2 = $link->get('title_custom', '');
     $tmpl = $link->get('tmpl', '');
     $tmpl = $tmpl ? 'tmpl=' . $tmpl : '';
     $vars = $tmpl;
     if (is_array($field->value)) {
         foreach ($field->value as $f) {
             // Prepare
             $c = $custom;
             if ($c != '#' && strpos($c, '*') !== false) {
                 $matches = '';
                 $search = '#\\*([a-zA-Z0-9_]*)\\*#U';
                 preg_match_all($search, $c, $matches);
                 if (count($matches[1])) {
                     foreach ($matches[1] as $target) {
                         $c = str_replace('*' . $target . '*', $f->{$target}, $c);
                     }
                 }
             }
             // Set
             $f->link = $c;
             if ($vars) {
                 $f->link .= strpos($f->link, '?') !== false ? '&' . $vars : '?' . $vars;
             }
             $f->link_attributes = $link_attr ? $link_attr : (isset($f->link_attributes) ? $f->link_attributes : '');
             $f->link_class = $link_class ? $link_class : (isset($f->link_class) ? $f->link_class : '');
             $f->link_rel = $link_rel ? $link_rel : (isset($f->link_rel) ? $f->link_rel : '');
             $f->link_state = $link->get('state', 1);
             $f->link_target = $link_target ? $link_target == '-1' ? '_blank' : $link_target : (isset($f->link_target) ? $f->link_target : '');
             $f->link_title = $link_title ? $link_title == '2' ? $link_title2 : (isset($f->link_title) ? $f->link_title : '') : '';
         }
         $field->link = '#';
         //todo
     } else {
         // Prepare
         if ($custom != '#' && strpos($custom, '*') !== false) {
             $matches = '';
             $search = '#\\*([a-zA-Z0-9_]*)\\*#U';
             preg_match_all($search, $custom, $matches);
             if (count($matches[1])) {
                 foreach ($matches[1] as $target) {
                     $custom = str_replace('*' . $target . '*', $field->{$target}, $custom);
                 }
             }
         }
         if ($custom != '#' && strpos($custom, '$cck->get') !== false) {
             $matches = '';
             $search = '#\\$cck\\->get([a-zA-Z0-9_]*)\\( ?\'([a-zA-Z0-9_,]*)\' ?\\)(;)?#';
             preg_match_all($search, $custom, $matches);
             if (count($matches[1])) {
                 parent::g_addProcess('beforeRenderContent', self::$type, $config, array('name' => $field->name, 'matches' => $matches, 'itemId' => $itemId, 'target_fieldname' => $link_target == '-1' ? $link->get('target_fieldname', '') : ''));
             }
         }
         if ($custom != '' && strpos($custom, '$uri->get') !== false) {
             $matches = '';
             $search = '#\\$uri\\->get([a-zA-Z]*)\\( ?\'?([a-zA-Z0-9_]*)\'? ?\\)(;)?#';
             preg_match_all($search, $custom, $matches);
             if (count($matches[1])) {
                 foreach ($matches[1] as $k => $v) {
                     $variable = $matches[2][$k];
                     if ($v == 'Current' || $v == 'CurrentUrl' || $v == 'EncodedUrl') {
                         if ($v == 'CurrentUrl' || $v == 'EncodedUrl' || $variable == 'true') {
                             $request = JURI::getInstance()->toString();
                         } else {
                             $request = JURI::current();
                         }
                         if ($v == 'EncodedUrl') {
                             $request = urlencode($request);
                         }
                         $custom = str_replace($matches[0][$k], $request, $custom);
                     } elseif ($v == 'Array') {
                         $value = '';
                         $custom_v = '';
                         static $custom_vars = array();
                         if (!isset($custom_vars[$field->name])) {
                             $custom_vars[$field->name] = explode('&', $custom);
                         }
                         if (count($custom_vars[$field->name])) {
                             foreach ($custom_vars[$field->name] as $custom_var) {
                                 if (strpos($custom_var, $matches[0][$k]) !== false) {
                                     $custom_v = substr($custom_var, 0, strpos($custom_var, '='));
                                 }
                             }
                         }
                         if ($custom_v != '') {
                             $values = $app->input->get($variable, '', 'array');
                             if (is_array($values) && count($values)) {
                                 foreach ($values as $val) {
                                     $value .= '&' . $custom_v . '[]=' . $val;
                                 }
                             }
                         }
                         $custom = str_replace('&' . $custom_v . '=' . $matches[0][$k], $value, $custom);
                     } else {
                         $request = 'get' . $v;
                         $custom = str_replace($matches[0][$k], $app->input->{$request}($variable, ''), $custom);
                     }
                 }
             }
         }
         // Set
         $field->link = $custom;
         if ($vars) {
             $field->link .= strpos($field->link, '?') !== false ? '&' . $vars : '?' . $vars;
         }
         $field->link_attributes = $link_attr ? $link_attr : (isset($field->link_attributes) ? $field->link_attributes : '');
         $field->link_class = $link_class ? $link_class : (isset($field->link_class) ? $field->link_class : '');
         $field->link_rel = $link_rel ? $link_rel : (isset($field->link_rel) ? $field->link_rel : '');
         $field->link_state = $link->get('state', 1);
         $field->link_target = $link_target ? $link_target == '-1' ? '_blank' : $link_target : (isset($field->link_target) ? $field->link_target : '');
         $field->link_title = $link_title ? $link_title == '2' ? $link_title2 : (isset($field->link_title) ? $field->link_title : '') : '';
     }
 }
 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 . '/');
     $field->label2 = trim(@$field->label2);
     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->label;
     $field->label = '';
     // Prepare
     $pre_task = '';
     $options2 = JCckDev::fromJSON($field->options2);
     $task = isset($options2['task']) && $options2['task'] ? $options2['task'] : 'save';
     $task_id = isset($options2['task_id']) && $options2['task_id'] ? $options2['task_id'] : 0;
     if (JFactory::getApplication()->isAdmin()) {
         $task = $config['client'] == 'admin' ? 'form.' . $task : 'list.' . $task;
     }
     if ($task_id) {
         $pre_task = htmlspecialchars('jQuery("#' . $config['formId'] . '").append(\'<input type="hidden" name="tid" value="' . $task_id . '">\');');
     }
     $class = 'button btn' . ($field->css ? ' ' . $field->css : '');
     if ($task == 'cancel') {
         $click = ' onclick="Joomla.submitform(\'' . $task . '\', document.getElementById(\'seblod_form\'));"';
     } else {
         if ($task == 'export') {
             parent::g_addProcess('beforeRenderForm', self::$type, $config, array('name' => $field->name, 'task' => $task, 'task_id' => $task_id));
         }
         $click = isset($config['submit']) ? ' onclick="' . $pre_task . $config['submit'] . '(\'' . $task . '\');return false;"' : '';
     }
     // $click	=	isset( $config['formId'] ) ? ' onclick="if (document.'.$config['formId'].'.boxchecked.value==0){alert(\''.addslashes( JText::_( 'JLIB_HTML_PLEASE_MAKE_A_SELECTION_FROM_THE_LIST' ) ).'\');}else{ Joomla.submitbutton(\''.$task.'\')};return false;"' : '';
     $attr = 'class="' . $class . '"' . $click . ($field->attributes ? ' ' . $field->attributes : '');
     if ($field->bool) {
         $label = $value;
         if (JCck::on()) {
             if ($field->bool6 == 3) {
                 $label = '<span class="icon-' . $options2['icon'] . '"></span>';
                 $attr .= ' title="' . $value . '"';
             } elseif ($field->bool6 == 2) {
                 $label = $value . "\n" . '<span class="icon-' . $options2['icon'] . '"></span>';
             } elseif ($field->bool6 == 1) {
                 $label = '<span class="icon-' . $options2['icon'] . '"></span>' . "\n" . $value;
             }
         }
         $type = $field->bool7 == 1 ? 'submit' : 'button';
         $form = '<button type="' . $type . '" id="' . $id . '" name="' . $name . '" ' . $attr . '>' . $label . '</button>';
         $tag = 'button';
     } else {
         $form = '<input type="submit" id="' . $id . '" name="' . $name . '" value="' . $value . '" ' . $attr . ' />';
         $tag = 'input';
     }
     if ($field->bool2 == 1) {
         $alt = $field->bool3 ? ' ' . JText::_('COM_CCK_OR') . ' ' : "\n";
         if ($config['client'] == 'search') {
             $onclick = 'onclick="jQuery(\'#' . $config['formId'] . '\').clearForm();"';
             $form .= $alt . '<a href="javascript: void(0);" ' . $onclick . ' title="' . JText::_('COM_CCK_RESET') . '">' . JText::_('COM_CCK_RESET') . '</a>';
         } else {
             $onclick = 'onclick="Joomla.submitform(\'cancel\', document.getElementById(\'seblod_form\'));"';
             $form .= $alt . '<a href="javascript: void(0);" ' . $onclick . ' title="' . JText::_('COM_CCK_CANCEL') . '">' . JText::_('COM_CCK_CANCEL') . '</a>';
         }
     } elseif ($field->bool2 == 2) {
         $alt = $field->bool3 ? ' ' . JText::_('COM_CCK_OR') . ' ' : "\n";
         $field2 = (object) array('link' => $options2['alt_link'], 'link_options' => $options2['alt_link_options'], 'id' => $id, 'name' => $name, 'text' => htmlspecialchars($options2['alt_link_text']), 'value' => '');
         JCckPluginLink::g_setLink($field2, $config);
         JCckPluginLink::g_setHtml($field2, 'text');
         $form .= $alt . $field2->html;
     }
     // Set
     if (!$field->variation) {
         $field->form = $form;
         if ($field->script) {
             parent::g_addScriptDeclaration($field->script);
         }
     } else {
         if ($field->variation == 'toolbar_button') {
             $field->form = '';
             $icon = isset($options2['icon']) && $options2['icon'] ? 'icon-' . $options2['icon'] : '';
             $html = '<button class="btn btn-small' . ($field->css ? ' ' . $field->css : '') . '" onclick="' . $pre_task . 'JCck.Core.submit(\'' . $task . '\')" href="#"><i class="' . $icon . '"></i> ' . $value . '</button>';
             JToolBar::getInstance('toolbar')->appendButton('Custom', $html, @$options2['icon']);
             // JToolBar::getInstance( 'toolbar' )->appendButton( 'Standard', $options2['icon'], $value, $task, true ); todo: check
         } else {
             parent::g_getDisplayVariation($field, $field->variation, $value, $value, $form, $id, $name, '<' . $tag, ' ', '', $config);
         }
     }
     $field->value = '';
     // Return
     if ($return === true) {
         return $field;
     }
 }
Пример #13
0
 public static function onCCK_Field_LinkBeforeRenderContent($process, &$fields, &$storages, &$config = array())
 {
     $name = $process['name'];
     $fieldname = $process['fieldname'];
     $location = $process['location'];
     $pk = isset($fields[$fieldname]) ? (int) $fields[$fieldname]->value : 0;
     if (!$pk) {
         if (count($process['matches'][1])) {
             parent::g_setCustomVars($process, $fields, $name);
         }
         return;
     }
     $fields[$name]->link = JCck::callFunc_Array('plgCCK_Storage_Location' . $location, 'getRoute', array($pk, $process['sef'], $process['itemId'], $config));
     $target = $fields[$name]->typo_target;
     if ($fields[$name]->link) {
         if ($process['vars']) {
             $fields[$name]->link .= strpos($fields[$name]->link, '?') !== false ? '&' . $process['vars'] : '?' . $process['vars'];
         }
         if ($process['custom']) {
             $fields[$name]->link .= $process['custom'][0] == '#' ? $process['custom'] : (strpos($fields[$name]->link, '?') !== false ? '&' . $process['custom'] : '?' . $process['custom']);
         }
         JCckPluginLink::g_setHtml($fields[$name], $target);
     }
     if ($fields[$name]->typo) {
         $fields[$name]->typo = str_replace($fields[$name]->{$target}, $fields[$name]->html, $fields[$name]->typo);
     }
     if (isset($process['matches']) && count($process['matches'][1])) {
         parent::g_setCustomVars($process, $fields, $name);
     }
 }