本文整理汇总了PHP中Lookup类的典型用法代码示例。如果您正苦于以下问题:PHP Lookup类的具体用法?PHP Lookup怎么用?PHP Lookup使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Lookup类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: newlookup_POST
function newlookup_POST(Web &$w)
{
$w->Admin->navigation($w, "Lookup");
$_REQUEST['type'] = $_REQUEST['ntype'] != "" ? $_REQUEST['ntype'] : $_REQUEST['type'];
$err = "";
if ($_REQUEST['type'] == "") {
$err = "Please add select or create a TYPE<br>";
}
if ($_REQUEST['code'] == "") {
$err .= "Please enter a KEY<br>";
}
if ($_REQUEST['title'] == "") {
$err .= "Please enter a VALUE<br>";
}
if ($w->Admin->getLookupbyTypeCode($_REQUEST['type'], $_REQUEST['code'])) {
$err .= "Type and Key combination already exists";
}
if ($err != "") {
$w->error($err, "/admin/lookup/?tab=2");
} else {
$lookup = new Lookup($w);
$lookup->fill($_REQUEST);
$lookup->insert();
$w->msg("Lookup Item added", "/admin/lookup/");
}
}
示例2: rules
/**
* @return array validation rules for model attributes.
*/
public function rules()
{
return (Y::checkAccess('moderator')?array(
array('username, password, email', 'required', 'on' => 'create'),
array('username, email', 'required', 'on' => 'update'),
array('id, role, username, password, email, activkey, createtime, lastvisit, status', 'safe'),
array('username', 'length', 'max'=>20, 'min' => 3,'message' => Users::t("Incorrect username (length between 2 and 20 characters).")),
array('password', 'length', 'max'=>128, 'min' => 4,'message' => Users::t("Incorrect password (minimal length 4 symbols).")),
array('email', 'email'),
array('username', 'unique', 'message' => Users::t("This user's name already exists.")),
array('email', 'unique', 'message' => Users::t("This user's email address already exists.")),
array('username', 'match', 'pattern' => '/^[A-Za-z0-9_]+$/u','message' => Users::t("Incorrect symbols (A-z0-9).")),
array('status', 'in', 'range'=>array(self::STATUS_NOACTIVE,self::STATUS_ACTIVE,self::STATUS_BANED)),
array('role', 'in', 'range'=>Lookup::keys('role')),
array('username, email, createtime, lastvisit, status', 'required'),
array('createtime, lastvisit, status', 'numerical', 'integerOnly'=>true),
):((Y::userId()==$this->id)?array(
array('username, email', 'required'),
array('username', 'length', 'max'=>20, 'min' => 3,'message' => Users::t("Incorrect username (length between 2 and 20 characters).")),
array('email', 'email'),
array('username', 'unique', 'message' => Users::t("This user's name already exists.")),
array('username', 'match', 'pattern' => '/^[A-Za-z0-9_]+$/u','message' => Users::t("Incorrect symbols (A-z0-9).")),
array('email', 'unique', 'message' => Users::t("This user's email address already exists.")),
):array()));
}
示例3: actionEditBlog
public function actionEditBlog($id)
{
$model = new Post();
$rec = Post::model()->findByPk($id);
$r = Lookup::model()->findAll(array('condition' => 'type=:t', 'params' => array(':t' => 'PostStatus')));
//echo "<pre>";print_r($r);die;
foreach ($r as $type) {
//echo "<pre>";print_r($type);
$i[] = $type->id;
$n[] = $type->name;
$op = array_combine($i, $n);
}
//die;
//echo "<pre>";print_r($rec);die;
if (isset($_POST['Post'])) {
$model->attributes = $_POST['Post'];
if ($model->validate()) {
$res = Post::model()->findByPk($id);
$res->title = $_REQUEST['Post']['title'];
$res->content = $_REQUEST['Post']['content'];
$res->tags = $_REQUEST['Post']['tags'];
$res->status = $_REQUEST['Post']['status'];
$res->update_time = date('Y-m-d');
if ($res->save(false)) {
$this->redirect(array('postlisting'));
}
} else {
$errors = $model->getErrors();
}
}
$this->render('editblog', array('edit' => $rec, 'model' => $model, 'type' => $op, 'i' => $i));
}
示例4: settings_meta_box
function settings_meta_box($Customer)
{
?>
<p>
<span>
<input type="hidden" name="marketing" value="no" />
<input type="checkbox" id="marketing" name="marketing" value="yes"<?php
echo $Customer->marketing == 'yes' ? ' checked="checked"' : '';
?>
/>
<label for="marketing" class="inline"> <?php
_e('Subscribes to marketing', 'Shopp');
?>
</label>
</span>
</p>
<br class="clear" />
<p>
<span>
<select name="type"><?php
echo Shopp::menuoptions(Lookup::customer_types(), $Customer->type);
?>
</select>
<label for="type"><?php
_e('Customer Type', 'Shopp');
?>
</label>
</span>
</p>
<br class="clear" />
<?php
do_action('shopp_customer_editor_settings', $Customer);
}
示例5: country
static function country($data)
{
$countries = Lookup::countries();
if (isset($countries[$data->country])) {
return $countries[$data->country]['name'];
}
return $data->country;
}
示例6: testItems
public function testItems()
{
$items = Lookup::items('CrashReportStatus');
$this->assertTrue($items[1] == 'Waiting');
Lookup::reset();
$items = Lookup::items('BugStatus', Bug::STATUS_OPEN_MAX);
$this->assertTrue($items[1] == 'New');
$this->assertTrue(count($items) == 4);
}
示例7: saveLookup
public function saveLookup($key)
{
try {
$lookup = $this->find('content=:content', array(':content' => $key));
if (isset($lookup) && !is_null($lookup)) {
$lookup->search_count = $lookup->search_count + 1;
$lookup->last_search_date = new CDbExpression('NOW()');
$lookup->save();
} else {
$lookup = new Lookup();
$lookup->search_count = 1;
$lookup->last_search_date = new CDbExpression('NOW()');
$lookup->content = $key;
$lookup->keyword_order = 1;
$lookup->save();
}
} catch (Exception $e) {
}
}
示例8: actionSearch
function actionSearch()
{
header('Content-type: application/json');
// if(Yii::app()->user->isGuest){
// IjoyPlusServiceUtils::exportServiceError(Constants::SEESION_IS_EXPIRED);
// return ;
// }
if (!IjoyPlusServiceUtils::validateAPPKey()) {
IjoyPlusServiceUtils::exportServiceError(Constants::APP_KEY_INVALID);
return;
}
$keyword = Yii::app()->request->getParam("keyword");
if (!(isset($keyword) && !is_null($keyword) && strlen($keyword) > 0)) {
IjoyPlusServiceUtils::exportServiceError(Constants::KEYWORD_IS_NULL);
return;
}
$keyword = trim($keyword);
Lookup::model()->saveLookup($keyword);
if (!FilterUtils::keyWordValid($keyword)) {
IjoyPlusServiceUtils::exportEntity(array('results' => array()));
return;
}
// $keyword= iconv("GBK","UTF-8",$keyword);n
// var_dump($keyword);
//$keyword='???';
// var_dump($keyword);
$keyword = strtr($keyword, array('%' => '\\%', '_' => '\\_'));
// var_dump($keyword);
$page_size = Yii::app()->request->getParam("page_size");
$page_num = Yii::app()->request->getParam("page_num");
if (!(isset($page_size) && is_numeric($page_size))) {
$page_size = 10;
$page_num = 1;
} else {
if (!(isset($page_num) && is_numeric($page_num))) {
$page_num = 1;
}
}
$type = Yii::app()->request->getParam("type");
try {
if (is_null($type) || $type == '') {
$prods = SearchManager::searchProgram($keyword, $page_size, $page_size * ($page_num - 1));
} else {
$prods = SearchManager::searchProgramByType($keyword, $type, $page_size, $page_size * ($page_num - 1));
}
if (isset($prods) && is_array($prods)) {
IjoyPlusServiceUtils::exportEntity(array('results' => $prods));
} else {
IjoyPlusServiceUtils::exportEntity(array('results' => array()));
}
} catch (Exception $e) {
var_dump($e);
IjoyPlusServiceUtils::exportServiceError(Constants::SYSTEM_ERROR);
}
}
示例9: screen
public function screen()
{
$Shopp = Shopp::object();
if (!current_user_can('shopp_settings_checkout')) {
wp_die(__('You do not have sufficient permissions to access this page.'));
}
$purchasetable = ShoppDatabaseObject::tablename(ShoppPurchase::$table);
$next = sDB::query("SELECT IF ((MAX(id)) > 0,(MAX(id)+1),1) AS id FROM {$purchasetable} LIMIT 1");
$next_setting = shopp_setting('next_order_id');
if ($next->id > $next_setting) {
$next_setting = $next->id;
}
$term_recount = false;
if (!empty($_POST['save'])) {
check_admin_referer('shopp-setup-management');
$next_order_id = $_POST['settings']['next_order_id'] = intval($_POST['settings']['next_order_id']);
if ($next_order_id >= $next->id) {
if (sDB::query("ALTER TABLE {$purchasetable} AUTO_INCREMENT=" . sDB::escape($next_order_id))) {
$next_setting = $next_order_id;
}
}
$_POST['settings']['order_shipfee'] = Shopp::floatval($_POST['settings']['order_shipfee']);
// Recount terms when this setting changes
if (isset($_POST['settings']['inventory']) && $_POST['settings']['inventory'] != shopp_setting('inventory')) {
$term_recount = true;
}
shopp_set_formsettings();
$this->notice(Shopp::__('Management settings saved.'), 'notice', 20);
}
if ($term_recount) {
$taxonomy = ProductCategory::$taxon;
$terms = get_terms($taxonomy, array('hide_empty' => 0, 'fields' => 'ids'));
if (!empty($terms)) {
wp_update_term_count_now($terms, $taxonomy);
}
}
$states = array(__('Map the label to an order state:', 'Shopp') => array_merge(array('' => ''), Lookup::txnstatus_labels()));
$statusLabels = shopp_setting('order_status');
$statesLabels = shopp_setting('order_states');
$reasonLabels = shopp_setting('cancel_reasons');
if (empty($reasonLabels)) {
$reasonLabels = array(__('Not as described or expected', 'Shopp'), __('Wrong size', 'Shopp'), __('Found better prices elsewhere', 'Shopp'), __('Product is missing parts', 'Shopp'), __('Product is defective or damaaged', 'Shopp'), __('Took too long to deliver', 'Shopp'), __('Item out of stock', 'Shopp'), __('Customer request to cancel', 'Shopp'), __('Item discontinued', 'Shopp'), __('Other reason', 'Shopp'));
}
$promolimit = array('1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '15', '20', '25');
$lowstock = shopp_setting('lowstock_level');
if (empty($lowstock)) {
$lowstock = 0;
}
include $this->ui('management.php');
}
示例10: actionAvatars
public function actionAvatars()
{
$this->layout = '//layouts/blank';
$dataProvider = null;
if (isset($_GET['uid'])) {
$id = $_GET['uid'];
$type = $_GET['type'] ? $_GET['type'] : Lookup::USER_PIC_FOLDER;
$lookup = Lookup::model()->find(array('condition' => 'uid = :uid AND type = :type', 'params' => array(':uid' => $id, ':type' => $type)));
if ($lookup !== null) {
$pid = $lookup->id;
$criteria = new CDbCriteria(array('condition' => 'pid = :pid AND uid = :uid', 'order' => 'id DESC', 'params' => array(':pid' => $pid, ':uid' => $id)));
$count = File::model()->count($criteria);
$pages = new CPagination($count);
// results per page
$pages->pageSize = 14;
$pages->applyLimit($criteria);
$dataProvider = new CActiveDataProvider('File', array('criteria' => $criteria, 'pagination' => $pages));
}
}
$this->render('avatars', array('dataProvider' => $dataProvider));
}
示例11: actionAdmin
/**
* Manages all models.
*/
public function actionAdmin()
{
$all = Lookup::model()->getAll();
Y::dump($all);
$model = new Portfolio('search');
$model->unsetAttributes(); // clear any default values
$model = $model->current($cat);
if (isset($_GET['Portfolio']))
$model->attributes=$_GET['Portfolio'];
if (isset($_GET['ajax'])) {
$this->renderPartial('admingrid',array(
'model'=>$model,
));
} else {
$this->render('admin',array(
'model'=>$model,
'cat'=>$cat
));
}
}
示例12:
'value' => 'CHtml::link(CHtml::encode($data->username),Users::url("admin/view",array("id"=>$data->id)))',
),
array(
'name'=>'email',
'type'=>'raw',
'value'=>'CHtml::link(CHtml::encode($data->email), "mailto:".$data->email)',
),
array(
'name'=>'status',
'value'=>'User::itemAlias("UserStatus",$data->status)',
'filter'=>User::aliases('UserStatus'),
),
array(
'name'=>'role',
'type'=>'raw',
'value'=>'Lookup::item("role",$data->role)',
'filter'=>Lookup::items('role'),
),
array(
'name' => 'createtime',
'value' => 'date("d.m.Y H:i:s",$data->createtime)',
),
array(
'name' => 'lastvisit',
'value' => '($data->lastvisit?date("d.m.Y H:i:s",$data->lastvisit):Users::t("Not visited"))',
),
array(
'class'=>'CButtonColumn',
),
),
)); ?>
示例13: orders_widget
/**
* Renders the recent orders dashboard widget
*
* @author Jonathan Davis
* @since 1.0
*
* @return void
**/
public static function orders_widget($args = false)
{
$defaults = array('before_widget' => '', 'before_title' => '', 'widget_name' => '', 'after_title' => '', 'after_widget' => '');
$args = array_merge($defaults, (array) $args);
extract($args, EXTR_SKIP);
$statusLabels = shopp_setting('order_status');
echo $before_widget;
echo $before_title;
echo $widget_name;
echo $after_title;
$purchasetable = ShoppDatabaseObject::tablename(ShoppPurchase::$table);
$purchasedtable = ShoppDatabaseObject::tablename(Purchased::$table);
$txnlabels = Lookup::txnstatus_labels();
if (!($Orders = get_transient('shopp_dashboard_orders'))) {
$Orders = sDB::query("SELECT p.*,count(*) as items FROM (SELECT * FROM {$purchasetable} WHERE txnstatus != 'purchased' AND txnstatus != 'invoiced' ORDER BY created DESC LIMIT 6) AS p LEFT JOIN {$purchasedtable} AS i ON i.purchase=p.id GROUP BY p.id ORDER BY p.id DESC", 'array');
set_transient('shopp_dashboard_orders', $Orders, 90);
// Keep for the next 1 minute
}
if (!empty($Orders)) {
echo '<table class="widefat">' . '<thead>' . ' <tr>' . ' <th scope="col">' . __('Name', 'Shopp') . '</th>' . ' <th scope="col">' . __('Date', 'Shopp') . '</th>' . ' <th scope="col" class="num">' . Shopp::__('Items') . '</th>' . ' <th scope="col" class="num">' . Shopp::__('Total') . '</th>' . ' <th scope="col" class="num">' . Shopp::__('Status') . '</th>' . ' </tr>' . '</thead>' . ' <tbody id="orders" class="list orders">';
$even = false;
foreach ($Orders as $Order) {
$classes = array();
if ($even = !$even) {
$classes[] = 'alternate';
}
$txnstatus = isset($txnlabels[$Order->txnstatus]) ? $txnlabels[$Order->txnstatus] : $Order->txnstatus;
$status = isset($statusLabels[$Order->status]) ? $statusLabels[$Order->status] : $Order->status;
$contact = '' == $Order->firstname . $Order->lastname ? '(no contact name)' : $Order->firstname . ' ' . $Order->lastname;
$url = add_query_arg(array('page' => ShoppAdmin()->pagename('orders'), 'id' => $Order->id), admin_url('admin.php'));
$classes[] = strtolower(preg_replace('/[^\\w]/', '_', $Order->txnstatus));
echo '<tr class="' . join(' ', $classes) . '">' . ' <td><a class="row-title" href="' . $url . '" title="View "Order ' . $Order->id . '"">' . (empty($Order->firstname) && empty($Order->lastname) ? '(no contact name)' : $Order->firstname . ' ' . $Order->lastname) . '</a></td>' . ' <td>' . date("Y/m/d", mktimestamp($Order->created)) . '</td>' . ' <td class="num items">' . $Order->items . '</td>' . ' <td class="num total">' . money($Order->total) . '</td>' . ' <td class="num status">' . $statusLabels[$Order->status] . '</td>' . '</tr>';
}
echo '</tbody></table>';
} else {
echo '<p>' . Shopp::__('No orders, yet.') . '</p>';
}
echo $after_widget;
}
示例14: behaviors
/**
* Queues Shopp storefront javascript and styles as needed
*
* @author Jonathan Davis
* @since 1.1
*
* @return void
**/
public function behaviors()
{
$Shopp = Shopp::object();
if (is_ssl()) {
$urls = array('option_siteurl', 'option_home', 'option_url', 'option_wpurl', 'option_stylesheet_url', 'option_template_url', 'script_loader_src');
foreach ($urls as $filter) {
add_filter($filter, 'force_ssl');
}
}
// Replace the WordPress canonical link
remove_action('wp_head', 'rel_canonical');
add_action('wp_head', array($this, 'header'));
add_action('wp_footer', array($this, 'footer'));
wp_enqueue_style('shopp.catalog', SHOPP_ADMIN_URI . '/styles/catalog.css', array(), 20110511, 'screen');
wp_enqueue_style('shopp.icons', SHOPP_ADMIN_URI . '/styles/icons.css', array(), 20110511, 'screen');
wp_enqueue_style('shopp', Shopp::template_url('shopp.css'), array(), 20110511, 'screen');
wp_enqueue_style('shopp.colorbox', SHOPP_ADMIN_URI . '/styles/colorbox.css', array(), 20110511, 'screen');
$orderhistory = is_account_page() && isset($_GET['id']) && !empty($_GET['id']);
if (is_thanks_page() || $orderhistory) {
wp_enqueue_style('shopp.printable', SHOPP_ADMIN_URI . '/styles/printable.css', array(), 20110511, 'print');
}
$loading = shopp_setting('script_loading');
if (!$loading || 'global' == $loading || !empty($page)) {
shopp_enqueue_script('colorbox');
shopp_enqueue_script('shopp');
shopp_enqueue_script('catalog');
shopp_enqueue_script('cart');
if (is_catalog_page()) {
shopp_custom_script('catalog', "var pricetags = {};\n");
}
}
if (is_checkout_page()) {
shopp_enqueue_script('address');
shopp_enqueue_script('checkout');
}
if (is_confirm_page()) {
shopp_enqueue_script('checkout');
}
if (is_account_page()) {
shopp_enqueue_script('address');
$regions = Lookup::country_zones();
$js = 'var regions=' . json_encode($regions);
add_storefrontjs($js, true);
}
}
示例15: state
/**
* Helper method to render markup for state/province input fields
*
* @internal
* @since 1.3
*
* @param string $result The output
* @param array $options The options
* - **mode**: `input` (input, value) Displays the field `input` or the current value of the property
* - **type**: `menu` (menu, text) Changes the input type to a drop-down menu or text input field
* - **options**: A comma-separated list of options for the drop-down menu when the **type** is set to `menu`
* - **required**: `auto` (auto,on,off) Sets the field to be required automatically, always `on` or disabled `off`
* - **class**: The class attribute specifies one or more class-names for the input
* - **label**: The label shown as the default option of the drop-down menu when the **type** is set to `menu`
* - **address**: `billing` (billing,shipping) Used to specify which address the field takes input for
* @param ShoppCustomer $O The working object
* @return string The state input markup
**/
private static function state($result, $options, $O)
{
$defaults = array('mode' => 'input', 'type' => 'menu', 'options' => '', 'required' => 'auto', 'class' => '', 'label' => '', 'address' => 'billing');
$options = array_merge($defaults, $options);
$options['address'] = self::valid_address($options['address']);
$Address = self::AddressObject($options['address']);
if (!isset($options['value'])) {
$options['value'] = $Address->state;
}
$options['selected'] = $options['value'];
$options['id'] = "{$options['address']}-state";
extract($options, EXTR_SKIP);
if ('value' == $mode) {
return $value;
}
$countries = (array) shopp_setting('target_markets');
$select_attrs = array('title', 'required', 'class', 'disabled', 'required', 'size', 'tabindex', 'accesskey');
$country = ShoppBaseLocale()->country();
if (!empty($Address->country)) {
$country = $Address->country;
}
if (!array_key_exists($country, $countries)) {
$country = key($countries);
}
$regions = Lookup::country_zones();
$states = isset($regions[$country]) ? $regions[$country] : array();
if (!empty($options['options']) && empty($states)) {
$states = explode(',', $options['options']);
}
$classes = false === strpos($class, ' ') ? explode(' ', $class) : array();
$classes[] = $id;
if ('auto' == $required) {
unset($options['required']);
// prevent inputattrs from handling required=auto
$classes[] = 'auto-required';
}
$options['class'] = join(' ', $classes);
if ('text' == $type) {
return '<input type="text" name="' . $address . '[state]" id="' . $id . '" ' . inputattrs($options) . '/>';
}
$options['disabled'] = 'disabled';
$options['class'] = join(' ', array_merge($classes, array('disabled', 'hidden')));
$result = '<select name="' . $address . '[state]" id="' . $id . '-menu" ' . inputattrs($options, $select_attrs) . '>' . '<option value="">' . $label . '</option>' . (!empty($states) ? menuoptions($states, $selected, true) : '') . '</select>';
unset($options['disabled']);
$options['class'] = join(' ', $classes);
$result .= '<input type="text" name="' . $address . '[state]" id="' . $id . '" ' . inputattrs($options) . '/>';
return $result;
}