本文整理汇总了PHP中io::isPositiveInteger方法的典型用法代码示例。如果您正苦于以下问题:PHP io::isPositiveInteger方法的具体用法?PHP io::isPositiveInteger怎么用?PHP io::isPositiveInteger使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类io
的用法示例。
在下文中一共展示了io::isPositiveInteger方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: create
public static function create($campaignId, $data = array())
{
if (!io::isPositiveInteger($campaignId)) {
return false;
}
$sql = 'INSERT INTO mod_mailjet VALUES (' . $campaignId . ',"' . json_encode($data) . '");';
$query = new CMS_query($sql);
return !$query->hasError();
}
示例2: getById
public static function getById($id = 0)
{
if (!io::isPositiveInteger($id)) {
return null;
}
$sql = 'SELECT * from mod_object_oembed_definition where id_mood = ' . io::sanitizeSQLString($id);
$query = new CMS_query($sql);
$data = array_pop($query->getAll());
if ($data === null) {
return null;
}
return self::getObj($data);
}
示例3: __construct
/**
* Constructor.
* initialize object.
*
* @param string $hash the cache hash to use
* @param string $type : the type of the cache to use
* @param mixed $lifetime : the cache lifetime
* @return void
* @access public
*/
function __construct($hash, $type, $lifetime = null, $contextAware = false)
{
if ($contextAware) {
$this->_parameters['hash'] = $hash . '_' . CMS_session::getContextHash();
$this->_context = true;
} else {
$this->_parameters['hash'] = $hash;
}
//normalize cache lifetime
if ($lifetime == 'false' || $lifetime == '0' || $lifetime === false || $lifetime === 0) {
$lifetime = false;
}
if ($lifetime == 'true' || $lifetime == 'auto' || $lifetime == '1' || $lifetime === true || $lifetime === 1) {
//this definition do not use PHP so use default cache lifetime
$lifetime = CACHE_MODULES_DEFAULT_LIFETIME;
//set this cache as auto lifetime
$this->_auto = true;
}
if (io::isPositiveInteger($lifetime)) {
$lifetime = (int) $lifetime;
}
$this->_parameters['type'] = io::sanitizeAsciiString($type);
$this->_parameters['lifetime'] = $lifetime ? $lifetime : null;
//check cache dir
$cachedir = new CMS_file(PATH_CACHE_FS . '/' . $this->_parameters['type'], CMS_file::FILE_SYSTEM, CMS_file::TYPE_DIRECTORY);
if (!$cachedir->exists()) {
$cachedir->writeTopersistence();
}
//Cache options
$frontendOptions = array('lifetime' => $this->_parameters['lifetime'], 'caching' => $this->_parameters['lifetime'] === null ? false : CACHE_MODULES_DATAS, 'automatic_cleaning_factor' => 50, 'automatic_serialization' => true);
$backendOptions = array('cache_dir' => PATH_CACHE_FS . '/' . $this->_parameters['type'], 'cache_file_umask' => octdec(FILES_CHMOD), 'hashed_directory_umask' => octdec(DIRS_CHMOD), 'hashed_directory_level' => 2);
// getting a Zend_Cache_Core object
if (!class_exists('Zend_Cache')) {
die('not found ....');
}
try {
$this->_cache = Zend_Cache::factory('Core', 'File', $frontendOptions, $backendOptions);
} catch (Zend_Cache_Exception $e) {
$this->raiseError($e->getMessage());
return false;
}
if (!isset($this->_cache) || !is_object($this->_cache)) {
$this->raiseError('Error : Zend cache object does not exists');
return false;
}
}
示例4: elseif
} elseif (method_exists($resource, 'getTitle')) {
$method = 'getTitle';
}
if ($method) {
$element = $resource->{$method}();
}
if (!$element) {
$element = $resource->getID();
} else {
$element .= ' (' . $resource->getID() . ')';
}
//get resource type label
if (method_exists($module, 'getRessourceTypeLabelMethod') && $module->getRessourceTypeLabelMethod()) {
$element = $resource->{$module->getRessourceTypeLabelMethod()}($cms_language) . ' : ' . $element;
} else {
$element .= ' (' . $module->getLabel($cms_language) . ')';
}
}
} else {
$element = $status = '';
}
$actionKey = array_search($log->getLogAction(), $actions);
$actionLabel = io::isPositiveInteger($actionKey) ? $cms_language->getMessage($actionKey) : $actionKey;
$feeds['items'][] = array('id' => $log->getID(), 'datetime' => $dt->getLocalizedDate($cms_language->getDateFormat() . ' H:i:s'), 'element' => $element, 'action' => $actionLabel, 'status' => $status, 'comment' => $log->getTextData());
}
$feeds['total_count'] = CMS_log_catalog::search('', 0, $userId, array(), false, false, $start, $limit, $order, $direction, true);
$feeds['version'] = 1;
$view->setContent($feeds);
break;
}
$view->show();
示例5: __construct
/**
* Constructor
*
* @access public
* @param $objectDefinition CMS_poly_object_definition the current search object definition or the ID of the CMS_poly_object_definition
* @param boolean $public
*/
function __construct($objectDefinition, $public = false)
{
global $cms_user;
if (io::isPositiveInteger($objectDefinition)) {
$objectDefinition = CMS_poly_object_catalog::getObjectDefinition($objectDefinition);
}
if (!is_a($objectDefinition, 'CMS_poly_object_definition')) {
$this->raiseError('ObjectDefinition must be a valid CMS_poly_object_definition.');
return false;
}
$this->_object = $objectDefinition;
// Set public status
$this->_public = $public;
//add search object type condition
$this->addWhereCondition("object", $this->_object);
//if cms_user exists, check user rights
if (is_object($cms_user)) {
$this->addWhereCondition("profile", $cms_user);
}
//add resource condition if any
if ($this->_object->isPrimaryResource()) {
//if this is a public search, add limitation to resource publications dates
if ($this->_public) {
$limitDate = new CMS_date();
$limitDate->setNow();
$this->addWhereCondition("publication date before", $limitDate);
$this->addWhereCondition("publication date end", $limitDate);
}
}
}
示例6: foreach
if (empty($limitToOrderedItems) && empty($limitToItems)) {
//Add all subobjects to search if any
foreach ($objectFields as $fieldID => $field) {
//if field is a poly object
if (CMS_session::getSessionVar('items_' . $object->getID() . '_' . $fieldID) != '') {
$search->addWhereCondition($fieldID, CMS_session::getSessionVar('items_' . $object->getID() . '_' . $fieldID));
}
}
}
// Param : With keywords (this is best if it is done at last)
if (CMS_session::getSessionVar('items_' . $object->getID() . '_kwrds') != '') {
$kwrd = CMS_session::getSessionVar('items_' . $object->getID() . '_kwrds');
if (io::isPositiveInteger($kwrd) && !io::isPositiveInteger($keywordsTarget)) {
$search->addWhereCondition("item", $kwrd);
} else {
if (io::isPositiveInteger($keywordsTarget)) {
// a specific field target was specified
$search->addWhereCondition($keywordsTarget, $kwrd, $keywordsOptions);
} else {
$search->addWhereCondition("keywords", $kwrd, $keywordsOptions);
}
}
}
//If we must limit to some specific items (usually used during refresh of some listing elements)
if ($limitToItems) {
$search->addWhereCondition("items", $limitToItems);
} elseif ($limitToOrderedItems) {
//If we must limit to some specific items ordered (usually used for polymod multi_poly_object field)
$search->addWhereCondition("itemsOrdered", $limitToOrderedItems);
} else {
// Params : paginate limit
示例7: redirect
/**
* Create the redirection of an alias
*
* @return boolean true on success, false on failure
* @access public
* @static
*/
function redirect()
{
//get aliases for current folder
$dirname = array_pop(explode(DIRECTORY_SEPARATOR, dirname($_SERVER['SCRIPT_NAME'])));
$aliases = CMS_module_cms_aliases::getByName($dirname);
if (!$aliases) {
//no alias found, go to 404
CMS_grandFather::raiseError('No alias found for directory ' . dirname($_SERVER['SCRIPT_NAME']));
CMS_view::redirect(PATH_SPECIAL_PAGE_NOT_FOUND_WR, true, 301);
}
//check each aliases returned to get the one which respond to current alias
$matchAlias = false;
$domain = @parse_url($_SERVER['REQUEST_URI'], PHP_URL_HOST) ? @parse_url($_SERVER['REQUEST_URI'], PHP_URL_HOST) : (@parse_url($_SERVER['HTTP_HOST'], PHP_URL_HOST) ? @parse_url($_SERVER['HTTP_HOST'], PHP_URL_HOST) : $_SERVER['HTTP_HOST']);
$websites = array();
if ($domain) {
$websites = CMS_websitesCatalog::getWebsitesFromDomain($domain);
}
foreach ($aliases as $alias) {
if (!$matchAlias && dirname($_SERVER['SCRIPT_NAME']) == substr($alias->getPath(), 0, -1)) {
if ($websites) {
foreach ($websites as $website) {
//alias match path, check for website
if (!$alias->getWebsites() || !$website || in_array($website->getId(), $alias->getWebsites())) {
//alias match website, use it
$matchAlias = $alias;
}
}
} else {
//alias match path, check for website
if (!$alias->getWebsites()) {
//alias match website, use it
$matchAlias = $alias;
}
}
}
}
if (!$matchAlias) {
//no alias found, go to 404
CMS_grandFather::raiseError('No alias found for directory ' . dirname($_SERVER['SCRIPT_NAME']) . ' and domain ' . $domain);
CMS_view::redirect(PATH_SPECIAL_PAGE_NOT_FOUND_WR, true, 301);
}
//if alias is used as a page url, return page
if ($matchAlias->urlReplaced()) {
if (io::isPositiveInteger($matchAlias->getPageID())) {
$page = CMS_tree::getPageById($matchAlias->getPageID());
} else {
//no valid page set, go to 404
$matchAlias->raiseError('No page set for alias ' . $matchAlias->getID());
CMS_view::redirect(PATH_SPECIAL_PAGE_NOT_FOUND_WR, true, 301);
}
if (!$page || $page->hasError()) {
//no valid page found, go to 404
$matchAlias->raiseError('Invalid page ' . $matchAlias->getPageID() . ' for alias ' . $matchAlias->getID());
CMS_view::redirect(PATH_SPECIAL_PAGE_NOT_FOUND_WR, true, 301);
}
//return page path
$pPath = $page->getHTMLURL(false, false, PATH_RELATIVETO_FILESYSTEM);
if ($pPath) {
if (file_exists($pPath)) {
return $pPath;
} elseif ($page->regenerate(true)) {
clearstatcache();
if (file_exists($pPath)) {
return $pPath;
}
}
}
//no valid url page found, go to 404
$matchAlias->raiseError('Invalid url page ' . $matchAlias->getPageID() . ' for alias ' . $matchAlias->getID());
CMS_view::redirect(PATH_SPECIAL_PAGE_NOT_FOUND_WR, true, 301);
} else {
//this is a redirection
$params = isset($_SERVER['QUERY_STRING']) && $_SERVER['QUERY_STRING'] ? '?' . $_SERVER['QUERY_STRING'] : '';
if (isset($_SERVER['HTTP_REFERER'])) {
header("Referer: " . $_SERVER['HTTP_REFERER']);
}
if (io::isPositiveInteger($matchAlias->getPageID())) {
//it's a redirection to an Automne Page
$page = CMS_tree::getPageById($matchAlias->getPageID());
if ($page && !$page->hasError()) {
$pageURL = CMS_tree::getPageValue($matchAlias->getPageID(), 'url');
if ($pageURL) {
CMS_view::redirect($pageURL . $params, true, $matchAlias->isPermanent() ? 301 : 302);
} else {
//no valid url page found, go to 404
$matchAlias->raiseError('Invalid url page ' . $matchAlias->getPageID() . ' for alias ' . $matchAlias->getID());
CMS_view::redirect(PATH_SPECIAL_PAGE_NOT_FOUND_WR, true, 301);
}
} else {
//no valid page found, go to 404
$matchAlias->raiseError('Invalid page ' . $matchAlias->getPageID() . ' for alias ' . $matchAlias->getID());
CMS_view::redirect(PATH_SPECIAL_PAGE_NOT_FOUND_WR, true, 301);
}
//.........这里部分代码省略.........
示例8: isset
// Limit
$mandatory = $paramValue == true ? '<span class="atm-red">*</span> ' : '';
$value = isset($data["value"]['search'][$searchName][$paramType]) ? $data["value"]['search'][$searchName][$paramType] : '';
$searchParamContent[] = array('fieldLabel' => $mandatory . $cms_language->getMessage(MESSAGE_PAGE_FIELD_LIMIT, false, MOD_POLYMOD_CODENAME), 'name' => 'value[search][' . $searchName . '][' . $paramType . ']', 'anchor' => '99%', 'allowNegative' => false, 'allowDecimals' => false, 'xtype' => 'numberfield', 'allowBlank' => !$mandatory, 'value' => $value);
break;
case 'order':
if (sizeof($paramValue)) {
$orderNameList = array('objectID' => MESSAGE_PAGE_FIELD_ORDER_OBJECTID, 'random' => MESSAGE_PAGE_FIELD_ORDER_RANDOM, 'publication date after' => MESSAGE_PAGE_FIELD_ORDER_PUBLICATION_START, 'publication date before' => MESSAGE_PAGE_FIELD_ORDER_PUBLICATION_END);
$searchOrderContent = array();
foreach ($paramValue as $orderName => $orderValue) {
$fieldLabel = '';
if (in_array($orderName, CMS_object_search::getStaticOrderConditionTypes())) {
$fieldLabel = $cms_language->getMessage($orderNameList[$orderName], false, MOD_POLYMOD_CODENAME);
} else {
$orderName = trim($orderName, '()');
if (io::isPositiveInteger($orderName)) {
$field = new CMS_poly_object_field($orderName);
if ($field && !$field->hasError()) {
$label = new CMS_object_i18nm($field->getValue('labelID'));
$fieldLabel = $label->getValue($cms_language->getCode());
}
}
}
if ($fieldLabel) {
// Order direction
$mandatory = $paramValue == true ? '<span class="atm-red">*</span> ' : '';
$value = isset($data["value"]['search'][$searchName][$paramType][$orderName]) ? $data["value"]['search'][$searchName][$paramType][$orderName] : '';
$searchOrderContent[] = array('xtype' => 'atmCombo', 'fieldLabel' => $mandatory . $fieldLabel, 'name' => 'value[search][' . $searchName . '][' . $paramType . '][' . $orderName . ']', 'hiddenName' => 'value[search][' . $searchName . '][' . $paramType . '][' . $orderName . ']', 'forceSelection' => true, 'mode' => 'local', 'valueField' => 'id', 'displayField' => 'name', 'triggerAction' => 'all', 'allowBlank' => !$mandatory, 'selectOnFocus' => true, 'editable' => false, 'value' => $value, 'store' => array('xtype' => 'arraystore', 'fields' => array('id', 'name'), 'data' => array(array('', '-'), array('asc', $cms_language->getMessage(MESSAGE_PAGE_FIELD_ORDER_ASC, false, MOD_POLYMOD_CODENAME)), array('desc', $cms_language->getMessage(MESSAGE_PAGE_FIELD_ORDER_DESC, false, MOD_POLYMOD_CODENAME)))));
} else {
$cms_message .= $cms_language->getMessage(MESSAGE_PAGE_SEARCH_ORDERTYPE_ERROR, array($searchName, $row->getLabel(), $orderName), MOD_POLYMOD_CODENAME) . "\n";
}
示例9: indentPHP
/**
* Return well indented php code
*
* @param string $phpcode : php code to indent
* @return string indented php code
* @access public
* @static
*/
function indentPHP($phpcode)
{
$phparray = array_map('trim', explode("\n", $phpcode));
$level = 0;
foreach ($phparray as $linenb => $phpline) {
//remove blank lines
if ($phpline == '') {
unset($phparray[$linenb]);
continue;
}
//check for indent level down
$firstChar = $phpline[0];
if ($firstChar == '}' || $firstChar == ')' || substr($phpline, 0, 5) == 'endif') {
$level--;
}
//indent code
$indent = io::isPositiveInteger($level) ? str_repeat("\t", $level) : '';
$phparray[$linenb] = $indent . $phpline;
//check for indent level up
$lastChar = substr($phpline, -1);
if ($lastChar == '{' || $lastChar == ':' || substr($phpline, -7) == 'array (') {
$level++;
}
}
return implode("\n", $phparray);
}
示例10: set403
/**
* Sets the 403 page Id for the website
*
* @param integer $pageId The 403 page Id to set
* @return boolean true on success, false on failure.
* @access public
*/
function set403($pageId)
{
if ($pageId && !io::isPositiveInteger($pageId)) {
return false;
}
$this->_403 = $pageId;
return true;
}
示例11: getSenderForContext
/**
* Factory, instanciate a sender from current context
*
* @return CMS_forms_sender
*/
function getSenderForContext()
{
//sender does not exists in DB so create a new one*/
$obj = new CMS_forms_sender();
$obj->setAttribute('sessionID', Zend_Session::getId());
if (io::isPositiveInteger(CMS_session::getUserID())) {
$obj->setAttribute('userID', CMS_session::getUserID());
}
$obj->setAttribute('clientIP', @$_SERVER["REMOTE_ADDR"]);
if (isset($_SERVER["HTTP_ACCEPT_LANGUAGE"])) {
$obj->setAttribute('languages', @$_SERVER["HTTP_ACCEPT_LANGUAGE"]);
}
$obj->setAttribute('userAgent', @$_SERVER["HTTP_USER_AGENT"]);
return $obj;
}
示例12: CMS_resource_cms_aliases
$replaceURL = sensitiveIO::request('replaceURL') ? true : false;
$permanent = sensitiveIO::request('permanent') ? true : false;
// Current alias object to manipulate
if ($aliasId) {
$item = CMS_module_cms_aliases::getByID($aliasId);
} else {
$item = new CMS_resource_cms_aliases();
}
//check protected status
$protected = sensitiveIO::request('protected') ? true : false;
if (!$item->isProtected() || !$protected && $cms_user->hasAdminClearance(CLEARANCE_ADMINISTRATION_EDITVALIDATEALL)) {
//set alias websites (needed to know if alias is correct in case of name conflict)
$item->setWebsites(explode(',', $websites));
//set parent only if alias has no subaliases
if (!$item->hasSubAliases()) {
if (io::isPositiveInteger($newFatherId)) {
$parent = CMS_module_cms_aliases::getByID($newFatherId);
$item->setParent($parent);
} else {
$item->setParent(false);
}
//then set alias name
if (!$item->setAlias($name)) {
$cms_message .= $cms_language->getMessage(MESSAGE_ERROR_DIRECTORY_EXISTS, false, 'cms_aliases');
break;
}
}
$item->setReplaceURL($replaceURL);
$item->setPermanent($permanent);
$item->setProtected($protected);
if ($pageId) {
示例13: _getIframe
/**
* Get iframe code for current html embed code
*
* @param string $style the html style code to add
* @param string $attr the html attributes code to add
* @return string the html code
* @access protected
*/
protected function _getIframe($style, $attr)
{
//load datas
if (!($datas = $this->getDatas())) {
return '';
}
//already iframe embeded, no need to redo an iframe arround
if (strtolower(substr(trim($datas['html']), 0, 8)) == '<iframe ') {
return '<div' . $style . $attr . '>' . $datas['html'] . '</div>';
}
//frame param
$frameParam = base64_encode(serialize(array('url' => $this->_url, 'maxwidth' => io::isPositiveInteger($this->_maxwidth) ? $this->_maxwidth : '', 'maxheight' => io::isPositiveInteger($this->_maxheight) ? $this->_maxheight : '')));
//frame domain
if (defined('APPLICATION_EMBED_DOMAIN') && APPLICATION_EMBED_DOMAIN) {
$domain = strtolower(substr(APPLICATION_EMBED_DOMAIN, 0, 4)) == 'http' ? APPLICATION_EMBED_DOMAIN : 'http://' . APPLICATION_EMBED_DOMAIN;
} else {
$domain = CMS_websitesCatalog::getCurrentDomain();
}
//iframe width/height
$width = $height = '';
if (isset($datas['width']) && io::isPositiveInteger($datas['width'])) {
$width = io::htmlspecialchars($datas['width']);
} else {
//try to guess width for iframe ...
$matches = array();
if (preg_match('/^<[^>]* width="([0-9]+)"/i', trim($datas['html']), $matches) && isset($matches[1])) {
$width = $matches[1];
} elseif (io::isPositiveInteger($this->_maxwidth)) {
$width = $this->_maxwidth;
}
}
if (isset($datas['height']) && io::isPositiveInteger($datas['height'])) {
$height = io::htmlspecialchars($datas['height']);
} else {
//try to guess width for iframe ...
$matches = array();
if (preg_match('/^<[^>]* height="([0-9]+)"/i', trim($datas['html']), $matches) && isset($matches[1])) {
$height = $matches[1];
} elseif (io::isPositiveInteger($this->_maxheight)) {
$height = $this->_maxheight;
}
}
return '<iframe scrolling="no" frameBorder="0"' . ($width ? ' width="' . $width . '"' : '') . ($height ? ' height="' . $height . '"' : '') . ' src="' . $domain . PATH_MAIN_WR . '/oembed/frame' . (!STRIP_PHP_EXTENSION ? '.php' : '') . '?params=' . $frameParam . '">' . ' <a href="' . $domain . PATH_MAIN_WR . '/oembed/frame' . (!STRIP_PHP_EXTENSION ? '.php' : '') . '?params=' . $frameParam . '" target="_blank">Click to view media</a>' . '</iframe>';
}
示例14: pathinfo
if ($_SERVER['REQUEST_URI'] && $_SERVER['REQUEST_URI'] != $_SERVER['SCRIPT_NAME']) {
$pathinfo = pathinfo($_SERVER['REQUEST_URI']);
$basename = isset($pathinfo['filename']) ? $pathinfo['filename'] : $pathinfo['basename'];
//first try to get redirection rules from CSV file if exists
if (file_exists(PATH_MAIN_FS . '/redirect/redirectRules.csv')) {
$csvFile = new CMS_file(PATH_MAIN_FS . '/redirect/redirectRules.csv');
$csvDatas = $csvFile->readContent('csv', 'trim', array('delimiter' => ';', 'enclosure' => '"', 'strict' => true));
$rules = array();
foreach ($csvDatas as $line => $csvData) {
if (isset($csvData[0]) && $csvData[0] && isset($csvData[1]) && $csvData[1]) {
$rules[$csvData[0]] = $csvData[1];
}
}
if (isset($rules[$_SERVER['REQUEST_URI']]) && io::isPositiveInteger($rules[$_SERVER['REQUEST_URI']])) {
$page = CMS_tree::getPageById($rules[$_SERVER['REQUEST_URI']]);
} elseif (isset($rules[parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH)]) && io::isPositiveInteger($rules[parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH)])) {
$page = CMS_tree::getPageById($rules[parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH)]);
}
}
if (!isset($page)) {
//get page from requested url
$page = CMS_tree::analyseURL($_SERVER['REQUEST_URI'], false);
}
//get redirection URL for page
if (isset($page) && is_object($page) && !$page->hasError() && $page->getStatus()->getLocation() != RESOURCE_LOCATION_DELETED) {
//get page file
$pageURL = $page->getURL(substr($basename, 0, 5) == 'print' ? true : false, false, PATH_RELATIVETO_FILESYSTEM);
if (file_exists($pageURL)) {
$redirectTo = $page->getURL(substr($basename, 0, 5) == 'print' ? true : false);
} else {
//try to regenerate page
示例15: getValue
/**
* get an object value
*
* @param string $name : the name of the value to get
* @param string $parameters (optional) : parameters for the value to get
* @return multidimentionnal array : the object values structure
* @access public
*/
function getValue($name, $parameters = '')
{
switch ($name) {
case 'file':
case 'thumb':
if ($name == 'file') {
$fieldIndex = 4;
$fielfPrefix = 'image';
} else {
$fieldIndex = 1;
$fielfPrefix = 'thumb';
}
// If we have a value and there are additionnal cropping parameters
if ($this->_subfieldValues[$fieldIndex]->getValue() && $parameters && in_array($this->getValue($name . 'Extension'), array('jpg', 'jpeg', 'png', 'gif'))) {
@(list($x, $y) = explode(',', str_replace(';', ',', $parameters)));
if (io::isPositiveInteger($x) && $x < $this->getValue($fielfPrefix . 'Width') || io::isPositiveInteger($y) && $y < $this->getValue($fielfPrefix . 'Height')) {
$crop = $x && $y ? 1 : 0;
//get module codename
$moduleCodename = CMS_poly_object_catalog::getModuleCodenameForField($this->_field->getID());
//set location
$location = $this->isPublic() ? RESOURCE_DATA_LOCATION_PUBLIC : RESOURCE_DATA_LOCATION_EDITED;
//resized image path
$pathInfo = pathinfo($this->_subfieldValues[$fieldIndex]->getValue());
$resizedImage = $pathInfo['filename'] . '-' . $x . '-' . $y . ($crop ? '-c' : '') . '.' . $pathInfo['extension'];
//resized image path
$resizedImagepathFS = PATH_MODULES_FILES_FS . '/' . $moduleCodename . '/' . $location . '/' . $resizedImage;
//if file already exists, no need to resize file send it
if (file_exists($resizedImagepathFS)) {
return $this->getValue('filePath') . '/' . $resizedImage;
} else {
return CMS_websitesCatalog::getCurrentDomain() . PATH_REALROOT_WR . '/image-file' . (!STRIP_PHP_EXTENSION ? '.php' : '') . '?image=' . $this->_subfieldValues[$fieldIndex]->getValue() . '&module=' . $moduleCodename . '&x=' . $x . '&y=' . $y . '&crop=' . $crop . ($location != RESOURCE_DATA_LOCATION_PUBLIC ? '&location=' . $location : '');
}
}
}
if ($this->_subfieldValues[$fieldIndex]->getValue()) {
// If we have a value but no cropping params
return $this->getValue('filePath') . '/' . $this->_subfieldValues[$fieldIndex]->getValue();
}
return '';
break;
case 'fileHTML':
//get module codename
$moduleCodename = CMS_poly_object_catalog::getModuleCodenameForField($this->_field->getID());
//set location
$location = $this->_public ? RESOURCE_DATA_LOCATION_PUBLIC : RESOURCE_DATA_LOCATION_EDITED;
$filepath = $this->_subfieldValues[3]->getValue() == self::OBJECT_FILE_TYPE_INTERNAL ? PATH_MODULES_FILES_WR . '/' . $moduleCodename . '/' . $location . '/' . $this->_subfieldValues[4]->getValue() : $this->_subfieldValues[4]->getValue();
//append website url if missing
if (io::substr($filepath, 0, 1) == '/') {
$filepath = CMS_websitesCatalog::getCurrentDomain() . $filepath;
}
//link content
$linkContent = $parameters ? $parameters : $this->_subfieldValues[0]->getValue();
$file = '<a href="' . $filepath . '" target="_blank" title="' . $this->_subfieldValues[0]->getValue() . '">' . $linkContent . '</a>';
return $file;
break;
case 'fileLabel':
return $this->_subfieldValues[0]->getValue();
break;
case 'filename':
return $this->_subfieldValues[4]->getValue();
break;
case 'thumbnail':
case 'thumbname':
return $this->_subfieldValues[1]->getValue();
break;
case 'filePath':
//get module codename
$moduleCodename = CMS_poly_object_catalog::getModuleCodenameForField($this->_field->getID());
//set location
$location = $this->isPublic() ? RESOURCE_DATA_LOCATION_PUBLIC : RESOURCE_DATA_LOCATION_EDITED;
$altDomain = $this->getAlternativeDomain();
// If we are serving a public file and there is an alternative domain set up, change the url
if ($this->isPublic() && $altDomain) {
return $altDomain . PATH_MODULES_FILES_WR . '/' . $moduleCodename . '/' . $location;
} else {
return CMS_websitesCatalog::getCurrentDomain() . PATH_MODULES_FILES_WR . '/' . $moduleCodename . '/' . $location;
}
break;
case 'thumbMaxWidth':
//get field parameters
$params = $this->getParamsValues();
return $params['thumbMaxWidth'] ? $params['thumbMaxWidth'] : '';
break;
case 'thumbMaxHeight':
//get field parameters
$params = $this->getParamsValues();
return $params['thumbMaxHeight'] ? $params['thumbMaxHeight'] : '';
break;
case 'thumbWidth':
case 'thumbHeight':
//get module codename
$moduleCodename = CMS_poly_object_catalog::getModuleCodenameForField($this->_field->getID());
//.........这里部分代码省略.........