Source of file api.customfields.php
Size: 29,652 Bytes - Last Modified: 2024-04-27T15:26:05+03:00
/tmp/current_snapshot/api/libs/api.customfields.php
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858 | <?php /** * Custom profile fields implementation */ class CustomFields { /** * Contains system alter config as key=>value * * @var array */ protected $altCfg = array(); /** * Contains available custom fileds types as TYPE=>description * * @var array */ protected $typesAvailable = array(); /** * Current instance user login * * @var string */ protected $login = ''; /** * Custom Fileds types database abstraction layer * * @var object */ protected $typesDb = ''; /** * Custom Fileds item records database abstraction layer * * @var object */ protected $itemsDb = ''; /** * System message helper instance placeholder * * @var object */ protected $messages = ''; /** * Contains all available custom profile fileds types as id=>typeData * * @var array */ protected $allTypes = array(); /** * Contains all current instance user custom fields data as typeId=>cfData * * @var array */ protected $userFieldsData = array(); /** * Some predefined stuff like URLs, routes etc */ const TABLE_TYPES = 'cftypes'; const TABLE_ITEMS = 'cfitems'; const PROUTE_NEWTYPE = 'newtype'; const PROUTE_NEWNAME = 'newname'; const PROUTE_EDID = 'editid'; const PROUTE_EDTYPE = 'edittype'; const PROUTE_EDNAME = 'editname'; const ROUTE_DELETE = 'deletetypeid'; const ROUTE_EDIT = 'edittypeid'; const PROUTE_MODTYPE = 'modcftypeid'; const PROUTE_MODLOGIN = 'modcflogin'; const PROUTE_MODCONTENT = 'modcfcontent'; const PROUTE_SEARCHTYPEID = 'cftypeid'; const PROUTE_SEARCHQUERY = 'cfquery'; const PHOTOSTORAGE_SCOPE = 'CFITEMS'; const PHOTOSTORAGE_ITEMID_DELIMITER = '|'; const FILESTORAGE_SCOPE = 'CFITEMS'; const FILESTORAGE_ITEMID_DELIMITER = '|'; const URL_ME = '?module=cftypes'; const URL_EDIT_BACK = '?module=useredit&username='; const URL_PHOTOUPL = '?module=photostorage&scope=CFITEMS&mode=list&itemid='; const URL_FILEUPL = '?module=filestorage&scope=CFITEMS&mode=list&itemid='; // _ // {` `'-. // { \ (\._ // { | / o'. // `} /.`'.___.' // { .' , \_/`\ // } /`_ '-. '=/ // { .' `\;`'` // { ; /_ // '-'...-;`__\ // // ^^^^ A CE BILOCHKA /** * Creates new CF instance * * @param string $login */ public function __construct($login = '') { $this->loadAltCfg(); $this->initMessages(); $this->setAvailableTypes(); $this->setLogin($login); $this->initDb(); $this->loadTypes(); if (!empty($this->login)) { $this->loadUserItems(); } } /** * Inits database absctraction layer for further usage * * @return void */ protected function initDb() { $this->typesDb = new NyanORM(self::TABLE_TYPES); $this->itemsDb = new NyanORM(self::TABLE_ITEMS); } /** * Loads system alter config to protected property * * @global object $ubillingConfig * * @return void */ protected function loadAltCfg() { global $ubillingConfig; $this->altCfg = $ubillingConfig->getAlter(); } /** * Inits system messages helper protected instance * * @return void */ protected function initMessages() { $this->messages = new UbillingMessageHelper(); } /** * Loads existing CF types from database * * @return void */ protected function loadTypes() { $this->allTypes = $this->typesDb->getAll('id'); } /** * Sets available custom fields types * * @return void */ protected function setAvailableTypes() { //basic types $this->typesAvailable = array( 'VARCHAR' => __('String'), 'TRIGGER' => __('Trigger'), 'TEXT' => __('Text'), 'INT' => __('Integer'), 'FLOAT' => __('Float'), 'FINANCE' => __('Finance'), 'NETWORK' => __('Network'), 'URL' => __('URL'), 'DATE' => __('Date'), 'TIME' => __('Time'), 'COLOR' => __('Color'), 'LIST' => __('List') ); //optional types if ($this->altCfg['PHOTOSTORAGE_ENABLED']) { $this->typesAvailable['PHOTO'] = __('Image'); } if ($this->altCfg['FILESTORAGE_ENABLED']) { $this->typesAvailable['FILE'] = __('File'); } } /** * Sets current instance user login * * @param string $login * * @return void */ protected function setLogin($login = '') { if (!empty($login)) { $this->login = ubRouting::filters($login, 'mres'); } } /** * Returns all available CF types as id=>typeData * * @return array */ public function getTypesAll() { return($this->allTypes); } /** * Returns all available fields data for all users * * @return array */ public function getAllFieldsData() { $result = array(); if (!empty($this->allTypes)) { $result = $this->itemsDb->getAll(); } return($result); } /** * Returns existing CF type data by its typeId * * @param int $typeId Existing CF type database ID * * @return array */ protected function getTypeData($typeId) { $result = array(); if (isset($this->allTypes[$typeId])) { $result = $this->allTypes[$typeId]; } return($result); } /** * Loads current instance users items data into protected property * * @return void */ protected function loadUserItems() { if (!empty($this->login)) { if (!empty($this->allTypes)) { $this->itemsDb->where('login', '=', $this->login); $this->userFieldsData = $this->itemsDb->getAll('typeid'); } } } /** * Flushes all of assigned to users CFs data from database * * @param int $typeId Existing CF type database ID * * @return void */ protected function flushType($typeId) { $typeId = ubRouting::filters($typeId, 'int'); $this->itemsDb->where('typeid', '=', $typeId); $this->itemsDb->delete(); log_register('CFTYPE FLUSH [' . $typeId . ']'); } /** * Deletes CF type from database by its ID and flushes assigned * * @param int $typeId Existing CF type database ID * * @return void */ public function deleteType($typeId) { $typeId = ubRouting::filters($typeId, 'int'); $this->typesDb->where('id', '=', $typeId); $this->typesDb->delete(); log_register('CFTYPE DELETE [' . $typeId . ']'); $this->flushType($typeId); } /** * Deletes all of CF items from database associated with some user * * @return void */ public function flushAllUserFieldsData() { if (!empty($this->login)) { $this->itemsDb->where('login', '=', $this->login); $this->itemsDb->delete(); log_register('CF FLUSH (' . $this->login . ')'); } } /** * Creates new CF type in database * * @param string $type Type of the CF (VARCHAR, TRIGGER, TEXT etc) * @param string $name Name of the custom field for display * * @return void */ public function createType($type, $name) { $type = ubRouting::filters($type, 'mres'); $name = ubRouting::filters($name, 'mres'); if ((!empty($name)) AND ( !empty($type))) { $this->typesDb->data('type', $type); $this->typesDb->data('name', $name); $this->typesDb->create(); $newId = $this->typesDb->getLastId(); log_register('CFTYPE ADD `' . $type . '` NAME `' . $name . '` AS [' . $newId . ']'); } } /** * Returns Custom Field Type creation form * * @return string */ public function renderTypeCreationForm() { $result = ''; $inputs = wf_Selector(self::PROUTE_NEWTYPE, $this->typesAvailable, __('Field type'), '', true); $inputs .= wf_TextInput(self::PROUTE_NEWNAME, __('Field name'), '', true, 15); $inputs .= wf_Submit(__('Create')); $result = wf_Form('', 'POST', $inputs, 'glamour'); return($result); } /** * Returns CF type editing form * * @param int $typeId Existing CF type ID * * @return string */ public function renderTypeEditForm($typeId) { $result = ''; $typeId = ubRouting::filters($typeId, 'int'); $typeData = $this->getTypeData($typeId); if (!empty($typeData)) { $inputs = wf_HiddenInput('editid', $typeId); $inputs .= wf_Selector('edittype', $this->typesAvailable, 'Field type', $typeData['type'], true); $inputs .= wf_TextInput('editname', 'Field name', $typeData['name'], true); $inputs .= wf_Submit('Edit'); $result .= wf_Form('', 'POST', $inputs, 'glamour'); } else { $result .= $this->messages->getStyledMessage(__('Something went wrong') . ' [' . $typeId . '] ' . __('Not exists'), 'error'); } $result .= wf_delimiter(); $result .= wf_BackLink(self::URL_ME); return($result); } /** * Saves CF type editing form into database * * @return void */ public function saveType() { if (ubRouting::checkPost(array(self::PROUTE_EDID, self::PROUTE_EDTYPE, self::PROUTE_EDNAME))) { $id = ubRouting::post(self::PROUTE_EDID, 'int'); $type = ubRouting::post(self::PROUTE_EDTYPE, 'mres'); $name = ubRouting::post(self::PROUTE_EDNAME); $nameF = ubRouting::filters($name, 'mres'); if (isset($this->allTypes[$id])) { $this->typesDb->data('type', $type); $this->typesDb->data('name', $nameF); $this->typesDb->where('id', '=', $id); $this->typesDb->save(); log_register('CFTYPE CHANGE [' . $id . '] NAME `' . $name . '`'); } } } /** * Returns human-readable type description * * @param string $type * * @return string */ protected function getTypeNameDesc($type) { $result = ''; if (isset($this->typesAvailable[$type])) { $result .= $this->typesAvailable[$type]; } else { $result .= __('Disabled'); } return($result); } /** * Renders list of available CF types * * @return string */ public function renderTypesList() { $result = ''; if (!empty($this->allTypes)) { $cells = wf_TableCell(__('ID')); $cells .= wf_TableCell(__('Field type')); $cells .= wf_TableCell(__('Field name')); $cells .= wf_TableCell(__('Actions')); $rows = wf_TableRow($cells, 'row1'); foreach ($this->allTypes as $io => $each) { $cells = wf_TableCell($each['id']); $cells .= wf_TableCell($this->getTypeNameDesc($each['type'])); $cells .= wf_TableCell($each['name']); $urlDelete = self::URL_ME . '&' . self::ROUTE_DELETE . '=' . $each['id']; $urlEdit = self::URL_ME . '&' . self::ROUTE_EDIT . '=' . $each['id']; $cancelUrl = self::URL_ME; $deleteTitle = __('Delete') . ' ' . $each['name'] . '?'; $deleteAlert = $this->messages->getDeleteAlert() . '. ' . __('All related data will be deleted too'); $actionControls = wf_ConfirmDialog($urlDelete, web_delete_icon(), $deleteAlert, '', $cancelUrl, $deleteTitle) . ' '; $actionControls .= wf_JSAlert($urlEdit, web_edit_icon(), $this->messages->getEditAlert()); $cells .= wf_TableCell($actionControls); $rows .= wf_TableRow($cells, 'row5'); } $result .= wf_TableBody($rows, '100%', 0, 'sortable'); } else { $result .= $this->messages->getStyledMessage(__('Nothing to show'), 'info'); } return($result); } /** * Returns preformatted view of CF content preprocessed depends by its type * * @param string $fieldType Type of the data (VARCHAR, TRIGGER, TEXT etc) * @param string $data Data of CF * @param int $typeId CF type ID * * @return string */ protected function renderField($fieldType, $data, $typeId = 0) { if ($fieldType == 'TRIGGER') { $data = ($data) ? wf_img_sized('skins/icon_active.gif', '', '12') : wf_img_sized('skins/icon_inactive.gif', '', '12'); } if ($fieldType == 'TEXT') { $data = nl2br($data); } if ($fieldType == 'URL') { $data = wf_Link($data, $data, false, '', 'target="_BLANK"'); } if ($fieldType == 'COLOR') { if (!empty($data)) { $data = wf_tag('color', false, '', 'style="color:' . $data . '"') . $data . wf_tag('font', true); } } if ($fieldType == 'PHOTO') { if (!empty($typeId) AND ! empty($this->login)) { if ($this->altCfg['PHOTOSTORAGE_ENABLED']) { $photostorage = new PhotoStorage(self::PHOTOSTORAGE_SCOPE, $this->login . self::PHOTOSTORAGE_ITEMID_DELIMITER . $typeId); $data = $photostorage->renderImagesRaw(); } } } if ($fieldType == 'FILE') { if (!empty($typeId) AND ! empty($this->login)) { if ($this->altCfg['FILESTORAGE_ENABLED']) { $fileStorage = new FileStorage(self::FILESTORAGE_SCOPE, $this->login . self::FILESTORAGE_ITEMID_DELIMITER . $typeId); $data = $fileStorage->renderFilesPreview(false, '', '', 64); } } } return ($data); } /** * Returns user custom field content depends on its type * * @param int $typeId * * @return string */ protected function getUserFieldContent($typeId) { $result = ''; if (isset($this->userFieldsData[$typeId])) { $result .= $this->userFieldsData[$typeId]['content']; } return($result); } /** * Returns available user custom fields for user profile * * @result */ public function renderUserFields() { $result = ''; if (!empty($this->login)) { if (!empty($this->allTypes)) { $rows = ''; foreach ($this->allTypes as $io => $eachType) { $cells = wf_TableCell($this->renderTypeName($eachType['id']), '30%', 'row2', 'valign="top"'); $cells .= wf_TableCell($this->renderField($eachType['type'], $this->getUserFieldContent($eachType['id']), $eachType['id']), '', 'row3', 'valign="top"'); $rows .= wf_TableRow($cells); } $result = wf_TableBody($rows, '100%', 0, '', UserProfile::MAIN_TABLE_STYLE); } } return($result); } /** * Sets content of custom field for current instance user * * @param string $login * @param int $typeId * @param string $content * @throws Exception * * @return void */ protected function setFieldContent($login, $typeId, $content) { $typeId = ubRouting::filters($typeId, 'int'); $contentF = ubRouting::filters($content, 'mres'); if (!empty($login)) { if (isset($this->allTypes[$typeId])) { $this->itemsDb->data('typeid', $typeId); $this->itemsDb->data('login', $login); $this->itemsDb->data('content', $contentF); //update or create field content if (isset($this->userFieldsData[$typeId])) { $currentFieldId = $this->userFieldsData[$typeId]['id']; $this->itemsDb->where('id', '=', $currentFieldId); $this->itemsDb->save(); } else { $this->itemsDb->create(); } $logContent = (strlen($content) < 20) ? $content : substr($content, 0, 20) . '..'; log_register('CF SET (' . $login . ') TYPE [' . $typeId . ']' . ' ON `' . $logContent . '`'); } else { throw new Exception('EX_TYPEID_NOT_EXISTS'); } } else { throw new Exception('EX_LOGIN_EMPTY'); } } /** * Returns existing type name, may be cleaned from technical data * * @param int $typeId * * @return string */ public function renderTypeName($typeId) { $result = ''; if (isset($this->allTypes[$typeId])) { $typeData = $this->allTypes[$typeId]; $typeName = $typeData['name']; //some optional postprocessing if ($typeData['type'] == 'LIST') { if (ispos($typeName, '[') AND ispos($typeName, ']')) { $rawList = zb_ParseTagData('[', ']', $typeName); $typeName = str_replace('[' . $rawList . ']', '', $typeName); } } $result = $typeName; } else { $result .= '[' . $typeId . '] ' . __('Not exists'); } return($result); } /** * Renders CF editor controller * * @return void */ public function renderUserFieldEditor() { global $billing; $result = ''; //editing subroutine if (ubRouting::checkPost(self::PROUTE_MODTYPE)) { $this->setFieldContent(ubRouting::post(self::PROUTE_MODLOGIN), ubRouting::post(self::PROUTE_MODTYPE), ubRouting::post(self::PROUTE_MODCONTENT)); //is user reset required after field change? if ($this->altCfg['RESETONCFCHANGE']) { $billing->resetuser($this->login); log_register('RESET User (' . $this->login . ')'); } ubRouting::nav(self::URL_EDIT_BACK . $this->login); } if (!empty($this->allTypes)) { $cells = wf_TableCell(__('Field name')); $cells .= wf_TableCell(__('Current value')); $cells .= wf_TableCell(__('Edit')); $rows = wf_TableRow($cells, 'row1'); foreach ($this->allTypes as $io => $eachType) { $cells = wf_TableCell($this->renderTypeName($eachType['id']), '', '', 'valign="top"'); $cells .= wf_TableCell($this->renderField($eachType['type'], $this->getUserFieldContent($eachType['id']), $eachType['id']), '', '', 'valign="top"'); $cells .= wf_TableCell($this->renderTypeController($this->login, $eachType['type'], $eachType['id']), '', '', 'valign="top"'); $rows .= wf_TableRow($cells, 'row3'); } $result .= wf_TableBody($rows, '100%', 0, '', UserProfile::MAIN_TABLE_STYLE); } return($result); } /** * Returns editing controller for CF assigned to user * * @param string $login Existing user login * @param string $type Type of CF to return control * @param int $typeId Type ID for change * * @return string */ protected function renderTypeController($login, $type, $typeId) { $result = ''; $type = ubRouting::filters($type, 'vf'); $typeId = ubRouting::filters($typeId, 'int'); $currentFieldContent = ''; if (isset($this->userFieldsData[$typeId])) { $currentFieldContent = $this->userFieldsData[$typeId]['content']; } //basic forms inputs $inputs = wf_HiddenInput(self::PROUTE_MODTYPE, $typeId); $inputs .= wf_HiddenInput(self::PROUTE_MODLOGIN, $login); if ($type == 'VARCHAR') { $inputs .= wf_TextInput(self::PROUTE_MODCONTENT, '', $currentFieldContent, false, 20); $inputs .= wf_Submit(__('Save')); $result = wf_Form("", 'POST', $inputs, ''); } if ($type == 'TRIGGER') { $triggerOpts = array(1 => __('Yes'), 0 => __('No')); $inputs .= wf_Selector(self::PROUTE_MODCONTENT, $triggerOpts, '', $currentFieldContent, false); $inputs .= wf_Submit(__('Save')); $result = wf_Form("", 'POST', $inputs, ''); } if ($type == 'TEXT') { $inputs .= wf_TextArea(self::PROUTE_MODCONTENT, '', $currentFieldContent, true, '45x5'); $inputs .= wf_Submit(__('Save')); $result = wf_Form("", 'POST', $inputs, ''); } if ($type == 'INT') { $inputs .= wf_TextInput(self::PROUTE_MODCONTENT, '', $currentFieldContent, false, 10, 'digits'); $inputs .= wf_Submit(__('Save')); $result = wf_Form("", 'POST', $inputs, ''); } if ($type == 'FLOAT') { $inputs .= wf_TextInput(self::PROUTE_MODCONTENT, '', $currentFieldContent, false, 10, 'float'); $inputs .= wf_Submit(__('Save')); $result = wf_Form("", 'POST', $inputs, ''); } if ($type == 'FINANCE') { $inputs .= wf_TextInput(self::PROUTE_MODCONTENT, '', $currentFieldContent, false, 10, 'float'); $inputs .= wf_Submit(__('Save')); $result = wf_Form("", 'POST', $inputs, ''); } if ($type == 'NETWORK') { $inputs .= wf_TextInput(self::PROUTE_MODCONTENT, '', $currentFieldContent, false, 10, 'net-cidr'); $inputs .= wf_Submit(__('Save')); $result = wf_Form("", 'POST', $inputs, ''); } if ($type == 'URL') { $inputs .= wf_TextInput(self::PROUTE_MODCONTENT, '', $currentFieldContent, false, 20, 'url'); $inputs .= wf_Submit(__('Save')); $result = wf_Form("", 'POST', $inputs, ''); } if ($type == 'DATE') { $inputs .= wf_DatePickerPreset(self::PROUTE_MODCONTENT, $currentFieldContent, true) . ' '; $inputs .= wf_Submit(__('Save')); $result = wf_Form("", 'POST', $inputs, ''); } if ($type == 'TIME') { $inputs .= wf_TimePickerPreset(self::PROUTE_MODCONTENT, $currentFieldContent, '', false) . ' '; $inputs .= wf_Submit(__('Save')); $result = wf_Form("", 'POST', $inputs, ''); } if ($type == 'COLOR') { $inputs .= wf_ColPicker(self::PROUTE_MODCONTENT, '', $currentFieldContent, false, 10); $inputs .= wf_Submit(__('Save')); $result = wf_Form("", 'POST', $inputs, ''); } if ($type == 'LIST') { if (isset($this->allTypes[$typeId])) { $typeName = $this->allTypes[$typeId]['name']; if (ispos($typeName, '[') AND ispos($typeName, ']')) { $rawList = zb_ParseTagData('[', ']', $typeName); if (!empty($rawList)) { $selectorOpts = array(); $rawList = explode(',', $rawList); if (!empty($rawList)) { $selectorOpts[''] = '-'; foreach ($rawList as $io => $each) { $cleanOpt = trim($each); $selectorOpts[$cleanOpt] = $cleanOpt; } } $inputs .= wf_Selector(self::PROUTE_MODCONTENT, $selectorOpts, '', $currentFieldContent, false); $inputs .= wf_Submit(__('Save')); $result = wf_Form("", 'POST', $inputs, ''); } else { $result .= __('Wrong element format') . ': ' . __('is empty'); } } else { $result .= __('Wrong element format') . ': ' . __('No tags'); } } } if ($type == 'PHOTO') { if ($this->altCfg['PHOTOSTORAGE_ENABLED']) { $uploadUrl = self::URL_PHOTOUPL . $login . self::PHOTOSTORAGE_ITEMID_DELIMITER . $typeId; $result = wf_Link($uploadUrl, wf_img('skins/photostorage.png', __('Upload images')) . ' ' . __('Upload images')); } else { $result = __('Disabled'); } } if ($type == 'FILE') { if ($this->altCfg['FILESTORAGE_ENABLED']) { $fileStorageItemId = $login . self::FILESTORAGE_ITEMID_DELIMITER . $typeId; $uploadUrl = self::URL_FILEUPL . $fileStorageItemId; $result = wf_Link($uploadUrl, wf_img('skins/photostorage_upload.png') . ' ' . __('Upload files'), false); } else { $result = __('Disabled'); } } return ($result); } /** * Returns search controller for CFs assigned to user * * @param string $type Type of CF to return control * @param int $typeid Type ID for change * * @return string */ function getTypeSearchControl($type, $typeid) { $type = ubRouting::filters($type, 'vf'); $typeid = ubRouting::filters($typeid, 'int'); $result = ''; $inputs = ''; $ignoredTypes = array('PHOTO', 'FILE', 'COLOR'); //I`m too lazy to do it today $ignoredTypes = array_flip($ignoredTypes); if (!isset($ignoredTypes[$type])) { if ($type == 'VARCHAR') { $inputs = wf_HiddenInput(self::PROUTE_SEARCHTYPEID, $typeid); $inputs .= wf_TextInput(self::PROUTE_SEARCHQUERY, '', '', false, 20); } if ($type == 'TRIGGER') { $triggerOpts = array(1 => __('Yes'), 0 => __('No')); $inputs = wf_HiddenInput(self::PROUTE_SEARCHTYPEID, $typeid); $inputs .= wf_Selector(self::PROUTE_SEARCHQUERY, $triggerOpts, '', '', false); } if ($type == 'TEXT') { $inputs = wf_HiddenInput(self::PROUTE_SEARCHTYPEID, $typeid); $inputs .= wf_TextInput(self::PROUTE_SEARCHQUERY, '', '', false, 20); } if ($type == 'INT') { $inputs = wf_HiddenInput(self::PROUTE_SEARCHTYPEID, $typeid); $inputs .= wf_TextInput(self::PROUTE_SEARCHQUERY, '', '', false, 10, 'digits'); } if ($type == 'FLOAT') { $inputs = wf_HiddenInput(self::PROUTE_SEARCHTYPEID, $typeid); $inputs .= wf_TextInput(self::PROUTE_SEARCHQUERY, '', '', false, 10, 'float'); } if ($type == 'FINANCE') { $inputs = wf_HiddenInput(self::PROUTE_SEARCHTYPEID, $typeid); $inputs .= wf_TextInput(self::PROUTE_SEARCHQUERY, '', '', false, 10, 'finance'); } if ($type == 'NETWORK') { $inputs = wf_HiddenInput(self::PROUTE_SEARCHTYPEID, $typeid); $inputs .= wf_TextInput(self::PROUTE_SEARCHQUERY, '', '', false, 10, 'net-cidr'); } if ($type == 'URL') { $inputs = wf_HiddenInput(self::PROUTE_SEARCHTYPEID, $typeid); $inputs .= wf_TextInput(self::PROUTE_SEARCHQUERY, '', '', false, 20, 'url'); } if ($type == 'DATE') { $inputs = wf_HiddenInput(self::PROUTE_SEARCHTYPEID, $typeid) . ' '; $inputs .= wf_DatePicker(self::PROUTE_SEARCHQUERY, true); } if ($type == 'TIME') { $inputs = wf_HiddenInput(self::PROUTE_SEARCHTYPEID, $typeid); $inputs .= wf_TimePickerPreset(self::PROUTE_SEARCHQUERY, '', '', false) . ' '; } if ($type == 'LIST') { $inputs = wf_HiddenInput(self::PROUTE_SEARCHTYPEID, $typeid); if (isset($this->allTypes[$typeid])) { $typeName = $this->allTypes[$typeid]['name']; if (ispos($typeName, '[') AND ispos($typeName, ']')) { $rawList = zb_ParseTagData('[', ']', $typeName); if (!empty($rawList)) { $selectorOpts = array(); $rawList = explode(',', $rawList); if (!empty($rawList)) { $selectorOpts[''] = '-'; foreach ($rawList as $io => $each) { $cleanOpt = trim($each); $selectorOpts[$cleanOpt] = $cleanOpt; } $inputs .= wf_Selector(self::PROUTE_SEARCHQUERY, $selectorOpts, '', '', false); } } } } } } if (!empty($inputs)) { $inputs .= wf_Submit(__('Search')); //appending search button to each $result = wf_Form("", 'POST', $inputs, ''); } return ($result); } } |