本文整理汇总了PHP中CPropertyValue类的典型用法代码示例。如果您正苦于以下问题:PHP CPropertyValue类的具体用法?PHP CPropertyValue怎么用?PHP CPropertyValue使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了CPropertyValue类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: beforeAction
public function beforeAction($action)
{
$this->scanModules('payment');
$arrModules = Modules::model()->findAllByAttributes(array('category' => 'payment'), array('order' => 'module'));
$this->_allowAdvancedPayments = CPropertyValue::ensureBoolean(Yii::app()->params['ALLOW_ADVANCED_PAY_METHODS']);
$menuSidebar = array();
foreach ($arrModules as $module) {
$currentModule = Yii::app()->getComponent($module->module);
if (is_null($currentModule)) {
continue;
}
if ($currentModule->cloudCompatible === false && _xls_get_conf('LIGHTSPEED_CLOUD') > 0) {
continue;
}
if ($currentModule->isDisplayable() === false) {
continue;
}
$menuSidebar[] = array('label' => $currentModule->AdminName, 'url' => array('payments/module', 'id' => $module->module), 'advancedPayment' => $currentModule->advancedMode);
}
$advancedPaymentMethods = where($menuSidebar, array('advancedPayment' => true));
$simplePaymentMethods = where($menuSidebar, array('advancedPayment' => false));
$this->menuItems = array_merge(array(array('label' => 'Simple Integration Modules', 'linkOptions' => array('class' => 'nav-header'))), $simplePaymentMethods, array(array('label' => 'Advanced Integration Modules', 'linkOptions' => array('class' => 'nav-header'), 'visible' => count($advancedPaymentMethods) > 0)), $advancedPaymentMethods, $this->getPaymentSetupLinks());
$objModules = Modules::model()->findAllByAttributes(array('category' => 'payment', 'active' => 1));
if (count($objModules) === 0 && $action->id == "index") {
$this->noneActive = 1;
Yii::app()->user->setFlash('error', Yii::t('admin', 'WARNING: You have no payment modules activated. No one can checkout.'));
}
return parent::beforeAction($action);
}
示例2: actionBulkCreate
public function actionBulkCreate(array $names = array(), $parentId = 0, $vocabularyId = 0)
{
$vocabularyId = CPropertyValue::ensureInteger($vocabularyId);
if (!$vocabularyId) {
return errorHandler()->log('Missing Vocabulary Id');
}
foreach ($names as $catName) {
$catName = trim($catName);
if ($catName == '') {
continue;
}
$model = new Term('single_save');
$model->v_id = $vocabularyId;
$model->name = $catName;
$model->alias = Utility::createAlias($model, $model->name);
$model->state = Term::STATE_ACTIVE;
$model->parentId = $parentId;
if (!$model->save()) {
$this->result->fail(ERROR_HANDLING_DB, 'save category failed');
} else {
if ($model->parentId) {
$relation = TermHierarchy::model()->findByAttributes(array('term_id' => $model->id));
if (!is_object($relation)) {
$relation = new TermHierarchy();
$relation->term_id = $model->id;
}
$relation->parent_id = $model->parentId;
if (!$relation->save()) {
Yii::log(CVarDumper::dumpAsString($relation->getErrors()), CLogger::LEVEL_ERROR);
}
}
}
}
}
示例3: send
public function send($phones, $text)
{
$request = new DOMDocument("1.0", "UTF-8");
$requestBody = $request->createElement('SMS');
$requestBody->appendChild($this->createOperationsElement(array(self::SEND)));
$requestBody->appendChild($this->createAuthElement());
$request->appendChild($requestBody);
$sms = $request->createElement('message');
$sms->appendChild($request->createElement('sender', $this->sender));
$textElement = $request->createElement('text');
$textElement->appendChild(new DOMCdataSection($text));
$sms->appendChild($textElement);
$requestBody->appendChild($sms);
if (is_array($phones) == false) {
$phones = array($phones => array());
}
$numbers = $request->createElement('numbers');
foreach ($phones as $phone => $value) {
$variables = implode(';', CPropertyValue::ensureArray($value)) . ';';
$number = $request->createElement('number', $phone);
$number->setAttribute('messageid', md5($phone . date() . $variables));
$number->setAttribute('variables', $variables);
$numbers->appendChild($number);
}
$requestBody->appendChild($numbers);
$responseText = $this->doRequest($request->saveXML());
$result = $this->parseResponse($responseText);
$status = $result['status'];
$ok = (bool) ($status > 0);
$needSmsAlert = $ok == false && $status != -4;
$credits = $this->balance();
return array('status' => $status, 'ok' => $ok, 'responseText' => $responseText, 'credits' => $credits, 'needSmsAlert' => $needSmsAlert);
}
示例4: render
public function render($params = array())
{
$height = CPropertyValue::ensureInteger($params['height']);
$height -= $height > 40 ? 20 : 0;
parent::appendOption($this->_htmlOptions, 'class', $this->_cssClass);
parent::appendOption($this->_htmlOptions, 'style', 'height: ' . $height . 'px;');
echo CHtml::tag('li', $this->_htmlOptions, $this->_data);
}
示例5: getIsGuest
public function getIsGuest()
{
$customer = Customer::model()->findByPk($this->id);
if ($customer !== null) {
return CPropertyValue::ensureInteger($customer->record_type) === Customer::GUEST;
}
return parent::getIsGuest();
}
示例6: generateProductGrid
/**
* This function generates the products grid
* based on the criteria. It also generates the
* pagination object need for the users to navigate
* through products.
*
* @return void
*/
public function generateProductGrid()
{
$this->_numberOfRecords = Product::model()->count($this->_productGridCriteria);
$this->_pages = new CPagination($this->_numberOfRecords);
$this->_pages->setPageSize(CPropertyValue::ensureInteger(Yii::app()->params['PRODUCTS_PER_PAGE']));
$this->_pages->applyLimit($this->_productGridCriteria);
$this->_productsGrid = self::createBookends(Product::model()->findAll($this->_productGridCriteria));
}
示例7: getGridViewConfig
/**
* @return array the config array passed to widget ()
*/
public function getGridViewConfig()
{
if (!isset($this->_gridViewConfig)) {
$this->_gridViewConfig = array_merge(parent::getGridViewConfig(), array('possibleResultsPerPage' => array(5, 10, 20, 30, 40, 50, 75, 100), 'defaultGvSettings' => array('isActive' => 65, 'fullName' => 125, 'lastLogin' => 80, 'emailAddress' => 100), 'template' => CHtml::openTag('div', X2Html::mergeHtmlOptions(array('class' => 'page-title'), array('style' => !CPropertyValue::ensureBoolean($this->getWidgetProperty('showHeader')) && !CPropertyValue::ensureBoolean($this->getWidgetProperty('hideFullHeader')) ? 'display: none;' : ''))) . '<h2 class="grid-widget-title-bar-dummy-element">' . '</h2>{buttons}{filterHint}' . '{summary}{topPager}</div>{items}{pager}', 'includedFields' => array('tagLine', 'username', 'officePhone', 'cellPhone', 'emailAddress', 'googleId', 'isActive', 'leadRoutingAvailability'), 'specialColumns' => array('fullName' => array('name' => 'fullName', 'header' => Yii::t('profile', 'Full Name'), 'value' => 'CHtml::link(CHtml::encode($data->fullName),array("view","id"=>$data->id))', 'type' => 'raw'), 'lastLogin' => array('name' => 'lastLogin', 'header' => Yii::t('profile', 'Last Login'), 'value' => '$data->user ? ($data->user->lastLogin == 0 ? "" : ' . 'Formatter::formatDateDynamic ($data->user->lastLogin)) : ""', 'type' => 'raw'), 'isActive' => array('name' => 'isActive', 'header' => Yii::t('profile', 'Active'), 'value' => '"<span title=\'' . '".(Session::isOnline ($data->username) ? ' . '"' . Yii::t('profile', 'Active User') . '" : "' . Yii::t('profile', 'Inactive User') . '")."\'' . ' class=\'".(Session::isOnline ($data->username) ? ' . '"active-indicator" : "inactive-indicator")."\'></span>"', 'type' => 'raw'), 'username' => array('name' => 'username', 'header' => Yii::t('profile', 'Username'), 'value' => '$data->user ? CHtml::encode($data->user->alias) : ""', 'type' => 'raw'), 'leadRoutingAvailability' => array('name' => 'leadRoutingAvailability', 'header' => Yii::t('profile', 'Lead Routing Availability'), 'value' => 'CHtml::encode($data->leadRoutingAvailability ?
Yii::t("profile", "Available") :
Yii::t("profile", "Unavailable"))', 'type' => 'raw')), 'enableControls' => false));
}
return $this->_gridViewConfig;
}
示例8: parseTree
public static function parseTree($objRet, $root = 0)
{
$return = array();
# Traverse the tree and search for direct children of the root
foreach ($objRet as $objItem) {
if (CPropertyValue::ensureInteger($objItem->child_count) > 0 || CPropertyValue::ensureBoolean(Yii::app()->params['DISPLAY_EMPTY_CATEGORY'])) {
$return[] = array('text' => CHtml::link($objItem->family, $objItem->Link), 'label' => $objItem->family, 'link' => $objItem->Link, 'request_url' => $objItem->request_url, 'url' => $objItem->Link, 'id' => $objItem->id, 'child_count' => $objItem->child_count, 'children' => null, 'items' => null);
}
}
return empty($return) ? null : $return;
}
示例9: init
public function init()
{
$this->maxBlockTime = $this->getTimeInterval($this->maxBlockTime);
$this->alertRepeatInterval = $this->getTimeInterval($this->alertRepeatInterval);
$this->gatewayMinCredit = CPropertyValue::ensureFloat($this->gatewayMinCredit);
$gateways = array();
foreach ($this->gateways as $gateway) {
$gateways[] = Yii::createComponent($gateway);
}
$this->gateways = $gateways;
}
示例10: truncate
public function truncate($value, $length, $type = TruncateType::Character)
{
switch (CPropertyValue::ensureEnum($type, TruncateType)) {
case TruncateType::Paragraph:
return $this->truncateParagraph($value, $length);
case TruncateType::Word:
return $this->truncateWord($value, $length);
case TruncateType::Character:
default:
return $this->truncateCharacter($value, $length);
}
}
示例11: enumValue
public static function enumValue($class, $id)
{
if ($id === '' || $id === null || $id === false) {
return '---';
}
$class = new ReflectionClass($class);
$values = $class->getConstants();
if (preg_match('/[0-9]+/', $id)) {
$values = array_values($values);
$id = isset($values[$id]) ? $values[$id] : '';
}
return self::formatLabel(CPropertyValue::ensureEnum($id, $class->name));
}
示例12: afterSave
/**
* Responds to {@link CActiveRecord::onAfterSave} event.
* Overrides this method if you want to handle the corresponding event of the {@link CBehavior::owner owner}.
* @param CModelEvent $event event parameter
*/
public function afterSave($event)
{
$data = array();
$objectId = $this->getOwner()->{$this->objectAttribute};
if ($this->useActiveField) {
$data = $this->getOwner()->{$this->name};
if (!is_array($data) && !is_object($data)) {
$data = array((int) $data);
}
} else {
if (isset($_POST[$this->name])) {
$data = $_POST[$this->name];
if (!is_array($data) && !is_object($data)) {
$data = array((int) $data);
}
}
}
//delete old
$sql = "DELETE FROM " . SITE_ID . '_' . "taxonomy_index t" . "\n USING " . SITE_ID . '_' . "taxonomy_term tt, " . SITE_ID . '_' . "taxonomy_vocabulary tv" . "\n WHERE tt.id = t.term_id AND tv.id = tt.v_id" . (is_numeric($this->taxonomy) ? "\n AND (tv.id = :id)" : "\n AND (tv.alias = :alias)") . "\n AND tv.module = :module AND t.object_id = :object_id";
if (count($data)) {
foreach ($data as $index => $val) {
$data[$index] = CPropertyValue::ensureInteger($val);
}
$dataString = implode(',', $data);
$sql .= "\n AND t.term_id NOT IN ({$dataString})";
}
$command = TermRelation::model()->getDbConnection()->createCommand($sql);
if (is_numeric($this->taxonomy)) {
$command->bindParam(":id", $this->taxonomy, PDO::PARAM_INT);
} else {
$command->bindParam(":alias", $this->taxonomy, PDO::PARAM_STR);
}
$command->bindParam(":module", $this->module, PDO::PARAM_STR);
$command->bindParam(":object_id", $objectId, PDO::PARAM_INT);
$command->execute();
//update/create
if (count($data)) {
foreach ($data as $val) {
$relation = TermRelation::model()->findByAttributes(array('object_id' => $objectId, 'term_id' => $val));
if (!is_object($relation)) {
$relation = new TermRelation();
}
$relation->object_id = $objectId;
$relation->term_id = $val;
if (!$relation->save()) {
Yii::log(CVarDumper::dumpAsString($relation->getErrors()), CLogger::LEVEL_ERROR);
}
}
}
}
示例13: prepareOutput
private function prepareOutput()
{
$preparedAttributes = array();
foreach ($this->getAttributes() as $key => $value) {
if (in_array($key, array('enableClientValidation', 'safe', 'skipOnError'))) {
$preparedAttributes[$key] = CPropertyValue::ensureBoolean($value);
}
if ($key === 'except' || $key === 'on') {
if (!is_null($value)) {
$preparedAttributes[$key] = array_map('trim', explode(',', $value));
}
}
}
return $preparedAttributes;
}
示例14: beforeAction
public function beforeAction($action)
{
$this->scanModules('theme');
if (Yii::app()->theme) {
$this->currentTheme = Yii::app()->theme->name;
if (Theme::hasAdminForm($this->currentTheme)) {
$model = Yii::app()->getComponent('wstheme')->getAdminModel($this->currentTheme);
$this->currentTheme = $model->name;
}
} else {
$this->currentTheme = "unknown";
}
// Only old self-hosted customers can download/upgrade themes on their own.
$canDisplayThemeGallery = CPropertyValue::ensureBoolean(Yii::app()->params['LIGHTSPEED_HOSTING']) === false && CPropertyValue::ensureBoolean(Yii::app()->params['ALLOW_LEGACY_THEMES']);
$this->menuItems = array(array('label' => 'Manage My Themes', 'url' => array('theme/manage')), array('label' => 'Configure ' . ucfirst($this->currentTheme), 'url' => array('theme/module')), array('label' => 'Edit CSS for ' . ucfirst($this->currentTheme), 'url' => array('theme/editcss'), 'visible' => Theme::hasAdminForm(Yii::app()->theme->name)), array('label' => 'View Theme Gallery', 'url' => array('theme/gallery'), 'visible' => $canDisplayThemeGallery), array('label' => 'Upload Theme .Zip', 'url' => array('theme/upload'), 'visible' => !(Yii::app()->params['LIGHTSPEED_MT'] > 0)), array('label' => 'My Header/Image Gallery', 'url' => array('theme/image', 'id' => 1)), array('label' => 'Upload FavIcon', 'url' => array('theme/favicon'), 'visible' => !(Yii::app()->params['LIGHTSPEED_MT'] > 0)));
//run parent beforeAction() after setting menu so highlighting works
return parent::beforeAction($action);
}
示例15: dropDownList
/**
* dropDownList Taxonomy
*
* @param string $name
* @param string $taxonomy
* @param string $module
* @param int $objectId
* @param array $htmlOptions
*/
public static function dropDownList($name, $taxonomy, $module, $objectId, $htmlOptions = array())
{
$properties = array('name' => $name, 'taxonomy' => $taxonomy, 'module' => $module, 'objectId' => $objectId);
if (isset($htmlOptions['type'])) {
$properties['type'] = CPropertyValue::ensureString($htmlOptions['type']);
unset($htmlOptions['type']);
}
if (isset($htmlOptions['repeatChar'])) {
$properties['repeatChar'] = CPropertyValue::ensureString($htmlOptions['repeatChar']);
unset($htmlOptions['repeatChar']);
}
if (isset($htmlOptions['useRepeatChar'])) {
$properties['useRepeatChar'] = CPropertyValue::ensureBoolean($htmlOptions['useRepeatChar']);
unset($htmlOptions['useRepeatChar']);
}
$properties['htmlOptions'] = $htmlOptions;
return Yii::app()->controller->widget('ListTaxonomy', $properties, true);
}