Example #1
0
 function getFields()
 {
     if (!$this->fields && ($cid = $this->getCid()) !== null) {
         $query = "SELECT * FROM @itemfield WHERE cid=#cid# ORDER BY sortId ASC";
         G::load($this->fields, array($query, $cid));
         ItemField::updateFromUserFields($this->fields);
     } elseif (!$this->fields) {
         $this->fields = ItemField::getFixAndCommonFields();
     }
     return $this->fields;
 }
Example #2
0
 function activateVariableFields()
 {
     $typ =& $this->getTypeInfo(TRUE);
     $table = $this->getManagedTable();
     $obj = new $table();
     $obj->cid = empty($this->cid) ? 0 : $this->cid;
     if ($obj->cid) {
         list($recursive, $allowAd) = G::getAttr($obj->cid, "appcategory", "recursive", "allowAd");
     }
     $showAdvancedSearch = !$obj->cid || !$allowAd && !$recursive;
     $showCategorySearch = FALSE;
     $typ["order"][] = "str";
     if ($showAdvancedSearch) {
         $fields = ItemField::getFixAndCommonFields();
     } else {
         $fields = $obj->getFields();
     }
     foreach ($fields as $field) {
         // a cName searchable attributuma hatarozza meg, hogy van-e kategoria szelektor a search formban:
         if ($field->columnIndex == "cName") {
             $showCategorySearch = $field->displayInSearchFormCondition();
             break;
         }
     }
     if ($showCategorySearch) {
         $typ["order"][] = "categorySearch";
         $typ["order"][] = "cid";
     }
     if ($showAdvancedSearch) {
         $typ["order"][] = "advancedSearch";
     }
     foreach ($fields as $field) {
         if ($field->columnIndex != "cName") {
             $this->activateField($field);
         }
     }
     // hogy a keresesek alapbol az aktiv itemekre menjenek:
     if (isset($typ["attributes"]["status"])) {
         $typ["attributes"]["status"]["default"] = 1;
     }
     $typ["order"][] = "relationBetweenFields";
     return $fields;
 }
