function getAdsmanagerRouteCategory($id) { $db = JFactory::getDBO(); $sql = "SELECT name FROM #__adsmanager_categories WHERE id = " . (int) $id; $db->setQuery($sql); $result = $db->loadResult(); $result = TText::_($result); $result = TTools::stringURLSafe($result); $result = JString::substr($result, 0, 30); return $result; }
function showFieldSearch($field,$catid,$default,$force=false) { $default = (object) $default; if (isset($default)) { $fieldname = $field->name; $value = @$default->$fieldname; } else { $value = null; } $options = $field->options; //We initialize the placeholder if they exist, if not we let it empty if(isset($options->placeholder_search) && $options->placeholder_search != ""){ $placeholder = htmlspecialchars($options->placeholder_search); } else { $placeholder = ""; } $values = array(); if ((!isset($options))|| (!isset($options->select_values_storage_type))|| ($options->select_values_storage_type == "internal")) { if (@$this->field_values[$field->fieldid]) { $values = $this->field_values[$field->fieldid]; } } else if ($options->select_values_storage_type == "db") { $dbname = $options->select_db_storage_db_name; $_name = $options->select_db_storage_column_name; $_value = $options->select_db_storage_column_value; //$parent = $options->select_db_storage_column_parent_value; $sql = "SELECT `$_name` as fieldtitle,`$_value` as fieldvalue FROM $dbname"; $this->_db->setQuery($sql); $values = $this->_db->loadObjectList(); } if (!isset($options)){ $options = new stdClass(); } foreach($values as $key => $val) { $values[$key]->fieldtitle = htmlspecialchars(TText::_($val->fieldtitle)); } if (($force==true) ||(strpos($field->catsid, ",$catid,") !== false)||(strpos($field->catsid, ",-1,") !== false)) { if(isset($options->searchtype_render)&&$options->searchtype_render != "") { $field->type = $options->searchtype_render; } switch($field->type) { case 'checkbox': if ($value == 1) echo "<input class='inputbox' type='checkbox' name='".$field->name."' value='1' checked='checked' />\n"; else echo "<input class='inputbox' type='checkbox' name='".$field->name."' value='1' />\n"; break; case 'radio': case 'radioimage': case 'multicheckbox': if (!is_array($value)) { $value = array($value); } $k = 0; echo "<table class='cbMulti'>\n"; for ($i=0 ; $i < $field->rows;$i++) { echo "<tr>\n"; for ($j=0 ; $j < $field->cols;$j++) { echo "<td>\n"; $fieldvalue = @$values[$k]->fieldvalue; $fieldtitle = @$values[$k]->fieldtitle; if ($field->type != 'radioimage') { if (isset($fieldtitle)) $fieldtitle=TText::_($fieldtitle); } else { $fieldtitle="<img src=\"{$this->baseurl}images/com_adsmanager/fields/$fieldtitle\" alt=\"$fieldtitle\" />"; } if (isset($values[$k])) { echo "<label>\n"; if (!in_array($fieldvalue,$value)) echo "<input type='checkbox' id='".$field->name."' name='".$field->name."[]' value=\"".htmlspecialchars($fieldvalue)."\" /> $fieldtitle \n"; else echo "<input type='checkbox' id='".$field->name."' checked='checked' name='".$field->name."[]' value=\"".htmlspecialchars($fieldvalue)."\" /> $fieldtitle \n"; echo "</label>\n"; } $k++; echo "</td>\n"; } echo "</tr>\n"; } echo "</table>\n"; break; case 'select': if ((ADSMANAGER_SPECIAL == "abrivac")&&($field->name == "ad_type")) { $value = @$default->ad_type; foreach($values as $v) { $ftitle = $v->fieldtitle; $fieldvalue = $v->fieldvalue; //var_dump($fieldvalue,$value); if (!is_array($value)) $value = array(); echo "<div class='champ_filtre_checkbox'>"; if (in_array($fieldvalue,$value)) echo "<input class='inputbox' type='checkbox' name='".$field->name."[]' checked='checked' value=\"".htmlspecialchars($fieldvalue)."\" /> $ftitle \n"; else echo "<input class='inputbox' type='checkbox' name='".$field->name."[]' value=\"".htmlspecialchars($fieldvalue)."\" /> $ftitle \n"; echo "</div>"; } } else { echo "<select id='".$field->name."' name='".$field->name."'>\n"; echo "<option value='' >".$placeholder."</option>\n"; foreach($values as $v) { $ftitle = $v->fieldtitle; if (($value == $v->fieldvalue)||($value == $ftitle)) echo "<option value=\"".htmlspecialchars($v->fieldvalue)."\" selected='selected' >$ftitle</option>\n"; else echo "<option value=\"".htmlspecialchars($v->fieldvalue)."\" >$ftitle</option>\n"; } echo "</select>\n"; } break; case 'multiselect': echo "<select name=\"".$field->name."[]\" multiple='multiple' size='$field->size'>\n"; foreach($values as $v) { $ftitle = $v->fieldtitle; if ($field->required == 1) $mosReq = "required"; if ((strpos($value, ",".$v->fieldvalue.",") === false) && (strpos($value, $ftitle."|*|") === false) && (strpos($value, "|*|".$ftitle) === false) && ($value != $ftitle)) echo "<option value=\"".htmlspecialchars($v->fieldvalue)."\" >$ftitle</option>\n"; else echo "<option value=\"".htmlspecialchars($v->fieldvalue)."\" selected='selected' >$ftitle</option>\n"; } echo "</select>\n"; break; case 'price': case 'number': if (!isset($options->search_type)) { $options->search_type = "textfield"; } if (isset($default)) { $fieldname = $field->name."_min"; $minvalue = @$default->$fieldname; $fieldname = $field->name."_max"; $maxvalue = @$default->$fieldname; } switch($options->search_type) { case "textfield": echo "<input name='".$field->name."' placeholder=\"".$placeholder."\" id='".$field->name."' value=\"".htmlspecialchars($value)."\" maxlength='$field->maxlength' class='inputbox' type='text' size='$field->size' />"; break; case "select": echo "<select id='".$field->name."' name='".$field->name."'>\n"; echo "<option value='' >".$placeholder."</option>\n"; foreach($values as $v) { $ftitle = TText::_($v->fieldtitle); if ($value == $v->fieldvalue) echo "<option value=\"".htmlspecialchars($v->fieldvalue)."\" selected='selected'>$ftitle</option>\n"; else echo "<option value=\"".htmlspecialchars($v->fieldvalue)."\" >$ftitle</option>\n"; } echo "</select>\n"; break; case "minmax": if($placeholder != '') { $placeholder = explode(',',$placeholder); echo "<input name='".$field->name."_min' id='".$field->name."_min' value=\"".htmlspecialchars($minvalue)."\" maxlength='$field->maxlength' class='inputbox' placeholder='".$placeholder[0]."' type='text' size='$field->size' />"; echo "<input name='".$field->name."_max' id='".$field->name."_max' value=\"".htmlspecialchars($maxvalue)."\" maxlength='$field->maxlength' class='inputbox' placeholder='".$placeholder[1]."' type='text' size='$field->size' />"; } else { echo JText::_('ADSMANAGER_MINMAX_MIN')."<input name='".$field->name."_min' id='".$field->name."_min' value=\"".htmlspecialchars($minvalue)."\" maxlength='$field->maxlength' class='inputbox' type='text' size='$field->size' />"; echo " ".JText::_('ADSMANAGER_MINMAX_MAX')."<input name='".$field->name."_max' id='".$field->name."_max' value=\"".htmlspecialchars($maxvalue)."\" maxlength='$field->maxlength' class='inputbox' type='text' size='$field->size' />"; } break; } break; case 'editor': case 'textarea': case 'emailaddress': case 'url': case 'text': if ((ADSMANAGER_SPECIAL == "abrivac")&&(($field->name == "ad_capaciteconf")||($field->name == "ad_capacitemax"))) { ?> <select name="<?php echo $field->name;?>"> <option value="" <?php if ($value=="") echo 'selected="selected"';?>></option> <option value="1" <?php if ($value==1) echo 'selected="selected"';?>>1 <?php echo TText::_('ADSMANAGER_PERSONNE') ?></option> <option value="2" <?php if ($value==2) echo 'selected="selected"';?>>2 <?php echo TText::_('ADSMANAGER_PERSONNES') ?></option> <option value="3" <?php if ($value==3) echo 'selected="selected"';?>>3 <?php echo TText::_('ADSMANAGER_PERSONNES') ?></option> <option value="4" <?php if ($value==4) echo 'selected="selected"';?>>4 <?php echo TText::_('ADSMANAGER_PERSONNES') ?></option> <option value="5" <?php if ($value==5) echo 'selected="selected"';?>>5 <?php echo TText::_('ADSMANAGER_PERSONNES') ?></option> <option value="6" <?php if ($value==6) echo 'selected="selected"';?>>6 <?php echo TText::_('ADSMANAGER_PERSONNES') ?></option> <option value="7" <?php if ($value==7) echo 'selected="selected"';?>>7 <?php echo TText::_('ADSMANAGER_PERSONNES') ?></option> <option value="8" <?php if ($value==8) echo 'selected="selected"';?>>8 <?php echo TText::_('ADSMANAGER_PERSONNES') ?></option> </select> <?php } else { echo "<input name='".$field->name."' id='".$field->name."' placeholder=\"".$placeholder."\" value=\"".htmlspecialchars($value)."\" maxlength='$field->maxlength' class='inputbox' type='text' size='$field->size' />"; } break; case 'date': $options = array(); $options['size'] = 25; echo JHTML::_('behavior.calendar'); echo JHTML::_('calendar', '', "$field->name", "$field->name", TText::_('ADSMANAGER_DATE_FORMAT_LC'), $options); break; default: if(isset($this->plugins[$field->type])) { if (method_exists($this->plugins[$field->type],"getSearchFormDisplay")) { echo $this->plugins[$field->type]->getSearchFormDisplay($default,$field ); } else { echo $this->plugins[$field->type]->getFormDisplay($default,$field ); } } } } }
<?php foreach($this->fields as $field) { if (@$field->options->edit_admin_only == 0) { $fieldform = $this->field->showFieldForm($field,$this->content,$this->default); if ($fieldform != "") { echo "<div id=\"row_".$field->name."\" class=\"span12\">"; echo "<div class=\"control-group\">"; if ($field->required == 1) $requiredtxt = JText::_('ADSMANAGER_REQUIRED'); else $requiredtxt = ""; if ((@$field->description)&&($field->description !="")) { JHTML::_('behavior.tooltip'); echo "<label class=\"control-label\" for=\"{$field->name}\">". JHTML::tooltip(TText::_($field->description),TText::_($field->title),null,$this->field->showFieldLabel($field,$this->content,$this->default).$requiredtxt). "</label>"; } else { echo "<label class=\"control-label\" for=\"{$field->name}\">".$this->field->showFieldLabel($field,$this->content,$this->default).$requiredtxt."</label>"; } echo $fieldform; echo "</div>"; echo "</div>"; } } } ?> </div> </fieldset> <!-- fields --> <!-- image -->
<?php foreach ($this->fieldsByPosition[$position->id] as $field) { if (@$field->options->edit_admin_only == 0) { $fieldform = $this->field->showFieldForm($field, $this->content, $this->default); if ($fieldform != "") { echo "<div id=\"row_" . $field->name . "\" class=\"span12\">"; if (!isset($field->options->display_edit_title) || $field->options->display_edit_title == 1) { echo "<div class=\"control-group\">"; if ($field->required == 1) { $requiredtxt = JText::_('ADSMANAGER_REQUIRED'); } else { $requiredtxt = ""; } if (@$field->description && $field->description != "") { JHTML::_('behavior.tooltip'); echo "<label class=\"control-label\" for=\"{$field->name}\">" . JHTML::tooltip(TText::_($field->description), TText::_($field->title), null, $this->field->showFieldLabel($field, $this->content, $this->default) . $requiredtxt) . "</label>"; } else { echo "<label class=\"control-label\" for=\"{$field->name}\">" . $this->field->showFieldLabel($field, $this->content, $this->default) . $requiredtxt . "</label>"; } echo "<div class=\"controls\">"; } echo $fieldform; if (!isset($field->options->display_edit_title) || $field->options->display_edit_title == 1) { echo "</div></div>"; } echo "</div>"; } } } ?> </div>
public static function categories($name = 'catid', $selected = '', $attribs = array()) { require_once JPATH_ROOT . '/administrator/components/com_adsmanager/models/category.php'; $model = new AdsmanagerModelCategory(); $list = $model->getFlatTree(false); foreach ($list as $key => $cat) { $indent = ""; for ($i = 0; $i < $cat->level; $i++) { $indent .= " "; } if ($cat->level > 0) { $indent .= 'L '; } $list[$key]->treename = $indent . TText::_($cat->name); } $options[] = JHTML::_('select.option', '', '- ' . sprintf(JText::_('ADSMANAGER_COMMON_SELECT'), JText::_('ADSMANAGER_CATEGORY')) . ' -'); foreach ($list as $item) { $options[] = JHTML::_('select.option', $item->id, $item->treename); } $html = self::genericlist($options, $name, $attribs, $selected, $name); return $html; }
function showFieldSearch($field, $catid, $default, $force = false) { $default = (object) $default; if (isset($default)) { $fieldname = $field->name; $value = @$default->{$fieldname}; } else { $value = null; } $options = $field->options; $values = array(); if (!isset($options) || !isset($options->select_values_storage_type) || $options->select_values_storage_type == "internal") { if (@$this->field_values[$field->fieldid]) { $values = $this->field_values[$field->fieldid]; } } else { if ($options->select_values_storage_type == "db") { $dbname = $options->select_db_storage_db_name; $_name = $options->select_db_storage_column_name; $_value = $options->select_db_storage_column_value; //$parent = $options->select_db_storage_column_parent_value; $sql = "SELECT `{$_name}` as fieldtitle,`{$_value}` as fieldvalue FROM {$dbname}"; $this->_db->setQuery($sql); $values = $this->_db->loadObjectList(); } } if (!isset($options)) { $options = new stdClass(); } foreach ($values as $key => $val) { $values[$key]->fieldtitle = htmlspecialchars(TText::_($val->fieldtitle)); } if ($force == true || strpos($field->catsid, ",{$catid},") !== false || strpos($field->catsid, ",-1,") !== false) { $placeholder = JText::_('ADSMANAGER_SEARCH_PLACEHOLDER_' . strtoupper($field->name)); if ($placeholder == 'ADSMANAGER_SEARCH_PLACEHOLDER_' . strtoupper($field->name)) { $placeholder = ""; } switch ($field->type) { case 'checkbox': if ($value == 1) { echo "<input class='inputbox' type='checkbox' name='" . $field->name . "' value='1' checked='checked' />\n"; } else { echo "<input class='inputbox' type='checkbox' name='" . $field->name . "' value='1' />\n"; } break; case 'radio': case 'multicheckbox': if (!is_array($value)) { $value = array($value); } echo "<table class='cbMulti'>\n"; $k = 0; for ($i = 0; $i < $field->rows; $i++) { echo "<tr>\n"; for ($j = 0; $j < $field->cols; $j++) { $fieldvalue = @$values[$k]->fieldvalue; $fieldtitle = @$values[$k]->fieldtitle; if (isset($fieldtitle)) { $fieldtitle = TText::_($fieldtitle); } echo "<td>\n"; if (isset($values[$k])) { if (!in_array($fieldvalue, $value)) { echo "<input class='inputbox' type='checkbox' id='" . $field->name . "' name='" . $field->name . "[]' value=\"" . htmlspecialchars($fieldvalue) . "\" /> {$fieldtitle} \n"; } else { echo "<input class='inputbox' type='checkbox' id='" . $field->name . "' checked='checked' name='" . $field->name . "[]' value=\"" . htmlspecialchars($fieldvalue) . "\" /> {$fieldtitle} \n"; } } echo "</td>\n"; $k++; } echo "</tr>\n"; } echo "</table>\n"; break; case 'select': if (ADSMANAGER_SPECIAL == "abrivac" && $field->name == "ad_type") { $value = @$default->ad_type; foreach ($values as $v) { $ftitle = $v->fieldtitle; $fieldvalue = $v->fieldvalue; //var_dump($fieldvalue,$value); if (!is_array($value)) { $value = array(); } echo "<div class='champ_filtre_checkbox'>"; if (in_array($fieldvalue, $value)) { echo "<input class='inputbox' type='checkbox' name='" . $field->name . "[]' checked='checked' value=\"" . htmlspecialchars($fieldvalue) . "\" /> {$ftitle} \n"; } else { echo "<input class='inputbox' type='checkbox' name='" . $field->name . "[]' value=\"" . htmlspecialchars($fieldvalue) . "\" /> {$ftitle} \n"; } echo "</div>"; } } else { echo "<select id='" . $field->name . "' name='" . $field->name . "'>\n"; echo "<option value='' >" . $placeholder . "</option>\n"; foreach ($values as $v) { $ftitle = $v->fieldtitle; if ($value == $v->fieldvalue || $value == $ftitle) { echo "<option value=\"" . htmlspecialchars($v->fieldvalue) . "\" selected='selected' >{$ftitle}</option>\n"; } else { echo "<option value=\"" . htmlspecialchars($v->fieldvalue) . "\" >{$ftitle}</option>\n"; } } echo "</select>\n"; } break; case 'multiselect': echo "<select name=\"" . $field->name . "[]\" multiple='multiple' size='{$field->size}'>\n"; foreach ($values as $v) { $ftitle = $v->fieldtitle; if ($field->required == 1) { $mosReq = "mosReq='1'"; } if (strpos($value, "," . $v->fieldvalue . ",") === false && strpos($value, $ftitle . "|*|") === false && strpos($value, "|*|" . $ftitle) === false && $value != $ftitle) { echo "<option value=\"" . htmlspecialchars($v->fieldvalue) . "\" >{$ftitle}</option>\n"; } else { echo "<option value=\"" . htmlspecialchars($v->fieldvalue) . "\" selected='selected' >{$ftitle}</option>\n"; } } echo "</select>\n"; break; case 'price': case 'number': if (!isset($options->search_type)) { $options->search_type = "textfield"; } if (isset($default)) { $fieldname = $field->name . "_min"; $minvalue = @$default->{$fieldname}; $fieldname = $field->name . "_max"; $maxvalue = @$default->{$fieldname}; } switch ($options->search_type) { case "textfield": echo "<input name='" . $field->name . "' placeholder=\"" . htmlspecialchars($placeholder) . "\" id='" . $field->name . "' value=\"" . htmlspecialchars($value) . "\" maxlength='{$field->maxlength}' class='inputbox' type='text' size='{$field->size}' />"; break; case "select": echo "<select id='" . $field->name . "' name='" . $field->name . "'>\n"; echo "<option value='' >" . htmlspecialchars($placeholder) . "</option>\n"; foreach ($values as $v) { $ftitle = TText::_($v->fieldtitle); if ($value == $v->fieldvalue) { echo "<option value=\"" . htmlspecialchars($v->fieldvalue) . "\" selected='selected'>{$ftitle}</option>\n"; } else { echo "<option value=\"" . htmlspecialchars($v->fieldvalue) . "\" >{$ftitle}</option>\n"; } } echo "</select>\n"; break; case "minmax": echo JText::_('ADSMANAGER_MINMAX_MIN') . "<input name='" . $field->name . "_min' id='" . $field->name . "_min' value=\"" . htmlspecialchars($minvalue) . "\" maxlength='{$field->maxlength}' class='inputbox' type='text' size='{$field->size}' />"; echo " " . JText::_('ADSMANAGER_MINMAX_MAX') . "<input name='" . $field->name . "_max' id='" . $field->name . "_max' value=\"" . htmlspecialchars($maxvalue) . "\" maxlength='{$field->maxlength}' class='inputbox' type='text' size='{$field->size}' />"; break; } break; case 'editor': case 'textarea': case 'emailaddress': case 'url': case 'text': if (ADSMANAGER_SPECIAL == "abrivac" && ($field->name == "ad_capaciteconf" || $field->name == "ad_capacitemax")) { ?> <select name="<?php echo $field->name; ?> "> <option value="" <?php if ($value == "") { echo 'selected="selected"'; } ?> ></option> <option value="1" <?php if ($value == 1) { echo 'selected="selected"'; } ?> >1 <?php echo TText::_('ADSMANAGER_PERSONNE'); ?> </option> <option value="2" <?php if ($value == 2) { echo 'selected="selected"'; } ?> >2 <?php echo TText::_('ADSMANAGER_PERSONNES'); ?> </option> <option value="3" <?php if ($value == 3) { echo 'selected="selected"'; } ?> >3 <?php echo TText::_('ADSMANAGER_PERSONNES'); ?> </option> <option value="4" <?php if ($value == 4) { echo 'selected="selected"'; } ?> >4 <?php echo TText::_('ADSMANAGER_PERSONNES'); ?> </option> <option value="5" <?php if ($value == 5) { echo 'selected="selected"'; } ?> >5 <?php echo TText::_('ADSMANAGER_PERSONNES'); ?> </option> <option value="6" <?php if ($value == 6) { echo 'selected="selected"'; } ?> >6 <?php echo TText::_('ADSMANAGER_PERSONNES'); ?> </option> <option value="7" <?php if ($value == 7) { echo 'selected="selected"'; } ?> >7 <?php echo TText::_('ADSMANAGER_PERSONNES'); ?> </option> <option value="8" <?php if ($value == 8) { echo 'selected="selected"'; } ?> >8 <?php echo TText::_('ADSMANAGER_PERSONNES'); ?> </option> </select> <?php } else { echo "<input name='" . $field->name . "' id='" . $field->name . "' placeholder=\"" . htmlspecialchars($placeholder) . "\" value=\"" . htmlspecialchars($value) . "\" maxlength='{$field->maxlength}' class='inputbox' type='text' size='{$field->size}' />"; } break; case 'date': $options = array(); $options['size'] = 25; echo JHTML::_('behavior.calendar'); echo JHTML::_('calendar', '', "{$field->name}", "{$field->name}", TText::_('ADSMANAGER_DATE_FORMAT_LC'), $options); break; default: if (isset($this->plugins[$field->type])) { if (method_exists($this->plugins[$field->type], "getSearchFormDisplay")) { echo $this->plugins[$field->type]->getSearchFormDisplay($default, $field); } else { echo $this->plugins[$field->type]->getFormDisplay($default, $field); } } } } }