Example #1
0
 /**
  * Constructor
  *
  * For php4 compatability we must not use the __constructor as a constructor for plugins
  * because func_get_args ( void ) returns a copy of all passed arguments NOT references.
  * This causes problems with cross-referencing necessary for the observer design pattern.
  *
  * @access	protected
  * @param	object	$subject The object to observe
  * @param 	array   $config  An array that holds the plugin configuration
  * @since	1.0
  */
 function construct()
 {
     $name = "image";
     $this->name = $name;
     /*$sitepath = JURI::base() ;
       $pos = strrpos($sitepath, "administrator");
       if(!empty($pos)){$sitepath  = JURI::base().'..'.DS;}*/
     $sitepath = fieldsattachHelper::getabsoluteURL();
     $this->path1 = $sitepath . 'images' . DS . 'documents';
     $documentpath = fieldsattachHelper::getabsolutePATH();
     if (JRequest::getVar('option') == 'com_categories' && JRequest::getVar('layout') == "edit") {
         $this->documentpath = $documentpath . DS . 'images' . DS . 'documentscategories';
     }
     //LOAD LANGUAGE --------------------------------------------------------------
     $lang =& JFactory::getLanguage();
     $lang->load('plg_fieldsattachment_' . $name);
     $lang =& JFactory::getLanguage();
     $lang_file = "plg_fieldsattachment_" . $name;
     $sitepath1 = JPATH_BASE;
     $sitepath1 = str_replace("administrator", "", $sitepath1);
     $path = $sitepath1 . "languages" . DS . $lang->getTag() . DS . $lang->getTag() . "." . $lang_file . ".php.ini";
     if (JFile::exists($path)) {
         JPlugin::loadLanguage('plg_fieldsattachment_' . $name);
     }
     //-----------------------------------------------------------------------------
 }