Example #3
0
 function activateVariableFields()
 {
     global $lll, $defaultPrecisionSeparator, $gorumroll;
     $typ =& $this->getTypeInfo(TRUE);
     hasAdminRights($isAdm);
     if (empty($this->cid) && !is_a($this, "user") && empty($this->fields)) {
         $fields = ItemField::getFixAndCommonFields();
     } else {
         $fields = $this->getFields();
     }
     $typ["order"] = array_keys($typ["attributes"]);
     for ($i = 0; $i < count($fields); $i++) {
         $v =& $fields[$i];
         // juzer fieldek nem lehetnek formban:
         if ($gorumroll->method == "create" && !empty($v->userField)) {
             continue;
         }
         // ha mar benne van, kivesszuk, hogy a sorrend stimmeljen:
         if (($key = array_search($v->columnIndex, $typ["order"])) !== FALSE) {
             unset($typ["order"][$key]);
         }
         $typ["order"][] = $v->columnIndex;
         if (!isset($typ["attributes"][$v->columnIndex])) {
             $typ["attributes"][$v->columnIndex] = array("type" => "TEXT");
         }
         $attrInfo =& $typ["attributes"][$v->columnIndex];
         $attrInfo["fieldIndex"] = "{$i}";
         $lll[$this->get_table() . "_{$v->columnIndex}"] = $v->getAttr("name");
         //echo($this->get_table()."_$v->columnIndex<br>");
         //var_dump($lll[$this->get_table()."_$v->columnIndex"]);
         if ($v->mandatory) {
             $attrInfo[] = "mandatory";
             $attrInfo["min"] = "1";
         }
         if ($v->rowspan) {
             $attrInfo[] = "rowspan";
         }
         if ($v->innewline) {
             $attrInfo[] = "in new line";
         }
         if ($v->customListPlacement) {
             $attrInfo[] = "customListPlacement";
         }
         if ($v->customDetailsPlacement) {
             $attrInfo[] = "customDetailsPlacement";
         }
         if ($v->css) {
             $attrInfo["customCss"] = $v->css;
         }
         if ($v->sortable) {
             $attrInfo[] = "sorta";
             if ($v->subType == customfield_integer || $v->subType == customfield_float) {
                 $attrInfo[] = "sortasint";
             }
         }
         if (!$v->displayLabel) {
             $attrInfo[] = "widecontent_details";
         }
         if ($v->detailsPosition != customfield_normal) {
             if ($v->detailsPosition == customfield_topright) {
                 $attrInfo["sidebar"] = "top";
             } elseif ($v->detailsPosition == customfield_bottomright) {
                 $attrInfo["sidebar"] = "bottom";
             }
         }
         if ($v->expl && !isset($lll[$lllLabel = $this->get_table() . "_{$v->columnIndex}" . "_expl"])) {
             $lll[$lllLabel] = $v->getAttr("expl");
         }
         if ($gorumroll->method == "showdetails") {
             $v->displayInDetails($attrInfo, isset($this->ownerId) ? $this->ownerId : 0);
         } elseif ($gorumroll->method == "showhtmllist") {
             $v->displayInList($attrInfo);
         } else {
             $v->displayInForm($attrInfo);
         }
         switch ($v->type) {
             case customfield_text:
                 $attrInfo[] = "text";
                 $attrInfo["default"] = $v->default;
                 $attrInfo["subtype"] = $v->subType;
                 if ($v->format) {
                     $attrInfo["format"] = $v->format;
                 }
                 if ($v->allowHtml) {
                     $attrInfo[] = "allow_html";
                 }
                 if ($v->seo == customfield_title) {
                     $attrInfo[] = "titleTag";
                 }
                 if ($v->seo == 1) {
                     $attrInfo[] = "descriptionTag";
                 }
                 if ($v->seo == customfield_keywords) {
                     $attrInfo[] = "keywordsTag";
                 }
                 if ($v->displaylength) {
                     $attrInfo["displaylength"] = $v->displaylength;
                 }
                 if ($v->subType == customfield_integer) {
                     $attrInfo["filterCharacters"] = "numeric()";
                 }
                 if ($v->subType == customfield_float) {
                     $attrInfo["filterCharacters"] = "numeric({allow:'{$defaultPrecisionSeparator}'})";
                 }
                 break;
             case customfield_textarea:
                 $attrInfo[] = "textarea";
                 $attrInfo["default"] = $v->default;
                 $attrInfo["rows"] = 10;
                 if ($v->allowHtml) {
                     $attrInfo[] = "allow_html";
                 }
                 if ($v->displaylength) {
                     $attrInfo["displaylength"] = $v->displaylength;
                 }
                 if ($v->seo == customfield_title) {
                     $attrInfo[] = "titleTag";
                 }
                 if ($v->seo == customfield_description) {
                     $attrInfo[] = "descriptionTag";
                 }
                 if ($v->seo == customfield_keywords) {
                     $attrInfo[] = "keywordsTag";
                 }
                 if ($v->useMarkitup) {
                     $attrInfo["markitup"] = array("set" => "ad_html");
                     $attrInfo[] = "widecontent_form";
                 } else {
                     $attrInfo["cols"] = 50;
                 }
                 break;
             case customfield_bool:
                 $attrInfo[] = "bool";
                 $attrInfo["default"] = $v->default;
                 break;
             case customfield_selection:
                 $attrInfo[] = "selection";
                 $v->activateEnumAttrInfo($attrInfo, $this->get_table(), $v->columnIndex);
                 break;
             case customfield_multipleselection:
                 $attrInfo[] = "multipleselection";
                 $count = $v->activateEnumAttrInfo($attrInfo, $this->get_table(), $v->columnIndex);
                 if ($count) {
                     $attrInfo["size"] = min(10, $count);
                 }
                 break;
             case customfield_checkbox:
                 $attrInfo[] = "checkbox";
                 $attrInfo["cols"] = $v->checkboxCols;
                 $v->activateEnumAttrInfo($attrInfo, $this->get_table(), $v->columnIndex);
                 break;
             case customfield_separator:
                 $attrInfo[] = "section";
                 $attrInfo["name"] = $v->name;
                 if (!isset($lll[$v->columnIndex])) {
                     $lll[$v->columnIndex] = $v->getAttr("name");
                 }
                 break;
             case customfield_picture:
                 $attrInfo[] = "file";
                 $attrInfo["name"] = $v->name;
                 $lll[$v->columnIndex] = $v->getAttr("name");
                 if (!empty($v->mainPicture)) {
                     $attrInfo[] = "pictureTag";
                 }
                 break;
             case customfield_media:
                 $attrInfo[] = "file";
                 $attrInfo[] = "media";
                 $attrInfo["name"] = $v->name;
                 $lll[$v->columnIndex] = $v->getAttr("name");
                 break;
             case customfield_url:
                 $attrInfo[] = "url";
                 $attrInfo["length"] = 20;
                 break;
             case customfield_date:
                 $attrInfo["type"] = "DATETIME";
                 $attrInfo["prototype"] = "date";
                 $attrInfo["format"] = "([0-9]{4})-([0-9]{2})-([0-9]{2})\$";
                 $attrInfo["order"] = array("year", "month", "day");
                 $attrInfo["display_format"] = "Y-m-d";
                 $attrInfo["length"] = 16;
                 $attrInfo[] = "jscalendar";
                 $attrInfo[] = "datetext";
                 $attrInfo["fromyear"] = $v->fromyear ? $v->fromyear : "now";
                 $attrInfo["toyear"] = $v->toyear ? $v->toyear : "now";
                 if ($v->dateDefaultNow) {
                     $attrInfo[] = "defaultnow";
                 }
             default:
                 break;
         }
     }
     if (!isset($typ["listOrder"])) {
         $typ["listOrder"] = $typ["order"];
     }
 }
