_options = $options; } function exec(&$Doc) { $this->Doc = &$Doc; $this->DBObj = SiteMap::getObj('FeaturedProperty/FeaturedProperty.php', @$_REQUEST['id']); $this->DBObj->setFilter(array('active' => 'y')); if (isset($_REQUEST['id']) && intval($_REQUEST['id'])) { $this->doClick(); } else { $this->doList(); } } function doList() { $properties = $this->DBObj->getList4Grid(); $properties = $properties['list']; $keys = array_keys($properties); sort($keys); $tmp = array(); while (!empty($keys)) { $i = rand(0, count($keys) - 1); $tmp[$properties[$keys[$i]]['id']] = $properties[$keys[$i]]; $tmp[$properties[$keys[$i]]['id']]['photo_full'] = image_db($tmp[$properties[$keys[$i]]['id']]['photo'], $this->DBObj->photoWidth); unset($keys[$i]); sort($keys); } $properties = $tmp; $propNum = count($properties); unset($tmp); if ($propNum > 0 && $propNum <= $this->_frameSize) { $i = 0; $idPrefix = '_'; $keys = array_keys($properties); do { if ($i >= count($keys)) { $i = 0; } $property = $properties[$keys[$i]]; $property['id'] .= $idPrefix; $properties[$property['id']] = $property; $propNum++; $i++; $idPrefix .= '_'; } while ($propNum <= $this->_frameSize); } $item = array( 'tpl' => 'FeaturedProperty/show.tpl', 'list' => $properties, 'json' => json_encode($properties), 'frameSize' => $this->_frameSize, ); $this->Doc->addItemProp('CSSs', 'css/featuredProperties.css'); $this->Doc->addItemProp('JSs', 'js/featuredProperty_functions.js'); $this->Doc->assign(_featuredProperties, $item); } function doClick() { $this->DBObj->initFromDB(); $url = $this->DBObj->getData('url'); if (empty($url)) { $this->Doc->addContent(array('tpl'=>'msg_error.tpl', 'text'=>'Invalid request')); return; } $this->DBObj->click(); require_once('class/HTTP.php'); skHTTP::redirect($url); } }