Example #2
0
 function renderInput($articleid, $fieldsid, $value, $extras = null)
 {
     $required = "";
     global $sitepath;
     JLoader::register('fieldattach', $sitepath . DS . 'components/com_fieldsattach/helpers/fieldattach.php');
     $boolrequired = fieldattach::isRequired($fieldsid);
     if ($boolrequired) {
         $required = "required";
     }
     $str = "";
     //Add CSS ***********************
     $str .= '<link rel="stylesheet" href="' . JURI::root() . 'plugins/fieldsattachment/image/image.css" type="text/css" />';
     $app = JFactory::getApplication();
     $templateDir = JURI::base() . 'templates/' . $app->getTemplate();
     $css = JPATH_SITE . "/administrator/templates/" . $app->getTemplate() . "/html/com_fieldsattach/css/image.css";
     $pathcss = JURI::root() . "administrator/templates/" . $app->getTemplate() . "/html/com_fieldsattach/css/image.css";
     if (file_exists($css)) {
         $str .= '<link rel="stylesheet" href="' . $pathcss . '" type="text/css" />';
     }
     $file = $value;
     $selectable = "";
     $str .= '<div class="image" style="overflow:hidden;">';
     if (!empty($extras)) {
         //$lineas = explode('":"',  $field->params);
         //$tmp = substr($lineas[1], 0, strlen($lineas[1])-2);
         $tmp = $extras;
         $lineas = explode(chr(13), $tmp);
         //$str .= "<br> resultado2: ".$lineas[0];
         $str .= '<div class="config"><div class="file label">Config</div>';
         foreach ($lineas as $linea) {
             $str .= '<div class="file">';
             $selectable = "";
             $filter = "";
             $height = "";
             $width = "";
             $tmp = explode('|', $linea);
             if (!empty($tmp[0])) {
                 $width = $tmp[0];
             }
             if (count($tmp) >= 1) {
                 if (!empty($tmp[1])) {
                     $height = $tmp[1];
                 }
             }
             if (count($tmp) >= 2) {
                 if (!empty($tmp[2]) && isset($tmp[2])) {
                     $filter = $tmp[2];
                 }
             }
             if (count($tmp) >= 3) {
                 if (!empty($tmp[3]) && isset($tmp[3])) {
                     $selectable = $tmp[3];
                 }
             }
             if (!empty($width)) {
                 $str .= '<span>Size:</span>' . $width;
             } else {
                 $str .= 'Size:-- ';
             }
             if (!empty($height)) {
                 $str .= 'X' . $height;
             } else {
                 $str .= 'X --';
             }
             if (!empty($filter)) {
                 $str .= '<br /><span>Filter:</span>' . $filter;
             }
             if (!empty($selectable)) {
                 $str .= '<br /><span>Selectable:</span> True ';
             }
             $str .= '</div>';
         }
         $str .= '</div>';
     }
     //$str .= $this->path .DS. $id.DS. $file;
     //$path = $this->params->get( "documentpath" );
     $path = $this->params->get("path");
     //  $str .= "<br>PATH:: ".$path;
     //$file_absolute =  $path .DS. $articleid .DS.  $file;
     //  $str .= "<br>PATH  file_absolute:: ".$file_absolute;
     $file_url = $path . DS . $articleid . DS . $file;
     //$documentpath = $this->params->get( "documentpath" );
     $documentpath = fieldsattachHelper::getabsolutePATH();
     $documentpath = $documentpath . DS . "images" . DS . "documents";
     //OJOOOOOOOOOOOOOOOOOOOOO
     //$file_url = $documentpath.DS. $articleid .DS.  $file;
     if (JRequest::getVar('option') == 'com_categories' && JRequest::getVar('layout') == "edit") {
         $file_url = str_replace("documents", "documentscategories", $file_url);
     }
     $file_absolute = $documentpath . DS . $articleid . DS . $file;
     if ($selectable == "selectable") {
         $file_url = fieldsattachHelper::getabsoluteURL() . $file;
     }
     //echo "<br>FILE: ".$file_absolute;
     //$str .= "<br>".$file_absolute." -> ". file_exists( '/media/Iomega_HDD/trabajos/dalmau/web3/images/documents/60/1003_LLEida1.jpg' )  ;
     // echo "<br>EXIST FILE: ".file_exists(  $file_absolute  );
     if (file_exists($file_absolute) && !empty($file) || $selectable && !empty($file)) {
         //Name file
         $str .= '<div class="file"><img src="' . $file_url . '" ';
         if (!empty($width)) {
             $str .= ' width="' . $width . '" ';
         }
         if (!empty($height)) {
             $str .= ' height="' . $height . '" ';
         }
         $str .= ' alt=" "/></div>';
         //Delete
         $str .= '<div class="file"><div style="overflow:hidden;">';
         if ($selectable == "selectable") {
             $str .= '<label for="field_' . $fieldsid . '_delete1">';
             $str .= JTEXT::_("Checkbox for delete file");
             $str .= '</label>';
             $str .= '<input name="field_' . $fieldsid . '_delete1" type="checkbox" onclick="javascript: $(\'field_' . $fieldsid . '\').value= \'\' ;"   />';
         } else {
             $str .= '<label for="field_' . $fieldsid . '_delete">';
             $str .= JTEXT::_("Checkbox for delete file");
             $str .= '</label>';
             $str .= '<input name="field_' . $fieldsid . '_delete" type="checkbox"   />';
         }
         $str .= '</div></div> ';
     } else {
         $value = "";
     }
     if ($selectable == "selectable") {
         $str .= '<div class="file"><input name="field_' . $fieldsid . '" id="field_' . $fieldsid . '" type="text" size="150" value="' . $value . '" class="' . $required . '" /></div> ';
         $str .= '<div class="file"><div class="button2-left">
                     <div class="blank">
                             <a class="modal modal-button" title="Select Image" href="index.php?option=com_media&amp;view=images&amp;tmpl=component&amp;asset=140&amp;author=&amp;fieldid=field_' . $fieldsid . '&amp;folder=" rel="{handler: \'iframe\', size: {x: 800, y: 500}}">
                                     Select Image</a>
                     </div>
                     </div>   ';
         $str .= '</div> ';
     } else {
         $str .= " <script type='text/javascript'>\n                \n                    window.addEvent('domready', function() { \n\n                                //Add check evrent\n                                \$\$('#field_" . $fieldsid . "_upload').addEvent('change', function(e){ \n                                    var upload =\$(this).value; \n                                    var result = '';\n                                    if(String(upload).length>0 )\n                                    {\n                                        result = upload;\n                                    }\n\n                                    \$('field_" . $fieldsid . "').value= result;\n                                });\n  \n\n\n                        });</script>";
         $str .= '<div class="file"><input name="field_' . $fieldsid . '" id="field_' . $fieldsid . '" type="hidden"   value="' . $value . '" class="customfields ' . $required . '" /> ';
         $str .= '<input name="field_' . $fieldsid . '_upload" id="field_' . $fieldsid . '_upload" type="file" size="150" class="customfields" /></div>';
     }
     $str .= '</div><script>function jInsertFieldValue(txt, field){ $(field).value= txt ;}</script>';
     return $str;
 }