Example #4
0
 function addDefaultCustomLists()
 {
     global $includeDumpJs;
     $v1 = ItemField::getFixOrCommonField('title');
     $v2 = ItemField::getFixOrCommonField('cName');
     $v3 = ItemField::getFixOrCommonField('creationtime');
     $v4 = ItemField::getFixOrCommonField('description');
     $v5 = ItemField::getFixOrCommonField('clicked');
     $v6 = ItemField::getFixOrCommonField('responded');
     $v7 = ItemField::getFixOrCommonField('ownerName');
     // Kivalasztjuk a common picture field-et, ha letezik:
     $fields = ItemField::getFixAndCommonFields();
     for ($pictureField = 0, $i = 0; !$pictureField && $i < count($fields); $pictureField = $fields[$i++]->type == customfield_picture ? $fields[$i - 1]->id : 0) {
     }
     $cl = new CustomList();
     $cl->listTitle = "Search result list";
     $cl->listDescription = "This is a special custom list you can use to configure the columns of a non-category specific search result list.";
     $cl->columns = "{$v1->id},{$v2->id},{$v4->id},{$v7->id}" . ($pictureField ? ",{$pictureField}" : "");
     $cl->create(TRUE);
     $cl = new CustomList();
     $cl->listTitle = "My ads";
     $cl->listDescription = "The list of ads of a user. This means both the 'My ads' list (the list of the currently logged in user), and the 'Advertisements of user XY' lists.";
     $cl->ownerName = array(0);
     $cl->primarySort = $v3->id;
     $cl->primaryDir = "DESC";
     $cl->columns = "{$v1->id},{$v2->id},{$v5->id},{$v6->id},{$v4->id}";
     $cl->displayedFor = customfield_forLoggedin;
     $cl->displayInMenu = customlist_userMenu;
     $cl->relationBetweenFields = search_allFields;
     $cl->create(TRUE);
     $cl = new CustomList();
     $cl->listTitle = "Recent ads";
     $cl->listDescription = "List of 100 most recent ads";
     $cl->status = array(1);
     $cl->primarySort = $v3->id;
     $cl->primaryDir = "DESC";
     $cl->limit = '100';
     $cl->columns = "{$v1->id},{$v2->id},{$v3->id},{$v4->id}" . ($pictureField ? ",{$pictureField}" : "");
     $cl->displayedFor = customfield_forAll;
     $cl->displayInMenu = customlist_loginMenu;
     $cl->create(TRUE);
     $cl = new CustomList();
     $cl->listTitle = "Popular ads";
     $cl->listDescription = "List of 100 most viewed ads";
     $cl->status = array(1);
     $cl->primarySort = $v5->id;
     $cl->primaryDir = "DESC";
     $cl->secondarySort = $v3->id;
     $cl->secondaryDir = "DESC";
     $cl->limit = '100';
     $cl->columns = "{$v1->id},{$v2->id},{$v5->id},{$v6->id},{$v4->id}" . ($pictureField ? ",{$pictureField}" : "");
     $cl->displayedFor = customfield_forAll;
     $cl->displayInMenu = customlist_loginMenu;
     $cl->create(TRUE);
     $cl = new CustomList();
     $cl->listTitle = "Pending ads";
     $cl->listDescription = "The list of ads that you haven't approved yet.";
     $cl->status = array(0);
     $cl->primarySort = $v3->id;
     $cl->primaryDir = "ASC";
     $cl->columns = "{$v1->id},{$v2->id},{$v3->id},{$v7->id},{$v4->id}";
     $cl->displayedFor = customfield_forAdmin;
     $cl->displayInMenu = customlist_adminMenu;
     $cl->create(TRUE);
     $cl = new CustomList();
     $cl->listTitle = "Featured ads: Gold level";
     $cl->listDescription = "This is a featured ad list that demonstrate a way you can set up the 'featured ads' feature yourself. It contains all the ads where the 'Promotion level' common custom field has been set to 'Gold'.";
     $cl->status = array(1);
     $cl->columns = "{$v1->id}" . ($pictureField ? ",{$pictureField}" : "") . ",{$v4->id}";
     foreach ($fields as $field) {
         if ($field->name == "Promotion level") {
             $cl->{$field->columnIndex} = array("Gold");
         }
     }
     $cl->displayedFor = customfield_forAdmin;
     $cl->listStyle = customlist_scrollable;
     $cl->positionScrollable = customlist_aboveContent;
     $cl->pages = $includeDumpJs ? "" : "/";
     $cl->limit = 10;
     $cl->relationBetweenFields = search_allFields;
     $cl->create(TRUE);
     // vegig kell menni a common fieldeken
     reset($fields);
     foreach ($fields as $field) {
         if (strstr($field->columnIndex, "col_")) {
             $field->updateDefaultOfSelectionTypeFieldOfCustomList();
         }
     }
 }
Example #5
0
 function getFixOrCommonField($which)
 {
     $fields = ItemField::getFixAndCommonFields();
     foreach ($fields as $field) {
         if ($field->columnIndex == $which) {
             return $field;
         }
     }
 }