本文整理汇总了PHP中Shineisp_Commons_Utilities::format方法的典型用法代码示例。如果您正苦于以下问题:PHP Shineisp_Commons_Utilities::format方法的具体用法?PHP Shineisp_Commons_Utilities::format怎么用?PHP Shineisp_Commons_Utilities::format使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Shineisp_Commons_Utilities
的用法示例。
在下文中一共展示了Shineisp_Commons_Utilities::format方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: addNew
/**
* Add a new product attribute
*
* @param integer $id [empty to create a new record]
* @param string $code
* @param string $label
* @param string $type
* @param integer $language_id
* @param integer $position
* @param boolean $active
* @param string $prefix
* @param string $suffix
* @param string $description
* @param boolean $is_visible_on_front
* @param boolean $is_system_var
* @param string $system_var
* @param string $defaultvalue
* @param boolean $is_required
* @param boolean $is_comparable
* @param boolean $on_product_listing
*/
public static function addNew($id = NULL, $code, $label, $type, $language_id = 1, $position = 0, $active = 1, $prefix = NULL, $suffix = NULL, $description = NULL, $is_visible_on_front = 1, $is_system_var = 0, $system_var = NULL, $defaultvalue = NULL, $is_required = 0, $is_comparable = 0, $on_product_listing = 0)
{
$productsattributes = new ProductsAttributes();
// Set the new values
if (is_numeric($id)) {
$productsattributes = Doctrine::getTable('ProductsAttributes')->find($id);
}
// format the attribute code
$code = Shineisp_Commons_Utilities::format($code);
// Check if the code has been already used before
$thecode = self::getAttributebyCode($code);
// If the record is in Update mode
if (is_numeric($id)) {
if (!empty($thecode) && count($thecode) > 1) {
return false;
}
} else {
// If the record is new
if (!empty($thecode) && count($thecode) > 0) {
return false;
}
}
$productsattributes['code'] = $code;
$productsattributes['position'] = $position;
$productsattributes['is_visible_on_front'] = $is_visible_on_front;
$productsattributes['active'] = $active;
$productsattributes['system'] = $is_system_var;
$productsattributes['system_var'] = $system_var;
$productsattributes['defaultvalue'] = $defaultvalue;
$productsattributes['type'] = $type;
$productsattributes['is_required'] = $is_required;
$productsattributes['is_comparable'] = $is_comparable;
$productsattributes['on_product_listing'] = $on_product_listing;
$productsattributes->save();
$productsattributesdata = Doctrine::getTable('ProductsAttributesData')->createQuery('pad')->where('pad.attribute_id = ?', $productsattributes['attribute_id'])->andWhere('pad.language_id = ?', $language_id)->fetchOne();
if (empty($productsattributesdata)) {
$productsattributesdata = new ProductsAttributesData();
}
$productsattributesdata['attribute_id'] = $productsattributes['attribute_id'];
$productsattributesdata['language_id'] = $language_id;
$productsattributesdata['label'] = $label;
$productsattributesdata['prefix'] = $prefix;
$productsattributesdata['suffix'] = $suffix;
$productsattributesdata['description'] = $description;
$productsattributesdata->save();
return $productsattributes['attribute_id'];
}