Ejemplo n.º 1
0
 function extraFields()
 {
     $mainframe =& JFactory::getApplication();
     $itemID = JRequest::getInt('cid', NULL);
     JTable::addIncludePath(JPATH_COMPONENT_ADMINISTRATOR . DS . 'tables');
     $catid = JRequest::getVar('id');
     $category =& JTable::getInstance('K2Category', 'Table');
     $category->load($catid);
     require_once JPATH_COMPONENT_ADMINISTRATOR . DS . 'models' . DS . 'extrafield.php';
     $extraFieldModel = new K2ModelExtraField();
     $extraFields = $extraFieldModel->getExtraFieldsByGroup($category->extraFieldsGroup);
     $output = '<table class="admintable" id="extraFields">';
     $counter = 0;
     if (count($extraFields)) {
         foreach ($extraFields as $extraField) {
             $output .= '<tr><td align="right" class="key">' . $extraField->name . '</td>';
             $output .= '<td>' . $extraFieldModel->renderExtraField($extraField, $itemID) . '</td></tr>';
             $counter++;
         }
     }
     $output .= '</table>';
     if ($counter == 0) {
         $output = JText::_("This category doesn't have assigned extra fields");
     }
     echo $output;
     $mainframe->close();
 }
Ejemplo n.º 2
0
 function extraFields()
 {
     $k2Path = JPATH_ADMINISTRATOR . '/components/com_k2/';
     JTable::addIncludePath($k2Path . 'tables');
     require_once $k2Path . 'models/model.php';
     require_once $k2Path . 'models/category.php';
     require_once $k2Path . 'models/extrafield.php';
     $mainframe = JFactory::getApplication();
     $itemID = JRequest::getInt('id', NULL);
     //$categoryModel = $this->getModel('category');
     $categoryModel = new K2ModelCategory();
     $category = $categoryModel->getData();
     //$extraFieldModel = $this->getModel('extraField');
     $extraFieldModel = new K2ModelExtraField();
     $extraFields = $extraFieldModel->getExtraFieldsByGroup($category->extraFieldsGroup);
     $output = '<table class="admintable" id="extraFields">';
     $counter = 0;
     if (count($extraFields)) {
         foreach ($extraFields as $extraField) {
             if ($extraField->type == 'header') {
                 $output .= '<tr><td colspan="2" ><h4 class="k2ExtraFieldHeader">' . $extraField->name . '</h4></td></tr>';
             } else {
                 $output .= '<tr><td align="right" class="key"><label for="K2ExtraField_' . $extraField->id . '">' . $extraField->name . '</label></td>';
                 $html = $extraFieldModel->renderExtraField($extraField, $itemID);
                 if ($extraField->type == 'textfield') {
                     $html2 = $this->renderField($itemID, $extraField);
                     if ($html2) {
                         $html = $html2;
                     }
                 }
                 $output .= '<td>' . $html . '</td></tr>';
             }
             $counter++;
         }
     }
     $output .= '</table>';
     if ($counter == 0) {
         $output = JText::_('K2_THIS_CATEGORY_DOESNT_HAVE_ASSIGNED_EXTRA_FIELDS');
     }
     echo $output;
     $mainframe->close();
 }
Ejemplo n.º 3
0
 function extraFields()
 {
     $mainframe = JFactory::getApplication();
     $language = JFactory::getLanguage();
     $language->load('com_k2', JPATH_ADMINISTRATOR);
     $itemID = JRequest::getInt('id', NULL);
     JTable::addIncludePath(JPATH_COMPONENT_ADMINISTRATOR . DS . 'tables');
     $catid = JRequest::getInt('cid');
     $category = JTable::getInstance('K2Category', 'Table');
     $category->load($catid);
     require_once JPATH_COMPONENT_ADMINISTRATOR . DS . 'models' . DS . 'extrafield.php';
     $extraFieldModel = new K2ModelExtraField();
     $extraFields = $extraFieldModel->getExtraFieldsByGroup($category->extraFieldsGroup);
     $output = '<table class="admintable" id="extraFields">';
     $counter = 0;
     if (count($extraFields)) {
         foreach ($extraFields as $extraField) {
             if ($extraField->type == 'header') {
                 $output .= '<tr><td colspan="2" ><h4 class="k2ExtraFieldHeader">' . $extraField->name . '</h4></td></tr>';
             } else {
                 $output .= '<tr><td align="right" class="key"><label for="K2ExtraField_' . $extraField->id . '">' . $extraField->name . '</label></td>';
                 $output .= '<td>' . $extraFieldModel->renderExtraField($extraField, $itemID) . '</td></tr>';
             }
             $counter++;
         }
     }
     $output .= '</table>';
     if ($counter == 0) {
         $output = JText::_('K2_THIS_CATEGORY_DOESNT_HAVE_ASSIGNED_EXTRA_FIELDS');
     }
     echo $output;
     $mainframe->close();
 }
