本文整理汇总了PHP中Text::getById方法的典型用法代码示例。如果您正苦于以下问题:PHP Text::getById方法的具体用法?PHP Text::getById怎么用?PHP Text::getById使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Text
的用法示例。
在下文中一共展示了Text::getById方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: init
/**
* Set up the payment array
* @author Reto Kohli <reto.kohli@comvation.com>
* @since 2.1.0
*/
static function init()
{
global $objDatabase;
$arrSqlName = \Text::getSqlSnippets('`payment`.`id`', FRONTEND_LANG_ID, 'Shop', array('name' => self::TEXT_NAME));
$query = "\n SELECT `payment`.`id`, `payment`.`processor_id`,\n `payment`.`fee`, `payment`.`free_from`,\n `payment`.`ord`, `payment`.`active`, " . $arrSqlName['field'] . "\n FROM `" . DBPREFIX . "module_shop" . MODULE_INDEX . "_payment` AS `payment`" . $arrSqlName['join'] . "\n ORDER BY id";
$objResult = $objDatabase->Execute($query);
if (!$objResult) {
return self::errorHandler();
}
self::$arrPayments = array();
if ($objResult->EOF) {
return true;
}
while ($objResult && !$objResult->EOF) {
$id = $objResult->fields['id'];
$strName = $objResult->fields['name'];
if ($strName === null) {
$objText = \Text::getById($id, 'Shop', self::TEXT_NAME);
if ($objText) {
$strName = $objText->content();
}
}
self::$arrPayments[$id] = array('id' => $id, 'processor_id' => $objResult->fields['processor_id'], 'name' => $strName, 'fee' => $objResult->fields['fee'], 'free_from' => $objResult->fields['free_from'], 'ord' => $objResult->fields['ord'], 'active' => $objResult->fields['active']);
$objResult->MoveNext();
}
return true;
}
示例2: init
/**
* Initialise the Manufacturer array
*
* Uses the FRONTEND_LANG_ID constant to determine the language.
* The array has the form
* array(
* 'id' => Manufacturer ID,
* 'name' => Manufacturer name,
* 'url' => Manufacturer URI,
* )
* @static
* @param string $order The optional sorting order.
* Defaults to null (unsorted)
* @return boolean True on success, false otherwise
* @global ADONewConnection $objDatabase
* @global array $_ARRAYLANG
* @todo Order the Manufacturers by their name
*/
static function init($order = null)
{
global $objDatabase;
$arrSql = \Text::getSqlSnippets('`manufacturer`.`id`', FRONTEND_LANG_ID, 'Shop', array('name' => self::TEXT_NAME, 'url' => self::TEXT_URI));
$query = "\n SELECT `manufacturer`.`id`, " . $arrSql['field'] . "\n FROM `" . DBPREFIX . "module_shop" . MODULE_INDEX . "_manufacturer` AS `manufacturer`" . $arrSql['join'] . ($order ? " ORDER BY {$order}" : '');
$objResult = $objDatabase->Execute($query);
if (!$objResult) {
return self::errorHandler();
}
self::$arrManufacturer = array();
while (!$objResult->EOF) {
$id = $objResult->fields['id'];
$strName = $objResult->fields['name'];
// Replace Text in a missing language by another, if available
if ($strName === null) {
$strName = \Text::getById($id, 'Shop', self::TEXT_NAME)->content();
}
$strUrl = $objResult->fields['url'];
if ($strUrl === null) {
$strUrl = \Text::getById($id, 'Shop', self::TEXT_URI)->content();
}
self::$arrManufacturer[$id] = array('id' => $id, 'name' => $strName, 'url' => $strUrl);
$objResult->MoveNext();
}
return true;
}
示例3: init
/**
* Initialize currencies
*
* Sets up the Currency array, and picks the selected Currency from the
* 'currency' request parameter, if available.
* @author Reto Kohli <reto.kohli@comvation.com>
* @static
*/
static function init($active_currency_id = 0)
{
global $objDatabase;
$arrSqlName = \Text::getSqlSnippets('`currency`.`id`', FRONTEND_LANG_ID, 'Shop', array('name' => self::TEXT_NAME));
$query = "\n SELECT `currency`.`id`, `currency`.`code`, `currency`.`symbol`,\n `currency`.`rate`, `currency`.`increment`,\n `currency`.`ord`,\n `currency`.`active`, `currency`.`default`, " . $arrSqlName['field'] . "\n FROM `" . DBPREFIX . "module_shop" . MODULE_INDEX . "_currencies` AS `currency`" . $arrSqlName['join'] . "\n ORDER BY `currency`.`id` ASC";
$objResult = $objDatabase->Execute($query);
if (!$objResult) {
return self::errorHandler();
}
while (!$objResult->EOF) {
$id = $objResult->fields['id'];
$strName = $objResult->fields['name'];
if ($strName === null) {
$strName = \Text::getById($id, 'Shop', self::TEXT_NAME)->content();
}
self::$arrCurrency[$objResult->fields['id']] = array('id' => $objResult->fields['id'], 'code' => $objResult->fields['code'], 'symbol' => $objResult->fields['symbol'], 'name' => $strName, 'rate' => $objResult->fields['rate'], 'increment' => $objResult->fields['increment'], 'ord' => $objResult->fields['ord'], 'active' => $objResult->fields['active'], 'default' => $objResult->fields['default']);
if ($objResult->fields['default']) {
self::$defaultCurrencyId = $objResult->fields['id'];
}
$objResult->MoveNext();
}
if (!isset($_SESSION['shop'])) {
$_SESSION['shop'] = array();
}
if (isset($_REQUEST['currency'])) {
$currency_id = intval($_REQUEST['currency']);
$_SESSION['shop']['currencyId'] = isset(self::$arrCurrency[$currency_id]) ? $currency_id : self::$defaultCurrencyId;
}
if (!empty($active_currency_id)) {
$_SESSION['shop']['currencyId'] = isset(self::$arrCurrency[$active_currency_id]) ? $active_currency_id : self::$defaultCurrencyId;
}
if (empty($_SESSION['shop']['currencyId'])) {
$_SESSION['shop']['currencyId'] = self::$defaultCurrencyId;
}
self::$activeCurrencyId = intval($_SESSION['shop']['currencyId']);
return true;
}
示例4: init
/**
* Initialises all Zones (but no relation)
* @return boolean True on success, false otherwise
* @static
*/
static function init()
{
global $objDatabase;
$arrSqlName = \Text::getSqlSnippets('`zone`.`id`', FRONTEND_LANG_ID, 'Shop', array('name' => self::TEXT_NAME));
$query = "\n SELECT `zone`.`id`, `zone`.`active`, " . $arrSqlName['field'] . "\n FROM `" . DBPREFIX . "module_shop" . MODULE_INDEX . "_zones` AS `zone`" . $arrSqlName['join'] . "\n ORDER BY `name` ASC";
$objResult = $objDatabase->Execute($query);
if (!$objResult) {
return self::errorHandler();
}
self::$arrZone = array();
while (!$objResult->EOF) {
$id = $objResult->fields['id'];
$strName = $objResult->fields['name'];
if ($strName === null) {
$objText = \Text::getById($id, 'Shop', self::TEXT_NAME);
if ($objText) {
$strName = $objText->content();
}
}
self::$arrZone[$id] = array('id' => $id, 'name' => $strName, 'active' => $objResult->fields['active']);
$objResult->MoveNext();
}
return true;
}
示例5: getById
/**
* Select a Product by ID from the database.
* @static
* @param integer $id The Product ID
* @return Product The Product object on success,
* false otherwise
* @global ADONewConnection
* @author Reto Kohli <reto.kohli@comvation.com>
*/
static function getById($id)
{
global $objDatabase;
if (!$id) {
return NULL;
}
$arrSql = \Text::getSqlSnippets('`product`.`id`', FRONTEND_LANG_ID, 'Shop', array('name' => self::TEXT_NAME, 'short' => self::TEXT_SHORT, 'long' => self::TEXT_LONG, 'keys' => self::TEXT_KEYS, 'code' => self::TEXT_CODE, 'uri' => self::TEXT_URI));
$query = "\n SELECT `product`.`id`, `product`.`category_id`,\n `product`.`ord`, `product`.`active`, `product`.`weight`,\n `product`.`picture`,\n `product`.`normalprice`, `product`.`resellerprice`,\n `product`.`discountprice`, `product`.`discount_active`,\n `product`.`stock`, `product`.`stock_visible`,\n `product`.`distribution`,\n `product`.`date_start`, `product`.`date_end`,\n `product`.`manufacturer_id`,\n `product`.`b2b`, `product`.`b2c`,\n `product`.`vat_id`,\n `product`.`flags`,\n `product`.`usergroup_ids`,\n `product`.`group_id`, `product`.`article_id`,\n `product`.`minimum_order_quantity`, " . $arrSql['field'] . "\n FROM `" . DBPREFIX . "module_shop" . MODULE_INDEX . "_products` AS `product`" . $arrSql['join'] . "\n WHERE `product`.`id`={$id}";
$objResult = $objDatabase->Execute($query);
if (!$objResult) {
return self::errorHandler();
}
if ($objResult->RecordCount() != 1) {
return false;
}
$id = $objResult->fields['id'];
$strCode = $objResult->fields['code'];
if ($strCode === null) {
$strCode = \Text::getById($id, 'Shop', self::TEXT_CODE)->content();
}
$strName = $objResult->fields['name'];
if ($strName === null) {
$strName = \Text::getById($id, 'Shop', self::TEXT_NAME)->content();
}
$strShort = $objResult->fields['short'];
if ($strShort === null) {
$strShort = \Text::getById($id, 'Shop', self::TEXT_SHORT)->content();
}
$strLong = $objResult->fields['long'];
if ($strLong === null) {
$strLong = \Text::getById($id, 'Shop', self::TEXT_LONG)->content();
}
$strUri = $objResult->fields['uri'];
if ($strUri === null) {
$strUri = \Text::getById($id, 'Shop', self::TEXT_URI)->content();
}
$strKeys = $objResult->fields['keys'];
if ($strKeys === null) {
$strKeys = \Text::getById($id, 'Shop', self::TEXT_KEYS)->content();
}
$objProduct = new Product($strCode, $objResult->fields['category_id'], $strName, $objResult->fields['distribution'], $objResult->fields['normalprice'], $objResult->fields['active'], $objResult->fields['ord'], $objResult->fields['weight'], $objResult->fields['id']);
$objProduct->pictures = $objResult->fields['picture'];
$objProduct->resellerprice = floatval($objResult->fields['resellerprice']);
$objProduct->short = $strShort;
$objProduct->long = $strLong;
$objProduct->stock($objResult->fields['stock']);
$objProduct->stock_visible($objResult->fields['stock_visible']);
$objProduct->discountprice = floatval($objResult->fields['discountprice']);
$objProduct->discount_active($objResult->fields['discount_active']);
$objProduct->b2b($objResult->fields['b2b']);
$objProduct->b2c($objResult->fields['b2c']);
$objProduct->date_start($objResult->fields['date_start']);
$objProduct->date_end($objResult->fields['date_end']);
$objProduct->manufacturer_id = $objResult->fields['manufacturer_id'];
$objProduct->uri = $strUri;
$objProduct->vat_id = $objResult->fields['vat_id'];
$objProduct->flags = $objResult->fields['flags'];
$objProduct->usergroup_ids = $objResult->fields['usergroup_ids'];
$objProduct->group_id = $objResult->fields['group_id'];
$objProduct->article_id = $objResult->fields['article_id'];
$objProduct->keywords = $strKeys;
$objProduct->minimum_order_quantity = $objResult->fields['minimum_order_quantity'];
// Fetch the Product Attribute relations
$objProduct->arrRelations = Attributes::getRelationArray($objProduct->id);
//die("dfhreh: ".$objProduct->category_id());
return $objProduct;
}
示例6: getVirtualCategoryNameArray
/**
* Returns an array with the names of all ShopCategories marked as virtual.
*
* Note that the names are ordered according to the sorting order field.
* @return array The array of virtual ShopCategory names
* @static
* @author Reto Kohli <reto.kohli@comvation.com>
*/
static function getVirtualCategoryNameArray()
{
global $objDatabase;
$arrSqlName = \Text::getSqlSnippets('`category`.`id`', FRONTEND_LANG_ID, 'Shop', array('name' => ShopCategory::TEXT_NAME));
$query = "\n SELECT `category`.`id`, " . $arrSqlName['field'] . "\n FROM `" . DBPREFIX . "module_shop" . MODULE_INDEX . "_categories` AS `category`" . $arrSqlName['join'] . "\n WHERE flags LIKE '%__VIRTUAL__%'\n ORDER BY ord ASC";
$objResult = $objDatabase->Execute($query);
if (!$objResult) {
return false;
}
$arrVirtual = array();
while (!$objResult->EOF) {
$id = $objResult->fields['id'];
$strName = $objResult->fields['name'];
// Replace Text in a missing language by another, if available
if ($strName === null) {
$objText = \Text::getById($id, 'Shop', ShopCategory::TEXT_NAME);
if ($objText) {
$strName = $objText->content();
}
}
$arrVirtual[$id] = $strName;
$objResult->MoveNext();
}
return $arrVirtual;
}
示例7: getNameById
/**
* Return the name of the Attribute selected by its ID
* from the database.
* @param integer $nameId The Attribute ID
* @return mixed The Attribute name on
* success, false otherwise
* @global ADONewConnection $objDatabase Database connection object
* @static
*/
static function getNameById($nameId)
{
return \Text::getById($nameId, 'Shop', self::TEXT_ATTRIBUTE_NAME, FRONTEND_LANG_ID)->content();
}
示例8: getOptionNameById
/**
* Return the name of the option selected by its ID
* from the database.
*
* Returns false on error, or the empty string if the value cannot be
* found.
* @param integer $option_id The option ID
* @return mixed The option name on success,
* or false otherwise.
* @static
* @global mixed $objDatabase Database object
*/
static function getOptionNameById($option_id)
{
global $objDatabase;
$arrSqlValue = \Text::getSqlSnippets('`option`.`id`', FRONTEND_LANG_ID, 'Shop', array('name' => Attribute::TEXT_OPTION_NAME));
$query = "\n SELECT 1, " . $arrSqlValue['field'] . "\n FROM `" . DBPREFIX . "module_shop" . MODULE_INDEX . "_option` AS `option`" . $arrSqlValue['join'] . "\n WHERE `option`.`id`={$option_id}";
$objResult = $objDatabase->Execute($query);
if (!$objResult || $objResult->EOF) {
return false;
}
$strName = $objResult->fields['name'];
if (is_null($strName)) {
$strName = \Text::getById($option_id, 'Shop', Attribute::TEXT_OPTION_NAME)->content();
}
return $strName;
}
示例9: getNameArray
/**
* Returns an array of Product names from the database
*
* The array is indexed by the Product ID and ordered by the names
* and ID, ascending.
* The names array is kept in this method statically between calls.
* @static
* @param boolean $activeonly Optional. Include active (true) or
* inactive (false) Products only.
* Ignored if null. Defaults to null
* @param string $format The optional sprintf() format
* @return array The array of Product names
* on success, false otherwise
* @global ADONewConnection
* @author Reto Kohli <reto.kohli@comvation.com>
*/
static function getNameArray($activeonly = false, $format = '%2$s')
{
global $objDatabase;
$arrSqlName = \Text::getSqlSnippets('`product`.`id`', FRONTEND_LANG_ID, 'Shop', array('name' => Product::TEXT_NAME));
$query = "\n SELECT `product`.`id`, " . $arrSqlName['field'] . "\n FROM `" . DBPREFIX . "module_shop" . MODULE_INDEX . "_products` AS `product`" . $arrSqlName['join'] . (isset($activeonly) ? ' WHERE `product`.`active`=' . ($activeonly ? 1 : 0) : '') . "\n ORDER BY `name` ASC, `product`.`id` ASC";
$objResult = $objDatabase->Execute($query);
if (!$objResult) {
return Product::errorHandler();
}
$arrName = array();
while (!$objResult->EOF) {
$id = $objResult->fields['id'];
$strName = $objResult->fields['name'];
if ($strName === null) {
$objText = \Text::getById($id, 'Shop', Product::TEXT_NAME);
if ($objText) {
$strName = $objText->content();
}
}
$arrName[$objResult->fields['id']] = sprintf($format, $id, $strName);
$objResult->MoveNext();
}
//\DBG::log("Products::getNameArray(): Made ".var_export($arrName, true));
return $arrName;
}
示例10: init
/**
* Initialize the mail template array for the current module
*
* Uses the given language ID $lang_id if not empty, or all active
* frontend languages otherwise.
* The $limit value defaults to the value of the
* mailtemplate_per_page_backend setting from the core settings
* (@see \Cx\Core\Setting\Controller\Setting}.
* @param integer $section The section
* @param integer $lang_id The optional language ID
* @param string $order The optional sorting order string,
* SQL syntax
* @param integer $position The optional position offset,
* defaults to zero
* @param integer $limit The optional limit for returned
* templates
* @param integer $count The actual count of templates
* available in total, by reference
* @return boolean True on success, false otherwise
*/
static function init($section, $lang_id = null, $order = '', $position = 0, $limit = -1, &$count = 0)
{
global $objDatabase;
if (empty($section)) {
die("MailTemplate::init(): Empty section!");
}
$arrLanguageId = null;
if ($lang_id) {
// Init one language
$arrLanguageId = array($lang_id);
} else {
// Load all languages if none is specified
$arrLanguageId = \FWLanguage::getIdArray();
}
self::reset();
if (empty($limit)) {
$limit = \Cx\Core\Setting\Controller\Setting::getValue('mailtemplate_per_page_backend');
}
if (empty($limit)) {
$limit = 25;
}
$query_from = null;
self::$arrTemplates = array();
foreach ($arrLanguageId as $lang_id) {
$arrSql = \Text::getSqlSnippets('`mail`.`text_id`', $lang_id, $section, array('name' => self::TEXT_NAME, 'from' => self::TEXT_FROM, 'sender' => self::TEXT_SENDER, 'reply' => self::TEXT_REPLY, 'to' => self::TEXT_TO, 'cc' => self::TEXT_CC, 'bcc' => self::TEXT_BCC, 'subject' => self::TEXT_SUBJECT, 'message' => self::TEXT_MESSAGE, 'message_html' => self::TEXT_MESSAGE_HTML, 'attachments' => self::TEXT_ATTACHMENTS, 'inline' => self::TEXT_INLINE));
$query_from = "\n FROM `" . DBPREFIX . "core_mail_template` AS `mail`" . $arrSql['join'] . "\n WHERE `mail`.`section`" . (isset($section) ? "='" . addslashes($section) . "'" : ' IS NULL');
$query_order = $order ? " ORDER BY {$order}" : '';
// The count of available templates needs to be initialized to zero
// in case there is a problem with one of the queries ahead.
// Ignore the code analyzer warning.
$count = 0;
$objResult = $objDatabase->SelectLimit("\n SELECT `mail`.`key`, `mail`.`text_id`, `mail`.`protected`, `mail`.`html`, " . $arrSql['field'] . $query_from . $query_order, $limit, $position);
if (!$objResult) {
return self::errorHandler();
}
while (!$objResult->EOF) {
$available = true;
$key = $objResult->fields['key'];
$text_id = $objResult->fields['text_id'];
$strName = $objResult->fields['name'];
if ($strName === null) {
$strName = \Text::getById($text_id, $section, self::TEXT_NAME)->content();
if ($strName) {
$available = false;
}
}
$strFrom = $objResult->fields['from'];
if ($strFrom === null) {
$strFrom = \Text::getById($text_id, $section, self::TEXT_FROM)->content();
if ($strFrom) {
$available = false;
}
}
$strSender = $objResult->fields['sender'];
if ($strSender === null) {
$strSender = \Text::getById($text_id, $section, self::TEXT_SENDER)->content();
if ($strSender) {
$available = false;
}
}
$strReply = $objResult->fields['reply'];
if ($strReply === null) {
$strReply = \Text::getById($text_id, $section, self::TEXT_REPLY)->content();
if ($strReply) {
$available = false;
}
}
$strTo = $objResult->fields['to'];
if ($strTo === null) {
$strTo = \Text::getById($text_id, $section, self::TEXT_TO)->content();
if ($strTo) {
$available = false;
}
}
$strCc = $objResult->fields['cc'];
if ($strCc === null) {
$strCc = \Text::getById($text_id, $section, self::TEXT_CC)->content();
if ($strCc) {
$available = false;
}
//.........这里部分代码省略.........
示例11: init
/**
* Initialize the Vat object with current values from the database.
*
* Set up two class array variables, one called $arrVatClass, like
* (ID => "class", ...)
* and the other called $arrVatRate, like
* (ID => rate)
* Plus initializes the various object variables.
* May die() with a message if it fails to access its settings.
* @global ADONewConnection $objDatabase Database connection object
* @return void
* @static
*/
static function init()
{
global $objDatabase;
$arrSqlClass = \Text::getSqlSnippets('`vat`.`id`', FRONTEND_LANG_ID, 'Shop', array('name' => self::TEXT_CLASS));
$query = "\n SELECT `vat`.`id`, `vat`.`rate`, " . $arrSqlClass['field'] . "\n FROM " . DBPREFIX . "module_shop" . MODULE_INDEX . "_vat as `vat`" . $arrSqlClass['join'];
$objResult = $objDatabase->Execute($query);
if (!$objResult) {
return self::errorHandler();
}
self::$arrVat = array();
while (!$objResult->EOF) {
$id = $objResult->fields['id'];
$strClass = $objResult->fields['name'];
// Replace Text in a missing language by another, if available
if ($strClass === null) {
$objText = \Text::getById($id, 'Shop', self::TEXT_CLASS);
if ($objText) {
$strClass = $objText->content();
}
}
self::$arrVat[$id] = array('id' => $id, 'rate' => $objResult->fields['rate'], 'class' => $strClass);
$objResult->MoveNext();
}
self::$arrVatEnabled = array(0 => array(0 => \Cx\Core\Setting\Controller\Setting::getValue('vat_enabled_foreign_customer', 'Shop'), 1 => \Cx\Core\Setting\Controller\Setting::getValue('vat_enabled_foreign_reseller', 'Shop')), 1 => array(0 => \Cx\Core\Setting\Controller\Setting::getValue('vat_enabled_home_customer', 'Shop'), 1 => \Cx\Core\Setting\Controller\Setting::getValue('vat_enabled_home_reseller', 'Shop')));
self::$arrVatIncluded = array(0 => array(0 => \Cx\Core\Setting\Controller\Setting::getValue('vat_included_foreign_customer', 'Shop'), 1 => \Cx\Core\Setting\Controller\Setting::getValue('vat_included_foreign_reseller', 'Shop')), 1 => array(0 => \Cx\Core\Setting\Controller\Setting::getValue('vat_included_home_customer', 'Shop'), 1 => \Cx\Core\Setting\Controller\Setting::getValue('vat_included_home_reseller', 'Shop')));
self::$vatDefaultId = \Cx\Core\Setting\Controller\Setting::getValue('vat_default_id', 'Shop');
self::$vatDefaultRate = self::getRate(self::$vatDefaultId);
self::$vatOtherId = \Cx\Core\Setting\Controller\Setting::getValue('vat_other_id', 'Shop');
return true;
}
示例12: getArraysByZoneId
/**
* Returns an array of two arrays; one with countries in the given zone,
* the other with the remaining countries.
*
* If $zone_id is empty, includes Countries for all Zones present.
* The array looks like this:
* array(
* 'in' => array( // Countries in the zone
* country ID => array(
* 'id' => country ID,
* 'name' => country name,
* ),
* ... more ...
* ),
* 'out' => array( // Countries not in the zone
* country ID => array(
* 'id' => country ID,
* 'name' => country name,
* ),
* ... more ...
* ),
* );
* @todo Shop use only (should be moved back there)!
* @param integer $zone_id The optional Zone ID
* @return array Countries array, as described above
*/
static function getArraysByZoneId($zone_id = null)
{
global $objDatabase;
if (is_null(self::$arrCountries)) {
self::init();
}
// Query relations between zones and countries:
// Get all country IDs and names
// associated with that zone ID
$arrSqlName = \Text::getSqlSnippets('`country`.`id`', FRONTEND_LANG_ID, 'core', array('name' => self::TEXT_NAME));
$query = "\n SELECT `country`.`id`, " . $arrSqlName['field'] . "\n FROM `" . DBPREFIX . "core_country` AS `country`\n INNER JOIN `" . DBPREFIX . "module_shop" . MODULE_INDEX . "_rel_countries` AS `relation`\n ON `country`.`id`=`relation`.`country_id`\n " . $arrSqlName['join'] . "\n WHERE `country`.`active`=1\n " . ($zone_id ? "AND `relation`.`zone_id`={$zone_id}" : '') . "\n ORDER BY `name` ASC";
$objResult = $objDatabase->Execute($query);
if (!$objResult) {
return false;
}
// Initialize the array to avoid notices when one or the other is empty
$arrZoneCountries = array('in' => array(), 'out' => array());
while (!$objResult->EOF) {
$id = $objResult->fields['id'];
$strName = $objResult->fields['name'];
if ($strName === null) {
//DBG::log(("MISSING Name for ID $id"));
$objText = \Text::getById($id, 'core', self::TEXT_NAME, 0);
//DBG::log(("GOT Name for Text ID $id: ".$objText->content()));
if ($objText) {
$strName = $objText->content();
}
}
//DBG::log(("IN zone: ID $id - $strName"));
$arrZoneCountries['in'][$id] = array('id' => $id, 'name' => $strName);
$objResult->MoveNext();
}
foreach (self::$arrCountries as $id => $arrCountry) {
// Country may only be available for the Zone if it's
// not in yet and it's active
if (empty($arrZoneCountries['in'][$id]) && $arrCountry['active']) {
//DBG::log(("OUT zone: ID $id - {$arrCountry['name']}"));
$arrZoneCountries['out'][$id] = array('id' => $id, 'name' => $arrCountry['name']);
}
}
return $arrZoneCountries;
}
示例13: getById
/**
* Returns a ShopCategory selected by its ID from the database.
*
* Returns null if the Category does not exist.
* @static
* @param integer $category_id The Shop Category ID
* @return ShopCategory The Shop Category object on success,
* false on failure, or null otherwise.
* @global ADONewConnection $objDatabase Database connection object
* @author Reto Kohli <reto.kohli@comvation.com>
*/
static function getById($category_id)
{
global $objDatabase;
$category_id = intval($category_id);
if ($category_id <= 0) {
return null;
}
$arrSql = \Text::getSqlSnippets('`category`.`id`', FRONTEND_LANG_ID, 'Shop', array('name' => self::TEXT_NAME, 'description' => self::TEXT_DESCRIPTION));
$query = "\n SELECT `category`.`id`,\n `category`.`parent_id`,\n `category`.`active`,\n `category`.`ord`,\n `category`.`picture`,\n `category`.`flags`, " . $arrSql['field'] . "\n FROM `" . DBPREFIX . "module_shop" . MODULE_INDEX . "_categories` AS `category`" . $arrSql['join'] . "\n WHERE `category`.`id`={$category_id}";
$objResult = $objDatabase->Execute($query);
if (!$objResult) {
return self::errorHandler();
}
if ($objResult->EOF) {
return null;
}
$id = $objResult->fields['id'];
$strName = $objResult->fields['name'];
if ($strName === null) {
$objText = \Text::getById($id, 'Shop', self::TEXT_NAME);
if ($objText) {
$strName = $objText->content();
}
}
$strDescription = $objResult->fields['description'];
if ($strDescription === null) {
$objText = \Text::getById($id, 'Shop', self::TEXT_DESCRIPTION);
if ($objText) {
$strDescription = $objText->content();
}
}
//DBG::log("ShopCategory::getById($category_id): Loaded '$strName' / '$strDescription'");
$objCategory = new ShopCategory($strName, $strDescription, $objResult->fields['parent_id'], $objResult->fields['active'], $objResult->fields['ord'], $category_id);
$objCategory->picture($objResult->fields['picture']);
$objCategory->flags($objResult->fields['flags']);
return $objCategory;
}
示例14: init
/**
* Initialize the arrays of extensions and mime types on request
*
* The arrays look like this:
* $arrExtensions2Mimetypes = array(
* Extension => array(
* 'id' => ID,
* 'text_id' => Text ID,
* 'name' => Name,
* 'extension' => Extension,
* 'mimetype' => array(
* MIME Type,
* ... more ...
* ),
* ),
* ... more ...
* );
*
* $arrMimetypes2Extensions = array(
* MIME Type => array(
* 'id' => ID,
* 'text_id' => Text ID,
* 'name' => Name,
* 'mimetype' => MIME Type,
* 'extension' => array(
* Extension,
* ... more ...
* ),
* ),
* ... more ...
* );
* @author Reto Kohli <reto.kohli@comvation.com>
* @return boolean True on success, false otherwise
* @static
*/
static function init()
{
global $objDatabase;
$arrSqlName = Text::getSqlSnippets('`filetype`.`text_name_id`', FRONTEND_LANG_ID, 0, self::TEXT_NAME);
$query = "\n SELECT `filetype`.`id`,\n `filetype`.`extension`, `filetype`.`mimetype`" . $arrSqlName['field'] . "\n FROM " . DBPREFIX . "core_filetype AS `filetype`" . $arrSqlName['join'] . "\n ORDER BY `filetype`.`ord` ASC";
$objResult = $objDatabase->Execute($query);
if (!$objResult) {
return self::errorHandler();
}
self::$arrExtensions2Mimetypes = array();
while (!$objResult->EOF) {
$id = $objResult->fields['id'];
$text_id = $objResult->fields[$arrSqlName['id']];
$strName = $objResult->fields[$arrSqlName['text']];
if ($strName === null) {
$objText = Text::getById($id, 0);
if ($objText) {
$strName = $objText->getText();
}
}
if (empty(self::$arrExtensions2Mimetypes[$objResult->fields['extension']])) {
self::$arrExtensions2Mimetypes[$objResult->fields['extension']] = array('id' => $id, 'text_id' => $text_id, 'name' => $strName, 'extension' => $objResult->fields['extension']);
}
self::$arrExtensions2Mimetypes[$objResult->fields['extension']]['mimetype'][] = $objResult->fields['mimetype'];
if (empty(self::$arrMimetypes2Extensions[$objResult->fields['mimetype']])) {
self::$arrMimetypes2Extensions[$objResult->fields['mimetype']] = array('id' => $id, 'text_id' => $text_id, 'name' => $strName, 'mimetype' => $objResult->fields['mimetype']);
}
self::$arrMimetypes2Extensions[$objResult->fields['mimetype']]['extension'][] = $objResult->fields['extension'];
$objResult->MoveNext();
}
return true;
}
示例15: replace
/**
* Replace or insert the Text record
*
* If the Text ID is specified, looks for the same record in the
* given language, or any other language if that is not found.
* If no record to update is found, a new one is created.
* The parameters are applied, and the Text is then stored.
* @param integer $id The Text ID
* @param integer $lang_id The language ID
* @param integer $section The section
* @param string $key The key
* @param string $strText The text
* @return integer The Text ID on success,
* null otherwise
* @author Reto Kohli <reto.kohli@comvation.com>
*/
static function replace($id, $lang_id, $section, $key, $strText)
{
//DBG::log("Text::replace($id, $lang_id, $section, $key, $strText): Entered");
$objText = Text::getById($id, $section, $key, $lang_id);
//echo("replace($id, $lang_id, $strText, $section, $key): got by ID: ".$objText->content()."<br />");
// if (!$objText) {
// $objText = new Text('', 0, $section, $key, $id);
// }
$objText->content($strText);
// The language may be empty!
$objText->lang_id($lang_id);
//DBG::log("Text::replace($id, $lang_id, $section, $key, $strText): Storing ".var_export($objText, true));
if (!$objText->store()) {
DBG::log("Text::replace({$id}, {$lang_id}, {$section}, {$key}, {$strText}): Error: failed to store Text");
return null;
}
return $objText->id;
}