/** * Injects Insert Tags input box and drop down menu to adminForm * * @access public * @since 1.5 */ function onBeforeRender() { $id = JRequest::getVar('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')); $user =& JFactory::getUser(); $task = JRequest::getVar('task'); $option = JRequest::getVar('option'); $id = JRequest::getVar('id', JRequest::getVar('a_id')); $view = JRequest::getVar('view'); $layout = JRequest::getVar('layout'); $fontend = false; if ($option == 'com_content' && $user->get('id') > 0 && $view == 'form' && $layout == 'edit') { $fontend = true; } $backend = false; if ($option == 'com_content' && $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; } if (!empty($id)) { if ($backend || $fontend) { $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 = 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); } //****** //INPUTS ================================================ $this->exist = false; $this->fields = $fields; //inputs RENDER ==================================================================== $idgroup = -1; $titlegropu = ""; $this->exist = false; $cont = -1; $cuantos_en_str = 0; //$field->position=1; $str = ""; //$('ul#list li:first').after('ul#list li:eq(1)') //If J3.1 ******* if (version_compare(JVERSION, '3.1', '>') == 1) { if (count($fields) > 0) { foreach ($fields as $field) { //if($field->position == 1){ //JError::raiseNotice(500, "FIELD ".$field->id); if ($field->idgroup != $idgroup) { $cont++; //JError::raiseNotice(500, "FIELD ".$field->title); if ($idgroup > 0) { if ($this->exist == true) { $str .= '</div> '; //JError::raiseNotice(500, "Escribir content"); $myTabContent = JLayoutHelper::render('libraries.cms.html.bootstrap.starttabset', array('selector' => 'myTab')); $document = JFactory::getDocument(); $content = $document->getBuffer('component'); $content = str_replace($myTabContent, $myTabContent . JHtml::_('bootstrap.addTab', 'myTab', 'tabID' . $idgroup, $titlegropu) . $str . JHtml::_('bootstrap.endTab'), $content); $document->setBuffer($content, array('type' => 'component', 'name' => '', 'title' => '')); $str = ""; } } $this->exist = true; $cuantos_en_str++; $str .= '<div class="tab-panewww" id="fiedlsattachTab_' . $field->idgroup . '" >'; if (!empty($field->descriptiongroup)) { $str .= '<div class="desc">' . $field->descriptiongroup . '</div>'; } } $idgroup = $field->idgroup; $titlegropu = $field->titlegroup; //NEW GET PLUGIN ******************************************************************** JPluginHelper::importPlugin('fieldsattachment'); // very important //select if (empty($this->array_fields)) { $this->array_fields = fieldsattachHelper::get_extensions(); } if (count($this->array_fields) > 0) { foreach ($this->array_fields as $obj) { $function = "plgfieldsattachment_" . $obj . "::construct();"; //$base = JPATH_BASE; //$base = str_replace("/administrator", "", $base); $base = JPATH_SITE; $file = $base . '/plugins/fieldsattachment/' . $obj . '/' . $obj . '.php'; if (JFile::exists($file)) { //file exist eval($function); $function = 'plgfieldsattachment_' . $obj . "::getName();"; eval("\$plugin_name =" . $function . ""); //$str .= $field->type." == ".$plugin_name."<br />"; eval($function); //JError::raiseNotice(500, "sssssdsf"); if ($field->type == $plugin_name) { if ($backendcategory) { $value = JRequest::getVar("field_" . $field->id, fieldsattachHelper::getfieldsvalueCategories($field->id, $id), 'post', 'string', JREQUEST_ALLOWHTML); // JError::raiseNotice(500, "sssssdsf"); //$value = JRequest::getVar("field_".$field->id, $this->getfieldsvalueCategories( $field->id, $id)); } else { // $value = JRequest::getVar("field_".$field->id,fieldsattachHelper::getfieldsvalue( $field->id, $id), 'post', 'string', JREQUEST_ALLOWHTML); $value = ""; if (isset($_POST["field_" . $field->id])) { $value = $_POST["field_" . $field->id]; } else { $value = fieldsattachHelper::getfieldsvalue($field->id, $id); } //$value = JRequest::getVar("field_".$field->id, $this->getfieldsvalue( $field->id, $id)); } $value = addslashes($value); //SESSION VALUE $session = JFactory::getSession(); $value_session = $session->get("field_" . $field->id); if (!empty($value_session) && empty($value)) { $value = $value_session; } //DELETE SESSION VALUE $session->clear("field_" . $field->id); $function = 'plgfieldsattachment_' . $obj . '::renderInput(' . $id . ',' . $field->id . ',"' . $value . '","' . $field->extras . '");'; //$function = "plgfieldsattachment_".$obj."::renderInput(".$id.",".$field->id.",'".$value."','".$field->extras."');"; eval("\$tmp=" . $function . ""); //ERROR: //$str .= '<div id="control-group_'.$field->id.'" class="control-group"><label class="control-label" for="field_'.$field->id.'">' . $field->title; //if($field->required) {$str .= '</label> <span>(*)</span>';} //CORRECT: $str .= '<div id="control-group_' . $field->id . '" class="control-group"><label class="control-label" for="field_' . $field->id . '">' . $field->title . '</label>'; if ($field->required) { $str .= '<span>(*)</span>'; } $str .= '<div class="controls">' . $tmp . '</div>'; $str .= '</div>'; //Reset field of category description ===================== // fieldsattachHelper::resetToDescription($id, $field->id, &$body); //$this->resetToDescription($id, $field->id); } } } } //END inputs RENDER ========================================================= } $str .= '</div>'; //END INPUT ============================================ } //******* //nav-tabs if ($fontend) { /*$myTabContent = JLayoutHelper::render('libraries.cms.html.bootstrap.starttabset', array('selector' => 'myTab')); $document = JFactory::getDocument(); $content = $document->getBuffer('component'); $content = str_replace($myTabContent, $myTabContent.JHtml::_('bootstrap.addTab', 'myTab', 'tabID'.$idgroup, $titlegropu).$str.JHtml::_('bootstrap.endTab'), $content); $document->setBuffer($content, array('type' => 'component', 'name' => '', 'title' => '')); */ } else { $myTabContent = JLayoutHelper::render('libraries.cms.html.bootstrap.starttabset', array('selector' => 'myTab')); $document = JFactory::getDocument(); $content = $document->getBuffer('component'); $content = str_replace($myTabContent, $myTabContent . JHtml::_('bootstrap.addTab', 'myTab', 'tabID' . $idgroup, $titlegropu) . $str . JHtml::_('bootstrap.endTab'), $content); $document->setBuffer($content, array('type' => 'component', 'name' => '', 'title' => '')); } } //*************** //$('ul#list li:first').after('ul#list li:eq(1)') $document =& JFactory::getDocument(); //$(window).load() //$document->addScript('/plugins/system/sjdinfinitescroll/jquery.infinitescroll.js'); $script = 'jQuery(window).load(function() { '; $script .= "tt = jQuery('#myTabTabs li:eq(1)').html();"; $script .= "num= jQuery('ul#myTabTabs li').length;"; for ($i = 0; $i <= $cont; $i++) { $script .= "var lastli = jQuery('ul#myTabTabs li:eq('+(num-1)+')');"; $script .= "jQuery('ul#myTabTabs li:first').after(lastli);"; } $script .= '});'; $document->addScriptDeclaration($script); } } //IF no empty ID //ENND : If 3.1 ******* }
/** * 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(); 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(); 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(); 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'; $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; } $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(); } } //END Experimental *************************************** **************** if (!$writed) { JResponse::setBody($body); } else { JResponse::setBody(""); } }
private function getAll(&$article) { if (!empty($article->id) && JRequest::getVar("view") == "article") { $db =& JFactory::getDBO(); $query = 'SELECT * FROM #__extensions as a WHERE a.folder = "fieldsattachment" AND a.enabled= 1'; $db->setQuery($query); $results_plugins = $db->loadObjectList(); $tmp_fields[] = array(); $tmp_fields = fieldsattachHelper::getfieldsForAll($article->id); $fields[] = array(); // $fields = $this->getfields($article->id); $fields = fieldsattachHelper::getfields($article->id); $fields = array_merge($tmp_fields, $fields); $fields_tmp2[] = array(); $fields_tmp2 = fieldsattachHelper::getfieldsForArticlesid($article->id, $fields); $fields = array_merge($fields, $fields_tmp2); if (count($fields) > 0) { //$body = str_replace('</head>', $header_code.'</head>', $body); $idgroup = $fields[0]->idgroup; $str = ''; $str_before = ''; $cont = 0; foreach ($fields as $field) { //NEW JPluginHelper::importPlugin('fieldsattachment'); // very important //select foreach ($results_plugins as $obj) { $function = "plgfieldsattachment_" . $obj->element . "::construct();"; //NEW PACTH CRISTIAN 10_04_2012 ======================= $base = JPATH_SITE; $file = $base . '/plugins/fieldsattachment/' . $obj->element . '/' . $obj->element . '.php'; //echo "<br>".$file; if (JFile::exists($file)) { //file exist eval($function); // eval($function); $i = count($this->array_fields); $this->array_fields[$i] = $obj->element; //$str .= "<br> ".$field->type." == ".$obj->element; if ($field->type == $obj->element && $field->visible) { $function = "plgfieldsattachment_" . $obj->element . "::getHTML(" . $article->id . "," . $field->id . ");"; //$str .= "<br> ".$function ; if ($field->positionarticle == 1) { eval("\$str_before .=" . $function . ""); } else { eval("\$str .=" . $function . ""); } // $str .= $function; } } //===================================================== } /* //EXTRA INFORMATION $width = '400'; $height = '400'; $filter = ''; if(!empty($field->extras)) { //$lineas = explode('":"', $field->params); //$tmp = substr($lineas[1], 0, strlen($lineas[1])-2); $tmp = $field->extras; //$str .= "<br> resultado1: ".$tmp; $lineas = explode(chr(13), $tmp); //$str .= "<br> resultado2: ".$lineas[0]; foreach ($lineas as $linea) { $tmp = explode('|', $linea); if (!empty($tmp[0])) $width = $tmp[0]; if (!empty($tmp[1])) $height = $tmp[1]; if (!empty($tmp[2])) $filter = $tmp[2]; } } //************************************************************************ //**************************** multiple select ********************** //*********************************************************************** if (($field->type == "select_multiple")&&($field->visible )) { $str .= fieldattach::getSelectmultiple($article->id, $field->id); } */ //************************************************************************ //**************************** titulo campos ********************** //*********************************************************************** //&& (!empty( $fields[$cont+1] )) if ($cont + 1 < count($fields)) { if ($idgroup != $fields[$cont + 1]->idgroup && !empty($str)) { $eltitle = false; if (isset($field->shortitlegroup)) { if ($field->shortitlegroup) { $eltitle = true; } } if ($eltitle) { $article->text .= '<h3>' . $field->titlegroup . '</h3>'; } $article->text = $str_before . $article->text . $str; $str = ''; } $idgroup = $fields[$cont + 1]->idgroup; } else { $article->text = $str_before . $article->text . $str; } $cont++; } } } }
/** * 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(""); }
private function getAll($article) { if (!empty($article->id) && JRequest::getVar("view") == "article") { $db = JFactory::getDBO(); $query = 'SELECT * FROM #__extensions as a WHERE a.folder = "fieldsattachment" AND a.enabled= 1'; $db->setQuery($query); $results_plugins = $db->loadObjectList(); $tmp_fields[] = array(); $tmp_fields = fieldsattachHelper::getfieldsForAll($article->id); $fields[] = array(); $fields = fieldsattachHelper::getfields($article->id); $fields = array_merge($tmp_fields, $fields); $fields_tmp2[] = array(); $fields_tmp2 = fieldsattachHelper::getfieldsForArticlesid($article->id, $fields); $fields = array_merge($fields, $fields_tmp2); //User access view the layout takes some responsibility for display of limited information. $user = JFactory::getUser(); $groups = $user->getAuthorisedViewLevels(); if (count($fields) > 0) { //$body = str_replace('</head>', $header_code.'</head>', $body); $idgroup = $fields[0]->idgroup; $str = ''; $str_before = ''; $cont = 0; foreach ($fields as $field) { //echo "field id: ".$field->id; //echo "<br>field id: ".$field->access; if (in_array($field->access, $groups)) { //NEW JPluginHelper::importPlugin('fieldsattachment'); // very important //select foreach ($results_plugins as $obj) { $function = "plgfieldsattachment_" . $obj->element . "::construct1();"; //NEW PACTH CRISTIAN 10_04_2012 ======================= $base = JPATH_SITE; $file = $base . '/plugins/fieldsattachment/' . $obj->element . '/' . $obj->element . '.php'; //echo "<br>".$file; if (JFile::exists($file)) { //file exist eval($function); // eval($function); $i = count($this->array_fields); $this->array_fields[$i] = $obj->element; //$str .= "<br> ".$field->type." == ".$obj->element; if ($field->type == $obj->element && $field->visible) { $function = "plgfieldsattachment_" . $obj->element . "::getHTML(" . $article->id . "," . $field->id . ");"; //$str .= "<br> ".$function ; if ($field->positionarticle == 1) { eval("\$str_before .=" . $function . ""); } else { eval("\$str .=" . $function . ""); } // $str .= $function; } } //===================================================== } //************************************************************************ //**************************** titulo campos ********************** //*********************************************************************** if ($cont + 1 < count($fields)) { if ($idgroup != $fields[$cont + 1]->idgroup && !empty($str)) { $eltitle = false; if (isset($field->shortitlegroup)) { if ($field->shortitlegroup) { $eltitle = true; } } if ($eltitle) { $article->text .= '<h3>' . $field->titlegroup . '</h3>'; } $article->text = $str_before . $article->text . $str; $str = ''; } $idgroup = $fields[$cont + 1]->idgroup; } else { $article->text = $str_before . $article->text . $str; $article->fulltext = $str_before . $article->fulltext . $str; } } $cont++; } } } }