当前位置: 首页>>代码示例>>PHP>>正文


PHP func::array_transparent方法代码示例

本文整理汇总了PHP中func::array_transparent方法的典型用法代码示例。如果您正苦于以下问题:PHP func::array_transparent方法的具体用法?PHP func::array_transparent怎么用?PHP func::array_transparent使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在func的用法示例。


在下文中一共展示了func::array_transparent方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: getBBSCategories

 function getBBSCategories($aSelectedID = array(), $bOptions = false)
 {
     if (!is_array($aSelectedID)) {
         $aSelectedID = array($aSelectedID);
     }
     bff::i()->GetModule('bbs');
     $aCats = $this->db->select('SELECT id, title, 0 as disabled FROM ' . TABLE_BBS_CATEGORIES . ' WHERE numlevel=1 ORDER BY numleft');
     if ($bOptions) {
         $sOptions = '';
         array_unshift($aCats, array('id' => 0, 'title' => 'любой', 'disabled' => 0), array('id' => -2, 'title' => '------------------------', 'disabled' => 1), array('id' => 1, 'title' => 'Все разделы сайта', 'disabled' => 0));
         foreach ($aCats as $v) {
             $sOptions .= '<option value="' . $v['id'] . '" class="' . ($v['id'] == 0 || $v['id'] == 1 ? 'bold' : '') . '" ' . ($v['id'] == -2 ? 'disabled' : '') . ' ' . (in_array($v['id'], $aSelectedID) ? ' selected="selected"' : '') . '>' . $v['title'] . '</option>';
         }
     } else {
         array_unshift($aCats, array('id' => 1, 'title' => 'Все разделы сайта'));
         $sCheckbox = '';
         foreach ($aCats as $v) {
             $sCheckbox .= '<label><input type="checkbox" name="cat[]" class="catcheck ' . ($v['id'] == 1 ? 'all bold' : 'cat') . '" value="' . $v['id'] . '"' . (in_array($v['id'], $aSelectedID) ? ' checked="checked"' : '') . '/> ' . $v['title'] . '</label><br/>';
         }
     }
     $aCats = func::array_transparent($aCats, 'id', true);
     return array('cats' => $aCats, 'options' => !empty($sOptions) ? $sOptions : '', 'checks' => !empty($sCheckbox) ? $sCheckbox : '');
 }
开发者ID:Sywooch,项目名称:dobox,代码行数:23,代码来源:banners.bl.class.php

