本文整理汇总了PHP中Model::factoryInstance方法的典型用法代码示例。如果您正苦于以下问题:PHP Model::factoryInstance方法的具体用法?PHP Model::factoryInstance怎么用?PHP Model::factoryInstance使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Model
的用法示例。
在下文中一共展示了Model::factoryInstance方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: del
function del(Criteria $c)
{
$condition = $c->getCondition("adCriterionId");
$nc = new Criteria();
$nc->addCondition($condition);
parent::del($c);
Model::factoryInstance("ad")->del($nc);
}
示例2: __construct
/**
* Generates the standard ModelRecord object
* @param array $data Row data - associated array
* @param bollean $new is new instance, not loaded from database
*/
public function __construct($data = false, $new = true)
{
parent::__construct($data);
$modelName = substr(get_class($this), 0, -6);
// "Record" length
$this->Model = Model::factoryInstance($modelName);
$this->_new = $new;
}
示例3: save
function save()
{
parent::save();
if ($this->itemId) {
Model::factoryInstance("site")->findByPk($this->itemId)->updatePhotos();
}
if (rand(1, 10) <= 1) {
Model::factoryInstance("photo")->removeExpiredTempPhotos();
}
}
示例4: save
public function save()
{
if (!empty($this->siteId)) {
$site = Model::factoryInstance("site")->findByPk($this->siteId);
if ($site) {
$site->paymentStatus = $this->status;
if ($this->status == "paid" && Config::get("automaticSiteValidation")) {
$site->status = "validated";
}
$site->save();
}
}
parent::save();
}
示例5: getControllerActionUrl
public function getControllerActionUrl($url)
{
$urlParts = @parse_url($url);
if (!empty($urlParts['query']) && !empty($urlParts['path'])) {
$filters = array_map('preg_quote', Model::factoryInstance('setting')->getCampaignFilters());
foreach ($filters as &$filter) {
$filter = str_replace('\\*', '.*', $filter);
}
$pattern = '#^(?:' . implode('|', $filters) . ')$#';
if (preg_match($pattern, $urlParts['query'])) {
$url = $urlParts['path'];
}
}
return parent::getControllerActionUrl($url);
}
示例6: getAdsOnPage
function getAdsOnPage($page)
{
$c = new Criteria();
$c->add("page", $page);
$ads = array();
foreach ($this->findAll($c, "adCriterionId, place") as $ad) {
$ads[$ad['place']] = $ad['adCriterionId'];
}
$globalSwitchOn = false;
//checking global switches
if (preg_match("#^(site|category|keyword|letter|tag)#", $page, $match) && strpos($page, "Custom") === false) {
$pagePrefix = $match[1];
$c = new Criteria();
$c->add("page", "predefine" . ucfirst($pagePrefix));
$c->add("place", "general");
$c->add("adCriterionId", 1);
if ($this->getCount($c)) {
$globalSwitchOn = true;
}
}
//checking predefine in site category
if (substr_compare("site", $page, 0, 4) == 0 && strpos($page, "Custom") === false) {
//only check ads on in category if site haven't on
if (empty($ads['general'])) {
$siteId = substr($page, 4);
$site = Model::factoryInstance("site")->findByPk($siteId, "categoryId");
$categoryPredefine = $this->isSiteAdsPredefinedInCategory($site->categoryId);
if ($categoryPredefine !== null) {
$globalSwitchOn = $categoryPredefine;
}
}
$customCategorySiteAds = $this->getCustomCategorySiteAds($site->categoryId);
if (!empty($customCategorySiteAds['general'])) {
foreach ($customCategorySiteAds as $key => $value) {
if (!isset($ads[$key])) {
$ads[$key] = $customCategorySiteAds[$key];
}
}
}
}
if (!isset($ads['general'])) {
$ads['general'] = $globalSwitchOn ? 1 : 0;
}
if (!isset($ads['predefine'])) {
$ads['predefine'] = $globalSwitchOn ? 1 : 0;
}
return $ads;
}
示例7: generateCaptchaCodesAndGetPublicOne
function generateCaptchaCodesAndGetPublicOne()
{
// generate random private code
$lettersSet = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789';
$privateCode = '';
do {
for ($i = 0; $i < 4; $i++) {
$privateCode .= substr($lettersSet, rand(0, strlen($lettersSet) - 1), 1);
}
} while (strlen($privateCode) != 4);
// generate random public code
$publicCode = '';
do {
for ($i = 0; $i < 20; $i++) {
$publicCode .= substr($lettersSet, rand(0, strlen($lettersSet) - 1), 1);
}
} while (strlen($publicCode) != 20);
$this->publicCode = $publicCode;
$this->privateCode = $privateCode;
$this->save();
Model::factoryInstance("captchaCode")->deleteExpiredCaptchaCodes();
return $publicCode;
}
示例8: __get
public function __get($name)
{
switch ($name) {
case "session":
$this->session = Session::getInstance();
break;
case "request":
$this->request = Request::getInstance();
break;
case "response":
$this->response = Response::getInstance();
break;
case "acl":
$this->acl = Acl::getInstance();
break;
case "userId":
$this->userId = $this->session->get("userId");
break;
default:
$this->{$name} = Model::factoryInstance($name);
}
return $this->{$name};
}
示例9: rebuildTable
public function rebuildTable()
{
$c = new Criteria();
$this->del($c);
$categoryModel = Model::factoryInstance($this->categoryModelName);
$categoryPrimaryKey = $categoryModel->getPrimaryKey();
$categories = $categoryModel->findAll($c, $categoryPrimaryKey . "," . $this->categoryParentKey);
$tree = new NavigationTree();
foreach ($categories as $category) {
$tree->addNode($category[$categoryPrimaryKey], $category[$this->categoryParentKey]);
}
$connections = $tree->getAllConnections();
foreach ($connections as $connection) {
$this->addNode($connection['parentCategoryId'], $connection['categoryId']);
}
}
示例10: getGoogleMap
function getGoogleMap()
{
if (!Config::get('googleMapEnabled') || empty($this->address) || empty($this->city) || empty($this->country)) {
return false;
}
$googleMap = new GoogleMap();
$googleMap->setZoomLevel(15);
$longAddress = $this->address . ', ' . $this->city . ', ' . $this->country;
$map = $googleMap->getScriptCode();
try {
try {
if (!is_null($this->lat) && !is_null($this->lng)) {
$googleMap->addGeoPoint($this->lat, $this->lng, $longAddress);
} else {
$point = $googleMap->addAddress($longAddress);
if ($point !== false) {
Model::factoryInstance('site')->updateByPk($point, $this->siteId);
}
}
} catch (Google_Map_AddressNotFoundException $e) {
try {
// No valid points for google map then search by zipCode City
$googleMap->addAddress($this->zipCode . ', ' . $this->city . ', ' . $this->country);
} catch (Google_Map_AddressNotFound_Exception $e) {
// No valid points for google map then search by country
$googleMap->addAddress($this->country);
$googleMap->setZoomLevel(12);
}
}
$map .= $googleMap->getMapCode();
return $map;
} catch (Google_Map_ServiceException $e) {
// geolocalization is temporary disabled for this IP, try user mode
$googleMap->setZoomLevel(Config::get('googleMapZoom'));
$googleMap->setZoomLevel(15);
$map .= $googleMap->getUserSideMapCode($this->address . ', ' . $this->city . ', ' . $this->country);
return $map;
} catch (Exception $e) {
return '';
}
}
示例11: changeParent
function changeParent($newParentId)
{
$c = new Criteria();
if (Model::factoryInstance("categoryParent")->isChild($this->categoryId, $newParentId)) {
return false;
}
$this->parentCategoryId = $newParentId;
return true;
}
示例12: __get
public function __get($name)
{
$this->{$name} = Model::factoryInstance($name);
return $this->{$name};
}
示例13: displayAd
public static function displayAd($params, &$tpl)
{
$place = $params['place'];
$page = Display::get("adPage");
if (empty($page)) {
return "";
}
if (!self::$adsLoaded) {
$page = Display::get("adPage");
$cache = Cacher::getInstance();
//get Ads ids on current page
if (($data = $cache->load("adsOnPage" . $page)) === null) {
$data = Model::factoryInstance("ad")->getAdsOnPage($page);
$cache->save($data, null, null, array("adCriteria", "ad"));
}
self::$adsOnPage = $data;
//load predefined settings
if (($data = $cache->load("adsPredefinitions")) === null) {
$data = Model::factoryInstance("ad")->getAllPredefinitions();
$cache->save($data, null, null, array("adCriteria", "ad"));
}
self::$predefinitions = $data;
if (preg_match("#^(site|keyword|category|letter|tag)#", $page, $match)) {
self::$predefinitionTypeName = $match[1];
}
//load ads html content
if (($data = $cache->load("adsAllCriterias")) === null) {
$data = Model::factoryInstance("adCriteria")->getArray(null, "htmlContent");
$cache->save($data, null, null, array("adCriteria"));
}
self::$adCriterias = $data;
self::$adsLoaded = true;
self::$pageIsPredefinied = !empty(self::$adsOnPage['predefine']);
}
$htmlContent = "";
if (!empty(self::$adsOnPage['general']) && !empty(self::$adsOnPage[$place])) {
$adCriterionId = self::$adsOnPage[$place];
if (!empty(self::$adCriterias[$adCriterionId])) {
$htmlContent = self::$adCriterias[$adCriterionId];
}
} else {
if (self::$pageIsPredefinied && (!isset(self::$adsOnPage['general']) || self::$adsOnPage['general'] == 1)) {
if (!empty(self::$predefinitions[self::$predefinitionTypeName][$place])) {
$adCriterionId = self::$predefinitions[self::$predefinitionTypeName][$place];
if (!empty(self::$adCriterias[$adCriterionId])) {
$htmlContent = self::$adCriterias[$adCriterionId];
}
}
}
}
return $htmlContent;
}
示例14: getGoogleDetailsOfSite
function getGoogleDetailsOfSite($url, $forcedWay = false)
{
$this->extractionWay = $forcedWay ? $forcedWay : Config::get("wayForPagerankExtraction");
if ($this->extractionWay == 2) {
$this->additionalServerUrl = Config::get("additionalServerUrl");
}
$cachedGoogleDetail = Model::factoryInstance("cacheGoogleDetail");
if (!$forcedWay && Config::get('pageRankCachingEnabled') == 1) {
// try to take the pagerank from the cache
$siteStats = $cachedGoogleDetail->getGoogleDetailsFromCache($url);
if (!empty($siteStats)) {
return $siteStats->toArray();
}
}
// if rank is not in cache
// get it and put in the cache
$results = array();
$results['pageRank'] = $this->getPageRank($url);
$results['backlinksCount'] = $this->getBacklinksCount($url);
$results['indexedPagesCount'] = $this->getIndexedPagesCount($url);
if (!$forcedWay && Config::get('pageRankCachingEnabled')) {
if (empty($siteStats)) {
$siteStats = new CacheGoogleDetailRecord();
$siteStats->url = $url;
}
$siteStats->fromArray($results);
$siteStats->save();
$c = new Criteria();
$c->add("url", $url);
foreach (Model::factoryInstance("site")->findAll($c, "siteId") as $site) {
Model::factoryInstance("site")->updateByPk(array("pageRank" => $results['pageRank']), $site['siteId']);
}
}
return $results;
}