Ejemplo n.º 4
0
    function edit()
    {
        $mainframe =& JFactory::getApplication();
        jimport('joomla.filesystem.file');
        jimport('joomla.html.pane');
        $db =& JFactory::getDBO();
        JHTML::_('behavior.mootools');
        $document =& JFactory::getDocument();
        $document->addScript(JURI::root() . 'administrator/components/com_k2/lib/Autocompleter.js');
        $document->addScript(JURI::root() . 'administrator/components/com_k2/lib/observer.js');
        $document->addScript(JURI::root() . 'administrator/components/com_k2/lib/simpletabs_1.3.js');
        //$document->addScript(JURI::root().'administrator/components/com_k2/js/k2.js'); // Core JS
        $document->addScript(JURI::root() . 'administrator/components/com_k2/js/k2.mootools.js');
        // Mootools based JS
        $document->addCustomTag('
        
<!-- K2 by JoomlaWorks (start) -->
		
	<!-- Load Khepri styling -->
	<link rel="stylesheet" href="' . JURI::root() . 'administrator/templates/system/css/system.css" type="text/css" />
	<link href="' . JURI::root() . 'administrator/templates/khepri/css/template.css" rel="stylesheet" type="text/css" />
	<!--[if IE 7]>
	<link href="' . JURI::root() . 'administrator/templates/khepri/css/ie7.css" rel="stylesheet" type="text/css" />
	<![endif]-->
	<!--[if lte IE 6]>
	<link href="' . JURI::root() . 'administrator/templates/khepri/css/ie6.css" rel="stylesheet" type="text/css" />
	<![endif]-->
	<link rel="stylesheet" type="text/css" href="' . JURI::root() . 'administrator/templates/khepri/css/rounded.css" />
	
	<!-- Load K2 styling -->
	<link href="' . JURI::root() . 'administrator/components/com_k2/css/k2.css" rel="stylesheet" type="text/css" />
	<!--[if IE 7]>
	<link href="' . JURI::root() . 'administrator/components/com_k2/css/k2_ie7.css" rel="stylesheet" type="text/css" />
	<![endif]-->
	<!--[if lte IE 6]>
	<link href="' . JURI::root() . 'administrator/components/com_k2/css/k2_ie6.css" rel="stylesheet" type="text/css" />
	<![endif]-->
		
<!-- K2 by JoomlaWorks (end) -->

		');
        JRequest::setVar('tmpl', 'component');
        require_once JPATH_COMPONENT_ADMINISTRATOR . DS . 'models' . DS . 'item.php';
        $model = new K2ModelItem();
        $task = JRequest::getCmd('task');
        $user =& JFactory::getUser();
        if ($task == 'edit') {
            $item = $model->getData();
            JFilterOutput::objectHTMLSafe($item, ENT_QUOTES, 'video');
            if (!K2HelperPermissions::canEditItem($item->created_by, $item->catid)) {
                JError::raiseError(403, JText::_("ALERTNOTAUTH"));
            }
            if (JTable::isCheckedOut($user->get('id'), $item->checked_out)) {
                $msg = JText::sprintf('DESCBEINGEDITTED', JText::_('The item'), $item->title);
                $mainframe->redirect('index.php?option=com_k2&view=item&id=' . $item->id . '&tmpl=component', $msg);
            }
        } elseif ($task == 'add') {
            if (!K2HelperPermissions::canAddItem()) {
                JError::raiseError(403, JText::_("ALERTNOTAUTH"));
            }
            JTable::addIncludePath(JPATH_COMPONENT . DS . 'tables');
            $item =& JTable::getInstance('K2Item', 'Table');
            $createdate =& JFactory::getDate();
            $item->published = 1;
            $item->publish_up = $createdate->toUnix();
            $item->publish_down = JText::_('Never');
            $item->created = $createdate->toUnix();
            $item->modified = $db->getNullDate();
        }
        if ($item->id) {
            $item->checkout($user->get('id'));
        }
        $item->created = JHTML::_('date', $item->created, '%Y-%m-%d %H:%M:%S');
        $item->publish_up = JHTML::_('date', $item->publish_up, '%Y-%m-%d %H:%M:%S');
        if (JHTML::_('date', $item->publish_down, '%Y') <= 1969 || $item->publish_down == $db->getNullDate()) {
            $item->publish_down = JText::_('Never');
        } else {
            $item->publish_down = JHTML::_('date', $item->publish_down, '%Y-%m-%d %H:%M:%S');
        }
        $params =& JComponentHelper::getParams('com_k2');
        $wysiwyg =& JFactory::getEditor();
        if ($params->get("mergeEditors")) {
            if (JString::strlen($item->fulltext) > 1) {
                $textValue = $item->introtext . "<hr id=\"system-readmore\" />" . $item->fulltext;
            } else {
                $textValue = $item->introtext;
            }
            $text = $wysiwyg->display('text', $textValue, '100%', '400', '40', '5', array('pagebreak'));
            $this->assignRef('text', $text);
        } else {
            $introtext = $wysiwyg->display('introtext', $item->introtext, '100%', '400', '40', '5', array('pagebreak', 'readmore'));
            $this->assignRef('introtext', $introtext);
            $fulltext = $wysiwyg->display('fulltext', $item->fulltext, '100%', '400', '40', '5', array('pagebreak', 'readmore'));
            $this->assignRef('fulltext', $fulltext);
        }
        $lists = array();
        $lists['published'] = JHTML::_('select.booleanlist', 'published', 'class="inputbox"', $item->published);
        $lists['access'] = JHTML::_('list.accesslevel', $item);
        $query = "SELECT ordering AS value, title AS text FROM #__k2_items WHERE catid={$item->catid}";
        $lists['ordering'] = JHTML::_('list.specificordering', $item, $item->id, $query);
        require_once JPATH_COMPONENT_ADMINISTRATOR . DS . 'models' . DS . 'categories.php';
        $categoriesModel = new K2ModelCategories();
        $categories = $categoriesModel->categoriesTree();
        $lists['catid'] = JHTML::_('select.genericlist', $categories, 'catid', 'class="inputbox"', 'value', 'text', $item->catid);
        $lists['checkSIG'] = $model->checkSIG();
        $lists['checkAllVideos'] = $model->checkAllVideos();
        $remoteVideo = false;
        $providerVideo = false;
        $embedVideo = false;
        $options['startOffset'] = 0;
        if (stristr($item->video, 'remote}') !== false) {
            $remoteVideo = true;
            $options['startOffset'] = 1;
        }
        $providers = $model->getVideoProviders();
        if (count($providers)) {
            foreach ($providers as $provider) {
                $providersOptions[] = JHTML::_('select.option', $provider, $provider);
                if (stristr($item->video, "{{$provider}}") !== false) {
                    $providerVideo = true;
                    $options['startOffset'] = 2;
                }
            }
        }
        if (JString::substr($item->video, 0, 1) !== '{') {
            $embedVideo = true;
            $options['startOffset'] = 3;
        }
        $lists['uploadedVideo'] = !$remoteVideo && !$providerVideo && !$embedVideo ? true : false;
        if ($lists['uploadedVideo']) {
            $options['startOffset'] = 0;
        }
        $lists['remoteVideo'] = $remoteVideo ? preg_replace('%\\{[a-z0-9-_]*\\}(.*)\\{/[a-z0-9-_]*\\}%i', '\\1', $item->video) : '';
        $lists['remoteVideoType'] = $remoteVideo ? preg_replace('%\\{([a-z0-9-_]*)\\}.*\\{/[a-z0-9-_]*\\}%i', '\\1', $item->video) : '';
        $lists['providerVideo'] = $providerVideo ? preg_replace('%\\{[a-z0-9-_]*\\}(.*)\\{/[a-z0-9-_]*\\}%i', '\\1', $item->video) : '';
        $lists['providerVideoType'] = $providerVideo ? preg_replace('%\\{([a-z0-9-_]*)\\}.*\\{/[a-z0-9-_]*\\}%i', '\\1', $item->video) : '';
        $lists['embedVideo'] = $embedVideo ? $item->video : '';
        if (count($providers)) {
            $lists['providers'] = JHTML::_('select.genericlist', $providersOptions, 'videoProvider', '', 'value', 'text', $lists['providerVideoType']);
        }
        JPluginHelper::importPlugin('content', 'jw_sigpro');
        JPluginHelper::importPlugin('content', 'jw_sig');
        JPluginHelper::importPlugin('content', 'jw_allvideos');
        $dispatcher =& JDispatcher::getInstance();
        $params->set('galleries_rootfolder', 'media/k2/galleries');
        $params->set('thb_width', '150');
        $params->set('thb_height', '120');
        $params->set('popup_engine', 'mootools_slimbox');
        $params->set('enabledownload', '0');
        $item->text = $item->gallery;
        $dispatcher->trigger('onPrepareContent', array(&$item, &$params, null));
        $item->gallery = $item->text;
        if (!$embedVideo) {
            $params->set('vfolder', 'media/k2/videos');
            $item->text = $item->video;
            $dispatcher->trigger('onPrepareContent', array(&$item, &$params, null));
            $item->video = $item->text;
        } else {
            $item->video = '<div>' . $item->video . '</div>';
        }
        if (isset($item->created_by)) {
            $author =& JUser::getInstance($item->created_by);
            $item->author = $author->name;
        }
        if (isset($item->modified_by)) {
            $moderator =& JUser::getInstance($item->modified_by);
            $item->moderator = $moderator->name;
        }
        if ($task == 'edit') {
            $item->editor = $item->author;
        } else {
            $item->editor = $user->name;
        }
        require_once JPATH_COMPONENT_ADMINISTRATOR . DS . 'models' . DS . 'categories.php';
        $categoriesModel = new K2ModelCategories();
        $categories_option[] = JHTML::_('select.option', 0, JText::_('- Select category -'));
        $categories = $categoriesModel->categoriesTree();
        if (($task == 'add' || $task == 'edit') && !$user->authorize('com_k2', 'add', 'category', 'all')) {
            for ($i = 0; $i < sizeof($categories); $i++) {
                if (!$user->authorize('com_k2', 'add', 'category', $categories[$i]->value)) {
                    $categories[$i]->disable = true;
                }
            }
        }
        $categories_options = @array_merge($categories_option, $categories);
        $lists['categories'] = JHTML::_('select.genericlist', $categories_options, 'catid', '', 'value', 'text', $item->catid);
        JTable::addIncludePath(JPATH_COMPONENT . DS . 'tables');
        $category =& JTable::getInstance('K2Category', 'Table');
        $category->load($item->catid);
        require_once JPATH_COMPONENT_ADMINISTRATOR . DS . 'models' . DS . 'extrafield.php';
        $extraFieldModel = new K2ModelExtraField();
        if ($category->extraFieldsGroup) {
            $extraFields = $extraFieldModel->getExtraFieldsByGroup($category->extraFieldsGroup);
        } else {
            $extraFields = NULL;
        }
        for ($i = 0; $i < sizeof($extraFields); $i++) {
            $extraFields[$i]->element = $extraFieldModel->renderExtraField($extraFields[$i], $item->id);
        }
        if ($item->id) {
            $item->attachments = $model->getAttachments($item->id);
        } else {
            $item->attachments = NULL;
        }
        $tags = $model->getAvailableTags($item->id);
        $lists['tags'] = JHTML::_('select.genericlist', $tags, 'tags', 'multiple="multiple" size="10" ', 'id', 'name');
        if (isset($item->id)) {
            $item->tags = $model->getCurrentTags($item->id);
            $lists['selectedTags'] = JHTML::_('select.genericlist', $item->tags, 'selectedTags[]', 'multiple="multiple" size="10" ', 'id', 'name');
        } else {
            $lists['selectedTags'] = '<select size="10" multiple="multiple" id="selectedTags" name="selectedTags[]"></select>';
        }
        if (JFile::exists(JPATH_SITE . DS . 'media' . DS . 'k2' . DS . 'items' . DS . 'cache' . DS . md5("Image" . $item->id) . '_L.jpg')) {
            $item->image = JURI::root() . 'media/k2/items/cache/' . md5("Image" . $item->id) . '_L.jpg';
        }
        if (JFile::exists(JPATH_SITE . DS . 'media' . DS . 'k2' . DS . 'items' . DS . 'cache' . DS . md5("Image" . $item->id) . '_S.jpg')) {
            $item->thumb = JURI::root() . 'media/k2/items/cache/' . md5("Image" . $item->id) . '_S.jpg';
        }
        $lists['metadata'] = new JParameter($item->metadata);
        JPluginHelper::importPlugin('k2');
        $dispatcher =& JDispatcher::getInstance();
        $K2PluginsItemContent = $dispatcher->trigger('onRenderAdminForm', array(&$item, 'item', 'content'));
        $this->assignRef('K2PluginsItemContent', $K2PluginsItemContent);
        $K2PluginsItemImage = $dispatcher->trigger('onRenderAdminForm', array(&$item, 'item', 'image'));
        $this->assignRef('K2PluginsItemImage', $K2PluginsItemImage);
        $K2PluginsItemGallery = $dispatcher->trigger('onRenderAdminForm', array(&$item, 'item', 'gallery'));
        $this->assignRef('K2PluginsItemGallery', $K2PluginsItemGallery);
        $K2PluginsItemVideo = $dispatcher->trigger('onRenderAdminForm', array(&$item, 'item', 'video'));
        $this->assignRef('K2PluginsItemVideo', $K2PluginsItemVideo);
        $K2PluginsItemExtraFields = $dispatcher->trigger('onRenderAdminForm', array(&$item, 'item', 'extra-fields'));
        $this->assignRef('K2PluginsItemExtraFields', $K2PluginsItemExtraFields);
        $K2PluginsItemAttachments = $dispatcher->trigger('onRenderAdminForm', array(&$item, 'item', 'attachments'));
        $this->assignRef('K2PluginsItemAttachments', $K2PluginsItemAttachments);
        $K2PluginsItemOther = $dispatcher->trigger('onRenderAdminForm', array(&$item, 'item', 'other'));
        $this->assignRef('K2PluginsItemOther', $K2PluginsItemOther);
        $form = new JParameter('', JPATH_COMPONENT_ADMINISTRATOR . DS . 'models' . DS . 'item.xml');
        $form->loadINI($item->params);
        $this->assignRef('form', $form);
        $this->assignRef('extraFields', $extraFields);
        $this->assignRef('options', $options);
        $this->assignRef('row', $item);
        $this->assignRef('lists', $lists);
        $this->assignRef('params', $params);
        parent::display();
    }
Ejemplo n.º 5
0
 function display($tpl = null)
 {
     $mainframe =& JFactory::getApplication();
     $db =& JFactory::getDBO();
     jimport('joomla.filesystem.file');
     jimport('joomla.html.pane');
     JHTML::_('behavior.keepalive');
     JRequest::setVar('hidemainmenu', 1);
     $document =& JFactory::getDocument();
     $document->addScript(JURI::root() . 'administrator/components/com_k2/lib/Autocompleter.js');
     $document->addScript(JURI::root() . 'administrator/components/com_k2/lib/observer.js');
     $document->addScript(JURI::root() . 'administrator/components/com_k2/lib/nicEdit.js');
     $js = "function initExtraFieldsEditor(){\n\t\t\t\$\$('.k2ExtraFieldEditor').each(function(element) {\n\t\t\t\tvar id = element.id;\n\t\t\t\tif (typeof JContentEditor != 'undefined') {\n\t\t\t\t\tif (tinyMCE.get(id)) {\n\t\t\t\t\t\ttinymce.EditorManager.remove(tinyMCE.get(id));\n\t\t\t\t\t}\n\t\t\t\t\ttinyMCE.execCommand('mceAddControl', false, id);\n\t\t\t\t} else {\n\t\t\t\t\tnew nicEditor({fullPanel: true, maxHeight: 180, iconsPath: '" . JURI::root() . "administrator/components/com_k2/images/system/nicEditorIcons.gif'}).panelInstance(element.getProperty('id'));\n\t\t\t\t}\n\t\t\t});\n\t\t}\n\t\tfunction syncExtraFieldsEditor(){\n\t\t\t\$\$('.k2ExtraFieldEditor').each(function(element){\n\t\t\t\teditor = nicEditors.findEditor(element.getProperty('id'));\n\t\t\t\tif(typeof editor != 'undefined'){\n\t\t\t\t\teditor.saveContent();\n\t\t\t\t}\n    \t\t});\n\t\t}\n\t\t";
     $document->addScriptDeclaration($js);
     $model =& $this->getModel();
     $item = $model->getData();
     JFilterOutput::objectHTMLSafe($item, ENT_QUOTES, 'video');
     $user =& JFactory::getUser();
     if (JTable::isCheckedOut($user->get('id'), $item->checked_out)) {
         $msg = JText::sprintf('DESCBEINGEDITTED', JText::_('The item'), $item->title);
         $mainframe->redirect('index.php?option=com_k2', $msg);
     }
     if ($item->id) {
         $item->checkout($user->get('id'));
     } else {
         $createdate =& JFactory::getDate();
         $item->published = 1;
         $item->publish_up = $createdate->toUnix();
         $item->publish_down = JText::_('Never');
         $item->created = $createdate->toUnix();
         $item->modified = $db->getNullDate();
     }
     $item->created = JHTML::_('date', $item->created, '%Y-%m-%d %H:%M:%S');
     $item->publish_up = JHTML::_('date', $item->publish_up, '%Y-%m-%d %H:%M:%S');
     if (JHTML::_('date', $item->publish_down, '%Y') <= 1969 || $item->publish_down == $db->getNullDate()) {
         $item->publish_down = JText::_('Never');
     } else {
         $item->publish_down = JHTML::_('date', $item->publish_down, '%Y-%m-%d %H:%M:%S');
     }
     $params =& JComponentHelper::getParams('com_k2');
     $wysiwyg =& JFactory::getEditor();
     if ($params->get("mergeEditors")) {
         if (JString::strlen($item->fulltext) > 1) {
             $textValue = $item->introtext . "<hr id=\"system-readmore\" />" . $item->fulltext;
         } else {
             $textValue = $item->introtext;
         }
         $text = $wysiwyg->display('text', $textValue, '100%', '400', '40', '5');
         $this->assignRef('text', $text);
     } else {
         $introtext = $wysiwyg->display('introtext', $item->introtext, '100%', '400', '40', '5', array('readmore'));
         $this->assignRef('introtext', $introtext);
         $fulltext = $wysiwyg->display('fulltext', $item->fulltext, '100%', '400', '40', '5', array('readmore'));
         $this->assignRef('fulltext', $fulltext);
     }
     $lists = array();
     $lists['published'] = JHTML::_('select.booleanlist', 'published', 'class="inputbox"', $item->published);
     $lists['access'] = JHTML::_('list.accesslevel', $item);
     $query = "SELECT ordering AS value, title AS text FROM #__k2_items WHERE catid={$item->catid}";
     $lists['ordering'] = JHTML::_('list.specificordering', $item, $item->id, $query);
     if (!$item->id) {
         $item->catid = $mainframe->getUserStateFromRequest('com_k2itemsfilter_category', 'catid', 0, 'int');
     }
     require_once JPATH_COMPONENT . DS . 'models' . DS . 'categories.php';
     $categoriesModel = new K2ModelCategories();
     $categories = $categoriesModel->categoriesTree();
     $lists['catid'] = JHTML::_('select.genericlist', $categories, 'catid', 'class="inputbox"', 'value', 'text', $item->catid);
     $lists['checkSIG'] = $model->checkSIG();
     $lists['checkAllVideos'] = $model->checkAllVideos();
     $remoteVideo = false;
     $providerVideo = false;
     $embedVideo = false;
     if (stristr($item->video, 'remote}') !== false) {
         $remoteVideo = true;
         $options['startOffset'] = 1;
     }
     $providers = $model->getVideoProviders();
     if (count($providers)) {
         foreach ($providers as $provider) {
             $providersOptions[] = JHTML::_('select.option', $provider, $provider);
             if (stristr($item->video, "{{$provider}}") !== false) {
                 $providerVideo = true;
                 $options['startOffset'] = 2;
             }
         }
     }
     if (JString::substr($item->video, 0, 1) !== '{') {
         $embedVideo = true;
         $options['startOffset'] = 3;
     }
     $lists['uploadedVideo'] = !$remoteVideo && !$providerVideo && !$embedVideo ? true : false;
     if ($lists['uploadedVideo'] || $item->video == '') {
         $options['startOffset'] = 0;
     }
     $lists['remoteVideo'] = $remoteVideo ? preg_replace('%\\{[a-z0-9-_]*\\}(.*)\\{/[a-z0-9-_]*\\}%i', '\\1', $item->video) : '';
     $lists['remoteVideoType'] = $remoteVideo ? preg_replace('%\\{([a-z0-9-_]*)\\}.*\\{/[a-z0-9-_]*\\}%i', '\\1', $item->video) : '';
     $lists['providerVideo'] = $providerVideo ? preg_replace('%\\{[a-z0-9-_]*\\}(.*)\\{/[a-z0-9-_]*\\}%i', '\\1', $item->video) : '';
     $lists['providerVideoType'] = $providerVideo ? preg_replace('%\\{([a-z0-9-_]*)\\}.*\\{/[a-z0-9-_]*\\}%i', '\\1', $item->video) : '';
     $lists['embedVideo'] = $embedVideo ? $item->video : '';
     if (isset($providersOptions)) {
         $lists['providers'] = JHTML::_('select.genericlist', $providersOptions, 'videoProvider', '', 'value', 'text', $lists['providerVideoType']);
     }
     JPluginHelper::importPlugin('content', 'jw_sigpro');
     JPluginHelper::importPlugin('content', 'jw_allvideos');
     $dispatcher =& JDispatcher::getInstance();
     $params->set('galleries_rootfolder', 'media/k2/galleries');
     $params->set('thb_width', '150');
     $params->set('thb_height', '120');
     $params->set('popup_engine', 'mootools_slimbox');
     $params->set('enabledownload', '0');
     $item->text = $item->gallery;
     $dispatcher->trigger('onPrepareContent', array(&$item, &$params, null));
     $item->gallery = $item->text;
     if (!$embedVideo) {
         $params->set('vfolder', 'media/k2/videos');
         if (JString::strpos($item->video, 'remote}')) {
             preg_match("#}(.*?){/#s", $item->video, $matches);
             if (JString::substr($matches[1], 0, 7) != 'http://') {
                 $item->video = JString::str_ireplace($matches[1], JURI::root() . $matches[1], $item->video);
             }
         }
         $item->text = $item->video;
         $dispatcher->trigger('onPrepareContent', array(&$item, &$params, null));
         $item->video = $item->text;
     } else {
         // no nothing
     }
     if (isset($item->created_by)) {
         $author =& JUser::getInstance($item->created_by);
         $item->author = $author->name;
     }
     if (isset($item->modified_by)) {
         $moderator =& JUser::getInstance($item->modified_by);
         $item->moderator = $moderator->name;
     }
     if ($item->id) {
         $active = $item->created_by;
     } else {
         $active = $user->id;
     }
     $lists['authors'] = JHTML::_('list.users', 'created_by', $active, false);
     require_once JPATH_COMPONENT . DS . 'models' . DS . 'categories.php';
     $categoriesModel = new K2ModelCategories();
     $categories_option[] = JHTML::_('select.option', 0, JText::_('- Select category -'));
     $categories = $categoriesModel->categoriesTree(NUll, true, false);
     $categories_options = @array_merge($categories_option, $categories);
     $lists['categories'] = JHTML::_('select.genericlist', $categories_options, 'catid', '', 'value', 'text', $item->catid);
     JTable::addIncludePath(JPATH_COMPONENT . DS . 'tables');
     $category =& JTable::getInstance('K2Category', 'Table');
     $category->load($item->catid);
     require_once JPATH_COMPONENT . DS . 'models' . DS . 'extrafield.php';
     $extraFieldModel = new K2ModelExtraField();
     if ($item->id) {
         $extraFields = $extraFieldModel->getExtraFieldsByGroup($category->extraFieldsGroup);
     } else {
         $extraFields = NULL;
     }
     for ($i = 0; $i < sizeof($extraFields); $i++) {
         $extraFields[$i]->element = $extraFieldModel->renderExtraField($extraFields[$i], $item->id);
     }
     if ($item->id) {
         $item->attachments = $model->getAttachments($item->id);
         $rating = $model->getRating();
         if (is_null($rating)) {
             $item->ratingSum = 0;
             $item->ratingCount = 0;
         } else {
             $item->ratingSum = (int) $rating->rating_sum;
             $item->ratingCount = (int) $rating->rating_count;
         }
     } else {
         $item->attachments = NULL;
         $item->ratingSum = 0;
         $item->ratingCount = 0;
     }
     if ($user->gid < 24 && $params->get('lockTags')) {
         $params->set('taggingSystem', 0);
     }
     $tags = $model->getAvailableTags($item->id);
     $lists['tags'] = JHTML::_('select.genericlist', $tags, 'tags', 'multiple="multiple" size="10" ', 'id', 'name');
     if (isset($item->id)) {
         $item->tags = $model->getCurrentTags($item->id);
         $lists['selectedTags'] = JHTML::_('select.genericlist', $item->tags, 'selectedTags[]', 'multiple="multiple" size="10" ', 'id', 'name');
     } else {
         $lists['selectedTags'] = '<select size="10" multiple="multiple" id="selectedTags" name="selectedTags[]"></select>';
     }
     $lists['metadata'] = new JParameter($item->metadata);
     if (JFile::exists(JPATH_SITE . DS . 'media' . DS . 'k2' . DS . 'items' . DS . 'cache' . DS . md5("Image" . $item->id) . '_L.jpg')) {
         $item->image = JURI::root() . 'media/k2/items/cache/' . md5("Image" . $item->id) . '_L.jpg';
     }
     if (JFile::exists(JPATH_SITE . DS . 'media' . DS . 'k2' . DS . 'items' . DS . 'cache' . DS . md5("Image" . $item->id) . '_S.jpg')) {
         $item->thumb = JURI::root() . 'media/k2/items/cache/' . md5("Image" . $item->id) . '_S.jpg';
     }
     JPluginHelper::importPlugin('k2');
     $dispatcher =& JDispatcher::getInstance();
     $K2PluginsItemContent = $dispatcher->trigger('onRenderAdminForm', array(&$item, 'item', 'content'));
     $this->assignRef('K2PluginsItemContent', $K2PluginsItemContent);
     $K2PluginsItemImage = $dispatcher->trigger('onRenderAdminForm', array(&$item, 'item', 'image'));
     $this->assignRef('K2PluginsItemImage', $K2PluginsItemImage);
     $K2PluginsItemGallery = $dispatcher->trigger('onRenderAdminForm', array(&$item, 'item', 'gallery'));
     $this->assignRef('K2PluginsItemGallery', $K2PluginsItemGallery);
     $K2PluginsItemVideo = $dispatcher->trigger('onRenderAdminForm', array(&$item, 'item', 'video'));
     $this->assignRef('K2PluginsItemVideo', $K2PluginsItemVideo);
     $K2PluginsItemExtraFields = $dispatcher->trigger('onRenderAdminForm', array(&$item, 'item', 'extra-fields'));
     $this->assignRef('K2PluginsItemExtraFields', $K2PluginsItemExtraFields);
     $K2PluginsItemAttachments = $dispatcher->trigger('onRenderAdminForm', array(&$item, 'item', 'attachments'));
     $this->assignRef('K2PluginsItemAttachments', $K2PluginsItemAttachments);
     $K2PluginsItemOther = $dispatcher->trigger('onRenderAdminForm', array(&$item, 'item', 'other'));
     $this->assignRef('K2PluginsItemOther', $K2PluginsItemOther);
     $form = new JParameter('', JPATH_COMPONENT . DS . 'models' . DS . 'item.xml');
     $form->loadINI($item->params);
     $this->assignRef('form', $form);
     $this->assignRef('extraFields', $extraFields);
     $this->assignRef('options', $options);
     $this->assignRef('row', $item);
     $this->assignRef('lists', $lists);
     $this->assignRef('params', $params);
     $this->assignRef('user', $user);
     JRequest::getInt('cid') ? $title = JText::_('Edit Item') : ($title = JText::_('Add Item'));
     JToolBarHelper::title($title, 'k2.png');
     JToolBarHelper::save();
     JToolBarHelper::custom('saveAndNew', 'save.png', 'save_f2.png', 'Save &amp; New', false);
     JToolBarHelper::apply();
     JToolBarHelper::cancel();
     parent::display($tpl);
 }