本文整理汇总了PHP中kConf::get方法的典型用法代码示例。如果您正苦于以下问题:PHP kConf::get方法的具体用法?PHP kConf::get怎么用?PHP kConf::get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类kConf
的用法示例。
在下文中一共展示了kConf::get方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getIdByStrId
public static function getIdByStrId($strId)
{
// try to get strId to id mapping form cache
$cacheKey = 'UserRolePeer_role_str_id_' . $strId;
if (kConf::get('enable_cache') && function_exists('apc_fetch') && function_exists('apc_store')) {
$id = apc_fetch($cacheKey);
// try to fetch from cache
if ($id) {
KalturaLog::debug("UserRole str_id [{$strId}] mapped to id [{$id}] - fetched from cache");
return $id;
}
}
// not found in cache - get from database
$c = new Criteria();
$c->addSelectColumn(UserRolePeer::ID);
$c->addAnd(UserRolePeer::STR_ID, $strId, Criteria::EQUAL);
$c->setLimit(1);
$stmt = UserRolePeer::doSelectStmt($c);
$id = $stmt->fetch(PDO::FETCH_COLUMN);
if ($id) {
// store the found id in cache for later use
if (kConf::get('enable_cache') && function_exists('apc_fetch') && function_exists('apc_store')) {
$success = apc_store($cacheKey, $id, kConf::get('apc_cache_ttl'));
if ($success) {
KalturaLog::debug("UserRole str_id [{$strId}] mapped to id [{$id}] - stored in cache");
}
}
}
if (!$id) {
KalturaLog::log("UserRole with str_id [{$strId}] not found in DB!");
}
return $id;
}
示例2: testCreateEntryForThumbAsset
/**
*
* Test the KMC Checks that the starting calls return okay
* @param array<unknown_type> $params
* @param array<unknown_type> $results
* @dataProvider provideData
*/
public function testCreateEntryForThumbAsset($entryId, $result)
{
$filter = new KalturaAssetFilter();
$filter->entryIdEqual = $entryId;
$results = $this->client->thumbAsset->listAction($filter, null);
$assetUrl = $this->client->thumbAsset->getUrl($results->objects[0]->id, null);
$filePath = dirname(__FILE__) . '/testsData/new_thumb_asset.jpg';
self::saveApiFileFromUrl($assetUrl, $filePath);
$tmpFile = tempnam(dirname(__FILE__), 'imageComperingTmp');
$imageMagick = dirname(kConf::get('bin_path_imagemagick'));
if ($imageMagick == '.') {
$compare = 'compare';
} else {
$compare = dirname(kConf::get('bin_path_imagemagick')) . '/compare';
}
$result = dirname(__FILE__) . '/' . $result;
$cmd = $compare . ' ' . $filePath . ' ' . $result . ' ' . $tmpFile . ' 2>resultLog.txt';
$retValue = null;
$output = null;
$output = system($cmd, $retValue);
@unlink($tmpFile);
// delete tmp comparing file (used to copmpare the two image files)
@unlink("resultLog.txt");
// delete tmp log file that was used to retrieve compare return value
if ($retValue != 0) {
$this->fail('Files are not equal [' . $filePath . '] [' . $result . ']' . 'Compare return value was' . $retValue);
}
}
示例3: parse
private static function parse($content)
{
$items = array();
$message = '';
$doc = new DOMDocument();
if ($doc->loadXML($content)) {
$xpath = new DOMXPath($doc);
$itemNodes = $xpath->query("//item");
if (!$itemNodes->length) {
$status = "error";
} else {
foreach ($itemNodes as $itemNode) {
$ns = "http://search.yahoo.com/mrss/";
$id = self::getXmlNodeValue($itemNode, "id");
$title = self::getXmlNodeValue($itemNode, "title");
$thumbnail = "http://s.mcstatic.com/thumb/" . $id . ".jpg";
$duration = self::getXmlNodeValue($itemNode, "content", "duration", $ns);
$description = self::getXmlNodeValue($itemNode, "description", null, $ns);
$description = strip_tags($description);
$tags = self::getXmlNodeValue($itemNode, "keywords", null, $ns);
$credit = self::getXmlNodeValue($itemNode, "credit", null, $ns);
$link = self::getXmlNodeValue($itemNode, "link");
$items[] = array('id' => $id, 'title' => $title, 'thumb' => $thumbnail, 'description' => $description, 'tags' => $tags, 'license' => '', 'credit' => $credit, 'source_link' => $link, 'url' => "http://" . kConf::get("www_host") . "/index.php/extservices/metacafeRedirect/itemId/" . $id);
}
$status = "ok";
}
} else {
$status = "error";
}
return array('status' => $status, 'message' => $message, 'objects' => $items, "needMediaInfo" => self::$NEED_MEDIA_INFO);
}
示例4: execute
public function execute()
{
$widgetId = $this->getRequestParameter("wid");
$widget = widgetPeer::retrieveByPK($widgetId);
if (!$widget) {
KalturaLog::err("Widget id [{$widgetId}] not found");
die;
}
$entry = $widget->getentry();
$entryId = $widget->getEntryId();
if (!$entry) {
KalturaLog::err("Entry id [{$entryId}] not found");
die;
}
$uiConf = $widget->getuiConf();
$uiConfId = $widget->getUiConfId();
if (!$uiConf) {
KalturaLog::err("UI Conf id [{$uiConfId}] not found");
die;
}
$widgetPath = "/kwidget/wid/{$widgetId}/entry_id/{$entryId}/ui_conf/{$uiConfId}";
$this->widget = $widget;
$this->entry = $entry;
$this->uiConf = $uiConf;
$this->entryThumbUrl = $entry->getThumbnailUrl();
$this->entryThumbSecureUrl = $entry->getThumbnailUrl(null, 'https');
$this->widgetUrl = 'http://' . kConf::get('www_host') . $widgetPath;
$this->widgetSecureUrl = 'https://' . kConf::get('www_host') . $widgetPath;
}
示例5: getCache
/**
* @param int $type
* @return kBaseCacheWrapper or null on error
*/
public static function getCache($type)
{
if (array_key_exists($type, self::$caches)) {
return self::$caches[$type];
}
if (!array_key_exists($type, self::$cacheConfigs)) {
return null;
}
$config = self::$cacheConfigs[$type];
$className = "k{$config[0]}CacheWrapper";
require_once dirname(__FILE__) . '/' . $className . '.php';
$cache = new $className();
// get required kConf params
$config = array_slice($config, 1);
foreach ($config as $index => $value) {
if (is_string($value) && substr($value, 0, strlen(self::KCONF_PARAM_PREFIX)) == self::KCONF_PARAM_PREFIX) {
$value = substr($value, strlen(self::KCONF_PARAM_PREFIX));
if (!kConf::hasParam($value)) {
self::$caches[$type] = null;
return null;
}
$config[$index] = kConf::get($value);
}
}
// initialize the cache
if (call_user_func_array(array($cache, 'init'), $config) === false) {
$cache = null;
}
self::$caches[$type] = $cache;
return $cache;
}
示例6: init
protected function init()
{
if (!parent::init()) {
return false;
}
// ignore params which may hurt caching such as callback, playSessionId
if (kConf::hasParam('playmanifest_ignore_params')) {
$ignoreParams = kConf::get('playmanifest_ignore_params');
foreach ($ignoreParams as $paramName) {
unset($this->_params[$paramName]);
}
}
$this->_playbackContext = isset($this->_params['playbackContext']) ? $this->_params['playbackContext'] : null;
unset($this->_params['playbackContext']);
$this->_deliveryCode = isset($this->_params['deliveryCode']) ? $this->_params['deliveryCode'] : null;
unset($this->_params['deliveryCode']);
// take only the hostname part of the referrer parameter of baseEntry.getContextData
if (isset($this->_params['referrer'])) {
$referrer = base64_decode(str_replace(" ", "+", $this->_params['referrer']));
if (!is_string($referrer)) {
$referrer = "";
}
unset($this->_params['referrer']);
} else {
$referrer = self::getHttpReferrer();
}
$this->_referrers[] = $referrer;
$this->finalizeCacheKey();
$this->addExtraFields();
return true;
}
示例7: isRelativeTimeEnabled
public static function isRelativeTimeEnabled()
{
if (!kConf::hasParam('disable_relative_time_partners')) {
return true;
}
return !in_array(kCurrentContext::getCurrentPartnerId(), kConf::get('disable_relative_time_partners'));
}
示例8: generateFilePathArr
/**
* will return a pair of file_root and file_path
* This is the only function that should be extended for building a different path
*
* @param ISyncableFile $object
* @param int $subType
* @param $version
*/
public function generateFilePathArr(ISyncableFile $object, $subType, $version = null)
{
// $traces = debug_backtrace(false);
// foreach($traces as $i => $trace)
// {
// $file = $trace['file'];
// $line = $trace['line'];
// $class = $trace['class'];
// $function = $trace['function'];
// KalturaLog::debug("#$i Called from function [$class::$function] file[$file] line[$line]");
// }
list($root, $path) = $object->generateFilePathArr($subType, $version);
$root = str_replace('//', '/', $root);
$path = str_replace('//', '/', $path);
if (!kConf::hasParam('volumes')) {
KalturaLog::debug("Path [{$root}{$path}]");
return array($root, $path);
}
if (isset(self::$sessionCache[$path])) {
return array($root, self::$sessionCache[$path]);
}
$volumes = kConf::get('volumes');
$volume = $volumes[rand(0, count($volumes) - 1)];
$newPath = str_replace('/content/', "/content/{$volume}/", $path);
self::$sessionCache[$path] = $newPath;
$path = $newPath;
KalturaLog::debug("Path [{$root}{$path}]");
return array($root, $path);
}
示例9: getPartnerPriorityFactorByPartner
public static function getPartnerPriorityFactorByPartner($partner)
{
$priority = self::getPriority($partner);
$priority2Factor = kConf::get('priority_factor');
$priorityFactor = $priority2Factor[$priority];
return $priorityFactor;
}
示例10: init
protected static function init()
{
if (!kConf::hasParam('monitor_uri')) {
return null;
}
$uri = kConf::get('monitor_uri');
$pathInfo = parse_url($uri);
if (isset($pathInfo['host']) && $pathInfo['port']) {
$host = $pathInfo['host'];
if (isset($pathInfo['scheme'])) {
$host = $pathInfo['scheme'] . "://{$host}";
}
$errno = null;
$errstr = null;
self::$stream = fsockopen($host, $pathInfo['port'], $errno, $errstr, 1);
if (self::$stream) {
return true;
}
if (class_exists('KalturaLog')) {
KalturaLog::err("Open socket failed: {$errstr}");
}
}
self::$stream = fopen($uri, 'a');
if (self::$stream) {
return true;
}
self::$stream = false;
// prevent init from being called again
return false;
}
示例11: createThumbnailAssetFromFile
public static function createThumbnailAssetFromFile(entry $entry, $filePath)
{
try {
$fileLocation = tempnam(sys_get_temp_dir(), $entry->getId());
$res = KCurlWrapper::getDataFromFile($filePath, $fileLocation, kConf::get('thumb_size_limit'));
} catch (Exception $e) {
KalturaLog::debug($e->getMessage());
throw new Exception("Data Retrieval Failed");
}
if (!$res) {
KalturaLog::debug("thumbnail cannot be created from {$filePath} " . error_get_last());
throw new Exception("thumbnail file path is not valid");
}
$thumbAsset = new thumbAsset();
$thumbAsset->setPartnerId($entry->getPartnerId());
$thumbAsset->setEntryId($entry->getId());
$thumbAsset->setStatus(thumbAsset::ASSET_STATUS_QUEUED);
$thumbAsset->incrementVersion();
$thumbAsset->save();
$fileSyncKey = $thumbAsset->getSyncKey(asset::FILE_SYNC_ASSET_SUB_TYPE_ASSET);
kFileSyncUtils::moveFromFile($fileLocation, $fileSyncKey);
$finalPath = kFileSyncUtils::getLocalFilePathForKey($fileSyncKey);
$ext = pathinfo($finalPath, PATHINFO_EXTENSION);
$thumbAsset->setFileExt($ext);
list($width, $height, $type, $attr) = getimagesize($finalPath);
$thumbAsset->setWidth($width);
$thumbAsset->setHeight($height);
$thumbAsset->setSize(filesize($finalPath));
$thumbAsset->setStatus(thumbAsset::ASSET_STATUS_READY);
$thumbAsset->save();
kBusinessConvertDL::setAsDefaultThumbAsset($thumbAsset);
myNotificationMgr::createNotification(kNotificationJobData::NOTIFICATION_TYPE_ENTRY_UPDATE_THUMBNAIL, $entry);
}
示例12: validateNestedObjects
protected function validateNestedObjects($maxPageSize = null, $maxNestingLevel = null)
{
$relatedProfiles = $this->relatedProfiles;
if (!$relatedProfiles) {
return;
}
if (is_null($maxPageSize)) {
$maxPageSize = kConf::get('response_profile_max_page_size', 'local', 100);
}
if (is_null($maxNestingLevel)) {
$maxNestingLevel = kConf::get('response_profile_max_nesting_level', 'local', 2);
}
if ($maxNestingLevel > 0) {
foreach ($relatedProfiles as $relatedProfile) {
/* @var $relatedProfile KalturaDetachedResponseProfile */
$relatedProfile->validateNestedObjects($maxPageSize, $maxNestingLevel - 1);
$pager = $relatedProfile->pager;
if ($pager) {
$pager->validatePropertyMaxValue('pageSize', $maxPageSize, true);
}
}
} elseif (count($relatedProfiles)) {
throw new KalturaAPIException(KalturaErrors::RESPONSE_PROFILE_MAX_NESTING_LEVEL);
}
}
示例13: retrieveByLastId
/**
* Retrieve all records larger than the id
*
* @param array $servers<SphinxLogServer>
* @param int $gap
* @param int $limit
* @param array $handledEntries
* @param PropelPDO $con the connection to use
* @return SphinxLog
*/
public static function retrieveByLastId(array $servers, $gap = 0, $limit = 1000, array $handledEntries = null, PropelPDO $con = null)
{
$criteria = new Criteria();
$criterions = null;
if (count($servers)) {
$criterions = $criteria->getNewCriterion(SphinxLogPeer::ID, null, Criteria::ISNULL);
}
foreach ($servers as $server) {
$dc = $server->getDc();
$crit = $criteria->getNewCriterion(SphinxLogPeer::ID, $server->getLastLogId() - $gap, Criteria::GREATER_THAN);
$crit->addAnd($criteria->getNewCriterion(SphinxLogPeer::DC, $dc));
if (!is_null($handledEntries)) {
$crit->addAnd($criteria->getNewCriterion(SphinxLogPeer::ID, $handledEntries[$dc], Criteria::NOT_IN));
}
$criterions->addOr($crit);
}
if ($criterions) {
$criteria->addAnd($criterions);
}
$disabledPartnerIds = kConf::get('disable_sphinx_indexing_partners', 'local', array());
if ($disabledPartnerIds) {
$criteria->add(SphinxLogPeer::PARTNER_ID, $disabledPartnerIds, Criteria::NOT_IN);
}
$criteria->addAscendingOrderByColumn(SphinxLogPeer::ID);
$criteria->setLimit($limit);
return SphinxLogPeer::doSelect($criteria, $con);
}
示例14: myCache
public function myCache($namespace, $expiry = NULL)
{
$this->m_namespace = $namespace;
if (self::$s_memcache == NULL) {
if (!function_exists('memcache_connect')) {
return;
}
self::$s_memcache = new Memcache();
//self::$s_memcache->pconnect(self::SERVER, self::PORT) // this will use a persistent connection
try {
$res = @self::$s_memcache->connect(kConf::get("memcache_host"), kConf::get("memcache_port"));
} catch (Exception $e) {
$res = false;
}
if (!$res) {
kLog::log("ERROR: Error while trying to connect to memcache. Make sure it is properly running on " . kConf::get("memcache_host") . ":" . kConf::get("memcache_port"));
//throw new Exception ("Error while trying to connect to memcache. Make sure it is properly running on " . self::SERVER . ":" . self::PORT );
} else {
self::$s_ready = true;
}
// or die ("Error while trying to connect to memcache. Make sure it is properly running on " . self::SERVER . ":" . self::PORT );
}
if ($expiry != null) {
$this->m_expiry = $expiry;
}
if ($this->calculateStats()) {
$this->m_stats = $this->getStatsObj();
if ($this->m_stats == NULL) {
$this->m_stats = new cacheStats();
}
} else {
$this->m_stats = new cacheStats();
}
}
示例15: __construct
public function __construct(KalturaDistributionJobData $distributionJobData = null)
{
parent::__construct($distributionJobData);
$this->notificationBaseUrl = 'http://' . kConf::get('cdn_api_host');
if (!$distributionJobData) {
return;
}
if (!$distributionJobData->distributionProfile instanceof KalturaUnicornDistributionProfile) {
return;
}
$entryDistributionDb = EntryDistributionPeer::retrieveByPK($distributionJobData->entryDistributionId);
$distributionProfileDb = DistributionProfilePeer::retrieveByPK($distributionJobData->distributionProfileId);
/* @var $distributionProfileDb UnicornDistributionProfile */
$flavorAssetIds = explode(',', $entryDistributionDb->getFlavorAssetIds());
$flavorAssetId = reset($flavorAssetIds);
$flavorAsset = assetPeer::retrieveById($flavorAssetId);
$flavorAssetOldVersion = $entryDistributionDb->getFromCustomData(kUnicornDistributionJobProviderData::CUSTOM_DATA_FLAVOR_ASSET_OLD_VERSION);
$flavorAssetNewVersion = null;
if ($flavorAsset) {
$flavorAssetNewVersion = $flavorAsset->getVersion();
}
$values = $distributionProfileDb->getAllFieldValues($entryDistributionDb);
$this->catalogGuid = $values[UnicornDistributionField::CATALOG_GUID];
$this->title = $values[UnicornDistributionField::TITLE];
$this->flavorAssetVersion = $flavorAssetNewVersion;
$this->mediaChanged = $flavorAssetOldVersion != $flavorAssetNewVersion;
}