function addDefaultCustomFields($fromInstall = FALSE) { global $lll; if ($this->up) { // az alkategoria orokli az apja custom fieldjeit: G::load($customFields, array("SELECT * FROM @customfield WHERE cid=#up#", $this->up)); foreach ($customFields as $cf) { $cf->cid = $this->id; unset($cf->id); create($cf); } } else { ItemField::addDefaultCustomFields($fromInstall, $this->id); } }
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; }
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"]; } }
/** * Constructor. * * @param string $method An item method name * @param array $options An options array * @param array $attributes An attributes array */ public function __construct($method, array $options = [], array $attributes = []) { $name = ['rss' => 'enclosure', 'atom' => 'link']; parent::__construct($name, $method, $options, $attributes); }
function move() { global $gorumroll; // csak admin move-olhat: hasAdminRights($isAdm); if (!$isAdm) { return; } $oldCid = G::getAttr($this->id, "item", "cid"); // ha nincs move-olas: if ($oldCid == $this->cid) { return; } G::load($newCategory, array("SELECT * FROM @category WHERE id=#cid#", $this->cid)); // Ellenorzes: ItemField::filterCompatibleCategories($oldCid, $newCategory); if (!count($newCategory)) { return; } // trukkozes $newCategory = $newCategory[0]; CustomField::addCustomColumns("item"); G::load($oldFields, array("SELECT columnIndex FROM @customfield WHERE cid=#cid# ORDER BY sortId ASC", $oldCid)); G::load($newFields, array("SELECT columnIndex FROM @customfield WHERE cid=#cid# ORDER BY sortId ASC", $this->cid)); load($this); $newObj = gclone($this); $newObj->cid = $newCategory->id; if ($newCategory->immediateAppear) { $newObj->status = TRUE; } for ($i = 0; $i < count($oldFields); $i++) { if (isset($this->{$oldFields[$i]->columnIndex})) { $newObj->{$newFields[$i]->columnIndex} = $this->{$oldFields[$i]->columnIndex}; } } modify($newObj); // itemnumok beallitasa if ($newObj->status) { $newCategory->increaseDirectItemNum(); } G::load($oldCategory, $oldCid, "appcategory"); if ($this->status) { $oldCategory->decreaseDirectItemNum(); } Roll::setInfoText("adMoved"); CacheManager::resetCache($this->cid); CacheManager::resetCache($oldCid); }
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(); } } }
function addDefaultCustomFields($fromInstall = FALSE, $cid = 0) { global $lll; // Creating the fix fields: $v = new ItemField(); $v->cid = $cid; $v->isCommon = !$cid; $v->name = $lll["item_id"]; $v->showInForm = customfield_forNone; $v->type = customfield_text; $v->subType = customfield_integer; $v->sortable = TRUE; $v->columnIndex = "id"; $v->searchable = customfield_forNone; $v->showInList = customfield_forNone; $v->showInDetails = customfield_forNone; $v->create(); $v = new ItemField(); $v->cid = $cid; $v->isCommon = !$cid; $v->name = $lll["appcategory"]; $v->showInForm = customfield_forNone; $v->type = customfield_selection; $v->columnIndex = "cName"; $v->searchable = customfield_forAll; $v->create(); if (!$v->cid) { $v->showInList = customfield_forAll; $v->modify(); } $v = new ItemField(); $v->cid = $cid; $v->isCommon = !$cid; $v->name = $lll["creationtime"]; $v->showInForm = customfield_forNone; $v->type = customfield_date; $v->searchable = customfield_forAll; $v->rangeSearch = TRUE; $v->columnIndex = "creationtime"; $v->create(); if (!$v->cid) { $v->showInList = customfield_forAll; $v->modify(); } $v = new ItemField(); $v->cid = $cid; $v->isCommon = !$cid; $v->name = $lll["item_status"]; $v->showInForm = customfield_forAdmin; $v->showInDetails = customfield_forAdmin; $v->type = customfield_selection; $v->values = "0,1"; $v->columnIndex = "status"; $v->searchable = customfield_forAdmin; $v->create(); if (!$v->cid) { $v->showInList = customfield_forAdmin; $v->modify(); } $v = new ItemField(); $v->cid = $cid; $v->isCommon = !$cid; $v->name = $lll["item_clicked"]; $v->showInForm = customfield_forNone; $v->showInDetails = customfield_forOwner; $v->type = customfield_text; $v->subType = customfield_integer; $v->columnIndex = "clicked"; $v->searchable = customfield_forAdmin; $v->rangeSearch = TRUE; $v->create(); if (!$v->cid) { $v->showInList = customfield_forLoggedin; $v->modify(); } $v = new ItemField(); $v->cid = $cid; $v->isCommon = !$cid; $v->name = $lll["item_responded"]; $v->showInForm = customfield_forNone; $v->showInDetails = customfield_forOwner; $v->type = customfield_text; $v->subType = customfield_integer; $v->columnIndex = "responded"; $v->searchable = customfield_forAdmin; $v->rangeSearch = TRUE; $v->create(); if (!$v->cid) { $v->showInList = customfield_forAdmin; $v->modify(); } $v = new ItemField(); $v->cid = $cid; $v->isCommon = !$cid; $v->name = $lll["item_ownerName"]; $v->showInForm = customfield_forNone; $v->showInDetails = customfield_forAll; $v->type = customfield_multipleselection; $v->columnIndex = "ownerName"; $v->searchable = customfield_forAdmin; $v->create(); if (!$v->cid) { $v->showInList = customfield_forAll; $v->modify(); } $v = new ItemField(); $v->cid = $cid; $v->isCommon = !$cid; $v->name = $lll["exp"]; $v->showInForm = customfield_forNone; $v->showInDetails = customfield_forOwner; $v->type = customfield_date; $v->searchable = customfield_forAdmin; $v->rangeSearch = TRUE; $v->columnIndex = "expirationTime"; $v->create(); if (!$v->cid) { $v->showInList = customfield_forAdmin; $v->modify(); } // ha uj kategoriat hozunk letre, akkor a tobbi categoriaban common-na tett mezoket bele kell masolni: if ($cid) { $query = "SELECT * FROM @customfield WHERE cid=0 AND isCommon=1 AND columnIndex LIKE 'col_%'"; G::load($commonFields, $query); $customCommonFields = array(); foreach ($commonFields as $field) { if (empty($customCommonFields[$field->name][$field->type])) { $field->cid = $cid; unset($field->id); create($field); $customCommonFields[$field->name][$field->type] = 1; } } } if (!$fromInstall) { // a kovetkezo mezoket csak kkor hozzuk letre, ha meg nem leteznek. // Akkor letezhetnek, ha az iment mar letrehoztuk oket, mert common-ok: if (!$cid || empty($customCommonFields[$lll["title"]][customfield_text])) { $v = new ItemField(); $v->cid = $cid; $v->isCommon = !$cid; $v->name = $lll["title"]; $v->type = customfield_text; $v->seo = customfield_title; $v->showInList = customfield_forAll; $v->mandatory = TRUE; $v->searchable = customfield_forAll; if (!$cid) { $v->columnIndex = "title"; } $v->create(); } if (!$cid || empty($customCommonFields[$lll["description"]][customfield_textarea])) { $v = new ItemField(); $v->cid = $cid; $v->isCommon = !$cid; $v->name = $lll["description"]; $v->type = customfield_textarea; $v->seo = customfield_description; $v->showInList = customfield_forAll; $v->innewline = TRUE; $v->searchable = customfield_forAll; if (!$cid) { $v->columnIndex = "description"; } $v->create(); } if ($cid && empty($customCommonFields[$lll["item_picture"]][customfield_picture])) { $v = new ItemField(); $v->cid = $cid; $v->isCommon = FALSE; $v->name = $lll["item_picture"]; $v->type = customfield_picture; $v->mainPicture = 1; $v->searchable = customfield_forAll; $v->showInList = customfield_forAll; $v->rowspan = TRUE; $v->create(); } } }