示例2: edit

 function edit()
 {
     if (bff::$isAjax) {
         $this->input->postm(array('id' => TYPE_UINT, 'reg' => TYPE_ARRAY_UINT, 'contacts' => TYPE_ARRAY_NOHTML, 'descr' => TYPE_NOTAGS, 'info' => TYPE_NOTAGS, 'img' => TYPE_ARRAY_NOHTML, 'imgfav' => TYPE_NOHTML, 'imo' => TYPE_NOHTML, 'price' => TYPE_NUM, 'price_torg' => TYPE_BOOL, 'price_bart' => TYPE_BOOL, 'video' => TYPE_NOHTML, 'period' => TYPE_UINT), $p);
         $sqlCheck = ' WHERE id = ' . $p['id'];
         if ($this->security->isMember()) {
             $sqlCheck .= ' AND user_id = ' . $this->security->getUserID();
         } else {
             if (!$this->isEditPassGranted($p['id'])) {
                 $this->ajaxResponse(Errors::ACCESSDENIED);
             }
         }
         $aData = $this->db->one_array('SELECT id, status, cat1_id, cat2_id, cat_id, cat_type, descr FROM ' . TABLE_BBS_ITEMS . $sqlCheck);
         if (empty($aData)) {
             $this->ajaxResponse(Errors::ACCESSDENIED);
         }
         $this->input->clean_array($p['reg'], array(1 => TYPE_UINT, 2 => TYPE_UINT, 3 => TYPE_UINT));
         $aDynpropsData = $this->input->post('dp', TYPE_ARRAY);
         if (!empty($aDynpropsData)) {
             $dp = $this->initDynprops();
             $aDynpropsData = $dp->prepareSaveDataByID($aDynpropsData, $dp->getByID(array_keys($aDynpropsData)), 'update');
         }
         $sRegionsTitle = '';
         if (!empty($p['reg'])) {
             $aRegions = $this->db->select('SELECT title, numlevel FROM ' . TABLE_BBS_REGIONS . ' WHERE id IN(' . join(',', $p['reg']) . ') ORDER BY numlevel');
             if (!empty($aRegions)) {
                 $aRegions = func::array_transparent($aRegions, 'numlevel', true);
                 $nRegionStart = 1;
                 if (sizeof($aRegions) == 1) {
                     $sRegionsTitle = $aRegions[$nRegionStart]['title'];
                 } else {
                     if (sizeof($aRegions) == 3) {
                         $nRegionStart = 2;
                     }
                     $sRegionsTitle = $aRegions[$nRegionStart]['title'] . ($aRegions[$nRegionStart + 1] ? ', ' . $aRegions[$nRegionStart + 1]['title'] : '');
                 }
             }
         }
         if ($this->errors->no()) {
             $p['contacts']['site'] = str_replace(array('http://', 'https://', 'ftp://'), '', $p['contacts']['site']);
             if (empty($p['contacts']['site'])) {
                 $p['contacts']['site'] = '';
             }
             $adtxtLimit = config::get('bbs_adtxt_limit');
             if (!empty($adtxtLimit)) {
                 $p['descr'] = mb_substr($p['descr'], 0, $adtxtLimit);
             }
             $p['descr'] = func::cleanComment($p['descr']);
             $p['info'] = func::cleanComment($p['info']);
             $sqlNOW = $this->db->getNOW();
             $sqlStatus = '';
             $isModified = $p['imo'] != md5('(*&^%$+_)578' . join(',', $p['img'])) || $aData['descr'] != $p['descr'];
             if ($isModified) {
                 $sqlStatus = ', moderated = 0';
             }
             $res = $this->db->execute('UPDATE ' . TABLE_BBS_ITEMS . ' SET
                 country_id = ' . $p['reg'][1] . ', region_id = ' . $p['reg'][2] . ', city_id = ' . $p['reg'][3] . ',  
                 img = :img, imgcnt = ' . sizeof($p['img']) . ', imgfav = :imgfav, 
                 price = ' . $p['price'] . ', price_torg = ' . $p['price_torg'] . ', price_bart = ' . $p['price_bart'] . ',   
                 contacts_name = :c_name, contacts_email = :c_email, contacts_phone = :c_phone, contacts_skype = :c_skype, contacts_site = :c_site, video = :video, 
                 descr = :descr, descr_regions = :descr_regions, info = :info, mkeywords = :mkeywords, mdescription = :mdescription, modified = ' . $sqlNOW . '
                 ' . (!empty($aDynpropsData) ? $aDynpropsData : '') . $sqlStatus . '
                 WHERE id = ' . $p['id'] . '              
             ', array(array(':img', join(',', $p['img']), PDO::PARAM_STR), array(':imgfav', $p['imgfav'], PDO::PARAM_STR), array(':c_name', isset($p['contacts']['name']) ? $p['contacts']['name'] : '', PDO::PARAM_STR), array(':c_email', isset($p['contacts']['email']) ? $p['contacts']['email'] : '', PDO::PARAM_STR), array(':c_phone', isset($p['contacts']['phone']) ? $p['contacts']['phone'] : '', PDO::PARAM_STR), array(':c_skype', isset($p['contacts']['skype']) ? $p['contacts']['skype'] : '', PDO::PARAM_STR), array(':c_site', isset($p['contacts']['site']) ? $p['contacts']['site'] : '', PDO::PARAM_STR), array(':video', $p['video'], PDO::PARAM_STR), array(':descr', $p['descr'], PDO::PARAM_STR), array(':descr_regions', $sRegionsTitle, PDO::PARAM_STR), array(':info', $p['info'], PDO::PARAM_STR), array(':mkeywords', $p['descr'], PDO::PARAM_STR), array(':mdescription', $p['descr'], PDO::PARAM_STR)));
             $success = $res === 1;
             $this->ajaxResponse(array('res' => $success));
         }
         $this->ajaxResponse(null);
     }
     $nItemID = $this->input->id('id');
     if (!$nItemID) {
         func::JSRedirect('/');
     }
     $nUserID = $this->security->getUserID();
     $dp = $this->initDynprops();
     $aData = $this->db->one_array('SELECT I.id, ' . $this->security->decodeBBSEditPass('I.pass') . ', I.user_id, I.status, I.moderated,
                           I.cat_id, C.regions as cat_regions, C.prices as cat_prices, C.prices_sett as cat_prices_sett,
                           I.country_id, I.region_id, I.city_id,
                           I.img, I.imgfav, I.imgcnt, I.descr, I.info, I.price, I.price_torg, I.price_bart, I.video,
                           I.contacts_name, I.contacts_email, I.contacts_phone, I.contacts_skype, I.contacts_site
                           , I.f' . join(', I.f', range($dp->datafield_int_first, $dp->datafield_text_last)) . '
                           FROM ' . TABLE_BBS_ITEMS . ' I, ' . TABLE_BBS_CATEGORIES . ' C
                           WHERE I.id = ' . $nItemID . ' AND I.cat_id = C.id
                           ');
     if (empty($aData)) {
         func::JSRedirect('/');
     }
     if ($aData['user_id'] == 0) {
         //доступ только по паролю
         if (!$this->isEditPassGranted($nItemID)) {
             $aData = array('item_id' => $nItemID, 'user_id' => $nUserID);
             return $this->tplFetchPHP($aData, 'item.edit.pass.php');
         }
     } else {
         if ($aData['user_id'] != $nUserID) {
             //не является владельцем объявления
             return $this->showForbidden('Вы не являетесь владельцем данного объявления.');
         }
     }
     if ($aData['status'] == BBS_STATUS_BLOCKED && $aData['moderated'] == 0) {
//.........这里部分代码省略.........
开发者ID:Sywooch,项目名称:dobox,代码行数:101,代码来源:bbs.class.php

示例3: cities_listing

 function cities_listing($nOnlyMain = 0)
 {
     if (!$this->haveAccessTo('cities')) {
         return $this->showAccessDenied();
     }
     if (bff::$isAjax) {
         //$cache = Cache::singleton();
         switch (func::GET('act')) {
             case 'toggle-enabled':
                 if (!($nRecordID = $this->input->id())) {
                     $this->ajaxResponse(Errors::UNKNOWNRECORD);
                 }
                 $res = $this->db->execute('UPDATE ' . TABLE_CITY . ' SET enabled=(1-enabled) WHERE city_id=' . $nRecordID);
                 if ($res) {
                     //$cache->delete('geo-сities-all');
                     //$cache->delete('geo-сities-main');
                 }
                 $this->ajaxResponse($res ? Errors::SUCCESS : Errors::IMPOSSIBLE);
                 break;
             case 'toggle-main':
                 if (!($nRecordID = $this->input->id())) {
                     $this->ajaxResponse(Errors::UNKNOWNRECORD);
                 }
                 $res = $this->db->execute('UPDATE ' . TABLE_CITY . ' SET main=(1-main) WHERE city_id=' . $nRecordID);
                 if ($res) {
                     //$cache->delete('geo-сities-main');
                 }
                 $this->ajaxResponse($res ? Errors::SUCCESS : Errors::IMPOSSIBLE);
                 break;
             case 'main-add':
                 if (!($nRecordID = $this->input->id('city', 'p'))) {
                     $this->ajaxResponse(Errors::UNKNOWNRECORD);
                 }
                 $res = $this->db->execute('UPDATE ' . TABLE_CITY . ' SET main=1 WHERE city_id=' . $nRecordID);
                 if ($res) {
                     //$cache->delete('geo-сities-main');
                 }
                 $this->ajaxResponse($res ? Errors::SUCCESS : Errors::IMPOSSIBLE);
                 break;
             case 'rotate':
                 $f = func::GET('f');
                 $f = $f == 'num' ? 'num' : 'numreg';
                 $res = $this->db->rotateTablednd(TABLE_CITY, '', 'city_id', $f);
                 if ($res) {
                     //$cache->delete('geo-сities-all');
                     //$cache->delete('geo-сities-main');
                     $this->ajaxResponse(Errors::SUCCESS);
                 } else {
                     $this->ajaxResponse(Errors::IMPOSSIBLE);
                 }
                 break;
             case 'notmain-list':
                 $sQ = func::POST('q', true);
                 //получаем список подходящих по названию городов, исключая
                 //- основные города
                 $aResult = $this->db->select('SELECT C.city_id as id, C.title FROM ' . TABLE_CITY . ' C 
                               WHERE C.main=0 AND C.title LIKE (' . $this->db->str2sql($sQ . '%') . ')
                               ORDER BY C.title');
                 $aCities = array();
                 foreach ($aResult as $c) {
                     $aCities[$c['id']] = $c['title'];
                 }
                 unset($aResult);
                 $this->ajaxResponse($aCities);
                 break;
         }
         $this->ajaxResponse(Errors::IMPOSSIBLE);
     }
     $aData = array('main' => $nOnlyMain, 'users' => func::GET('users'), 'region' => func::GET('region', false, true));
     $aData['rotate'] = ($aData['main'] || $aData['region']) && !($aData['main'] && $aData['region']) && !$aData['users'] ? 1 : 0;
     $aData['rotate_field'] = $aData['rotate'] ? $aData['main'] ? 'num' : 'numreg' : 'title';
     $aData['cities'] = $this->db->select('SELECT C.*, C.city_id as id, COUNT(U.user_id) as users 
         FROM ' . TABLE_CITY . ' C
             LEFT JOIN ' . TABLE_USERS . ' U ON U.city_id=C.city_id
         WHERE 1=1 ' . ($aData['region'] ? ' AND C.region_id = ' . $aData['region'] . ' ' : '') . ' 
                   ' . ($aData['main'] ? ' AND C.main = 1 ' : '') . '
         GROUP BY C.city_id
        ' . ($aData['users'] ? ' HAVING users > 0 ' : '') . '
         ORDER BY C.' . $aData['rotate_field']);
     $aData['regions_options'] = $this->geoOblastOptions($aData['region'], $aRegions);
     $aData['regions'] = func::array_transparent($aRegions, 'region_id', true);
     $this->tplAssignByRef('aData', $aData);
     $this->includeJS(array('tablednd', 'autocomplete'));
     return $this->tplFetch('admin.cities.listing.tpl');
 }
开发者ID:Sywooch,项目名称:dobox,代码行数:85,代码来源:sites.adm.class.php

示例4: items_edit

 function items_edit()
 {
     if (!$this->haveAccessTo('items-edit')) {
         return $this->showAccessDenied();
     }
     if (bff::$isAjax) {
         $this->input->postm(array('id' => TYPE_UINT, 'reg' => TYPE_ARRAY_UINT, 'contacts' => TYPE_ARRAY_STR, 'descr' => TYPE_STR, 'info' => TYPE_STR, 'price' => TYPE_NUM, 'price_torg' => TYPE_BOOL, 'price_bart' => TYPE_BOOL, 'video' => TYPE_STR, 'mkeywords' => TYPE_STR, 'mdescription' => TYPE_STR), $p);
         $this->input->clean_array($p['reg'], array(1 => TYPE_UINT, 2 => TYPE_UINT, 3 => TYPE_UINT));
         $aDynpropsData = $this->input->post('dp', TYPE_ARRAY);
         if (!empty($aDynpropsData)) {
             $dp = $this->initDynprops();
             $aDynpropsData = $dp->prepareSaveDataByID($aDynpropsData, $dp->getByID(array_keys($aDynpropsData)), 'update');
         }
         $sRegionsTitle = '';
         if (!empty($p['reg'])) {
             $aRegions = $this->db->select('SELECT title, numlevel FROM ' . TABLE_BBS_REGIONS . ' WHERE id IN(' . join(',', $p['reg']) . ') ORDER BY numlevel');
             if (!empty($aRegions)) {
                 $aRegions = func::array_transparent($aRegions, 'numlevel', true);
                 $nRegionStart = 1;
                 if (sizeof($aRegions) == 1) {
                     $sRegionsTitle = $aRegions[$nRegionStart]['title'];
                 } else {
                     if (sizeof($aRegions) == 3) {
                         $nRegionStart = 2;
                     }
                     $sRegionsTitle = $aRegions[$nRegionStart]['title'] . ($aRegions[$nRegionStart + 1] ? ', ' . $aRegions[$nRegionStart + 1]['title'] : '');
                 }
             }
         }
         if ($this->errors->no()) {
             if (!empty($p['contacts']['site']) && $p['contacts']['site'] == 'http://') {
                 $p['contacts']['site'] = '';
             }
             $adtxtLimit = config::get('bbs_adtxt_limit');
             if (!empty($adtxtLimit)) {
                 $p['descr'] = mb_substr($p['descr'], 0, $adtxtLimit);
             }
             $sqlNOW = $this->db->getNOW();
             $res = $this->db->execute('UPDATE ' . TABLE_BBS_ITEMS . ' SET
                 country_id = ' . $p['reg'][1] . ', region_id = ' . $p['reg'][2] . ', city_id = ' . $p['reg'][3] . ',  
                 price = ' . $p['price'] . ', price_torg = ' . $p['price_torg'] . ', price_bart = ' . $p['price_bart'] . ',   
                 contacts_name = :c_name, contacts_email = :c_email, contacts_phone = :c_phone, contacts_skype = :c_skype, contacts_site = :c_site, video = :video, 
                 descr = :descr, descr_regions = :descr_regions, info = :info, mkeywords = :mkeywords, mdescription = :mdescription, modified = ' . $sqlNOW . '
                 ' . (!empty($aDynpropsData) ? $aDynpropsData : '') . '
                 WHERE id = ' . $p['id'] . '              
             ', array(array(':c_name', isset($p['contacts']['name']) ? $p['contacts']['name'] : '', PDO::PARAM_STR), array(':c_email', isset($p['contacts']['email']) ? $p['contacts']['email'] : '', PDO::PARAM_STR), array(':c_phone', isset($p['contacts']['phone']) ? $p['contacts']['phone'] : '', PDO::PARAM_STR), array(':c_skype', isset($p['contacts']['skype']) ? $p['contacts']['skype'] : '', PDO::PARAM_STR), array(':c_site', isset($p['contacts']['site']) ? $p['contacts']['site'] : '', PDO::PARAM_STR), array(':video', $p['video'], PDO::PARAM_STR), array(':descr', $p['descr'], PDO::PARAM_STR), array(':descr_regions', $sRegionsTitle, PDO::PARAM_STR), array(':info', $p['info'], PDO::PARAM_STR), array(':mkeywords', $p['mkeywords'], PDO::PARAM_STR), array(':mdescription', $p['mdescription'], PDO::PARAM_STR)));
             $this->ajaxResponse(array('res' => $res === 1));
         }
         $this->ajaxResponse(null);
     }
     $sFilter = $this->input->get('f', TYPE_STR);
     // listing filter
     $sRedirect = 'items_listing&' . $sFilter;
     $sFilter = rawurlencode($sFilter);
     $nRecordID = $this->input->id();
     if (!$nRecordID) {
         $this->adminRedirect(Errors::IMPOSSIBLE, $sRedirect);
     }
     $dp = $this->initDynprops();
     $aData = $this->db->one_array('SELECT I.*, C.regions as cat_regions, C.prices as cat_prices, C.prices_sett as cat_prices_sett,
                             CT.title as cat_type_title
                           FROM ' . TABLE_BBS_ITEMS . ' I
                             LEFT JOIN ' . TABLE_BBS_CATEGORIES_TYPES . ' CT ON I.cat_type = CT.id,
                             ' . TABLE_BBS_CATEGORIES . ' C
                           WHERE I.id = ' . $nRecordID . ' AND I.cat_id = C.id');
     if (empty($aData)) {
         $this->adminRedirect(Errors::IMPOSSIBLE, $sRedirect);
     }
     $aDynprops = $dp->form($aData['cat_id'], $aData, true, array(), 'dp', 'dynprops.form.edit.php', $this->module_dir_tpl);
     $aData['dp'] = !empty($aDynprops['form']) ? $aDynprops['form'] : 0;
     unset($aDynprops);
     $aData['regions'] = $this->db->select('SELECT R.id, R.pid, R.title
                                    FROM ' . TABLE_BBS_REGIONS . ' R, ' . TABLE_BBS_REGIONS . ' R2
                                    WHERE R.numlevel IN(1,2) AND R.enabled = 1 AND (R.pid = 0 OR (R.pid = R2.id AND R2.enabled = 1)) 
                                    ORDER BY R.main DESC, R.num, R.title');
     $aData['regions'] = $this->db->transformRowsToTree($aData['regions'], 'id', 'pid', 'sub');
     if ($aData['country_id'] && $aData['region_id'] && $aData['city_id']) {
         $aData['cities'] = $this->db->select('SELECT R.id, R.title
                                    FROM ' . TABLE_BBS_REGIONS . ' R 
                                    WHERE R.pid = ' . $aData['region_id'] . ' AND R.enabled = 1 
                                    ORDER BY R.main DESC, R.num, R.title');
     }
     if ($this->items_images) {
         $aData['img'] = !empty($aData['img']) ? explode(',', $aData['img']) : array();
         $this->items_images_limit = config::get('bbs_images_limit' . ($aData['user_id'] > 0 ? '_reg' : ''));
     }
     $aData['cats_path'] = '';
     $aParentsID = $this->tree_getNodeParentsID($aData['cat_id']);
     $aParentsID[] = $aData['cat_id'];
     if (!empty($aParentsID)) {
         $sQuery = 'SELECT C.title
                    FROM ' . TABLE_BBS_CATEGORIES . ' C
                    WHERE ' . $this->db->prepareIN('C.id', $aParentsID) . '
                    ORDER BY C.numleft';
         $aData['cats_path'] = join('&nbsp;&nbsp;<img src="/img/arrowRightSmall.png" />&nbsp;&nbsp;', $this->db->select_one_column($sQuery));
     }
     $aData['f'] =& $sFilter;
     $this->includeJS(array('bbs.txt', 'admin.bbs.edit'), false, false);
     $this->includeJS(array('swfupload/swfupload'));
     return $this->tplFetchPHP($aData, 'admin.items.edit.php');
//.........这里部分代码省略.........
开发者ID:Sywooch,项目名称:dobox,代码行数:101,代码来源:bbs.adm.class.php

示例5: prepareSaveDataByOwner

 /**
  * Подготовка запроса сохранения значений свойств по ID владельцев
  * @param mixed id владельца
  * @param array значения свойств: array(id владельца=>значения, ...)
  * @param array параметры свойств: без группировки по id владельца
  * @param string тип запроса: 'insert', 'update'
  * @return array @see prepareSaveDataByOwner
  */
 public function prepareSaveDataByOwner($mOwnerID, $aDynpropsData, $aDynprops, $sQueryType = 'insert')
 {
     if (!empty($mOwnerID) && !empty($aDynpropsData) && !empty($aDynprops)) {
         if (!is_array($mOwnerID)) {
             $mOwnerID = array($mOwnerID);
         }
         $aDynprops = func::array_transparent($aDynprops, $this->ownerColumn);
         $aResult = array();
         foreach ($mOwnerID as $ownerID) {
             if ($ownerID > 0) {
                 $aResult[$ownerID] = $this->prepareSaveData(isset($aDynpropsData[$ownerID]) ? $aDynpropsData[$ownerID] : array(), isset($aDynprops[$ownerID]) ? $aDynprops[$ownerID] : array(), $sQueryType);
             }
         }
         return $aResult;
     }
     return array();
 }
开发者ID:Sywooch,项目名称:dobox,代码行数:25,代码来源:dynprops.php


注:本文中的func::array_transparent方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。