コード例 #1
0
    function fetchElement($name, $value, &$node, $control_name)
    {
        JHTML::_('behavior.modal');
        $params = JComponentHelper::getParams('com_k2');
        $document = JFactory::getDocument();
        if (version_compare(JVERSION, '1.6.0', 'ge')) {
            JHtml::_('behavior.framework');
        } else {
            JHTML::_('behavior.mootools');
        }
        K2HelperHTML::loadjQuery();
        $mainframe = JFactory::getApplication();
        if (K2_JVERSION != '15') {
            $fieldName = $name;
            if (!$node->attributes()->multiple) {
                $fieldName .= '[]';
            }
            $image = JURI::root(true) . '/administrator/templates/' . $mainframe->getTemplate() . '/images/admin/publish_x.png';
        } else {
            $fieldName = $control_name . '[' . $name . '][]';
            $image = JURI::root(true) . '/administrator/images/publish_x.png';
        }
        $js = "\n\t\tfunction jSelectCategory(id, title, object) {\n\t\t\tvar exists = false;\n\t\t\t\$K2('#categoriesList input').each(function(){\n\t\t\t\t\tif(\$K2(this).val()==id){\n\t\t\t\t\t\talert('" . JText::_('K2_THE_SELECTED_CATEGORY_IS_ALREADY_IN_THE_LIST', true) . "');\n\t\t\t\t\t\texists = true;\n\t\t\t\t\t}\n\t\t\t});\n\t\t\tif(!exists){\n\t\t\t\tvar container = \$K2('<li/>').appendTo(\$K2('#categoriesList'));\n\t\t\t\tvar img = \$K2('<img/>',{class:'remove', src:'" . $image . "'}).appendTo(container);\n\t\t\t\timg.click(function(){\$K2(this).parent().remove();});\n\t\t\t\tvar span = \$K2('<span/>',{class:'handle'}).html(title).appendTo(container);\n\t\t\t\tvar input = \$K2('<input/>',{value:id, type:'hidden', name:'" . $fieldName . "'}).appendTo(container);\n\t\t\t\tvar div = \$K2('<div/>',{style:'clear:both;'}).appendTo(container);\n\t\t\t\t\$K2('#categoriesList').sortable('refresh');\n\t\t\t\talert('" . JText::_('K2_CATEGORY_ADDED_IN_THE_LIST', true) . "');\n\t\t\t}\n\t\t}\n\n\t\t\$K2(document).ready(function(){\n\t\t\t\$K2('#categoriesList').sortable({\n\t\t\t\tcontainment: '#categoriesList',\n\t\t\t\titems: 'li',\n\t\t\t\thandle: 'span.handle'\n\t\t\t});\n\t\t\t\$K2('body').css('overflow-y', 'scroll');\n\t\t\t\$K2('#categoriesList .remove').click(function(){\n\t\t\t\t\$K2(this).parent().remove();\n\t\t\t});\n\t\t});\n\t\t";
        $document->addScriptDeclaration($js);
        $document->addStyleSheet(JURI::root(true) . '/media/k2/assets/css/k2.modules.css?v=2.6.0');
        $current = array();
        if (is_string($value) && !empty($value)) {
            $current[] = $value;
        }
        if (is_array($value)) {
            $current = $value;
        }
        $output = '
		<div class="button2-left">
			<div class="blank">
				<a class="modal btn" title="' . JText::_('K2_CLICK_TO_SELECT_ONE_OR_MORE_CATEGORIES') . '"  href="index.php?option=com_k2&view=categories&task=element&tmpl=component" rel="{handler: \'iframe\', size: {x: 700, y: 450}}">' . JText::_('K2_CLICK_TO_SELECT_ONE_OR_MORE_CATEGORIES') . '</a>
			</div>
		</div>
		<div style="clear:both;"></div>
		';
        JTable::addIncludePath(JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_k2' . DS . 'tables');
        $output .= '<ul id="categoriesList">';
        foreach ($current as $id) {
            $row = JTable::getInstance('K2Category', 'Table');
            $row->load($id);
            $output .= '
			<li>
				<img class="remove" src="' . $image . '"/>
				<span class="handle">' . $row->name . '</span>
				<input type="hidden" value="' . $row->id . '" name="' . $fieldName . '"/>
				<span style="clear:both;"></span>
			</li>
			';
        }
        $output .= '</ul>';
        return $output;
    }
コード例 #2
0
ファイル: comments.php プロジェクト: GitIPFire/Homeworks
    public function display($cachable = false, $urlparams = array())
    {

        $user = JFactory::getUser();
        if ($user->guest)
        {
            $uri = JFactory::getURI();
            if (K2_JVERSION != '15')
            {
                $url = 'index.php?option=com_users&view=login&return='.base64_encode($uri->toString());
            }
            else
            {
                $url = 'index.php?option=com_user&view=login&return='.base64_encode($uri->toString());
            }
            $application = JFactory::getApplication();
            $application->redirect(JRoute::_($url, false), JText::_('K2_YOU_NEED_TO_LOGIN_FIRST'));
        }
        JRequest::setVar('tmpl', 'component');

        $params = JComponentHelper::getParams('com_k2');

        $document = JFactory::getDocument();

        if (version_compare(JVERSION, '1.6.0', 'ge'))
        {
            JHtml::_('behavior.framework');
        }
        else
        {
            JHTML::_('behavior.mootools');
        }

        // Language
        $language = JFactory::getLanguage();
        $language->load('com_k2', JPATH_ADMINISTRATOR);

        // CSS
        $document->addStyleSheet(JURI::root(true).'/media/k2/assets/css/k2.css?v=2.6.6');

        // JS
        K2HelperHTML::loadjQuery(true);
        $document->addScript(JURI::root(true).'/media/k2/assets/js/k2.js?v=2.6.6&amp;sitepath='.JURI::root(true).'/');

        $this->addViewPath(JPATH_COMPONENT_ADMINISTRATOR.DS.'views');
        $this->addModelPath(JPATH_COMPONENT_ADMINISTRATOR.DS.'models');
        $view = $this->getView('comments', 'html');
        $view->addTemplatePath(JPATH_COMPONENT_ADMINISTRATOR.DS.'views'.DS.'comments'.DS.'tmpl');
        $view->addHelperPath(JPATH_COMPONENT_ADMINISTRATOR.DS.'helpers');
        $view->display();
    }
コード例 #3
0
ファイル: items.php プロジェクト: educakanchay/educa
    function fetchElement($name, $value, &$node, $control_name)
    {
        $params = JComponentHelper::getParams('com_k2');
        $document = JFactory::getDocument();
        if (version_compare(JVERSION, '1.6.0', 'ge')) {
            JHtml::_('behavior.framework');
        } else {
            JHTML::_('behavior.mootools');
        }
        K2HelperHTML::loadjQuery();
        $mainframe = JFactory::getApplication();
        if (K2_JVERSION != '15') {
            $fieldName = $name;
            $attribute = K2_JVERSION == '25' ? $node->getAttribute('multiple') : $node->attributes()->multiple;
            if (!$attribute) {
                $fieldName .= '[]';
            }
            $image = JURI::root(true) . '/administrator/templates/' . $mainframe->getTemplate() . '/images/admin/publish_x.png';
        } else {
            $fieldName = $control_name . '[' . $name . '][]';
            $image = JURI::root(true) . '/administrator/images/publish_x.png';
        }
        $js = "\n\t\tfunction jSelectItem(id, title, object) {\n\t\t\tvar exists = false;\n\t\t\t\$K2('#itemsList input').each(function(){\n\t\t\t\t\tif(\$K2(this).val()==id){\n\t\t\t\t\t\talert('" . JText::_('K2_THE_SELECTED_ITEM_IS_ALREADY_IN_THE_LIST') . "');\n\t\t\t\t\t\texists = true;\n\t\t\t\t\t}\n\t\t\t});\n\t\t\tif(!exists){\n\t\t\t\tvar container = \$K2('<li/>').appendTo(\$K2('#itemsList'));\n\t\t\t\tvar img = \$K2('<img/>',{'class':'remove', src:'" . $image . "'}).appendTo(container);\n\t\t\t\timg.click(function(){\$K2(this).parent().remove();});\n\t\t\t\tvar span = \$K2('<span/>',{'class':'handle'}).html(title).appendTo(container);\n\t\t\t\tvar input = \$K2('<input/>',{value:id, type:'hidden', name:'" . $fieldName . "'}).appendTo(container);\n\t\t\t\tvar div = \$K2('<div/>',{style:'clear:both;'}).appendTo(container);\n\t\t\t\t\$K2('#itemsList').sortable('refresh');\n\t\t\t\talert('" . JText::_('K2_ITEM_ADDED_IN_THE_LIST', true) . "');\n\t\t\t}\n\t\t}\n\t\t\n\t\t\$K2(document).ready(function(){\n\t\t\t\$K2('#itemsList').sortable({\n\t\t\t\tcontainment: '#itemsList',\n\t\t\t\titems: 'li',\n\t\t\t\thandle: 'span.handle'\n\t\t\t});\n\t\t\t\$K2('#itemsList .remove').click(function(){\n\t\t\t\t\$K2(this).parent().remove();\n\t\t\t});\n\t\t});\n\t\t";
        $document->addScriptDeclaration($js);
        $document->addStyleSheet(JURI::root(true) . '/media/k2/assets/css/k2.modules.css?v=2.6.8');
        $current = array();
        if (is_string($value) && !empty($value)) {
            $current[] = $value;
        }
        if (is_array($value)) {
            $current = $value;
        }
        JTable::addIncludePath(JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_k2' . DS . 'tables');
        $output = '<div style="clear:both"></div><ul id="itemsList">';
        foreach ($current as $id) {
            $row = JTable::getInstance('K2Item', 'Table');
            $row->load($id);
            $output .= '
			<li>
				<img class="remove" src="' . $image . '" alt="' . JText::_('K2_REMOVE_ENTRY_FROM_LIST') . '" />
				<span class="handle">' . $row->title . '</span>
				<input type="hidden" value="' . $row->id . '" name="' . $fieldName . '"/>
				<span style="clear:both;"></span>
			</li>
			';
        }
        $output .= '</ul>';
        return $output;
    }
コード例 #4
0
 function fetchElement($name, $value, &$node, $control_name)
 {
     $params = JComponentHelper::getParams('com_k2');
     $document = JFactory::getDocument();
     if (version_compare(JVERSION, '1.6.0', 'ge')) {
         JHtml::_('behavior.framework');
     } else {
         JHTML::_('behavior.mootools');
     }
     K2HelperHTML::loadjQuery();
     $db = JFactory::getDBO();
     $query = 'SELECT m.* FROM #__k2_categories m WHERE trash = 0 ORDER BY parent, ordering';
     $db->setQuery($query);
     $mitems = $db->loadObjectList();
     $children = array();
     if ($mitems) {
         foreach ($mitems as $v) {
             if (K2_JVERSION != '15') {
                 $v->title = $v->name;
                 $v->parent_id = $v->parent;
             }
             $pt = $v->parent;
             $list = @$children[$pt] ? $children[$pt] : array();
             array_push($list, $v);
             $children[$pt] = $list;
         }
     }
     $list = JHTML::_('menu.treerecurse', 0, '', array(), $children, 9999, 0, 0);
     $mitems = array();
     foreach ($list as $item) {
         $item->treename = JString::str_ireplace('&#160;', '- ', $item->treename);
         $mitems[] = JHTML::_('select.option', $item->id, '   ' . $item->treename);
     }
     $doc = JFactory::getDocument();
     if (K2_JVERSION != '15') {
         $js = "\n\t\t\t\$K2(document).ready(function(){\n\t\t\t\t\n\t\t\t\t\$K2('#jform_params_catfilter0').click(function(){\n\t\t\t\t\t\$K2('#jformparamscategory_id').attr('disabled', 'disabled');\n\t\t\t\t\t\$K2('#jformparamscategory_id option').each(function() {\n\t\t\t\t\t\t\$K2(this).attr('selected', 'selected');\n\t\t\t\t\t});\n\t\t\t\t\t\$K2('#jformparamscategory_id').trigger('liszt:updated');\n\t\t\t\t});\n\t\t\t\t\n\t\t\t\t\$K2('#jform_params_catfilter1').click(function(){\n\t\t\t\t\t\$K2('#jformparamscategory_id').removeAttr('disabled');\n\t\t\t\t\t\$K2('#jformparamscategory_id option').each(function() {\n\t\t\t\t\t\t\$K2(this).removeAttr('selected');\n\t\t\t\t\t});\n\t\t\t\t\t\$K2('#jformparamscategory_id').trigger('liszt:updated');\n\t\t\t\t});\n\t\t\t\t\n\t\t\t\tif (\$K2('#jform_params_catfilter0').attr('checked')) {\n\t\t\t\t\t\$K2('#jformparamscategory_id').attr('disabled', 'disabled');\n\t\t\t\t\t\$K2('#jformparamscategory_id option').each(function() {\n\t\t\t\t\t\t\$K2(this).attr('selected', 'selected');\n\t\t\t\t\t});\n\t\t\t\t\t\$K2('#jformparamscategory_id').trigger('liszt:updated');\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\tif (\$K2('#jform_params_catfilter1').attr('checked')) {\n\t\t\t\t\t\$K2('#jformparamscategory_id').removeAttr('disabled');\n\t\t\t\t\t\$K2('#jformparamscategory_id').trigger('liszt:updated');\n\t\t\t\t}\n\t\t\t\t\n\t\t\t});\n\t\t\t";
     } else {
         $js = "\n\t\t\t\$K2(document).ready(function(){\n\t\t\t\t\n\t\t\t\t\$K2('#paramscatfilter0').click(function(){\n\t\t\t\t\t\$K2('#paramscategory_id').attr('disabled', 'disabled');\n\t\t\t\t\t\$K2('#paramscategory_id option').each(function() {\n\t\t\t\t\t\t\$K2(this).attr('selected', 'selected');\n\t\t\t\t\t});\n\t\t\t\t});\n\t\t\t\t\n\t\t\t\t\$K2('#paramscatfilter1').click(function(){\n\t\t\t\t\t\$K2('#paramscategory_id').removeAttr('disabled');\n\t\t\t\t\t\$K2('#paramscategory_id option').each(function() {\n\t\t\t\t\t\t\$K2(this).removeAttr('selected');\n\t\t\t\t\t});\n\t\n\t\t\t\t});\n\t\t\t\t\n\t\t\t\tif (\$K2('#paramscatfilter0').attr('checked')) {\n\t\t\t\t\t\$K2('#paramscategory_id').attr('disabled', 'disabled');\n\t\t\t\t\t\$K2('#paramscategory_id option').each(function() {\n\t\t\t\t\t\t\$K2(this).attr('selected', 'selected');\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\tif (\$K2('#paramscatfilter1').attr('checked')) {\n\t\t\t\t\t\$K2('#paramscategory_id').removeAttr('disabled');\n\t\t\t\t}\n\t\t\t\t\n\t\t\t});\n\t\t\t";
     }
     if (K2_JVERSION != '15') {
         $fieldName = $name . '[]';
     } else {
         $fieldName = $control_name . '[' . $name . '][]';
     }
     $doc->addScriptDeclaration($js);
     $output = JHTML::_('select.genericlist', $mitems, $fieldName, 'class="inputbox" multiple="multiple" size="10"', 'value', 'text', $value);
     return $output;
 }
コード例 #5
0
ファイル: k2.php プロジェクト: emavro/k2
    function onAfterRoute()
    {
        $mainframe = JFactory::getApplication();
        $user = JFactory::getUser();
        $basepath = $mainframe->isSite() ? JPATH_SITE : JPATH_ADMINISTRATOR;
        JPlugin::loadLanguage('com_k2', $basepath);
        if (K2_JVERSION != '15') {
            JPlugin::loadLanguage('com_k2.j16', JPATH_ADMINISTRATOR, null, true);
        }
        if ($mainframe->isAdmin()) {
            return;
        }
        if ((JRequest::getCmd('task') == 'add' || JRequest::getCmd('task') == 'edit') && JRequest::getCmd('option') == 'com_k2') {
            return;
        }
        // Joomla! modal trigger
        if (!$user->guest || JRequest::getCmd('option') == 'com_k2' && JRequest::getCmd('view') == 'item' || defined('K2_JOOMLA_MODAL_REQUIRED')) {
            JHTML::_('behavior.modal');
        }
        $params = JComponentHelper::getParams('com_k2');
        $document = JFactory::getDocument();
        // jQuery and K2 JS loading
        K2HelperHTML::loadjQuery();
        $document->addScript(JURI::root(true) . '/components/com_k2/js/k2.js?v2.7.0&amp;sitepath=' . JURI::root(true) . '/');
        //$document->addScriptDeclaration("var K2SitePath = '".JURI::root(true)."/';");
        if (JRequest::getCmd('task') == 'search' && $params->get('googleSearch')) {
            $language = JFactory::getLanguage();
            $lang = $language->getTag();
            // Fallback to the new container ID without breaking things
            $googleSearchContainerID = trim($params->get('googleSearchContainer', 'k2GoogleSearchContainer'));
            if ($googleSearchContainerID == 'k2Container') {
                $googleSearchContainerID = 'k2GoogleSearchContainer';
            }
            $document->addScript('http://www.google.com/jsapi');
            $js = '
			//<![CDATA[
			google.load("search", "1", {"language" : "' . $lang . '"});

			function OnLoad(){
				var searchControl = new google.search.SearchControl();
				var siteSearch = new google.search.WebSearch();
				siteSearch.setUserDefinedLabel("' . $mainframe->getCfg('sitename') . '");
				siteSearch.setUserDefinedClassSuffix("k2");
				options = new google.search.SearcherOptions();
				options.setExpandMode(google.search.SearchControl.EXPAND_MODE_OPEN);
				siteSearch.setSiteRestriction("' . JURI::root() . '");
				searchControl.addSearcher(siteSearch, options);
				searchControl.setResultSetSize(google.search.Search.LARGE_RESULTSET);
				searchControl.setLinkTarget(google.search.Search.LINK_TARGET_SELF);
				searchControl.draw(document.getElementById("' . $googleSearchContainerID . '"));
				searchControl.execute("' . JRequest::getString('searchword') . '");
			}

			google.setOnLoadCallback(OnLoad);
			//]]>
 			';
            $document->addScriptDeclaration($js);
        }
        // Add related CSS to the <head>
        if ($document->getType() == 'html' && $params->get('enable_css')) {
            jimport('joomla.filesystem.file');
            // k2.css
            if (JFile::exists(JPATH_SITE . DS . 'templates' . DS . $mainframe->getTemplate() . DS . 'css' . DS . 'k2.css')) {
                $document->addStyleSheet(JURI::root(true) . '/templates/' . $mainframe->getTemplate() . '/css/k2.css');
            } else {
                $document->addStyleSheet(JURI::root(true) . '/components/com_k2/css/k2.css');
            }
            // k2.print.css
            if (JRequest::getInt('print') == 1) {
                if (JFile::exists(JPATH_SITE . DS . 'templates' . DS . $mainframe->getTemplate() . DS . 'css' . DS . 'k2.print.css')) {
                    $document->addStyleSheet(JURI::root(true) . '/templates/' . $mainframe->getTemplate() . '/css/k2.print.css', 'text/css', 'print');
                } else {
                    $document->addStyleSheet(JURI::root(true) . '/components/com_k2/css/k2.print.css', 'text/css', 'print');
                }
            }
        }
    }
コード例 #6
0
ファイル: k2.php プロジェクト: brenot/forumdesenvolvimento
    } else {
        $user->gid = 1;
    }
    if ($params->get('lockTags') && !$user->authorise('core.admin', 'com_k2') && ($view == 'tags' || $view == 'tag') || !$user->authorise('core.admin', 'com_k2') && ($view == 'extrafield' || $view == 'extrafields' || $view == 'extrafieldsgroup' || $view == 'extrafieldsgroups' || $view == 'user' || $view == 'users' && $task != 'element' || $view == 'usergroup' || $view == 'usergroups')) {
        JError::raiseError(403, JText::_('K2_ALERTNOTAUTH'));
    }
}
$document = JFactory::getDocument();
if (version_compare(JVERSION, '1.6.0', 'ge')) {
    JHtml::_('behavior.framework');
} else {
    JHTML::_('behavior.mootools');
}
// CSS
$document->addStyleSheet(JURI::root(true) . '/media/k2/assets/css/k2.css?v=2.6.9');
K2HelperHTML::loadjQuery(true, JRequest::getCmd('view') == 'media');
// JS
if (K2_JVERSION == '30') {
    JHtml::_('formbehavior.chosen', 'select');
}
$document->addScriptDeclaration('K2JVersion = "' . K2_JVERSION . '";');
$document->addScript(JURI::root(true) . '/media/k2/assets/js/k2.js?v=2.6.9&amp;sitepath=' . JURI::root(true) . '/');
// Container CSS class definition
if (K2_JVERSION == '15') {
    $k2CSSContainerClass = ' isJ15';
} elseif (K2_JVERSION == '25') {
    $k2CSSContainerClass = ' isJ25';
} elseif (K2_JVERSION == '30') {
    $k2CSSContainerClass = ' isJ25 isJ30';
} else {
    $k2CSSContainerClass = '';
コード例 #7
0
ファイル: item.php プロジェクト: educakanchay/educa
 function users()
 {
     $itemID = JRequest::getInt('itemID');
     JTable::addIncludePath(JPATH_COMPONENT_ADMINISTRATOR . DS . 'tables');
     $item = JTable::getInstance('K2Item', 'Table');
     $item->load($itemID);
     if (!K2HelperPermissions::canAddItem() && !K2HelperPermissions::canEditItem($item->created_by, $item->catid)) {
         JError::raiseError(403, JText::_('K2_ALERTNOTAUTH'));
     }
     $K2Permissions = K2Permissions::getInstance();
     if (!$K2Permissions->permissions->get('editAll')) {
         JError::raiseError(403, JText::_('K2_ALERTNOTAUTH'));
     }
     JRequest::setVar('tmpl', 'component');
     $mainframe = JFactory::getApplication();
     $params = JComponentHelper::getParams('com_k2');
     $language = JFactory::getLanguage();
     $language->load('com_k2', JPATH_ADMINISTRATOR);
     $document = JFactory::getDocument();
     if (version_compare(JVERSION, '1.6.0', 'ge')) {
         JHtml::_('behavior.framework');
     } else {
         JHTML::_('behavior.mootools');
     }
     // CSS
     $document->addStyleSheet(JURI::root(true) . '/media/k2/assets/css/k2.css?v=2.6.8');
     // JS
     K2HelperHTML::loadjQuery(true);
     $document->addScript(JURI::root(true) . '/media/k2/assets/js/k2.js?v=2.6.8&amp;sitepath=' . JURI::root(true) . '/');
     $this->addViewPath(JPATH_COMPONENT_ADMINISTRATOR . DS . 'views');
     $this->addModelPath(JPATH_COMPONENT_ADMINISTRATOR . DS . 'models');
     $view = $this->getView('users', 'html');
     $view->addTemplatePath(JPATH_COMPONENT_ADMINISTRATOR . DS . 'views' . DS . 'users' . DS . 'tmpl');
     $view->setLayout('element');
     $view->display();
 }