Пример #1
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;
 }
Пример #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);
     // 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;
 }
Пример #3
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';
 }
Пример #4
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);
     }
 }
Пример #5
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});
 }
Пример #6
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) {
Пример #7
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;
     }
 }
 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;
     }
 }
Пример #9
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);
     }
 }