/** * Injects Insert Tags input box and drop down menu to adminForm * * @access public * @since 1.5 */ function onAfterRender() { //SELECT WHERE I AM ****** if (!JFactory::getApplication()->isAdmin()) { $option = JRequest::getCmd('option', ''); $view = JRequest::getCmd('view', ''); if ($option == 'com_content' && $view == 'category') { // your processing code here $body = JResponse::getBody(); //JResponse::setBody("saa"); //TODO WRITE A FIELDS TO CATEGORY EDIT CONTENT ======================== //$this->addFieldsInCategory(); //$body = $this->onAfterRenderCategory($body); return; } } $body = JResponse::getBody(); //$model = JController::getInstance("com_content"); //$state = $model->getModel(); //$dd = $state->getState("filter.category_id"); // $state->state->get('filter.category_id'); $writed = false; $id = JRequest::getVar('id'); $str = ''; $str_options = ''; $exist = false; $exist_options = false; $idgroup = 0; $editor =& JFactory::getEditor(); $oneclicksave = $this->params->get('oneclicksave', 1); //Experimental *************************************** **************** if ($oneclicksave == 1 || !empty($id)) { //EDIT ARTICLE ===================================================================== if (!$id) { $cid = JRequest::getVar('cid', array(), '', 'array'); @($id = $cid[0]); $view = JRequest::getVar('view'); if ($view == 'article') { $path = ''; } else { $path = '..' . DS; } } $task = JRequest::getVar('task'); $option = JRequest::getVar('option'); $id = JRequest::getVar('id', JRequest::getVar('a_id')); $view = JRequest::getVar('view'); $layout = JRequest::getVar('layout'); $pos = strrpos(JPATH_BASE, "administrator"); $user =& JFactory::getUser(); //*********************************************************************************************** //Where we are **************** **************** **************** //*********************************************************************************************** $fontend = false; if ($option == 'com_content' && $user->get('id') > 0 && $view == 'form' && $layout == 'edit') { $fontend = true; } $backend = false; if ($option == 'com_content' && !empty($pos) && $layout == 'edit') { $backend = true; } $backendcategory = false; if (JRequest::getVar('option') == 'com_categories' && JRequest::getVar('view') == "category" && JRequest::getVar('extension') == "com_content") { $backendcategory = true; $backend = true; } //EDIT FRONTEND if ($fontend && $view == "form") { //echo "el id".$id."<br>"; $id = JRequest::getVar('a_id'); } //*********************************************************************************************** //If we are in admin content edit or frontend edit **************** **************** //*********************************************************************************************** if ($backend || $fontend) { $body = str_replace('method="post"', 'method="post" enctype="multipart/form-data" ', $body); //DELETE DE ERROR WRONG //$body = str_replace('<li>Save failed with the following error: </li>', '' , $body); //$body .= '<style>.message ul li:last-of-type {display: none;} .message ul li:first-of-type {display: block;}</style>'; //Plugin control for the no insert new rows **************** //Author: giuppe //********************************************************** if (empty($id)) { //*********************************************************************************************** //If NEW Redirect **************** **************** //*********************************************************************************************** if ($backend && !$backendcategory) { $id = $this->getlastId(); JError::raiseWarning(100, "CREAR DIR::: " . $id . " -- " . JRequest::getVar("id")); if (!empty($id)) { $url = JURI::base() . "index.php?option=com_content&task=article.edit&id=" . $id; echo "<script>document.location.href='" . $url . "';</script>\n"; } } if ($fontend) { $id = $this->getlastId(); JError::raiseWarning(100, "CREAR DIR2::: " . $id . " -- " . JRequest::getVar("id")); if (!empty($id)) { //base64_encode($uri) //$uri = $_SERVER["HTTP_REFERER"]; $user = JFactory::getUser(); $userId = $user->get('id'); $uri = JFactory::getURI(); $uri = 'index.php?option=com_content&task=article.edit&a_id=' . $id; $app = JFactory::getApplication(); $app->setUserState('com_content.edit.article.id', $id); $url = JURI::base() . "index.php?option=com_content&view=form&layout=edit&a_id=" . $id . "&Itemid=" . JRequest::getVar("Itemid") . "&return=" . base64_encode($uri); $button = JHtml::_('link', JRoute::_($url), "TESTO"); echo "<script>document.location.href='" . $url . "';</script>\n"; //header('Location: '.$url); //JApplication::redirect($url); } } } //*********************************************************************************************** //create array of fields **************** **************** **************** //*********************************************************************************************** $fields = array(); $fields = $this->fields; /*if($backendcategory) { if(!empty($id)) { $fields_tmp0 = fieldsattachHelper::getfieldsForAllCategory($id); $fields = fieldsattachHelper::getfieldsCategory($id); $fields = array_merge($fields_tmp0, $fields); } }else{ $fields_tmp0 = fieldsattachHelper::getfieldsForAll($id); //$fields_tmp1 = $this->getfields($id); $fields_tmp1 = fieldsattachHelper::getfields($id); $fields_tmp1 = array_merge($fields_tmp0, $fields_tmp1); $fields_tmp2 = fieldsattachHelper::getfieldsForArticlesid($id, $fields_tmp1); $fields = array_merge($fields_tmp1, $fields_tmp2); //$fields = $fields_tmp0; }*/ //*********************************************************************************************** //create HTML with new extra fields **************** **************** **************** //*********************************************************************************************** //include('lib/QueryPath-2.1.1/php/QueryPath/QueryPath.php'); include 'lib/phpQuery-onefile.php'; //For j3.0 //include('lib/ganon.php'); //For j3.1.1 o highter $menuTabstr = ""; if (count($fields) > 0) { $helper = new fieldsattachHelper(); $helper->body = $body; $helper->menuTabstr = $str; $helper->str = $str; $helper->str_options = $str_options; //$helper->getinputfields($id, $fields, $backend, $fontend, $backendcategory, $exist_options, &$body, &$str, &$str_options); $helper->getinputfields($id, $fields, $backend, $fontend, $backendcategory, $exist_options); $str = $helper->str; $menuTabstr = $helper->menuTabstr; //$body = $helper->body; $exist = $helper->exist; $exist_options = $helper->exist_options; } //Javascript for reorder li ************* /*$script = '<script>jQuery(document).ready(function() { jQuery("#myTabTabs").append(jQuery("li.addtab")); jQuery("#myTabTabs li:first").after( jQuery("li.addtab") ); });</script>';*/ if (version_compare(JVERSION, '3.1', '>') == 1) { if ($fontend) { $options = array('replace_entities' => TRUE, 'ignore_parser_warnings' => TRUE); //Load Document $doc = phpQuery::newDocument($body); phpQuery::selectDocument($doc); //Find element pq('.nav-tabs li:first-child')->append($menuTabstr); //Backend if ($backend) { pq('#general')->after($str); } if ($backendcategory) { pq('#details')->after($str); } //Front end if ($fontend) { if (pq("#editor")->length) { pq('#editor')->after($str); // element exists } else { $str = '</fieldset><fieldset><legend>' . strip_tags($menuTabstr) . '</legend>' . $str . ''; pq('#adminForm #editor-xtd-buttons')->after($str); } } //Return HTML $body = pq('')->htmlOuter(); } else { //Go to beforeRender } } else { //echo "running Joomla! 3.0"; $options = array('replace_entities' => TRUE, 'ignore_parser_warnings' => TRUE); //Load Document $doc = phpQuery::newDocument($body); phpQuery::selectDocument($doc); //Find element pq('.nav-tabs li:first-child')->append($menuTabstr); if ($backend) { pq('#general')->after($str); } if ($fontend) { pq('#editor')->after($str); } if ($backendcategory) { pq('#details')->after($str); } //Return HTML $body = pq('')->htmlOuter(); } //if($fontend) $html('#editor')->after($str); //if($backendcategory) $html('#details')->after($str); //$html->find('#myTabTabs')->append($menuTabstr); } } //END Experimental *************************************** **************** if (!$writed) { JResponse::setBody($body); } else { JResponse::setBody(""); } }
/** * Injects Insert Tags input box and drop down menu to adminForm * * @access public * @since 1.5 */ function onAfterRender() { if ( !JFactory::getApplication()->isAdmin()) { $option = JRequest::getCmd('option', ''); $view = JRequest::getCmd('view', ''); if ($option == 'com_content' && $view == 'category') { // your processing code here $body = JResponse::getBody(); //JResponse::setBody("saa"); //TODO WRITE A FIELDS TO CATEGORY EDIT CONTENT ======================== //$this->addFieldsInCategory(); $body = $this->onAfterRenderCategory($body); return; } } $body = JResponse::getBody(); //$model = JController::getInstance("com_content"); //$state = $model->getModel(); //$dd = $state->getState("filter.category_id"); // $state->state->get('filter.category_id'); $writed = false; $id = JRequest::getVar('id'); $str = ''; $str_options = ''; $exist=false; $exist_options=false; $idgroup= 0; $editor =& JFactory::getEditor(); //EDIT ARTICLE ===================================================================== if (!$id) { $cid = JRequest::getVar( 'cid' , array() , '' , 'array' ); @$id = $cid[0]; $view = JRequest::getVar('view'); if ($view =='article') $path = ''; else $path = '..'.DS; } $task = JRequest::getVar('task'); $option= JRequest::getVar('option'); $id= JRequest::getVar('id', JRequest::getVar('a_id')); $view= JRequest::getVar('view'); $layout= JRequest::getVar('layout'); //$tagsList = $this->getTags($id, $option); //$masterTagList = $this->getMasterTagsList(); // Added by Duane Jeffers $pos = strrpos(JPATH_BASE, "administrator"); $user =& JFactory::getUser(); //*********************************************************************************************** //Where we are **************** **************** **************** //*********************************************************************************************** $fontend = false; if( $option=='com_content' && $user->get('id')>0 && $view == 'form' && $layout == 'edit' ) $fontend = true; $backend = false; if( $option=='com_content' && !empty($pos) && $layout == 'edit') $backend = true; $backendcategory = false; if ((JRequest::getVar('option')=='com_categories' && JRequest::getVar('view')=="category" && JRequest::getVar('extension')=="com_content" )){ $backendcategory = true; $backend=true; } //EDIT FRONTEND if(($fontend)&&($view == "form")){ //echo "el id".$id."<br>"; $id = JRequest::getVar( 'a_id'); } //*********************************************************************************************** //If we are in admin content edit or frontend edit **************** **************** //*********************************************************************************************** if (($backend ) || ( $fontend ) ) { $body = str_replace('method="post"', 'method="post" enctype="multipart/form-data" ' , $body); //DELETE DE ERROR WRONG //$body = str_replace('<li>Save failed with the following error: </li>', '' , $body); $body .= '<style>.message ul li:last-of-type {display: none;} .message ul li:first-of-type {display: block;}</style>'; //Plugin control for the no insert new rows **************** //Author: giuppe //********************************************************** $oneclicksave = $this->params->def('oneclicksave', 1); if($oneclicksave == 1){ if(empty($id)) { //*********************************************************************************************** //If NEW Redirect **************** **************** //*********************************************************************************************** if($backend && !$backendcategory ) { $id = $this->getlastId(); if(!empty($id)){ $url = JURI::base() ."index.php?option=com_content&task=article.edit&id=".$id; echo "<script>document.location.href='" . ($url) . "';</script>\n"; //header('Location: '.$url); //JApplication::redirect($url); } } if($fontend ) { $id = $this->getlastId(); // echo "aaaaaaaa : ".$id; //$canEdit = $this->item->params->get('access-edit'); if(!empty($id)){ //index.php?option=com_content&view=form&layout=edit&a_id=3&Itemid=124 //base64_encode($uri) //$uri = $_SERVER["HTTP_REFERER"]; $user = JFactory::getUser(); $userId = $user->get('id'); $uri = JFactory::getURI(); //index.php?option=com_content&view=form&layout=edit&a_id=20&Itemid=130&return=aHR0cDovLzEyNy4wLjAuMS90ZXN0L3dlYjMvaW5kZXgucGhwP29wdGlvbj1jb21fY29udGVudCZ2aWV3PWNhdGVnb3J5JmxheW91dD1ibG9nJmlkPTImSXRlbWlkPTEzMA== //index.php?option=com_content&task=article.edit&a_id=20 $uri = 'index.php?option=com_content&task=article.edit&a_id='.$id; $app = JFactory::getApplication(); $app->setUserState('com_content.edit.article.id',$id); $url = JURI::base() ."index.php?option=com_content&view=form&layout=edit&a_id=".$id."&Itemid=".JRequest::getVar("Itemid")."&return=".base64_encode($uri); //echo "URLLLLLLLLLLLLL ".$url; $button = JHtml::_('link',JRoute::_($url), "TESTO"); echo "<script>document.location.href='" . ($url) . "';</script>\n"; //header('Location: '.$url); //JApplication::redirect($url); } } } } //*********************************************************************************************** //create array of fields **************** **************** **************** //*********************************************************************************************** $fields = array(); if($backendcategory){ if(!empty($id)){ $fields_tmp0 = fieldsattachHelper::getfieldsForAllCategory($id); $fields = fieldsattachHelper::getfieldsCategory($id); $fields = array_merge($fields_tmp0, $fields); } }else{ $fields_tmp0 = fieldsattachHelper::getfieldsForAll($id); //$fields_tmp1 = $this->getfields($id); $fields_tmp1 = fieldsattachHelper::getfields($id); $fields_tmp1 = array_merge($fields_tmp0, $fields_tmp1); $fields_tmp2 = fieldsattachHelper::getfieldsForArticlesid($id, $fields_tmp1); $fields = array_merge($fields_tmp1, $fields_tmp2); //$fields = $fields_tmp0; } //*********************************************************************************************** //create HTML with new extra fields **************** **************** **************** //*********************************************************************************************** if(count($fields)>0){ $helper = new fieldsattachHelper(); $helper->body = $body; $helper->str = $str; $helper->str_options = $str_options; //$helper->getinputfields($id, $fields, $backend, $fontend, $backendcategory, $exist_options, &$body, &$str, &$str_options); $helper->getinputfields($id, $fields, $backend, $fontend, $backendcategory, $exist_options); $str = $helper->str; $str_options= $helper->str_options; $body = $helper->body; $exist = $helper->exist; $exist_options = $helper->exist_options; // fieldsattachHelper::getinputfields($id, $fields, $backend, $fontend, $backendcategory, $exist_options, &$body, &$str, &$str_options); } //*********************************************************************************************** //WRITE HTML in page **************** **************** **************** //*********************************************************************************************** $pos = strrpos(JPATH_BASE, "administrator"); //echo "-------".$body."--------"; //echo "EXIST:: ".$exist_options; if ( !empty($pos) ){ //if(!empty($str)){ // descendant selector include('lib/QueryPath-2.1.1/php/QueryPath/QueryPath.php'); //debajo ------------------ if(isset($exist) ) if(!$exist) $str="<p></p>"; if(isset($exist_options) ) if(!$exist_options) { $str_options="<p></p>"; }; // echo "---------".$str." -------------"; // echo "---------".$str_options." -------------"; //$str="<p></p>"; //================================================================================================= //Special characters replace //http://groups.google.com/group/support-querypath/browse_thread/thread/f1b156f791835b37?pli=1 //Bug contribution: G1boo //================================================================================================= $options = array('replace_entities' => TRUE); //================================================================================================= //Wrappers $str = '<div id="fieldsattach_footer">'.$str.'</div>'; //REMOVE NOT ASCII CHARACTERS **************************** // $str = preg_replace('/[^(\x20-\x7F)]*/','', $str); // $str_options = preg_replace('/[^(\x20-\x7F)]*/','', $str_options); //INSERT FORM $pos = strrpos( $body, 'id="access-rules' ); if ($pos === false) { if($backendcategory) { $body = qp($body, 'body', $options)->find(':root form')->after($str."<br /><br />")->find(':root #categories-sliders-'.JRequest::getVar("id"))->append($str_options) ; }else{ //$body = qp($body, 'body', $options)->find(':root form')->after($str."<br /><br />")->find(':root #content-sliders-'.JRequest::getVar("id"))->append($str_options) ; $body = qp($body, 'body', $options)->find(':root form')->append($str."<br /><br />")->find(':root #content-sliders-'.JRequest::getVar("id"))->append($str_options) ; } }else{ if($backendcategory) { $body = qp($body, 'body', $options)->find(':root #access-rules')->parent()->before($str."<br /><br />")->find(':root #categories-sliders-'.JRequest::getVar("id"))->append($str_options) ; }else { $body = qp($body, 'body', $options)->find(':root #access-rules')->parent()->before($str."<br /><br />")->find(':root #content-sliders-'.JRequest::getVar("id"))->append($str_options) ; //$body = qp($body, 'body', $options)->find(':root #access-rules')->parent()->before($str."<br /><br />")->find(':root #content-sliders-'.JRequest::getVar("id"))->append($str_options) ; } } //EN las opciones ------------------ $body->writeHTML(); //$body = $body->html(); $writed=true; // } }else { $finds = explode('</fieldset>', $body); if(!empty ($id)) $finds[1] = $str.$finds[1]; $body = implode('</fieldset>', $finds); if ( !empty($pos) ){ } } } //Añadir enctype="multipart/form-data" if(!$writed) JResponse::setBody($body); else JResponse::setBody(""); //JResponse::setBody(""); }